From 3cd3cb9a45c71644362715b8aab517a44351049c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=AE=E5=8F=AE=E5=92=9A=E5=92=9A?= <3107655287@qq.com> Date: Thu, 13 Jun 2024 15:17:53 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BD=91=E7=AB=99=E9=A6=96=E9=A1=B5=E2=80=94?= =?UTF-8?q?=E2=80=94=E8=A7=A6=E5=BA=95=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/courses/CoursesServiceImpl.java | 54 +++++++++++++++++-- src/main/resources/application.yml | 2 +- 2 files changed, 51 insertions(+), 5 deletions(-) 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