Переглянути джерело

content-service/geo 模块
1.MallReply 添加 replyDate 和 userId 字段, 删除 appendContent 字段
2.MallReply 的 itemId 和 replyId 字段修改为 long 类型

reghao 7 місяців тому
батько
коміт
753214ab73

+ 14 - 9
content/content-api/src/main/java/cn/reghao/tnb/content/api/dto/geo/MallReplyDto.java

@@ -1,5 +1,6 @@
 package cn.reghao.tnb.content.api.dto.geo;
 
+import cn.reghao.tnb.content.api.dto.CamPhoto;
 import lombok.AllArgsConstructor;
 import lombok.Getter;
 import lombok.NoArgsConstructor;
@@ -24,28 +25,32 @@ public class MallReplyDto implements Serializable {
 
     @NotNull
     private Integer itemType;
-    @NotBlank
-    private String itemId;
-    @NotBlank
-    private String replyId;
+    @NotNull
+    private Long itemId;
+    @NotNull
+    private Long replyId;
     private String replyContent;
-    private String appendContent;
     private String extra;
     @NotBlank
+    private String replyDate;
+    @NotBlank
+    private String userId;
+    @NotBlank
     private String username;
     @NotBlank
     private String avatarUrl;
     @NotEmpty
-    private List<MallReplyPhotoDto> photos;
+    private List<CamPhoto> CamPhotoList;
 
-    public MallReplyDto(int itemType, String itemId, String replyId, String replyContent, String appendContent,
-                        String extra, String username, String avatarUrl) {
+    public MallReplyDto(int itemType, long itemId, long replyId, String replyContent, String extra, String replyDate,
+                        String userId, String username, String avatarUrl) {
         this.itemType = itemType;
         this.itemId = itemId;
         this.replyId = replyId;
         this.replyContent = replyContent;
-        this.appendContent = appendContent;
         this.extra = extra;
+        this.replyDate = replyDate;
+        this.userId = userId;
         this.username = username;
         this.avatarUrl = avatarUrl;
     }

+ 0 - 42
content/content-api/src/main/java/cn/reghao/tnb/content/api/dto/geo/MallReplyPhotoDto.java

@@ -1,42 +0,0 @@
-package cn.reghao.tnb.content.api.dto.geo;
-
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-import lombok.Setter;
-
-import javax.validation.constraints.NotBlank;
-import javax.validation.constraints.NotNull;
-import java.io.Serializable;
-
-/**
- * @author reghao
- * @date 2023-08-31 10:38:26
- */
-@NoArgsConstructor
-@Setter
-@Getter
-public class MallReplyPhotoDto implements Serializable {
-    private static final long serialVersionUID = 1L;
-
-    @NotBlank
-    private String replyId;
-    @NotBlank
-    private String uploadId;
-    @NotNull
-    private Integer channelId;
-    @NotBlank
-    private String photoUrl;
-    private String manufacturer;
-    private String model;
-    private String software;
-    private String shotAt;
-    private Double longitude;
-    private Double latitude;
-
-    public MallReplyPhotoDto(String replyId, String uploadId, int channelId, String photoUrl) {
-        this.replyId = replyId;
-        this.uploadId = uploadId;
-        this.channelId = channelId;
-        this.photoUrl = photoUrl;
-    }
-}

+ 0 - 15
content/content-service/src/main/java/cn/reghao/tnb/content/app/geo/controller/PhotoMapController.java

@@ -4,7 +4,6 @@ import cn.reghao.jutil.web.WebResult;
 import cn.reghao.tnb.common.auth.AuthUser;
 import cn.reghao.tnb.common.db.SelectOption;
 import cn.reghao.tnb.content.api.dto.geo.MallReplyDto;
-import cn.reghao.tnb.content.api.dto.geo.MallReplyPhotoDto;
 import cn.reghao.tnb.content.app.geo.model.vo.MapMarker;
 import cn.reghao.tnb.content.app.geo.model.vo.MarkerInfo;
 import cn.reghao.tnb.content.app.geo.service.PhotoMapService;
@@ -30,13 +29,6 @@ public class PhotoMapController {
         this.photoMapService = photoMapService;
     }
 
-    @Operation(summary = "检查淘宝商品评论是否存在", description = "N")
-    @GetMapping(value = "/reply/{replyId}", produces = MediaType.APPLICATION_JSON_VALUE)
-    public String checkReply(@PathVariable("replyId") String replyId) {
-        boolean exist = photoMapService.checkReplyId(replyId);
-        return WebResult.success(exist);
-    }
-
     @Operation(summary = "添加淘宝商品评论", description = "N")
     @PostMapping(value = "/reply", produces = MediaType.APPLICATION_JSON_VALUE)
     public String addReply(@RequestBody @Validated MallReplyDto mallReplyDto) {
@@ -44,13 +36,6 @@ public class PhotoMapController {
         return WebResult.success();
     }
 
-    @Operation(summary = "添加淘宝商品评论中的照片", description = "N")
-    @PostMapping(value = "/photo", produces = MediaType.APPLICATION_JSON_VALUE)
-    public String addPhoto(@RequestBody List<MallReplyPhotoDto> list) {
-        photoMapService.addCameraPhotos(list);
-        return WebResult.success();
-    }
-
     @Operation(summary = "获取照片分类", description = "N")
     @GetMapping(value = "/item", produces = MediaType.APPLICATION_JSON_VALUE)
     public String getGeoItems() {

+ 2 - 2
content/content-service/src/main/java/cn/reghao/tnb/content/app/geo/db/mapper/MallReplyMapper.java

@@ -13,9 +13,9 @@ import java.util.List;
  */
 @Mapper
 public interface MallReplyMapper extends BaseMapper<MallReply> {
-    void updateSetCup(@Param("replyId") String replyId, @Param("cup") String cup);
+    void updateSetCup(@Param("replyId") long replyId, @Param("cup") String cup);
 
     List<MallReply> findByItemType(int itemType);
     List<MallReply> findByItemId(String itemId);
-    MallReply findByReplyId(String replyId);
+    MallReply findByReplyId(long replyId);
 }

+ 13 - 13
content/content-service/src/main/java/cn/reghao/tnb/content/app/geo/model/po/CameraPhoto.java

@@ -1,7 +1,7 @@
 package cn.reghao.tnb.content.app.geo.model.po;
 
 import cn.reghao.jutil.jdk.db.BaseObject;
-import cn.reghao.tnb.content.api.dto.geo.MallReplyPhotoDto;
+import cn.reghao.tnb.content.api.dto.CamPhoto;
 import lombok.Getter;
 import lombok.NoArgsConstructor;
 import lombok.Setter;
@@ -30,24 +30,24 @@ public class CameraPhoto extends BaseObject<Integer> {
     private BigDecimal latitude;
     private Boolean geoValid;
 
-    public CameraPhoto(MallReplyPhotoDto mallReplyPhotoDto) {
+    public CameraPhoto(long replyId, CamPhoto camPhoto) {
         this.albumType = "MallReply";
-        this.albumId = Long.parseLong(mallReplyPhotoDto.getReplyId());
-        this.objectId = mallReplyPhotoDto.getUploadId();
-        this.channelId = mallReplyPhotoDto.getChannelId();
-        this.photoUrl = mallReplyPhotoDto.getPhotoUrl();
-        this.manufacturer = mallReplyPhotoDto.getManufacturer();
-        this.model = mallReplyPhotoDto.getModel();
-        this.software = mallReplyPhotoDto.getSoftware();
-        if (mallReplyPhotoDto.getLongitude() != null) {
-            this.longitude = BigDecimal.valueOf(mallReplyPhotoDto.getLongitude());
+        this.albumId = replyId;
+        this.objectId = camPhoto.getObjectId();
+        this.channelId = camPhoto.getChannelCode();
+        this.photoUrl = camPhoto.getPhotoUrl();
+        this.manufacturer = camPhoto.getManufacturer();
+        this.model = camPhoto.getModel();
+        this.software = camPhoto.getSoftware();
+        if (camPhoto.getLongitude() != null) {
+            this.longitude = BigDecimal.valueOf(camPhoto.getLongitude());
             this.geoValid = true;
         } else {
             this.geoValid = false;
         }
 
-        if (mallReplyPhotoDto.getLatitude() != null) {
-            this.latitude = BigDecimal.valueOf(mallReplyPhotoDto.getLatitude());
+        if (camPhoto.getLatitude() != null) {
+            this.latitude = BigDecimal.valueOf(camPhoto.getLatitude());
             this.geoValid = true;
         } else {
             this.geoValid = false;

+ 8 - 6
content/content-service/src/main/java/cn/reghao/tnb/content/app/geo/model/po/MallReply.java

@@ -17,22 +17,24 @@ import lombok.Setter;
 @Getter
 public class MallReply extends BaseObject<Integer> {
     private Integer itemType;
-    private String itemId;
-    private String replyId;
+    private Long itemId;
+    private Long replyId;
     private String replyContent;
-    private String appendContent;
     private String extra;
     private String cup;
+    private String replyDate;
+    private String userId;
     private String username;
     private String avatarUrl;
 
-    public MallReply(MallReplyDto mallReplyDto) {
+    public MallReply(long replyId, MallReplyDto mallReplyDto) {
         this.itemType = mallReplyDto.getItemType();
         this.itemId = mallReplyDto.getItemId();
-        this.replyId = mallReplyDto.getReplyId();
+        this.replyId = replyId;
         this.replyContent = mallReplyDto.getReplyContent();
-        this.appendContent = mallReplyDto.getAppendContent();
         this.extra = mallReplyDto.getExtra();
+        this.replyDate = mallReplyDto.getReplyDate();
+        this.userId = mallReplyDto.getUserId();
         this.username = mallReplyDto.getUsername();
         this.avatarUrl = mallReplyDto.getAvatarUrl();
     }

+ 7 - 33
content/content-service/src/main/java/cn/reghao/tnb/content/app/geo/service/PhotoMapService.java

@@ -4,7 +4,6 @@ import cn.reghao.file.api.iface.OssService;
 import cn.reghao.jutil.jdk.converter.DateTimeConverter;
 import cn.reghao.tnb.common.db.SelectOption;
 import cn.reghao.tnb.content.api.dto.geo.MallReplyDto;
-import cn.reghao.tnb.content.api.dto.geo.MallReplyPhotoDto;
 import cn.reghao.tnb.content.app.geo.db.mapper.CameraPhotoMapper;
 import cn.reghao.tnb.content.app.geo.db.mapper.MallReplyMapper;
 import cn.reghao.tnb.content.app.geo.model.constant.GeoItem;
@@ -40,27 +39,22 @@ public class PhotoMapService {
         this.cameraPhotoMapper = cameraPhotoMapper;
     }
 
-    public boolean checkReplyId(String replyId) {
-        MallReply mallReply = mallReplyMapper.findByReplyId(replyId);
-        return mallReply != null;
-    }
-
     public synchronized void addTmallReply(MallReplyDto mallReplyDto) {
-        String replyId = mallReplyDto.getReplyId();
+        long replyId = mallReplyDto.getReplyId();
         MallReply mallReply = mallReplyMapper.findByReplyId(replyId);
         if (mallReply != null) {
             log.info("{} 已存在", replyId);
             return;
         }
 
-        mallReply = new MallReply(mallReplyDto);
-        List<CameraPhoto> list = mallReplyDto.getPhotos().stream()
-                .map(mallReplyPhotoDto -> {
-                    CameraPhoto cameraPhoto = new CameraPhoto(mallReplyPhotoDto);
+        mallReply = new MallReply(replyId, mallReplyDto);
+        List<CameraPhoto> list = mallReplyDto.getCamPhotoList().stream()
+                .map(camPhoto -> {
+                    CameraPhoto cameraPhoto = new CameraPhoto(replyId, camPhoto);
                     try {
-                        String shotAtStr = mallReplyPhotoDto.getShotAt();
+                        String shotAtStr = camPhoto.getShotAt();
                         if (shotAtStr != null) {
-                            LocalDateTime shotAt = DateTimeConverter.localDateTime2(mallReplyPhotoDto.getShotAt());
+                            LocalDateTime shotAt = DateTimeConverter.localDateTime2(camPhoto.getShotAt());
                             cameraPhoto.setShotAt(shotAt);
                         }
                     } catch (Exception e) {
@@ -76,26 +70,6 @@ public class PhotoMapService {
         }
     }
 
-    public void addCameraPhotos(List<MallReplyPhotoDto> list) {
-        List<CameraPhoto> locations = list.stream().map(mallReplyPhotoDto -> {
-            CameraPhoto cameraPhoto = new CameraPhoto(mallReplyPhotoDto);
-            try {
-                String shotAtStr = mallReplyPhotoDto.getShotAt();
-                if (shotAtStr != null) {
-                    LocalDateTime shotAt = DateTimeConverter.localDateTime2(mallReplyPhotoDto.getShotAt());
-                    cameraPhoto.setShotAt(shotAt);
-                }
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
-            return cameraPhoto;
-        }).collect(Collectors.toList());
-
-        if (!locations.isEmpty()) {
-            cameraPhotoMapper.saveAll(locations);
-        }
-    }
-
     @Transactional(rollbackFor = Exception.class)
     public void saveTmallReply(MallReply mallReply, List<CameraPhoto> list) {
         mallReplyMapper.save(mallReply);

+ 2 - 2
content/content-service/src/main/resources/mapper/geo/MallReplyMapper.xml

@@ -4,9 +4,9 @@
 <mapper namespace="cn.reghao.tnb.content.app.geo.db.mapper.MallReplyMapper">
     <insert id="save" useGeneratedKeys="true" keyProperty="id">
         insert into geo_mall_reply
-        (`id`,`deleted`,`create_time`,`update_time`,`item_type`,`item_id`,`reply_id`,`reply_content`,`append_content`,`extra`,`username`,`avatar_url`)
+        (`item_type`,`item_id`,`reply_id`,`reply_content`,`extra`,`reply_date`,`user_id`,`username`,`avatar_url`)
         values 
-        (#{id},#{deleted},#{createTime},#{updateTime},#{itemType},#{itemId},#{replyId},#{replyContent},#{appendContent},#{extra},#{username},#{avatarUrl})
+        (#{itemType},#{itemId},#{replyId},#{replyContent},#{extra},#{replyDate},#{userId},#{username},#{avatarUrl})
     </insert>
 
     <update id="updateSetCup">