admin
2021-12-09 f609ca35ee2946acd0ff04b7ac1aa61f75a2e4a1
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
81
82
83
84
85
86
87
88
89
90
package com.ks.app.controller.client.api;
 
import com.ks.app.entity.config.SystemConfigKey;
import com.ks.app.service.inter.config.SystemConfigService;
import com.ks.app.vo.AcceptData;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.yeshi.utils.JsonUtil;
import org.yeshi.utils.StringUtil;
 
import javax.annotation.Resource;
 
/**
 * @author hxh
 * @title: ConfigController
 * @description: 配置信息接口
 * @date 2021/11/16 17:37
 */
@Controller
@RequestMapping("api/v1/config")
public class ConfigController {
 
    @Resource
    private SystemConfigService systemConfigService;
 
    /**
     * @return java.lang.String
     * @author hxh
     * @description 建议
     * @date 13:15 2021/12/2
     * @param: acceptData
     **/
    @RequestMapping("getConfig")
    @ResponseBody
    public String getConfig(AcceptData acceptData) {
        com.alibaba.fastjson.JSONObject data = new com.alibaba.fastjson.JSONObject();
 
        SystemConfigKey[] configs = new SystemConfigKey[]{
                SystemConfigKey.kefu,
                SystemConfigKey.course,
                SystemConfigKey.unRegister,
                SystemConfigKey.privacyComplain,
                SystemConfigKey.vipLink
        };
 
        for (SystemConfigKey config : configs) {
            String value = systemConfigService.getValueCache(acceptData.getSystem(), config);
            data.put(config.name(), value);
        }
 
        //TODO 广告K接口配置
        SystemConfigKey[] ads = new SystemConfigKey[]{
 
        };
 
        for (SystemConfigKey ad : ads) {
            String value = systemConfigService.getValueCache(acceptData.getSystem(), ad);
            JSONObject valueJSON = JSONObject.fromObject(value);
 
            String channel = acceptData.getChannel();
            if (StringUtil.isNullOrEmpty(channel) || valueJSON.optJSONObject(channel) == null) {
                channel = "qq";
            }
 
            valueJSON = valueJSON.optJSONObject(channel.toLowerCase());
            if (valueJSON != null) {
                if (acceptData.getVersion() <= valueJSON.optInt("version")) {
                    String pid = valueJSON.optString("pid");
                    String type = valueJSON.optString("type");
                    valueJSON = new JSONObject();
                    valueJSON.put("pid", pid);
                    valueJSON.put("type", type);
                } else {
                    valueJSON = null;
                }
            }
 
            if (valueJSON != null) {
                data.put(ad.name().replace("ad_", ""), valueJSON.toString());
            }
        }
 
 
        return JsonUtil.loadTrueResult(data);
    }
 
 
}