feat: 🎸 课程列表携带讲师信息

This commit is contained in:
GoCo 2025-08-15 17:13:22 +08:00
parent 64b7eded58
commit ec89859f60
6 changed files with 44 additions and 7 deletions

View File

@ -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<List<Course>> queryCourseList(
public Result<List<CourseWithTeacherInfo>> queryCourseList(
@RequestParam(value = "categoryId", required = false) String categoryId,
@RequestParam(value = "difficulty", required = false) String difficulty,
@RequestParam(value = "subject", required = false) String topic) {
List<Course> list = courseBizService.getCourseList(categoryId, difficulty, topic);
List<CourseWithTeacherInfo> list = courseBizService.getCourseList(categoryId, difficulty, topic);
return Result.OK(list);
}

View File

@ -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<TeacherInfo> teacherList;
}

View File

@ -9,4 +9,5 @@ public class TeacherInfo {
private String avatar;
private String title;
private String tag;
private Integer sortOrder;
}

View File

@ -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<Course> {
String uploadHls(MultipartFile file, HttpServletRequest request) throws Exception;
/**
* 根据分类难度专题查询课程列表
* 根据分类难度专题查询课程列表包含讲师信息
* @param categoryId
* @param difficulty
* @param topic
* @return
*/
List<Course> getCourseList(String categoryId, String difficulty, String topic);
List<CourseWithTeacherInfo> getCourseList(String categoryId, String difficulty, String topic);
/**
* 查询课程分类列表

View File

@ -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<CourseMapper, Course> impl
}
@Override
public List<Course> getCourseList(String categoryId, String difficulty, String topic) {
public List<CourseWithTeacherInfo> getCourseList(String categoryId, String difficulty, String topic) {
// TODO GC 根据分类 专题进行查询
QueryWrapper<Course> queryWrapper = new QueryWrapper<>();
if (difficulty != null && difficulty.trim().length() > 0) {
queryWrapper.eq("difficulty", difficulty);
}
return courseMapper.selectList(queryWrapper);
List<Course> courseList = courseMapper.selectList(queryWrapper);
// 构建包含讲师信息的课程列表
List<CourseWithTeacherInfo> result = new ArrayList<>();
for (Course course : courseList) {
CourseWithTeacherInfo courseWithTeacher = new CourseWithTeacherInfo();
// 复制课程基本信息
BeanUtils.copyProperties(course, courseWithTeacher);
// 获取讲师信息
List<TeacherInfo> teacherList = getCourseTeacherList(course.getId());
courseWithTeacher.setTeacherList(teacherList);
result.add(courseWithTeacher);
}
return result;
}
@Override
@ -255,6 +274,7 @@ public class CourseBizServiceImpl extends ServiceImpl<CourseMapper, Course> impl
teacherInfo.setAvatar(sysUser.getAvatar());
teacherInfo.setTitle(userInfo.getTitle());
teacherInfo.setTag(userInfo.getTag());
teacherInfo.setSortOrder(userInfo.getSortOrder());
result.add(teacherInfo);
}
return result;

View File

@ -79,6 +79,7 @@ public class UserBizServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> 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());