package com.malk.server.dingtalk;

import com.malk.utils.UtilMap;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 读取配置文件参考FilePah
 */
@Data
@Component
@ConfigurationProperties(prefix = "dingtalk")
public class DDConf {

    private Number agentId;

    private String appKey;

    private String appSecret;

    private String corpId;

    private String corpToken;

    private String aesKey;

    private String token;

    // 操作人, 需要为OA后台管理员
    private String operator;

    // 机器人编号
    private String robotCode;

    /**
     * 钉钉一级部门: 1
     */
    public static final long TOP_DEPARTMENT = 1L;

    /**
     * 钉钉回调响应
     */
    public static final String CALLBACK_RESPONSE = "success";

    /**
     * 验证注册地址, 通过开发平台配置触发
     */
    public static final String CALLBACK_CHECK = "check_url";

    /**
     * 审批任务回调 [审批任务开始、结束、转交]
     */
    public static final String BPMS_TASK_CHANGE = "bpms_task_change";

    /**
     * 审批实例回调 [审批实例开始、结束]
     */
    public static final String BPMS_INSTANCE_CHANGE = "bpms_instance_change";

    /**
     * token授权参数: 旧版本
     */
    public static Map initTokenParams(String access_token) {
        return UtilMap.map("access_token", access_token);
    }

    /**
     * token授权参数: 新版本
     */
    public static Map initTokenHeader(String access_token) {
        return UtilMap.map("x-acs-dingtalk-access-token", access_token);
    }
}
