Ver código fonte

修改了fastjson门面序列化

wuweihao 5 anos atrás
pai
commit
e81870e235

+ 42 - 0
gis_common/src/main/java/com/gis/common/config/WebMvcConfig.java

@@ -1,11 +1,20 @@
 package com.gis.common.config;
 
+import com.alibaba.fastjson.serializer.SerializerFeature;
+import com.alibaba.fastjson.support.config.FastJsonConfig;
+import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
+import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.http.MediaType;
 import org.springframework.web.servlet.config.annotation.CorsRegistry;
 import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * Created by owen on 2020/2/18 0018 12:01
  */
@@ -35,4 +44,37 @@ public class WebMvcConfig implements WebMvcConfigurer {
     public void addInterceptors(InterceptorRegistry registry) {
         registry.addInterceptor(commonInterceptor).addPathPatterns("/**");
     }
+
+
+    /**
+     * fastJson相关设置
+     * Dto包含json,需要配置不然会异常
+     * @return
+     */
+    @Bean
+    public HttpMessageConverters customConverters() {
+
+        FastJsonHttpMessageConverter fastJson = new FastJsonHttpMessageConverter();
+        // 创建FastJson信息转换对象
+        FastJsonConfig fastJsonConfig = new FastJsonConfig();
+
+
+        // 设置全程返回时间
+        fastJsonConfig.setDateFormat("yyyy-MM-dd HH:mm:ss");
+        // 设置返回值为null是时输出,不写的话,null 字段 不返回。也可以设置返回空串, 可以同时设置多个
+        fastJsonConfig.setSerializerFeatures(SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullStringAsEmpty);
+
+        fastJson.setFastJsonConfig(fastJsonConfig);
+
+        //3、中文乱码解决方案
+        List<MediaType> mediaTypeList = new ArrayList<>();
+        mediaTypeList.add(MediaType.APPLICATION_JSON_UTF8);
+        mediaTypeList.add(MediaType.valueOf("text/html;charset=UTF-8"));
+
+        //4、将转换规则应用于转换对象
+        fastJson.setSupportedMediaTypes(mediaTypeList);
+
+        return new HttpMessageConverters(fastJson);
+    }
+
 }

+ 2 - 2
gis_domain/src/main/java/com/gis/domain/po/GoodsEntity.java

@@ -32,8 +32,8 @@ public class GoodsEntity extends BaseEntity implements Serializable {
     private Integer viewCount;
 
 
-    @ApiModelProperty(value = "是否显示,1:是, 0:否")
-    private Integer display;
+//    @ApiModelProperty(value = "是否显示,1:是, 0:否")
+//    private Integer display;
 
     @ApiModelProperty(value = "提交用户Id")
     private Long submitId;

+ 0 - 33
gis_domain/src/main/java/com/gis/domain/po/TopicEntity.java

@@ -1,33 +0,0 @@
-package com.gis.domain.po;
-
-import lombok.Data;
-
-import javax.persistence.Table;
-import java.io.Serializable;
-
-/**
- * 主题表
- */
-@Data
-@Table(name = "tb_topic")
-public class TopicEntity extends BaseEntity implements Serializable {
-
-
-    private static final long serialVersionUID = -3394791736156714542L;
-
-    /**
-     * 操作者用户id
-     */
-    private Long userId;
-
-    /**
-     * 操作类型
-     */
-    private String type;
-
-    /**
-     * 操作记录
-     */
-    private String description;
-
-}

+ 3 - 0
gis_domain/src/main/java/com/gis/domain/vo/GoodsVo.java

@@ -37,4 +37,7 @@ public class GoodsVo extends BaseEntity {
     @ApiModelProperty(value = "原因")
     private String reason;
 
+    @ApiModelProperty(value = "阅读量")
+    private Integer viewCount;
+
 }

+ 7 - 4
gis_mapper/src/main/java/com/gis/mapper/CommonMapper.java

@@ -17,9 +17,12 @@ import java.util.Map;
 @Mapper
 public interface CommonMapper extends IBaseMapper<CommentEntity, Long> {
 
-    @Select(value = "select * from tb_topic where rec_status = 'A'")
-    Map getTopic();
+    @Select(value = "select * from tb_topic where rec_status = 'A' ")
+    List<Map> getTopic();
 
-    @Update(value = "update tb_topic set name = #{topic} where id = #{id} ")
-    void setTopic(Long id, String topic);
+    @Update(value = "update tb_topic set display = 1 where id = #{id} ")
+    void setTopic(Long id);
+
+    @Update(value = "update tb_topic set display = 0 ")
+    void setAllDisable();
 }

+ 1 - 1
gis_mapper/src/main/java/com/gis/mapper/provider/GoodsProvider.java

@@ -14,7 +14,7 @@ public class GoodsProvider {
 
     public String search(GoodsPageDateDto param){
         StringBuffer sql = new StringBuffer(
-                "select a.id, a.title, a.type, a.img, a.thumb, a.display, a.view_count, a.status, a.reason," +
+                "select a.id, a.title, a.type, a.img, a.thumb, a.display, a.view_count, a.status, a.reason, a.create_time, a.update_time, a.view_count," +
                         "a.submit_id, b.real_name as submit_name from tb_goods a left join sys_user b on b.id = a.submit_id where a.rec_status = 'A' ");
 
         if(StringUtils.isNotBlank(param.getStartTime()) ){

+ 1 - 1
gis_mapper/src/main/java/com/gis/mapper/provider/SlideshowProvider.java

@@ -13,7 +13,7 @@ public class SlideshowProvider {
 
     public String search(SlideshowPageDateDto param, Long userId){
         StringBuffer sql = new StringBuffer(
-                "select a.id, a.title, a.img, a.thumb, a.web_site, a.status, a.reason, a.sort, a.display" +
+                "select a.id, a.title, a.img, a.thumb, a.web_site, a.status, a.reason, a.sort, a.display, a.create_time, a.update_time, " +
                         "a.submit_id, b.real_name as submit_name from tb_slideshow a left join sys_user b on b.id = a.submit_id where a.rec_status = 'A' ");
 
         if(StringUtils.isNotBlank(param.getStartTime()) ){

+ 1 - 1
gis_mapper/src/main/java/com/gis/mapper/provider/VideoProvider.java

@@ -13,7 +13,7 @@ public class VideoProvider {
 
     public String search(PageDto param){
         StringBuffer sql = new StringBuffer(
-                "select a.id, a.title, a.img, a.thumb, a.display, a.video, " +
+                "select a.id, a.title, a.img, a.thumb, a.display, a.video, a.create_time, a.update_time, " +
                         "a.submit_id, b.real_name as submit_name from tb_video a left join sys_user b on b.id = a.submit_id where a.rec_status = 'A' ");
 
 

+ 5 - 4
gis_web/src/main/java/com/gis/web/controller/TopicController.java

@@ -38,15 +38,16 @@ public class TopicController extends BaseController {
     @ApiOperation("获取主题")
     @GetMapping("get")
     public Result getTopic() {
-        Map topic = commonMapper.getTopic();
+        List<Map> topic = commonMapper.getTopic();
         return Result.success(topic);
     }
 
     @WebControllerLog(description = "主题管理-设置主题")
     @ApiOperation("设置主题")
-    @GetMapping("set/{id}/{topic}")
-    public Result setTopic(@PathVariable Long id, @PathVariable String topic) {
-        commonMapper.setTopic(id, topic);
+    @GetMapping("set/{id}")
+    public Result setTopic(@PathVariable Long id) {
+        commonMapper.setAllDisable();
+        commonMapper.setTopic(id);
         return Result.success();
     }
 

+ 0 - 40
gis_web/src/main/java/com/gis/web/shiro/ShiroConfig.java

@@ -118,44 +118,4 @@ public class ShiroConfig {
         return advisor;
     }
 
-
-    /**
-     * fastJson相关设置
-     * Dto包含json,需要配置不然会异常
-     * @return
-     */
-    @Bean
-    public HttpMessageConverters customConverters() {
-//        log.warn("run customConverters");
-
-
-        FastJsonHttpMessageConverter fastJson = new FastJsonHttpMessageConverter();
-
-        // 创建FastJson信息转换对象
-        FastJsonConfig fastJsonConfig = new FastJsonConfig();
-
-
-        // 设置全程返回时间
-        fastJsonConfig.setDateFormat("yyyy-MM-dd HH:mm:ss");
-        // 设置返回值为null是时输出,不写的话,null 字段 不返回。也可以设置返回空串
-        fastJsonConfig.setSerializerFeatures(SerializerFeature.WriteNullStringAsEmpty);
-        fastJson.setFastJsonConfig(fastJsonConfig);
-
-        //3、中文乱码解决方案
-        List<MediaType> mediaTypeList = new ArrayList<>();
-        mediaTypeList.add(MediaType.APPLICATION_JSON_UTF8);
-        mediaTypeList.add(MediaType.valueOf("text/html;charset=UTF-8"));
-
-
-        //4、将转换规则应用于转换对象
-        fastJson.setSupportedMediaTypes(mediaTypeList);
-
-
-        return new HttpMessageConverters(fastJson);
-    }
-
-
-
-
-
 }