肖海南个人中心课程推荐接口

master
总裁 3 months ago
parent 9701771c45
commit 0663d44383
  1. 3
      src/main/java/com/teaching/backend/controller/records/CourseLearningRecordController.java
  2. 11
      src/main/java/com/teaching/backend/controller/records/KnowledgeLearningRecordController.java
  3. 2
      src/main/java/com/teaching/backend/mapper/records/CourseLearningRecordMapper.java
  4. 2
      src/main/java/com/teaching/backend/model/entity/umsAdmin/AdminUserDetails.java
  5. 23
      src/main/java/com/teaching/backend/service/impl/records/CourseLearningRecordServiceImpl.java
  6. 21
      src/main/java/com/teaching/backend/service/impl/records/KnowledgeLearningRecordServiceImpl.java
  7. 15
      src/main/java/com/teaching/backend/service/impl/umsAdmin/UmsStudentManageServiceImpl.java
  8. 2
      src/main/java/com/teaching/backend/service/impl/umsAdmin/UmsUserServiceImpl.java
  9. 3
      src/main/java/com/teaching/backend/service/records/IKnowledgeLearningRecordService.java
  10. 4
      src/main/resources/mapper/CourseLearningRecordMapper.xml

@ -79,9 +79,6 @@ public class CourseLearningRecordController {
@PostMapping("/recommendCourses") @PostMapping("/recommendCourses")
public CommonResult<List<CoursesVO>> recommendCourses(@RequestParam String userId) { public CommonResult<List<CoursesVO>> recommendCourses(@RequestParam String userId) {
List<CoursesVO> coursesVOList = courseLearningRecordService.queryrecommendCourses(userId); List<CoursesVO> coursesVOList = courseLearningRecordService.queryrecommendCourses(userId);
if (coursesVOList == null){
CommonResult.failed("用户或角色错误");
}
return CommonResult.success(coursesVOList); return CommonResult.success(coursesVOList);
} }

@ -8,6 +8,7 @@ import com.teaching.backend.filter.ValidateParams;
import com.teaching.backend.mapper.records.KnowledgeLearningRecordMapper; import com.teaching.backend.mapper.records.KnowledgeLearningRecordMapper;
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.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;
@ -84,5 +85,15 @@ public class KnowledgeLearningRecordController {
return CommonResult.success(knowVO); return CommonResult.success(knowVO);
} }
/**
* 推荐知识点
* @return
*/
@ApiOperation("推荐知识点")
@PostMapping("/recommendKnowledge")
public CommonResult<List<KnowVO>> recommendCourses(@RequestParam String userId) {
List<KnowVO> coursesVOList = knowledgeLearningRecordService.queryRecommendKnowledge(userId);
return CommonResult.success(coursesVOList);
}
} }

@ -18,7 +18,7 @@ public interface CourseLearningRecordMapper extends BaseMapper<CourseLearningRec
CourseLearningRecord selectNewRecord(String student); CourseLearningRecord selectNewRecord(String student);
List<String> selectMaxNumber(); List<String> selectMaxNumber(String userId);
List<String> selectMaxCourseId(String userId); List<String> selectMaxCourseId(String userId);
} }

@ -59,6 +59,6 @@ public class AdminUserDetails implements UserDetails {
@Override @Override
public boolean isEnabled() { public boolean isEnabled() {
return umsAdmin.getStatus().equals(1); return umsAdmin.getStatus().equals("1");
} }
} }

@ -127,7 +127,7 @@ public class CourseLearningRecordServiceImpl extends ServiceImpl<CourseLearningR
String roleId = umsUserMapper.getByIdRoleId(userId); String roleId = umsUserMapper.getByIdRoleId(userId);
List<Courses> coursesList = new ArrayList<>(); List<Courses> coursesList = new ArrayList<>();
if (roleId.equals("1")){ if (roleId.equals("1")){
List<String> courseIds = courseLearningRecordMapper.selectMaxNumber(); List<String> courseIds = courseLearningRecordMapper.selectMaxNumber(userId);
for (String courseId : courseIds) { for (String courseId : courseIds) {
Courses courses = coursesMapper.selectById(courseId); Courses courses = coursesMapper.selectById(courseId);
coursesList.add(courses); coursesList.add(courses);
@ -149,18 +149,15 @@ public class CourseLearningRecordServiceImpl extends ServiceImpl<CourseLearningR
@Override @Override
public List<CoursesVO> queryrecommendCourses(String userId) { public List<CoursesVO> queryrecommendCourses(String userId) {
String roleId = umsUserMapper.getByIdRoleId(userId); List<Courses> coursesList = new ArrayList<>();
List<String> courseIds = courseLearningRecordMapper.selectMaxNumber(userId);
if (roleId.equals("1")) { for (String courseId : courseIds) {
Courses courses = coursesMapper.selectById(courseId);
return null; if (courses != null){
} else if (roleId.equals("2")) { coursesList.add(courses);
}
return null;
}else {
return null;
} }
List<CoursesVO> coursesVOList = BeanUtil.copyToList(coursesList, CoursesVO.class);
return coursesVOList;
} }
} }

@ -171,4 +171,25 @@ public class KnowledgeLearningRecordServiceImpl extends ServiceImpl<KnowledgeLea
} }
} }
@Override
public List<KnowVO> queryRecommendKnowledge(String userId) {
List<KnowVO> coursesList = new ArrayList<>();
KnowVO knowVO = null;
List<String> knowledgeIdList = knowledgeLearningRecordMapper.queryStudyKnowledgeMaxNumber();
for (String knowledgeId : knowledgeIdList) {
BaseResponse<Knowtmp> 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;
}
} }

@ -124,13 +124,14 @@ public class UmsStudentManageServiceImpl extends ServiceImpl<UmsStudentManageMap
@Override @Override
public void startOrStop(String status, Long id) { public void startOrStop(String status, Long id) {
UmsUser umsUser = new UmsUser();
umsUser.setStatus(status); UmsUser umsUser = new UmsUser();
umsUser.setId(id); umsUser.setStatus(status);
boolean updateUserInformation = umsUserMapper.updateUserInformation(umsUser); umsUser.setId(id);
if (updateUserInformation == false){ boolean updateUserInformation = umsUserMapper.updateUserInformation(umsUser);
throw new BusinessException(400,"账号状态修改失败"); if (updateUserInformation == false){
} throw new BusinessException(400,"账号状态修改失败");
}
} }
@Override @Override

@ -103,7 +103,7 @@ public class UmsUserServiceImpl extends ServiceImpl<UmsUserMapper, UmsUser> impl
if(!passwordEncoder.matches(password,userDetails.getPassword())){ if(!passwordEncoder.matches(password,userDetails.getPassword())){
throw new BusinessException(400,"密码错误"); throw new BusinessException(400,"密码错误");
} }
if(userDetails.isEnabled()){ if(!userDetails.isEnabled()){
throw new BusinessException(400,"帐号已被禁用"); throw new BusinessException(400,"帐号已被禁用");
} }
UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities()); UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());

@ -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.courses.CoursesVO;
import io.swagger.models.auth.In; import io.swagger.models.auth.In;
import com.teaching.backend.model.vo.knowGraph.KnowVO; import com.teaching.backend.model.vo.knowGraph.KnowVO;
@ -28,5 +29,7 @@ public interface IKnowledgeLearningRecordService extends IService<KnowledgeLearn
List<KnowVO> queryMaxKnowledge(String userId); List<KnowVO> queryMaxKnowledge(String userId);
List<KnowVO> queryRecommendKnowledge(String userId);
} }

@ -12,11 +12,13 @@
times times
DESC LIMIT 1; DESC LIMIT 1;
</select> </select>
<select id="selectMaxNumber" resultType="java.lang.String"> <select id="selectMaxNumber" resultType="java.lang.String" parameterType="java.lang.String">
SELECT SELECT
cln.course_id courseId cln.course_id courseId
FROM FROM
course_learning_number cln course_learning_number cln
WHERE
CONCAT(',', cln.teacher_user_id, ',') LIKE CONCAT('%,', #{userId}, ',%')
ORDER BY ORDER BY
number number
DESC; DESC;

Loading…
Cancel
Save