# 员工信息同步

# 接口URL

  • 测试环境: http://apitest.dudubashi.com/index.php/api/user/admin
  • 线上环境: http://wx.dudubashi.com/index.php/api/user/admin

# 请求方法

post

# 请求参数

名称 类型 说明 是否必须
token string 临时票据(有效期:2小时) Y
user_list string 用户列表(用户json字符串,DES加密后的结果,明细字段参考样例) Y
$user_list = '[
            {
				"job_no":"xxyyzz",         // 工号或OA号或域账号(员工唯一识别号)【必填】
				"flag":"1",                // 用户状态,1:增加,2:修改,3:删除【必填】
				"phone_number":"158****88",// 手机号【可选】
				"user_name":"张三",        // 用户姓名【可选】
				"city":"深圳",             // 城市【可选】
				"card_no":"112233",        // 卡号【可选】
                "feishu_id":"18eb23e1",    // 飞书id (用户id或open_id)【可选】
				"department":"运营部",     // 部门名称【可选】
				"type":"0"                 // 乘车类型,0:普通乘车员工,1:宿舍员工【可选】
            },
            {
				"job_no":"zzyyxx",
				"flag":"1",
				"phone_number":"",
				"user_name":"李四",
				"city":"广州",
				"card_no":"332211",
                "feishu_id":"16eb23e1",
				"department":"平台部",
				"type":"1"
            }
        ]
';

$user_list = php_des_encode($user_list, $app_secrect);

// key = 嘟嘟提供的app_secrect,iv="dudu1234";

# JAVA DEMO

import javax.crypto.*;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.io.UnsupportedEncodingException;
import java.security.*;
import java.util.Arrays;

public class Example {
    public static final String KEY = "3CE00040"; // 8字节字符串
    public static final String IV = "dudu1234"; // 8字节字符串
    public static final String DEFAULT_ENC_NAME = "UTF-8";

    public static String encrypt(String data) {
        try {
            byte[] bytes = data.getBytes(DEFAULT_ENC_NAME);
            Cipher cipher = createCipher(Cipher.ENCRYPT_MODE);
            return byteArrayToHex(cipher.doFinal(bytes));
        } catch (Exception e) {
            throw new RuntimeException("Encryption failed", e);
        }
    }

    public static String byteArrayToHex(byte[] bytes) {
        char[] hexArray = "0123456789abcdef".toCharArray();
        char[] hexChars = new char[bytes.length * 2];
        for (int i = 0; i < bytes.length; i++) {
            int v = bytes[i] & 0xFF;
            hexChars[i * 2] = hexArray[v >>> 4];
            hexChars[i * 2 + 1] = hexArray[v & 0x0F];
        }
        return new String(hexChars);
    }

    private static Cipher createCipher(int mode) throws Exception {
        byte[] key = Arrays.copyOf(KEY.getBytes(DEFAULT_ENC_NAME), 8);
        byte[] iv = Arrays.copyOf(IV.getBytes(DEFAULT_ENC_NAME), 8);
        Cipher cipher = Cipher.getInstance("DES/CBC/PKCS5Padding");
        cipher.init(mode, new SecretKeySpec(key, "DES"), new IvParameterSpec(iv));
        return cipher;
    }

    public static void main(String[] args) {
        String a = "[{\"job_no\":\"ss\",\"card_no\":\"xx\",\"department\":\"厂商\",\"flag\":\"1\"}]";
        System.out.println("原始数据: " + a);
        System.out.println("加密结果: " + encrypt(a));
    }
}

# 返回参数

名称 类型 说明 必须存在
result string 结果状态码('0000': '操作成功') Y
info string 结果提示语 Y
{
    "result": "0000",
    "info": "成功"
}

# 新增部门

# 接口URL

  • 测试环境: http://apitest.dudubashi.com/index.php/api/user/add_department
  • 线上环境: http://wx.dudubashi.com/index.php/api/user/add_department

# 请求方法

post

# 请求参数

名称 类型 说明 是否必须
token string 临时票据(有效期:2小时) Y
department_name string 部门名称 Y

# 返回参数

名称 类型 说明 必须存在
result string 结果状态码('0000': '操作成功') Y
info string 结果提示语 Y
{
    "result": "0000",
    "info": "成功"
}

# 删除部门

# 接口URL

  • 测试环境: http://apitest.dudubashi.com/index.php/api/user/del_department
  • 线上环境: http://wx.dudubashi.com/index.php/api/user/del_department

# 请求方法

post

# 请求参数

名称 类型 说明 是否必须
token string 临时票据(有效期:2小时) Y
department_name string 部门名称 Y

# 返回参数

名称 类型 说明 必须存在
result string 结果状态码('0000': '操作成功') Y
info string 结果提示语 Y
{
    "result": "0000",
    "info": "成功"
}

# 上传员工人脸头像

# 接口URL

  • 测试环境: http://apitest.dudubashi.com/index.php/api/user/save_user_avatar
  • 线上环境: http://wx.dudubashi.com/index.php/api/user/save_user_avatar

# 请求方法

post

# 请求参数

名称 类型 说明 是否必须
token string 临时票据(有效期:2小时) Y
avatar_img string 头像base64值 (如avatar_img_url有数据则优先avatar_img_url,并且忽略avatar_img字段) N
avatar_img_url string 头像链接 (如有数据则优先,并且忽略avatar_img字段) N
open_id string 企业用户开放id,如 工号 Y
phone string 企业用户手机号(open_id 和 phone 二选一) Y

# 返回参数

名称 类型 说明 必须存在
result string 结果状态码('0000': '操作成功') Y
info string 结果提示语 Y
{
    "result": "0000",
    "info": "成功"
}

# 删除员工人脸头像

# 接口URL

  • 测试环境: http://apitest.dudubashi.com/index.php/api/user/del_user_avatar
  • 线上环境: http://wx.dudubashi.com/index.php/api/user/del_user_avatar

# 请求方法

post

# 请求参数

名称 类型 说明 是否必须
token string 临时票据(有效期:2小时) Y
open_id string 企业用户开放id,如 工号 Y
phone string 企业用户手机号(open_id 和 phone 二选一) Y

# 返回参数

名称 类型 说明 必须存在
result string 结果状态码('0000': '操作成功') Y
info string 结果提示语 Y
{
    "result": "0000",
    "info": "成功"
}