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..f5a9259 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,13 +173,58 @@ 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;
+
}
/**
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index cf160ba..e5d1972 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -10,7 +10,7 @@ spring:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/teaching_db
username: root
- password: root
+ password: 1234567788
mybatis:
configuration:
map-underscore-to-camel-case: true