mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-12-22 18:29:51 +08:00
优化event的时间属性 && 新增线上课章节和课时的排序编辑apic
This commit is contained in:
@@ -23,4 +23,6 @@ public interface CourseChapterService extends IService<CourseChapter> {
|
||||
|
||||
CourseChapter findOrFail(Integer id, Integer courseId) throws NotFoundException;
|
||||
|
||||
void updateSort(List<Integer> ids, Integer cid);
|
||||
|
||||
}
|
||||
|
||||
@@ -21,7 +21,11 @@ public interface CourseHourService extends IService<CourseHour> {
|
||||
|
||||
CourseHour create(Integer courseId, Integer chapterId, Integer sort, String title, String type, Integer rid, Integer duration);
|
||||
|
||||
Integer getCourseClassHourByCourseId(Integer courseId);
|
||||
Integer getCountByCourseId(Integer courseId);
|
||||
|
||||
Integer getCountByChapterId(Integer chapterId);
|
||||
|
||||
void remove(Integer courseId, Integer chapterId);
|
||||
|
||||
void updateSort(List<Integer> ids, Integer cid);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import xyz.playedu.api.service.CourseChapterService;
|
||||
import xyz.playedu.api.mapper.CourseChapterMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -61,6 +62,23 @@ public class CourseChapterServiceImpl extends ServiceImpl<CourseChapterMapper, C
|
||||
}
|
||||
return chapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSort(List<Integer> ids, Integer cid) {
|
||||
if (ids == null || ids.size() == 0) {
|
||||
return;
|
||||
}
|
||||
List<CourseChapter> chapters = new ArrayList<>();
|
||||
final Integer[] sortVal = {0};
|
||||
for (Integer idItem : ids) {
|
||||
chapters.add(new CourseChapter() {{
|
||||
setId(idItem);
|
||||
setId(cid);
|
||||
setSort(sortVal[0]++);
|
||||
}});
|
||||
}
|
||||
updateBatchById(chapters);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import xyz.playedu.api.service.CourseHourService;
|
||||
import xyz.playedu.api.mapper.CourseHourMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -62,14 +63,36 @@ public class CourseHourServiceImpl extends ServiceImpl<CourseHourMapper, CourseH
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getCourseClassHourByCourseId(Integer courseId) {
|
||||
public Integer getCountByCourseId(Integer courseId) {
|
||||
return Math.toIntExact(count(query().getWrapper().eq("course_id", courseId)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getCountByChapterId(Integer chapterId) {
|
||||
return Math.toIntExact(count(query().getWrapper().eq("chapter_id", chapterId)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(Integer courseId, Integer chapterId) {
|
||||
remove(query().getWrapper().eq("course_id", courseId).eq("chapter_id", chapterId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSort(List<Integer> ids, Integer cid) {
|
||||
if (ids == null || ids.size() == 0) {
|
||||
return;
|
||||
}
|
||||
List<CourseHour> hours = new ArrayList<>();
|
||||
final Integer[] sortVal = {0};
|
||||
for (Integer idVal : ids) {
|
||||
hours.add(new CourseHour() {{
|
||||
setId(idVal);
|
||||
setCourseId(cid);
|
||||
setSort(sortVal[0]++);
|
||||
}});
|
||||
}
|
||||
updateBatchById(hours);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user