缓存增加

master
rong.liu 1 month ago
parent dd99db1a79
commit cd998458cb
  1. 33
      src/main/java/com/huoran/iasf/controller/SysColumnController.java
  2. 34
      src/main/java/com/huoran/iasf/controller/SysContentController.java

@ -103,8 +103,8 @@ public class SysColumnController {
@NoRepeatSubmit @NoRepeatSubmit
@PostMapping("/save") @PostMapping("/save")
@CacheEvict(value = {"redis_listWithTree", "redis_columnDisplayFloatingBar", "redis_listWithTreeMenuVisible", @CacheEvict(value = {"redis_listWithTree", "redis_columnDisplayFloatingBar", "redis_listWithTreeMenuVisible",
"redis_showTheFooterAccordingToTheColumn", "redis_articlesByColumnType", "redis_columnDetails", "redis_controlDisplayNavigationMenu"}, "redis_showTheFooterAccordingToTheColumn", "redis_articlesByColumnType", "redis_columnDetails",
allEntries = true) "redis_controlDisplayNavigationMenu", "redis_newlyPublishedArticles"}, allEntries = true)
@ApiOperation(value = "新增", response = SysColumn.class) @ApiOperation(value = "新增", response = SysColumn.class)
public R save(@RequestBody @Valid SysColumn sysColumn) { public R save(@RequestBody @Valid SysColumn sysColumn) {
QueryWrapper<SysColumn> queryWrapper = new QueryWrapper<SysColumn>(); QueryWrapper<SysColumn> queryWrapper = new QueryWrapper<SysColumn>();
@ -116,8 +116,8 @@ public class SysColumnController {
} }
@CacheEvict(value = {"redis_listWithTree", "redis_columnDisplayFloatingBar", "redis_listWithTreeMenuVisible", @CacheEvict(value = {"redis_listWithTree", "redis_columnDisplayFloatingBar", "redis_listWithTreeMenuVisible",
"redis_showTheFooterAccordingToTheColumn", "redis_articlesByColumnType", "redis_columnDetails", "redis_controlDisplayNavigationMenu"}, "redis_showTheFooterAccordingToTheColumn", "redis_articlesByColumnType", "redis_columnDetails",
allEntries = true) "redis_controlDisplayNavigationMenu", "redis_newlyPublishedArticles"}, allEntries = true)
@ApiOperation(value = "修改", response = SysColumn.class) @ApiOperation(value = "修改", response = SysColumn.class)
@PostMapping("/update") @PostMapping("/update")
public R update(@RequestBody SysColumn sysColumn) { public R update(@RequestBody SysColumn sysColumn) {
@ -136,8 +136,7 @@ public class SysColumnController {
@ApiOperation(value = "缓存用户存过的字段") @ApiOperation(value = "缓存用户存过的字段")
public R cacheField(@ApiParam(name = "userId", value = "用户id", required = true) @RequestParam Integer userId, public R cacheField(@ApiParam(name = "userId", value = "用户id", required = true) @RequestParam Integer userId,
@ApiParam(name = "fields", required = true, value = "字段(逗号隔开)") @RequestParam String fields, @ApiParam(name = "fields", required = true, value = "字段(逗号隔开)") @RequestParam String fields,
@ApiParam(name = "siteId", required = true, value = "站点id") @RequestParam Integer siteId @ApiParam(name = "siteId", required = true, value = "站点id") @RequestParam Integer siteId) {
) {
try { try {
String key = "fieldCache_" + "siteId_" + siteId + "userId_" + userId; String key = "fieldCache_" + "siteId_" + siteId + "userId_" + userId;
@ -195,16 +194,13 @@ public class SysColumnController {
} }
@PostMapping("/controlDisplayNavigationMenu") @PostMapping("/controlDisplayNavigationMenu")
@ApiOperation(value = "控制显示导航菜单", response = SysColumn.class) @ApiOperation(value = "控制显示导航菜单", response = SysColumn.class)
@CacheEvict(value = {"redis_listWithTree", "redis_columnDisplayFloatingBar", "redis_listWithTreeMenuVisible", @CacheEvict(value = {"redis_listWithTree", "redis_columnDisplayFloatingBar", "redis_listWithTreeMenuVisible",
"redis_showTheFooterAccordingToTheColumn", "redis_articlesByColumnType", "redis_columnDetails", "redis_controlDisplayNavigationMenu"}, "redis_showTheFooterAccordingToTheColumn", "redis_articlesByColumnType", "redis_columnDetails",
allEntries = true) "redis_controlDisplayNavigationMenu", "redis_newlyPublishedArticles"}, allEntries = true)
@CachePut(value = "redis_controlDisplayNavigationMenu", key = "#id + ':' + #menuVisible") @CachePut(value = "redis_controlDisplayNavigationMenu", key = "#id + ':' + #menuVisible")
public R controlDisplayNavigationMenu( public R controlDisplayNavigationMenu(@ApiParam(name = "id", value = "主键", required = true) @RequestParam Integer id, @ApiParam(name = "menuVisible", value = "菜单是否可见(默认0可见 1不可见)", required = true) @RequestParam Integer menuVisible) {
@ApiParam(name = "id", value = "主键", required = true) @RequestParam Integer id,
@ApiParam(name = "menuVisible", value = "菜单是否可见(默认0可见 1不可见)", required = true) @RequestParam Integer menuVisible) {
SysColumn column = new SysColumn(); SysColumn column = new SysColumn();
column.setId(id); column.setId(id);
@ -230,8 +226,8 @@ public class SysColumnController {
@NoRepeatSubmit @NoRepeatSubmit
@PostMapping("/batchDeletion") @PostMapping("/batchDeletion")
@CacheEvict(value = {"redis_listWithTree", "redis_columnDisplayFloatingBar", "redis_listWithTreeMenuVisible", @CacheEvict(value = {"redis_listWithTree", "redis_columnDisplayFloatingBar", "redis_listWithTreeMenuVisible",
"redis_showTheFooterAccordingToTheColumn", "redis_articlesByColumnType", "redis_columnDetails", "redis_controlDisplayNavigationMenu"}, "redis_showTheFooterAccordingToTheColumn", "redis_articlesByColumnType", "redis_columnDetails",
allEntries = true) "redis_controlDisplayNavigationMenu", "redis_newlyPublishedArticles"}, allEntries = true)
@ApiOperation(value = "批量删除栏目", response = SysColumn.class) @ApiOperation(value = "批量删除栏目", response = SysColumn.class)
public R batchDeletion(@ApiParam(name = "ids", value = "栏目ID列表", required = true) @RequestParam List<Integer> ids) { public R batchDeletion(@ApiParam(name = "ids", value = "栏目ID列表", required = true) @RequestParam List<Integer> ids) {
for (Integer id : ids) { for (Integer id : ids) {
@ -281,8 +277,8 @@ public class SysColumnController {
@PostMapping("/sortByColumn") @PostMapping("/sortByColumn")
@ApiOperation(value = "栏目排序(依据id更改)", response = SysColumn.class) @ApiOperation(value = "栏目排序(依据id更改)", response = SysColumn.class)
@CacheEvict(value = {"redis_listWithTree", "redis_columnDisplayFloatingBar", "redis_listWithTreeMenuVisible", @CacheEvict(value = {"redis_listWithTree", "redis_columnDisplayFloatingBar", "redis_listWithTreeMenuVisible",
"redis_showTheFooterAccordingToTheColumn", "redis_articlesByColumnType", "redis_columnDetails", "redis_controlDisplayNavigationMenu"}, "redis_showTheFooterAccordingToTheColumn", "redis_articlesByColumnType", "redis_columnDetails",
allEntries = true) "redis_controlDisplayNavigationMenu", "redis_newlyPublishedArticles"}, allEntries = true)
public R sortByColumn(@RequestBody List<SortColumnRespVO> sortColumnRespVOList) { public R sortByColumn(@RequestBody List<SortColumnRespVO> sortColumnRespVOList) {
for (SortColumnRespVO sortInfo : sortColumnRespVOList) { for (SortColumnRespVO sortInfo : sortColumnRespVOList) {
// 获取当前要排序的栏目信息 // 获取当前要排序的栏目信息
@ -290,10 +286,7 @@ public class SysColumnController {
// 构建查询条件,检查同级下是否有名称相同的其他栏目(排除自己) // 构建查询条件,检查同级下是否有名称相同的其他栏目(排除自己)
QueryWrapper<SysColumn> queryWrapper = new QueryWrapper<>(); QueryWrapper<SysColumn> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("column_name", existingColumn.getColumnName()) queryWrapper.eq("column_name", existingColumn.getColumnName()).eq("site_id", existingColumn.getSiteId()).eq("father_id", sortInfo.getFatherId()).ne("id", sortInfo.getId()); // 确保不包括当前正在处理的栏目
.eq("site_id", existingColumn.getSiteId())
.eq("father_id", sortInfo.getFatherId())
.ne("id", sortInfo.getId()); // 确保不包括当前正在处理的栏目
// 执行查询 // 执行查询
List<SysColumn> conflictingColumns = service.list(queryWrapper); List<SysColumn> conflictingColumns = service.list(queryWrapper);

@ -94,8 +94,8 @@ public class SysContentController {
@PostMapping("/save") @PostMapping("/save")
@CacheEvict(value = {"redis_listWithTree", "redis_columnDisplayFloatingBar", "redis_listWithTreeMenuVisible", @CacheEvict(value = {"redis_listWithTree", "redis_columnDisplayFloatingBar", "redis_listWithTreeMenuVisible",
"redis_showTheFooterAccordingToTheColumn", "redis_articlesByColumnType", "redis_columnDetails", "redis_controlDisplayNavigationMenu"}, "redis_showTheFooterAccordingToTheColumn", "redis_articlesByColumnType", "redis_columnDetails",
allEntries = true) "redis_controlDisplayNavigationMenu", "redis_newlyPublishedArticles"}, allEntries = true)
@ApiOperation(value = "新增", response = SysContent.class) @ApiOperation(value = "新增", response = SysContent.class)
public R save(@RequestBody @Valid @ApiParam(name = "文章管理对象", value = "传入json格式", required = true) SysContent sysContent) { public R save(@RequestBody @Valid @ApiParam(name = "文章管理对象", value = "传入json格式", required = true) SysContent sysContent) {
@ -116,8 +116,8 @@ public class SysContentController {
@PostMapping("/update") @PostMapping("/update")
@CacheEvict(value = {"redis_listWithTree", "redis_columnDisplayFloatingBar", "redis_listWithTreeMenuVisible", @CacheEvict(value = {"redis_listWithTree", "redis_columnDisplayFloatingBar", "redis_listWithTreeMenuVisible",
"redis_showTheFooterAccordingToTheColumn", "redis_articlesByColumnType", "redis_columnDetails", "redis_controlDisplayNavigationMenu"}, "redis_showTheFooterAccordingToTheColumn", "redis_articlesByColumnType", "redis_columnDetails",
allEntries = true) "redis_controlDisplayNavigationMenu", "redis_newlyPublishedArticles"}, allEntries = true)
@ApiOperation(value = "修改", response = SysContent.class) @ApiOperation(value = "修改", response = SysContent.class)
public R update(@RequestBody @ApiParam(name = "文章管理对象", value = "传入json格式", required = true) SysContent sysContent) { public R update(@RequestBody @ApiParam(name = "文章管理对象", value = "传入json格式", required = true) SysContent sysContent) {
boolean updateState = service.updateById(sysContent); boolean updateState = service.updateById(sysContent);
@ -127,8 +127,8 @@ public class SysContentController {
@PostMapping("/delete") @PostMapping("/delete")
@CacheEvict(value = {"redis_listWithTree", "redis_columnDisplayFloatingBar", "redis_listWithTreeMenuVisible", @CacheEvict(value = {"redis_listWithTree", "redis_columnDisplayFloatingBar", "redis_listWithTreeMenuVisible",
"redis_showTheFooterAccordingToTheColumn", "redis_articlesByColumnType", "redis_columnDetails", "redis_controlDisplayNavigationMenu"}, "redis_showTheFooterAccordingToTheColumn", "redis_articlesByColumnType", "redis_columnDetails",
allEntries = true) "redis_controlDisplayNavigationMenu", "redis_newlyPublishedArticles"}, allEntries = true)
@ApiOperation(value = "删除", response = SysContent.class) @ApiOperation(value = "删除", response = SysContent.class)
public R delete(@ApiParam(name = "id", value = "主键", required = true) @RequestParam Integer id) { public R delete(@ApiParam(name = "id", value = "主键", required = true) @RequestParam Integer id) {
UpdateWrapper<SysFilesEntity> queryWrapper = new UpdateWrapper<>(); UpdateWrapper<SysFilesEntity> queryWrapper = new UpdateWrapper<>();
@ -143,8 +143,8 @@ public class SysContentController {
@PostMapping("/batchDeletion") @PostMapping("/batchDeletion")
@CacheEvict(value = {"redis_listWithTree", "redis_columnDisplayFloatingBar", "redis_listWithTreeMenuVisible", @CacheEvict(value = {"redis_listWithTree", "redis_columnDisplayFloatingBar", "redis_listWithTreeMenuVisible",
"redis_showTheFooterAccordingToTheColumn", "redis_articlesByColumnType", "redis_columnDetails", "redis_controlDisplayNavigationMenu"}, "redis_showTheFooterAccordingToTheColumn", "redis_articlesByColumnType", "redis_columnDetails",
allEntries = true) "redis_controlDisplayNavigationMenu", "redis_newlyPublishedArticles"}, allEntries = true)
@ApiOperation(value = "批量删除文章", response = SysContent.class) @ApiOperation(value = "批量删除文章", response = SysContent.class)
public R batchDeletion(@ApiParam(name = "ids", value = "主键", required = true) @RequestParam List<Integer> ids) { public R batchDeletion(@ApiParam(name = "ids", value = "主键", required = true) @RequestParam List<Integer> ids) {
for (Integer id : ids) { for (Integer id : ids) {
@ -168,8 +168,8 @@ public class SysContentController {
@ApiOperation(value = "站点最新发布的文章", response = PageContentReqVO.class) @ApiOperation(value = "站点最新发布的文章", response = PageContentReqVO.class)
@Cacheable(value = "redis_newlyPublishedArticles", key = "#content.toString()") @Cacheable(value = "redis_newlyPublishedArticles", key = "#content.toString()")
@CacheEvict(value = {"redis_listWithTree", "redis_columnDisplayFloatingBar", "redis_listWithTreeMenuVisible", @CacheEvict(value = {"redis_listWithTree", "redis_columnDisplayFloatingBar", "redis_listWithTreeMenuVisible",
"redis_showTheFooterAccordingToTheColumn", "redis_articlesByColumnType", "redis_columnDetails", "redis_controlDisplayNavigationMenu"}, "redis_showTheFooterAccordingToTheColumn", "redis_articlesByColumnType", "redis_columnDetails",
allEntries = true) "redis_controlDisplayNavigationMenu", "redis_newlyPublishedArticles"}, allEntries = true)
public R newlyPublishedArticles(@Valid @RequestBody PageContentReqVO content) { public R newlyPublishedArticles(@Valid @RequestBody PageContentReqVO content) {
return service.newlyPublishedArticles(content); return service.newlyPublishedArticles(content);
} }
@ -202,10 +202,11 @@ public class SysContentController {
@PostMapping("/articleEnableOrDisable") @PostMapping("/articleEnableOrDisable")
@CacheEvict(value = {"redis_listWithTree", "redis_columnDisplayFloatingBar", "redis_listWithTreeMenuVisible", @CacheEvict(value = {"redis_listWithTree", "redis_columnDisplayFloatingBar", "redis_listWithTreeMenuVisible",
"redis_showTheFooterAccordingToTheColumn", "redis_articlesByColumnType", "redis_columnDetails", "redis_controlDisplayNavigationMenu"}, "redis_showTheFooterAccordingToTheColumn", "redis_articlesByColumnType", "redis_columnDetails",
allEntries = true) "redis_controlDisplayNavigationMenu", "redis_newlyPublishedArticles"}, allEntries = true)
@ApiOperation(value = "文章启用禁用", response = SysContent.class) @ApiOperation(value = "文章启用禁用", response = SysContent.class)
public R articleEnableOrDisable(@ApiParam(name = "id", value = "文章id", required = true) @RequestParam Integer id, @ApiParam(name = "isDisable", value = "是否禁用(0默认,0启用 1禁用)", required = true) @RequestParam Integer isDisable) { public R articleEnableOrDisable(@ApiParam(name = "id", value = "文章id", required = true) @RequestParam Integer id,
@ApiParam(name = "isDisable", value = "是否禁用(0默认,0启用 1禁用)", required = true) @RequestParam Integer isDisable) {
UpdateWrapper<SysContent> updateWrapper = new UpdateWrapper<>(); UpdateWrapper<SysContent> updateWrapper = new UpdateWrapper<>();
updateWrapper.set("is_disable", isDisable); updateWrapper.set("is_disable", isDisable);
updateWrapper.eq("id", id); updateWrapper.eq("id", id);
@ -238,8 +239,8 @@ public class SysContentController {
@PostMapping("/articleTopOperation") @PostMapping("/articleTopOperation")
@CacheEvict(value = {"redis_listWithTree", "redis_columnDisplayFloatingBar", "redis_listWithTreeMenuVisible", @CacheEvict(value = {"redis_listWithTree", "redis_columnDisplayFloatingBar", "redis_listWithTreeMenuVisible",
"redis_showTheFooterAccordingToTheColumn", "redis_articlesByColumnType", "redis_columnDetails", "redis_controlDisplayNavigationMenu"}, "redis_showTheFooterAccordingToTheColumn", "redis_articlesByColumnType", "redis_columnDetails",
allEntries = true) "redis_controlDisplayNavigationMenu", "redis_newlyPublishedArticles"}, allEntries = true)
@ApiOperation(value = "文章置顶/取消置顶", response = SysContent.class) @ApiOperation(value = "文章置顶/取消置顶", response = SysContent.class)
public R articleTopOperation(@ApiParam(name = "isTop", value = "是否置顶(默认为0 不置顶 1为置顶)", required = true) @RequestParam Integer isTop, @ApiParam(name = "articleId", value = "文章Id", required = true) @RequestParam Integer articleId) { public R articleTopOperation(@ApiParam(name = "isTop", value = "是否置顶(默认为0 不置顶 1为置顶)", required = true) @RequestParam Integer isTop, @ApiParam(name = "articleId", value = "文章Id", required = true) @RequestParam Integer articleId) {
//是否置顶(默认为0 不置顶 1为置顶) //是否置顶(默认为0 不置顶 1为置顶)
@ -270,8 +271,7 @@ public class SysContentController {
@ApiOperation(value = "缓存用户存过的字段") @ApiOperation(value = "缓存用户存过的字段")
public R cacheField(@ApiParam(name = "userId", value = "用户id", required = true) @RequestParam Integer userId, public R cacheField(@ApiParam(name = "userId", value = "用户id", required = true) @RequestParam Integer userId,
@ApiParam(name = "fields", required = true, value = "字段(逗号隔开)") @RequestParam String fields, @ApiParam(name = "fields", required = true, value = "字段(逗号隔开)") @RequestParam String fields,
@ApiParam(name = "siteId", required = true, value = "站点id") @RequestParam Integer siteId @ApiParam(name = "siteId", required = true, value = "站点id") @RequestParam Integer siteId) {
) {
try { try {
String key = "articleFieldCache_" + "siteId_" + siteId + "userId_" + userId; String key = "articleFieldCache_" + "siteId_" + siteId + "userId_" + userId;

Loading…
Cancel
Save