package com.yeshi.location.app.controller.client.api;
|
|
import com.yeshi.location.app.entity.config.SystemConfigKey;
|
import com.yeshi.location.app.entity.feedback.Advice;
|
import com.yeshi.location.app.entity.feedback.PrivacyComplain;
|
import com.yeshi.location.app.service.inter.config.SystemConfigService;
|
import com.yeshi.location.app.service.inter.feedback.AdviceService;
|
import com.yeshi.location.app.service.inter.feedback.PrivacyComplainService;
|
import com.yeshi.location.app.vo.AcceptData;
|
import net.sf.json.JSONArray;
|
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;
|
import java.util.ArrayList;
|
import java.util.List;
|
|
/**
|
* @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,
|
SystemConfigKey.sdkList
|
};
|
|
for (SystemConfigKey config : configs) {
|
String value = systemConfigService.getValueCache(acceptData.getSystem(), config);
|
data.put(config.name(), value);
|
}
|
|
SystemConfigKey[] ads = new SystemConfigKey[]{
|
SystemConfigKey.ad_homeInterstitial,
|
SystemConfigKey.ad_mineExpress,
|
SystemConfigKey.ad_searchExpress,
|
SystemConfigKey.ad_searchResultBanner,
|
SystemConfigKey.ad_splash,
|
SystemConfigKey.ad_travelShareInterstitial,
|
SystemConfigKey.ad_vipReward
|
};
|
|
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);
|
}
|
|
|
}
|