浏览代码

95:红德堂APP调试

获取文章列表查询修改
缓存修改
Long 1 天之前
父节点
当前提交
8beee66987

+ 2 - 14
fs-service/src/main/java/com/fs/his/mapper/FsArticleMapper.java

@@ -65,21 +65,9 @@ public interface FsArticleMapper
      * @return 结果
      */
     public int deleteFsArticleByArticleIds(Long[] articleIds);
-    @Select({"<script> " +
-            "select a.*  from fs_article a    " +
-            "where 1=1  " +
-            "<if test = 'maps.keyword != null     '> " +
-            "and a.title like CONCAT(#{maps.keyword},'%')" +
-            "</if>" +
-            "<if test = 'maps.isTui != null     '> " +
-            "and a.is_tui = #{maps.isTui} " +
-            "</if>" +
-            "<if test = 'maps.cateId != null and maps.cateId !=0    '> " +
-            "and a.cate_id = #{maps.cateId} " +
-            "</if>" +
-            " order by a.article_id desc "+
-            "</script>"})
+
     List<FsArticleListUVO> selectFsArticleListUVO(@Param("maps")FsArticleListUParam param);
+
     @Update("update fs_article set views=views+1 where article_id=#{articleId}")
     int updateFsArticleViews(Long articleId);
 

+ 19 - 1
fs-service/src/main/resources/mapper/his/FsArticleMapper.xml

@@ -43,7 +43,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <include refid="selectFsArticleVo"/>
         where article_id = #{articleId}
     </select>
-        
+
+    <select id="selectFsArticleListUVO" resultType="com.fs.his.vo.FsArticleListUVO">
+        select
+            a.*
+        from fs_article a
+        inner join fs_article_cate c on c.cate_id = a.cate_id
+        where c.status = 1 and c.is_del = 0
+        <if test = 'maps.cateId != null and maps.cateId !=0'>
+            and a.cate_id = #{maps.cateId}
+        </if>
+        <if test = 'maps.isTui != null'>
+            and a.is_tui = #{maps.isTui}
+        </if>
+        <if test="maps.keyword != null and maps.keyword != ''">
+            and a.title like concat('%', #{maps.keyword}, '%')
+        </if>
+        order by a.article_id desc
+    </select>
+
     <insert id="insertFsArticle" parameterType="FsArticle" useGeneratedKeys="true" keyProperty="articleId">
         insert into fs_article
         <trim prefix="(" suffix=")" suffixOverrides=",">

+ 1 - 1
fs-user-app/src/main/java/com/fs/app/controller/ArticleController.java

@@ -43,7 +43,7 @@ public class ArticleController {
 	@Autowired
 	private IFsArticleCateService articleCateService;
 
-	@Cacheable(value="getArticleCateList", key = "#status")
+	@Cacheable(value="getArticleCateList", key = "#status != null ? #status : 'getArticleCateList'")
 	@ApiOperation("获取文章分类列表")
 	@GetMapping("/getArticleCateList")
 	public R getArticleCateList(@RequestParam(required = false) Integer status){

+ 12 - 26
fs-user-app/src/main/java/com/fs/framework/config/RedisConfig.java

@@ -5,21 +5,13 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo;
 import com.fasterxml.jackson.annotation.PropertyAccessor;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.cache.CacheManager;
 import org.springframework.cache.annotation.CachingConfigurerSupport;
 import org.springframework.cache.annotation.EnableCaching;
-import org.springframework.cache.concurrent.ConcurrentMapCache;
-import org.springframework.cache.concurrent.ConcurrentMapCacheManager;
-import org.springframework.cache.interceptor.KeyGenerator;
-import org.springframework.cache.interceptor.SimpleKeyGenerator;
-import org.springframework.cache.support.SimpleCacheManager;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.data.redis.cache.RedisCacheConfiguration;
 import org.springframework.data.redis.cache.RedisCacheManager;
 import org.springframework.data.redis.connection.RedisConnectionFactory;
-import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.data.redis.core.script.DefaultRedisScript;
 import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
@@ -28,11 +20,6 @@ import org.springframework.data.redis.serializer.RedisSerializationContext;
 import org.springframework.data.redis.serializer.StringRedisSerializer;
 
 import java.time.Duration;
-import java.util.Arrays;
-
-import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
-import org.springframework.data.redis.serializer.RedisSerializationContext;
-import org.springframework.data.redis.serializer.StringRedisSerializer;
 
 /**
  * redis配置
@@ -43,20 +30,19 @@ import org.springframework.data.redis.serializer.StringRedisSerializer;
 @EnableCaching
 public class RedisConfig extends CachingConfigurerSupport
 {
-//    @Bean
-//    public CacheManager cacheManager() {
-//        SimpleCacheManager cacheManager = new SimpleCacheManager();
-//        cacheManager.setCaches(Arrays.asList(
-//                new ConcurrentMapCache("getCourseCate"),
-//                new ConcurrentMapCache("getProductCateByPid"),
-//                new ConcurrentMapCache("getCourseList"),
-//                new ConcurrentMapCache("getAppAdvList"),
-//                new ConcurrentMapCache("getAdvList")
-//        ));
-//        return cacheManager;
-//    }
-
 
+    @Bean
+    public RedisCacheManager cacheManager(RedisConnectionFactory connectionFactory) {
+        RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig()
+                .entryTtl(Duration.ofSeconds(30))
+                .serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(new StringRedisSerializer()))
+                .serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(new GenericJackson2JsonRedisSerializer()))
+                .disableCachingNullValues();
+
+        return RedisCacheManager.builder(connectionFactory)
+                .cacheDefaults(config)
+                .build();
+    }
 
     @Bean
     @SuppressWarnings(value = { "unchecked", "rawtypes" })