ソースを参照

update content-service/geo

reghao 7 ヶ月 前
コミット
f9cb688cae

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

@@ -15,15 +15,15 @@ import java.util.List;
  */
 @Mapper
 public interface CameraPhotoMapper extends BaseMapper<CameraPhoto> {
-    void updateSetAlbumId(@Param("objectId") String objectId, @Param("albumId") Long albumId);
     void updateSetAlbumType(@Param("objectId") String objectId, @Param("albumType") String albumType);
 
-    List<MapMarker> findByWestGeoGroup(@Param("pageSize") int pageSize, @Param("itemType") int itemType);
-    List<MapMarker> findAllByReplyIdGroup(int pageSize);
-    List<MapMarker> findByWestChina(@Param("pageSize") int pageSize, @Param("itemType") int itemType);
-    MarkerInfo findCommentMarkerInfo(int id);
+    List<MapMarker> findAlbumIdGroup(int pageSize);
+    List<MapMarker> findByImagePost(int pageSize);
+    List<MapMarker> findByMallReply(int pageSize);
+    List<MapMarker> findByMallReplyCup(@Param("pageSize") int pageSize, @Param("itemType") int itemType);
+    List<MapMarker> findByMallReplyItem(@Param("pageSize") int pageSize, @Param("itemType") int itemType);
+
+    MarkerInfo findImagePostInfo(int id);
+    MarkerInfo findMallReplyInfo(int id);
     MarkerInfo findMarkerInfo(int id);
-    MarkerInfo findAlbumMarkerInfo(int id);
-    List<CameraPhoto> findByAlbumId(String albumId);
-    List<CameraPhoto> findByAlbumType(String albumType);
 }

+ 3 - 2
content/content-service/src/main/java/cn/reghao/tnb/content/app/geo/model/constant/GeoItem.java

@@ -6,8 +6,9 @@ package cn.reghao.tnb.content.app.geo.model.constant;
  */
 public enum GeoItem {
     All(1),
-    Comment(2),
-    Photo(3);
+    ImagePost(2),
+    MallReply(3),
+    Cup(4);
 
     private final int value;
     GeoItem(int value) {

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

@@ -28,6 +28,7 @@ public class CameraPhoto extends BaseObject<Integer> {
     private LocalDateTime shotAt;
     private BigDecimal longitude;
     private BigDecimal latitude;
+    private Boolean geoValid;
 
     public CameraPhoto(MallReplyPhotoDto mallReplyPhotoDto) {
         this.albumType = "MallReply";
@@ -40,10 +41,16 @@ public class CameraPhoto extends BaseObject<Integer> {
         this.software = mallReplyPhotoDto.getSoftware();
         if (mallReplyPhotoDto.getLongitude() != null) {
             this.longitude = BigDecimal.valueOf(mallReplyPhotoDto.getLongitude());
+            this.geoValid = true;
+        } else {
+            this.geoValid = false;
         }
 
         if (mallReplyPhotoDto.getLatitude() != null) {
             this.latitude = BigDecimal.valueOf(mallReplyPhotoDto.getLatitude());
+            this.geoValid = true;
+        } else {
+            this.geoValid = false;
         }
     }
 }

+ 1 - 3
content/content-service/src/main/java/cn/reghao/tnb/content/app/geo/model/vo/MarkerInfo.java

@@ -11,13 +11,11 @@ import lombok.Setter;
 @Getter
 public class MarkerInfo {
     private Integer type;
-    private String albumType;
     private String itemId;
     private String replyId;
     private String sku;
     private String replyContent;
-    private String appendContent;
     private String uploadId;
-    private Integer channelId;
+    private Integer channelCode;
     private String photoUrl;
 }

+ 18 - 20
content/content-service/src/main/java/cn/reghao/tnb/content/app/geo/service/PhotoMapService.java

@@ -102,25 +102,21 @@ public class PhotoMapService {
     }
 
     public List<MapMarker> getPhotoMarks(int itemType) {
-        int pageSize = 1000;
+        int pageSize = 100;
+        List<MapMarker> list;
         if (itemType == 1) {
-            List<MapMarker> list = cameraPhotoMapper.findAllByReplyIdGroup(pageSize);
-            return list;
+            list = cameraPhotoMapper.findAlbumIdGroup(pageSize);
         } else if (itemType == 2) {
-            List<MapMarker> list = cameraPhotoMapper.findByWestChina(pageSize, itemType);
-            return list;
+            list = cameraPhotoMapper.findByImagePost(pageSize);
         } else if (itemType == 3) {
-            List<MapMarker> list = cameraPhotoMapper.findByWestGeoGroup(pageSize, itemType);
-            return list;
+            list = cameraPhotoMapper.findByMallReply(pageSize);
         } else if (itemType == 4) {
-            List<MapMarker> list = cameraPhotoMapper.findByWestGeoGroup(pageSize, itemType);
-            list.forEach(mapMarker -> {
-                String objectId = mapMarker.getId();
-            });
-            return list;
+            list = cameraPhotoMapper.findByMallReplyCup(pageSize, itemType);
+        } else {
+            list = cameraPhotoMapper.findByMallReplyItem(pageSize, itemType);
         }
 
-        return Collections.emptyList();
+        return list;
     }
 
     public MarkerInfo getMarkerInfo(int id) {
@@ -132,19 +128,21 @@ public class PhotoMapService {
         String albumType = cameraPhoto.getAlbumType();
         MarkerInfo markerInfo;
         if (albumType.equals("ImagePost")) {
-            markerInfo = cameraPhotoMapper.findMarkerInfo(id);
+            markerInfo = cameraPhotoMapper.findImagePostInfo(id);
+            markerInfo.setType(GeoItem.ImagePost.getValue());
         } else if (albumType.equals("MallReply")) {
-            markerInfo = cameraPhotoMapper.findCommentMarkerInfo(id);
+            markerInfo = cameraPhotoMapper.findMallReplyInfo(id);
+            markerInfo.setType(GeoItem.MallReply.getValue());
         } else {
-            markerInfo = cameraPhotoMapper.findAlbumMarkerInfo(id);
+            markerInfo = cameraPhotoMapper.findMarkerInfo(id);
+            markerInfo.setType(0);
         }
-        markerInfo.setAlbumType(albumType);
 
-        int channelId = markerInfo.getChannelId();
-        if (channelId != 0) {
+        int channelCode = markerInfo.getChannelCode();
+        if (channelCode != 0) {
             String uploadId = markerInfo.getUploadId();
             try {
-                String signedUrl = ossService.getSignedUrl(channelId, uploadId);
+                String signedUrl = ossService.getSignedUrl(channelCode, uploadId);
                 if (signedUrl != null) {
                     markerInfo.setPhotoUrl(signedUrl);
                 }

+ 48 - 44
content/content-service/src/main/resources/mapper/geo/CameraPhotoMapper.xml

@@ -4,82 +4,91 @@
 <mapper namespace="cn.reghao.tnb.content.app.geo.db.mapper.CameraPhotoMapper">
     <insert id="save" useGeneratedKeys="true" keyProperty="id">
         insert into geo_camera_photo
-        (`album_type`,`album_id`,`object_id`,`channel_code`,`photo_url`,`manufacturer`,`model`,`software`,`shot_at`,`geo`)
+        (`album_type`,`album_id`,`object_id`,`channel_code`,`photo_url`,`manufacturer`,`model`,`software`,`shot_at`,`geo`,`geo_valid`)
         values 
-        (#{albumType},#{albumId},#{objectId},#{channelCode},#{photoUrl},#{manufacturer},#{model},#{software},#{shotAt},point(#{longitude},#{latitude}))
+        (#{albumType},#{albumId},#{objectId},#{channelCode},#{photoUrl},#{manufacturer},#{model},#{software},#{shotAt},point(#{longitude},#{latitude}),#{geoValid})
     </insert>
     <insert id="saveAll" useGeneratedKeys="true" keyProperty="id">
         insert ignore into geo_camera_photo
-        (`album_type`,`album_id`,`object_id`,`channel_code`,`photo_url`,`manufacturer`,`model`,`software`,`shot_at`,`geo`)
+        (`album_type`,`album_id`,`object_id`,`channel_code`,`photo_url`,`manufacturer`,`model`,`software`,`shot_at`,`geo`,`geo_valid`)
         values
         <foreach collection="list" item="item" index="index" separator=",">
-            (#{item.albumType},#{item.albumId},#{item.objectId},#{item.channelCode},#{item.photoUrl},#{item.manufacturer},#{item.model},#{item.software},#{item.shotAt},point(#{item.longitude},#{item.latitude}))
+            (#{item.albumType},#{item.albumId},#{item.objectId},#{item.channelCode},#{item.photoUrl},#{item.manufacturer},#{item.model},#{item.software},#{item.shotAt},point(#{item.longitude},#{item.latitude}),#{item.geoValid})
         </foreach>
     </insert>
 
-    <update id="updateSetAlbumId">
-        update geo_camera_photo
-        set album_id=#{albumId}
-        where object_id=#{objectId}
-    </update>
     <update id="updateSetAlbumType">
         update geo_camera_photo
         set album_type=#{albumType}
         where object_id=#{objectId}
     </update>
 
-    <delete id="delete">
+    <delete id="deleteById">
         delete from geo_camera_photo
         where id=#{id}
     </delete>
 
-    <select id="findById" resultType="cn.reghao.tnb.content.app.geo.model.po.CameraPhoto">
-        select *
-        from geo_camera_photo
-        where id=#{id}
-    </select>
-    <select id="findAll" resultType="cn.reghao.tnb.content.app.geo.model.po.CameraPhoto">
-        select *
-        from geo_camera_photo
-    </select>
-
     <resultMap id="mapMarker" type="cn.reghao.tnb.content.app.geo.model.vo.MapMarker">
         <result property="id" column="id"/>
-        <result property="title" column="cup"/>
+        <result property="title" column="title"/>
         <association property="position" javaType="cn.reghao.tnb.content.app.geo.model.vo.MapPoint">
             <result property="lng" column="lng"/>
             <result property="lat" column="lat"/>
         </association>
     </resultMap>
-    <select id="findByWestGeoGroup" resultMap="mapMarker">
-        select id, manufacturer as cup,x(geo) as lng,y(geo) as lat
-        from geo_camera_photo
-        where `type`=#{itemType} and geo is not null
-        group by geo
-        order by shot_at desc
+    <select id="findAlbumIdGroup" resultMap="mapMarker">
+        select photo.id,photo.manufacturer as title,photo.photo_url,x(photo.geo) as lng,y(photo.geo) as lat
+        from geo_camera_photo photo
+        inner join geo_mall_reply reply
+        on photo.album_id=reply.reply_id and photo.geo_valid=1
+        group by photo.album_id
+        order by photo.id desc
         limit #{pageSize}
     </select>
-    <select id="findAllByReplyIdGroup" resultMap="mapMarker">
-        select photo.id,photo.manufacturer as cup,photo.photo_url,x(photo.geo) as lng,y(photo.geo) as lat
+    <select id="findByImagePost" resultMap="mapMarker">
+        select photo.id,photo.manufacturer as title,photo.photo_url,x(photo.geo) as lng,y(photo.geo) as lat
+        from geo_camera_photo photo
+        where photo.album_type='ImagePost' and photo.geo_valid=1
+        group by photo.album_id
+        order by photo.id desc
+        limit #{pageSize}
+    </select>
+    <select id="findByMallReply" resultMap="mapMarker">
+        select photo.id,photo.manufacturer as title,photo.photo_url,x(photo.geo) as lng,y(photo.geo) as lat
         from geo_camera_photo photo
         inner join geo_mall_reply reply
-        on photo.album_id=reply.reply_id and photo.geo is not null
+        on photo.album_id=reply.reply_id and photo.geo_valid=1 and photo.album_type='MallReply'
         group by photo.album_id
         order by photo.id desc
         limit #{pageSize}
     </select>
-    <!-- 由西向东升序 -->
-    <select id="findByWestChina" resultMap="mapMarker">
-        select photo.id,reply.cup,photo.photo_url,x(photo.geo) as lng,y(photo.geo) as lat
+    <select id="findByMallReplyCup" resultMap="mapMarker">
+        select photo.id,reply.cup as title,photo.photo_url,x(photo.geo) as lng,y(photo.geo) as lat
         from geo_camera_photo photo
         inner join geo_mall_reply reply
-        on photo.album_id=reply.reply_id and photo.geo is not null
+        on photo.album_id=reply.reply_id and photo.geo_valid=1 and photo.album_type='MallReply'
         and reply.item_type=#{itemType}
         group by photo.album_id
         order by photo.id desc
         limit #{pageSize}
     </select>
-    <select id="findCommentMarkerInfo" resultType="cn.reghao.tnb.content.app.geo.model.vo.MarkerInfo">
+    <select id="findByMallReplyItem" resultMap="mapMarker">
+        select photo.id,photo.manufacturer as title,photo.photo_url,x(photo.geo) as lng,y(photo.geo) as lat
+        from geo_camera_photo photo
+        inner join geo_mall_reply reply
+        on photo.album_id=reply.reply_id and photo.geo_valid=1 and photo.album_type='MallReply'
+        and reply.item_type=#{itemType}
+        group by photo.album_id
+        order by photo.id desc
+        limit #{pageSize}
+    </select>
+
+    <select id="findImagePostInfo" resultType="cn.reghao.tnb.content.app.geo.model.vo.MarkerInfo">
+        select object_id as upload_id,album_id as item_id,channel_code,photo_url
+        from geo_camera_photo
+        where id=#{id} and geo is not null
+    </select>
+    <select id="findMallReplyInfo" resultType="cn.reghao.tnb.content.app.geo.model.vo.MarkerInfo">
         select reply.item_id,reply.reply_id,reply.extra as sku,reply.reply_content,reply.append_content,
         photo.object_id as upload_id,photo.channel_code,photo.photo_url
         from geo_camera_photo photo
@@ -91,19 +100,14 @@
         from geo_camera_photo
         where id=#{id} and geo is not null
     </select>
-    <select id="findAlbumMarkerInfo" resultType="cn.reghao.tnb.content.app.geo.model.vo.MarkerInfo">
-        select object_id as upload_id,album_id as item_id,channel_code,photo_url
-        from geo_camera_photo
-        where id=#{id} and geo is not null
-    </select>
-    <select id="findByAlbumId" resultType="cn.reghao.tnb.content.app.geo.model.po.CameraPhoto">
+
+    <select id="findById" resultType="cn.reghao.tnb.content.app.geo.model.po.CameraPhoto">
         select *
         from geo_camera_photo
-        where album_id=#{albumId}
+        where id=#{id}
     </select>
-    <select id="findByAlbumType" resultType="cn.reghao.tnb.content.app.geo.model.po.CameraPhoto">
+    <select id="findAll" resultType="cn.reghao.tnb.content.app.geo.model.po.CameraPhoto">
         select *
         from geo_camera_photo
-        where album_type is null
     </select>
 </mapper>