chenminghua 2 years ago
parent
commit
3c644be8d1

+ 19 - 0
exam-06173-api/src/main/java/com/gyee/exam/modules/course/dto/CourseDTO.java

@@ -1,5 +1,6 @@
 package com.gyee.exam.modules.course.dto;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.gyee.boot.base.api.annon.Dict;
 import com.gyee.exam.modules.course.enums.CourseState;
 import io.swagger.annotations.ApiModel;
@@ -135,6 +136,24 @@ public class CourseDTO implements Serializable {
     @ApiModelProperty(value = "数据标识", required=true)
     private Integer dataFlag;
 
+    /**
+     * 需要学习时长
+     */
+    @TableField(exist = false)
+    private Double needLearnCount;
+
+    /**
+     * 已学习时长
+     */
+    @TableField(exist = false)
+    private Double learnMinCount;
+
+    /**
+     * 学习时长比例
+     */
+    @TableField(exist = false)
+    private Double proportion;
+
 
     /**
      * 判断状态

+ 4 - 1
exam-06173-api/src/main/java/com/gyee/exam/modules/course/dto/response/UserCourseProcessDTO.java

@@ -1,8 +1,11 @@
-package com.yf.exam.modules.course.dto.response;
+package com.gyee.exam.modules.course.dto.response;
 
 
 import lombok.Data;
 
+/**
+ * 课程总进度统计
+ */
 @Data
 public class UserCourseProcessDTO {
 

+ 5 - 0
exam-06173-api/src/main/java/com/gyee/exam/modules/course/mapper/CourseMapper.java

@@ -5,10 +5,13 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.gyee.exam.modules.course.dto.ext.CourseDetailExtDTO;
 import com.gyee.exam.modules.course.dto.request.UserCourseReqDTO;
+import com.gyee.exam.modules.course.dto.response.UserCourseProcessDTO;
 import com.gyee.exam.modules.course.dto.response.UserCourseRespDTO;
 import com.gyee.exam.modules.course.entity.Course;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 /**
 * <p>
 * 课程信息Mapper
@@ -34,4 +37,6 @@ public interface CourseMapper extends BaseMapper<Course> {
      * @return
      */
     IPage<UserCourseRespDTO> userPaging(Page page, @Param("query") UserCourseReqDTO reqDTO);
+
+    List<UserCourseProcessDTO> userPagingToal(Page page, @Param("query") UserCourseReqDTO reqDTO);
 }

+ 11 - 1
exam-06173-api/src/main/java/com/gyee/exam/modules/course/service/impl/CourseServiceImpl.java

@@ -15,6 +15,7 @@ import com.gyee.exam.modules.course.dto.ext.CourseDetailExtDTO;
 import com.gyee.exam.modules.course.dto.ext.CourseRefDirExtDTO;
 import com.gyee.exam.modules.course.dto.ext.CourseRefFileExtDTO;
 import com.gyee.exam.modules.course.dto.request.UserCourseReqDTO;
+import com.gyee.exam.modules.course.dto.response.UserCourseProcessDTO;
 import com.gyee.exam.modules.course.dto.response.UserCourseRespDTO;
 import com.gyee.exam.modules.course.entity.Course;
 import com.gyee.exam.modules.course.entity.CourseRefDir;
@@ -34,6 +35,8 @@ import org.springframework.util.CollectionUtils;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -215,7 +218,14 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
 
     @Override
     public IPage<UserCourseRespDTO> userPaging(PagingReqDTO<UserCourseReqDTO> reqDTO) {
-        return baseMapper.userPaging(reqDTO.toPage(), reqDTO.getParams());
+        IPage<UserCourseRespDTO> page = baseMapper.userPaging(reqDTO.toPage(), reqDTO.getParams());
+        Map<String, UserCourseProcessDTO> map = baseMapper.userPagingToal(reqDTO.toPage(), reqDTO.getParams()).stream().collect(Collectors.toMap(UserCourseProcessDTO::getId, userCourseProcessDTO -> userCourseProcessDTO));
+        page.getRecords().stream().forEach(i->{
+            i.setNeedLearnCount(map.get(i.getId()).getNeedLearn());
+            i.setLearnMinCount(map.get(i.getId()).getLearnMin());
+            i.setProportion(map.get(i.getId()).getProportion());
+        });
+        return page;
     }
 
     @Override

+ 1 - 1
exam-06173-api/src/main/resources/mapper/course/CourseMapper.xml

@@ -127,7 +127,7 @@
 
     </select>
 
-    <select id="userPagingToal" resultType="com.yf.exam.modules.course.dto.response.UserCourseProcessDTO">
+    <select id="userPagingToal" resultType="com.gyee.exam.modules.course.dto.response.UserCourseProcessDTO">
 
         SELECT
         cs.id,