doum
13 小时以前 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
package com.doumee.core.jiandaoyun.api.jdy;
 
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import  com.doumee.core.jiandaoyun.model.base.PageBaseParam;
import  com.doumee.core.jiandaoyun.model.http.ApiClient;
import  com.doumee.core.jiandaoyun.model.http.HttpRequestParam;
 
import java.util.Collections;
import java.util.List;
import java.util.Map;
 
import static com.doumee.core.jiandaoyun.constants.HttpConstant.APP_BASE_PATH;
 
 
/**
 * 应用相关接口
 */
public class AppApiClient extends ApiClient {
 
    private static final String DEFAULT_VERSION = "v5";
    private static final List<String> VALID_VERSION_LIST = Collections.singletonList("v5");
 
    public AppApiClient(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) + APP_BASE_PATH + path;
    }
 
    /**
     * 应用分页列表
     *
     * @param queryParam - 查询参数
     * @return 应用信息
     */
    public Map<String, Object> appList(PageBaseParam queryParam, String version) throws Exception {
        if (queryParam == null || !queryParam.isValid()) {
            throw new RuntimeException("param lack!");
        }
        String path = this.generatePath(version, "list");
        // 请求参数 将 queryParam 里面的属性转换成map
        Map<String, Object> data =
                new ObjectMapper().convertValue(queryParam, new TypeReference<Map<String, Object>>() {
                });
        HttpRequestParam param = new HttpRequestParam(path, data);
        return this.sendPostRequest(param);
    }
}