Browse Source

update content-service/geo

reghao 7 tháng trước cách đây
mục cha
commit
d742a4a29d

+ 31 - 0
content/content-service/src/main/java/cn/reghao/tnb/content/app/geo/db/repository/MallReplyRepository.java

@@ -0,0 +1,31 @@
+package cn.reghao.tnb.content.app.geo.db.repository;
+
+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.po.CameraPhoto;
+import cn.reghao.tnb.content.app.geo.model.po.MallReply;
+import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+
+/**
+ * @author reghao
+ * @date 2025-08-15 21:10:03
+ */
+@Repository
+public class MallReplyRepository {
+    private final MallReplyMapper mallReplyMapper;
+    private final CameraPhotoMapper cameraPhotoMapper;
+
+    public MallReplyRepository(MallReplyMapper mallReplyMapper, CameraPhotoMapper cameraPhotoMapper) {
+        this.mallReplyMapper = mallReplyMapper;
+        this.cameraPhotoMapper = cameraPhotoMapper;
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    public void saveTmallReply(MallReply mallReply, List<CameraPhoto> list) {
+        mallReplyMapper.save(mallReply);
+        cameraPhotoMapper.saveAll(list);
+    }
+}

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

@@ -6,6 +6,7 @@ import cn.reghao.tnb.common.db.SelectOption;
 import cn.reghao.tnb.content.api.dto.geo.MallReplyDto;
 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.db.repository.MallReplyRepository;
 import cn.reghao.tnb.content.app.geo.model.constant.GeoItem;
 import cn.reghao.tnb.content.app.geo.model.po.CameraPhoto;
 import cn.reghao.tnb.content.app.geo.model.po.MallReply;
@@ -33,10 +34,13 @@ public class PhotoMapService {
 
     private final MallReplyMapper mallReplyMapper;
     private final CameraPhotoMapper cameraPhotoMapper;
+    private MallReplyRepository mallReplyRepository;
 
-    public PhotoMapService(MallReplyMapper mallReplyMapper, CameraPhotoMapper cameraPhotoMapper) {
+    public PhotoMapService(MallReplyMapper mallReplyMapper, CameraPhotoMapper cameraPhotoMapper,
+                           MallReplyRepository mallReplyRepository) {
         this.mallReplyMapper = mallReplyMapper;
         this.cameraPhotoMapper = cameraPhotoMapper;
+        this.mallReplyRepository = mallReplyRepository;
     }
 
     public synchronized void addTmallReply(MallReplyDto mallReplyDto) {
@@ -66,16 +70,10 @@ public class PhotoMapService {
                 .collect(Collectors.toList());
 
         if (!list.isEmpty()) {
-            saveTmallReply(mallReply, list);
+            mallReplyRepository.saveTmallReply(mallReply, list);
         }
     }
 
-    @Transactional(rollbackFor = Exception.class)
-    public void saveTmallReply(MallReply mallReply, List<CameraPhoto> list) {
-        mallReplyMapper.save(mallReply);
-        cameraPhotoMapper.saveAll(list);
-    }
-
     @Cacheable(cacheNames = "tnb:geo:mark", key = "#itemType", unless = "#result == null")
     public List<MapMarker> getPhotoMarks(int itemType) {
         int pageSize = 100;