mirror of
https://github.com/PlayEdu/PlayEdu
synced 2026-02-03 15:22:19 +08:00
课程上架时间
This commit is contained in:
@@ -138,7 +138,7 @@ public class CourseController {
|
||||
Date now = new Date();
|
||||
int classHourCount = 0;
|
||||
|
||||
if (req.getHours().size() > 0) { // 无章节课时配置
|
||||
if (!req.getHours().isEmpty()) { // 无章节课时配置
|
||||
List<CourseHour> insertHours = new ArrayList<>();
|
||||
final Integer[] chapterSort = {0};
|
||||
for (CourseRequest.HourItem hourItem : req.getHours()) {
|
||||
@@ -156,12 +156,12 @@ public class CourseController {
|
||||
}
|
||||
});
|
||||
}
|
||||
if (insertHours.size() > 0) {
|
||||
if (!insertHours.isEmpty()) {
|
||||
hourService.saveBatch(insertHours);
|
||||
classHourCount = insertHours.size();
|
||||
}
|
||||
} else {
|
||||
if (req.getChapters().size() == 0) {
|
||||
if (req.getChapters().isEmpty()) {
|
||||
return JsonResponse.error("请配置课时");
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ public class CourseController {
|
||||
});
|
||||
}
|
||||
}
|
||||
if (insertHours.size() > 0) {
|
||||
if (!insertHours.isEmpty()) {
|
||||
hourService.saveBatch(insertHours);
|
||||
classHourCount = insertHours.size();
|
||||
}
|
||||
@@ -210,7 +210,7 @@ public class CourseController {
|
||||
}
|
||||
|
||||
// 课程附件
|
||||
if (null != req.getAttachments() && req.getAttachments().size() > 0) {
|
||||
if (null != req.getAttachments() && !req.getAttachments().isEmpty()) {
|
||||
List<CourseAttachment> insertAttachments = new ArrayList<>();
|
||||
final Integer[] sort = {0};
|
||||
for (CourseRequest.AttachmentItem attachmentItem : req.getAttachments()) {
|
||||
@@ -226,7 +226,7 @@ public class CourseController {
|
||||
}
|
||||
});
|
||||
}
|
||||
if (insertAttachments.size() > 0) {
|
||||
if (!insertAttachments.isEmpty()) {
|
||||
attachmentService.saveBatch(insertAttachments);
|
||||
}
|
||||
}
|
||||
@@ -245,7 +245,7 @@ public class CourseController {
|
||||
List<CourseHour> hours = hourService.getHoursByCourseId(course.getId());
|
||||
List<CourseAttachment> attachments =
|
||||
attachmentService.getAttachmentsByCourseId(course.getId());
|
||||
if (null != attachments && attachments.size() > 0) {
|
||||
if (null != attachments && !attachments.isEmpty()) {
|
||||
Map<Integer, Resource> resourceMap =
|
||||
resourceService
|
||||
.chunks(attachments.stream().map(CourseAttachment::getRid).toList())
|
||||
@@ -286,6 +286,7 @@ public class CourseController {
|
||||
req.getShortDesc(),
|
||||
req.getIsRequired(),
|
||||
req.getIsShow(),
|
||||
req.getPublishedAt(),
|
||||
req.getCategoryIds(),
|
||||
req.getDepIds());
|
||||
return JsonResponse.success();
|
||||
|
||||
@@ -17,14 +17,11 @@ package xyz.playedu.api.controller.frontend;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import xyz.playedu.common.context.FCtx;
|
||||
import xyz.playedu.common.types.JsonResponse;
|
||||
import xyz.playedu.common.types.paginate.CoursePaginateFiler;
|
||||
import xyz.playedu.common.types.paginate.PaginationResult;
|
||||
import xyz.playedu.common.util.IpUtil;
|
||||
import xyz.playedu.course.domain.*;
|
||||
import xyz.playedu.course.service.*;
|
||||
@@ -63,21 +60,6 @@ public class CourseController {
|
||||
|
||||
@Autowired private CourseAttachmentDownloadLogService courseAttachmentDownloadLogService;
|
||||
|
||||
@GetMapping("/index")
|
||||
public JsonResponse index(@RequestParam HashMap<String, Object> params) {
|
||||
Integer page = MapUtils.getInteger(params, "page", 1);
|
||||
Integer size = MapUtils.getInteger(params, "size", 10);
|
||||
String categoryIds = MapUtils.getString(params, "category_ids");
|
||||
|
||||
CoursePaginateFiler filer = new CoursePaginateFiler();
|
||||
filer.setIsShow(1);
|
||||
filer.setCategoryIds(categoryIds);
|
||||
|
||||
PaginationResult<Course> result = courseService.paginate(page, size, filer);
|
||||
|
||||
return JsonResponse.data(result);
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
@SneakyThrows
|
||||
public JsonResponse detail(@PathVariable(name = "id") Integer id) {
|
||||
@@ -87,7 +69,7 @@ public class CourseController {
|
||||
|
||||
List<CourseAttachment> attachments =
|
||||
attachmentService.getAttachmentsByCourseId(course.getId());
|
||||
if (null != attachments && attachments.size() > 0) {
|
||||
if (null != attachments && !attachments.isEmpty()) {
|
||||
Map<Integer, Resource> resourceMap =
|
||||
resourceService
|
||||
.chunks(attachments.stream().map(CourseAttachment::getRid).toList())
|
||||
|
||||
@@ -68,7 +68,7 @@ public class UserController {
|
||||
User user = FCtx.getUser();
|
||||
List<Department> departments = new ArrayList<>();
|
||||
List<Integer> depIds = userService.getDepIdsByUserId(user.getId());
|
||||
if (depIds != null && depIds.size() > 0) {
|
||||
if (depIds != null && !depIds.isEmpty()) {
|
||||
departments = departmentService.listByIds(depIds);
|
||||
}
|
||||
|
||||
@@ -134,17 +134,21 @@ public class UserController {
|
||||
// 全部部门课
|
||||
List<Course> openCourses = courseService.getOpenCoursesAndShow(500, categoryId);
|
||||
// 汇总到一个list中
|
||||
if (depCourses != null && depCourses.size() > 0) {
|
||||
if (depCourses != null && !depCourses.isEmpty()) {
|
||||
courses.addAll(depCourses);
|
||||
}
|
||||
if (openCourses != null && openCourses.size() > 0) {
|
||||
if (openCourses != null && !openCourses.isEmpty()) {
|
||||
courses.addAll(openCourses);
|
||||
}
|
||||
// 对结果进行排序->按照课程id倒序
|
||||
if (courses.size() > 0) {
|
||||
if (!courses.isEmpty()) {
|
||||
courses =
|
||||
courses.stream()
|
||||
.sorted(Comparator.comparing(Course::getId).reversed())
|
||||
.sorted(
|
||||
Comparator.comparing(
|
||||
Course::getPublishedAt,
|
||||
Comparator.nullsFirst(Date::compareTo))
|
||||
.reversed())
|
||||
.toList();
|
||||
}
|
||||
|
||||
@@ -154,7 +158,7 @@ public class UserController {
|
||||
|
||||
// -------- 读取学习进度 ----------
|
||||
Map<Integer, UserCourseRecord> learnCourseRecords = new HashMap<>();
|
||||
if (courses.size() > 0) {
|
||||
if (!courses.isEmpty()) {
|
||||
learnCourseRecords =
|
||||
userCourseRecordService.chunk(FCtx.getId(), courseIds).stream()
|
||||
.collect(Collectors.toMap(UserCourseRecord::getCourseId, e -> e));
|
||||
@@ -174,7 +178,7 @@ public class UserController {
|
||||
Long learnDuration = userLearnDurationStatsService.userDuration(FCtx.getId()); // 学习总时长
|
||||
|
||||
// -------- 学习数据统计 ----------
|
||||
if (courses.size() > 0) {
|
||||
if (!courses.isEmpty()) {
|
||||
for (Course courseItem : courses) {
|
||||
if (courseItem.getIsRequired() == 1) {
|
||||
requiredHourCount += courseItem.getClassHour();
|
||||
@@ -233,7 +237,7 @@ public class UserController {
|
||||
// 读取当前学员最近100条学习的线上课
|
||||
List<UserCourseHourRecord> userCourseHourRecords =
|
||||
userCourseHourRecordService.getLatestCourseIds(FCtx.getId(), 100);
|
||||
if (userCourseHourRecords == null || userCourseHourRecords.size() == 0) {
|
||||
if (userCourseHourRecords == null || userCourseHourRecords.isEmpty()) {
|
||||
return JsonResponse.data(new ArrayList<>());
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import jakarta.validation.constraints.NotNull;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -58,6 +59,9 @@ public class CourseRequest {
|
||||
@JsonProperty("category_ids")
|
||||
private Integer[] categoryIds;
|
||||
|
||||
@JsonProperty("published_at")
|
||||
private Date publishedAt;
|
||||
|
||||
@Data
|
||||
public static class HourItem {
|
||||
private String name;
|
||||
|
||||
@@ -34,7 +34,7 @@ spring:
|
||||
max-wait: 30000 # 连接池最大阻塞等待时间(使用负数表示没有限制,默认-1)
|
||||
max-active: 100 # 连接池最大连接数(使用负数表示没有限制,默认8)
|
||||
max-idle: 20 # 连接池中的最大空闲连接(默认8)
|
||||
min-idle: 5 # 连接池中的最小空闲连接(默认0)
|
||||
min-idle: 1 # 连接池中的最小空闲连接(默认0)
|
||||
# 线程池配置
|
||||
task:
|
||||
execution:
|
||||
|
||||
Reference in New Issue
Block a user