跳转至

修改员工

功能说明

根据工号,修改企业平台上员工的信息

  • 工号corp_code只支持字母数字,不区分大小写。新版本以废弃改用userid
  • 手机号mobile(建议填写) 为11位数字,限于运营商因素,国外手机号暂不支持短信通知。

接口地址

HTTP请求方式

  • Method: POST
  • Content-Type: application/x-www-form-urlencoded

参数说明

  • 公有参数

发送请求是必须传入公共参数,详见公共参数

  • 私有参数
参数名称 是否必须 参数类型 长度限制 描述
userid string [1,100] 员工第三方唯一标识,不会变更
enterprise_code string [1,20] 企业编号(集团和运营商必填,企业不填)
third_type int [1,5] 第三方类型,1:企业微信, 2:钉钉,3:飞书,4, 定制, 5:标准对接,非必填默认5
name string [1,50] 员工姓名
code string [1,20] 员工工号
new_corp_code string [1,20] 员工新工号,用于修改工号
gender int [1] 性别,1:男;2:女;3:未知
email string [1,100] 邮箱,企业内唯一
mobile_area int [1,10] 手机区号,国外手机必填,不填默认为国内手机区号(86)
mobile string [6,20] 手机,企业内唯一
remark string [0,254] 备注
dept_code string [1,50] 部门编号
level string [1,50] 员工分级(若传空字符串,则将该员工分级置空)(需先在企业后台开启该功能) ,如果要清空请传#default#
category string [] 员工分类,多个分类,用“,”分割(若传空字符串,则将该员工分类置空)(需先在企业后台开启该功能) ,如果要清空请传#default#
birth_day string [10] 生日,格式为yyyy-MM-dd或者MM-dd,如:1991-01-01或者01-21 ,如果要清空请传#default#
entry_day string [10] 入职日,格式为yyyy-MM-dd,如:2016-02-03 ,如果要清空请传#default#
card_type int [1] 证件类型,1:身份证;2:护照
card_no string [1,30] 证件号码
employee_attribute string 扩展信息,JsonArray,格式如: List«EmployeeAttribute»(需先确认扩展信息已启用的字段,合同性质、固定电话、级别、分类等默认已启用)
cost_center_id int [1,10] 成本中心id,取值范围1~2147483647之间的整数
  • employee_attribute中的EmployeeAttribute对象
参数名称 是否必须 参数类型 长度限制 描述
attributeCode string [1,100] 扩展字段编号,如:contractNature(合同性质) taxpayerMapper(纳税人归属)
attributeValue string [1,100] 扩展字段值,如:contractNature对应: 正式员工,试用员工,临时员工,实习生,兼职员工,外聘员工 taxpayerMapper对应纳税人归属id

请求示例(HTTP)

  POST /employee/update HTTP/1.1
  Host: openapi.guanaitong.tech
  Content-Type: application/x-www-form-urlencoded
  Cache-Control: no-cache

  access_token=d557ea2ff6fb2e78e45e14e8f5062b5a&userid=1001&birth_day=1991-02-20&card_no=371322199105204123&
  card_type=1&corp_code=CJJ200&cost_center_id=1234&departmentId=1797&dept_code=A001&level=S1&email=654321@qq.com&
  entry_day=2016-10-01&gender=1&mobile_area=86&mobile=15588756223&name=zhangSan&new_corp_code=CJJ666&
  timestamp=1492419521&remark=添加员工&sign=07b86548dc6169a07a6d0f2414e46aedd14d4a40&

请求示例(JAVA SDK)

public class Main {
    public static OpenClient openClient = new OpenClient(Constants.BASE_URL_TEST, "xxx", "xxx");
    public static void main(String[] args) {
        EmployeeUpdateRequest employeeUpdateRequest = new EmployeeUpdateRequest();
        employeeUpdateRequest.setUserId("tom0001");
        ArrayList<String> category = new ArrayList<>();
        category.add("帅哥组");
        employeeUpdateRequest.setCategory(category);
        employeeUpdateRequest.setLevel("金丹");
        employeeUpdateRequest.setGender(2);
        employeeUpdateRequest.setBirthDay("1990-06-05");
        employeeUpdateRequest.setEntryDay("2022-06-29");
        employeeUpdateRequest.setCode("tom0002");
        employeeUpdateRequest.setMobile("16898989091");
        ArrayList<EmployeeAttribute> employeeAttribute = new ArrayList<>();
        EmployeeAttribute e = new EmployeeAttribute();
        e.setAttributeCode("politicalVisage");
        e.setAttributeValue("群众");
        employeeAttribute.add(e);
        employeeUpdateRequest.setEmployeeAttribute(employeeAttribute);

        String userid = openClient.employeeApi().update(employeeUpdateRequest);
        System.out.println(userid);
    }
}

返回参数说明

参数名称 描述
code 返回码。详见错误返回码
msg 如果错误,返回错误信息。
data 如果没有错误,返回业务数据-工号。

正确返回示例

{
  "code": 0,
  "data": "CJJ200",
  "msg": "OK"
}

错误返回示例

{
  "code": 1000220102,
  "data": null,
  "msg": "员工不存在"
}

常见错误码

错误码 错误信息 排查方法
1000220002 参数验证不通过 检测参数是否符合要求,如:entryDay日期格式错误, 需要yyyy-MM-dd的日期格式
1000220096 该用户ID对应员工不存在 userid对应员工是否已添加
1000220102 员工不存在 userid对应员工是否已添加
1002219003 员工工号已存在 员工工号已存在,工号企业下唯一
1000220010 dept_code not exists ! 部门编号不存在,校验是否对应部门已添加
1002218004 会员:邮箱已存在 邮箱已存在,邮箱企业下唯一
1002218007 会员:手机已存在 手机已存在,手机号企业下唯一
1002219046 员工身份证号码错误 身份证类型是大陆身份,不符合大陆身份证号格式

护照,只能为1-20位大小写字母和数字
1000220030 该员工分级未设置 需要去企业管理后台设置
1000210028 该员工分类未设置 需要去企业管理后台设置
1000220072 politicalVisage1未启用,扩展信息字段attributeCode错误或未启用 需要去企业管理后台设置
1000240002 enterprise_code校验失败 检查enterprise_code是否是已绑定的编码
1002219069 员工国际区号不存在 对应手机号区号,检查是否是正确的国际电话区号
other 其他公共错误码 其他公共错误码
回到页面顶部