From 0663d443839cafddd90c39f3f91355aa5a44e2cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=80=BB=E8=A3=81?= <14186472+wenyu441069198@user.noreply.gitee.com> Date: Sat, 17 Aug 2024 17:23:12 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E8=82=96=E6=B5=B7=E5=8D=97=E4=B8=AA?= =?UTF-8?q?=E4=BA=BA=E4=B8=AD=E5=BF=83=E8=AF=BE=E7=A8=8B=E6=8E=A8=E8=8D=90?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CourseLearningRecordController.java | 3 --- .../KnowledgeLearningRecordController.java | 11 +++++++++ .../records/CourseLearningRecordMapper.java | 2 +- .../entity/umsAdmin/AdminUserDetails.java | 2 +- .../CourseLearningRecordServiceImpl.java | 23 ++++++++----------- .../KnowledgeLearningRecordServiceImpl.java | 21 +++++++++++++++++ .../umsAdmin/UmsStudentManageServiceImpl.java | 15 ++++++------ .../impl/umsAdmin/UmsUserServiceImpl.java | 2 +- .../IKnowledgeLearningRecordService.java | 3 +++ .../mapper/CourseLearningRecordMapper.xml | 4 +++- 10 files changed, 59 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/teaching/backend/controller/records/CourseLearningRecordController.java b/src/main/java/com/teaching/backend/controller/records/CourseLearningRecordController.java index 32be4d1..f9ad0f0 100644 --- a/src/main/java/com/teaching/backend/controller/records/CourseLearningRecordController.java +++ b/src/main/java/com/teaching/backend/controller/records/CourseLearningRecordController.java @@ -79,9 +79,6 @@ public class CourseLearningRecordController { @PostMapping("/recommendCourses") public CommonResult> recommendCourses(@RequestParam String userId) { List coursesVOList = courseLearningRecordService.queryrecommendCourses(userId); - if (coursesVOList == null){ - CommonResult.failed("用户或角色错误"); - } return CommonResult.success(coursesVOList); } diff --git a/src/main/java/com/teaching/backend/controller/records/KnowledgeLearningRecordController.java b/src/main/java/com/teaching/backend/controller/records/KnowledgeLearningRecordController.java index f723a2d..8c132cb 100644 --- a/src/main/java/com/teaching/backend/controller/records/KnowledgeLearningRecordController.java +++ b/src/main/java/com/teaching/backend/controller/records/KnowledgeLearningRecordController.java @@ -8,6 +8,7 @@ import com.teaching.backend.filter.ValidateParams; import com.teaching.backend.mapper.records.KnowledgeLearningRecordMapper; import com.teaching.backend.model.entity.records.CourseLearningRecord; import com.teaching.backend.model.entity.records.KnowledgeLearningRecord; +import com.teaching.backend.model.vo.courses.CoursesVO; import com.teaching.backend.model.vo.knowGraph.KnowVO; import com.teaching.backend.service.impl.records.KnowledgeLearningRecordServiceImpl; import io.swagger.annotations.ApiOperation; @@ -84,5 +85,15 @@ public class KnowledgeLearningRecordController { return CommonResult.success(knowVO); } + /** + * 推荐知识点 + * @return + */ + @ApiOperation("推荐知识点") + @PostMapping("/recommendKnowledge") + public CommonResult> recommendCourses(@RequestParam String userId) { + List coursesVOList = knowledgeLearningRecordService.queryRecommendKnowledge(userId); + return CommonResult.success(coursesVOList); + } } diff --git a/src/main/java/com/teaching/backend/mapper/records/CourseLearningRecordMapper.java b/src/main/java/com/teaching/backend/mapper/records/CourseLearningRecordMapper.java index 602a416..56fd7d9 100644 --- a/src/main/java/com/teaching/backend/mapper/records/CourseLearningRecordMapper.java +++ b/src/main/java/com/teaching/backend/mapper/records/CourseLearningRecordMapper.java @@ -18,7 +18,7 @@ public interface CourseLearningRecordMapper extends BaseMapper selectMaxNumber(); + List selectMaxNumber(String userId); List selectMaxCourseId(String userId); } diff --git a/src/main/java/com/teaching/backend/model/entity/umsAdmin/AdminUserDetails.java b/src/main/java/com/teaching/backend/model/entity/umsAdmin/AdminUserDetails.java index ffb8ff4..a244453 100644 --- a/src/main/java/com/teaching/backend/model/entity/umsAdmin/AdminUserDetails.java +++ b/src/main/java/com/teaching/backend/model/entity/umsAdmin/AdminUserDetails.java @@ -59,6 +59,6 @@ public class AdminUserDetails implements UserDetails { @Override public boolean isEnabled() { - return umsAdmin.getStatus().equals(1); + return umsAdmin.getStatus().equals("1"); } } diff --git a/src/main/java/com/teaching/backend/service/impl/records/CourseLearningRecordServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/records/CourseLearningRecordServiceImpl.java index 1193803..017d625 100644 --- a/src/main/java/com/teaching/backend/service/impl/records/CourseLearningRecordServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/records/CourseLearningRecordServiceImpl.java @@ -127,7 +127,7 @@ public class CourseLearningRecordServiceImpl extends ServiceImpl coursesList = new ArrayList<>(); if (roleId.equals("1")){ - List courseIds = courseLearningRecordMapper.selectMaxNumber(); + List courseIds = courseLearningRecordMapper.selectMaxNumber(userId); for (String courseId : courseIds) { Courses courses = coursesMapper.selectById(courseId); coursesList.add(courses); @@ -149,18 +149,15 @@ public class CourseLearningRecordServiceImpl extends ServiceImpl queryrecommendCourses(String userId) { - String roleId = umsUserMapper.getByIdRoleId(userId); - - if (roleId.equals("1")) { - - return null; - } else if (roleId.equals("2")) { - - return null; - }else { - - return null; + List coursesList = new ArrayList<>(); + List courseIds = courseLearningRecordMapper.selectMaxNumber(userId); + for (String courseId : courseIds) { + Courses courses = coursesMapper.selectById(courseId); + if (courses != null){ + coursesList.add(courses); + } } + List coursesVOList = BeanUtil.copyToList(coursesList, CoursesVO.class); + return coursesVOList; } - } diff --git a/src/main/java/com/teaching/backend/service/impl/records/KnowledgeLearningRecordServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/records/KnowledgeLearningRecordServiceImpl.java index c392c53..5e673eb 100644 --- a/src/main/java/com/teaching/backend/service/impl/records/KnowledgeLearningRecordServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/records/KnowledgeLearningRecordServiceImpl.java @@ -171,4 +171,25 @@ public class KnowledgeLearningRecordServiceImpl extends ServiceImpl queryRecommendKnowledge(String userId) { + + List coursesList = new ArrayList<>(); + + KnowVO knowVO = null; + + List knowledgeIdList = knowledgeLearningRecordMapper.queryStudyKnowledgeMaxNumber(); + for (String knowledgeId : knowledgeIdList) { + BaseResponse knowledge = knowtmpService.query(Long.valueOf(knowledgeId)); + if (knowledge.getData() != null) { + knowVO = new KnowVO(); + knowVO.setId(knowledge.getData().getId()); + knowVO.setLabel(knowledge.getData().getName()); + knowVO.setColor(knowledge.getData().getInfo()); + coursesList.add(knowVO); + } + } + return coursesList; + } + } diff --git a/src/main/java/com/teaching/backend/service/impl/umsAdmin/UmsStudentManageServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/umsAdmin/UmsStudentManageServiceImpl.java index a865c84..c8b5c32 100644 --- a/src/main/java/com/teaching/backend/service/impl/umsAdmin/UmsStudentManageServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/umsAdmin/UmsStudentManageServiceImpl.java @@ -124,13 +124,14 @@ public class UmsStudentManageServiceImpl extends ServiceImpl impl if(!passwordEncoder.matches(password,userDetails.getPassword())){ throw new BusinessException(400,"密码错误"); } - if(userDetails.isEnabled()){ + if(!userDetails.isEnabled()){ throw new BusinessException(400,"帐号已被禁用"); } UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities()); diff --git a/src/main/java/com/teaching/backend/service/records/IKnowledgeLearningRecordService.java b/src/main/java/com/teaching/backend/service/records/IKnowledgeLearningRecordService.java index 4e320e0..a90f9c4 100644 --- a/src/main/java/com/teaching/backend/service/records/IKnowledgeLearningRecordService.java +++ b/src/main/java/com/teaching/backend/service/records/IKnowledgeLearningRecordService.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import com.teaching.backend.common.BaseResponse; import com.teaching.backend.model.entity.records.KnowledgeLearningRecord; +import com.teaching.backend.model.vo.courses.CoursesVO; import io.swagger.models.auth.In; import com.teaching.backend.model.vo.knowGraph.KnowVO; @@ -28,5 +29,7 @@ public interface IKnowledgeLearningRecordService extends IService queryMaxKnowledge(String userId); + + List queryRecommendKnowledge(String userId); } diff --git a/src/main/resources/mapper/CourseLearningRecordMapper.xml b/src/main/resources/mapper/CourseLearningRecordMapper.xml index d117fc7..7ec9971 100644 --- a/src/main/resources/mapper/CourseLearningRecordMapper.xml +++ b/src/main/resources/mapper/CourseLearningRecordMapper.xml @@ -12,11 +12,13 @@ times DESC LIMIT 1; - SELECT cln.course_id courseId FROM course_learning_number cln + WHERE + CONCAT(',', cln.teacher_user_id, ',') LIKE CONCAT('%,', #{userId}, ',%') ORDER BY number DESC; From c3bf152cb087bf3219b12700d990937787663d38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=80=BB=E8=A3=81?= <14186472+wenyu441069198@user.noreply.gitee.com> Date: Sat, 17 Aug 2024 17:44:37 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E8=82=96=E6=B5=B7=E5=8D=97DOT=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E7=B1=BB=E5=9E=8B=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/model/dto/umsAdmin/UmsStudentAndTeacherDTO.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/teaching/backend/model/dto/umsAdmin/UmsStudentAndTeacherDTO.java b/src/main/java/com/teaching/backend/model/dto/umsAdmin/UmsStudentAndTeacherDTO.java index 42011e6..b5089c6 100644 --- a/src/main/java/com/teaching/backend/model/dto/umsAdmin/UmsStudentAndTeacherDTO.java +++ b/src/main/java/com/teaching/backend/model/dto/umsAdmin/UmsStudentAndTeacherDTO.java @@ -10,6 +10,7 @@ import lombok.experimental.Accessors; import java.io.Serializable; import java.time.LocalDate; import java.time.LocalDateTime; +import java.util.List; /** *

@@ -122,5 +123,5 @@ public class UmsStudentAndTeacherDTO implements Serializable { /** * role_id */ - private Integer roleId; + private List roleId; } From 5c9061d8dffc0288b62310ccc015e024ac9e9a00 Mon Sep 17 00:00:00 2001 From: Alan <3052806735@qq.com> Date: Mon, 19 Aug 2024 21:50:09 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=80=BB=E7=9B=AE?= =?UTF-8?q?=E6=A0=87/=E6=80=9D=E6=94=BF=E7=9B=AE=E6=A0=87=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E9=80=BB=E8=BE=91=E4=BC=98=E5=8C=96=EF=BC=88=E5=8F=AA?= =?UTF-8?q?=E8=83=BD=E5=A1=AB=E4=B8=80=E4=B8=AA=E5=86=85=E5=AE=B9=EF=BC=89?= =?UTF-8?q?=20=E4=BF=AE=E6=94=B9=E7=9F=A5=E8=AF=86=E7=82=B9--=E5=85=B3?= =?UTF-8?q?=E8=81=94=E7=9B=AE=E6=A0=87=E5=86=85=E5=AE=B9=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=20=E4=BF=AE=E6=94=B9=E7=9B=AE=E6=A0=87=E5=86=85=E5=AE=B9--?= =?UTF-8?q?=E7=9F=A5=E8=AF=86=E7=82=B9=20=20=E6=95=B0=E6=8D=AE=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E6=8E=A5=E5=8F=A3=EF=BC=8C=E7=8E=B0=E5=9C=A8=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E6=8B=BF=E5=88=B0=E7=9F=A5=E8=AF=86=E7=82=B9=E4=B8=AA?= =?UTF-8?q?=E6=95=B0=EF=BC=8C=E6=80=BB=E5=AD=A6=E6=97=B6=EF=BC=8C=E5=8D=A0?= =?UTF-8?q?=E6=AF=94=EF=BC=8C=E4=BB=A5=E5=8F=8A=E7=9B=B8=E5=85=B3=E7=9F=A5?= =?UTF-8?q?=E8=AF=86=E7=82=B9=E7=9A=84=E8=AF=A6=E7=BB=86=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=EF=BC=88id=EF=BC=8Cname=EF=BC=8C=E5=AD=A6=E6=97=B6=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../teaching/backend/common/ErrorCode.java | 2 +- .../courses/CourseObjectivesController.java | 8 + .../ObjectiveContentKnowController.java | 8 +- .../courses/ObjectiveContentsController.java | 4 +- .../dto/courses/ObjectiveContentKnowDTO.java | 2 +- .../entity/courses/ObjectiveContentKnow.java | 6 +- .../entity/courses/ObjectiveContents.java | 4 +- .../backend/model/entity/knowtmp/Knowtmp.java | 1 - .../model/vo/courses/CourseObjectivesVO.java | 23 +++ .../vo/courses/ObjectiveContentKnowVO.java | 11 +- .../backend/model/vo/knowtmp/KnowTmpVO.java | 29 +++ .../courses/ICourseObjectivesService.java | 3 + .../courses/IObjectiveContentKnowService.java | 2 +- .../courses/IObjectiveContentsService.java | 2 + .../courses/CourseObjectivesServiceImpl.java | 34 +++- .../impl/courses/CoursesServiceImpl.java | 2 +- .../ObjectiveContentKnowServiceImpl.java | 168 +++++++++--------- .../courses/ObjectiveContentsServiceImpl.java | 34 +++- 18 files changed, 233 insertions(+), 110 deletions(-) create mode 100644 src/main/java/com/teaching/backend/model/vo/courses/CourseObjectivesVO.java create mode 100644 src/main/java/com/teaching/backend/model/vo/knowtmp/KnowTmpVO.java diff --git a/src/main/java/com/teaching/backend/common/ErrorCode.java b/src/main/java/com/teaching/backend/common/ErrorCode.java index 041682c..a67b684 100644 --- a/src/main/java/com/teaching/backend/common/ErrorCode.java +++ b/src/main/java/com/teaching/backend/common/ErrorCode.java @@ -10,7 +10,7 @@ public enum ErrorCode { SUCCESS(200, "ok"), PARAMS_ERROR(40000, "请求参数错误"), - OBJECTIVE_OR_CONTENT_NOT_EXIT(40001, "目标或内容id不存在"), + OBJECTIVE_CONTENT_NOT_EXIT(40001, "目标内容不存在"), KONWID_NOT_EXIT(40002, "没有选择知识点"), OBJECTIVE_OR_CONTENT_EXIT(40003, "该记录已存在"), KNOW_NOT_EXIT(40004, "知识点不存在"), diff --git a/src/main/java/com/teaching/backend/controller/courses/CourseObjectivesController.java b/src/main/java/com/teaching/backend/controller/courses/CourseObjectivesController.java index c6ca203..3383eff 100644 --- a/src/main/java/com/teaching/backend/controller/courses/CourseObjectivesController.java +++ b/src/main/java/com/teaching/backend/controller/courses/CourseObjectivesController.java @@ -9,6 +9,7 @@ import com.teaching.backend.mapper.courses.CourseObjectivesMapper; import com.teaching.backend.model.dto.courses.CourseObjectivesDTO; import com.teaching.backend.model.entity.courses.CourseObjectives; import com.teaching.backend.model.vo.courses.CourseObjectivesTreeVO; +import com.teaching.backend.model.vo.courses.CourseObjectivesVO; import com.teaching.backend.service.courses.ICourseObjectivesService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -76,5 +77,12 @@ public class CourseObjectivesController { return ResultUtils.success(courseObjectivesTreeVO); } + @ApiOperation("列表显示分项目标(用于添加目标内容时选择)") + @GetMapping("/objectiveslist/{courseId}") + public BaseResponse> queryCourseObjectivesForAdd(@PathVariable String courseId){ + List courseObjectivesVOS = courseObjectivesService.queryCourseObjectivesForAdd(courseId); + return ResultUtils.success(courseObjectivesVOS); + } + } diff --git a/src/main/java/com/teaching/backend/controller/courses/ObjectiveContentKnowController.java b/src/main/java/com/teaching/backend/controller/courses/ObjectiveContentKnowController.java index d3fc4d7..bd3497b 100644 --- a/src/main/java/com/teaching/backend/controller/courses/ObjectiveContentKnowController.java +++ b/src/main/java/com/teaching/backend/controller/courses/ObjectiveContentKnowController.java @@ -31,11 +31,11 @@ public class ObjectiveContentKnowController { IObjectiveContentKnowService objectiveContentKnowService; - @ApiOperation("给分项目标或者是内容添加知识点") -// @ValidateParams({"objectiveId","know"}) + @ApiOperation("给知识点关联--目标内容") + @ValidateParams({"objectiveContentId","knowId"}) @PostMapping("/addknows") - public BaseResponse saveKnowsWithObjectiveOrContent(@RequestBody ObjectiveContentKnowDTO objectiveContentKnowDTO){ - String data = objectiveContentKnowService.saveKnowsWithObjectiveOrContent(objectiveContentKnowDTO); + public BaseResponse saveKnowsWithObjectiveContent(@RequestBody ObjectiveContentKnowDTO objectiveContentKnowDTO){ + String data = objectiveContentKnowService.saveKnowsWithObjectiveContent(objectiveContentKnowDTO); return ResultUtils.success(data); } diff --git a/src/main/java/com/teaching/backend/controller/courses/ObjectiveContentsController.java b/src/main/java/com/teaching/backend/controller/courses/ObjectiveContentsController.java index cbe1c5e..b18112f 100644 --- a/src/main/java/com/teaching/backend/controller/courses/ObjectiveContentsController.java +++ b/src/main/java/com/teaching/backend/controller/courses/ObjectiveContentsController.java @@ -31,8 +31,8 @@ public class ObjectiveContentsController { @ValidateParams({"objectiveId"}) @PostMapping("/addcontent") public BaseResponse saveContent(@RequestBody ObjectiveContents objectiveContents){ - objectiveContentsService.save(objectiveContents); - return ResultUtils.success("添加成功"); + String data = objectiveContentsService.saveWithCheck(objectiveContents); + return ResultUtils.success(data); } @ApiOperation("删除目标内容") diff --git a/src/main/java/com/teaching/backend/model/dto/courses/ObjectiveContentKnowDTO.java b/src/main/java/com/teaching/backend/model/dto/courses/ObjectiveContentKnowDTO.java index f0eb4ef..fd46c10 100644 --- a/src/main/java/com/teaching/backend/model/dto/courses/ObjectiveContentKnowDTO.java +++ b/src/main/java/com/teaching/backend/model/dto/courses/ObjectiveContentKnowDTO.java @@ -20,7 +20,7 @@ import java.io.Serializable; * @since 2024-06-13 */ @Data -@ApiModel(description = "分项目标或内容添加知识点") +@ApiModel(description = "目标内容添加知识点") public class ObjectiveContentKnowDTO extends ObjectiveContentKnow { } diff --git a/src/main/java/com/teaching/backend/model/entity/courses/ObjectiveContentKnow.java b/src/main/java/com/teaching/backend/model/entity/courses/ObjectiveContentKnow.java index fb91204..023b03b 100644 --- a/src/main/java/com/teaching/backend/model/entity/courses/ObjectiveContentKnow.java +++ b/src/main/java/com/teaching/backend/model/entity/courses/ObjectiveContentKnow.java @@ -38,12 +38,14 @@ public class ObjectiveContentKnow implements Serializable { /** * 分项目标或内容 的 id */ - private String objectiveOrContent; +// private String objectiveOrContent; + private String objectiveContentId; /** * 关联的知识点 */ - private String know; +// private String know; + private Integer knowId; } diff --git a/src/main/java/com/teaching/backend/model/entity/courses/ObjectiveContents.java b/src/main/java/com/teaching/backend/model/entity/courses/ObjectiveContents.java index 8ccd7ef..ab1a339 100644 --- a/src/main/java/com/teaching/backend/model/entity/courses/ObjectiveContents.java +++ b/src/main/java/com/teaching/backend/model/entity/courses/ObjectiveContents.java @@ -36,8 +36,6 @@ public class ObjectiveContents implements Serializable { @ApiModelProperty(value = "内容",required = true) private String content; - @ApiModelProperty(value = "排序字段",required = true) + @ApiModelProperty(value = "排序字段") private Float orderNum; - - } diff --git a/src/main/java/com/teaching/backend/model/entity/knowtmp/Knowtmp.java b/src/main/java/com/teaching/backend/model/entity/knowtmp/Knowtmp.java index 978d8e4..1e3a0ab 100644 --- a/src/main/java/com/teaching/backend/model/entity/knowtmp/Knowtmp.java +++ b/src/main/java/com/teaching/backend/model/entity/knowtmp/Knowtmp.java @@ -36,5 +36,4 @@ public class Knowtmp implements Serializable { private double hour; - } diff --git a/src/main/java/com/teaching/backend/model/vo/courses/CourseObjectivesVO.java b/src/main/java/com/teaching/backend/model/vo/courses/CourseObjectivesVO.java new file mode 100644 index 0000000..4647a83 --- /dev/null +++ b/src/main/java/com/teaching/backend/model/vo/courses/CourseObjectivesVO.java @@ -0,0 +1,23 @@ +package com.teaching.backend.model.vo.courses; + +import com.teaching.backend.model.entity.courses.CourseObjectives; +import com.teaching.backend.model.entity.courses.ObjectiveContents; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +@Data +@ApiModel(description = "课程目标详情(简略)") +public class CourseObjectivesVO implements Serializable { + + @ApiModelProperty(value = "目标id") + private String id; + + @ApiModelProperty(value = "目标名称") + private String name; + + +} diff --git a/src/main/java/com/teaching/backend/model/vo/courses/ObjectiveContentKnowVO.java b/src/main/java/com/teaching/backend/model/vo/courses/ObjectiveContentKnowVO.java index d3b6a35..0460cd4 100644 --- a/src/main/java/com/teaching/backend/model/vo/courses/ObjectiveContentKnowVO.java +++ b/src/main/java/com/teaching/backend/model/vo/courses/ObjectiveContentKnowVO.java @@ -1,5 +1,6 @@ package com.teaching.backend.model.vo.courses; +import com.teaching.backend.model.vo.knowtmp.KnowTmpVO; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -12,7 +13,7 @@ import java.util.List; public class ObjectiveContentKnowVO { /** - * 分项目标或内容 的 id + * 目标内容 的 id */ private String objectiveOrContent; @@ -26,17 +27,17 @@ public class ObjectiveContentKnowVO { * 关联的知识点学时合计 */ @ApiModelProperty(value = "关联的知识点学时合计") - private BigDecimal knowsTime; + private Double knowsTime; /** * 关联的知识点学时占比 */ @ApiModelProperty(value = "关联的知识点学时占比") - private String persent; + private Double persent; /** - * 分项目标下面的内容对应的知识点数据 + * 知识点的展示数据 */ - List contentKnowsData; + List knowTmpVOList; } diff --git a/src/main/java/com/teaching/backend/model/vo/knowtmp/KnowTmpVO.java b/src/main/java/com/teaching/backend/model/vo/knowtmp/KnowTmpVO.java new file mode 100644 index 0000000..b0aaab0 --- /dev/null +++ b/src/main/java/com/teaching/backend/model/vo/knowtmp/KnowTmpVO.java @@ -0,0 +1,29 @@ +package com.teaching.backend.model.vo.knowtmp; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +/** + *

+ * + *

+ * + * @author author + * @since 2024-05-31 + */ +@Data +@TableName(value = "knowtmp") +public class KnowTmpVO implements Serializable { + + private Long id; + + private String name; + + private double hour; + +} diff --git a/src/main/java/com/teaching/backend/service/courses/ICourseObjectivesService.java b/src/main/java/com/teaching/backend/service/courses/ICourseObjectivesService.java index 3d3c753..55c1783 100644 --- a/src/main/java/com/teaching/backend/service/courses/ICourseObjectivesService.java +++ b/src/main/java/com/teaching/backend/service/courses/ICourseObjectivesService.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.teaching.backend.model.dto.courses.CourseObjectivesDTO; import com.teaching.backend.model.entity.courses.CourseObjectives; import com.teaching.backend.model.vo.courses.CourseObjectivesTreeVO; +import com.teaching.backend.model.vo.courses.CourseObjectivesVO; import java.util.List; @@ -37,4 +38,6 @@ public interface ICourseObjectivesService extends IService { * @return */ List queryCourseObjectivesTree(String id); + + List queryCourseObjectivesForAdd(String courseId); } diff --git a/src/main/java/com/teaching/backend/service/courses/IObjectiveContentKnowService.java b/src/main/java/com/teaching/backend/service/courses/IObjectiveContentKnowService.java index 18c2809..b6b1207 100644 --- a/src/main/java/com/teaching/backend/service/courses/IObjectiveContentKnowService.java +++ b/src/main/java/com/teaching/backend/service/courses/IObjectiveContentKnowService.java @@ -15,7 +15,7 @@ import com.teaching.backend.model.vo.courses.ObjectiveContentKnowVO; */ public interface IObjectiveContentKnowService extends IService { - String saveKnowsWithObjectiveOrContent(ObjectiveContentKnowDTO objectiveContentKnowDTO); + String saveKnowsWithObjectiveContent(ObjectiveContentKnowDTO objectiveContentKnowDTO); ObjectiveContentKnowVO getCountData(String objectiveId); } diff --git a/src/main/java/com/teaching/backend/service/courses/IObjectiveContentsService.java b/src/main/java/com/teaching/backend/service/courses/IObjectiveContentsService.java index b031659..b1f3c7c 100644 --- a/src/main/java/com/teaching/backend/service/courses/IObjectiveContentsService.java +++ b/src/main/java/com/teaching/backend/service/courses/IObjectiveContentsService.java @@ -16,4 +16,6 @@ public interface IObjectiveContentsService extends IService { String deleteById(String id); + + String saveWithCheck(ObjectiveContents objectiveContents); } diff --git a/src/main/java/com/teaching/backend/service/impl/courses/CourseObjectivesServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/courses/CourseObjectivesServiceImpl.java index 435f710..1ce4255 100644 --- a/src/main/java/com/teaching/backend/service/impl/courses/CourseObjectivesServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/courses/CourseObjectivesServiceImpl.java @@ -14,8 +14,10 @@ import com.teaching.backend.model.entity.courses.CourseObjectives; import com.teaching.backend.model.entity.courses.ObjectiveContentKnow; import com.teaching.backend.model.entity.courses.ObjectiveContents; import com.teaching.backend.model.vo.courses.CourseObjectivesTreeVO; +import com.teaching.backend.model.vo.courses.CourseObjectivesVO; import com.teaching.backend.service.courses.ICourseObjectivesService; import com.teaching.backend.utils.CourseCode; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -26,6 +28,7 @@ import java.util.List; import java.util.Map; import static com.teaching.backend.utils.CourseCode.TOTAL_OBJECTIVE_HAS_NO_CHILD; +import static com.teaching.backend.utils.CourseCode.TOTAL_OBJECTIVE_TYPE; /** *

@@ -36,6 +39,7 @@ import static com.teaching.backend.utils.CourseCode.TOTAL_OBJECTIVE_HAS_NO_CHILD * @since 2024-05-31 */ @Service +@Slf4j public class CourseObjectivesServiceImpl extends ServiceImpl implements ICourseObjectivesService { @@ -109,12 +113,12 @@ public class CourseObjectivesServiceImpl extends ServiceImpl() - .eq(ObjectiveContentKnow::getObjectiveOrContent, id)); + .eq(ObjectiveContentKnow::getObjectiveContentId, id)); if(count > CourseCode.KNOWS_EXIT.getValue()){ throw new BusinessException(ErrorCode.KNOWS_EXIT); } @@ -204,6 +208,30 @@ public class CourseObjectivesServiceImpl extends ServiceImpl queryCourseObjectivesForAdd(String courseId) { + CourseObjectives courseObjectives = courseObjectivesMapper.selectOne(new LambdaQueryWrapper<>(CourseObjectives.class) + .eq(CourseObjectives::getCourseId, courseId)); + if (courseObjectives == null){ + log.error("课程相关数据不存在:{}",courseId); + throw new BusinessException(ErrorCode.NOT_FOUND_ERROR); + } + String courseTotalObjectiveId = courseObjectives.getId(); + List objectivesLists = courseObjectivesMapper.selectList(new LambdaQueryWrapper<>(CourseObjectives.class) + .eq(CourseObjectives::getPid, courseTotalObjectiveId) + .select(CourseObjectives::getId,CourseObjectives::getType) + .orderByAsc(CourseObjectives::getType) + ); + List courseObjectivesVOS = new ArrayList<>(objectivesLists.size()); + for (CourseObjectives objectives : objectivesLists) { + CourseObjectivesVO courseObjectivesVO = new CourseObjectivesVO(); + courseObjectivesVO.setId(objectives.getId()); + courseObjectivesVO.setName(objectivesTypeMapper.selectById(objectives.getType()).getTypeName()); + courseObjectivesVOS.add(courseObjectivesVO); + } + return courseObjectivesVOS; + } + // 获取目标的内容列表 private List fetchContentsForObjective(String objectiveId) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); 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 005414f..ee9f974 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 @@ -283,7 +283,7 @@ public class CoursesServiceImpl extends ServiceImpl impl contents+=content; Long know = objectiveContentKnowMapper.selectCount(new LambdaQueryWrapper() - .eq(ObjectiveContentKnow::getObjectiveOrContent, objectiveId)); + .eq(ObjectiveContentKnow::getObjectiveContentId, objectiveId)); knows+=know; } if(contents > 0){ diff --git a/src/main/java/com/teaching/backend/service/impl/courses/ObjectiveContentKnowServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/courses/ObjectiveContentKnowServiceImpl.java index 13720df..c1ee035 100644 --- a/src/main/java/com/teaching/backend/service/impl/courses/ObjectiveContentKnowServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/courses/ObjectiveContentKnowServiceImpl.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.teaching.backend.common.ErrorCode; import com.teaching.backend.exception.BusinessException; +import com.teaching.backend.mapper.Knowtemp.KnowtmpMapper; import com.teaching.backend.mapper.courses.CourseObjectivesMapper; import com.teaching.backend.mapper.courses.CoursesMapper; import com.teaching.backend.mapper.courses.ObjectiveContentKnowMapper; @@ -13,7 +14,9 @@ import com.teaching.backend.model.dto.courses.ObjectiveContentKnowDTO; import com.teaching.backend.model.entity.courses.CourseObjectives; import com.teaching.backend.model.entity.courses.ObjectiveContentKnow; import com.teaching.backend.model.entity.courses.ObjectiveContents; +import com.teaching.backend.model.entity.knowtmp.Knowtmp; import com.teaching.backend.model.vo.courses.ObjectiveContentKnowVO; +import com.teaching.backend.model.vo.knowtmp.KnowTmpVO; import com.teaching.backend.service.courses.IObjectiveContentKnowService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -40,8 +43,8 @@ public class ObjectiveContentKnowServiceImpl extends ServiceImpl knowIds = new ArrayList<>(Arrays.asList(knows.split(","))); - List objectiveContentKnowList = new ArrayList<>(); - for (String knowId : knowIds) { - ObjectiveContentKnow objectiveContentKnow = new ObjectiveContentKnow(); -// objectiveContentKnow.setId(snowflakeGenerator.next()); - objectiveContentKnow.setObjectiveOrContent(objectiveOrContent); - objectiveContentKnow.setKnow(knowId); - objectiveContentKnowList.add(objectiveContentKnow); - } - try { - objectiveContentKnowMapper.insertBatchSomeColumn(objectiveContentKnowList); - } catch (Exception e) { - e.printStackTrace(); - throw new BusinessException(ErrorCode.OBJECTIVE_OR_CONTENT_EXIT); +// String knows = objectiveContentKnowDTO.getKnow(); +// if (knows == null || knows.equals("")){ +// throw new BusinessException(ErrorCode.KONWID_NOT_EXIT); +// } +// List knowIds = new ArrayList<>(Arrays.asList(knows.split(","))); +// List objectiveContentKnowList = new ArrayList<>(); +// for (String knowId : knowIds) { +// ObjectiveContentKnow objectiveContentKnow = new ObjectiveContentKnow(); +//// objectiveContentKnow.setId(snowflakeGenerator.next()); +// objectiveContentKnow.setObjectiveOrContent(objectiveOrContent); +// objectiveContentKnow.setKnow(knowId); +// objectiveContentKnowList.add(objectiveContentKnow); +// } +// try { +// objectiveContentKnowMapper.insertBatchSomeColumn(objectiveContentKnowList); +// } catch (Exception e) { +// e.printStackTrace(); +// throw new BusinessException(ErrorCode.OBJECTIVE_OR_CONTENT_EXIT); +// } + + //添加逻辑变了 变成了给知识点添加关联的--课程目标 + ObjectiveContents objectiveContents = objectiveContentsMapper.selectById(objectiveContentKnowDTO.getObjectiveContentId()); + if (objectiveContents == null) { + throw new BusinessException(ErrorCode.OBJECTIVE_CONTENT_NOT_EXIT); } + int insert = objectiveContentKnowMapper.insert(objectiveContentKnowDTO); - return "添加成功"; + return insert > 0 ? "添加成功" : "添加失败"; } @Override - public ObjectiveContentKnowVO getCountData(String objectiveOrContentId) { - // 查询分项目标或者是下面的内容关联的知识点数据(按设计要求,这个传的就是分项目标的id) - List objectiveContentKnows = objectiveContentKnowMapper.selectList( - new LambdaQueryWrapper() - .eq(ObjectiveContentKnow::getObjectiveOrContent, objectiveOrContentId)); + public ObjectiveContentKnowVO getCountData(String objectiveContentId) { + // 创建ObjectiveContentKnowVO对象,用于存储和返回计算结果 + ObjectiveContentKnowVO objectiveContentKnowVO = new ObjectiveContentKnowVO(); - // 创建ObjectiveContentKnowVO对象,并计算相关数据 - ObjectiveContentKnowVO objectiveContentKnowVO = createObjectiveContentKnowVO(objectiveOrContentId, objectiveContentKnows); - - // 根据分项目标找到课程id + // 根据传入的目标内容ID找到课程ID和总学时 + String objectiveID = objectiveContentsMapper.selectOne(new LambdaQueryWrapper() + .eq(ObjectiveContents::getId, objectiveContentId)).getObjectiveId(); String pid = courseObjectivesMapper.selectOne(new LambdaQueryWrapper() - .eq(CourseObjectives::getId, objectiveOrContentId)).getPid(); + .eq(CourseObjectives::getId, objectiveID)).getPid(); String courseId = courseObjectivesMapper.selectOne(new LambdaQueryWrapper() - .eq(CourseObjectives::getId, pid)).getCourseId(); + .eq(CourseObjectives::getId, pid)).getCourseId(); Integer classhours = coursesMapper.selectById(courseId).getClasshours(); - // 计算并设置比例(百分比) -// BigDecimal percentage = calculatePercentage(objectiveContentKnowVO.getKnowsTime(), classhours); - -// objectiveContentKnowVO.setPersent(percentage + "%"); - - // 查找分项目标下的内容 - List objectiveContents = objectiveContentsMapper.selectList(new LambdaQueryWrapper() - .eq(ObjectiveContents::getObjectiveId, objectiveOrContentId)); + // 获取当前目标内容下关联的知识点数据 + List objectiveContentKnows = objectiveContentKnowMapper.selectList( + new LambdaQueryWrapper() + .eq(ObjectiveContentKnow::getObjectiveContentId, objectiveContentId) + ); - // 如果存在分项目标内容,处理并计算每个内容的相关数据 - if (!CollectionUtils.isEmpty(objectiveContents)) { - List contentKnowVOs = objectiveContents.stream() - .map(content -> createObjectiveContentKnowVO(content.getId(), objectiveContentKnowMapper.selectList( - new LambdaQueryWrapper() - .eq(ObjectiveContentKnow::getObjectiveOrContent, content.getId()) - ))) - .collect(Collectors.toList()); + // 创建并设置ObjectiveContentKnowVO对象的属性 + objectiveContentKnowVO = createObjectiveContentKnowVO(objectiveContentId, objectiveContentKnows); - // 计算每个内容的知识点总学时的比例(百分比) -// contentKnowVOs.forEach(contentKnowVO -> { -// BigDecimal contentPercentage = calculatePercentage(contentKnowVO.getKnowsTime(), classhours); -// contentKnowVO.setPersent(contentPercentage + "%"); -// }); + // 计算并设置该内容的知识点总学时的比例(百分比) + Double contentPercentage = calculatePercentage(objectiveContentKnowVO.getKnowsTime(), classhours); + objectiveContentKnowVO.setPersent(contentPercentage); - // 设置内容的知识点数据 - objectiveContentKnowVO.setContentKnowsData(contentKnowVOs); - } - - // 返回计算结果 + // 返回最终结果 return objectiveContentKnowVO; } - // 创建ObjectiveContentKnowVO对象,并计算知识点数量和总时间 + // 创建ObjectiveContentKnowVO对象,并计算知识点数量、总时间和关联的知识点部分数据 private ObjectiveContentKnowVO createObjectiveContentKnowVO(String objectiveOrContentId, List objectiveContentKnows) { ObjectiveContentKnowVO vo = new ObjectiveContentKnowVO(); vo.setObjectiveOrContent(objectiveOrContentId); vo.setKnowsNumber(objectiveContentKnows.size()); - // 计算知识点的总时间 -// BigDecimal knowsTime = objectiveContentKnows.stream() -// .map(contentKnow -> { -// Know know = knowMapper.selectOne(new LambdaQueryWrapper() -// .eq(Know::getId, contentKnow.getKnow())); -// if (know == null) { -// throw new BusinessException(ErrorCode.KNOW_NOT_EXIT); -// } -// return know.getHour(); -// }) -// .reduce(BigDecimal.ZERO, BigDecimal::add); - -// vo.setKnowsTime(knowsTime); + // 计算知识点的总时间,并收集关联的知识点部分数据 + Double knowsTime = 0.0; + List knowTmpVOList = new ArrayList<>(); + + for (ObjectiveContentKnow contentKnow : objectiveContentKnows) { + Knowtmp know = knowtmpMapper.selectOne(new LambdaQueryWrapper() + .eq(Knowtmp::getId, contentKnow.getKnowId())); + if (know == null) { + throw new BusinessException(ErrorCode.KNOW_NOT_EXIT); + } + knowsTime += know.getHour(); + + // 将当前知识点数据添加到knowTmpVOList中 + KnowTmpVO knowTmpVO = new KnowTmpVO(); + knowTmpVO.setId(know.getId()); + knowTmpVO.setName(know.getName()); + knowTmpVO.setHour(know.getHour()); + knowTmpVOList.add(knowTmpVO); + } + + vo.setKnowsTime(knowsTime); + vo.setKnowTmpVOList(knowTmpVOList); // 设置知识点的部分数据列表 return vo; } - // 计算知识点时间占总学时的比例,并转换为百分比 - private BigDecimal calculatePercentage(BigDecimal knowsTime, Integer classhours) { + // 计算知识点学时占总学时的比例,并返回百分比形式的结果 + private Double calculatePercentage(Double knowsTime, Integer classhours) { if (classhours == null || classhours == 0) { - return BigDecimal.ZERO; + return 0.0; } - // 将classhours转换为BigDecimal类型,以便进行精确计算 - BigDecimal classHoursBigDecimal = new BigDecimal(classhours); - // 计算knowsTime占classhours的比例,先除以classhours再乘以100,保留两位小数,并四舍五入 - return knowsTime.divide(classHoursBigDecimal, 4, RoundingMode.HALF_UP).multiply(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP); + return new BigDecimal(knowsTime) + .divide(new BigDecimal(classhours), 4, RoundingMode.HALF_UP) + .multiply(new BigDecimal(100)) + .setScale(2, RoundingMode.HALF_UP) + .doubleValue(); } -} +} \ No newline at end of file diff --git a/src/main/java/com/teaching/backend/service/impl/courses/ObjectiveContentsServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/courses/ObjectiveContentsServiceImpl.java index b44668e..98e90de 100644 --- a/src/main/java/com/teaching/backend/service/impl/courses/ObjectiveContentsServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/courses/ObjectiveContentsServiceImpl.java @@ -5,16 +5,21 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.teaching.backend.common.ErrorCode; import com.teaching.backend.exception.BusinessException; +import com.teaching.backend.mapper.courses.CourseObjectivesMapper; import com.teaching.backend.mapper.courses.ObjectiveContentKnowMapper; import com.teaching.backend.mapper.courses.ObjectiveContentsMapper; +import com.teaching.backend.model.entity.courses.CourseObjectives; import com.teaching.backend.model.entity.courses.ObjectiveContentKnow; import com.teaching.backend.model.entity.courses.ObjectiveContents; import com.teaching.backend.service.courses.IObjectiveContentsService; import com.teaching.backend.utils.CourseCode; import io.swagger.annotations.Api; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import static com.teaching.backend.utils.CourseCode.*; + /** *

* 服务实现类 @@ -24,23 +29,50 @@ import org.springframework.stereotype.Service; * @since 2024-06-05 */ @Service +@Slf4j public class ObjectiveContentsServiceImpl extends ServiceImpl implements IObjectiveContentsService { @Autowired ObjectiveContentKnowMapper objectiveContentKnowMapper; @Autowired ObjectiveContentsMapper objectiveContentsMapper; + @Autowired + CourseObjectivesMapper courseObjectivesMapper; @Override public String deleteById(String id) { if (id == null){ throw new BusinessException(ErrorCode.CONTENT_NOT_EXIT); } Long count = objectiveContentKnowMapper.selectCount(new LambdaQueryWrapper() - .eq(ObjectiveContentKnow::getObjectiveOrContent, id)); + .eq(ObjectiveContentKnow::getObjectiveContentId, id)); if(count > CourseCode.KNOWS_EXIT.getValue()){ throw new BusinessException(ErrorCode.KNOWS_EXIT); } int delete = objectiveContentsMapper.deleteById(id); return delete > 0 ? "删除成功!" : "删除失败!"; } + + /** + * 在添加内容的时候需要校验,总目标和思政目标只有一个内容 + * @param objectiveContents + * @return + */ + @Override + public String saveWithCheck(ObjectiveContents objectiveContents) { + CourseObjectives courseObjective = courseObjectivesMapper.selectOne(new LambdaQueryWrapper<>(CourseObjectives.class) + .eq(CourseObjectives::getId, objectiveContents.getObjectiveId())); + if (courseObjective == null){ + log.error("课程目标数据不存在:{}",objectiveContents.getObjectiveId()); + throw new BusinessException(ErrorCode.NOT_FOUND_ERROR); + } + if (courseObjective.getType() == SI_ZHENG_TYPE.getValue() || courseObjective.getType() == TOTAL_OBJECTIVE_TYPE.getValue()){ + Long count = objectiveContentsMapper.selectCount(new LambdaQueryWrapper<>(ObjectiveContents.class) + .eq(ObjectiveContents::getObjectiveId, objectiveContents.getObjectiveId())); + if (count>CONTENT_EXIT.getValue()){ + throw new BusinessException(ErrorCode.CONTENT_EXISTS,"该目标下面已存在一条内容,无需再次添加"); + } + } + int insert = objectiveContentsMapper.insert(objectiveContents); + return insert > 0 ? "添加内容成功" : "添加内容失败"; + } } From 395d4b00786e20c0c731799a4874d8fc2de4d7b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=80=BB=E8=A3=81?= <14186472+wenyu441069198@user.noreply.gitee.com> Date: Tue, 20 Aug 2024 11:30:11 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E8=82=96=E6=B5=B7=E5=8D=97=E5=AD=A6?= =?UTF-8?q?=E7=94=9F=E7=AE=A1=E7=90=86=E5=88=86=E9=A1=B5=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/courses/ICoursesService.java | 2 +- .../impl/courses/CoursesServiceImpl.java | 31 ++++++++++--------- .../umsAdmin/UmsStudentManageServiceImpl.java | 2 +- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/teaching/backend/service/courses/ICoursesService.java b/src/main/java/com/teaching/backend/service/courses/ICoursesService.java index e08a348..5f3d7d5 100644 --- a/src/main/java/com/teaching/backend/service/courses/ICoursesService.java +++ b/src/main/java/com/teaching/backend/service/courses/ICoursesService.java @@ -54,7 +54,7 @@ public interface ICoursesService extends IService { List queryStudentList(String userId); LinkedHashSet queryTeacherByStudentLearningRecordList(String userId); - LinkedHashSet queryTeacherByStudentList(String userId); + List queryTeacherByStudentList(String userId); List getUserInfByCourse(Long userId); } 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 ee9f974..f6d9ba7 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 @@ -407,25 +407,28 @@ public class CoursesServiceImpl extends ServiceImpl impl } @Override - public LinkedHashSet queryTeacherByStudentList(String userId) { + public List queryTeacherByStudentList(String userId) { String roleId = umsUserMapper.getByIdRoleId(userId); CourseQuery courseQuery = new CourseQuery(); courseQuery.setUserId(userId); - LinkedHashSet umsStudentManageList = new LinkedHashSet<>(); if (roleId.equals("1")){ - PageDTO queryCourses = queryCourses(courseQuery); + PageDTO queryCourses = queryForTeacher(courseQuery); List coursesList = queryCourses.getList(); - List courseIds = coursesList.stream().map(CoursesVO::getId).collect(Collectors.toList()); - for (String courseId : courseIds) { - List studentUsernames = studentCoursesMapper.selectBatchSomeStudent(courseId); - for (StudentCourses studentUsername : studentUsernames) { - UmsStudentManage umsStudentManage = umsStudentManageMapper.queryStudent(String.valueOf(studentUsername.getStudent())); - if (umsStudentManage != null){ - umsStudentManageList.add(umsStudentManage); - } - } - } - return umsStudentManageList; + + // 首先,收集所有需要查询的学生ID + Set studentIds = coursesList.stream() + .map(CoursesVO::getId) + .flatMap(courseId -> studentCoursesMapper.selectBatchSomeStudent(courseId).stream() + .map(StudentCourses::getStudent)) // 假设getStudent返回Long类型 + .collect(Collectors.toSet()); // 使用Set去重 + + // 然后,一次性查询所有学生信息 + List umsStudentManageLists = studentIds.stream() + .map(studentId -> umsStudentManageMapper.queryStudent(String.valueOf(studentId))) // 假设queryStudent接受Long类型参数 + .filter(Objects::nonNull) + .collect(Collectors.toList()); + + return umsStudentManageLists; } throw new BusinessException(400,"只有老师才有此功能"); } diff --git a/src/main/java/com/teaching/backend/service/impl/umsAdmin/UmsStudentManageServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/umsAdmin/UmsStudentManageServiceImpl.java index c8b5c32..2d4b5c2 100644 --- a/src/main/java/com/teaching/backend/service/impl/umsAdmin/UmsStudentManageServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/umsAdmin/UmsStudentManageServiceImpl.java @@ -54,7 +54,7 @@ public class UmsStudentManageServiceImpl extends ServiceImpl pageQuery(UmsStudentPageQueryDTO umsStudentPageQueryDTO) { - LinkedHashSet umsStudentManages = coursesService.queryTeacherByStudentList(umsStudentPageQueryDTO.getUserId()); + List umsStudentManages = coursesService.queryTeacherByStudentList(umsStudentPageQueryDTO.getUserId()); //总记录数 int totalCount = umsStudentManages.size(); From 04df7b2cc3080ed469d3f82a262860cfe5e39951 Mon Sep 17 00:00:00 2001 From: wenyu441069198 <14186472+wenyu441069198@user.noreply.gitee.com> Date: Tue, 20 Aug 2024 16:24:20 +0800 Subject: [PATCH 5/6] wy --- .../controller/cms/CmsEssayController.java | 3 +- .../KnowledgeLearningNumberMapper.java | 2 +- .../courses/CourseLearningNumberMapper.java | 2 +- .../records/RecordKnowledgeFinishMapper.java | 17 +++++++ .../records/RecordResourceFinishMapper.java | 17 +++++++ .../backend/model/entity/cms/CmsEssay.java | 5 +- .../CourseLearningNumber.java | 4 +- .../entity/records/CourseLearningRecord.java | 2 +- .../KnowledgeLearningNumber.java | 4 +- .../records/KnowledgeLearningRecord.java | 6 ++- .../entity/records/RecordKnowledgeFinish.java | 47 +++++++++++++++++ .../entity/records/RecordResourceFinish.java | 50 +++++++++++++++++++ .../records/ResourceLearningNumber.java | 2 +- .../records/ResourceLearningRecord.java | 15 +++--- .../vo/records/KnowledgeLearningRecordVo.java | 4 ++ .../vo/records/ResourceLearingRecordVo.java | 6 +++ .../IKnowledgeLearningNumberService.java | 2 +- .../courses/ICourseLearningNumberService.java | 2 +- .../CourseLearningNumberServiceImpl.java | 2 +- .../KnowledgeLearningNumberServiceImpl.java | 2 +- .../CourseLearningRecordServiceImpl.java | 2 +- .../KnowledgeLearningRecordServiceImpl.java | 4 +- .../RecordKnowledgeFinishServiceImpl.java | 21 ++++++++ .../RecordResourceFinishServiceImpl.java | 21 ++++++++ .../ResourceLearningRecordServiceImpl.java | 20 +++++++- .../IRecordKnowledgeFinishService.java | 17 +++++++ .../records/IRecordResourceFinishService.java | 17 +++++++ 27 files changed, 272 insertions(+), 24 deletions(-) create mode 100644 src/main/java/com/teaching/backend/mapper/records/RecordKnowledgeFinishMapper.java create mode 100644 src/main/java/com/teaching/backend/mapper/records/RecordResourceFinishMapper.java rename src/main/java/com/teaching/backend/model/entity/{courses => records}/CourseLearningNumber.java (93%) rename src/main/java/com/teaching/backend/model/entity/{KnowGraph => records}/KnowledgeLearningNumber.java (92%) create mode 100644 src/main/java/com/teaching/backend/model/entity/records/RecordKnowledgeFinish.java create mode 100644 src/main/java/com/teaching/backend/model/entity/records/RecordResourceFinish.java create mode 100644 src/main/java/com/teaching/backend/service/impl/records/RecordKnowledgeFinishServiceImpl.java create mode 100644 src/main/java/com/teaching/backend/service/impl/records/RecordResourceFinishServiceImpl.java create mode 100644 src/main/java/com/teaching/backend/service/records/IRecordKnowledgeFinishService.java create mode 100644 src/main/java/com/teaching/backend/service/records/IRecordResourceFinishService.java diff --git a/src/main/java/com/teaching/backend/controller/cms/CmsEssayController.java b/src/main/java/com/teaching/backend/controller/cms/CmsEssayController.java index cc45502..8b3621c 100644 --- a/src/main/java/com/teaching/backend/controller/cms/CmsEssayController.java +++ b/src/main/java/com/teaching/backend/controller/cms/CmsEssayController.java @@ -53,7 +53,8 @@ public class CmsEssayController { * @return */ @PutMapping("/edit") - public BaseResponse editEssay(CmsEssay cmsEssay){ + public BaseResponse editEssay(@RequestBody CmsEssay cmsEssay){ + System.out.println(cmsEssay); return cmsEssayService.editEssay(cmsEssay); } diff --git a/src/main/java/com/teaching/backend/mapper/KnowGraph/KnowledgeLearningNumberMapper.java b/src/main/java/com/teaching/backend/mapper/KnowGraph/KnowledgeLearningNumberMapper.java index 0f66e8e..deedf99 100644 --- a/src/main/java/com/teaching/backend/mapper/KnowGraph/KnowledgeLearningNumberMapper.java +++ b/src/main/java/com/teaching/backend/mapper/KnowGraph/KnowledgeLearningNumberMapper.java @@ -2,7 +2,7 @@ package com.teaching.backend.mapper.KnowGraph; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.teaching.backend.model.entity.KnowGraph.KnowledgeLearningNumber; +import com.teaching.backend.model.entity.records.KnowledgeLearningNumber; /** *

diff --git a/src/main/java/com/teaching/backend/mapper/courses/CourseLearningNumberMapper.java b/src/main/java/com/teaching/backend/mapper/courses/CourseLearningNumberMapper.java index e30dc6d..181b591 100644 --- a/src/main/java/com/teaching/backend/mapper/courses/CourseLearningNumberMapper.java +++ b/src/main/java/com/teaching/backend/mapper/courses/CourseLearningNumberMapper.java @@ -2,7 +2,7 @@ package com.teaching.backend.mapper.courses; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.teaching.backend.model.entity.courses.CourseLearningNumber; +import com.teaching.backend.model.entity.records.CourseLearningNumber; /** *

diff --git a/src/main/java/com/teaching/backend/mapper/records/RecordKnowledgeFinishMapper.java b/src/main/java/com/teaching/backend/mapper/records/RecordKnowledgeFinishMapper.java new file mode 100644 index 0000000..5d8ebb0 --- /dev/null +++ b/src/main/java/com/teaching/backend/mapper/records/RecordKnowledgeFinishMapper.java @@ -0,0 +1,17 @@ +package com.teaching.backend.mapper.records; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.teaching.backend.model.entity.records.RecordKnowledgeFinish; + +/** + *

+ * Mapper 接口 + *

+ * + * @author author + * @since 2024-08-20 + */ +public interface RecordKnowledgeFinishMapper extends BaseMapper { + +} diff --git a/src/main/java/com/teaching/backend/mapper/records/RecordResourceFinishMapper.java b/src/main/java/com/teaching/backend/mapper/records/RecordResourceFinishMapper.java new file mode 100644 index 0000000..b8444ce --- /dev/null +++ b/src/main/java/com/teaching/backend/mapper/records/RecordResourceFinishMapper.java @@ -0,0 +1,17 @@ +package com.teaching.backend.mapper.records; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.teaching.backend.model.entity.records.RecordResourceFinish; + +/** + *

+ * Mapper 接口 + *

+ * + * @author author + * @since 2024-08-20 + */ +public interface RecordResourceFinishMapper extends BaseMapper { + +} diff --git a/src/main/java/com/teaching/backend/model/entity/cms/CmsEssay.java b/src/main/java/com/teaching/backend/model/entity/cms/CmsEssay.java index cc381f2..845f681 100644 --- a/src/main/java/com/teaching/backend/model/entity/cms/CmsEssay.java +++ b/src/main/java/com/teaching/backend/model/entity/cms/CmsEssay.java @@ -2,8 +2,10 @@ package com.teaching.backend.model.entity.cms; import com.baomidou.mybatisplus.annotation.*; +import java.time.LocalDate; import java.time.LocalDateTime; import java.io.Serializable; +import java.time.LocalTime; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; @@ -44,7 +46,8 @@ public class CmsEssay implements Serializable { private String content; @ApiModelProperty(value = "发布时间") - private LocalDateTime publishTime; + @JsonFormat (locale= "zh", timezone= "GMT+8", pattern= "yyyy-MM-dd") + private LocalDate publishTime; @ApiModelProperty(value = "浏览次数") private Integer readingNumber; diff --git a/src/main/java/com/teaching/backend/model/entity/courses/CourseLearningNumber.java b/src/main/java/com/teaching/backend/model/entity/records/CourseLearningNumber.java similarity index 93% rename from src/main/java/com/teaching/backend/model/entity/courses/CourseLearningNumber.java rename to src/main/java/com/teaching/backend/model/entity/records/CourseLearningNumber.java index e462f90..3816b81 100644 --- a/src/main/java/com/teaching/backend/model/entity/courses/CourseLearningNumber.java +++ b/src/main/java/com/teaching/backend/model/entity/records/CourseLearningNumber.java @@ -1,4 +1,4 @@ -package com.teaching.backend.model.entity.courses; +package com.teaching.backend.model.entity.records; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; @@ -22,7 +22,7 @@ import lombok.experimental.Accessors; @Data @EqualsAndHashCode(callSuper = false) @Accessors(chain = true) -@TableName("course_learning_number") +@TableName("record_course_number") @ApiModel(value="CourseLearningNumber对象", description="") public class CourseLearningNumber implements Serializable { diff --git a/src/main/java/com/teaching/backend/model/entity/records/CourseLearningRecord.java b/src/main/java/com/teaching/backend/model/entity/records/CourseLearningRecord.java index 7afccf3..08b6326 100644 --- a/src/main/java/com/teaching/backend/model/entity/records/CourseLearningRecord.java +++ b/src/main/java/com/teaching/backend/model/entity/records/CourseLearningRecord.java @@ -23,7 +23,7 @@ import lombok.experimental.Accessors; @Data @EqualsAndHashCode(callSuper = false) @Accessors(chain = true) -@TableName("course_learning_record") +@TableName("record_course_learning") @ApiModel(value="CourseLearningRecord对象", description="") public class CourseLearningRecord implements Serializable { diff --git a/src/main/java/com/teaching/backend/model/entity/KnowGraph/KnowledgeLearningNumber.java b/src/main/java/com/teaching/backend/model/entity/records/KnowledgeLearningNumber.java similarity index 92% rename from src/main/java/com/teaching/backend/model/entity/KnowGraph/KnowledgeLearningNumber.java rename to src/main/java/com/teaching/backend/model/entity/records/KnowledgeLearningNumber.java index 7fea27b..e5fc9a5 100644 --- a/src/main/java/com/teaching/backend/model/entity/KnowGraph/KnowledgeLearningNumber.java +++ b/src/main/java/com/teaching/backend/model/entity/records/KnowledgeLearningNumber.java @@ -1,4 +1,4 @@ -package com.teaching.backend.model.entity.KnowGraph; +package com.teaching.backend.model.entity.records; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; @@ -22,7 +22,7 @@ import lombok.experimental.Accessors; @Data @EqualsAndHashCode(callSuper = false) @Accessors(chain = true) -@TableName("knowledge_learning_number") +@TableName("record_knowledge_number") @ApiModel(value="KnowledgeLearningNumber对象", description="") public class KnowledgeLearningNumber implements Serializable { diff --git a/src/main/java/com/teaching/backend/model/entity/records/KnowledgeLearningRecord.java b/src/main/java/com/teaching/backend/model/entity/records/KnowledgeLearningRecord.java index 37b4cab..7ae9fb2 100644 --- a/src/main/java/com/teaching/backend/model/entity/records/KnowledgeLearningRecord.java +++ b/src/main/java/com/teaching/backend/model/entity/records/KnowledgeLearningRecord.java @@ -23,7 +23,7 @@ import lombok.experimental.Accessors; @Data @EqualsAndHashCode(callSuper = false) @Accessors(chain = true) -@TableName("knowledge_learning_record") +@TableName("record_knowledge_learning") @ApiModel(value="KnowledgeLearningRecord对象", description="") public class KnowledgeLearningRecord implements Serializable { @@ -61,5 +61,9 @@ public class KnowledgeLearningRecord implements Serializable { @TableField("times") private LocalDateTime times; + @ApiModelProperty(value = "完成状态") + @TableField("finish") + private Integer finish; + } diff --git a/src/main/java/com/teaching/backend/model/entity/records/RecordKnowledgeFinish.java b/src/main/java/com/teaching/backend/model/entity/records/RecordKnowledgeFinish.java new file mode 100644 index 0000000..12f1f23 --- /dev/null +++ b/src/main/java/com/teaching/backend/model/entity/records/RecordKnowledgeFinish.java @@ -0,0 +1,47 @@ +package com.teaching.backend.model.entity.records; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import java.io.Serializable; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * + *

+ * + * @author author + * @since 2024-08-20 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("record_knowledge_finish") +@ApiModel(value="RecordKnowledgeFinish对象", description="") +public class RecordKnowledgeFinish implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "知识点完成状态id") + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @ApiModelProperty(value = "用户id") + private String userId; + + @ApiModelProperty(value = "课程id") + private String courseId; + + @ApiModelProperty(value = "知识点id") + private String knowledgeId; + + @ApiModelProperty(value = "完成状态") + private Integer finish; + + +} diff --git a/src/main/java/com/teaching/backend/model/entity/records/RecordResourceFinish.java b/src/main/java/com/teaching/backend/model/entity/records/RecordResourceFinish.java new file mode 100644 index 0000000..e021550 --- /dev/null +++ b/src/main/java/com/teaching/backend/model/entity/records/RecordResourceFinish.java @@ -0,0 +1,50 @@ +package com.teaching.backend.model.entity.records; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import java.io.Serializable; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * + *

+ * + * @author author + * @since 2024-08-20 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("record_resource_finish") +@ApiModel(value="RecordResourceFinish对象", description="") +public class RecordResourceFinish implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "资源学习状态id") + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @ApiModelProperty(value = "用户id") + private String userId; + + @ApiModelProperty(value = "课程id") + private String courseId; + + @ApiModelProperty(value = "知识点id") + private String knowledgeId; + + @ApiModelProperty(value = "资源id") + private String resourceId; + + @ApiModelProperty(value = "是否完成:1已完成;2;未完成") + private Integer finish; + + +} diff --git a/src/main/java/com/teaching/backend/model/entity/records/ResourceLearningNumber.java b/src/main/java/com/teaching/backend/model/entity/records/ResourceLearningNumber.java index 57638e2..8f63d59 100644 --- a/src/main/java/com/teaching/backend/model/entity/records/ResourceLearningNumber.java +++ b/src/main/java/com/teaching/backend/model/entity/records/ResourceLearningNumber.java @@ -21,7 +21,7 @@ import lombok.experimental.Accessors; @Data @EqualsAndHashCode(callSuper = false) @Accessors(chain = true) -@TableName("resource_learning_number") +@TableName("record_resource_number") @ApiModel(value="ResourceLearningNumber对象", description="") public class ResourceLearningNumber implements Serializable { diff --git a/src/main/java/com/teaching/backend/model/entity/records/ResourceLearningRecord.java b/src/main/java/com/teaching/backend/model/entity/records/ResourceLearningRecord.java index d7dd115..738605c 100644 --- a/src/main/java/com/teaching/backend/model/entity/records/ResourceLearningRecord.java +++ b/src/main/java/com/teaching/backend/model/entity/records/ResourceLearningRecord.java @@ -23,7 +23,7 @@ import lombok.experimental.Accessors; @Data @EqualsAndHashCode(callSuper = false) @Accessors(chain = true) -@TableName("resource_learning_record") +@TableName("record_resource_learning") @ApiModel(value="ResourceLearningRecord对象", description="") public class ResourceLearningRecord implements Serializable { @@ -67,19 +67,22 @@ public class ResourceLearningRecord implements Serializable { @ApiModelProperty(value = "学习时长") @TableField("duration") - private Integer duration; + private double duration; + + @ApiModelProperty(value = "总时长") + @TableField("total_duration") + private double totalDuration; @ApiModelProperty(value = "是否完成观看") @TableField("finish") private Integer finish; - @ApiModelProperty(value = "记录封面") - @TableField("img") - private String img; @ApiModelProperty(value = "最近学习时间") @TableField("times") private LocalDateTime times; - + @ApiModelProperty(value = "资源类型: 1:视频, 2:音频,3:文本资源,4:pdf,5:文件,6:压缩文件") + @TableField("type") + private Integer type; } diff --git a/src/main/java/com/teaching/backend/model/vo/records/KnowledgeLearningRecordVo.java b/src/main/java/com/teaching/backend/model/vo/records/KnowledgeLearningRecordVo.java index c550f19..216885e 100644 --- a/src/main/java/com/teaching/backend/model/vo/records/KnowledgeLearningRecordVo.java +++ b/src/main/java/com/teaching/backend/model/vo/records/KnowledgeLearningRecordVo.java @@ -34,4 +34,8 @@ public class KnowledgeLearningRecordVo { * 学习时间 */ private String time; + /** + * 完成状态 + */ + private Integer finish; } diff --git a/src/main/java/com/teaching/backend/model/vo/records/ResourceLearingRecordVo.java b/src/main/java/com/teaching/backend/model/vo/records/ResourceLearingRecordVo.java index 09a738e..de81f2e 100644 --- a/src/main/java/com/teaching/backend/model/vo/records/ResourceLearingRecordVo.java +++ b/src/main/java/com/teaching/backend/model/vo/records/ResourceLearingRecordVo.java @@ -26,4 +26,10 @@ public class ResourceLearingRecordVo { * 学习时间 */ private String time; + + /** + * 完成状态 + */ + private Integer finish; + } diff --git a/src/main/java/com/teaching/backend/service/KnowGraph/IKnowledgeLearningNumberService.java b/src/main/java/com/teaching/backend/service/KnowGraph/IKnowledgeLearningNumberService.java index 5d6864c..0196709 100644 --- a/src/main/java/com/teaching/backend/service/KnowGraph/IKnowledgeLearningNumberService.java +++ b/src/main/java/com/teaching/backend/service/KnowGraph/IKnowledgeLearningNumberService.java @@ -2,7 +2,7 @@ package com.teaching.backend.service.KnowGraph; import com.baomidou.mybatisplus.extension.service.IService; -import com.teaching.backend.model.entity.KnowGraph.KnowledgeLearningNumber; +import com.teaching.backend.model.entity.records.KnowledgeLearningNumber; /** *

diff --git a/src/main/java/com/teaching/backend/service/courses/ICourseLearningNumberService.java b/src/main/java/com/teaching/backend/service/courses/ICourseLearningNumberService.java index ba882e1..a0b0c74 100644 --- a/src/main/java/com/teaching/backend/service/courses/ICourseLearningNumberService.java +++ b/src/main/java/com/teaching/backend/service/courses/ICourseLearningNumberService.java @@ -2,7 +2,7 @@ package com.teaching.backend.service.courses; import com.baomidou.mybatisplus.extension.service.IService; -import com.teaching.backend.model.entity.courses.CourseLearningNumber; +import com.teaching.backend.model.entity.records.CourseLearningNumber; /** *

diff --git a/src/main/java/com/teaching/backend/service/impl/courses/CourseLearningNumberServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/courses/CourseLearningNumberServiceImpl.java index ce62b53..137e847 100644 --- a/src/main/java/com/teaching/backend/service/impl/courses/CourseLearningNumberServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/courses/CourseLearningNumberServiceImpl.java @@ -3,7 +3,7 @@ package com.teaching.backend.service.impl.courses; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.teaching.backend.mapper.courses.CourseLearningNumberMapper; -import com.teaching.backend.model.entity.courses.CourseLearningNumber; +import com.teaching.backend.model.entity.records.CourseLearningNumber; import com.teaching.backend.service.courses.ICourseLearningNumberService; import org.springframework.stereotype.Service; diff --git a/src/main/java/com/teaching/backend/service/impl/knowledge/KnowledgeLearningNumberServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/knowledge/KnowledgeLearningNumberServiceImpl.java index 2a1d42f..9ce4508 100644 --- a/src/main/java/com/teaching/backend/service/impl/knowledge/KnowledgeLearningNumberServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/knowledge/KnowledgeLearningNumberServiceImpl.java @@ -3,7 +3,7 @@ package com.teaching.backend.service.impl.knowledge; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.teaching.backend.mapper.KnowGraph.KnowledgeLearningNumberMapper; -import com.teaching.backend.model.entity.KnowGraph.KnowledgeLearningNumber; +import com.teaching.backend.model.entity.records.KnowledgeLearningNumber; import com.teaching.backend.service.KnowGraph.IKnowledgeLearningNumberService; import org.springframework.stereotype.Service; diff --git a/src/main/java/com/teaching/backend/service/impl/records/CourseLearningRecordServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/records/CourseLearningRecordServiceImpl.java index 017d625..0d25f53 100644 --- a/src/main/java/com/teaching/backend/service/impl/records/CourseLearningRecordServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/records/CourseLearningRecordServiceImpl.java @@ -7,7 +7,7 @@ import com.teaching.backend.common.BaseResponse; import com.teaching.backend.common.ResultUtils; import com.teaching.backend.mapper.courses.CoursesMapper; import com.teaching.backend.mapper.records.CourseLearningRecordMapper; -import com.teaching.backend.model.entity.courses.CourseLearningNumber; +import com.teaching.backend.model.entity.records.CourseLearningNumber; import com.teaching.backend.mapper.umsAdmin.UmsUserMapper; import com.teaching.backend.model.entity.courses.Courses; import com.teaching.backend.model.entity.records.CourseLearningRecord; diff --git a/src/main/java/com/teaching/backend/service/impl/records/KnowledgeLearningRecordServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/records/KnowledgeLearningRecordServiceImpl.java index 5e673eb..04ba60b 100644 --- a/src/main/java/com/teaching/backend/service/impl/records/KnowledgeLearningRecordServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/records/KnowledgeLearningRecordServiceImpl.java @@ -10,7 +10,7 @@ import com.teaching.backend.common.ResultUtils; import com.teaching.backend.mapper.records.KnowledgeLearningRecordMapper; import com.teaching.backend.mapper.umsAdmin.UmsUserMapper; -import com.teaching.backend.model.entity.KnowGraph.KnowledgeLearningNumber; +import com.teaching.backend.model.entity.records.KnowledgeLearningNumber; import com.teaching.backend.model.entity.knowtmp.Knowtmp; import com.teaching.backend.model.entity.records.KnowledgeLearningRecord; @@ -111,6 +111,7 @@ public class KnowledgeLearningRecordServiceImpl extends ServiceImpl(pagenum, pagesize)); Page page1 = new Page<>(); List records = page.getRecords(); + //System.out.println(records); BeanUtil.copyProperties(page, page1); List recordsVos = new ArrayList<>(); //copy集合 @@ -123,6 +124,7 @@ public class KnowledgeLearningRecordServiceImpl extends ServiceImpl + * 服务实现类 + *

+ * + * @author author + * @since 2024-08-20 + */ +@Service +public class RecordKnowledgeFinishServiceImpl extends ServiceImpl implements IRecordKnowledgeFinishService { + +} diff --git a/src/main/java/com/teaching/backend/service/impl/records/RecordResourceFinishServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/records/RecordResourceFinishServiceImpl.java new file mode 100644 index 0000000..ba72c52 --- /dev/null +++ b/src/main/java/com/teaching/backend/service/impl/records/RecordResourceFinishServiceImpl.java @@ -0,0 +1,21 @@ +package com.teaching.backend.service.impl.records; + + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.teaching.backend.mapper.records.RecordResourceFinishMapper; +import com.teaching.backend.model.entity.records.RecordResourceFinish; +import com.teaching.backend.service.records.IRecordResourceFinishService; +import org.springframework.stereotype.Service; + +/** + *

+ * 服务实现类 + *

+ * + * @author author + * @since 2024-08-20 + */ +@Service +public class RecordResourceFinishServiceImpl extends ServiceImpl implements IRecordResourceFinishService { + +} diff --git a/src/main/java/com/teaching/backend/service/impl/records/ResourceLearningRecordServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/records/ResourceLearningRecordServiceImpl.java index 293c056..b5121d8 100644 --- a/src/main/java/com/teaching/backend/service/impl/records/ResourceLearningRecordServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/records/ResourceLearningRecordServiceImpl.java @@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.teaching.backend.common.BaseResponse; import com.teaching.backend.common.ResultUtils; import com.teaching.backend.mapper.records.ResourceLearningRecordMapper; +import com.teaching.backend.model.entity.records.KnowledgeLearningRecord; import com.teaching.backend.model.entity.records.ResourceLearningNumber; import com.teaching.backend.model.entity.records.ResourceLearningRecord; @@ -35,6 +36,8 @@ public class ResourceLearningRecordServiceImpl extends ServiceImpl saveCoursesRecords(ResourceLearningRecord resourceLearningRecord) { @@ -81,6 +84,21 @@ public class ResourceLearningRecordServiceImpl extends ServiceImpl getPage(int pagenum, int pagesize, String userId, String knowledgeId, String courseId) { -//格式化时间 + //格式化时间 String strDateFormat = "yyyy-MM-dd HH:mm:ss"; SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat); //分页查询 diff --git a/src/main/java/com/teaching/backend/service/records/IRecordKnowledgeFinishService.java b/src/main/java/com/teaching/backend/service/records/IRecordKnowledgeFinishService.java new file mode 100644 index 0000000..2437e18 --- /dev/null +++ b/src/main/java/com/teaching/backend/service/records/IRecordKnowledgeFinishService.java @@ -0,0 +1,17 @@ +package com.teaching.backend.service.records; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.teaching.backend.model.entity.records.RecordKnowledgeFinish; + +/** + *

+ * 服务类 + *

+ * + * @author author + * @since 2024-08-20 + */ +public interface IRecordKnowledgeFinishService extends IService { + +} diff --git a/src/main/java/com/teaching/backend/service/records/IRecordResourceFinishService.java b/src/main/java/com/teaching/backend/service/records/IRecordResourceFinishService.java new file mode 100644 index 0000000..bd6666e --- /dev/null +++ b/src/main/java/com/teaching/backend/service/records/IRecordResourceFinishService.java @@ -0,0 +1,17 @@ +package com.teaching.backend.service.records; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.teaching.backend.model.entity.records.RecordResourceFinish; + +/** + *

+ * 服务类 + *

+ * + * @author author + * @since 2024-08-20 + */ +public interface IRecordResourceFinishService extends IService { + +} From fa0ff84bf9bc2934364ee1569a2d1b71f6b2e52f Mon Sep 17 00:00:00 2001 From: wenyu441069198 <14186472+wenyu441069198@user.noreply.gitee.com> Date: Tue, 20 Aug 2024 17:55:54 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../KnowledgeLearningRecordMapper.java | 2 +- .../KnowledgeLearningRecordServiceImpl.java | 23 +++++++++- .../RecordKnowledgeFinishServiceImpl.java | 43 +++++++++++++++++++ .../RecordResourceFinishServiceImpl.java | 32 ++++++++++++++ .../ResourceLearningRecordServiceImpl.java | 32 +++++++------- .../IRecordKnowledgeFinishService.java | 7 +++ .../records/IRecordResourceFinishService.java | 4 ++ 7 files changed, 124 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/teaching/backend/mapper/records/KnowledgeLearningRecordMapper.java b/src/main/java/com/teaching/backend/mapper/records/KnowledgeLearningRecordMapper.java index 2ddda90..d02a1f0 100644 --- a/src/main/java/com/teaching/backend/mapper/records/KnowledgeLearningRecordMapper.java +++ b/src/main/java/com/teaching/backend/mapper/records/KnowledgeLearningRecordMapper.java @@ -20,7 +20,7 @@ import java.util.List; */ public interface KnowledgeLearningRecordMapper extends BaseMapper { - @Select("SELECT knowledge_id FROM knowledge_learning_record WHERE user_id = #{userId} GROUP BY knowledge_id") + @Select("SELECT knowledge_id FROM record_knowledge_learning WHERE user_id = #{userId} GROUP BY knowledge_id") List selectDistinctKnowledgeIdsByUser(@Param("userId") String userId); List queryStudyKnowledgeMaxNumber(); diff --git a/src/main/java/com/teaching/backend/service/impl/records/KnowledgeLearningRecordServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/records/KnowledgeLearningRecordServiceImpl.java index 04ba60b..b120f8a 100644 --- a/src/main/java/com/teaching/backend/service/impl/records/KnowledgeLearningRecordServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/records/KnowledgeLearningRecordServiceImpl.java @@ -15,6 +15,7 @@ import com.teaching.backend.model.entity.records.KnowledgeLearningNumber; import com.teaching.backend.model.entity.knowtmp.Knowtmp; import com.teaching.backend.model.entity.records.KnowledgeLearningRecord; +import com.teaching.backend.model.entity.records.RecordKnowledgeFinish; import com.teaching.backend.model.vo.knowGraph.KnowVO; import com.teaching.backend.model.vo.records.KnowledgeLearningRecordVo; @@ -50,6 +51,8 @@ public class KnowledgeLearningRecordServiceImpl extends ServiceImpl saveCoursesRecords(KnowledgeLearningRecord knowledgeLearningRecord) { @@ -78,7 +81,14 @@ public class KnowledgeLearningRecordServiceImpl extends ServiceImpl getPage(int pagenum, int pagesize, String userId, String courseId) { //格式化时间 @@ -122,6 +139,8 @@ public class KnowledgeLearningRecordServiceImpl extends ServiceImpl implements IRecordKnowledgeFinishService { + @Override + public void addFinish(KnowledgeLearningRecord knowledgeLearningRecord) { + RecordKnowledgeFinish recordKnowledgeFinish = new RecordKnowledgeFinish(); + recordKnowledgeFinish.setUserId(knowledgeLearningRecord.getUserId()); + recordKnowledgeFinish.setCourseId(knowledgeLearningRecord.getCoursesId()); + recordKnowledgeFinish.setKnowledgeId(knowledgeLearningRecord.getKnowledgeId()); + recordKnowledgeFinish.setFinish(knowledgeLearningRecord.getFinish()); + save(recordKnowledgeFinish); + } + + @Override + public void addFinish(ResourceLearningRecord resourceLearningRecord) { + RecordKnowledgeFinish recordKnowledgeFinish = new RecordKnowledgeFinish(); + recordKnowledgeFinish.setUserId(resourceLearningRecord.getUserId()); + recordKnowledgeFinish.setCourseId(resourceLearningRecord.getCoursesId()); + recordKnowledgeFinish.setKnowledgeId(resourceLearningRecord.getKnowledgeId()); + recordKnowledgeFinish.setFinish(resourceLearningRecord.getFinish()); + save(recordKnowledgeFinish); + } + + @Override + public void editFinish(KnowledgeLearningRecord knowledgeLearningRecord) { + //设置完成状态 + RecordKnowledgeFinish one = query() + .eq("course_id", knowledgeLearningRecord.getCoursesId()) + .eq("knowledge_id", knowledgeLearningRecord.getKnowledgeId()) + .eq("user_id", knowledgeLearningRecord.getUserId()).one(); + one.setFinish(1); + updateById(one); + } + + @Override + public void editFinish(ResourceLearningRecord resourceLearningRecord) { + //设置完成状态 + RecordKnowledgeFinish one = query() + .eq("course_id", resourceLearningRecord.getCoursesId()) + .eq("knowledge_id", resourceLearningRecord.getKnowledgeId()) + .eq("user_id", resourceLearningRecord.getUserId()).one(); + one.setFinish(1); + updateById(one); + } } diff --git a/src/main/java/com/teaching/backend/service/impl/records/RecordResourceFinishServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/records/RecordResourceFinishServiceImpl.java index ba72c52..6892a5b 100644 --- a/src/main/java/com/teaching/backend/service/impl/records/RecordResourceFinishServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/records/RecordResourceFinishServiceImpl.java @@ -3,10 +3,14 @@ package com.teaching.backend.service.impl.records; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.teaching.backend.mapper.records.RecordResourceFinishMapper; +import com.teaching.backend.model.entity.records.RecordKnowledgeFinish; import com.teaching.backend.model.entity.records.RecordResourceFinish; +import com.teaching.backend.model.entity.records.ResourceLearningRecord; import com.teaching.backend.service.records.IRecordResourceFinishService; import org.springframework.stereotype.Service; +import javax.annotation.Resource; + /** *

* 服务实现类 @@ -18,4 +22,32 @@ import org.springframework.stereotype.Service; @Service public class RecordResourceFinishServiceImpl extends ServiceImpl implements IRecordResourceFinishService { + @Resource + private RecordKnowledgeFinishServiceImpl recordKnowledgeFinishService; + @Override + public void addFinish(ResourceLearningRecord resourceLearningRecord) { + //如果资源学习完成,知识点也改为完成 + if (resourceLearningRecord.getFinish() == 1){ + recordKnowledgeFinishService.editFinish(resourceLearningRecord); + } + RecordResourceFinish recordResourceFinish = new RecordResourceFinish(); + recordResourceFinish.setUserId(resourceLearningRecord.getUserId()); + recordResourceFinish.setCourseId(resourceLearningRecord.getCoursesId()); + recordResourceFinish.setKnowledgeId(resourceLearningRecord.getKnowledgeId()); + recordResourceFinish.setResourceId(resourceLearningRecord.getResourceId()); + recordResourceFinish.setFinish(resourceLearningRecord.getFinish()); + System.out.println(recordResourceFinish); + save(recordResourceFinish); + } + + @Override + public void editFinish(ResourceLearningRecord resourceLearningRecord) { + RecordResourceFinish one = query() + .eq("course_id", resourceLearningRecord.getCoursesId()) + .eq("knowledge_id", resourceLearningRecord.getKnowledgeId()) + .eq("resource_id",resourceLearningRecord.getResourceId()) + .eq("user_id", resourceLearningRecord.getUserId()).one(); + one.setFinish(1); + updateById(one); + } } diff --git a/src/main/java/com/teaching/backend/service/impl/records/ResourceLearningRecordServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/records/ResourceLearningRecordServiceImpl.java index b5121d8..bf57112 100644 --- a/src/main/java/com/teaching/backend/service/impl/records/ResourceLearningRecordServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/records/ResourceLearningRecordServiceImpl.java @@ -37,7 +37,7 @@ public class ResourceLearningRecordServiceImpl extends ServiceImpl saveCoursesRecords(ResourceLearningRecord resourceLearningRecord) { @@ -68,6 +68,13 @@ public class ResourceLearningRecordServiceImpl extends ServiceImpl @@ -13,5 +16,9 @@ import com.teaching.backend.model.entity.records.RecordKnowledgeFinish; * @since 2024-08-20 */ public interface IRecordKnowledgeFinishService extends IService { + void addFinish(KnowledgeLearningRecord knowledgeLearningRecord); + void addFinish(ResourceLearningRecord resourceLearningRecord); + void editFinish(KnowledgeLearningRecord knowledgeLearningRecord); + void editFinish(ResourceLearningRecord resourceLearningRecord); } diff --git a/src/main/java/com/teaching/backend/service/records/IRecordResourceFinishService.java b/src/main/java/com/teaching/backend/service/records/IRecordResourceFinishService.java index bd6666e..5e020f3 100644 --- a/src/main/java/com/teaching/backend/service/records/IRecordResourceFinishService.java +++ b/src/main/java/com/teaching/backend/service/records/IRecordResourceFinishService.java @@ -2,7 +2,9 @@ package com.teaching.backend.service.records; import com.baomidou.mybatisplus.extension.service.IService; +import com.teaching.backend.model.entity.records.KnowledgeLearningRecord; import com.teaching.backend.model.entity.records.RecordResourceFinish; +import com.teaching.backend.model.entity.records.ResourceLearningRecord; /** *

@@ -13,5 +15,7 @@ import com.teaching.backend.model.entity.records.RecordResourceFinish; * @since 2024-08-20 */ public interface IRecordResourceFinishService extends IService { + void addFinish(ResourceLearningRecord resourceLearningRecord); + void editFinish(ResourceLearningRecord resourceLearningRecord); }