Ad展示优化
This commit is contained in:
@@ -2,11 +2,14 @@ package com.jsh.erp.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.datasource.entities.PlatformConfig;
|
||||
import com.jsh.erp.datasource.entities.User;
|
||||
import com.jsh.erp.service.platformConfig.PlatformConfigService;
|
||||
import com.jsh.erp.service.user.UserService;
|
||||
import com.jsh.erp.utils.BaseResponseInfo;
|
||||
import com.jsh.erp.utils.ErpInfo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -24,9 +27,17 @@ import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
|
||||
public class PlatformConfigController {
|
||||
private Logger logger = LoggerFactory.getLogger(PlatformConfigController.class);
|
||||
|
||||
@Value("${demonstrate.open}")
|
||||
private boolean demonstrateOpen;
|
||||
|
||||
@Resource
|
||||
private PlatformConfigService platformConfigService;
|
||||
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
private static final String TEST_USER = "jsh";
|
||||
|
||||
/**
|
||||
* 获取平台名称
|
||||
* @param request
|
||||
@@ -65,6 +76,31 @@ public class PlatformConfigController {
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否显示广告
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/isShowAd")
|
||||
public BaseResponseInfo isShowAd(HttpServletRequest request)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
try {
|
||||
User user = userService.getCurrentUser();
|
||||
if (demonstrateOpen && TEST_USER.equals(user.getLoginName())) {
|
||||
res.code = 200;
|
||||
res.data = true;
|
||||
} else {
|
||||
res.code = 200;
|
||||
res.data = false;
|
||||
}
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "获取数据失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据platformKey更新platformValue
|
||||
* @param object
|
||||
|
||||
Reference in New Issue
Block a user