[comment]: # translation:outdated

[comment]: # ({8e295f21-f9e8f670})
# 批量添加

[comment]: # ({/8e295f21-f9e8f670})

[comment]: # ({4eebb3e3-b5ff62ed})
### 描述

`object templategroup.massadd(object parameters)`

此方法允许同时向给定的模板组添加多个相关对象.

::: noteclassic
此方法只有Super admin(超级管理员)用户可用. 可以在用户角色设置中撤销调用该方法的权限. 更多信息请查看 [User
roles](/manual/web_interface/frontend_sections/users/user_roles).
:::

[comment]: # ({/4eebb3e3-b5ff62ed})

[comment]: # ({8293b941-3ff1a765})
### 参数

`(object)` 参数包含要更新的模板组ID和要添加到这些模板组中的对象.

该方法接受以下参数.

|参数|[类型](/manual/api/reference_commentary#data_types)|描述|
|--|--|------|
|groups|object/array|要更新的[模板组](/manual/api/reference/templategroup/object#template_group).<br><br>这些模板组只能定义一个`groupid`属性.<br><br>[属性行为](/manual/api/reference_commentary#parameter-behavior):<br>- *必选*|
|templates|object/array|需要被添加到模板组中的[模板](/manual/api/reference/template/object#template).<br><br>这些模板只能定义一个`templateid` 属性.<br><br>[属性行为](/manual/api/reference_commentary#parameter-behavior):<br>- *必选*|

[comment]: # ({/8293b941-3ff1a765})

[comment]: # ({9cf84bdf-cc7938a3})
### 返回值

`(object)` 返回一个对象，该对象包含`groupids`属性下已更新的模板组的ID.

[comment]: # ({/9cf84bdf-cc7938a3})

[comment]: # ({4811a99c-518dc5ee})
### 示例

[comment]: # ({/4811a99c-518dc5ee})

[comment]: # ({d6d75ca0-3954c00e})
#### 将模板添加到模板组中

将两个模板添加到ID为12和13的模板组中.

[请求](/manual/api#performing-requests):

```json
{
    "jsonrpc": "2.0",
    "method": "templategroup.massadd",
    "params": {
        "groups": [
            {
                "groupid": "12"
            },
            {
                "groupid": "13"
            }
        ],
        "templates": [
            {
                "templateid": "10486"
            },
            {
                "templateid": "10487"
            }
        ]
    },
    "id": 1
}
```

响应:

```json
{
    "jsonrpc": "2.0",
    "result": {
        "groupids": [
            "12",
            "13"
        ]
    },
    "id": 1
}
```

[comment]: # ({/d6d75ca0-3954c00e})

[comment]: # ({f3cd9368-d05fe284})
### 参阅

-   [模板](/manual/api/reference/template/object#template)

[comment]: # ({/f3cd9368-d05fe284})

[comment]: # ({afff73ad-47263542})
### 来源
CTemplateGroup::massAdd() in *ui/include/classes/api/services/CTemplateGroup.php*.

[comment]: # ({/afff73ad-47263542})
