# informat.company 团队

## 概述

使用`informat.company`对象进行团队相关操作。

## getCompany

查询当前团队信息

```javascript
informat.company.getCompany();
```

**返回值**

类型为[Company](/guide/script/model.md#company)，返回团队

**示例**

::: code-group

```javascript [调用]
informat.company.getCompany();
```
```json [返回值]
{
  "createAccountId": "wcueuhi1ib6ul",
  "createTime": 1664196760747,
  "dbIndex": 0,
  "favicon": "0238219de8614a6a8a27db74d2dfc82a.jpg",
  "id": "g09aj7cus3d8s",
  "maxApplicationNum": 0,
  "maxUserNum": 10000,
  "name": "深圳交付团队UAT",
  "updateTime": 1683595804684,
  "version": "enterprise"
}
```
:::

## queryRoleList

查询团队角色列表

```javascript
informat.company.queryRoleList()
```

**返回值**

类型为Array<[Role](/guide/script/model.md#role)>，返回所有角色

**示例**

::: code-group

```javascript [调用]
informat.company.queryRoleList()
```
```json [返回值]
[
  {
    "admin": true,
    "createTime": 1664196760903,
    "id": "admin",
    "isAdmin": true,
    "name": "管理员",
    "permissionIds": []
  },
  {
    "admin": false,
    "createTime": 1664196760907,
    "id": "member",
    "isAdmin": false,
    "name": "成员",
    "permissionIds": [
      "InviteMember"
    ]
  },
  {
    "admin": false,
    "createTime": 1670301261933,
    "id": "supplier",
    "isAdmin": false,
    "name": "供应商",
    "permissionIds": [
      "InviteMember"
    ]
  }
]
```
:::

## addCompanyMember

将账号添加到团队成员列表中

```javascript
informat.company.addCompanyMember(accountId, departmentList, roleList)
```

::: tip 提醒
添加账号到团队成员中会受到license中团队成员数量的限制，如果团队成员数量超过license的限制则添加不成功
:::

| 参数             | 类型              | 描述                        |
|----------------|-----------------|---------------------------|
| accountId      | `String`        | 账号ID                      |
| departmentList | `Array<String>` | 部门ID列表，如果列表为空，则用户会被加入到根部门 |
| roleList       | `Array<String>` | 角色ID列表                    |

**示例**

```javascript
informat.company.addCompanyMember('zhangsan', ['yanfabu'], ['tester']);
```

## deleteCompanyMember

将账号从团队成员中移除

```javascript
informat.company.deleteCompanyMember(accountId)
```

| 参数        | 类型       | 描述   |
|-----------|----------|------|
| accountId | `String` | 账号ID |

**返回值**

类型为`Boolean`，返回是否移除成功

**示例**

::: code-group

```javascript [调用]
informat.company.deleteCompanyMember('zhangsan');
```
```text [返回值]
true
```
:::

## updateCompanyMember

更新团队成员

```javascript
informat.company.updateCompanyMember(member)
```

| 参数     | 类型                                       | 描述   |
|--------|------------------------------------------|------|
| member | [CompanyMember](/guide/script/model.md#companymember) | 团队成员 |

**示例**

```javascript
informat.company.updateCompanyMember({
    id: 'zhangsan',
    departmentList: ['yanfabu', 'yunyingbu'],
    roleList: ['tester', 'devopser'],
    leaderList: ['lisi'],
    dingtalkUserId: 'zhangsan',
    weworkUserId: 'eobg38987',
    feishuUserId: 'ecbg46933',
});
```

## queryCompanyMemberList

查询团队成员列表

```javascript
informat.company.queryCompanyMemberList(query)
```

| 参数    | 类型                               | 描述     |
|-------|----------------------------------|--------|
| query | [Query](/guide/script/model.md#query) | 团队成员查询条件 |

**返回值**
类型Array<[CompanyMember](/guide/script/model.md#companymember)>，团队成员列表

**示例**

::: code-group

```javascript [调用]
informat.company.queryCompanyMemberList({
	pageIndex:1,
	pageSize:100,
	filter:{
		conditionList:[{
			"fieldId":"weworkUserId",
			"opt":"isnull"
		}]
	}
});
```
```json [返回值]
[
  {
    "createTime": 1700628322740,
    "departmentKeyList": [
      "root"
    ],
    "departmentList": [
      "acocdpvd8d6a6"
    ],
    "id": "zhangsan",
    "name": "张三",
    "rowNumber": 5,
    "updateTime": 1700820250268
  }
]
```
:::

## queryCompanyMemberListCount

查询团队成员列表数量

```javascript
informat.company.queryCompanyMemberListCount(filter)
```

| 参数    | 类型                                       | 描述     |
|-------|------------------------------------------|--------|
| filter | [Filter](/guides/script/model.md#filter) | 团队成员查询过滤器 |

**返回值**

类型为`Integer`，返回匹配到的总数

**示例**

::: code-group

```javascript [调用]
informat.company.queryCompanyMemberListCount(
	{
		conditionList:[{
			"fieldId":"weworkUserId",
			"opt":"isnull"
		}]
	}
);
```
```text [返回值]
2
```
:::

## queryAppGroupById

通过ID查询应用分组

```javascript
informat.company.queryAppGroupById(id)
```

| 参数    | 类型              | 描述     |
|-------|-----------------|--------|
| id | `String` | 应用分组ID |


**返回值**

类型为[AppGroup](/guide/script/model.md#appgroup)，返回应用分组

**示例**


::: code-group

```javascript [调用]
informat.company.queryAppGroupById('ruh8zp94ke3p0');
```
```json [返回值]
{
  "createTime": 1700628428167,
  "id": "qvwfhdf328lex",
  "name": "演示（gitee上有链接，供客户安装）",
  "rowNumber": 1,
  "updateTime": 1717149133338
}
```
:::

## queryAppGroupList

查询应用分组列表

```javascript
informat.company.queryAppGroupList(query)
```

| 参数    | 类型              | 描述     |
|-------|-----------------|--------|
| query | [Query](/guide/script/model.md#query) | 查询条件 |

**返回值**

类型为Array<[AppGroup](/guide/script/model.md#appgroup)>，返回应用分组列表

**示例**

::: code-group

```javascript [调用]
informat.company.queryAppGroupList({
	pageIndex:1,
	pageSize:100,
	filter:{
		conditionList:[{
			"fieldId": "name",
			"opt":"isnotnull"
		}]
	}
});
```
```json [返回值]
[
  {
    "createTime": 1717146091865,
    "id": "sjppghi7ofsci",
    "name": "⚠️案例-项目管理",
    "rowNumber": 5,
    "updateTime": 1717660920434
  },
  {
    "createTime": 1717660867337,
    "id": "mjeb7d6mnrsi7",
    "name": "⚠️案例-生产制造2",
    "rowNumber": 8,
    "updateTime": 1717660937343
  }
]
```
:::

## queryAppGroupListCount

查询应用分组列表数量

```javascript
informat.company.queryAppGroupListCount(filter)
```

| 参数    | 类型                                | 描述     |
|-------|-----------------------------------|--------|
| filter | [Filter](/guide/script/model.md#filter) | 查询过滤器 |

**返回值**

类型为`Integer`，返回匹配到的总数

**示例**

::: code-group

```javascript [调用]
informat.company.queryAppGroupListCount({
      conditionList:[{
        "fieldId":"name",
        "opt":"contains",
        "value":"案例"
      }]
    }
)
```
```text [返回值]
4
```
:::

## addAppGroup

创建应用分组

```javascript
informat.company.addAppGroup(group);
```

| 参数     | 类型     | 描述             |
| -------- | -------- | ---------------- |
| group | [AppGroup](/guide/script/model.md#appgroup) | 应用分组 |

**返回值**

类型`String`，新增应用分组的ID

**示例**

::: code-group

```javascript [调用]
informat.company.addAppGroup({
	'name':'测试分组'
});
```
```text [返回值]
qunzjrmed162w
```
:::

## updateAppGroup

编辑应用分组

```javascript
informat.company.updateAppGroup(group);
```

| 参数     | 类型     | 描述             |
| -------- | -------- | ---------------- |
| group | [AppGroup](/guide/script/model.md#appgroup)| 应用分组 |

**返回值**

类型`Integer`，编辑成功的分组数量

::: code-group

```javascript [调用]
informat.company.updateAppGroup({
	'id':'qunzjrmed162w',
	'name':'测试分组2'
})
```
```text [返回值]
1
```
:::

## deleteAppGroup

删除应用分组

```javascript
informat.company.deleteAppGroup(id);
```
::: warning
分组下有应用则不能删除
:::


| 参数     | 类型     | 描述             |
| -------- | -------- | ---------------- |
| id | `String` | 应用分组ID |

**返回值**

类型为`Integer`，删除成功的分组数量

**示例**

::: code-group

```javascript [调用]
informat.company.deleteAppGroup('qunzjrmed162w');
```
```text [返回值]
1
```
:::

## queryAppList

查询应用列表

```javascript
informat.company.queryAppList(query)
```

| 参数    | 类型              | 描述     |
|-------|-----------------|--------|
| query | [Query](/guide/script/model.md#query) | 查询条件 |

**返回值** 

类型为Array<[Application](/guide/script/model.md#app)）>，返回应用列表

**示例**

::: code-group

```javascript [调用]
informat.company.queryAppList({
	pageIndex:1,
	pageSize:100,
	filter:{
		conditionList:[{
			"fieldId":"name",
			"opt":"contains",
			"value":"测试"
		}]
	}
});
```
```json [返回值]
[
  {
    "appDefineId": "com.mycompany",
    "color": "c7",
    "createAccountId": "zhangsan",
    "createTime": 1680006873433,
    "icon": "home",
    "id": "ftegr30w93jya",
    "name": "测试一下",
    "updateAccountId": "zhangsan",
    "updateTime": 1696919628896
  },
  {
    "appDefineId": "cn.informat.test",
    "color": "c1",
    "createAccountId": "zhangsan",
    "createTime": 1664258560997,
    "icon": "community",
    "id": "btz5tka89273q",
    "name": "全字段测试",
    "updateAccountId": "zhangsan",
    "updateTime": 1696919628886
  }
]
```
:::

## queryAppListCount

查询应用列表数量

```javascript
informat.company.queryAppListCount(filter)
```

| 参数    | 类型              | 描述     |
|-------|-----------------|--------|
| filter | [Filter](/guide/script/model.md#filter) | 查询过滤器 |

**返回值**

类型为`Integer`，返回匹配到的总数

**示例**

::: code-group

```javascript [调用]
informat.company.queryAppListCount(
	{
		conditionList:[{
			"fieldId":"name",
			"opt":"contains",
			"value":"测试"
		}]
	}
);
```
```text [返回值]
2
```
:::

## installApp

安装应用

```javascript
informat.company.installApp(req);
```

| 参数     | 类型                                           | 描述             |
| -------- |----------------------------------------------| ---------------- |
| req | [InstallAppRequest](/guide/script/model.md#installapprequest) | 安装信息 |

**返回值**

类型为`String`, 新安装的应用ID

**示例**

::: code-group

```javascript [调用]
let company = informat.company.getCompany();
informat.company.installApp({
	'groupId': company.id,
	'imrUrl':'https://next.inforamt.cn/test.imr'
});
```
```text [返回值]
uzafvisn1whcq
```
:::

## uninstallApp

卸载应用

```javascript
informat.company.uninstallApp(appId);
```

| 参数     | 类型     | 描述             |
| -------- | -------- | ---------------- |
| appId | `String` | 应用ID |


**示例**

```javascript
informat.company.uninstallApp('uzafvisn1whcq');
```

## getUserAppList

查询用户可以访问的应用列表

```javascript
informat.company.getUserAppList(accountId)
```

| 参数    | 类型              | 描述     |
|-------|-----------------|--------|
| accountId | `String` | 账号ID |

**返回值** 

类型为[UserAppList](/guide/script/model.md#userapplist)，返回应用列表

**示例**

::: code-group

```javascript [调用]
informat.company.getUserAppList('zhangsan');
```
```json [返回值]
{
	"appGroupList":[
		{
			"createTime":1737464180983,
			"id":"nj4h8ci8kjpsu",
			"name":"演示应用",
			"rowNumber":1,
			"updateTime":1738810011210
		},
		{
			"createTime":1717142070955,
			"id":"qdjpyk2iw8zzt",
			"name":"开发迭代",
			"rowNumber":2,
			"updateTime":1738810011216
		}
	],
	"appList":[
		{
			"appDefineBuild":920,
			"appDefineEditable":true,
			"appDefineId":"com.demo.srm",
			"appDefineVersion":"1.0",
			"color":"c1",
			"createAccountId":"lwfwqr67xsvup",
			"createTime":1725441476365,
			"enableAppJsonLog":false,
			"enableAppLog":false,
			"icon":"instance-fill",
			"id":"dvl8ig0j3odwh",
			"logLevel":"DEBUG",
			"name":"功能演示-供应商管理",
			"groupId":"nj4h8ci8kjpsu",
			"updateTime":1739861044583
		},
		{
			"appDefineBuild":54,
			"appDefineEditable":true,
			"appDefineId":"demoApp.pm",
			"appDefineVersion":"1.0",
			"color":"c2",
			"createTime":1725503438313,
			"enableAppJsonLog":false,
			"enableAppLog":false,
			"icon":"task",
			"id":"m4mfdpi5plchm",
			"logLevel":"DEBUG",
			"name":"功能演示-项目管理",
			"groupId":"nj4h8ci8kjpsu",
			"updateTime":1740559881456
		}
	]
}
```
:::
