Commit d2681852 authored by tangwei's avatar tangwei

增加缓存

parent 7d860341
package com.yeejoin.amos.boot.module.jcs.biz.controller; package com.yeejoin.amos.boot.module.jcs.biz.controller;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -41,6 +42,8 @@ public class AlertFormController extends BaseController { ...@@ -41,6 +42,8 @@ public class AlertFormController extends BaseController {
IAlertFormService iAlertFormService; IAlertFormService iAlertFormService;
@Autowired @Autowired
FormList FormList; FormList FormList;
@Autowired
RedisUtils redisUtils;
/** /**
* 新增警情表单 * 新增警情表单
* @return * @return
...@@ -102,18 +105,22 @@ public class AlertFormController extends BaseController { ...@@ -102,18 +105,22 @@ public class AlertFormController extends BaseController {
*/ */
@TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY) @TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/from/{code}", method = RequestMethod.GET) @RequestMapping(value = "/form/{code}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据表态类型code查询表单数据项", notes = "根据表态类型code查询表单数据项") @ApiOperation(httpMethod = "GET", value = "根据表态类型code查询表单数据项", notes = "根据表态类型code查询表单数据项")
public ResponseModel selectFormdItem(HttpServletRequest request, @PathVariable String code){ public ResponseModel selectFormdItem(HttpServletRequest request, @PathVariable String code){
QueryWrapper queryWrapper = new QueryWrapper<>(); List<AlertFormVo> list=null;
queryWrapper.eq("alert_type_code", code); if(redisUtils.hasKey("form_"+code)){
//警情动态表单数据 Object obj= redisUtils.get("form_"+code);
List<AlertForm> alertFormValue = iAlertFormService.list(queryWrapper); return CommonResponseUtil.success(obj);
}else{
List<AlertFormVo> list= FormList.getFormlist(alertFormValue); QueryWrapper queryWrapper = new QueryWrapper<>();
queryWrapper.eq("alert_type_code", code);
return CommonResponseUtil.success(list); //警情动态表单数据
List<AlertForm> alertFormValue = iAlertFormService.list(queryWrapper);
list= FormList.getFormlist(alertFormValue);
redisUtils.set("form_"+code,list,86400);
return CommonResponseUtil.success(list);
}
} }
......
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