From 5a4749ae9d33238de58250d84af8330031580a57 Mon Sep 17 00:00:00 2001 From: wenyu441069198 <14186472+wenyu441069198@user.noreply.gitee.com> Date: Tue, 6 Aug 2024 16:19:03 +0800 Subject: [PATCH] =?UTF-8?q?=E8=82=96=E6=B5=B7=E5=8D=97=E4=B8=AA=E4=BA=BA?= =?UTF-8?q?=E4=B8=AD=E5=BF=83=E5=AD=A6=E4=B9=A0=E8=AE=B0=E5=BD=95=EF=BC=88?= =?UTF-8?q?=E7=9F=A5=E8=AF=86=E7=82=B9=EF=BC=89=E6=8E=A5=E5=8F=A3=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../KnowledgeLearningRecordController.java | 18 +++++++ .../KnowledgeLearningRecordMapper.java | 5 ++ .../backend/model/vo/knowGraph/KnowVO.java | 1 - .../KnowledgeLearningRecordServiceImpl.java | 52 +++++++++++++++++++ .../IKnowledgeLearningRecordService.java | 3 ++ .../mapper/KnowledgeLearningRecordMapper.xml | 20 +++++++ 6 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/mapper/KnowledgeLearningRecordMapper.xml 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 867889c..dac49ac 100644 --- a/src/main/java/com/teaching/backend/controller/records/KnowledgeLearningRecordController.java +++ b/src/main/java/com/teaching/backend/controller/records/KnowledgeLearningRecordController.java @@ -2,10 +2,13 @@ package com.teaching.backend.controller.records; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.teaching.backend.common.BaseResponse; +import com.teaching.backend.common.CommonResult; import com.teaching.backend.common.ResultUtils; import com.teaching.backend.filter.ValidateParams; 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; import org.springframework.web.bind.annotation.*; @@ -53,5 +56,20 @@ public class KnowledgeLearningRecordController { return knowledgeLearningRecordService.removeKnowledgeRecord(ids); } + /** + * 获取学习最多的知识点 + * + * @return + */ + @ApiOperation("查询学习最多的知识点") + @PostMapping("/studyMaxKnowledge") + public CommonResult> studyMaxKnowledge(@RequestParam String userId) { + List knowVO = knowledgeLearningRecordService.queryMaxKnowledge(userId); + if (knowVO == null){ + CommonResult.failed("用户或角色错误"); + } + return CommonResult.success(knowVO); + } + } 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 d9dbbe5..78f4ada 100644 --- a/src/main/java/com/teaching/backend/mapper/records/KnowledgeLearningRecordMapper.java +++ b/src/main/java/com/teaching/backend/mapper/records/KnowledgeLearningRecordMapper.java @@ -4,6 +4,8 @@ package com.teaching.backend.mapper.records; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.teaching.backend.model.entity.records.KnowledgeLearningRecord; +import java.util.List; + /** *

* Mapper 接口 @@ -14,4 +16,7 @@ import com.teaching.backend.model.entity.records.KnowledgeLearningRecord; */ public interface KnowledgeLearningRecordMapper extends BaseMapper { + List queryStudyKnowledgeMaxNumber(); + + List queryStudyMaxKnowledgeId(String userId); } diff --git a/src/main/java/com/teaching/backend/model/vo/knowGraph/KnowVO.java b/src/main/java/com/teaching/backend/model/vo/knowGraph/KnowVO.java index d6a60a2..beaa1a2 100644 --- a/src/main/java/com/teaching/backend/model/vo/knowGraph/KnowVO.java +++ b/src/main/java/com/teaching/backend/model/vo/knowGraph/KnowVO.java @@ -3,7 +3,6 @@ package com.teaching.backend.model.vo.knowGraph; import lombok.Data; import java.io.Serializable; -import java.util.List; @Data 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 c26e3d9..da5e2be 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 @@ -8,15 +8,23 @@ 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.KnowledgeLearningRecordMapper; +import com.teaching.backend.mapper.umsAdmin.UmsUserMapper; +import com.teaching.backend.model.entity.KnowGraph.Know; import com.teaching.backend.model.entity.KnowGraph.KnowledgeLearningNumber; +import com.teaching.backend.model.entity.Knowtemp.Knowtemp; import com.teaching.backend.model.entity.courses.CourseLearningNumber; +import com.teaching.backend.model.entity.courses.Courses; 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.model.vo.records.KnowledgeLearningRecordVo; +import com.teaching.backend.service.KnowGraph.KnowService; import com.teaching.backend.service.impl.courses.CourseLearningNumberServiceImpl; import com.teaching.backend.service.impl.knowledge.KnowledgeLearningNumberServiceImpl; import com.teaching.backend.service.records.IKnowledgeLearningRecordService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -39,6 +47,12 @@ import java.util.List; public class KnowledgeLearningRecordServiceImpl extends ServiceImpl implements IKnowledgeLearningRecordService { @Resource private KnowledgeLearningNumberServiceImpl knowledgeLearningNumberService; + @Autowired + private UmsUserMapper umsUserMapper; + @Autowired + private KnowledgeLearningRecordMapper knowledgeLearningRecordMapper; + @Resource + private KnowService knowService; @Override public BaseResponse saveCoursesRecords(KnowledgeLearningRecord knowledgeLearningRecord) { @@ -115,4 +129,42 @@ public class KnowledgeLearningRecordServiceImpl extends ServiceImpl queryMaxKnowledge(String userId) { + String roleId = umsUserMapper.getbyIdRoleId(userId); + List coursesList = new ArrayList<>(); + KnowVO knowVO = null; + if (roleId.equals("1")){ + //老师 + List knowledgeIdList = knowledgeLearningRecordMapper.queryStudyKnowledgeMaxNumber(); + for (String knowledgeId : knowledgeIdList) { + BaseResponse knowledge = knowService.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; + }else if (roleId.equals("2")){ + //学生 + List knowledgeIdList = knowledgeLearningRecordMapper.queryStudyMaxKnowledgeId(userId); + for (String knowledgeId : knowledgeIdList) { + BaseResponse knowledge = knowService.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; + }else { + return null; + } + } } 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 252d176..977aad0 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.knowGraph.KnowVO; import java.util.List; @@ -23,5 +24,7 @@ public interface IKnowledgeLearningRecordService extends IService getPage(int pagenum, int pagesize, String userId, String courseId); BaseResponse removeKnowledgeRecord(List ids); + + List queryMaxKnowledge(String userId); } diff --git a/src/main/resources/mapper/KnowledgeLearningRecordMapper.xml b/src/main/resources/mapper/KnowledgeLearningRecordMapper.xml new file mode 100644 index 0000000..3ea0405 --- /dev/null +++ b/src/main/resources/mapper/KnowledgeLearningRecordMapper.xml @@ -0,0 +1,20 @@ + + + + + + +