mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-06-08 02:04:04 +08:00
课程上架时间
This commit is contained in:
parent
5a93eb9423
commit
4387471d76
@ -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:
|
||||
|
@ -24,6 +24,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@ -62,6 +63,9 @@ public class Course implements Serializable {
|
||||
@JsonProperty("is_show")
|
||||
private Integer isShow;
|
||||
|
||||
@JsonProperty("published_at")
|
||||
private Date publishedAt;
|
||||
|
||||
@JsonProperty("created_at")
|
||||
private Date createdAt;
|
||||
|
||||
@ -69,91 +73,7 @@ public class Course implements Serializable {
|
||||
|
||||
@JsonIgnore private Date deletedAt;
|
||||
|
||||
@Serial
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
if (that == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != that.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Course other = (Course) that;
|
||||
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
|
||||
&& (this.getTitle() == null
|
||||
? other.getTitle() == null
|
||||
: this.getTitle().equals(other.getTitle()))
|
||||
&& (this.getThumb() == null
|
||||
? other.getThumb() == null
|
||||
: this.getThumb().equals(other.getThumb()))
|
||||
&& (this.getCharge() == null
|
||||
? other.getCharge() == null
|
||||
: this.getCharge().equals(other.getCharge()))
|
||||
&& (this.getClassHour() == null
|
||||
? other.getClassHour() == null
|
||||
: this.getClassHour().equals(other.getClassHour()))
|
||||
&& (this.getIsShow() == null
|
||||
? other.getIsShow() == null
|
||||
: this.getIsShow().equals(other.getIsShow()))
|
||||
&& (this.getIsRequired() == null
|
||||
? other.getIsRequired() == null
|
||||
: this.getIsRequired().equals(other.getIsRequired()))
|
||||
&& (this.getCreatedAt() == null
|
||||
? other.getCreatedAt() == null
|
||||
: this.getCreatedAt().equals(other.getCreatedAt()))
|
||||
&& (this.getUpdatedAt() == null
|
||||
? other.getUpdatedAt() == null
|
||||
: this.getUpdatedAt().equals(other.getUpdatedAt()))
|
||||
&& (this.getDeletedAt() == null
|
||||
? other.getDeletedAt() == null
|
||||
: this.getDeletedAt().equals(other.getDeletedAt()))
|
||||
&& (this.getShortDesc() == null
|
||||
? other.getShortDesc() == null
|
||||
: this.getShortDesc().equals(other.getShortDesc()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
|
||||
result = prime * result + ((getTitle() == null) ? 0 : getTitle().hashCode());
|
||||
result = prime * result + ((getThumb() == null) ? 0 : getThumb().hashCode());
|
||||
result = prime * result + ((getCharge() == null) ? 0 : getCharge().hashCode());
|
||||
result = prime * result + ((getShortDesc() == null) ? 0 : getShortDesc().hashCode());
|
||||
result = prime * result + ((getClassHour() == null) ? 0 : getClassHour().hashCode());
|
||||
result = prime * result + ((getIsShow() == null) ? 0 : getIsShow().hashCode());
|
||||
result = prime * result + ((getIsRequired() == null) ? 0 : getIsRequired().hashCode());
|
||||
result = prime * result + ((getCreatedAt() == null) ? 0 : getCreatedAt().hashCode());
|
||||
result = prime * result + ((getUpdatedAt() == null) ? 0 : getUpdatedAt().hashCode());
|
||||
result = prime * result + ((getDeletedAt() == null) ? 0 : getDeletedAt().hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [");
|
||||
sb.append("Hash = ").append(hashCode());
|
||||
sb.append(", id=").append(id);
|
||||
sb.append(", title=").append(title);
|
||||
sb.append(", thumb=").append(thumb);
|
||||
sb.append(", charge=").append(charge);
|
||||
sb.append(", shortDesc=").append(shortDesc);
|
||||
sb.append(", classHour=").append(classHour);
|
||||
sb.append(", isShow=").append(isShow);
|
||||
sb.append(", isRequired=").append(isRequired);
|
||||
sb.append(", createdAt=").append(createdAt);
|
||||
sb.append(", updatedAt=").append(updatedAt);
|
||||
sb.append(", deletedAt=").append(deletedAt);
|
||||
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ import xyz.playedu.common.types.paginate.CoursePaginateFiler;
|
||||
import xyz.playedu.common.types.paginate.PaginationResult;
|
||||
import xyz.playedu.course.domain.Course;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -50,6 +51,7 @@ public interface CourseService extends IService<Course> {
|
||||
String shortDesc,
|
||||
Integer isRequired,
|
||||
Integer isShow,
|
||||
Date publishedAt,
|
||||
Integer[] categoryIds,
|
||||
Integer[] depIds);
|
||||
|
||||
|
@ -76,6 +76,7 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
|
||||
course.setShortDesc(shortDesc);
|
||||
course.setIsShow(isShow);
|
||||
course.setIsRequired(isRequired);
|
||||
course.setPublishedAt(new Date());
|
||||
course.setCreatedAt(new Date());
|
||||
course.setUpdatedAt(new Date());
|
||||
save(course);
|
||||
@ -146,6 +147,7 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
|
||||
String shortDesc,
|
||||
Integer isRequired,
|
||||
Integer isShow,
|
||||
Date publishedAt,
|
||||
Integer[] categoryIds,
|
||||
Integer[] depIds) {
|
||||
Course newCourse = new Course();
|
||||
@ -156,6 +158,10 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
|
||||
newCourse.setIsRequired(isRequired);
|
||||
newCourse.setShortDesc(shortDesc);
|
||||
|
||||
if (null != publishedAt) {
|
||||
newCourse.setPublishedAt(publishedAt);
|
||||
}
|
||||
|
||||
updateById(newCourse);
|
||||
|
||||
resetRelateCategories(newCourse, categoryIds);
|
||||
|
@ -13,6 +13,7 @@
|
||||
<result property="classHour" column="class_hour" jdbcType="INTEGER"/>
|
||||
<result property="isShow" column="is_show" jdbcType="TINYINT"/>
|
||||
<result property="isRequired" column="is_required" jdbcType="TINYINT"/>
|
||||
<result property="publishedAt" column="published_at" jdbcType="TIMESTAMP"/>
|
||||
<result property="createdAt" column="created_at" jdbcType="TIMESTAMP"/>
|
||||
<result property="updatedAt" column="updated_at" jdbcType="TIMESTAMP"/>
|
||||
<result property="deletedAt" column="deleted_at" jdbcType="TIMESTAMP"/>
|
||||
@ -21,7 +22,7 @@
|
||||
<sql id="Base_Column_List">
|
||||
id,title,thumb,short_desc,
|
||||
charge,class_hour,is_show,
|
||||
is_required,created_at,updated_at,
|
||||
is_required,published_at,created_at,updated_at,
|
||||
deleted_at
|
||||
</sql>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user