diff --git a/pom.xml b/pom.xml index a96b610..2c86e01 100644 --- a/pom.xml +++ b/pom.xml @@ -163,6 +163,17 @@ org.springframework.boot spring-boot-maven-plugin + + + com.teaching.TeachingBackendApplication + + + + + repackage + + + diff --git a/src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java index 9809732..c262b18 100644 --- a/src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java @@ -37,6 +37,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.stream.Collectors; /** *

@@ -172,15 +173,59 @@ public class CoursesServiceImpl extends ServiceImpl impl } @Override - public int countHours(String id) { - return 0; + public List getPagePageSize(int page, int pageSize) { + int startIndex = (page-1) * pageSize; + List list = coursesMapper.getItemsByPage(startIndex, pageSize); +// List list = coursesMapper.selectList(null); + List coursesVo = BeanUtil.copyToList(list, CoursesVO.class); + coursesVo = coursesVo.stream().map((item) -> { + + item.setTotalHours(countHours(item.getId())); + item.setTotalchapter(100); + item.setTotalKnow(100); +// if (StringUtils.isBlank(item.getName()) || +// StringUtils.isBlank(item.getDescription()) ){ +// throw new BusinessException(ErrorCode.OPERATION_ERROR,"数据格式有问题,请修改"); +// } + return item; + }).collect(Collectors.toList()); + return coursesVo; + } @Override - public List getPagePageSize(int page, int pageSize) { - return null; - } + public int countHours(String id) { + Courses courses = coursesMapper.selectById(id); + + Integer classhours = 0; + Integer theoryhours = 0; + Integer practicehours = 0; + Integer experimenthours = 0; + Integer otherhours = 0; + if (courses.getClasshours() != null) { + classhours = courses.getClasshours(); + } + + if (courses.getTheoryhours() != null) { + theoryhours = courses.getTheoryhours(); + } + if (courses.getPracticehours() != null) { + practicehours = courses.getPracticehours(); + } + + if (courses.getExperimenthours() != null) { + experimenthours = courses.getExperimenthours(); + } + + if (courses.getOtherhours() != null) { + otherhours = courses.getOtherhours(); + } + int total = classhours + theoryhours + practicehours + experimenthours + otherhours; + + return total; + + } /** * 修改课程信息 * @param coursesDTO diff --git a/src/main/java/com/teaching/backend/service/impl/records/LearningRecordsServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/records/LearningRecordsServiceImpl.java index 1350838..e27a638 100644 --- a/src/main/java/com/teaching/backend/service/impl/records/LearningRecordsServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/records/LearningRecordsServiceImpl.java @@ -103,8 +103,8 @@ public class LearningRecordsServiceImpl extends ServiceImpl