Commit 316b2127 authored by tangwei's avatar tangwei

增加缓存

parent 28b35ffd
......@@ -8,10 +8,20 @@ package com.yeejoin.amos.boot.biz.common.utils;
*/
public class RedisKey {
//动态表单
public static final String FORM = "form_";
//数据字典
public static final String DATADICTIONARY= "dataDictionary_";
//根据动态表单code获取动态表单列表
public static final String FORM_CODE = "form_code_";
//根据字典code获取数据字典列表
public static final String DATA_DICTIONARY_CODE= "data_dictionary_code_";
//根据id获取消防人员基本信息
public static final String FIREFIGHTERS_ID="firefighters_id_";
//根据id获取消防人员列表基本信息
public static final String FIREFIGHTERS_LIST_ID="firefighters_id_list_";
//根据消防人员id查询岗位学历信息工作经历
public static final String EDUCATION_POST_EXPERIENCE_FIREFIGHTERS_ID="education_post_experience_firefighters_id_";
//根据合同信id 查询合同信息
public static final String CONTRACT_ID="contract_id";
//根据思想状况信息id 查询思想信息
public static final String THOUGHT_ID="thought_id";
//根据警情id查询警情详情记录
public static final String ALERTCALLED_ID="alertcalled_id";
}
......@@ -16,9 +16,10 @@ import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.jcs.api.service.IAlertCalledService;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import javax.servlet.http.HttpServletRequest;
......@@ -26,7 +27,11 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jcs.api.entity.AlertCalled;
import com.yeejoin.amos.boot.module.jcs.api.entity.AlertForm;
import com.yeejoin.amos.boot.biz.common.utils.NameUtils;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
......@@ -54,7 +59,10 @@ public class AlertCalledController extends BaseController {
IAlertCalledService iAlertCalledService;
@Autowired
IAlertFormValueService iAlertFormValueService;
@Autowired
RedisUtils redisUtils;
@Value("${redis.cache.failure.time}")
private long time;
/**
* 新增警情接警记录
*
......@@ -124,6 +132,11 @@ public class AlertCalledController extends BaseController {
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据id查询", notes = "根据id查询")
public ResponseModel selectById(HttpServletRequest request, @PathVariable Long id) {
if(redisUtils.hasKey(RedisKey.ALERTCALLED_ID+id)){
Object obj= redisUtils.get(RedisKey.ALERTCALLED_ID+id);
return CommonResponseUtil.success(obj);
}else{
// 警情基本信息
AlertCalled alertCalled = iAlertCalledService.getById(id);
QueryWrapper queryWrapper = new QueryWrapper<>();
......@@ -136,8 +149,11 @@ public class AlertCalledController extends BaseController {
formValue.add(value);
}
AlertCalledFormVo alertCalledFormVo = new AlertCalledFormVo(alertCalled, formValue);
redisUtils.set(RedisKey.ALERTCALLED_ID+id,JSON.toJSON(alertCalledFormVo),time);
return CommonResponseUtil.success(alertCalledFormVo);
}
}
/**
* 列表分页查询
......
......@@ -7,6 +7,7 @@ import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -51,6 +52,8 @@ public class AlertFormController extends BaseController {
FormList FormList;
@Autowired
RedisUtils redisUtils;
@Value("${redis.cache.failure.time}")
private long time;
/**
* 新增警情表单
* @return
......@@ -125,7 +128,7 @@ public class AlertFormController extends BaseController {
//警情动态表单数据
List<AlertForm> alertFormValue = iAlertFormService.list(queryWrapper);
list= FormList.getFormlist(alertFormValue);
redisUtils.set(RedisKey.FORM_CODE+code,JSON.toJSON(list),86400);
redisUtils.set(RedisKey.FORM_CODE+code,JSON.toJSON(list),time);
return CommonResponseUtil.success(list);
}
}
......
......@@ -7,6 +7,7 @@ import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -49,6 +50,9 @@ public class DataDictionaryController extends BaseController {
IDataDictionaryService iDataDictionaryService;
@Autowired
RedisUtils redisUtils;
@Value("${redis.cache.failure.time}")
private long time;
/**
* 新增数据字典
* @return
......@@ -164,7 +168,7 @@ public class DataDictionaryController extends BaseController {
}else{
Collection<DataDictionary> list=iDataDictionaryService.list(queryWrapper);
List<Menu> menus =TreeParser.getTree(null, list, DataDictionary.class.getName(),"getCode",0, "getName", "getParent");
redisUtils.set(RedisKey.DATA_DICTIONARY_CODE+type, JSON.toJSON(menus),86400);
redisUtils.set(RedisKey.DATA_DICTIONARY_CODE+type, JSON.toJSON(menus),time);
return CommonResponseUtil.success(menus);
}
}
......
......@@ -5,8 +5,15 @@ import java.util.List;
import javax.servlet.http.HttpServletRequest;
import com.alibaba.fastjson.JSON;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.jcs.api.entity.Firefighters;
import com.yeejoin.amos.boot.module.jcs.api.entity.FirefightersContacts;
import com.yeejoin.amos.boot.module.jcs.api.vo.FirefightersVo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -43,7 +50,10 @@ public class FirefightersContractController extends BaseController {
@Autowired
IFirefightersContractService iFirefightersContractService;
@Autowired
RedisUtils redisUtils;
@Value("${redis.cache.failure.time}")
private long time;
/**
* 新增消防员合同
* @return
......@@ -52,12 +62,8 @@ public class FirefightersContractController extends BaseController {
@RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "新增消防员合同", notes = "新增消防员合同")
public ResponseModel saveFirefightersContract(HttpServletRequest request, @RequestBody FirefightersContract firefightersContract){
boolean flag= iFirefightersContractService.save(firefightersContract);
return CommonResponseUtil.success(firefightersContract);
}
/**
......@@ -73,6 +79,8 @@ public class FirefightersContractController extends BaseController {
List<String> ids= Arrays.asList(str);
for (String sequenceNbr : ids) {
iFirefightersContractService.update(new UpdateWrapper<FirefightersContract>().eq("sequence_nbr", Long.valueOf(sequenceNbr)).set("is_delete", 1));
//删除缓存
redisUtils.del(RedisKey.CONTRACT_ID+sequenceNbr);
}
return CommonResponseUtil.success();
}
......@@ -90,6 +98,8 @@ public class FirefightersContractController extends BaseController {
public ResponseModel updateByIdFirefightersContract(HttpServletRequest request, @RequestBody FirefightersContract firefightersContract){
boolean flag=iFirefightersContractService.updateById(firefightersContract);
if(flag) {
//删除缓存
redisUtils.del(RedisKey.CONTRACT_ID+firefightersContract.getSequenceNbr());
return CommonResponseUtil.success(firefightersContract);
}
return CommonResponseUtil.failure("修改失败!");
......@@ -107,9 +117,15 @@ public class FirefightersContractController extends BaseController {
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据id查询", notes = "根据id查询")
public ResponseModel selectById(HttpServletRequest request, @PathVariable Long id){
if(redisUtils.hasKey(RedisKey.CONTRACT_ID+id)){
Object obj= redisUtils.get(RedisKey.CONTRACT_ID+id);
return CommonResponseUtil.success(obj);
}else{
FirefightersContract firefightersContract= iFirefightersContractService.getById(id);
redisUtils.set(RedisKey.CONTRACT_ID+id, JSON.toJSON(firefightersContract),time);
return CommonResponseUtil.success(firefightersContract);
}
}
......
package com.yeejoin.amos.boot.module.jcs.biz.controller;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.utils.CommonResponseUtil;
import com.yeejoin.amos.boot.biz.common.utils.NameUtils;
import com.yeejoin.amos.boot.biz.common.utils.*;
import com.yeejoin.amos.boot.module.jcs.api.entity.Firefighters;
import com.yeejoin.amos.boot.module.jcs.api.entity.FirefightersContacts;
import com.yeejoin.amos.boot.module.jcs.api.entity.FirefightersContract;
......@@ -27,6 +27,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
......@@ -68,6 +69,10 @@ public class FirefightersController extends BaseController {
IFirefightersContractService iFirefightersContractService;
@Autowired
IFirefightersJacketService iFirefightersJacketService;
@Autowired
RedisUtils redisUtils;
@Value("${redis.cache.failure.time}")
private long time;
/**
* 新增消防队员
......@@ -111,6 +116,8 @@ public class FirefightersController extends BaseController {
iFirefightersThoughtService.update(new UpdateWrapper<FirefightersThought>().eq("firefighters_id", id).set("is_delete", 1));
iFirefightersContractService.update(new UpdateWrapper<FirefightersContract>().eq("firefighters_id", id).set("is_delete", 1));
iFirefightersJacketService.update(new UpdateWrapper<FirefightersJacket>().eq("firefighters_id", id).set("is_delete", 1));
//删除缓存
redisUtils.del(RedisKey.FIREFIGHTERS_ID+id,RedisKey.FIREFIGHTERS_LIST_ID+id);
return CommonResponseUtil.success();
} catch (Exception e) {
......@@ -129,11 +136,14 @@ public class FirefightersController extends BaseController {
@TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/updateById", method = RequestMethod.PUT)
@ApiOperation(httpMethod = "PUT", value = "修改消防队员", notes = "修改消防队员")
@Transactional
public ResponseModel updateByIdFirefighters(HttpServletRequest request, @RequestBody FirefightersVo firefighters){
iFirefightersService.updateById(firefighters.getFirefighters());
Firefighters firefighter= firefighters.getFirefighters();
iFirefightersService.updateById(firefighter);
ifirefightersContactsService.updateById(firefighters.getFirefightersContacts());
//删除缓存
redisUtils.del(RedisKey.FIREFIGHTERS_ID+firefighter.getSequenceNbr(),RedisKey.FIREFIGHTERS_LIST_ID+firefighter.getSequenceNbr());
return CommonResponseUtil.success();
}
......@@ -148,14 +158,20 @@ public class FirefightersController extends BaseController {
@ApiOperation(httpMethod = "GET", value = "根据id查询", notes = "根据id查询")
public ResponseModel selectById(HttpServletRequest request, @PathVariable Long id){
if(redisUtils.hasKey(RedisKey.FIREFIGHTERS_ID+id)){
Object obj= redisUtils.get(RedisKey.FIREFIGHTERS_ID+id);
return CommonResponseUtil.success(obj);
}else{
Firefighters firefighters=iFirefightersService.getById(id);
@SuppressWarnings("rawtypes")
QueryWrapper queryWrapper=new QueryWrapper<>();
queryWrapper.eq("firefighters_id", id);
FirefightersContacts firefightersContacts= ifirefightersContactsService.getOne(queryWrapper);
FirefightersVo firefightersVo=new FirefightersVo(firefighters, firefightersContacts);
redisUtils.set(RedisKey.FIREFIGHTERS_ID+id, JSON.toJSON(firefightersVo),time);
return CommonResponseUtil.success(firefightersVo);
}
}
/**
* 列表详情展示
......@@ -166,9 +182,15 @@ public class FirefightersController extends BaseController {
@RequestMapping(value = "/list/{id}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "列表详情根据id查询", notes = "列表详情根据id查询")
public ResponseModel listToSelectById(HttpServletRequest request, @PathVariable Long id){
if(redisUtils.hasKey(RedisKey.FIREFIGHTERS_LIST_ID+id)){
Object obj= redisUtils.get(RedisKey.FIREFIGHTERS_LIST_ID+id);
return CommonResponseUtil.success(obj);
}else{
Map<String, Object> firefighters=iFirefightersService.listToSelectById(id);
redisUtils.set(RedisKey.FIREFIGHTERS_LIST_ID+id, JSON.toJSON(firefighters),time);
return CommonResponseUtil.success(firefighters);
}
}
/**
* 列表分页查询
* @return
......
......@@ -3,8 +3,14 @@ import java.util.Arrays;
import javax.servlet.http.HttpServletRequest;
import com.alibaba.fastjson.JSON;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.jcs.api.entity.*;
import com.yeejoin.amos.boot.module.jcs.api.vo.FirefightersVo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
......@@ -22,9 +28,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.utils.CommonResponseUtil;
import com.yeejoin.amos.boot.biz.common.utils.NameUtils;
import com.yeejoin.amos.boot.module.jcs.api.entity.FirefightersEducation;
import com.yeejoin.amos.boot.module.jcs.api.entity.FirefightersPost;
import com.yeejoin.amos.boot.module.jcs.api.entity.FirefightersWorkexperience;
import com.yeejoin.amos.boot.module.jcs.api.service.IFirefightersContactsService;
import com.yeejoin.amos.boot.module.jcs.api.service.IFirefightersEducationService;
import com.yeejoin.amos.boot.module.jcs.api.service.IFirefightersPostService;
......@@ -54,6 +57,10 @@ public class FirefightersPostController extends BaseController {
IFirefightersEducationService ifirefightersEducationService;
@Autowired
IFirefightersWorkexperienceService ifirefightersWorkexperienceService;
@Autowired
RedisUtils redisUtils;
@Value("${redis.cache.failure.time}")
private long time;
/**
* 新增岗位信息
* @return
......@@ -82,6 +89,8 @@ public class FirefightersPostController extends BaseController {
iFirefightersPostService.update(new UpdateWrapper<FirefightersPost>().eq("firefighters_id", id).set("is_delete", 1));
ifirefightersWorkexperienceService.update(new UpdateWrapper<FirefightersWorkexperience>().eq("firefighters_id", id).set("is_delete", 1));
ifirefightersEducationService.update(new UpdateWrapper<FirefightersEducation>().eq("firefighters_id", id).set("is_delete", 1));
//删除缓存
redisUtils.del(RedisKey.EDUCATION_POST_EXPERIENCE_FIREFIGHTERS_ID+id);
return CommonResponseUtil.success();
}
......@@ -96,10 +105,12 @@ public class FirefightersPostController extends BaseController {
@RequestMapping(value = "/updateById", method = RequestMethod.PUT)
@ApiOperation(httpMethod = "PUT", value = "修改岗位信息", notes = "修改岗位信息")
public ResponseModel updateByIdFirefightersPost(HttpServletRequest request, @RequestBody FirefightersData firefightersData){
iFirefightersPostService.updateById(firefightersData.getFirefightersPost());
FirefightersPost firefightersPost= firefightersData.getFirefightersPost();
iFirefightersPostService.updateById(firefightersPost);
ifirefightersWorkexperienceService.updateById(firefightersData.getFirefightersWorkexperience());
ifirefightersEducationService.updateById(firefightersData.getFirefightersEducation());
//删除缓存
redisUtils.del(RedisKey.EDUCATION_POST_EXPERIENCE_FIREFIGHTERS_ID+firefightersPost.getSequenceNbr());
return CommonResponseUtil.success();
}
......@@ -116,13 +127,18 @@ public class FirefightersPostController extends BaseController {
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据消防员id查询", notes = "根据消防员id查询")
public ResponseModel selectById(HttpServletRequest request, @PathVariable Long id){
if(redisUtils.hasKey(RedisKey.EDUCATION_POST_EXPERIENCE_FIREFIGHTERS_ID+id)){
Object obj= redisUtils.get(RedisKey.EDUCATION_POST_EXPERIENCE_FIREFIGHTERS_ID+id);
return CommonResponseUtil.success(obj);
}else{
@SuppressWarnings("rawtypes")
QueryWrapper queryWrapper=new QueryWrapper<>();
queryWrapper.eq("firefighters_id", id);
FirefightersData firefightersData=new FirefightersData( ifirefightersWorkexperienceService.getOne(queryWrapper), ifirefightersEducationService.getOne(queryWrapper), iFirefightersPostService.getOne(queryWrapper));
redisUtils.set(RedisKey.EDUCATION_POST_EXPERIENCE_FIREFIGHTERS_ID+id, JSON.toJSON(firefightersData),time);
return CommonResponseUtil.success(firefightersData);
}
}
......
......@@ -5,8 +5,15 @@ import java.util.List;
import javax.servlet.http.HttpServletRequest;
import com.alibaba.fastjson.JSON;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.jcs.api.entity.Firefighters;
import com.yeejoin.amos.boot.module.jcs.api.entity.FirefightersContacts;
import com.yeejoin.amos.boot.module.jcs.api.vo.FirefightersVo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -43,7 +50,10 @@ public class FirefightersThoughtController extends BaseController {
@Autowired
IFirefightersThoughtService iFirefightersThoughtService;
@Autowired
RedisUtils redisUtils;
@Value("${redis.cache.failure.time}")
private long time;
/**
* 新增消防员思想谈话记录
* @return
......@@ -70,6 +80,8 @@ public class FirefightersThoughtController extends BaseController {
List<String> ids= Arrays.asList(str);
for (String sequenceNbr : ids) {
iFirefightersThoughtService.update(new UpdateWrapper<FirefightersThought>().eq("sequence_nbr", Long.valueOf(sequenceNbr)).set("is_delete", 1));
//删除缓存
redisUtils.del(RedisKey.THOUGHT_ID+sequenceNbr);
}
return CommonResponseUtil.success();
......@@ -86,6 +98,8 @@ public class FirefightersThoughtController extends BaseController {
@ApiOperation(httpMethod = "PUT", value = "修改消防员思想谈话记录", notes = "修改消防员思想谈话记录")
public ResponseModel updateByIdFirefightersThought(HttpServletRequest request, @RequestBody FirefightersThought firefightersThought){
boolean flag= iFirefightersThoughtService.updateById(firefightersThought);
//删除缓存
redisUtils.del(RedisKey.THOUGHT_ID+firefightersThought.getSequenceNbr());
return CommonResponseUtil.success(firefightersThought);
}
......@@ -102,10 +116,18 @@ public class FirefightersThoughtController extends BaseController {
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据消防员id查询", notes = "根据消防员id查询")
public ResponseModel selectById(HttpServletRequest request, @PathVariable Long id){
if(redisUtils.hasKey(RedisKey.THOUGHT_ID+id)){
Object obj= redisUtils.get(RedisKey.THOUGHT_ID+id);
return CommonResponseUtil.success(obj);
}else{
FirefightersThought firefightersThought= iFirefightersThoughtService.getById(id);
redisUtils.set(RedisKey.THOUGHT_ID+id, JSON.toJSON(firefightersThought),time);
return CommonResponseUtil.success(firefightersThought);
}
}
/**
......
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