Skip to main content

一、新建前端查询课程名师接口

1、在service-edu模块创建controller

(1)查询最新前4条讲师数据

(2)查询最新前8条课程数据

@RestController
@RequestMapping("/eduservice/index")
@CrossOrigin
public class IndexController {

@Autowired
private EduCourseService courseService;
@Autowired
private EduTeacherService teacherService;

//查询前8条热门课程,查询前4条名师
@GetMapping("index")
public R index() {
//查询前8条热门课程
QueryWrapper<EduCourse> wrapper = new QueryWrapper<>();
wrapper.orderByDesc("id");
wrapper.last("limit 8");
List<EduCourse> eduList = courseService.list(wrapper);

//查询前4条名师
QueryWrapper<EduTeacher> wrapperTeacher = new QueryWrapper<>();
wrapperTeacher.orderByDesc("id");
wrapperTeacher.last("limit 4");
List<EduTeacher> teacherList = teacherService.list(wrapperTeacher);

return R.ok().data("eduList",eduList).data("teacherList",teacherList);
}
}