[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]: # ({49b88fb8-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]: # ({/49b88fb8-3ff1a765})

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

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

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

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

[comment]: # ({/b41637d2-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})
