diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/biz/controller/CourseBizController.java b/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/biz/controller/CourseBizController.java index 3e0fe24e..5b87ea71 100644 --- a/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/biz/controller/CourseBizController.java +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/biz/controller/CourseBizController.java @@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.jeecg.common.system.api.ISysBaseAPI; +import org.jeecg.modules.biz.dto.CourseWithTeacherInfo; import org.jeecg.modules.biz.dto.TeacherInfo; import org.jeecg.modules.biz.service.CourseBizService; import org.jeecg.modules.gen.course.entity.Course; @@ -42,13 +43,13 @@ public class CourseBizController { private ISysBaseAPI sysBaseApi; @GetMapping("/list") - @Operation(summary = "查询课程列表", description = "可根据分类、难度、专题进行检索,三个参数可任意传递其中之一、之二或全部,不传参则查询所有课程") + @Operation(summary = "查询课程列表", description = "可根据分类、难度、专题进行检索,三个参数可任意传递其中之一、之二或全部,不传参则查询所有课程,携带讲师信息") @IgnoreAuth - public Result> queryCourseList( + public Result> queryCourseList( @RequestParam(value = "categoryId", required = false) String categoryId, @RequestParam(value = "difficulty", required = false) String difficulty, @RequestParam(value = "subject", required = false) String topic) { - List list = courseBizService.getCourseList(categoryId, difficulty, topic); + List list = courseBizService.getCourseList(categoryId, difficulty, topic); return Result.OK(list); } diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/biz/dto/CourseWithTeacherInfo.java b/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/biz/dto/CourseWithTeacherInfo.java new file mode 100644 index 00000000..cd78b9ea --- /dev/null +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/biz/dto/CourseWithTeacherInfo.java @@ -0,0 +1,13 @@ +package org.jeecg.modules.biz.dto; + +import org.jeecg.modules.gen.course.entity.Course; +import lombok.Data; +import lombok.EqualsAndHashCode; +import java.util.List; + +@Data +@EqualsAndHashCode(callSuper = false) +public class CourseWithTeacherInfo extends Course { + /**讲师信息列表*/ + private List teacherList; +} diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/biz/dto/TeacherInfo.java b/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/biz/dto/TeacherInfo.java index e85afa3c..3a6d940b 100644 --- a/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/biz/dto/TeacherInfo.java +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/biz/dto/TeacherInfo.java @@ -9,4 +9,5 @@ public class TeacherInfo { private String avatar; private String title; private String tag; + private Integer sortOrder; } diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/biz/service/CourseBizService.java b/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/biz/service/CourseBizService.java index c16e726a..7e5d201c 100644 --- a/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/biz/service/CourseBizService.java +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/biz/service/CourseBizService.java @@ -4,6 +4,7 @@ import java.util.List; import javax.servlet.http.HttpServletRequest; +import org.jeecg.modules.biz.dto.CourseWithTeacherInfo; import org.jeecg.modules.biz.dto.TeacherInfo; import org.jeecg.modules.gen.course.entity.Course; import org.jeecg.modules.gen.coursecategory.entity.CourseCategory; @@ -27,13 +28,13 @@ public interface CourseBizService extends IService { String uploadHls(MultipartFile file, HttpServletRequest request) throws Exception; /** - * 根据分类、难度、专题查询课程列表 + * 根据分类、难度、专题查询课程列表(包含讲师信息) * @param categoryId * @param difficulty * @param topic * @return */ - List getCourseList(String categoryId, String difficulty, String topic); + List getCourseList(String categoryId, String difficulty, String topic); /** * 查询课程分类列表 diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/biz/service/impl/CourseBizServiceImpl.java b/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/biz/service/impl/CourseBizServiceImpl.java index 3ec179c6..f1d71f93 100644 --- a/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/biz/service/impl/CourseBizServiceImpl.java +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/biz/service/impl/CourseBizServiceImpl.java @@ -6,6 +6,7 @@ import org.jeecg.common.util.MinioUtil; import org.jeecg.common.util.SpringContextUtils; import org.jeecg.common.util.oss.OssBootUtil; import org.jeecg.modules.biz.constant.EntityLinkConst; +import org.jeecg.modules.biz.dto.CourseWithTeacherInfo; import org.jeecg.modules.biz.dto.TeacherInfo; import org.jeecg.modules.biz.service.CourseBizService; import org.jeecg.modules.biz.service.EntityLinkBizService; @@ -22,6 +23,7 @@ import org.jeecg.modules.gen.userinfo.entity.UserInfo; import org.jeecg.modules.gen.userinfo.mapper.UserInfoMapper; import org.jeecg.modules.system.entity.SysUser; import org.jeecg.modules.system.mapper.SysUserMapper; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; @@ -147,12 +149,29 @@ public class CourseBizServiceImpl extends ServiceImpl impl } @Override - public List getCourseList(String categoryId, String difficulty, String topic) { + public List getCourseList(String categoryId, String difficulty, String topic) { + // TODO GC 根据分类 专题进行查询 QueryWrapper queryWrapper = new QueryWrapper<>(); if (difficulty != null && difficulty.trim().length() > 0) { queryWrapper.eq("difficulty", difficulty); } - return courseMapper.selectList(queryWrapper); + List courseList = courseMapper.selectList(queryWrapper); + + // 构建包含讲师信息的课程列表 + List result = new ArrayList<>(); + for (Course course : courseList) { + CourseWithTeacherInfo courseWithTeacher = new CourseWithTeacherInfo(); + // 复制课程基本信息 + BeanUtils.copyProperties(course, courseWithTeacher); + + // 获取讲师信息 + List teacherList = getCourseTeacherList(course.getId()); + courseWithTeacher.setTeacherList(teacherList); + + result.add(courseWithTeacher); + } + + return result; } @Override @@ -255,6 +274,7 @@ public class CourseBizServiceImpl extends ServiceImpl impl teacherInfo.setAvatar(sysUser.getAvatar()); teacherInfo.setTitle(userInfo.getTitle()); teacherInfo.setTag(userInfo.getTag()); + teacherInfo.setSortOrder(userInfo.getSortOrder()); result.add(teacherInfo); } return result; diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/biz/service/impl/UserBizServiceImpl.java b/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/biz/service/impl/UserBizServiceImpl.java index 783a155a..bd789cd6 100644 --- a/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/biz/service/impl/UserBizServiceImpl.java +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/biz/service/impl/UserBizServiceImpl.java @@ -79,6 +79,7 @@ public class UserBizServiceImpl extends ServiceImpl im teacherInfo.setAvatar(sysUser.getAvatar()); teacherInfo.setTitle(userInfo.getTitle()); teacherInfo.setTag(userInfo.getTag()); + teacherInfo.setSortOrder(userInfo.getSortOrder()); if (!teacherIds.contains(courseTeacher.getTeacherId())) { result.add(teacherInfo); teacherIds.add(courseTeacher.getTeacherId());