Commit 33d0f5d6 authored by Administrator's avatar Administrator

助手页面接口增加缓存

parent d37316ac
......@@ -128,7 +128,8 @@ public class SecurityInterceptor implements HandlerInterceptor {
|| uri.startsWith("/ueditor/")
|| uri.startsWith("/static/")
|| uri.startsWith("/api-common/")
|| uri.startsWith("/api/cmpt/getCmpt/")
|| uri.startsWith("/api/cmpt/")
|| uri.startsWith("/api/func/")
|| uri.equals("/auth") || uri.equals("/auth_no");
}
......
......@@ -144,7 +144,7 @@ public class MicroApiController {
@ApiResponses({@ApiResponse(code = 200, message = "成功"), @ApiResponse(code = -1, message = "失败"), @ApiResponse(code = 200, message = "成功", response = Result.class)})
@ApiOperation(value = "绑定赛事", notes = "用户与赛事绑定功能", tags = "赛事页面")
public Result<EnrollInfo> bind(@RequestParam("phone") String phone, @RequestParam("cmptId") Integer cmptId, @RequestParam(name = "userMapId", defaultValue = "-1", required = false) Integer userMapId, HttpServletRequest request) {
int userId = org.apache.commons.lang3.math.NumberUtils.toInt(request.getParameter("userId"), -1);
int userId = NumberUtils.toInt(request.getParameter("userId"), -1);
if (userId == -1) {
return Result.fail()
.setMsg("入参错误");
......@@ -431,21 +431,26 @@ public class MicroApiController {
@GetMapping(value = "/customer/{cmptId}")
@ApiResponses({@ApiResponse(code = 200, message = "成功"), @ApiResponse(code = -1, message = "失败", response = ObjectUtils.Null.class), @ApiResponse(code = 200, message = "成功", response = Result.class, responseContainer = "List")})
@SuppressWarnings("unchecked")
public Result getCustomer(@PathVariable("cmptId") Integer cmptId) {
// 新增耗时计算
long startTime = System.currentTimeMillis();
Customer customer = customerService.getCusomerServiceInfo(cmptId);
FuncSetting setting = funcSettingService.getSettingByCmptId(cmptId);
Map<String, String> result = new HashMap<>();
if (setting == null || setting.getCustomer() == null || setting.getCustomer() != 1) {
result.put("mobile", "");
} else {
result.put("mobile", customer == null ? "" : customer.getMobile());
}
// 新增耗时计算
long endTime = System.currentTimeMillis();
long duration = endTime - startTime;
// log.info("获取合作信息耗时:" + duration + "毫秒");
Map<String, String> result = cacheTemplate.get(
"cmpt:customer",
String.valueOf(cmptId),
Map.class,
2L, TimeUnit.MINUTES,
5L, TimeUnit.MINUTES,
() -> {
Customer customer = customerService.getCusomerServiceInfo(cmptId);
FuncSetting setting = funcSettingService.getSettingByCmptId(cmptId);
Map<String, String> map = new HashMap<>();
if (setting == null || setting.getCustomer() == null || setting.getCustomer() != 1) {
map.put("mobile", "");
} else {
map.put("mobile", customer == null ? "" : customer.getMobile());
}
return map;
}
);
return Result.success()
.setContent(result);
}
......@@ -505,36 +510,24 @@ public class MicroApiController {
@ApiResponses({@ApiResponse(code = 200, message = "成功"), @ApiResponse(code = -1, message = "失败", response = ObjectUtils.Null.class), @ApiResponse(code = 200, message = "成功", response = Result.class, responseContainer = "List")})
@ApiImplicitParam(name = "enrollId", value = "赛事用户标识", required = false, paramType = "query")
@ApiOperation(value = "赛事功能模块列表", notes = "赛事功能模块列表", tags = "赛事页面")
@SuppressWarnings("unchecked")
public Result<List<Func>> func(@PathVariable("cmptId") int cmpId, HttpServletRequest request) {
// String enrollId = request.getParameter("enrollId");
List<Func> list = cmptSetting.queryFuncs(cmpId);
// list=list
// .stream()
// .filter(v -> {
// if (v.getNeedTime() == null || v.getNeedTime() != 1) {
// return true; // 不需要时间校验的直接保留
// }
// Date now = new Date();
// // 检查开始时间条件(如果有)
// boolean startValid = v.getStartTime() == null || !now.before(v.getStartTime());
// // 检查结束时间条件(如果有)
// boolean endValid = v.getDeadTime() == null || now.before(v.getDeadTime());
//
// // 必须同时满足开始和结束时间条件
// return startValid && endValid;
// })
// .collect(Collectors.toList());
list.forEach(v -> {
if (v.getOpenType()
.equals(0)) {
v.setUrl(serverURL + "gk/cmpt/cmptSetting/page/" + v.getId());
}
});
/* if (StringUtils.isBlank(enrollId)) {
list = cmptSetting.queryAllFuncs(cmpId); // 查询 可对外的
} else { // 绑定后
list = cmptSetting.queryFuncs(cmpId); // 仅公开
}*/
List<Func> list = cacheTemplate.get(
"cmpt:func",
String.valueOf(cmpId),
List.class,
2L, TimeUnit.MINUTES,
5L, TimeUnit.MINUTES,
() -> {
List<Func> result = cmptSetting.queryFuncs(cmpId);
result.forEach(v -> {
if (v.getOpenType().equals(0)) {
v.setUrl(serverURL + "gk/cmpt/cmptSetting/page/" + v.getId());
}
});
return result;
}
);
return Result.success()
.setContent(list);
}
......
......@@ -3,6 +3,14 @@ spring.datasource.password=8N8F0cWb7rg88FWW
spring.datasource.username=geexek_mysql
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://rm-bp1xezgtx890ssl6r.mysql.rds.aliyuncs.com:3306/gksite?autoReconnect=true&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true
# Druid 连接池配置
spring.datasource.druid.max-active=150
spring.datasource.druid.min-idle=10
spring.datasource.druid.max-wait=3000
spring.datasource.druid.validation-query=SELECT 1
spring.datasource.druid.test-while-idle=true
spring.datasource.druid.time-between-eviction-runs-millis=60000
spring.datasource.druid.min-evictable-idle-time-millis=300000
mybatis.typeAliasesPackage=com.dlbridge.jadp.plugins
mybatis.mapperLocations=classpath:com/dlbridge/jadp/**/**.xml
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment