doum
7 小时以前 36f691267e45ca2861bed663fdcf5f2efcefdfce
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package com.doumee.core.jiandaoyun.api.arch;
 
import  com.doumee.core.jiandaoyun.model.http.ApiClient;
import  com.doumee.core.jiandaoyun.model.http.HttpRequestParam;
import org.apache.commons.lang3.StringUtils;
 
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import static  com.doumee.core.jiandaoyun.constants.HttpConstant.CORP_COOP_BASE_PATH;
 
/**
 * 企业互联相关接口
 */
public class CorpCoopApiClient extends ApiClient {
 
    private static final String DEFAULT_VERSION = "v5";
    private static final List<String> VALID_VERSION_LIST = Collections.singletonList("v5");
 
 
    public CorpCoopApiClient(String apiKey, String host) {
        super(apiKey, host);
        this.setDefaultVersion(DEFAULT_VERSION);
        this.setValidVersionList(VALID_VERSION_LIST);
    }
 
    @Override
    public String generatePath(String version, String path) {
        return super.getValidVersion(version) + CORP_COOP_BASE_PATH + path;
    }
 
    /**
     * 列出我连接的企业
     *
     * @param deptNo - 部门编号 可为null
     * @return 我连接的企业
     */
    public Map<String, Object> corpCoopDepartList(Integer deptNo, String version) throws Exception {
        String path = this.generatePath(version, "department/list");
        // 请求参数
        Map<String, Object> data = new HashMap<>();
        data.put("dept_no", deptNo);
        HttpRequestParam param = new HttpRequestParam(path, data);
        return this.sendPostRequest(param);
    }
 
    /**
     * 列出我连接的企业对接人
     *
     * @param deptNo - 部门编号 可为null
     * @return 我连接的企业对接人
     */
    public Map<String, Object> corpCoopMemberList(Integer deptNo, String version) throws Exception {
        String path = this.generatePath(version, "user/list");
        // 请求参数
        Map<String, Object> data = new HashMap<>();
        data.put("dept_no", deptNo);
        HttpRequestParam param = new HttpRequestParam(path, data);
        return this.sendPostRequest(param);
    }
 
    /**
     * 列出我连接的企业对接人详细信息
     *
     * @param userName - 用户名
     */
    public Map<String, Object> corpCoopUserInfo(String userName, String version) throws Exception {
        if (StringUtils.isBlank(userName)) {
            throw new RuntimeException("param lack!");
        }
        String path = this.generatePath(version, "user/get");
        // 请求参数
        Map<String, Object> data = new HashMap<>();
        data.put("username", userName);
        HttpRequestParam param = new HttpRequestParam(path, data);
        return this.sendPostRequest(param);
    }
}