Ver código fonte

feat(app): 优化教练列表搜索功能

- 添加培训项目字段并优化显示逻辑
- 修复关键字搜索功能,提高搜索准确性
- 优化 SQL 查询,提高数据加载效率
- 更新相关实体类和 VO 类以支持新功能
SheepHy 3 dias atrás
pai
commit
a80bc9ac38

+ 6 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/service/impl/AppHomeServiceImpl.java

@@ -359,6 +359,12 @@ public class AppHomeServiceImpl implements IAppHomeService {
         Page<SearchVO.SearchInstructorVO> page = new Page<>(searchDTO.getCurrent(), searchDTO.getSize());
         Page<SearchVO.SearchInstructorVO> searchInstructorVOPage = appInstructorMapper.convertSearchInstructorVOPage(page, searchDTO);
         searchInstructorVOPage.getRecords().forEach(instructorVO -> {
+            List<String> list = new ArrayList<>();
+            List.of(instructorVO.getTrainingPrograms().split(",")).forEach(item -> {
+                String str = appCategoryMapper.selectById(item).getName();
+                list.add(str);
+            });
+            instructorVO.setList( list);
             // 获取该教练的课程(最多取2个)
             List<AppCourses> courses = appCoursesMapper.selectList(
                     Wrappers.<AppCourses>lambdaQuery().eq(AppCourses::getUserId, instructorVO.getUserId()).last("LIMIT 2"));

+ 3 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/vo/SearchVO.java

@@ -48,6 +48,8 @@ public class SearchVO{
         private String goodRate;
         @Schema(description = "订单数")
         private String orderCount;
+        @Schema(description = "培训项目")
+        private String trainingPrograms;
         @Schema(description = "授课人数")
         private String classesNumber;
         @Schema(description = "课程列表ID")
@@ -56,6 +58,7 @@ public class SearchVO{
         private String userId;
         @Schema(description = "课程列表")
         private List<SearchCoursesVO> courseList;
+        private List<String> list;
     }
     @Data
     @Accessors(chain = true)

+ 21 - 29
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/mapper/xml/AppInstructorMapper.xml

@@ -61,37 +61,29 @@
     </update>
     <select id="convertSearchInstructorVOPage" resultType="org.jeecg.modules.app.vo.SearchVO$SearchInstructorVO">
         SELECT
-            a.id,
-            b.realname AS name,
-            b.avatar,
-            c.depart_name AS orgName,
-            a.excel_msg,
-            a.teaching_philosophy,
-            a.good_rate,
-            a.classes_number,
-            b.id AS userId,
-            a.org_code AS orgCode,
-            COUNT( DISTINCT d.user_id, c2.id ) AS orderCount
-        FROM
-            nm_instructor a
-                LEFT JOIN sys_user b ON a.user_id = b.id
-                LEFT JOIN sys_depart c ON b.org_code = c.org_code
-                LEFT JOIN nm_courses d ON a.user_id = d.user_id
-                LEFT JOIN nm_order_pro_info c2 ON d.user_id = c2.family_user_id
+        a.id,
+        b.realname AS name,
+        b.avatar,
+        s.name AS orgName,
+        a.excel_msg,
+        a.teaching_philosophy,
+        a.good_rate,
+        a.classes_number,
+        b.id AS userId,
+        a.org_code AS orgCode,
+        COUNT(DISTINCT d.user_id, c2.id) AS orderCount,
+        a.training_programs
+        FROM nm_instructor a
+        LEFT JOIN sys_user b ON a.user_id = b.id
+        LEFT JOIN sys_depart c ON b.org_code = c.org_code
+        LEFT JOIN nm_site s ON c.org_code = s.org_code
+        LEFT JOIN nm_courses d ON a.user_id = d.user_id
+        LEFT JOIN nm_order_pro_info c2 ON d.user_id = c2.family_user_id
         WHERE 1=1
-        <if test="searchDTO.keyword != null and searchDTO.keyword == ''">
-            AND (b.realname LIKE CONCAT('%',#{searchDTO.keyword},'%') OR c.depart_name LIKE CONCAT('%',#{searchDTO.keyword},'%'))
+        <if test="searchDTO.keyword != null and searchDTO.keyword != ''">
+            AND b.realname LIKE CONCAT('%',#{searchDTO.keyword},'%')
         </if>
-        GROUP BY
-            a.id,
-            b.realname,
-            b.avatar,
-            userId,
-            c.depart_name,
-            a.excel_msg,
-            a.teaching_philosophy,
-            a.good_rate,
-            a.classes_number
+        GROUP BY a.id
         ORDER BY orderCount DESC
     </select>
     <select id="findCoachList" resultType="org.jeecg.modules.app.vo.coach.AppCoachVO">