فهرست منبع

修改了fastjson门面序列化

wuweihao 5 سال پیش
والد
کامیت
1f15f27bb5

+ 1 - 2
gis_common/src/main/java/com/gis/common/config/CommonInterceptor.java

@@ -27,8 +27,7 @@ public class CommonInterceptor implements HandlerInterceptor {
 
 
 
 
         // uat环境禁止访问api文档
         // uat环境禁止访问api文档
-        if (active.equals("uat")) {
-            log.info("访问api文档拦截");
+        if (active.equals("pro")) {
             return !request.getRequestURI().contains("doc.html");
             return !request.getRequestURI().contains("doc.html");
         }
         }
 
 

+ 8 - 0
gis_common/src/main/java/com/gis/common/constant/TypeCode.java

@@ -13,4 +13,12 @@ public class TypeCode {
 
 
     /**文件外键id前缀*/
     /**文件外键id前缀*/
     public static final String FILE_GOODS = "goods_";
     public static final String FILE_GOODS = "goods_";
+
+
+    public static final String MODEL_GOODS_IMG = "goodsImg";
+
+    public static final String MODEL_GOODS_MODEL = "goodsModel";
+
+    public static final String MODEL_GOODS_VIDEO = "goodsVideo";
 }
 }
+

+ 1 - 1
gis_domain/src/main/java/com/gis/domain/dto/GoodsDto.java

@@ -30,7 +30,7 @@ public class GoodsDto {
     private String thumb;
     private String thumb;
 
 
     @ApiModelProperty(value = "文件id")
     @ApiModelProperty(value = "文件id")
-    private String fileIds;
+    private String fileId;
 
 
     @ApiModelProperty(value = "状态,1:草稿中,2:待审核,3:审核不通过,4:审核通过")
     @ApiModelProperty(value = "状态,1:草稿中,2:待审核,3:审核不通过,4:审核通过")
     private Integer status;
     private Integer status;

+ 9 - 2
gis_mapper/src/main/java/com/gis/mapper/FileMapper.java

@@ -7,6 +7,7 @@ import com.gis.mapper.provider.SpiritProvider;
 import org.apache.ibatis.annotations.*;
 import org.apache.ibatis.annotations.*;
 import org.springframework.data.jpa.repository.Modifying;
 import org.springframework.data.jpa.repository.Modifying;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
+import sun.awt.SunHints;
 
 
 import java.util.List;
 import java.util.List;
 
 
@@ -19,12 +20,18 @@ public interface FileMapper extends IBaseMapper<FileEntity, Long> {
 //    @Update(value = "UPDATE tb_file SET fk_id = #{fkId} WHERE id in ( #{ids} )")
 //    @Update(value = "UPDATE tb_file SET fk_id = #{fkId} WHERE id in ( #{ids} )")
 //    void setFkIdByIds(String ids, String fkId);
 //    void setFkIdByIds(String ids, String fkId);
 
 
-    @SelectProvider(type = FileProvider.class, method = "setFkIdByIds")
-    void setFkIdByIds(String ids, String fkId);
+    @Update(value = "update tb_file set fk_id = #{fkId}, type = #{type} where id = #{id} ")
+    void setFkIdByIds(String id, Long fkId, String type);
 
 
     @Select(value = "select * from tb_file where rec_status = 'A' AND fk_id = #{fkId}")
     @Select(value = "select * from tb_file where rec_status = 'A' AND fk_id = #{fkId}")
     List<FileEntity> findByFkId(String fkId);
     List<FileEntity> findByFkId(String fkId);
 
 
     @Delete(value = "DELETE FROM tb_file WHERE fk_id = #{fkId}")
     @Delete(value = "DELETE FROM tb_file WHERE fk_id = #{fkId}")
     void deleteByFkId(String fkId);
     void deleteByFkId(String fkId);
+
+    @Update(value = "update tb_file set cover = 0 where type = #{modelType} ")
+    void setCoverDefault(String modelType);
+
+    @Update(value = "update tb_file set cover = 1 where id = #{id}")
+    void setCover(Long id);
 }
 }

+ 9 - 1
gis_service/src/main/java/com/gis/service/FileService.java

@@ -11,9 +11,17 @@ import java.util.List;
 public interface FileService extends IBaseService<FileEntity, Long> {
 public interface FileService extends IBaseService<FileEntity, Long> {
 
 
 
 
-    void setFkIdByIds(String ids, String fkId);
+    void setFkIdByIds(String id, Long fkId, String type);
 
 
     List<FileEntity> findByFkId(String fkId);
     List<FileEntity> findByFkId(String fkId);
 
 
     void deleteByFkId(String fkId);
     void deleteByFkId(String fkId);
+
+    void setCoverDefault(String modelType);
+
+    /**
+     * 设置封面
+     * @param fileId
+     */
+    void setCover(Long fileId);
 }
 }

+ 12 - 2
gis_service/src/main/java/com/gis/service/impl/FileServiceImpl.java

@@ -26,8 +26,8 @@ public class FileServiceImpl extends IBaseServiceImpl<FileEntity, Long> implemen
 
 
 
 
     @Override
     @Override
-    public void setFkIdByIds(String ids, String fkId) {
-        entityMapper.setFkIdByIds(ids, fkId);
+    public void setFkIdByIds(String id, Long fkId, String type) {
+        entityMapper.setFkIdByIds(id, fkId, type);
     }
     }
 
 
     @Override
     @Override
@@ -39,4 +39,14 @@ public class FileServiceImpl extends IBaseServiceImpl<FileEntity, Long> implemen
     public void deleteByFkId(String fkId) {
     public void deleteByFkId(String fkId) {
         entityMapper.deleteByFkId(fkId);
         entityMapper.deleteByFkId(fkId);
     }
     }
+
+    @Override
+    public void setCoverDefault(String modelType) {
+        entityMapper.setCoverDefault(modelType);
+    }
+
+    @Override
+    public void setCover(Long fileId) {
+        entityMapper.setCover(fileId);
+    }
 }
 }

+ 24 - 16
gis_web/src/main/java/com/gis/web/controller/GoodsController.java

@@ -7,6 +7,7 @@ import com.gis.domain.dto.GoodsPageDateDto;
 import com.gis.domain.po.FileEntity;
 import com.gis.domain.po.FileEntity;
 import com.gis.domain.po.GoodsEntity;
 import com.gis.domain.po.GoodsEntity;
 import com.gis.domain.vo.GoodsVo;
 import com.gis.domain.vo.GoodsVo;
+import com.gis.service.FileService;
 import com.gis.service.GoodsService;
 import com.gis.service.GoodsService;
 import com.gis.web.aop.WebControllerLog;
 import com.gis.web.aop.WebControllerLog;
 import com.github.pagehelper.PageInfo;
 import com.github.pagehelper.PageInfo;
@@ -37,6 +38,11 @@ public class GoodsController extends BaseController {
     @Autowired
     @Autowired
     private GoodsService goodsService;
     private GoodsService goodsService;
 
 
+    @Autowired
+    private FileService fileService;
+
+
+
 
 
 
 
 
 
@@ -61,10 +67,18 @@ public class GoodsController extends BaseController {
             BeanUtils.copyProperties(param, entity);
             BeanUtils.copyProperties(param, entity);
             goodsService.save(entity);
             goodsService.save(entity);
 
 
-            // 图片信息跟goodsId绑定
-            String fkId= "goods_" + entity.getId();
 
 
-            fileService.setFkIdByIds(param.getFileIds(), fkId);
+            String modelType = null;
+            if (entity.getType() == 1) {
+                modelType = TypeCode.MODEL_GOODS_IMG;
+            } else if (entity.getType() == 2) {
+                modelType = TypeCode.MODEL_GOODS_VIDEO;
+            } else if (entity.getType() == 3) {
+                modelType = TypeCode.MODEL_GOODS_MODEL;
+            }
+
+            // 图片信息跟goodsId绑定
+            fileService.setFkIdByIds(param.getFileId(), entity.getId(), modelType);
 
 
         } else {
         } else {
             entity = goodsService.findById(param.getId());
             entity = goodsService.findById(param.getId());
@@ -102,19 +116,13 @@ public class GoodsController extends BaseController {
      *
      *
     */
     */
     @ApiOperation("设置封面")
     @ApiOperation("设置封面")
-    @GetMapping("setCover/{fileId}/{goodsId}")
-    public Result setCover(@PathVariable Long fileId, @PathVariable String goodsId) {
-        List<FileEntity> entityList = fileService.findByFkId(TypeCode.FILE_GOODS + goodsId);
-        for (FileEntity entity: entityList) {
-            if (entity.getId() == fileId) {
-                // 1:设置封面
-                entity.setCover(1);
-            } else {
-                entity.setCover(0);
-            }
-            entity.setUpdateTime(new Date());
-            fileService.update(entity);
-        }
+    @GetMapping("setCover/{fileId}")
+    public Result setCover(@PathVariable Long fileId) {
+        // 对应模块封面设置默认
+        fileService.setCoverDefault(TypeCode.MODEL_GOODS_IMG);
+        // 设置封面
+        fileService.setCover(fileId);
+
 
 
         return Result.success();
         return Result.success();
     }
     }