diff --git a/src/main/java/com/huoran/iasf/IASFApplication.java b/src/main/java/com/huoran/iasf/IASFApplication.java index 333e112..5a0bdcf 100644 --- a/src/main/java/com/huoran/iasf/IASFApplication.java +++ b/src/main/java/com/huoran/iasf/IASFApplication.java @@ -5,6 +5,7 @@ import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.web.servlet.ServletComponentScan; +import org.springframework.cache.annotation.EnableCaching; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.core.env.Environment; @@ -13,6 +14,7 @@ import java.net.InetAddress; @SpringBootApplication @MapperScan("com.huoran.iasf.mapper") @Slf4j +@EnableCaching @ServletComponentScan(basePackages = {"com.huoran.iasf.common.filter"}) //这一句完成了配置,Springboot的”懒理念“真的厉害。 public class IASFApplication { diff --git a/src/main/java/com/huoran/iasf/common/utils/R.java b/src/main/java/com/huoran/iasf/common/utils/R.java index 14d5966..b26fbbf 100644 --- a/src/main/java/com/huoran/iasf/common/utils/R.java +++ b/src/main/java/com/huoran/iasf/common/utils/R.java @@ -5,6 +5,8 @@ import com.huoran.iasf.common.exception.code.ResponseCodeInterface; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.io.Serializable; + /** * 返回值R * @@ -13,8 +15,8 @@ import lombok.Data; * @date 2022年7月28日 */ @Data -public class R { - +public class R implements Serializable { + private static final long serialVersionUID = 1L; /** * 请求响应code,0为成功 其他为失败 */ diff --git a/src/main/java/com/huoran/iasf/controller/LogoController.java b/src/main/java/com/huoran/iasf/controller/LogoController.java index d8e0dfc..f394914 100644 --- a/src/main/java/com/huoran/iasf/controller/LogoController.java +++ b/src/main/java/com/huoran/iasf/controller/LogoController.java @@ -8,6 +8,8 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.Cacheable; import org.springframework.web.bind.annotation.*; import java.util.List; @@ -34,6 +36,8 @@ public class LogoController { * @return R 结果对象,包含操作状态信息 */ @PostMapping("/saveOrUpdate") + @CacheEvict(value = {"redis_LogoDetails"}, + allEntries = true) @ApiOperation(value = "保存或更新系统logo设置记录", response = Logo.class) public R saveOrUpdate(@RequestBody @ApiParam(name = "系统logo设置对象", value = "包含系统logo设置详细信息,若id不存在则新建,否则视为更新", required = true) Logo logo) { @@ -51,6 +55,7 @@ public class LogoController { @PostMapping("/findById") @ApiOperation(value = "查询详情", response = Logo.class) + @Cacheable(value = "redis_LogoDetails", key = "#siteId") public R findById(@ApiParam(name = "siteId", value = "主键", required = true) @RequestParam Integer siteId) { //根据站点id查询站点信息 QueryWrapper queryWrapper = new QueryWrapper<>(); diff --git a/src/main/java/com/huoran/iasf/controller/SysColumnController.java b/src/main/java/com/huoran/iasf/controller/SysColumnController.java index fc92dd3..fedea57 100644 --- a/src/main/java/com/huoran/iasf/controller/SysColumnController.java +++ b/src/main/java/com/huoran/iasf/controller/SysColumnController.java @@ -1,6 +1,7 @@ package com.huoran.iasf.controller; import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.huoran.iasf.common.aop.annotation.NoRepeatSubmit; @@ -18,6 +19,8 @@ import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.Cacheable; import org.springframework.data.redis.RedisConnectionFailureException; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.web.bind.annotation.*; @@ -63,12 +66,14 @@ public class SysColumnController { @PostMapping("/listWithTree") @ApiOperation(value = "栏目树结构", response = SysColumn.class) + @Cacheable(value = "redis_listWithTree", key = "#sysColumn.toString()") public R listWithTree(@RequestBody @Valid PaginationColumnReqVO sysColumn) { return R.success(service.listWithTree(sysColumn)); } @PostMapping("/listWithTreeMenuVisible") @ApiOperation(value = "栏目树结构(前台可见,只展示试单可见的栏目)", response = SysColumn.class) + @Cacheable(value = "redis_listWithTreeMenuVisible", key = "#sysColumn.toString()") public R listWithTreeMenuVisible(@RequestBody @Valid PaginationColumnReqVO sysColumn) { return R.success(service.listWithTreeMenuVisible(sysColumn)); } @@ -76,6 +81,7 @@ public class SysColumnController { @PostMapping("/findById") @ApiOperation(value = "查询详情", response = SysColumn.class) + @Cacheable(value = "redis_columnDetails", key = "#id") public R findById(@RequestParam("id") @ApiParam(value = "主键ID") Integer id) { SysColumn sysColumn = service.getById(id); if (sysColumn == null) { @@ -83,11 +89,11 @@ public class SysColumnController { } SysTemplateStyle sysTemplateStyle = styleService.getById(sysColumn.getListStyleId()); - if (!ObjectUtil.isEmpty(sysTemplateStyle)){ - if (!ObjectUtil.isEmpty(sysTemplateStyle.getPath())) { - sysColumn.setPath(sysTemplateStyle.getPath()); - } - } + if (!ObjectUtil.isEmpty(sysTemplateStyle)) { + if (!ObjectUtil.isEmpty(sysTemplateStyle.getPath())) { + sysColumn.setPath(sysTemplateStyle.getPath()); + } + } return R.success(sysColumn); } @@ -95,6 +101,9 @@ public class SysColumnController { @NoRepeatSubmit @PostMapping("/save") + @CacheEvict(value = {"redis_listWithTree", "redis_columnDisplayFloatingBar", + "redis_showTheFooterAccordingToTheColumn", "redis_articlesByColumnType", "redis_columnDetails","redis_listWithTreeMenuVisible"}, + allEntries = true) @ApiOperation(value = "新增", response = SysColumn.class) public R save(@RequestBody @Valid SysColumn sysColumn) { QueryWrapper queryWrapper = new QueryWrapper(); @@ -105,7 +114,9 @@ public class SysColumnController { return addState ? R.success(sysColumn.getId()) : R.fail("新增失败"); } - @PostMapping("/update") + @CacheEvict(value = {"redis_listWithTree", "redis_columnDisplayFloatingBar", + "redis_showTheFooterAccordingToTheColumn", "redis_articlesByColumnType", "redis_columnDetails","redis_listWithTreeMenuVisible"}, + allEntries = true) @ApiOperation(value = "修改", response = SysColumn.class) public R update(@RequestBody SysColumn sysColumn) { boolean updateState = service.updateById(sysColumn); @@ -124,10 +135,10 @@ public class SysColumnController { 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 - ) { + ) { try { - String key = "fieldCache_" +"siteId_" +siteId +"userId_"+ userId; + String key = "fieldCache_" + "siteId_" + siteId + "userId_" + userId; redisTemplate.opsForValue().set(key, fields); return R.success("字段缓存成功"); } catch (RedisConnectionFailureException e) { @@ -136,7 +147,6 @@ public class SysColumnController { } - /** * 根据用户ID和站点ID获取缓存的字段列表。 * 该接口通过组合用户ID和站点ID作为键,从Redis缓存中获取字段列表。如果缓存中不存在相应的数据, @@ -152,7 +162,7 @@ public class SysColumnController { @ApiParam(name = "siteId", required = true, value = "站点id") @RequestParam Integer siteId) { try { // 组合键名,用于在Redis中查找缓存数据。 - String key = "fieldCache_" +"siteId_" +siteId +"userId_"+ userId; + String key = "fieldCache_" + "siteId_" + siteId + "userId_" + userId; // 从Redis中获取缓存数据。 Object cachedFieldsObj = redisTemplate.opsForValue().get(key); @@ -169,8 +179,8 @@ public class SysColumnController { // 将缓存的字符串转换为字段列表。 // 直接将字符串分割成列表 String cachedFieldsStr = (String) cachedFieldsObj; - if (cachedFieldsStr.isEmpty()){ - return R.success(); + if (cachedFieldsStr.isEmpty()) { + return R.success(); } List fields = Arrays.asList(cachedFieldsStr.split(",")); @@ -185,7 +195,8 @@ public class SysColumnController { @PostMapping("/controlDisplayNavigationMenu") @ApiOperation(value = "控制显示导航菜单", response = SysColumn.class) - 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); column.setMenuVisible(menuVisible);//菜单是否可见(默认0可见 1不可见) @@ -195,8 +206,7 @@ public class SysColumnController { } - - /** + /** * 批量删除栏目及其关联的内容和长页信息。 * 接收一个包含栏目ID的列表,遍历这些ID以执行以下操作: * 1. 更新与栏目关联的文件记录为已删除状态。 @@ -210,6 +220,9 @@ public class SysColumnController { */ @NoRepeatSubmit @PostMapping("/batchDeletion") + @CacheEvict(value = {"redis_listWithTree", "redis_columnDisplayFloatingBar", + "redis_showTheFooterAccordingToTheColumn", "redis_articlesByColumnType", "redis_columnDetails"}, + allEntries = true) @ApiOperation(value = "批量删除栏目", response = SysColumn.class) public R batchDeletion(@ApiParam(name = "ids", value = "栏目ID列表", required = true) @RequestParam List ids) { for (Integer id : ids) { @@ -242,14 +255,13 @@ public class SysColumnController { } - @PostMapping("/sameLevelJudgment") @ApiOperation(value = "同级判重", response = ColumnWeightReqVO.class) public R sameLevelJudgment(@RequestBody @Valid ColumnWeightReqVO sysColumn) { return service.sameLevelJudgment(sysColumn) ? R.success() : R.fail("同级下已存在重复栏目!"); } - /** + /** * 根据传入的栏目排序信息更新栏目顺序。 * 遍历接收到的排序信息列表,针对每个栏目验证同级下是否有名称相同的栏目存在(排除自身), * 若无冲突则更新该栏目的排序信息。 @@ -267,9 +279,9 @@ public class SysColumnController { // 构建查询条件,检查同级下是否有名称相同的其他栏目(排除自己) QueryWrapper queryWrapper = new QueryWrapper<>(); 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 conflictingColumns = service.list(queryWrapper); @@ -292,7 +304,8 @@ public class SysColumnController { @ApiOperation("获取一级下的子级栏目") @PostMapping("/getsTheSubColumn") - public R getsTheSubColumn(@ApiParam(name = "id", value = "id", required = true) @RequestParam Integer id, @ApiParam(name = "siteId", value = "站点id", required = true) @RequestParam Integer siteId) { + public R getsTheSubColumn(@ApiParam(name = "id", value = "id", required = true) @RequestParam Integer id, + @ApiParam(name = "siteId", value = "站点id", required = true) @RequestParam Integer siteId) { String ids = this.getIds(id); return service.getsTheSubColumn(id, ids, siteId); @@ -366,7 +379,10 @@ public class SysColumnController { @ApiOperation("某一级查全部") @PostMapping("/oneLevelChecksThemAll") - public R oneLevelChecksThemAll(@ApiParam(name = "id", value = "栏目id", required = true) @RequestParam Integer id, @ApiParam(name = "isSort", value = "判断是否为排序接口调用(1为排序接口调用 0我栏目管理列表调用)", required = true) @RequestParam Integer isSort, @ApiParam(name = "ids", value = "主键", required = true) @RequestParam Integer siteId) { + public R oneLevelChecksThemAll(@ApiParam(name = "id", value = "栏目id", required = true) @RequestParam Integer id, + @ApiParam(name = "isSort", value = "判断是否为排序接口调用(1为排序接口调用 0我栏目管理列表调用)", required = + true) @RequestParam Integer isSort, @ApiParam(name = "ids", value = "主键", + required = true) @RequestParam Integer siteId) { Integer pid = service.oneLevelChecksThemAll(id); String ids = this.getIds(pid); @@ -383,8 +399,12 @@ public class SysColumnController { */ @ApiOperation("查询栏目下的文章(若选中栏目与子级全部栏目类型一致返回全部文章,反之查询选中栏目下的文章)") @PostMapping("/queryArticlesByColumnType") + @Cacheable(value = "redis_articlesByColumnType", key = "#ids + '-' + #id") public R queryArticlesByColumnType(@ApiParam(name = "columnId", value = "栏目id", required = true) @RequestParam Integer columnId) { String ids = this.getIds(columnId); + if (StrUtil.isBlank(ids)) { + return R.fail("栏目类型ID字符串不能为空"); + } return service.queryArticlesByColumnType(ids, columnId); } diff --git a/src/main/java/com/huoran/iasf/controller/SysContentController.java b/src/main/java/com/huoran/iasf/controller/SysContentController.java index 9f476cb..3c2914b 100644 --- a/src/main/java/com/huoran/iasf/controller/SysContentController.java +++ b/src/main/java/com/huoran/iasf/controller/SysContentController.java @@ -23,6 +23,7 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.Cacheable; import org.springframework.data.redis.RedisConnectionFailureException; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.web.bind.annotation.*; @@ -152,6 +153,7 @@ public class SysContentController { @PostMapping("/newlyPublishedArticles") @ApiOperation(value = "站点最新发布的文章", response = PageContentReqVO.class) + @Cacheable(value = "redis_newlyPublishedArticles", key = "#content.toString()") public R newlyPublishedArticles(@Valid @RequestBody PageContentReqVO content) { return service.newlyPublishedArticles(content); } diff --git a/src/main/java/com/huoran/iasf/controller/SysFloatingColumnSchemeController.java b/src/main/java/com/huoran/iasf/controller/SysFloatingColumnSchemeController.java index 9b22452..b6d1e88 100644 --- a/src/main/java/com/huoran/iasf/controller/SysFloatingColumnSchemeController.java +++ b/src/main/java/com/huoran/iasf/controller/SysFloatingColumnSchemeController.java @@ -17,6 +17,7 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.Cacheable; import org.springframework.web.bind.annotation.*; import java.util.HashSet; @@ -53,7 +54,8 @@ public class SysFloatingColumnSchemeController { */ @PostMapping("/saveOrUpdate") @ApiOperation(value = "保存或更新悬浮栏方案记录", response = SysFloatingColumnScheme.class) - public R saveOrUpdate(@RequestBody @ApiParam(name = "悬浮栏方案对象", value = "包含悬浮栏方案详细信息,若id不存在则新建,否则视为更新", required = true) SysFloatingColumnScheme sysFloatingColumnScheme) { + public R saveOrUpdate(@RequestBody @ApiParam(name = "悬浮栏方案对象", value = "包含悬浮栏方案详细信息,若id不存在则新建,否则视为更新", required = + true) SysFloatingColumnScheme sysFloatingColumnScheme) { // 校验集合内是否有重复的schemeTitle Set schemeTitles = new HashSet<>(); @@ -68,9 +70,11 @@ public class SysFloatingColumnSchemeController { } } - if (sysFloatingColumnScheme.getId() != null&&sysFloatingColumnScheme.getIsDisable()==0){ - ConflictCheckResultVO conflictCheckResultVO = service.preCheckMultiScopeConflictBeforeUpdate(sysFloatingColumnScheme.getSiteId(), - sysFloatingColumnScheme.getFloatingColumnSchemeScopeOfApplications(),sysFloatingColumnScheme.getId()); + if (sysFloatingColumnScheme.getId() != null && sysFloatingColumnScheme.getIsDisable() == 0) { + ConflictCheckResultVO conflictCheckResultVO = + service.preCheckMultiScopeConflictBeforeUpdate(sysFloatingColumnScheme.getSiteId(), + sysFloatingColumnScheme.getFloatingColumnSchemeScopeOfApplications(), + sysFloatingColumnScheme.getId()); if (conflictCheckResultVO.isHasConflict()) { return R.fail(conflictCheckResultVO.getMessage()); } @@ -85,15 +89,18 @@ public class SysFloatingColumnSchemeController { } // 编辑场景下,只有当名称发生改变时才进行校验,并排除当前记录自身 else if (!sysFloatingColumnScheme.getSchemeName().equals(service.getById(sysFloatingColumnScheme.getId()).getSchemeName())) { - if (checkSchemeNameExceptSelf(sysFloatingColumnScheme.getSchemeName(), sysFloatingColumnScheme.getSiteId(), sysFloatingColumnScheme.getId())) { + if (checkSchemeNameExceptSelf(sysFloatingColumnScheme.getSchemeName(), + sysFloatingColumnScheme.getSiteId(), sysFloatingColumnScheme.getId())) { return R.fail("该站点下已存在相同的悬浮栏方案名称"); } } //获取floatingColumnSchemeScopeOfApplications中的范围判断是不是0,如果包含为0 - List floatingColumnSchemeScopeOfApplications = sysFloatingColumnScheme.getFloatingColumnSchemeScopeOfApplications(); - for (SysFloatingColumnSchemeScopeOfApplication floatingColumnSchemeScopeOfApplication : floatingColumnSchemeScopeOfApplications) { + List floatingColumnSchemeScopeOfApplications = + sysFloatingColumnScheme.getFloatingColumnSchemeScopeOfApplications(); + for (SysFloatingColumnSchemeScopeOfApplication floatingColumnSchemeScopeOfApplication : + floatingColumnSchemeScopeOfApplications) { if (floatingColumnSchemeScopeOfApplication.getApplicationScopeId().equals("0")) { sysFloatingColumnScheme.setIsGlobal(1); @@ -148,6 +155,7 @@ public class SysFloatingColumnSchemeController { @PostMapping("/columnDisplayFloatingBar") @ApiOperation(value = "根据栏目展示悬浮栏", response = SysFloatingColumnSchemeVO.class) + @Cacheable(value = "redis_columnDisplayFloatingBar", key = "#columnId") public R columnDisplayFloatingBar(@ApiParam(name = "columnId", value = "栏目id", required = true) @RequestParam String columnId) { return service.columnDisplayFloatingBar(columnId); } @@ -167,7 +175,8 @@ public class SysFloatingColumnSchemeController { */ @PostMapping("/enableOrDisableScheme") @ApiOperation(value = "启用或禁用", response = SysFloatingColumnSchemeVO.class) - public R enableOrDisableScheme(@ApiParam(name = "id", value = "主键", required = true) @RequestParam Integer id, @ApiParam(name = "isDisable", value = "是否禁用(0启用 1禁用)", required = true) @RequestParam Integer isDisable) { + public R enableOrDisableScheme(@ApiParam(name = "id", value = "主键", required = true) @RequestParam Integer id, + @ApiParam(name = "isDisable", value = "是否禁用(0启用 1禁用)", required = true) @RequestParam Integer isDisable) { /* return service.enableOrDisableScheme(id, isDisable);*/ //禁启用操作 @@ -192,7 +201,8 @@ public class SysFloatingColumnSchemeController { @PostMapping("/checkEnableOrDisable") @ApiOperation(value = "检查“启用”或“禁用”()", response = SysFloatingColumnSchemeVO.class) - public R checkEnableOrDisable(@ApiParam(name = "id", value = "主键", required = true) @RequestParam Integer id, @ApiParam(name = "isDisable", value = "是否禁用(0启用 1禁用)", required = true) @RequestParam Integer isDisable) { + public R checkEnableOrDisable(@ApiParam(name = "id", value = "主键", required = true) @RequestParam Integer id, + @ApiParam(name = "isDisable", value = "是否禁用(0启用 1禁用)", required = true) @RequestParam Integer isDisable) { return service.checkEnableOrDisable(id, isDisable); } @@ -202,8 +212,10 @@ public class SysFloatingColumnSchemeController { @ApiOperation(value = "查询详情", response = SysFloatingColumnScheme.class) public R findById(@ApiParam(name = "id", value = "主键", required = true) @RequestParam Integer id) { SysFloatingColumnScheme sysFloatingColumnScheme = service.getById(id); - List sysFloatingColumnSchemeScopeOfApplications = floatingColumnSchemeScopeOfApplicationService.getScopeOfApplicationByFloatingBarSchemeId(id); - List getModuleByFloatingBarSchemeId = floatingColumnSchemeModuleService.getModuleByFloatingBarSchemeId(id); + List sysFloatingColumnSchemeScopeOfApplications = + floatingColumnSchemeScopeOfApplicationService.getScopeOfApplicationByFloatingBarSchemeId(id); + List getModuleByFloatingBarSchemeId = + floatingColumnSchemeModuleService.getModuleByFloatingBarSchemeId(id); sysFloatingColumnScheme.setFloatingColumnSchemeScopeOfApplications(sysFloatingColumnSchemeScopeOfApplications); sysFloatingColumnScheme.setFloatingColumnSchemeModules(getModuleByFloatingBarSchemeId); return R.success(sysFloatingColumnScheme); @@ -224,7 +236,8 @@ public class SysFloatingColumnSchemeController { queryWrapper.eq(SysFloatingColumnSchemeModule::getFloatingBarSchemeId, removeId); floatingColumnSchemeModuleService.remove(queryWrapper); - LambdaQueryWrapper queryWrapper1 = new LambdaQueryWrapper<>(); + LambdaQueryWrapper queryWrapper1 = + new LambdaQueryWrapper<>(); queryWrapper1.eq(SysFloatingColumnSchemeScopeOfApplication::getFloatingBarSchemeId, removeId); floatingColumnSchemeScopeOfApplicationService.remove(queryWrapper1); } @@ -280,7 +293,8 @@ public class SysFloatingColumnSchemeController { private void handleFloatingColumnSchemeScopeOfApplications(SysFloatingColumnScheme sysFloatingColumnScheme) { if (sysFloatingColumnScheme.getFloatingColumnSchemeScopeOfApplications() != null && !sysFloatingColumnScheme.getFloatingColumnSchemeScopeOfApplications().isEmpty()) { - for (SysFloatingColumnSchemeScopeOfApplication scope : sysFloatingColumnScheme.getFloatingColumnSchemeScopeOfApplications()) { + for (SysFloatingColumnSchemeScopeOfApplication scope : + sysFloatingColumnScheme.getFloatingColumnSchemeScopeOfApplications()) { scope.setFloatingBarSchemeId(sysFloatingColumnScheme.getId()); if (sysFloatingColumnScheme.getId() == null) { // 如果悬浮栏方案是新建的,直接保存范围 diff --git a/src/main/java/com/huoran/iasf/controller/SysFooterSetupController.java b/src/main/java/com/huoran/iasf/controller/SysFooterSetupController.java index f8fab17..55631fe 100644 --- a/src/main/java/com/huoran/iasf/controller/SysFooterSetupController.java +++ b/src/main/java/com/huoran/iasf/controller/SysFooterSetupController.java @@ -18,6 +18,7 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.Cacheable; import org.springframework.web.bind.annotation.*; import java.util.List; @@ -169,6 +170,7 @@ public class SysFooterSetupController { @PostMapping("/showTheFooterAccordingToTheColumn") @ApiOperation(value = "根据栏目展示页脚", response = SysFloatingColumnSchemeVO.class) + @Cacheable(value = "redis_showTheFooterAccordingToTheColumn", key = "#columnId") public R columnDisplayFloatingBar(@ApiParam(name = "columnId", value = "栏目id", required = true) @RequestParam String columnId) { return service.showTheFooterAccordingToTheColumn(columnId); } diff --git a/src/main/java/com/huoran/iasf/service/SysColumnService.java b/src/main/java/com/huoran/iasf/service/SysColumnService.java index c04eeb2..b2971c8 100644 --- a/src/main/java/com/huoran/iasf/service/SysColumnService.java +++ b/src/main/java/com/huoran/iasf/service/SysColumnService.java @@ -7,6 +7,7 @@ import com.huoran.iasf.vo.req.ColumnWeightReqVO; import com.huoran.iasf.vo.req.LongPageColumnReqVO; import com.huoran.iasf.vo.req.PageContentReqVO; import com.huoran.iasf.vo.req.PaginationColumnReqVO; +import com.huoran.iasf.vo.resp.PageContentRespVO; import java.util.Collection; import java.util.List; @@ -41,7 +42,7 @@ public interface SysColumnService extends IService { R getSubColumn(Integer parentId,String ids,Integer isSort,Integer siteId); - R queryArticlesByColumnType(String ids,Integer id); + R queryArticlesByColumnType(String ids, Integer id); List getColumnNamesByIds(Collection applicationScopeIds); diff --git a/src/main/java/com/huoran/iasf/service/impl/SysColumnServiceImpl.java b/src/main/java/com/huoran/iasf/service/impl/SysColumnServiceImpl.java index 4531815..29a23f0 100644 --- a/src/main/java/com/huoran/iasf/service/impl/SysColumnServiceImpl.java +++ b/src/main/java/com/huoran/iasf/service/impl/SysColumnServiceImpl.java @@ -17,8 +17,13 @@ import com.huoran.iasf.vo.req.ColumnWeightReqVO; import com.huoran.iasf.vo.req.LongPageColumnReqVO; import com.huoran.iasf.vo.req.PaginationColumnReqVO; import com.huoran.iasf.vo.resp.PageContentRespVO; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections.CollectionUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.CacheManager; +import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; import java.util.*; @@ -30,6 +35,7 @@ import java.util.stream.Collectors; * @日期: 2022-08-01 */ @Service +@Slf4j public class SysColumnServiceImpl extends ServiceImpl implements SysColumnService { @Autowired @@ -37,6 +43,8 @@ public class SysColumnServiceImpl extends ServiceImpl getColumnNamesByIds(Collection applicationScopeIds) { if (CollectionUtils.isEmpty(applicationScopeIds)) { diff --git a/src/main/java/com/huoran/iasf/vo/resp/PageContentRespVO.java b/src/main/java/com/huoran/iasf/vo/resp/PageContentRespVO.java index 82179c9..f9dbfb5 100644 --- a/src/main/java/com/huoran/iasf/vo/resp/PageContentRespVO.java +++ b/src/main/java/com/huoran/iasf/vo/resp/PageContentRespVO.java @@ -7,6 +7,7 @@ import com.huoran.iasf.vo.FatherContentRespVO; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.io.Serializable; import java.util.Date; import java.util.List; @@ -16,8 +17,8 @@ import java.util.List; * @日期: 2022-08-05 */ @Data -public class PageContentRespVO { - +public class PageContentRespVO implements Serializable { + private static final long serialVersionUID = 1L; @TableId(type = IdType.AUTO) @ApiModelProperty(value = "主键")