3.9Adding role interface (addRoleInfo)
**Request address:** - `/ivci/api/role/addRoleInfo` **Request mode:** - POST,GET **Parameter Description** |Parameter name|Type|Description|Remark| |:---- |:---|:----- |----- | |content |String |Requested encrypted data |Mandatory | |merchantId |String |Request customer ID of the users | Mandatory | **Remark** Content is decrypted into json format via RSA ``` { "userName":"testuser", "antiFake":"4bbab6ff0d8042548cc6f2df9f3655fa", "timestamp":"20160518165030", "serverIP":"127.0.0.1", "addRole":{ "roleName":"test_role", "roleNote":"test test", "modelIds":"2,3,4,5,6,7,8,9" } } ``` **Content Parameter Description** |Parmeter name|Type|Description|Remark| |:---- |:---|:----- |----- | |userName | String| User name |Mandatory | |antiFake | String | Anti-fake random string | Mandatory | |timestamp | String | Request timestamp, accurate to second | Mandatory | |serverIP | String | Server IP | Mandatory | |deleteRole | json | Add role inforamtion | Mandatory | |addRole.roleNames| String | Add role name |Mandatory| |addRole.roleNote| String | Add description of role |Optional| |addRole.modelIds| String |Add role operation authorization,need calling getRoleOperationAuths, query the current operation permission of users |Mandatory | |addRole.deptId| Int |Create a new role ID, if not specified, the default is the user's department|Optional| **Use examples::** 1. Backend ```java //读取privateKeyStr String privateKey=........... ///Reading privateKeyStr SimpleDateFormat formatter = new SimpleDateFormat ("yyyyMMddHHmmss"); String timestamp=formatter.format(new Date()); String signStr=RSAUtils.sign(timestamp.getBytes(), privateKey); String ip=request.getRemoteAddr(); //Encrypted with private key String ext=",\"deleteRole\":{.............}";//Assemble the role information String dataStr="{\"userName\":\"testuser\",\"antiFake\":\""+signStr+"\",\"timestamp\":\""+timestamp+"\",\"serverIP\":\""+ip+"\" "+ext+" }"; String content=RSAUtils.encryptByPrivateKey(dataStr, privateKey); ``` 2. Front end The backend return the encrypted content to the front end, and then send the requestcalling http://xxxxx/ivci/api/role/delRoleById?merchantId=100000&content=content **Return data** All return data should be in json format ```json {"code":0,"msg":"Operate failed","data":{}} ``` **Return parameter** |Parameter name|Type|Description|Remark| |:---- |:---|:----- |----- | |code | String |Operate result code(success=0,failure=1),refer to appendix 1| Return| |msg| String | Operate return information(Operate succeed,return null;operate failed,return prompt information)| | |data | json | {“roleId’:123456} | | Return data need to be decoded, the decryption process is as follows: ```json String key="......"; String mi="56D56B912C68308AA6D863DE087DBFD82D65C37836FC15E0B92"; String ming=RSAUtils.decryptByPrivateKey(mi, key); ```