网站首页——触底加载

master
叮叮咚咚 6 months ago
parent 838d75e13e
commit 3cd3cb9a45
  1. 54
      src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java
  2. 2
      src/main/resources/application.yml

@ -37,6 +37,7 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* <p> * <p>
@ -172,13 +173,58 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
} }
@Override @Override
public int countHours(String id) { public List<CoursesVO> getPagePageSize(int page, int pageSize) {
return 0; int startIndex = (page-1) * pageSize;
List<Courses> list = coursesMapper.getItemsByPage(startIndex, pageSize);
// List<Courses> list = coursesMapper.selectList(null);
List<CoursesVO> 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 @Override
public List<CoursesVO> getPagePageSize(int page, int pageSize) { public int countHours(String id) {
return null; 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;
} }
/** /**

@ -10,7 +10,7 @@ spring:
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/teaching_db url: jdbc:mysql://localhost:3306/teaching_db
username: root username: root
password: root password: 1234567788
mybatis: mybatis:
configuration: configuration:
map-underscore-to-camel-case: true map-underscore-to-camel-case: true

Loading…
Cancel
Save