mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-11 20:06:51 +08:00
feat:评估学习记录、报名记录查询修改为以报名方式筛选、6类课件学习记录增加content_type字段
This commit is contained in:
@@ -79,6 +79,9 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
@Autowired
|
||||
IStudyHomeWorkService studyHomeWorkService;
|
||||
|
||||
@Autowired
|
||||
IStudyAssessService assessService;
|
||||
|
||||
@Resource
|
||||
private ThirdApi thirdApi;
|
||||
|
||||
@@ -1268,7 +1271,50 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* 资源学习情况分页查询-评估信息
|
||||
* 此接口只查询评估信息
|
||||
*
|
||||
* @param pager 分页参数
|
||||
* @param courseId 课程id
|
||||
* @param contentId 内容id
|
||||
* @param name 用户名称
|
||||
* @param status 用户学习状态(1-未开始,2-已完成,3-进行中)
|
||||
* @return 资源学习情况分页集合
|
||||
*/
|
||||
@RequestMapping(value = "/contents-assess", method = {RequestMethod.GET, RequestMethod.POST})
|
||||
public JsonResponse<PageList<StudyCourseItem>> findPageAssess(Pagination pager, String courseId, String contentId, String name, Integer status) {
|
||||
if (StringUtils.isBlank(courseId)) {
|
||||
return error("无课程信息");
|
||||
}
|
||||
if (StringUtils.isBlank(contentId)) {
|
||||
return error("无资源信息");
|
||||
}
|
||||
try {
|
||||
// 查询当前课程的评估信息
|
||||
List<StudyAssess> studyAssesses = assessService.getByCourseIdAndContentId(courseId, contentId);
|
||||
// 空值校验
|
||||
if (studyAssesses == null || studyAssesses.isEmpty()) {
|
||||
return success(new PageList<>());
|
||||
}
|
||||
// 分页查询资源学习信息(只查询有评估信息的部分)
|
||||
PageList<StudyCourseItem> rs = studyService.findItemPage(pager.getPageIndex(), pager.getPageSize(), null, contentId, courseId, name, status);
|
||||
// 拼接评估信息
|
||||
List<StudyCourseItem> studyCourseItems = rs.getList();
|
||||
if (studyCourseItems != null && !studyCourseItems.isEmpty() && !studyAssesses.isEmpty()) {
|
||||
for (StudyCourseItem studyCourseItem : studyCourseItems) {
|
||||
// 获取当前课程的评估信息
|
||||
studyCourseItem.setStudyAssesses(studyAssesses.stream().filter(studyAssess -> studyAssess.getStudyItemId().equals(studyCourseItem.getId())).collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
return success(rs);
|
||||
} catch (Exception e) {
|
||||
log.error("【资源学习情况分页查询-评估信息】错误:{}", e.getMessage());
|
||||
return error("查询失败", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 资源学习情况导出-考试信息
|
||||
* 导出单个考试信息
|
||||
*
|
||||
|
||||
@@ -1,20 +1,5 @@
|
||||
package com.xboe.school.study.api;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.xboe.common.OrderCondition;
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.common.Pagination;
|
||||
@@ -26,8 +11,16 @@ import com.xboe.core.api.ApiBaseController;
|
||||
import com.xboe.school.study.dto.BatchSignup;
|
||||
import com.xboe.school.study.entity.StudySignup;
|
||||
import com.xboe.school.study.service.IStudySignupService;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 课程报名, 本控制器只有一个报名处理,没有其它的处理
|
||||
@@ -63,17 +56,24 @@ public class StudySignupApi extends ApiBaseController{
|
||||
return error("报名失败,请与管理员联系",e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询报名人员
|
||||
* @param pager 分页
|
||||
* @param courseId 课程id
|
||||
* @param name 姓名
|
||||
* @param signType 报名方式
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/pagelist")
|
||||
public JsonResponse<PageList<StudySignup>> findPage(Pagination pager,String courseId,String name,Integer status){
|
||||
public JsonResponse<PageList<StudySignup>> findPage(Pagination pager, String courseId, String name, Integer signType) {
|
||||
// if(StringUtils.isBlank(courseId)){
|
||||
// return error("无课程信息");
|
||||
// }
|
||||
StudySignup ss=new StudySignup();
|
||||
ss.setCourseId(courseId);
|
||||
ss.setName(name);
|
||||
ss.setStatus(status);
|
||||
|
||||
//2025.11.28 新增signType筛选
|
||||
ss.setSignType(signType);
|
||||
//CurrentUser cuser=getCurrent();
|
||||
try {
|
||||
PageList<StudySignup> list =signupService.findPage(pager.getPageIndex(),pager.getPageSize(), ss, OrderCondition.desc("id"));
|
||||
|
||||
@@ -11,16 +11,28 @@ import java.util.List;
|
||||
|
||||
@Repository
|
||||
public class CourseStatDao extends BaseDao<StudyCourse> {
|
||||
// 查当前页DTO列表(参数:偏移量、每页条数、courseId)
|
||||
|
||||
/**
|
||||
* 查询课程完成人数
|
||||
*
|
||||
* @param startIndex 分页开始索引
|
||||
* @param pageSize 分页大小
|
||||
* @param courseId 课程ID
|
||||
* @return 课程完成人数统计DTO集合
|
||||
*/
|
||||
public List<CourseFinishCountDto> findFinishCountPage(int startIndex, int pageSize, String courseId) {
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.append("SELECT ")
|
||||
// 课程名(和DTO字段对应)
|
||||
.append("c.content_name AS contentName, ")
|
||||
// 完成人数(去重统计)
|
||||
.append("COUNT(DISTINCT c.aid) AS finishCount ")
|
||||
// 你的课程表名(必改!)
|
||||
.append("COUNT(DISTINCT c.aid) AS finishCount, ")
|
||||
//2025.11.27新增:资源类型
|
||||
.append("cc.content_type AS contentType ")
|
||||
// 你的课程表名
|
||||
.append("FROM boe_study_course_item c ")
|
||||
// 2025.11.27新增:连表 boe_course_content
|
||||
.append("LEFT JOIN boe_course_content cc ON cc.id = c.content_id ")
|
||||
.append("WHERE 1=1 ")
|
||||
// 条件:已完成
|
||||
.append("AND c.status = 9 ");
|
||||
@@ -31,9 +43,10 @@ public class CourseStatDao extends BaseDao<StudyCourse> {
|
||||
params.add(courseId);
|
||||
}
|
||||
// 分组+排序+分页(聚合函数必须分组,排序参考第一个代码的desc id)
|
||||
sql.append("GROUP BY c.content_id, c.content_name ")
|
||||
sql.append("GROUP BY c.content_id, c.content_name, cc.content_type ")
|
||||
.append("ORDER BY c.content_id DESC ")
|
||||
.append("LIMIT ?, ?"); // MySQL分页:偏移量,每页条数
|
||||
// MySQL分页:偏移量,每页条数
|
||||
.append("LIMIT ?, ?");
|
||||
// 补充分页参数(顺序:startIndex → pageSize)
|
||||
params.add(startIndex);
|
||||
params.add(pageSize);
|
||||
@@ -45,6 +58,7 @@ public class CourseStatDao extends BaseDao<StudyCourse> {
|
||||
CourseFinishCountDto dto = new CourseFinishCountDto();
|
||||
dto.setContentName(objs[0] != null ? (String) objs[0] : "");
|
||||
dto.setFinishCount(objs[1] != null ? ((Number) objs[1]).intValue() : 0);
|
||||
dto.setContentType((Integer) objs[2]);
|
||||
dtoList.add(dto);
|
||||
}
|
||||
return dtoList;
|
||||
@@ -54,7 +68,7 @@ public class CourseStatDao extends BaseDao<StudyCourse> {
|
||||
public int findFinishCountTotal(String courseId) {
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.append("SELECT ")
|
||||
// 总条数=去重后的人数(和GROUP BY对应)
|
||||
// 总条数=去重后的人数
|
||||
.append("COUNT(DISTINCT c.content_id) ")
|
||||
.append("FROM boe_study_course_item c ")
|
||||
.append("WHERE 1=1 ")
|
||||
|
||||
@@ -2,6 +2,9 @@ package com.xboe.school.study.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 课程完成人数统计DTO
|
||||
*/
|
||||
@Data
|
||||
public class CourseFinishCountDto {
|
||||
|
||||
@@ -15,4 +18,10 @@ public class CourseFinishCountDto {
|
||||
*/
|
||||
private Integer finishCount;
|
||||
|
||||
/**
|
||||
* 内容类型
|
||||
* 枚举值参考BoedxContentType
|
||||
*/
|
||||
private Integer contentType;
|
||||
|
||||
}
|
||||
|
||||
@@ -144,4 +144,12 @@ public class StudyCourseItem extends IdEntity {
|
||||
*/
|
||||
@Transient
|
||||
private List<StudyExam> studyExams;
|
||||
|
||||
/**
|
||||
* 评估记录集合
|
||||
* 仅在资源学习情况分页查询-评估信息接口使用
|
||||
* 25.11.28新增
|
||||
*/
|
||||
@Transient
|
||||
private List<StudyAssess> studyAssesses;
|
||||
}
|
||||
|
||||
@@ -28,4 +28,13 @@ public interface IStudyAssessService {
|
||||
* @return
|
||||
*/
|
||||
List<StudyAssess> getByStudyIdAndContentId(String studyId,String contentId);
|
||||
|
||||
/**
|
||||
* 根据课程id和内容id得到评估的内容
|
||||
* @param courseId 课程id
|
||||
* @param contentId 内容
|
||||
* @return
|
||||
*/
|
||||
List<StudyAssess> getByCourseIdAndContentId(String courseId,String contentId);
|
||||
|
||||
}
|
||||
|
||||
@@ -86,4 +86,15 @@ public class StudyAssessServiceImpl implements IStudyAssessService{
|
||||
return dao.findList(FieldFilters.eq("studyId", studyId),FieldFilters.eq("contentId", contentId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据课程id和内容id得到评估的内容
|
||||
* @param courseId 课程id
|
||||
* @param contentId 内容
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<StudyAssess> getByCourseIdAndContentId(String courseId,String contentId){
|
||||
return dao.findList(FieldFilters.eq("courseId", courseId),FieldFilters.eq("contentId", contentId));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user