Browse Source

完善门户网站的旅游项目列表接口和劳务项目接口的全部项目查询

chenchen 6 months ago
parent
commit
32c986ad81

+ 18 - 4
application-webadmin/src/main/java/com/tourism/webadmin/app/website/controller/JobProjectToWebController.java

@@ -9,8 +9,10 @@ import com.tourism.common.core.object.*;
 import com.tourism.common.core.util.MyModelUtil;
 import com.tourism.common.core.util.MyPageUtil;
 import com.tourism.webadmin.back.dto.JobProjectDto;
+import com.tourism.webadmin.back.model.DirectoryInfo;
 import com.tourism.webadmin.back.model.JobProject;
 import com.tourism.webadmin.back.service.JobProjectService;
+import com.tourism.webadmin.back.service.TourismProjectService;
 import com.tourism.webadmin.back.vo.JobProjectVo;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import lombok.extern.slf4j.Slf4j;
@@ -19,6 +21,8 @@ import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
 
+import static java.util.stream.Collectors.toList;
+
 /**
  * 网页劳务项目管理操作控制器类。
  *
@@ -34,7 +38,8 @@ public class JobProjectToWebController {
 
     @Autowired
     private JobProjectService jobProjectService;
-
+    @Autowired
+    private TourismProjectService tourismProjectService;
     /**
      * 列出符合过滤条件的劳务项目管理列表。
      *
@@ -48,16 +53,25 @@ public class JobProjectToWebController {
             @MyRequestBody JobProjectDto jobProjectDtoFilter,
             @MyRequestBody MyOrderParam orderParam,
             @MyRequestBody MyPageParam pageParam) {
-        if (pageParam != null) {
-            PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize(), pageParam.getCount());
-        }
         if(jobProjectDtoFilter.getBelongTab() == null){
             return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST,"所属分类(belongTab)不能为空!");
         }
+        //如果belongTab小于1000并且大于10.则表明查询的是一级菜单
+        if(jobProjectDtoFilter.getBelongTab()>=10 && jobProjectDtoFilter.getBelongTab()<1000){
+            DirectoryInfo filter = new DirectoryInfo();
+            filter.setParentId(jobProjectDtoFilter.getBelongTab());
+            filter.setEnable(1);
+            List<DirectoryInfo> directoryInfoList = tourismProjectService.getDirectoryInfoList(filter, null);
+            jobProjectDtoFilter.setBelongTab(null);
+            jobProjectDtoFilter.setDirectoryInfoIds(directoryInfoList.stream().map(DirectoryInfo::getId).collect(toList()));
+        }
         JobProject jobProjectFilter = MyModelUtil.copyTo(jobProjectDtoFilter, JobProject.class);
         //首页展示的为启用的内容
         jobProjectFilter.setEnable(1);
         String orderBy = MyOrderParam.buildOrderBy(orderParam, JobProject.class);
+        if (pageParam != null) {
+            PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize(), pageParam.getCount());
+        }
         List<JobProject> jobProjectList = jobProjectService.getJobProjectListWithRelation(jobProjectFilter, orderBy);
         return ResponseResult.success(MyPageUtil.makeResponseData(jobProjectList, JobProjectVo.class));
     }

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

@@ -11,6 +11,7 @@ import com.tourism.common.core.util.MyModelUtil;
 import com.tourism.common.core.util.MyPageUtil;
 import com.tourism.common.redis.cache.SessionCacheHelper;
 import com.tourism.webadmin.back.dto.TourismProjectDto;
+import com.tourism.webadmin.back.model.DirectoryInfo;
 import com.tourism.webadmin.back.model.TourismProject;
 import com.tourism.webadmin.back.service.TourismProjectService;
 import com.tourism.webadmin.back.vo.TourismProjectVo;
@@ -23,6 +24,9 @@ import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
+import java.util.stream.Collectors;
+
+import static java.util.stream.Collectors.toList;
 
 /**
  * 旅游项目管理操作控制器类。
@@ -57,13 +61,22 @@ public class TourismProjectToWebController {
 //        if(tourismProjectDtoFilter.getBelongTab() == null){
 //            return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST,"所属分类(belongTab)不能为空!");
 //        }
-        if (pageParam != null) {
-            PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize(), pageParam.getCount());
+        //如果belongTab小于1000并且大于10.则表明查询的是一级菜单
+        if(tourismProjectDtoFilter.getBelongTab()>=10 && tourismProjectDtoFilter.getBelongTab()<1000){
+            DirectoryInfo filter = new DirectoryInfo();
+            filter.setParentId(tourismProjectDtoFilter.getBelongTab());
+            filter.setEnable(1);
+            List<DirectoryInfo> directoryInfoList = tourismProjectService.getDirectoryInfoList(filter, null);
+            tourismProjectDtoFilter.setBelongTab(null);
+            tourismProjectDtoFilter.setDirectoryInfoIds(directoryInfoList.stream().map(DirectoryInfo::getId).collect(toList()));
         }
         TourismProject tourismProjectFilter = MyModelUtil.copyTo(tourismProjectDtoFilter, TourismProject.class);
         //首页展示的为启用的内容
         tourismProjectFilter.setEnable(1);
         String orderBy = MyOrderParam.buildOrderBy(orderParam, TourismProject.class);
+        if (pageParam != null) {
+            PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize(), pageParam.getCount());
+        }
         List<TourismProject> tourismProjectList =
                 tourismProjectService.getTourismProjectListWithRelation(tourismProjectFilter, orderBy);
         return ResponseResult.success(MyPageUtil.makeResponseData(tourismProjectList, TourismProjectVo.class));

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

@@ -126,6 +126,12 @@
                 AND (IFNULL(tour_job_project.job_title,'') LIKE #{safeJobProjectSearchString}
                 or IFNULL(tour_job_project.job_area,'') LIKE #{safeJobProjectSearchString})
             </if>
+            <if test="jobProjectFilter.directoryInfoIds != null and jobProjectFilter.directoryInfoIds.size() > 0">
+                AND tour_job_project.belong_tab IN
+                <foreach item="id" index="index" collection="jobProjectFilter.directoryInfoIds" open="(" separator="," close=")">
+                    #{id}
+                </foreach>
+            </if>
         </if>
     </sql>
 

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

@@ -96,6 +96,12 @@
             <if test="tourismProjectFilter.enable != null">
                 AND tour_tourism_project.enable = #{tourismProjectFilter.enable}
             </if>
+            <if test="tourismProjectFilter.directoryInfoIds != null and tourismProjectFilter.directoryInfoIds.size() > 0">
+                AND tour_tourism_project.belong_tab IN
+                <foreach item="id" index="index" collection="tourismProjectFilter.directoryInfoIds" open="(" separator="," close=")">
+                    #{id}
+                </foreach>
+            </if>
         </if>
     </sql>
 

+ 7 - 0
application-webadmin/src/main/java/com/tourism/webadmin/back/dto/JobProjectDto.java

@@ -10,6 +10,8 @@ import lombok.Data;
 
 import jakarta.validation.constraints.*;
 
+import java.util.List;
+
 /**
  * 劳务项目管理Dto对象。
  *
@@ -174,4 +176,9 @@ public class JobProjectDto {
      */
     @Schema(description = "LIKE模糊搜索字符串")
     private String searchString;
+
+    /**
+     * 菜单id。
+     */
+    private List<Long> directoryInfoIds;
 }

+ 7 - 0
application-webadmin/src/main/java/com/tourism/webadmin/back/dto/TourismProjectDto.java

@@ -10,6 +10,8 @@ import jakarta.validation.constraints.NotBlank;
 import jakarta.validation.constraints.NotNull;
 import lombok.Data;
 
+import java.util.List;
+
 /**
  * 旅游项目管理Dto对象。
  *
@@ -114,4 +116,9 @@ public class TourismProjectDto {
      */
     @Schema(description = "LIKE模糊搜索字符串")
     private String searchString;
+
+    /**
+     * 菜单id。
+     */
+    private List<Long> directoryInfoIds;
 }

+ 6 - 0
application-webadmin/src/main/java/com/tourism/webadmin/back/model/JobProject.java

@@ -11,6 +11,7 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 
 import java.math.BigDecimal;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -219,4 +220,9 @@ public class JobProject extends BaseModel {
             constantDictClass = Enable.class)
     @TableField(exist = false)
     private Map<String, Object> enableDictMap;
+
+    /**
+     * 菜单id。
+     */
+    private List<Long> directoryInfoIds;
 }

+ 6 - 0
application-webadmin/src/main/java/com/tourism/webadmin/back/model/TourismProject.java

@@ -10,6 +10,7 @@ import com.tourism.webadmin.back.model.constant.Hotspot;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -158,4 +159,9 @@ public class TourismProject extends BaseModel {
             constantDictClass = Enable.class)
     @TableField(exist = false)
     private Map<String, Object> enableDictMap;
+
+    /**
+     * 菜单ids。
+     */
+    private List<Long> directoryInfoIds;
 }

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

@@ -105,4 +105,14 @@ public interface TourismProjectService extends IBaseService<TourismProject, Long
      * @return 验证结果。如果失败,包含具体的错误信息和导致错误的数据对象。
      */
     CallResult verifyImportList(List<TourismProject> dataList, Set<String> ignoreFieldSet);
+
+    /**
+     * 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
+     * 如果需要同时获取关联数据,请移步(getDirectoryInfoListWithRelation)方法。
+     *
+     * @param filter  过滤对象。
+     * @param orderBy 排序参数。
+     * @return 查询结果集。
+     */
+    List<DirectoryInfo> getDirectoryInfoList(DirectoryInfo filter, String orderBy);
 }

+ 5 - 1
application-webadmin/src/main/java/com/tourism/webadmin/back/service/impl/TourismProjectServiceImpl.java

@@ -41,7 +41,6 @@ public class TourismProjectServiceImpl extends BaseService<TourismProject, Long>
     private TourismFileService tourismFileService;
     @Autowired
     private TourismContentService tourismContentService;
-
     /**
      * 返回当前Service的主表Mapper对象。
      *
@@ -213,4 +212,9 @@ public class TourismProjectServiceImpl extends BaseService<TourismProject, Long>
         tourismProject.setDataState(GlobalDeletedFlag.NORMAL);
         return tourismProject;
     }
+
+    @Override
+    public List<DirectoryInfo> getDirectoryInfoList(DirectoryInfo filter, String orderBy) {
+        return directoryInfoService.getDirectoryInfoList(filter, orderBy);
+    }
 }