肖海南个人中心学习记录(知识点)接口代码

master
wenyu441069198 4 months ago
parent a4ae842a4a
commit 5a4749ae9d
  1. 18
      src/main/java/com/teaching/backend/controller/records/KnowledgeLearningRecordController.java
  2. 5
      src/main/java/com/teaching/backend/mapper/records/KnowledgeLearningRecordMapper.java
  3. 1
      src/main/java/com/teaching/backend/model/vo/knowGraph/KnowVO.java
  4. 52
      src/main/java/com/teaching/backend/service/impl/records/KnowledgeLearningRecordServiceImpl.java
  5. 3
      src/main/java/com/teaching/backend/service/records/IKnowledgeLearningRecordService.java
  6. 20
      src/main/resources/mapper/KnowledgeLearningRecordMapper.xml

@ -2,10 +2,13 @@ package com.teaching.backend.controller.records;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.teaching.backend.common.BaseResponse; import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.common.CommonResult;
import com.teaching.backend.common.ResultUtils; import com.teaching.backend.common.ResultUtils;
import com.teaching.backend.filter.ValidateParams; import com.teaching.backend.filter.ValidateParams;
import com.teaching.backend.model.entity.records.CourseLearningRecord; import com.teaching.backend.model.entity.records.CourseLearningRecord;
import com.teaching.backend.model.entity.records.KnowledgeLearningRecord; 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 com.teaching.backend.service.impl.records.KnowledgeLearningRecordServiceImpl;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -53,5 +56,20 @@ public class KnowledgeLearningRecordController {
return knowledgeLearningRecordService.removeKnowledgeRecord(ids); return knowledgeLearningRecordService.removeKnowledgeRecord(ids);
} }
/**
* 获取学习最多的知识点
*
* @return
*/
@ApiOperation("查询学习最多的知识点")
@PostMapping("/studyMaxKnowledge")
public CommonResult<List<KnowVO>> studyMaxKnowledge(@RequestParam String userId) {
List<KnowVO> knowVO = knowledgeLearningRecordService.queryMaxKnowledge(userId);
if (knowVO == null){
CommonResult.failed("用户或角色错误");
}
return CommonResult.success(knowVO);
}
} }

@ -4,6 +4,8 @@ package com.teaching.backend.mapper.records;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.teaching.backend.model.entity.records.KnowledgeLearningRecord; import com.teaching.backend.model.entity.records.KnowledgeLearningRecord;
import java.util.List;
/** /**
* <p> * <p>
* Mapper 接口 * Mapper 接口
@ -14,4 +16,7 @@ import com.teaching.backend.model.entity.records.KnowledgeLearningRecord;
*/ */
public interface KnowledgeLearningRecordMapper extends BaseMapper<KnowledgeLearningRecord> { public interface KnowledgeLearningRecordMapper extends BaseMapper<KnowledgeLearningRecord> {
List<String> queryStudyKnowledgeMaxNumber();
List<String> queryStudyMaxKnowledgeId(String userId);
} }

@ -3,7 +3,6 @@ package com.teaching.backend.model.vo.knowGraph;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.util.List;
@Data @Data

@ -8,15 +8,23 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.teaching.backend.common.BaseResponse; import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.common.ResultUtils; import com.teaching.backend.common.ResultUtils;
import com.teaching.backend.mapper.records.KnowledgeLearningRecordMapper; 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.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.CourseLearningNumber;
import com.teaching.backend.model.entity.courses.Courses;
import com.teaching.backend.model.entity.records.KnowledgeLearningRecord; 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.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.courses.CourseLearningNumberServiceImpl;
import com.teaching.backend.service.impl.knowledge.KnowledgeLearningNumberServiceImpl; import com.teaching.backend.service.impl.knowledge.KnowledgeLearningNumberServiceImpl;
import com.teaching.backend.service.records.IKnowledgeLearningRecordService; import com.teaching.backend.service.records.IKnowledgeLearningRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -39,6 +47,12 @@ import java.util.List;
public class KnowledgeLearningRecordServiceImpl extends ServiceImpl<KnowledgeLearningRecordMapper, KnowledgeLearningRecord> implements IKnowledgeLearningRecordService { public class KnowledgeLearningRecordServiceImpl extends ServiceImpl<KnowledgeLearningRecordMapper, KnowledgeLearningRecord> implements IKnowledgeLearningRecordService {
@Resource @Resource
private KnowledgeLearningNumberServiceImpl knowledgeLearningNumberService; private KnowledgeLearningNumberServiceImpl knowledgeLearningNumberService;
@Autowired
private UmsUserMapper umsUserMapper;
@Autowired
private KnowledgeLearningRecordMapper knowledgeLearningRecordMapper;
@Resource
private KnowService knowService;
@Override @Override
public BaseResponse<String> saveCoursesRecords(KnowledgeLearningRecord knowledgeLearningRecord) { public BaseResponse<String> saveCoursesRecords(KnowledgeLearningRecord knowledgeLearningRecord) {
@ -115,4 +129,42 @@ public class KnowledgeLearningRecordServiceImpl extends ServiceImpl<KnowledgeLea
removeByIds(ids); removeByIds(ids);
return ResultUtils.success("删除成功!"); return ResultUtils.success("删除成功!");
} }
@Override
public List<KnowVO> queryMaxKnowledge(String userId) {
String roleId = umsUserMapper.getbyIdRoleId(userId);
List<KnowVO> coursesList = new ArrayList<>();
KnowVO knowVO = null;
if (roleId.equals("1")){
//老师
List<String> knowledgeIdList = knowledgeLearningRecordMapper.queryStudyKnowledgeMaxNumber();
for (String knowledgeId : knowledgeIdList) {
BaseResponse<Knowtemp> 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<String> knowledgeIdList = knowledgeLearningRecordMapper.queryStudyMaxKnowledgeId(userId);
for (String knowledgeId : knowledgeIdList) {
BaseResponse<Knowtemp> 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;
}
}
} }

@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.teaching.backend.common.BaseResponse; import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.model.entity.records.KnowledgeLearningRecord; import com.teaching.backend.model.entity.records.KnowledgeLearningRecord;
import com.teaching.backend.model.vo.knowGraph.KnowVO;
import java.util.List; import java.util.List;
@ -23,5 +24,7 @@ public interface IKnowledgeLearningRecordService extends IService<KnowledgeLearn
BaseResponse<Page> getPage(int pagenum, int pagesize, String userId, String courseId); BaseResponse<Page> getPage(int pagenum, int pagesize, String userId, String courseId);
BaseResponse<String> removeKnowledgeRecord(List<Long> ids); BaseResponse<String> removeKnowledgeRecord(List<Long> ids);
List<KnowVO> queryMaxKnowledge(String userId);
} }

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.teaching.backend.mapper.records.KnowledgeLearningRecordMapper">
<select id="queryStudyKnowledgeMaxNumber" resultType="java.lang.String">
SELECT
kln.knowledge_id knowledgeId
FROM
knowledge_learning_number kln
ORDER BY
number
DESC;
</select>
<select id="queryStudyMaxKnowledgeId" resultType="java.lang.String">
SELECT knowledge_id,knowledge_name
FROM knowledge_learning_record
WHERE user_id = #{userId}
ORDER BY times DESC;
</select>
</mapper>
Loading…
Cancel
Save