Compare commits
3 Commits
326e764f29
...
337ba0f42a
Author | SHA1 | Date | |
---|---|---|---|
![]() |
337ba0f42a | ||
![]() |
42eb767979 | ||
![]() |
bf470b1c79 |
@ -33,8 +33,8 @@ import org.jeecg.modules.gen.resource.entity.Resource;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.Comparator;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
@ -55,8 +55,27 @@ public class CourseBizController {
|
|||||||
public Result<List<CourseWithTeacherInfo>> 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,
|
||||||
|
@RequestParam(value = "sort", required = false) String sort) {
|
||||||
List<CourseWithTeacherInfo> list = courseBizService.getCourseList(categoryId, difficulty, topic);
|
List<CourseWithTeacherInfo> list = courseBizService.getCourseList(categoryId, difficulty, topic);
|
||||||
|
if (sort != null) {
|
||||||
|
switch (sort) {
|
||||||
|
case "hottest":
|
||||||
|
list = list.stream()
|
||||||
|
.sorted(Comparator.comparing(Course::getEnrollCount, Comparator.nullsLast(Integer::compareTo)).reversed())
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
break;
|
||||||
|
case "latest":
|
||||||
|
list = list.stream()
|
||||||
|
.sorted(Comparator.comparing(Course::getCreateTime, Comparator.nullsLast(java.util.Date::compareTo)).reversed())
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
break;
|
||||||
|
case "recommend":
|
||||||
|
default:
|
||||||
|
// 不处理,直接返回
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
return Result.OK(list);
|
return Result.OK(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,6 +238,16 @@ public class CourseBizController {
|
|||||||
return Result.OK(progress);
|
return Result.OK(progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/count")
|
||||||
|
@Operation(summary = "查询课程总数", description = "返回系统中所有课程的总数量")
|
||||||
|
@IgnoreAuth
|
||||||
|
public Result<Long> queryCourseCount() {
|
||||||
|
long count = courseBizService.count();
|
||||||
|
return Result.OK(count);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/test")
|
@GetMapping("/test")
|
||||||
@IgnoreAuth
|
@IgnoreAuth
|
||||||
public Result<String> test() {
|
public Result<String> test() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user