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;