|
|
@ -1,6 +1,7 @@ |
|
|
|
package com.teaching.backend.service.impl.courses; |
|
|
|
package com.teaching.backend.service.impl.courses; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
@ -25,6 +26,7 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* <p> |
|
|
|
* <p> |
|
|
@ -115,4 +117,60 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public List<CoursesVO> getPagePageSize(int page, int pageSize) { |
|
|
|
|
|
|
|
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 |
|
|
|
|
|
|
|
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; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|