Browse Source

[fix]
1、write表中的travelNotesBannerUrl字段--->travelNotesBanner

chenchen 4 months ago
parent
commit
74f19a6e72
13 changed files with 99 additions and 22 deletions
  1. 2 2
      application-webadmin/src/main/java/com/tourism/webadmin/app/website/controller/WebSiteTourismTravelNotesPublishController.java
  2. 30 12
      application-webadmin/src/main/java/com/tourism/webadmin/app/website/controller/WebsiteTourismProjectTravelNotesController.java
  3. 1 1
      application-webadmin/src/main/java/com/tourism/webadmin/app/website/vo/TourWriteBelongTabVo.java
  4. 10 0
      application-webadmin/src/main/java/com/tourism/webadmin/back/dao/TourUserLikeTravelNotesMapper.java
  5. 12 0
      application-webadmin/src/main/java/com/tourism/webadmin/back/dao/mapper/TourUserLikeTravelNotesMapper.xml
  6. 3 3
      application-webadmin/src/main/java/com/tourism/webadmin/back/dao/mapper/TourismProjectTravelNotesWriteMapper.xml
  7. 1 1
      application-webadmin/src/main/java/com/tourism/webadmin/back/dto/TourismProjectTravelNotesWriteDto.java
  8. 8 0
      application-webadmin/src/main/java/com/tourism/webadmin/back/model/TourUserLikeTravelNotes.java
  9. 2 2
      application-webadmin/src/main/java/com/tourism/webadmin/back/model/TourismProjectTravelNotesWrite.java
  10. 11 0
      application-webadmin/src/main/java/com/tourism/webadmin/back/service/TourUserLikeTravelNotesService.java
  11. 10 0
      application-webadmin/src/main/java/com/tourism/webadmin/back/service/impl/TourUserLikeTravelNotesServiceImpl.java
  12. 8 0
      application-webadmin/src/main/java/com/tourism/webadmin/back/vo/TourUserLikeTravelNotesVo.java
  13. 1 1
      application-webadmin/src/main/java/com/tourism/webadmin/back/vo/TourismProjectTravelNotesWriteVo.java

+ 2 - 2
application-webadmin/src/main/java/com/tourism/webadmin/app/website/controller/WebSiteTourismTravelNotesPublishController.java

@@ -380,9 +380,9 @@ public class WebSiteTourismTravelNotesPublishController {
         List<TourWriteBelongTabVo> tourWriteBelongTabVoList = MyModelUtil.copyCollectionTo(directoryInfoList, TourWriteBelongTabVo.class);
         List<TourWriteBelongTabVo> newDirectoryInfoList = new ArrayList<>();
         for(TourWriteBelongTabVo i : tourWriteBelongTabVoList){
-            if(i.getId() != 10L){
+            if(!i.getId().equals("10")){
                 DirectoryInfo directoryInfo2  = new DirectoryInfo();
-                directoryInfo2.setParentId(i.getId());
+                directoryInfo2.setParentId(Long.valueOf(i.getId()));
                 directoryInfo2.setDirectoryType(1);
                 List<DirectoryInfo> bodyDirectoryInfoList = directoryInfoService.getDirectoryInfoList(directoryInfo2, "");
 

+ 30 - 12
application-webadmin/src/main/java/com/tourism/webadmin/app/website/controller/WebsiteTourismProjectTravelNotesController.java

@@ -11,6 +11,7 @@ import com.tourism.common.core.object.ResponseResult;
 import com.tourism.common.core.object.TokenData;
 import com.tourism.common.core.util.MyCommonUtil;
 import com.tourism.common.core.util.MyModelUtil;
+import com.tourism.common.core.util.MyPageUtil;
 import com.tourism.common.core.validator.UpdateGroup;
 import com.tourism.common.log.annotation.OperationLog;
 import com.tourism.common.log.model.constant.SysOperationLogType;
@@ -21,6 +22,7 @@ import com.tourism.webadmin.app.website.service.BasicToWebService;
 import com.tourism.webadmin.app.website.vo.TourTravelNotesDirectoryCountryVo;
 import com.tourism.webadmin.app.website.vo.TourTravelNotesDirectoryVo;
 import com.tourism.webadmin.back.model.*;
+import com.tourism.webadmin.back.model.constant.UnmountState;
 import com.tourism.webadmin.back.service.*;
 import com.tourism.webadmin.back.vo.TourTourismProjectTravelNotesVo;
 import com.tourism.webadmin.back.vo.TourismProjectVo;
@@ -59,6 +61,8 @@ public class WebsiteTourismProjectTravelNotesController {
     private ApplicationConfig applicationConfig;
     @Autowired
     private TourUserLikeTravelNotesService tourUserLikeTravelNotesService;
+    @Autowired
+    private TourismProjectTravelNotesWriteService tourismProjectTravelNotesWriteService;
 
 
     /**
@@ -144,7 +148,7 @@ public class WebsiteTourismProjectTravelNotesController {
      */
     @OperationLog(type = SysOperationLogType.LIST)
     @GetMapping("/userCollectTravelNotesList")
-    public ResponseResult<List<TourTourismProjectTravelNotes>> userCollectTravelNotesList(PageDto pageDto) {
+    public ResponseResult<MyPageData<TourUserLikeTravelNotes>> userCollectTravelNotesList(PageDto pageDto) {
 
         MyOrderParam myOrderParam = new MyOrderParam();
         myOrderParam.add(new MyOrderParam.OrderInfo("updateTime",false,null));
@@ -155,17 +159,31 @@ public class WebsiteTourismProjectTravelNotesController {
         if(pageDto.getPageSize() != null && pageDto.getPageNum() != null){
             PageMethod.startPage(pageDto.getPageNum(), pageDto.getPageSize(), true);
         }
-        List<TourUserLikeTravelNotes> tourUserLikeTravelNotesList = tourUserLikeTravelNotesService.getTourUserLikeTravelNotesList(filter, orderBy);
-        List<TourTourismProjectTravelNotes> tourTourismProjectTravelNotesList = new ArrayList<>();
-        if(CollectionUtils.isNotEmpty(tourUserLikeTravelNotesList)) {
-            for(TourUserLikeTravelNotes item:tourUserLikeTravelNotesList){
-                TourTourismProjectTravelNotes tourTourismProjectTravelNotes = tourTourismProjectTravelNotesService.getById(item.getId());
-                if(tourTourismProjectTravelNotes != null){
-                    tourTourismProjectTravelNotesList.add(tourTourismProjectTravelNotes);
-                }
-            }
-        }
-        return ResponseResult.success(tourTourismProjectTravelNotesList);
+        List<TourUserLikeTravelNotes> tourUserLikeTravelNotesList = tourUserLikeTravelNotesService.getTourUserLikeTravelNotesWithRelationWriteList(filter, UnmountState.LISTING, orderBy);
+
+        //游记查询notes表
+//        List<TourTourismProjectTravelNotes> tourTourismProjectTravelNotesList = new ArrayList<>();
+//        if(CollectionUtils.isNotEmpty(tourUserLikeTravelNotesList)) {
+//            for(TourUserLikeTravelNotes item:tourUserLikeTravelNotesList){
+//                TourTourismProjectTravelNotes tourTourismProjectTravelNotes = tourTourismProjectTravelNotesService.getById(item.getTravelNotesId());
+//                if(tourTourismProjectTravelNotes != null){
+//                    tourTourismProjectTravelNotesList.add(tourTourismProjectTravelNotes);
+//                }
+//            }
+//        }
+        //游记查询write表   tourismProjectTravelNotesWriteService
+//        List<TourismProjectTravelNotesWrite> tourismProjectTravelNotesWriteList = new ArrayList<>();
+//        if(CollectionUtils.isNotEmpty(tourUserLikeTravelNotesList)) {
+//            for(TourUserLikeTravelNotes item:tourUserLikeTravelNotesList){
+//                TourismProjectTravelNotesWrite tourismProjectTravelNotesWrite = tourismProjectTravelNotesWriteService.getTourismProjectTravelNotesWriteListWithRelation(item.getTravelNotesId());
+//                if(tourismProjectTravelNotesWrite != null){
+//                    tourismProjectTravelNotesWriteList.add(tourismProjectTravelNotesWrite);
+//                }
+//            }
+//        }
+
+
+        return ResponseResult.success(MyPageUtil.makeResponseData(tourUserLikeTravelNotesList));
     }
 
 

+ 1 - 1
application-webadmin/src/main/java/com/tourism/webadmin/app/website/vo/TourWriteBelongTabVo.java

@@ -15,7 +15,7 @@ import java.util.List;
 @Data
 public class TourWriteBelongTabVo {
 
-    private Long id;
+    private String id;
 
     private String menuName;
 

+ 10 - 0
application-webadmin/src/main/java/com/tourism/webadmin/back/dao/TourUserLikeTravelNotesMapper.java

@@ -30,4 +30,14 @@ public interface TourUserLikeTravelNotesMapper extends BaseDaoMapper<TourUserLik
      */
     List<TourUserLikeTravelNotes> getTourUserLikeTravelNotesList(
             @Param("tourUserLikeTravelNotesFilter") TourUserLikeTravelNotes tourUserLikeTravelNotesFilter, @Param("orderBy") String orderBy);
+
+    /**
+     * 获取过滤后的对象列表(关联write表)。
+     *
+     * @param tourUserLikeTravelNotesFilter 主表过滤对象。
+     * @param orderBy 排序字符串,order by从句的参数。
+     * @return 对象列表。
+     */
+    List<TourUserLikeTravelNotes> getTourUserLikeTravelNotesWithRelationWriteList(
+            @Param("tourUserLikeTravelNotesFilter") TourUserLikeTravelNotes tourUserLikeTravelNotesFilter,@Param("unmountState") Integer unmountState, @Param("orderBy") String orderBy);
 }

+ 12 - 0
application-webadmin/src/main/java/com/tourism/webadmin/back/dao/mapper/TourUserLikeTravelNotesMapper.xml

@@ -63,4 +63,16 @@
             ORDER BY ${orderBy}
         </if>
     </select>
+
+    <select id="getTourUserLikeTravelNotesWithRelationWriteList" resultMap="BaseResultMap" parameterType="com.tourism.webadmin.back.model.TourUserLikeTravelNotes">
+        SELECT * FROM tour_user_like_travel_notes left join tour_tourism_project_travel_notes_writer on tour_tourism_project_travel_notes_writer.id = tour_user_like_travel_notes.travel_notes_id
+        <where>
+            <include refid="filterRef"/>
+                 and tour_tourism_project_travel_notes_writer.unmount_state = ${unmountState}
+                 and tour_tourism_project_travel_notes_writer.data_state = 1
+        </where>
+        <if test="orderBy != null and orderBy != ''">
+            ORDER BY ${orderBy}
+        </if>
+    </select>
 </mapper>

+ 3 - 3
application-webadmin/src/main/java/com/tourism/webadmin/back/dao/mapper/TourismProjectTravelNotesWriteMapper.xml

@@ -12,7 +12,7 @@
         <result column="state" jdbcType="TINYINT" property="state"/>
         <result column="reason" jdbcType="VARCHAR" property="reason"/>
         <result column="create_user_id" jdbcType="BIGINT" property="createUserId"/>
-        <result column="travel_notes_banner_url" jdbcType="VARCHAR" property="travelNotesBannerUrl"/>
+        <result column="travel_notes_banner" jdbcType="VARCHAR" property="travelNotesBanner"/>
         <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
         <result column="update_user_id" jdbcType="BIGINT" property="updateUserId"/>
         <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
@@ -42,7 +42,7 @@
             state,
             reason,
             create_user_id,
-            travel_notes_banner_url,
+            travel_notes_banner,
             create_time,
             update_user_id,
             update_time,
@@ -70,7 +70,7 @@
             #{item.state},
             #{item.reason},
             #{item.createUserId},
-            #{item.travelNotesBannerUrl},
+            #{item.travelNotesBanner},
             #{item.createTime},
             #{item.updateUserId},
             #{item.updateTime},

+ 1 - 1
application-webadmin/src/main/java/com/tourism/webadmin/back/dto/TourismProjectTravelNotesWriteDto.java

@@ -93,7 +93,7 @@ public class TourismProjectTravelNotesWriteDto {
      * 发布游记的banner图。
      */
     @Schema(description = "发布游记的banner图。")
-    private String travelNotesBannerUrl;
+    private String travelNotesBanner;
 
     /**
      * 游记内容中的图片。

+ 8 - 0
application-webadmin/src/main/java/com/tourism/webadmin/back/model/TourUserLikeTravelNotes.java

@@ -1,6 +1,7 @@
 package com.tourism.webadmin.back.model;
 
 import com.baomidou.mybatisplus.annotation.*;
+import com.tourism.common.core.annotation.RelationOneToOne;
 import com.tourism.common.core.base.model.BaseModel;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
@@ -40,4 +41,11 @@ public class TourUserLikeTravelNotes extends BaseModel {
     @TableLogic
     @TableField(value = "data_state")
     private Integer dataState;
+
+    @RelationOneToOne(
+            masterIdField = "travelNotesId",
+            slaveModelClass = TourismProjectTravelNotesWrite.class,
+            slaveIdField = "id")
+    @TableField(exist = false)
+    private TourismProjectTravelNotesWrite tourismProjectTravelNotesWrite;
 }

+ 2 - 2
application-webadmin/src/main/java/com/tourism/webadmin/back/model/TourismProjectTravelNotesWrite.java

@@ -85,8 +85,8 @@ public class TourismProjectTravelNotesWrite extends BaseModel {
      * 发布游记的banner图。
      */
     @UploadFlagColumn(storeType = UploadStoreTypeEnum.HUAWEI_OBS_SYSTEM)
-    @TableField(value = "travel_notes_banner_url")
-    private String travelNotesBannerUrl;
+    @TableField(value = "travel_notes_banner")
+    private String travelNotesBanner;
 
     /**
      * 逻辑删除标记字段(1: 正常 -1: 已删除)。

+ 11 - 0
application-webadmin/src/main/java/com/tourism/webadmin/back/service/TourUserLikeTravelNotesService.java

@@ -65,4 +65,15 @@ public interface TourUserLikeTravelNotesService extends IBaseService<TourUserLik
      * @return 查询结果集。
      */
     List<TourUserLikeTravelNotes> getTourUserLikeTravelNotesListWithRelation(TourUserLikeTravelNotes filter, String orderBy);
+
+    /**
+     * 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
+     * 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
+     * 如果仅仅需要获取主表数据,请移步(getTourUserLikeTravelNotesList),以便获取更好的查询性能。
+     *
+     * @param filter 主表过滤对象。
+     * @param orderBy 排序参数。
+     * @return 查询结果集。
+     */
+    List<TourUserLikeTravelNotes> getTourUserLikeTravelNotesWithRelationWriteList(TourUserLikeTravelNotes filter,Integer unmountState, String orderBy);
 }

+ 10 - 0
application-webadmin/src/main/java/com/tourism/webadmin/back/service/impl/TourUserLikeTravelNotesServiceImpl.java

@@ -93,6 +93,16 @@ public class TourUserLikeTravelNotesServiceImpl extends BaseService<TourUserLike
         return resultList;
     }
 
+    @Override
+    public List<TourUserLikeTravelNotes> getTourUserLikeTravelNotesWithRelationWriteList(TourUserLikeTravelNotes filter,Integer unmountState, String orderBy) {
+        List<TourUserLikeTravelNotes> resultList = tourUserLikeTravelNotesMapper.getTourUserLikeTravelNotesWithRelationWriteList(filter,unmountState, orderBy);
+        // 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。
+        // 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。
+        int batchSize = resultList instanceof Page ? 0 : 1000;
+        this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize);
+        return resultList;
+    }
+
     private TourUserLikeTravelNotes buildDefaultValue(TourUserLikeTravelNotes tourUserLikeTravelNotes) {
         if (tourUserLikeTravelNotes.getId() == null) {
             tourUserLikeTravelNotes.setId(idGenerator.nextLongId());

+ 8 - 0
application-webadmin/src/main/java/com/tourism/webadmin/back/vo/TourUserLikeTravelNotesVo.java

@@ -5,6 +5,8 @@ import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
+import java.util.Map;
+
 /**
  * 用户游记点赞表VO视图对象。
  *
@@ -33,4 +35,10 @@ public class TourUserLikeTravelNotesVo extends BaseVo {
      */
     @Schema(description = "游记id")
     private Long travelNotesId;
+
+    /**
+     * tourismProjectTravelNotesWrite 的一对一关联数据对象,数据对应类型为TourismProjectTravelNotesWriteVo。
+     */
+    @Schema(description = "tourismProjectTravelNotesWrite 的一对一关联数据对象,数据对应类型为TourismProjectTravelNotesWrite")
+    private Map<String, Object> tourismProjectTravelNotesWrite;
 }

+ 1 - 1
application-webadmin/src/main/java/com/tourism/webadmin/back/vo/TourismProjectTravelNotesWriteVo.java

@@ -79,7 +79,7 @@ public class TourismProjectTravelNotesWriteVo extends BaseVo {
      * 发布游记的banner图。
      */
     @Schema(description = "发布游记的banner图")
-    private String travelNotesBannerUrl;
+    private String travelNotesBanner;
 
     /**
      * 游记内容中的图片。