缓存增加

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

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

@ -93,9 +93,9 @@ public class SysContentController {
}
@PostMapping("/save")
@CacheEvict(value = {"redis_listWithTree", "redis_columnDisplayFloatingBar","redis_listWithTreeMenuVisible",
"redis_showTheFooterAccordingToTheColumn", "redis_articlesByColumnType", "redis_columnDetails", "redis_controlDisplayNavigationMenu"},
allEntries = true)
@CacheEvict(value = {"redis_listWithTree", "redis_columnDisplayFloatingBar", "redis_listWithTreeMenuVisible",
"redis_showTheFooterAccordingToTheColumn", "redis_articlesByColumnType", "redis_columnDetails",
"redis_controlDisplayNavigationMenu", "redis_newlyPublishedArticles"}, allEntries = true)
@ApiOperation(value = "新增", response = SysContent.class)
public R save(@RequestBody @Valid @ApiParam(name = "文章管理对象", value = "传入json格式", required = true) SysContent sysContent) {
@ -115,9 +115,9 @@ public class SysContentController {
@PostMapping("/update")
@CacheEvict(value = {"redis_listWithTree", "redis_columnDisplayFloatingBar","redis_listWithTreeMenuVisible",
"redis_showTheFooterAccordingToTheColumn", "redis_articlesByColumnType", "redis_columnDetails", "redis_controlDisplayNavigationMenu"},
allEntries = true)
@CacheEvict(value = {"redis_listWithTree", "redis_columnDisplayFloatingBar", "redis_listWithTreeMenuVisible",
"redis_showTheFooterAccordingToTheColumn", "redis_articlesByColumnType", "redis_columnDetails",
"redis_controlDisplayNavigationMenu", "redis_newlyPublishedArticles"}, allEntries = true)
@ApiOperation(value = "修改", response = SysContent.class)
public R update(@RequestBody @ApiParam(name = "文章管理对象", value = "传入json格式", required = true) SysContent sysContent) {
boolean updateState = service.updateById(sysContent);
@ -126,9 +126,9 @@ public class SysContentController {
@PostMapping("/delete")
@CacheEvict(value = {"redis_listWithTree", "redis_columnDisplayFloatingBar","redis_listWithTreeMenuVisible",
"redis_showTheFooterAccordingToTheColumn", "redis_articlesByColumnType", "redis_columnDetails", "redis_controlDisplayNavigationMenu"},
allEntries = true)
@CacheEvict(value = {"redis_listWithTree", "redis_columnDisplayFloatingBar", "redis_listWithTreeMenuVisible",
"redis_showTheFooterAccordingToTheColumn", "redis_articlesByColumnType", "redis_columnDetails",
"redis_controlDisplayNavigationMenu", "redis_newlyPublishedArticles"}, allEntries = true)
@ApiOperation(value = "删除", response = SysContent.class)
public R delete(@ApiParam(name = "id", value = "主键", required = true) @RequestParam Integer id) {
UpdateWrapper<SysFilesEntity> queryWrapper = new UpdateWrapper<>();
@ -142,9 +142,9 @@ public class SysContentController {
@PostMapping("/batchDeletion")
@CacheEvict(value = {"redis_listWithTree", "redis_columnDisplayFloatingBar","redis_listWithTreeMenuVisible",
"redis_showTheFooterAccordingToTheColumn", "redis_articlesByColumnType", "redis_columnDetails", "redis_controlDisplayNavigationMenu"},
allEntries = true)
@CacheEvict(value = {"redis_listWithTree", "redis_columnDisplayFloatingBar", "redis_listWithTreeMenuVisible",
"redis_showTheFooterAccordingToTheColumn", "redis_articlesByColumnType", "redis_columnDetails",
"redis_controlDisplayNavigationMenu", "redis_newlyPublishedArticles"}, allEntries = true)
@ApiOperation(value = "批量删除文章", response = SysContent.class)
public R batchDeletion(@ApiParam(name = "ids", value = "主键", required = true) @RequestParam List<Integer> ids) {
for (Integer id : ids) {
@ -167,9 +167,9 @@ public class SysContentController {
@PostMapping("/newlyPublishedArticles")
@ApiOperation(value = "站点最新发布的文章", response = PageContentReqVO.class)
@Cacheable(value = "redis_newlyPublishedArticles", key = "#content.toString()")
@CacheEvict(value = {"redis_listWithTree", "redis_columnDisplayFloatingBar","redis_listWithTreeMenuVisible",
"redis_showTheFooterAccordingToTheColumn", "redis_articlesByColumnType", "redis_columnDetails", "redis_controlDisplayNavigationMenu"},
allEntries = true)
@CacheEvict(value = {"redis_listWithTree", "redis_columnDisplayFloatingBar", "redis_listWithTreeMenuVisible",
"redis_showTheFooterAccordingToTheColumn", "redis_articlesByColumnType", "redis_columnDetails",
"redis_controlDisplayNavigationMenu", "redis_newlyPublishedArticles"}, allEntries = true)
public R newlyPublishedArticles(@Valid @RequestBody PageContentReqVO content) {
return service.newlyPublishedArticles(content);
}
@ -201,11 +201,12 @@ public class SysContentController {
@PostMapping("/articleEnableOrDisable")
@CacheEvict(value = {"redis_listWithTree", "redis_columnDisplayFloatingBar","redis_listWithTreeMenuVisible",
"redis_showTheFooterAccordingToTheColumn", "redis_articlesByColumnType", "redis_columnDetails", "redis_controlDisplayNavigationMenu"},
allEntries = true)
@CacheEvict(value = {"redis_listWithTree", "redis_columnDisplayFloatingBar", "redis_listWithTreeMenuVisible",
"redis_showTheFooterAccordingToTheColumn", "redis_articlesByColumnType", "redis_columnDetails",
"redis_controlDisplayNavigationMenu", "redis_newlyPublishedArticles"}, allEntries = true)
@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.set("is_disable", isDisable);
updateWrapper.eq("id", id);
@ -237,9 +238,9 @@ public class SysContentController {
@PostMapping("/articleTopOperation")
@CacheEvict(value = {"redis_listWithTree", "redis_columnDisplayFloatingBar","redis_listWithTreeMenuVisible",
"redis_showTheFooterAccordingToTheColumn", "redis_articlesByColumnType", "redis_columnDetails", "redis_controlDisplayNavigationMenu"},
allEntries = true)
@CacheEvict(value = {"redis_listWithTree", "redis_columnDisplayFloatingBar", "redis_listWithTreeMenuVisible",
"redis_showTheFooterAccordingToTheColumn", "redis_articlesByColumnType", "redis_columnDetails",
"redis_controlDisplayNavigationMenu", "redis_newlyPublishedArticles"}, allEntries = true)
@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) {
//是否置顶(默认为0 不置顶 1为置顶)
@ -270,8 +271,7 @@ public class SysContentController {
@ApiOperation(value = "缓存用户存过的字段")
public R cacheField(@ApiParam(name = "userId", value = "用户id", required = true) @RequestParam Integer userId,
@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 {
String key = "articleFieldCache_" + "siteId_" + siteId + "userId_" + userId;
@ -310,7 +310,7 @@ public class SysContentController {
// 直接将字符串分割成列表
String cachedFieldsStr = (String) cachedFieldsObj;
if (cachedFieldsStr.isEmpty()){
if (cachedFieldsStr.isEmpty()) {
return R.success();
}
List<String> fields = Arrays.asList(cachedFieldsStr.split(","));

Loading…
Cancel
Save