feat: 🎸 课程列表携带讲师信息
This commit is contained in:
parent
64b7eded58
commit
ec89859f60
@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
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.dto.TeacherInfo;
|
||||||
import org.jeecg.modules.biz.service.CourseBizService;
|
import org.jeecg.modules.biz.service.CourseBizService;
|
||||||
import org.jeecg.modules.gen.course.entity.Course;
|
import org.jeecg.modules.gen.course.entity.Course;
|
||||||
@ -42,13 +43,13 @@ public class CourseBizController {
|
|||||||
private ISysBaseAPI sysBaseApi;
|
private ISysBaseAPI sysBaseApi;
|
||||||
|
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
@Operation(summary = "查询课程列表", description = "可根据分类、难度、专题进行检索,三个参数可任意传递其中之一、之二或全部,不传参则查询所有课程")
|
@Operation(summary = "查询课程列表", description = "可根据分类、难度、专题进行检索,三个参数可任意传递其中之一、之二或全部,不传参则查询所有课程,携带讲师信息")
|
||||||
@IgnoreAuth
|
@IgnoreAuth
|
||||||
public Result<List<Course>> queryCourseList(
|
public Result<List<CourseWithTeacherInfo>> queryCourseList(
|
||||||
@RequestParam(value = "categoryId", required = false) String categoryId,
|
@RequestParam(value = "categoryId", required = false) String categoryId,
|
||||||
@RequestParam(value = "difficulty", required = false) String difficulty,
|
@RequestParam(value = "difficulty", required = false) String difficulty,
|
||||||
@RequestParam(value = "subject", required = false) String topic) {
|
@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);
|
return Result.OK(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
}
|
@ -9,4 +9,5 @@ public class TeacherInfo {
|
|||||||
private String avatar;
|
private String avatar;
|
||||||
private String title;
|
private String title;
|
||||||
private String tag;
|
private String tag;
|
||||||
|
private Integer sortOrder;
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import org.jeecg.modules.biz.dto.CourseWithTeacherInfo;
|
||||||
import org.jeecg.modules.biz.dto.TeacherInfo;
|
import org.jeecg.modules.biz.dto.TeacherInfo;
|
||||||
import org.jeecg.modules.gen.course.entity.Course;
|
import org.jeecg.modules.gen.course.entity.Course;
|
||||||
import org.jeecg.modules.gen.coursecategory.entity.CourseCategory;
|
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;
|
String uploadHls(MultipartFile file, HttpServletRequest request) throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据分类、难度、专题查询课程列表
|
* 根据分类、难度、专题查询课程列表(包含讲师信息)
|
||||||
* @param categoryId
|
* @param categoryId
|
||||||
* @param difficulty
|
* @param difficulty
|
||||||
* @param topic
|
* @param topic
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<Course> getCourseList(String categoryId, String difficulty, String topic);
|
List<CourseWithTeacherInfo> getCourseList(String categoryId, String difficulty, String topic);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询课程分类列表
|
* 查询课程分类列表
|
||||||
|
@ -6,6 +6,7 @@ import org.jeecg.common.util.MinioUtil;
|
|||||||
import org.jeecg.common.util.SpringContextUtils;
|
import org.jeecg.common.util.SpringContextUtils;
|
||||||
import org.jeecg.common.util.oss.OssBootUtil;
|
import org.jeecg.common.util.oss.OssBootUtil;
|
||||||
import org.jeecg.modules.biz.constant.EntityLinkConst;
|
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.dto.TeacherInfo;
|
||||||
import org.jeecg.modules.biz.service.CourseBizService;
|
import org.jeecg.modules.biz.service.CourseBizService;
|
||||||
import org.jeecg.modules.biz.service.EntityLinkBizService;
|
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.gen.userinfo.mapper.UserInfoMapper;
|
||||||
import org.jeecg.modules.system.entity.SysUser;
|
import org.jeecg.modules.system.entity.SysUser;
|
||||||
import org.jeecg.modules.system.mapper.SysUserMapper;
|
import org.jeecg.modules.system.mapper.SysUserMapper;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
@ -147,12 +149,29 @@ public class CourseBizServiceImpl extends ServiceImpl<CourseMapper, Course> impl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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<>();
|
QueryWrapper<Course> queryWrapper = new QueryWrapper<>();
|
||||||
if (difficulty != null && difficulty.trim().length() > 0) {
|
if (difficulty != null && difficulty.trim().length() > 0) {
|
||||||
queryWrapper.eq("difficulty", difficulty);
|
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
|
@Override
|
||||||
@ -255,6 +274,7 @@ public class CourseBizServiceImpl extends ServiceImpl<CourseMapper, Course> impl
|
|||||||
teacherInfo.setAvatar(sysUser.getAvatar());
|
teacherInfo.setAvatar(sysUser.getAvatar());
|
||||||
teacherInfo.setTitle(userInfo.getTitle());
|
teacherInfo.setTitle(userInfo.getTitle());
|
||||||
teacherInfo.setTag(userInfo.getTag());
|
teacherInfo.setTag(userInfo.getTag());
|
||||||
|
teacherInfo.setSortOrder(userInfo.getSortOrder());
|
||||||
result.add(teacherInfo);
|
result.add(teacherInfo);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -79,6 +79,7 @@ public class UserBizServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> im
|
|||||||
teacherInfo.setAvatar(sysUser.getAvatar());
|
teacherInfo.setAvatar(sysUser.getAvatar());
|
||||||
teacherInfo.setTitle(userInfo.getTitle());
|
teacherInfo.setTitle(userInfo.getTitle());
|
||||||
teacherInfo.setTag(userInfo.getTag());
|
teacherInfo.setTag(userInfo.getTag());
|
||||||
|
teacherInfo.setSortOrder(userInfo.getSortOrder());
|
||||||
if (!teacherIds.contains(courseTeacher.getTeacherId())) {
|
if (!teacherIds.contains(courseTeacher.getTeacherId())) {
|
||||||
result.add(teacherInfo);
|
result.add(teacherInfo);
|
||||||
teacherIds.add(courseTeacher.getTeacherId());
|
teacherIds.add(courseTeacher.getTeacherId());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user