|
@ -4,20 +4,22 @@ package com.yihu.wlyy.controller.redis;
|
|
import com.yihu.wlyy.common.constants.ApiVersion;
|
|
import com.yihu.wlyy.common.constants.ApiVersion;
|
|
import com.yihu.wlyy.common.constants.ServiceApi;
|
|
import com.yihu.wlyy.common.constants.ServiceApi;
|
|
import com.yihu.wlyy.common.controller.EnvelopRestEndPoint;
|
|
import com.yihu.wlyy.common.controller.EnvelopRestEndPoint;
|
|
import com.yihu.wlyy.common.vo.MRedisCacheCategory;
|
|
|
|
import com.yihu.wlyy.common.vo.MRedisCacheKeyRule;
|
|
import com.yihu.wlyy.common.vo.MRedisCacheKeyRule;
|
|
|
|
import com.yihu.wlyy.entity.User;
|
|
import com.yihu.wlyy.entity.redis.RedisCacheKeyRule;
|
|
import com.yihu.wlyy.entity.redis.RedisCacheKeyRule;
|
|
import com.yihu.wlyy.service.redis.cache.RedisCacheKeyRuleService;
|
|
import com.yihu.wlyy.service.redis.cache.RedisCacheKeyRuleService;
|
|
import com.yihu.wlyy.util.Envelop;
|
|
import com.yihu.wlyy.util.Envelop;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiParam;
|
|
import io.swagger.annotations.ApiParam;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.ui.Model;
|
|
import org.springframework.ui.Model;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
/**
|
|
@ -42,13 +44,13 @@ public class RedisCacheKeyRuleEndPoint extends EnvelopRestEndPoint {
|
|
MRedisCacheKeyRule mRedisCacheKeyRule = convertToModel(redisCacheKeyRuleService.getById(id), MRedisCacheKeyRule.class);
|
|
MRedisCacheKeyRule mRedisCacheKeyRule = convertToModel(redisCacheKeyRuleService.getById(id), MRedisCacheKeyRule.class);
|
|
model.addAttribute("detailModel", toJson(mRedisCacheKeyRule));
|
|
model.addAttribute("detailModel", toJson(mRedisCacheKeyRule));
|
|
}else {
|
|
}else {
|
|
Object detailModel = new MRedisCacheCategory();
|
|
|
|
|
|
Object detailModel = new MRedisCacheKeyRule();
|
|
model.addAttribute("detailModel", toJson(detailModel));
|
|
model.addAttribute("detailModel", toJson(detailModel));
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
return "redis/cache/cache/detail";
|
|
|
|
|
|
return "redis/cache/keyRule/detail";
|
|
}
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "根据条件获取缓存Key规则")
|
|
@ApiOperation(value = "根据条件获取缓存Key规则")
|
|
@ -59,6 +61,8 @@ public class RedisCacheKeyRuleEndPoint extends EnvelopRestEndPoint {
|
|
@RequestParam(value = "fields", required = false) String fields,
|
|
@RequestParam(value = "fields", required = false) String fields,
|
|
@ApiParam(name = "searchContent", value = "筛选条件")
|
|
@ApiParam(name = "searchContent", value = "筛选条件")
|
|
@RequestParam(value = "searchContent", required = false) String searchContent,
|
|
@RequestParam(value = "searchContent", required = false) String searchContent,
|
|
|
|
@ApiParam(name = "categoryCode", value = "类别")
|
|
|
|
@RequestParam(value = "categoryCode", required = false) String categoryCode,
|
|
@ApiParam(name = "sorts", value = "排序")
|
|
@ApiParam(name = "sorts", value = "排序")
|
|
@RequestParam(value = "sorts", required = false) String sorts,
|
|
@RequestParam(value = "sorts", required = false) String sorts,
|
|
@ApiParam(name = "page", value = "页码", defaultValue = "1")
|
|
@ApiParam(name = "page", value = "页码", defaultValue = "1")
|
|
@ -68,8 +72,16 @@ public class RedisCacheKeyRuleEndPoint extends EnvelopRestEndPoint {
|
|
Envelop envelop = new Envelop();
|
|
Envelop envelop = new Envelop();
|
|
envelop.setSuccessFlg(false);
|
|
envelop.setSuccessFlg(false);
|
|
try {
|
|
try {
|
|
List<RedisCacheKeyRule> redisCacheKeyRuleList = redisCacheKeyRuleService.search(fields, searchContent, sorts, page, rows);
|
|
|
|
int count = (int) redisCacheKeyRuleService.getCount(searchContent);
|
|
|
|
|
|
String filters = "";
|
|
|
|
if (!StringUtils.isEmpty(searchContent)) {
|
|
|
|
filters = "code?" + searchContent + ";name?" + searchContent + ";";
|
|
|
|
}
|
|
|
|
if (!StringUtils.isEmpty(categoryCode)) {
|
|
|
|
filters = "categoryCode=" + categoryCode + ";";
|
|
|
|
}
|
|
|
|
|
|
|
|
List<RedisCacheKeyRule> redisCacheKeyRuleList = redisCacheKeyRuleService.search(fields, filters, sorts, page, rows);
|
|
|
|
int count = (int) redisCacheKeyRuleService.getCount(filters);
|
|
List<MRedisCacheKeyRule> mRedisCacheKeyRule = (List<MRedisCacheKeyRule>) convertToModels(redisCacheKeyRuleList, new ArrayList<MRedisCacheKeyRule>(), MRedisCacheKeyRule.class, fields);
|
|
List<MRedisCacheKeyRule> mRedisCacheKeyRule = (List<MRedisCacheKeyRule>) convertToModels(redisCacheKeyRuleList, new ArrayList<MRedisCacheKeyRule>(), MRedisCacheKeyRule.class, fields);
|
|
envelop = getPageResult(mRedisCacheKeyRule, count, page, rows);
|
|
envelop = getPageResult(mRedisCacheKeyRule, count, page, rows);
|
|
envelop.setSuccessFlg(true);
|
|
envelop.setSuccessFlg(true);
|
|
@ -84,13 +96,16 @@ public class RedisCacheKeyRuleEndPoint extends EnvelopRestEndPoint {
|
|
@ApiOperation("新增缓存Key规则")
|
|
@ApiOperation("新增缓存Key规则")
|
|
@ResponseBody
|
|
@ResponseBody
|
|
@RequestMapping(value = ServiceApi.Redis.CacheKeyRule.Save, method = RequestMethod.POST)
|
|
@RequestMapping(value = ServiceApi.Redis.CacheKeyRule.Save, method = RequestMethod.POST)
|
|
public Envelop add(
|
|
|
|
@ApiParam(value = "缓存Key规则JSON", required = true)
|
|
|
|
@RequestBody String entityJson) {
|
|
|
|
|
|
public Envelop add(String data) {
|
|
Envelop envelop = new Envelop();
|
|
Envelop envelop = new Envelop();
|
|
envelop.setSuccessFlg(false);
|
|
envelop.setSuccessFlg(false);
|
|
try {
|
|
try {
|
|
RedisCacheKeyRule newEntity = objectMapper.readValue(entityJson, RedisCacheKeyRule.class);
|
|
|
|
|
|
RedisCacheKeyRule newEntity = objectMapper.readValue(data, RedisCacheKeyRule.class);
|
|
|
|
User currentUser = (User) request.getSession().getAttribute("current_user");
|
|
|
|
newEntity.setCreator(currentUser.getCode());
|
|
|
|
newEntity.setCreateDate(new Date());
|
|
|
|
newEntity.setModifyDate(new Date());
|
|
|
|
newEntity.setModifier(currentUser.getCode());
|
|
newEntity = redisCacheKeyRuleService.save(newEntity);
|
|
newEntity = redisCacheKeyRuleService.save(newEntity);
|
|
|
|
|
|
MRedisCacheKeyRule mRedisCacheKeyRule = convertToModel(newEntity, MRedisCacheKeyRule.class);
|
|
MRedisCacheKeyRule mRedisCacheKeyRule = convertToModel(newEntity, MRedisCacheKeyRule.class);
|
|
@ -107,13 +122,14 @@ public class RedisCacheKeyRuleEndPoint extends EnvelopRestEndPoint {
|
|
@ApiOperation("更新缓存Key规则")
|
|
@ApiOperation("更新缓存Key规则")
|
|
@ResponseBody
|
|
@ResponseBody
|
|
@RequestMapping(value = ServiceApi.Redis.CacheKeyRule.Update, method = RequestMethod.POST)
|
|
@RequestMapping(value = ServiceApi.Redis.CacheKeyRule.Update, method = RequestMethod.POST)
|
|
public Envelop update(
|
|
|
|
@ApiParam(value = "缓存Key规则JSON", required = true)
|
|
|
|
@RequestBody String entityJson) {
|
|
|
|
|
|
public Envelop update(String data) {
|
|
Envelop envelop = new Envelop();
|
|
Envelop envelop = new Envelop();
|
|
envelop.setSuccessFlg(false);
|
|
envelop.setSuccessFlg(false);
|
|
try {
|
|
try {
|
|
RedisCacheKeyRule updateEntity = objectMapper.readValue(entityJson, RedisCacheKeyRule.class);
|
|
|
|
|
|
RedisCacheKeyRule updateEntity = objectMapper.readValue(data, RedisCacheKeyRule.class);
|
|
|
|
User currentUser = (User) request.getSession().getAttribute("current_user");
|
|
|
|
updateEntity.setModifyDate(new Date());
|
|
|
|
updateEntity.setModifier(currentUser.getCode());
|
|
updateEntity = redisCacheKeyRuleService.save(updateEntity);
|
|
updateEntity = redisCacheKeyRuleService.save(updateEntity);
|
|
|
|
|
|
MRedisCacheKeyRule mRedisCacheKeyRule = convertToModel(updateEntity, MRedisCacheKeyRule.class);
|
|
MRedisCacheKeyRule mRedisCacheKeyRule = convertToModel(updateEntity, MRedisCacheKeyRule.class);
|
|
@ -132,7 +148,7 @@ public class RedisCacheKeyRuleEndPoint extends EnvelopRestEndPoint {
|
|
@RequestMapping(value = ServiceApi.Redis.CacheKeyRule.Delete, method = RequestMethod.POST)
|
|
@RequestMapping(value = ServiceApi.Redis.CacheKeyRule.Delete, method = RequestMethod.POST)
|
|
public Envelop delete(
|
|
public Envelop delete(
|
|
@ApiParam(name = "id", value = "缓存Key规则ID", required = true)
|
|
@ApiParam(name = "id", value = "缓存Key规则ID", required = true)
|
|
@RequestParam(value = "id") Integer id) {
|
|
|
|
|
|
@RequestParam(value = "id") Long id) {
|
|
Envelop envelop = new Envelop();
|
|
Envelop envelop = new Envelop();
|
|
envelop.setSuccessFlg(false);
|
|
envelop.setSuccessFlg(false);
|
|
try {
|
|
try {
|