Merge remote-tracking branch 'origin/master'

master
小萌新 3 months ago
commit 3f63df9f86
  1. 6
      pom.xml
  2. 5
      src/main/java/com/teaching/backend/common/ErrorCode.java
  3. 21
      src/main/java/com/teaching/backend/controller/Know/Edge.java
  4. 38
      src/main/java/com/teaching/backend/controller/Know/KnowChapterVO.java
  5. 58
      src/main/java/com/teaching/backend/controller/Know/KnowController.java
  6. 33
      src/main/java/com/teaching/backend/controller/Know/KnowCourseVO.java
  7. 42
      src/main/java/com/teaching/backend/controller/Know/KnowJson.java
  8. 31
      src/main/java/com/teaching/backend/controller/Know/KnowJsonListVO.java
  9. 9
      src/main/java/com/teaching/backend/controller/Knowtmp/KnowtmpController.java
  10. 2
      src/main/java/com/teaching/backend/controller/chapter/ChapterController2.java
  11. 76
      src/main/java/com/teaching/backend/controller/cms/CmsCategoryController.java
  12. 80
      src/main/java/com/teaching/backend/controller/cms/CmsEssayController.java
  13. 8
      src/main/java/com/teaching/backend/controller/courses/CourseObjectivesController.java
  14. 8
      src/main/java/com/teaching/backend/controller/courses/ObjectiveContentKnowController.java
  15. 4
      src/main/java/com/teaching/backend/controller/courses/ObjectiveContentsController.java
  16. 3
      src/main/java/com/teaching/backend/controller/records/CourseLearningRecordController.java
  17. 11
      src/main/java/com/teaching/backend/controller/records/KnowledgeLearningRecordController.java
  18. 8
      src/main/java/com/teaching/backend/controller/resource/ResourceController.java
  19. 4
      src/main/java/com/teaching/backend/controller/umsAdmin/UmsStudentManageController.java
  20. 2
      src/main/java/com/teaching/backend/mapper/KnowGraph/KnowledgeLearningNumberMapper.java
  21. 8
      src/main/java/com/teaching/backend/mapper/Knowtemp/KnowtmpMapper.java
  22. 18
      src/main/java/com/teaching/backend/mapper/chapter/ChapterMapper.java
  23. 17
      src/main/java/com/teaching/backend/mapper/cms/CmsCategoryMapper.java
  24. 17
      src/main/java/com/teaching/backend/mapper/cms/CmsEssayMapper.java
  25. 2
      src/main/java/com/teaching/backend/mapper/courses/CourseLearningNumberMapper.java
  26. 62
      src/main/java/com/teaching/backend/mapper/know/KnowRepository.java
  27. 2
      src/main/java/com/teaching/backend/mapper/records/CourseLearningRecordMapper.java
  28. 2
      src/main/java/com/teaching/backend/mapper/records/KnowledgeLearningRecordMapper.java
  29. 17
      src/main/java/com/teaching/backend/mapper/records/RecordKnowledgeFinishMapper.java
  30. 17
      src/main/java/com/teaching/backend/mapper/records/RecordResourceFinishMapper.java
  31. 4
      src/main/java/com/teaching/backend/mapper/resource/ResourcesRepository.java
  32. 2
      src/main/java/com/teaching/backend/mapper/umsAdmin/UmsStudentMapper.java
  33. 3
      src/main/java/com/teaching/backend/mapper/umsAdmin/UmsUserMapper.java
  34. 2
      src/main/java/com/teaching/backend/model/dto/courses/ObjectiveContentKnowDTO.java
  35. 3
      src/main/java/com/teaching/backend/model/dto/umsAdmin/UmsStudentAndTeacherDTO.java
  36. 67
      src/main/java/com/teaching/backend/model/entity/cms/CmsCategory.java
  37. 75
      src/main/java/com/teaching/backend/model/entity/cms/CmsEssay.java
  38. 6
      src/main/java/com/teaching/backend/model/entity/courses/ObjectiveContentKnow.java
  39. 4
      src/main/java/com/teaching/backend/model/entity/courses/ObjectiveContents.java
  40. 1
      src/main/java/com/teaching/backend/model/entity/knowtmp/Knowtmp.java
  41. 8
      src/main/java/com/teaching/backend/model/entity/records/CourseLearningNumber.java
  42. 6
      src/main/java/com/teaching/backend/model/entity/records/CourseLearningRecord.java
  43. 4
      src/main/java/com/teaching/backend/model/entity/records/KnowledgeLearningNumber.java
  44. 6
      src/main/java/com/teaching/backend/model/entity/records/KnowledgeLearningRecord.java
  45. 47
      src/main/java/com/teaching/backend/model/entity/records/RecordKnowledgeFinish.java
  46. 50
      src/main/java/com/teaching/backend/model/entity/records/RecordResourceFinish.java
  47. 2
      src/main/java/com/teaching/backend/model/entity/records/ResourceLearningNumber.java
  48. 15
      src/main/java/com/teaching/backend/model/entity/records/ResourceLearningRecord.java
  49. 2
      src/main/java/com/teaching/backend/model/entity/umsAdmin/AdminUserDetails.java
  50. 4
      src/main/java/com/teaching/backend/model/entity/umsAdmin/UmsStudent.java
  51. 2
      src/main/java/com/teaching/backend/model/entity/umsAdmin/UmsStudentManage.java
  52. 23
      src/main/java/com/teaching/backend/model/vo/courses/CourseObjectivesVO.java
  53. 11
      src/main/java/com/teaching/backend/model/vo/courses/ObjectiveContentKnowVO.java
  54. 29
      src/main/java/com/teaching/backend/model/vo/knowtmp/KnowTmpVO.java
  55. 2
      src/main/java/com/teaching/backend/model/vo/message/CourseUserInfVO.java
  56. 4
      src/main/java/com/teaching/backend/model/vo/records/KnowledgeLearningRecordVo.java
  57. 6
      src/main/java/com/teaching/backend/model/vo/records/ResourceLearingRecordVo.java
  58. 15
      src/main/java/com/teaching/backend/service/Know/KnowService.java
  59. 2
      src/main/java/com/teaching/backend/service/KnowGraph/IKnowledgeLearningNumberService.java
  60. 29
      src/main/java/com/teaching/backend/service/cms/ICmsCategoryService.java
  61. 29
      src/main/java/com/teaching/backend/service/cms/ICmsEssayService.java
  62. 2
      src/main/java/com/teaching/backend/service/courses/ICourseLearningNumberService.java
  63. 3
      src/main/java/com/teaching/backend/service/courses/ICourseObjectivesService.java
  64. 5
      src/main/java/com/teaching/backend/service/courses/ICoursesService.java
  65. 2
      src/main/java/com/teaching/backend/service/courses/IObjectiveContentKnowService.java
  66. 2
      src/main/java/com/teaching/backend/service/courses/IObjectiveContentsService.java
  67. 84
      src/main/java/com/teaching/backend/service/impl/cms/CmsCategoryServiceImpl.java
  68. 55
      src/main/java/com/teaching/backend/service/impl/cms/CmsEssayServiceImpl.java
  69. 2
      src/main/java/com/teaching/backend/service/impl/courses/CourseLearningNumberServiceImpl.java
  70. 34
      src/main/java/com/teaching/backend/service/impl/courses/CourseObjectivesServiceImpl.java
  71. 278
      src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java
  72. 168
      src/main/java/com/teaching/backend/service/impl/courses/ObjectiveContentKnowServiceImpl.java
  73. 34
      src/main/java/com/teaching/backend/service/impl/courses/ObjectiveContentsServiceImpl.java
  74. 5
      src/main/java/com/teaching/backend/service/impl/favour/SeCourseFavourServiceImpl.java
  75. 729
      src/main/java/com/teaching/backend/service/impl/know/knowServiceImpl.java
  76. 2
      src/main/java/com/teaching/backend/service/impl/knowledge/KnowledgeLearningNumberServiceImpl.java
  77. 23
      src/main/java/com/teaching/backend/service/impl/knowtmp/KnowtmpServiceImpl.java
  78. 20
      src/main/java/com/teaching/backend/service/impl/message/MessagesServiceImpl.java
  79. 30
      src/main/java/com/teaching/backend/service/impl/message/UserInboxServiceImpl.java
  80. 28
      src/main/java/com/teaching/backend/service/impl/records/CourseLearningRecordServiceImpl.java
  81. 56
      src/main/java/com/teaching/backend/service/impl/records/KnowledgeLearningRecordServiceImpl.java
  82. 64
      src/main/java/com/teaching/backend/service/impl/records/RecordKnowledgeFinishServiceImpl.java
  83. 53
      src/main/java/com/teaching/backend/service/impl/records/RecordResourceFinishServiceImpl.java
  84. 20
      src/main/java/com/teaching/backend/service/impl/records/ResourceLearningRecordServiceImpl.java
  85. 7
      src/main/java/com/teaching/backend/service/impl/resource/ResourceServiceImpl.java
  86. 55
      src/main/java/com/teaching/backend/service/impl/umsAdmin/UmsStudentManageServiceImpl.java
  87. 10
      src/main/java/com/teaching/backend/service/impl/umsAdmin/UmsUserServiceImpl.java
  88. 4
      src/main/java/com/teaching/backend/service/knowtmp/KnowtmpService.java
  89. 3
      src/main/java/com/teaching/backend/service/records/IKnowledgeLearningRecordService.java
  90. 24
      src/main/java/com/teaching/backend/service/records/IRecordKnowledgeFinishService.java
  91. 21
      src/main/java/com/teaching/backend/service/records/IRecordResourceFinishService.java
  92. 2
      src/main/java/com/teaching/backend/service/resource/ResourceService.java
  93. 7
      src/main/java/com/teaching/backend/utils/Chapter/SheetHandler.java
  94. 26
      src/main/java/com/teaching/backend/utils/MyMetaObjectHandler.java
  95. 4
      src/main/resources/mapper/CourseLearningRecordMapper.xml
  96. 2
      src/main/resources/mapper/UmsUserMapper.xml

@ -243,6 +243,12 @@
<artifactId>httpclient</artifactId> <artifactId>httpclient</artifactId>
<version>4.5.6</version> <version>4.5.6</version>
</dependency> </dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.9</version>
</dependency>
</dependencies> </dependencies>

@ -10,7 +10,7 @@ public enum ErrorCode {
SUCCESS(200, "ok"), SUCCESS(200, "ok"),
PARAMS_ERROR(40000, "请求参数错误"), PARAMS_ERROR(40000, "请求参数错误"),
OBJECTIVE_OR_CONTENT_NOT_EXIT(40001, "目标内容id不存在"), OBJECTIVE_CONTENT_NOT_EXIT(40001, "目标内容不存在"),
KONWID_NOT_EXIT(40002, "没有选择知识点"), KONWID_NOT_EXIT(40002, "没有选择知识点"),
OBJECTIVE_OR_CONTENT_EXIT(40003, "该记录已存在"), OBJECTIVE_OR_CONTENT_EXIT(40003, "该记录已存在"),
KNOW_NOT_EXIT(40004, "知识点不存在"), KNOW_NOT_EXIT(40004, "知识点不存在"),
@ -26,7 +26,8 @@ public enum ErrorCode {
NO_AUTH_ERROR(40101, "无权限"), NO_AUTH_ERROR(40101, "无权限"),
NOT_FOUND_ERROR(40400, "请求数据不存在"), NOT_FOUND_ERROR(40400, "请求数据不存在"),
CONTENT_EXISTS(41000, "内容存在"), CONTENT_EXISTS(41000, "内容存在"),
STUDENT_ROLE_CANT_MULTIPLESEND(41001, "学生用户不能群发,只能单发"),
LEAST_ONE_USER(41002, "最少选择一个用户"),
KNOWS_EXISTS(41001, "存在关联的知识点"), KNOWS_EXISTS(41001, "存在关联的知识点"),
ADD_RELATION_FAILED(41002, "添加关系失败"), ADD_RELATION_FAILED(41002, "添加关系失败"),

@ -0,0 +1,21 @@
package com.teaching.backend.controller.Know;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author:youhang
* @Date:2024-08-19-15:41
* @Description:
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Edge {
private String source;
private String target;
private String type;
private Integer sta; // 1 课程-章节 2 章节 - 章节 3 章节 - 知识点 4 点 - 点
}

@ -0,0 +1,38 @@
package com.teaching.backend.controller.Know;
import lombok.Data;
import java.io.Serializable;
@Data
public class KnowChapterVO implements Serializable {
/**
* 章节id
*/
private Long chapterId;
/**
* 知识点名称
*/
private String name;
/**
* 信息
*/
private String info;
/**
* 学时
*/
private double hour;
}

@ -7,6 +7,7 @@ package com.teaching.backend.controller.Know;
*/ */
import com.teaching.backend.common.BaseResponse; import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.mapper.know.KnowRepository;
import com.teaching.backend.model.dto.Know.*; import com.teaching.backend.model.dto.Know.*;
import com.teaching.backend.model.entity.know.Know; import com.teaching.backend.model.entity.know.Know;
import com.teaching.backend.model.entity.know.KnowChapter; import com.teaching.backend.model.entity.know.KnowChapter;
@ -22,12 +23,48 @@ import java.util.Set;
@RestController @RestController
@RequestMapping("/knowNeo") @RequestMapping("/api/knowNeo")
public class KnowController { public class KnowController {
@Autowired @Autowired
private KnowService knowService; private KnowService knowService;
@Autowired
private KnowRepository knowRepository;
//返回2层知识点
@GetMapping("/twoLevelKnows")
BaseResponse<BaseKnowReturn> getTwoLevelKnows(@RequestParam Long id){
return knowService.getTwoLevelKnows(id);
}
//返回3层知识点
@GetMapping("/threeLevelKnows")
BaseResponse<BaseKnowReturn> getThreeLevelKnows(@RequestParam Long id){
return knowService.getThreeLevelKnows(id);
}
//返回4层知识点
@GetMapping("/fourLevelKnows")
BaseResponse<BaseKnowReturn> getFourLevelKnows(@RequestParam Long id){
return knowService.getFourLevelKnows(id);
}
//通过courseId 显示图的JSON
@GetMapping("/test")
void test(@RequestParam String courseId){
int res = knowRepository.addCourseRelationship(courseId,932L,"related");
}
//通过courseId 显示图的JSON
@GetMapping("/showGraphJson")
BaseResponse<String> showGraphJson(@RequestParam String courseId){
return knowService.showGraphJson(courseId);
}
// 添加全部知识点 // 添加全部知识点
@PostMapping("/addAllKnow") @PostMapping("/addAllKnow")
BaseResponse<String> addAllKnow(@RequestParam String courseId){ BaseResponse<String> addAllKnow(@RequestParam String courseId){
@ -42,11 +79,11 @@ public class KnowController {
//=================== //===================
// 添加知识点 // // 添加知识点
@PostMapping("/addKnow") // @PostMapping("/addKnow")
BaseResponse<String> addKnow(@RequestBody KnowRequest knowRequest){ // BaseResponse<String> addKnow(@RequestBody KnowRequest knowRequest){
return knowService.addKnow(knowRequest); // return knowService.addKnow(knowRequest);
} // }
// 修改知识点 // 修改知识点
@PostMapping("/updateKnow") @PostMapping("/updateKnow")
@ -129,4 +166,13 @@ public class KnowController {
} }
//获取二级知识图谱
@GetMapping("/getsecondKnowsById")
BaseResponse<BaseKnowReturn> getsecondKnowsById(@RequestParam Long id){
return knowService.getsecondKnowsById(id);
}
} }

@ -0,0 +1,33 @@
package com.teaching.backend.controller.Know;
import lombok.Data;
import java.io.Serializable;
@Data
public class KnowCourseVO implements Serializable {
/**
* 课程id
*/
private String courseId;
/**
* 知识点名称
*/
private String name;
/**
* 信息
*/
private String info;
private double hour;
}

@ -0,0 +1,42 @@
package com.teaching.backend.controller.Know;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class KnowJson implements Serializable {
/**
* mysql 知识点id
*/
private Long knowId;
/**
* 知识点名称
*/
private String name;
/**
* 信息
*/
private String info;
/**
* 学时
*/
private double hour;
}

@ -0,0 +1,31 @@
package com.teaching.backend.controller.Know;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.List;
public class KnowJsonListVO implements Serializable {
private List<KnowJson> knowJsonList;
public List<KnowJson> KnowJsonListVO() {
return knowJsonList;
}
public void setKnowJsonList(List<KnowJson> knowJsonList) {
this.knowJsonList = knowJsonList;
}
public List<KnowJson> getKnowJsonList() {
return this.knowJsonList ;
}
}

@ -1,6 +1,7 @@
package com.teaching.backend.controller.Knowtmp; package com.teaching.backend.controller.Knowtmp;
import com.teaching.backend.common.BaseResponse; import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.model.dto.Know.BaseKnowReturn;
import com.teaching.backend.model.dto.Knowtmp.KnowtempAdd; import com.teaching.backend.model.dto.Knowtmp.KnowtempAdd;
import com.teaching.backend.model.dto.Knowtmp.KnowtempUpdate; import com.teaching.backend.model.dto.Knowtmp.KnowtempUpdate;
import com.teaching.backend.model.entity.knowtmp.Knowtmp; import com.teaching.backend.model.entity.knowtmp.Knowtmp;
@ -22,6 +23,14 @@ public class KnowtmpController {
@Autowired @Autowired
private KnowtmpService knowtmpService; private KnowtmpService knowtmpService;
//返回课程下所有知识点
@GetMapping("/getAllKnows")
BaseResponse<Long> getAllKnows(@RequestParam String courseId){
return knowtmpService.getAllKnows(courseId);
}
// 添加知识点 // 添加知识点
@PostMapping("/addKnow") @PostMapping("/addKnow")

@ -32,7 +32,7 @@ import java.util.List;
*/ */
@Api(tags = "课程章节管理接口2") @Api(tags = "课程章节管理接口2")
@RestController @RestController
@RequestMapping("/chapter2") @RequestMapping("/api/chapter2")
public class ChapterController2 { public class ChapterController2 {
@Autowired @Autowired

@ -0,0 +1,76 @@
package com.teaching.backend.controller.cms;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.model.entity.cms.CmsCategory;
import com.teaching.backend.model.entity.cms.CmsEssay;
import com.teaching.backend.service.impl.cms.CmsCategoryServiceImpl;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* <p>
* 前端控制器
* </p>
*
* @author author
* @since 2024-08-13
*/
@Api(tags = "栏目管理")
@RestController
@RequestMapping("/api/cms-category")
public class CmsCategoryController {
@Resource
private CmsCategoryServiceImpl cmsCategoryService;
/**
* 添加栏目
* @param cmsCategory
* @return
*/
@PostMapping("/add")
public BaseResponse<String> addCategory(CmsCategory cmsCategory){
return cmsCategoryService.addCategory(cmsCategory);
}
/**'
* 删除栏目
* @param ids
* @return
*/
@DeleteMapping("/delete")
public BaseResponse<String> deleteCategory(@RequestParam List<Integer> ids){
return cmsCategoryService.deleteCategory(ids);
}
/**
* 编辑栏目
* @param cmsCategory
* @return
*/
@PutMapping("/edit")
public BaseResponse<String> editCategory(CmsCategory cmsCategory){
return cmsCategoryService.editCategory(cmsCategory);
}
/**
* 查询栏目
* @return
*/
@GetMapping("/query")
public BaseResponse<List<?>> queryCategory(){
return cmsCategoryService.queryCategory();
}
/**
* 修改显示状态
* @param cmsCategory
* @return
*/
@PutMapping("/edit/status")
public BaseResponse<String> editStatus(CmsCategory cmsCategory){
return cmsCategoryService.editStatus(cmsCategory);
}
}

@ -0,0 +1,80 @@
package com.teaching.backend.controller.cms;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.model.entity.cms.CmsCategory;
import com.teaching.backend.model.entity.cms.CmsEssay;
import com.teaching.backend.service.impl.cms.CmsEssayServiceImpl;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* <p>
* 前端控制器
* </p>
*
* @author author
* @since 2024-08-13
*/
@Api(tags = "文章管理")
@RestController
@RequestMapping("/api/cms-essay")
public class CmsEssayController {
@Resource
private CmsEssayServiceImpl cmsEssayService;
/**
* 添加文章
* @param cmsEssay
* @return
*/
@PostMapping("/add")
public BaseResponse<String> addEssay(CmsEssay cmsEssay){
return cmsEssayService.addEssay(cmsEssay);
}
/**
* 删除文章
* @param ids
* @return
*/
@DeleteMapping("/delete")
public BaseResponse<String> deleteEssay(@RequestParam List<Integer> ids){
return cmsEssayService.deleteEssay(ids);
}
/**
* 编辑文章
* @param cmsEssay
* @return
*/
@PutMapping("/edit")
public BaseResponse<String> editEssay(@RequestBody CmsEssay cmsEssay){
System.out.println(cmsEssay);
return cmsEssayService.editEssay(cmsEssay);
}
/**
* 查询文章
* @param category_id
* @return
*/
@GetMapping("/query")
public BaseResponse<List<?>> queryEssay(Integer category_id){
return cmsEssayService.queryEssay(category_id);
}
/**
* 取消发布
* @param cmsEssay
* @return
*/
@PutMapping("/edit/status")
public BaseResponse<String> editStatus(CmsEssay cmsEssay){
return cmsEssayService.editStatus(cmsEssay);
}
}

@ -9,6 +9,7 @@ import com.teaching.backend.mapper.courses.CourseObjectivesMapper;
import com.teaching.backend.model.dto.courses.CourseObjectivesDTO; import com.teaching.backend.model.dto.courses.CourseObjectivesDTO;
import com.teaching.backend.model.entity.courses.CourseObjectives; import com.teaching.backend.model.entity.courses.CourseObjectives;
import com.teaching.backend.model.vo.courses.CourseObjectivesTreeVO; 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.service.courses.ICourseObjectivesService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -76,5 +77,12 @@ public class CourseObjectivesController {
return ResultUtils.success(courseObjectivesTreeVO); return ResultUtils.success(courseObjectivesTreeVO);
} }
@ApiOperation("列表显示分项目标(用于添加目标内容时选择)")
@GetMapping("/objectiveslist/{courseId}")
public BaseResponse<List<CourseObjectivesVO>> queryCourseObjectivesForAdd(@PathVariable String courseId){
List<CourseObjectivesVO> courseObjectivesVOS = courseObjectivesService.queryCourseObjectivesForAdd(courseId);
return ResultUtils.success(courseObjectivesVOS);
}
} }

@ -31,11 +31,11 @@ public class ObjectiveContentKnowController {
IObjectiveContentKnowService objectiveContentKnowService; IObjectiveContentKnowService objectiveContentKnowService;
@ApiOperation("给分项目标或者是内容添加知识点") @ApiOperation("给知识点关联--目标内容")
// @ValidateParams({"objectiveId","know"}) @ValidateParams({"objectiveContentId","knowId"})
@PostMapping("/addknows") @PostMapping("/addknows")
public BaseResponse<String> saveKnowsWithObjectiveOrContent(@RequestBody ObjectiveContentKnowDTO objectiveContentKnowDTO){ public BaseResponse<String> saveKnowsWithObjectiveContent(@RequestBody ObjectiveContentKnowDTO objectiveContentKnowDTO){
String data = objectiveContentKnowService.saveKnowsWithObjectiveOrContent(objectiveContentKnowDTO); String data = objectiveContentKnowService.saveKnowsWithObjectiveContent(objectiveContentKnowDTO);
return ResultUtils.success(data); return ResultUtils.success(data);
} }

@ -31,8 +31,8 @@ public class ObjectiveContentsController {
@ValidateParams({"objectiveId"}) @ValidateParams({"objectiveId"})
@PostMapping("/addcontent") @PostMapping("/addcontent")
public BaseResponse<String> saveContent(@RequestBody ObjectiveContents objectiveContents){ public BaseResponse<String> saveContent(@RequestBody ObjectiveContents objectiveContents){
objectiveContentsService.save(objectiveContents); String data = objectiveContentsService.saveWithCheck(objectiveContents);
return ResultUtils.success("添加成功"); return ResultUtils.success(data);
} }
@ApiOperation("删除目标内容") @ApiOperation("删除目标内容")

@ -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);
}
} }

@ -22,7 +22,7 @@ import java.util.Set;
@RestController @RestController
@RequestMapping("/resource") @RequestMapping("/api/resource")
public class ResourceController { public class ResourceController {
@Autowired @Autowired
@ -47,6 +47,7 @@ public class ResourceController {
public ResponseEntity<InputStreamResource> readFile(@RequestParam String filename) { public ResponseEntity<InputStreamResource> readFile(@RequestParam String filename) {
return resourceService.readFile(filename); return resourceService.readFile(filename);
} }
@GetMapping("/addRelationship/BetweenCourseAndResources") @GetMapping("/addRelationship/BetweenCourseAndResources")
public BaseResponse<String> addResourcesAndKnowByCourseId(@RequestParam String courseId, @RequestParam List<Long> resourcesIds){ public BaseResponse<String> addResourcesAndKnowByCourseId(@RequestParam String courseId, @RequestParam List<Long> resourcesIds){
return resourceService.addResourcesAndKnowByCourseId(courseId,resourcesIds); return resourceService.addResourcesAndKnowByCourseId(courseId,resourcesIds);
@ -77,6 +78,11 @@ public class ResourceController {
BaseResponse<Set<Resources>> queryBesidesKnowToResources(@RequestParam Long KnowId){ BaseResponse<Set<Resources>> queryBesidesKnowToResources(@RequestParam Long KnowId){
return resourceService.queryBesidesKnowToResources(KnowId); return resourceService.queryBesidesKnowToResources(KnowId);
} }
//查询知识点下资源
@GetMapping("/queryResourcesByKnowId")
BaseResponse<Set<Resources>> queryResourcesByKnowId(@RequestParam Long KnowId){
return resourceService.queryResourcesByKnowId(KnowId);
}

@ -1,7 +1,7 @@
package com.teaching.backend.controller.umsAdmin; package com.teaching.backend.controller.umsAdmin;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.common.CommonResult; import com.teaching.backend.common.CommonResult;
import com.teaching.backend.filter.ValidateParams;
import com.teaching.backend.model.dto.umsAdmin.UmsStudentPageQueryDTO; import com.teaching.backend.model.dto.umsAdmin.UmsStudentPageQueryDTO;
import com.teaching.backend.model.entity.umsAdmin.UmsStudentManage; import com.teaching.backend.model.entity.umsAdmin.UmsStudentManage;
import com.teaching.backend.service.umsAdmin.UmsStudentManageService; import com.teaching.backend.service.umsAdmin.UmsStudentManageService;
@ -11,7 +11,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -30,6 +29,7 @@ public class UmsStudentManageController {
* @return * @return
*/ */
@GetMapping("/page") @GetMapping("/page")
@ValidateParams({"page","pageSize", "userId"}) // 需要校验的参数
@ApiOperation("学生管理分页查询") @ApiOperation("学生管理分页查询")
public CommonResult<Map<String, Object>> page(UmsStudentPageQueryDTO umsStudentPageQueryDTO){ public CommonResult<Map<String, Object>> page(UmsStudentPageQueryDTO umsStudentPageQueryDTO){
Map<String, Object> pageResult = umsStudentManageService.pageQuery(umsStudentPageQueryDTO); Map<String, Object> pageResult = umsStudentManageService.pageQuery(umsStudentPageQueryDTO);

@ -2,7 +2,7 @@ package com.teaching.backend.mapper.KnowGraph;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.teaching.backend.model.entity.KnowGraph.KnowledgeLearningNumber; import com.teaching.backend.model.entity.records.KnowledgeLearningNumber;
/** /**
* <p> * <p>

@ -2,7 +2,11 @@ package com.teaching.backend.mapper.Knowtemp;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.teaching.backend.model.entity.knowtmp.Knowtmp; import com.teaching.backend.model.entity.knowtmp.Knowtmp;
import io.lettuce.core.dynamic.annotation.Param;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/** /**
@ -11,6 +15,10 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper @Mapper
public interface KnowtmpMapper extends BaseMapper<Knowtmp> { public interface KnowtmpMapper extends BaseMapper<Knowtmp> {
@Select("SELECT * FROM Knowtmp WHERE chapterid = #{chapterId} ORDER BY ordernum")
List<Knowtmp> queryIdByChapterId(@Param("chapterid") Long chapterId);
} }

@ -22,6 +22,24 @@ public interface ChapterMapper extends BaseMapper<Chapter> {
@Select("SELECT * FROM chapter WHERE course_id = #{courseId}") @Select("SELECT * FROM chapter WHERE course_id = #{courseId}")
List<Chapter> selectSectionsByCourseId(@Param("courseId") String courseId); List<Chapter> selectSectionsByCourseId(@Param("courseId") String courseId);
@Select("SELECT id FROM chapter WHERE course_id = #{courseId}")
List<Long> selectChapterIdsByCourseId(@Param("courseId") String courseId);
@Select("SELECT * FROM chapter WHERE course_id = #{courseId} ORDER BY order_num")
List<Chapter> selectSectionsOrderByNumByCourseId(@Param("courseId") String courseId);
@Select("SELECT * FROM chapter WHERE course_id = #{courseId} AND pid = 0 ORDER BY order_num")
List<Chapter> selectChapterPIDByCourseId(@Param("courseId") String courseId);
@Select("SELECT * FROM chapter WHERE pid = #{parentId} ORDER BY order_num")
List<Chapter> selectChapterChildrenOrderByNum(@Param("parentId") Long parentId);
@Select("SELECT id FROM chapter WHERE pid = #{chapterId} ORDER BY order_num")
List<Integer> selectSectionsOrderByNumByChapterId(@Param("pid") Integer chapterId);
@Select("SELECT * FROM course_chapter WHERE course_id = #{courseId} AND (pid = #{parentId} )") @Select("SELECT * FROM course_chapter WHERE course_id = #{courseId} AND (pid = #{parentId} )")
List<Chapter> selectSectionsWithChildren(@Param("courseId") String courseId, @Param("parentId") String parentId); List<Chapter> selectSectionsWithChildren(@Param("courseId") String courseId, @Param("parentId") String parentId);
@Select("SELECT * FROM chapter WHERE id = #{excelId}") @Select("SELECT * FROM chapter WHERE id = #{excelId}")

@ -0,0 +1,17 @@
package com.teaching.backend.mapper.cms;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.teaching.backend.model.entity.cms.CmsCategory;
/**
* <p>
* Mapper 接口
* </p>
*
* @author author
* @since 2024-08-13
*/
public interface CmsCategoryMapper extends BaseMapper<CmsCategory> {
}

@ -0,0 +1,17 @@
package com.teaching.backend.mapper.cms;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.teaching.backend.model.entity.cms.CmsEssay;
/**
* <p>
* Mapper 接口
* </p>
*
* @author author
* @since 2024-08-13
*/
public interface CmsEssayMapper extends BaseMapper<CmsEssay> {
}

@ -2,7 +2,7 @@ package com.teaching.backend.mapper.courses;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.teaching.backend.model.entity.courses.CourseLearningNumber; import com.teaching.backend.model.entity.records.CourseLearningNumber;
/** /**
* <p> * <p>

@ -7,22 +7,31 @@ package com.teaching.backend.mapper.know;
*/ */
import com.teaching.backend.model.entity.courses.Courses;
import com.teaching.backend.model.entity.know.Know; import com.teaching.backend.model.entity.know.Know;
import com.teaching.backend.model.entity.know.KnowChapter; import com.teaching.backend.model.entity.know.KnowChapter;
import com.teaching.backend.model.entity.know.KnowCourse; import com.teaching.backend.model.entity.know.KnowCourse;
import com.teaching.backend.model.entity.resource.Resources; import com.teaching.backend.model.entity.resource.Resources;
import org.springframework.data.neo4j.repository.Neo4jRepository; import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.neo4j.repository.query.Query; import org.springframework.data.neo4j.repository.query.Query;
import org.springframework.data.repository.query.Param;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
public interface KnowRepository extends Neo4jRepository<Know, Long> { public interface KnowRepository extends Neo4jRepository<Know, Long> {
@Query("MATCH (p:Know)-[:FatherAndSon]->(n:Know) WHERE p.chapterId = $chapterId RETURN p.id ORDER BY ordernum;")
List<Long>queryKnowIdByChapterId(Long chapterId);
//====================== //======================
@Query("CREATE (n:Know {name: $name,info:$info}) return n;") @Query("CREATE (n:Know {knowId: $KnowId,name: $name,info:$info,hour:$hour}) return ID(n);")
Know addKnow(String name,String info); Long addKnow(Long KnowId,String name,String info,double hour);
@Query("MATCH ID(p:Know) = $id SET p.name = $name set p.info= $info RETURN count(p);") @Query("MATCH ID(p:Know) = $id SET p.name = $name set p.info= $info RETURN count(p);")
@ -36,8 +45,8 @@ public interface KnowRepository extends Neo4jRepository<Know, Long> {
//============================= //=============================
@Query("CREATE (n:Know {name: $name, courseId: $courseId,info:$info,hour:$hour}) return count(n)") @Query("CREATE (n:Know {name: $name, courseId: $courseId,info:$info,hour:$hour}) return ID(n) as id")
int addCourse(String courseId, String name, String info,double hour); Long addCourse(String courseId, String name, String info, double hour);
@Query("MATCH (p:Know {courseId:$courseId }) SET p.name = $name set p.info= $info RETURN count(p);") @Query("MATCH (p:Know {courseId:$courseId }) SET p.name = $name set p.info= $info RETURN count(p);")
int updateCourse(String courseId, String name, String info); int updateCourse(String courseId, String name, String info);
@ -50,8 +59,8 @@ public interface KnowRepository extends Neo4jRepository<Know, Long> {
//==================== //====================
@Query("CREATE (n:Know {name: $name, chapterId:$chapterId,info:$info,hour:$hour}) return count(n)") @Query("CREATE (n:Know {name: $name, chapterId:$chapterId,info:$info,hour:$hour}) return ID(n)")
int addChapter(Long chapterId, String name, String info,double hour); Long addChapter(Long chapterId, String name, String info,double hour);
@Query("MATCH (p:Know {chapterId:$chapterId }) SET p.name = $name set p.info= $info RETURN count(p);") @Query("MATCH (p:Know {chapterId:$chapterId }) SET p.name = $name set p.info= $info RETURN count(p);")
int updateChapter(Long chapterId, String name, String info); int updateChapter(Long chapterId, String name, String info);
@ -67,18 +76,47 @@ public interface KnowRepository extends Neo4jRepository<Know, Long> {
Set<Resources> queryBesidesKnowToResources(Long id); Set<Resources> queryBesidesKnowToResources(Long id);
//建立关系 课程 - 章节 //建立关系 课程 - 章节
@Query("MATCH (p:Know {courseId: $courseId}), (c:Know {chapterId: $chapterId}) CREATE (p)-[r:FatherAndSon]->(c) return count(r);") @Query("MATCH (p:Know {courseId: $courseId}), (c:Know {chapterId: $chapterId}) CREATE (p)-[r:contain]->(c) return count(r);")
int addFatherAndSonWithCourse(String courseId,Long chapterId); int addContainWithCourse(String courseId,Long chapterId);
//建立关系 章节与章节 //建立关系 章节与章节
@Query("MATCH (p:Know {chapterId: $chapterId1}), (c:Know {chapterId: $chapterId2}) CREATE (c)-[r:FatherAndSon]->(p) return count(r);") @Query("MATCH (p:Know {chapterId: $chapterId1}), (c:Know {chapterId: $chapterId2}) CREATE (c)-[r:contain]->(p) return count(r);")
int addFatherAndSonWithChapter(Long chapterId1,Long chapterId2); int addContainWithChapter(Long chapterId1,Long chapterId2);
//建立关系 章节与知识点 //建立关系 章节与知识点
@Query("MATCH (p:Know), (j:Know) WHERE p.chapterId= $chapterId AND ID(j) = $id CREATE (p)-[r:FatherAndSon]->(j) return count(r);") @Query("MATCH (p:Know), (j:Know) WHERE p.chapterId= $chapterId AND ID(j) = $id CREATE (p)-[r:contain]->(j) return count(r);")
int addFatherAndSonWithKnow(Long id,Long chapterId); int addContainWithKnow(Long id,Long chapterId);
@Query("MATCH (p:Know), (c:Resources) WHERE ID(p) = $id AND ID(c) = $ResourcesId CREATE (p)-[r:resources]->(c) return count(r)") @Query("MATCH (p:Know), (c:Resources) WHERE ID(p) = $id AND ID(c) = $ResourcesId CREATE (p)-[r:resources]->(c) return count(r)")
int addResourceResourcesKnow(Long id, Long ResourcesId); int addResourceResourcesKnow(Long id, Long ResourcesId);
//建立关系 章节与章节 顺序 Subsequent
@Query("MATCH (p:Know), (j:Know) WHERE ID(p) = $chapterId1 AND ID(j)= $chapterId2 CREATE (p)-[r:Subsequent]->(j) return count(r);")
int addSubsequentByChapterId(Long chapterId1,Long chapterId2);
//建立关系 章节与章节 顺序 Subsequent
@Query("MATCH (p:Know), (j:Know) WHERE ID(p)= $id1 AND ID(j)= $id2 CREATE (p)-[r:order]->(j) return count(r);")
int addOrderById(Long id1,Long id2);
//==========
//建立关系 all -课程
@Query("MATCH (p:Know {courseId: $courseId}), (j:Know {chapterId: $chapterId}) CREATE (p)-[r:顺序]->(j) return count(p);")
int addCourseRelationship(String courseId,Long chapterId,String type);
//建立关系 all -章节
@Query("MATCH (p:Know), (j:Know) WHERE p.chapterId= $chapterId1 AND ID(j)= $chapterId2 CREATE (p)-[r: "+"$type"+"]->(j) return count(r);")
int addChapterRelationship(Long chapterId1, Long chapterId2, @Param("type")String type);
//建立关系 all -节 - 点
@Query("MATCH (p:Know), (j:Know) WHERE p.chapterId= $chapterId AND j.knowId= $knowId CREATE (p)-[r: $type]->(j) return count(r);")
int addChapterToKnowRelationship(Long chapterId,Long knowId,String type);
//建立关系 all - 知识点
@Query("MATCH (p:Know), (j:Know) WHERE p.knowId= $knowId1 AND j.knowId = $knowId2 CREATE (p)-[r: $type]->(j) return count(r);")
int addKnowRelationship(Long knowId1,Long knowId2,String type);
} }

@ -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);
} }

@ -20,7 +20,7 @@ import java.util.List;
*/ */
public interface KnowledgeLearningRecordMapper extends BaseMapper<KnowledgeLearningRecord> { public interface KnowledgeLearningRecordMapper extends BaseMapper<KnowledgeLearningRecord> {
@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<String > selectDistinctKnowledgeIdsByUser(@Param("userId") String userId); List<String > selectDistinctKnowledgeIdsByUser(@Param("userId") String userId);
List<String> queryStudyKnowledgeMaxNumber(); List<String> queryStudyKnowledgeMaxNumber();

@ -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;
/**
* <p>
* Mapper 接口
* </p>
*
* @author author
* @since 2024-08-20
*/
public interface RecordKnowledgeFinishMapper extends BaseMapper<RecordKnowledgeFinish> {
}

@ -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;
/**
* <p>
* Mapper 接口
* </p>
*
* @author author
* @since 2024-08-20
*/
public interface RecordResourceFinishMapper extends BaseMapper<RecordResourceFinish> {
}

@ -45,6 +45,10 @@ public interface ResourcesRepository extends Neo4jRepository<Resources, Long> {
@Query("MATCh (p:Know)-[*0..1]->(n:Know)-[:resources]->(m:Resources) WHERE ID(p) = $KnowId RETURN m") @Query("MATCh (p:Know)-[*0..1]->(n:Know)-[:resources]->(m:Resources) WHERE ID(p) = $KnowId RETURN m")
Set<Resources> queryBesidesKnowToResources(Long KnowId); Set<Resources> queryBesidesKnowToResources(Long KnowId);
//
@Query("MATCH (p)-[r:resources]->(c) WHERE ID(p) = $KnowId RETURN c")
Set<Resources> queryResourcesByKnowId(Long KnowId);

@ -14,6 +14,6 @@ import com.teaching.backend.model.entity.umsAdmin.UmsStudent;
public interface UmsStudentMapper extends BaseMapper<UmsStudent> { public interface UmsStudentMapper extends BaseMapper<UmsStudent> {
boolean updateStudentInfo(UmsStudent umsStudent); boolean updateStudentInfo(UmsStudent umsStudent);
UmsStudent selectByUserId(Integer userId); UmsStudent selectByUserId(Long userId);
} }

@ -1,7 +1,6 @@
package com.teaching.backend.mapper.umsAdmin; package com.teaching.backend.mapper.umsAdmin;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.teaching.backend.model.entity.courses.StudentCourses;
import com.teaching.backend.model.entity.umsAdmin.UmsRole; import com.teaching.backend.model.entity.umsAdmin.UmsRole;
import com.teaching.backend.model.entity.umsAdmin.UmsTeacher; import com.teaching.backend.model.entity.umsAdmin.UmsTeacher;
import com.teaching.backend.model.entity.umsAdmin.UmsUser; import com.teaching.backend.model.entity.umsAdmin.UmsUser;
@ -19,5 +18,5 @@ public interface UmsUserMapper extends BaseMapper<UmsUser> {
UmsStudentVO getByIdStudent(String id); UmsStudentVO getByIdStudent(String id);
String getbyIdRoleId(String userId); String getByIdRoleId(String userId);
} }

@ -20,7 +20,7 @@ import java.io.Serializable;
* @since 2024-06-13 * @since 2024-06-13
*/ */
@Data @Data
@ApiModel(description = "分项目标内容添加知识点") @ApiModel(description = "目标内容添加知识点")
public class ObjectiveContentKnowDTO extends ObjectiveContentKnow { public class ObjectiveContentKnowDTO extends ObjectiveContentKnow {
} }

@ -10,6 +10,7 @@ import lombok.experimental.Accessors;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List;
/** /**
* <p> * <p>
@ -122,5 +123,5 @@ public class UmsStudentAndTeacherDTO implements Serializable {
/** /**
* role_id * role_id
*/ */
private Integer roleId; private List<String> roleId;
} }

@ -0,0 +1,67 @@
package com.teaching.backend.model.entity.cms;
import com.baomidou.mybatisplus.annotation.*;
import java.time.LocalDateTime;
import java.io.Serializable;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
/**
* <p>
*
* </p>
*
* @author author
* @since 2024-08-13
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("cms_category")
@ApiModel(value="CmsCategory对象", description="")
public class CmsCategory implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "栏目id")
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@ApiModelProperty(value = "栏目名称")
private String categoryName;
@ApiModelProperty(value = "创建该栏目的用户id")
private String creatorId;
@ApiModelProperty(value = "栏目父id(若为一级栏目则父id等于栏目id)")
private Integer categoryPid;
@ApiModelProperty(value = "排序")
private Integer sort;
@ApiModelProperty(value = "是否显示")
private Integer status;
@ApiModelProperty(value = "创建时间")
@TableField(fill = FieldFill.INSERT)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "Asia/Shanghai")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
@ApiModelProperty(value = "更新时间")
@TableField(fill = FieldFill.INSERT_UPDATE)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "Asia/Shanghai")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;
@TableField(exist = false)
private List<CmsCategory> childrenNode;
}

@ -0,0 +1,75 @@
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;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
/**
* <p>
*
* </p>
*
* @author author
* @since 2024-08-13
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("cms_essay")
@ApiModel(value="CmsEssay对象", description="")
public class CmsEssay implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "文章id")
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@ApiModelProperty(value = "文章标题")
private String title;
@ApiModelProperty(value = "标题图片")
private String pic;
@ApiModelProperty(value = "文章内容")
private String content;
@ApiModelProperty(value = "发布时间")
@JsonFormat (locale= "zh", timezone= "GMT+8", pattern= "yyyy-MM-dd")
private LocalDate publishTime;
@ApiModelProperty(value = "浏览次数")
private Integer readingNumber;
@ApiModelProperty(value = "所属栏目id")
private Integer categoryId;
@ApiModelProperty(value = "发布文章的用户id")
private Integer userId;
@ApiModelProperty(value = "文章文件")
private String file;
@ApiModelProperty(value = "发布状态: 1: 已发布; 2未发布")
private Integer status;
@ApiModelProperty(value = "更新时间")
@TableField(fill = FieldFill.INSERT_UPDATE)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "Asia/Shanghai")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;
}

@ -38,12 +38,14 @@ public class ObjectiveContentKnow implements Serializable {
/** /**
* 分项目标或内容 id * 分项目标或内容 id
*/ */
private String objectiveOrContent; // private String objectiveOrContent;
private String objectiveContentId;
/** /**
* 关联的知识点 * 关联的知识点
*/ */
private String know; // private String know;
private Integer knowId;
} }

@ -36,8 +36,6 @@ public class ObjectiveContents implements Serializable {
@ApiModelProperty(value = "内容",required = true) @ApiModelProperty(value = "内容",required = true)
private String content; private String content;
@ApiModelProperty(value = "排序字段",required = true) @ApiModelProperty(value = "排序字段")
private Float orderNum; private Float orderNum;
} }

@ -36,5 +36,4 @@ public class Knowtmp implements Serializable {
private double hour; private double hour;
} }

@ -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.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
@ -22,7 +22,7 @@ import lombok.experimental.Accessors;
@Data @Data
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
@Accessors(chain = true) @Accessors(chain = true)
@TableName("course_learning_number") @TableName("record_course_number")
@ApiModel(value="CourseLearningNumber对象", description="") @ApiModel(value="CourseLearningNumber对象", description="")
public class CourseLearningNumber implements Serializable { public class CourseLearningNumber implements Serializable {
@ -36,6 +36,10 @@ public class CourseLearningNumber implements Serializable {
@TableField("course_id") @TableField("course_id")
private String courseId; private String courseId;
@ApiModelProperty(value = "老师用户id")
@TableField("teacher_user_id")
private String teacherUserId;
@ApiModelProperty(value = "课程学习人数") @ApiModelProperty(value = "课程学习人数")
@TableField("number") @TableField("number")
private Integer number; private Integer number;

@ -23,7 +23,7 @@ import lombok.experimental.Accessors;
@Data @Data
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
@Accessors(chain = true) @Accessors(chain = true)
@TableName("course_learning_record") @TableName("record_course_learning")
@ApiModel(value="CourseLearningRecord对象", description="") @ApiModel(value="CourseLearningRecord对象", description="")
public class CourseLearningRecord implements Serializable { public class CourseLearningRecord implements Serializable {
@ -54,6 +54,10 @@ public class CourseLearningRecord implements Serializable {
@TableField("img") @TableField("img")
private String img; private String img;
@ApiModelProperty(value = "老师用户id")
@TableField("teacher_user_id")
private String teacherUserId;
@ApiModelProperty(value = "最近学习时间") @ApiModelProperty(value = "最近学习时间")
@TableField("times") @TableField("times")
private LocalDateTime times; private LocalDateTime times;

@ -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.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
@ -22,7 +22,7 @@ import lombok.experimental.Accessors;
@Data @Data
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
@Accessors(chain = true) @Accessors(chain = true)
@TableName("knowledge_learning_number") @TableName("record_knowledge_number")
@ApiModel(value="KnowledgeLearningNumber对象", description="") @ApiModel(value="KnowledgeLearningNumber对象", description="")
public class KnowledgeLearningNumber implements Serializable { public class KnowledgeLearningNumber implements Serializable {

@ -23,7 +23,7 @@ import lombok.experimental.Accessors;
@Data @Data
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
@Accessors(chain = true) @Accessors(chain = true)
@TableName("knowledge_learning_record") @TableName("record_knowledge_learning")
@ApiModel(value="KnowledgeLearningRecord对象", description="") @ApiModel(value="KnowledgeLearningRecord对象", description="")
public class KnowledgeLearningRecord implements Serializable { public class KnowledgeLearningRecord implements Serializable {
@ -61,5 +61,9 @@ public class KnowledgeLearningRecord implements Serializable {
@TableField("times") @TableField("times")
private LocalDateTime times; private LocalDateTime times;
@ApiModelProperty(value = "完成状态")
@TableField("finish")
private Integer finish;
} }

@ -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;
/**
* <p>
*
* </p>
*
* @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;
}

@ -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;
/**
* <p>
*
* </p>
*
* @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;
}

@ -21,7 +21,7 @@ import lombok.experimental.Accessors;
@Data @Data
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
@Accessors(chain = true) @Accessors(chain = true)
@TableName("resource_learning_number") @TableName("record_resource_number")
@ApiModel(value="ResourceLearningNumber对象", description="") @ApiModel(value="ResourceLearningNumber对象", description="")
public class ResourceLearningNumber implements Serializable { public class ResourceLearningNumber implements Serializable {

@ -23,7 +23,7 @@ import lombok.experimental.Accessors;
@Data @Data
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
@Accessors(chain = true) @Accessors(chain = true)
@TableName("resource_learning_record") @TableName("record_resource_learning")
@ApiModel(value="ResourceLearningRecord对象", description="") @ApiModel(value="ResourceLearningRecord对象", description="")
public class ResourceLearningRecord implements Serializable { public class ResourceLearningRecord implements Serializable {
@ -67,19 +67,22 @@ public class ResourceLearningRecord implements Serializable {
@ApiModelProperty(value = "学习时长") @ApiModelProperty(value = "学习时长")
@TableField("duration") @TableField("duration")
private Integer duration; private double duration;
@ApiModelProperty(value = "总时长")
@TableField("total_duration")
private double totalDuration;
@ApiModelProperty(value = "是否完成观看") @ApiModelProperty(value = "是否完成观看")
@TableField("finish") @TableField("finish")
private Integer finish; private Integer finish;
@ApiModelProperty(value = "记录封面")
@TableField("img")
private String img;
@ApiModelProperty(value = "最近学习时间") @ApiModelProperty(value = "最近学习时间")
@TableField("times") @TableField("times")
private LocalDateTime times; private LocalDateTime times;
@ApiModelProperty(value = "资源类型: 1:视频, 2:音频,3:文本资源,4:pdf,5:文件,6:压缩文件")
@TableField("type")
private Integer type;
} }

@ -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");
} }
} }

@ -6,6 +6,8 @@ import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable; import java.io.Serializable;
import io.swagger.models.auth.In;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
@ -60,7 +62,7 @@ public class UmsStudent implements Serializable {
private String className; private String className;
//user_id //user_id
private Integer userId; private Long userId;
} }

@ -78,7 +78,7 @@ public class UmsStudentManage implements Serializable {
private String className; private String className;
//user_id //user_id
private Integer userId; private Long userId;
} }

@ -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;
}

@ -1,5 +1,6 @@
package com.teaching.backend.model.vo.courses; package com.teaching.backend.model.vo.courses;
import com.teaching.backend.model.vo.knowtmp.KnowTmpVO;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@ -12,7 +13,7 @@ import java.util.List;
public class ObjectiveContentKnowVO { public class ObjectiveContentKnowVO {
/** /**
* 分项目标内容 id * 目标内容 id
*/ */
private String objectiveOrContent; private String objectiveOrContent;
@ -26,17 +27,17 @@ public class ObjectiveContentKnowVO {
* 关联的知识点学时合计 * 关联的知识点学时合计
*/ */
@ApiModelProperty(value = "关联的知识点学时合计") @ApiModelProperty(value = "关联的知识点学时合计")
private BigDecimal knowsTime; private Double knowsTime;
/** /**
* 关联的知识点学时占比 * 关联的知识点学时占比
*/ */
@ApiModelProperty(value = "关联的知识点学时占比") @ApiModelProperty(value = "关联的知识点学时占比")
private String persent; private Double persent;
/** /**
* 分项目标下面的内容对应的知识点数据 * 知识点的展示数据
*/ */
List<ObjectiveContentKnowVO> contentKnowsData; List<KnowTmpVO> knowTmpVOList;
} }

@ -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;
/**
* <p>
*
* </p>
*
* @author author
* @since 2024-05-31
*/
@Data
@TableName(value = "knowtmp")
public class KnowTmpVO implements Serializable {
private Long id;
private String name;
private double hour;
}

@ -13,8 +13,6 @@ public class CourseUserInfVO {
private String courseId; private String courseId;
@ApiModelProperty(value = "课程name") @ApiModelProperty(value = "课程name")
private String courseName; private String courseName;
@ApiModelProperty(value = "与课程有关的用户信息集合") @ApiModelProperty(value = "与课程有关的用户信息集合")
private List<UserReadMessageTimeVO> usersInf; private List<UserReadMessageTimeVO> usersInf;
} }

@ -34,4 +34,8 @@ public class KnowledgeLearningRecordVo {
* 学习时间 * 学习时间
*/ */
private String time; private String time;
/**
* 完成状态
*/
private Integer finish;
} }

@ -26,4 +26,10 @@ public class ResourceLearingRecordVo {
* 学习时间 * 学习时间
*/ */
private String time; private String time;
/**
* 完成状态
*/
private Integer finish;
} }

@ -18,6 +18,14 @@ import java.util.Set;
*/ */
public interface KnowService { public interface KnowService {
BaseResponse<BaseKnowReturn> getTwoLevelKnows(Long id);
BaseResponse<BaseKnowReturn> getThreeLevelKnows(Long id);
BaseResponse<BaseKnowReturn> getFourLevelKnows(Long id);
//通过courseId 显示图的JSON
BaseResponse<String> showGraphJson(String courseId);
//通过courseId 添加所有节点 //通过courseId 添加所有节点
BaseResponse<String> addAllKnow(String courseId); BaseResponse<String> addAllKnow(String courseId);
@ -27,8 +35,8 @@ public interface KnowService {
//===================== //=====================
// 添加知识点 // // 添加知识点
BaseResponse<String> addKnow(KnowRequest knowRequest); // BaseResponse<String> addKnow(KnowRequest knowRequest);
// 修改知识点 // 修改知识点
BaseResponse<String> updateKnow(KnowUpdateRequest knowUpdateRequest); BaseResponse<String> updateKnow(KnowUpdateRequest knowUpdateRequest);
@ -73,6 +81,9 @@ public interface KnowService {
//获取课程下的所有知识点 //获取课程下的所有知识点
BaseResponse<BaseKnowReturn> getAllKnowByCourseId(String id); BaseResponse<BaseKnowReturn> getAllKnowByCourseId(String id);
//获取课程下的所有知识点
BaseResponse<BaseKnowReturn> getsecondKnowsById(Long id);
//获取课程下的所有资源 //获取课程下的所有资源
BaseResponse<Set<KnowVO1>> getAllResourcesByCourseId(String id); BaseResponse<Set<KnowVO1>> getAllResourcesByCourseId(String id);

@ -2,7 +2,7 @@ package com.teaching.backend.service.KnowGraph;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.teaching.backend.model.entity.KnowGraph.KnowledgeLearningNumber; import com.teaching.backend.model.entity.records.KnowledgeLearningNumber;
/** /**
* <p> * <p>

@ -0,0 +1,29 @@
package com.teaching.backend.service.cms;
import com.baomidou.mybatisplus.extension.service.IService;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.model.entity.cms.CmsCategory;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author author
* @since 2024-08-13
*/
public interface ICmsCategoryService extends IService<CmsCategory> {
BaseResponse<String> addCategory(CmsCategory cmsCategory);
BaseResponse<String> deleteCategory(List<Integer> ids);
BaseResponse<String> editCategory(CmsCategory cmsCategory);
BaseResponse<List<?>> queryCategory();
BaseResponse<String> editStatus(CmsCategory cmsCategory);
}

@ -0,0 +1,29 @@
package com.teaching.backend.service.cms;
import com.baomidou.mybatisplus.extension.service.IService;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.model.entity.cms.CmsEssay;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author author
* @since 2024-08-13
*/
public interface ICmsEssayService extends IService<CmsEssay> {
BaseResponse<String> addEssay(CmsEssay cmsEssay);
BaseResponse<String> deleteEssay(List<Integer> ids);
BaseResponse<String> editEssay(CmsEssay cmsEssay);
BaseResponse<List<?>> queryEssay(Integer category_id);
BaseResponse<String> editStatus(CmsEssay cmsEssay);
}

@ -2,7 +2,7 @@ package com.teaching.backend.service.courses;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.teaching.backend.model.entity.courses.CourseLearningNumber; import com.teaching.backend.model.entity.records.CourseLearningNumber;
/** /**
* <p> * <p>

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.teaching.backend.model.dto.courses.CourseObjectivesDTO; import com.teaching.backend.model.dto.courses.CourseObjectivesDTO;
import com.teaching.backend.model.entity.courses.CourseObjectives; import com.teaching.backend.model.entity.courses.CourseObjectives;
import com.teaching.backend.model.vo.courses.CourseObjectivesTreeVO; import com.teaching.backend.model.vo.courses.CourseObjectivesTreeVO;
import com.teaching.backend.model.vo.courses.CourseObjectivesVO;
import java.util.List; import java.util.List;
@ -37,4 +38,6 @@ public interface ICourseObjectivesService extends IService<CourseObjectives> {
* @return * @return
*/ */
List<CourseObjectivesTreeVO> queryCourseObjectivesTree(String id); List<CourseObjectivesTreeVO> queryCourseObjectivesTree(String id);
List<CourseObjectivesVO> queryCourseObjectivesForAdd(String courseId);
} }

@ -4,6 +4,7 @@ package com.teaching.backend.service.courses;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.teaching.backend.model.dto.courses.CoursesDTO; import com.teaching.backend.model.dto.courses.CoursesDTO;
import com.teaching.backend.model.dto.courses.PageDTO; import com.teaching.backend.model.dto.courses.PageDTO;
import com.teaching.backend.model.dto.umsAdmin.UmsStudentPageQueryDTO;
import com.teaching.backend.model.entity.courses.Courses; import com.teaching.backend.model.entity.courses.Courses;
import com.teaching.backend.model.entity.umsAdmin.UmsStudent; import com.teaching.backend.model.entity.umsAdmin.UmsStudent;
import com.teaching.backend.model.entity.umsAdmin.UmsStudentManage; import com.teaching.backend.model.entity.umsAdmin.UmsStudentManage;
@ -51,7 +52,9 @@ public interface ICoursesService extends IService<Courses> {
Map<String, Object> getPagePageSize2(int page, int pageSize); Map<String, Object> getPagePageSize2(int page, int pageSize);
List<PersonalCenterStudentListVO> queryStudentList(String userId); List<PersonalCenterStudentListVO> queryStudentList(String userId);
LinkedHashSet<UmsStudentManage> queryTeacherByStudentList(String userId); LinkedHashSet<UmsStudentManage> queryTeacherByStudentLearningRecordList(String userId);
List<UmsStudentManage> queryTeacherByStudentList(String userId);
List<CourseUserInfVO> getUserInfByCourse(Long userId); List<CourseUserInfVO> getUserInfByCourse(Long userId);
} }

@ -15,7 +15,7 @@ import com.teaching.backend.model.vo.courses.ObjectiveContentKnowVO;
*/ */
public interface IObjectiveContentKnowService extends IService<ObjectiveContentKnow> { public interface IObjectiveContentKnowService extends IService<ObjectiveContentKnow> {
String saveKnowsWithObjectiveOrContent(ObjectiveContentKnowDTO objectiveContentKnowDTO); String saveKnowsWithObjectiveContent(ObjectiveContentKnowDTO objectiveContentKnowDTO);
ObjectiveContentKnowVO getCountData(String objectiveId); ObjectiveContentKnowVO getCountData(String objectiveId);
} }

@ -16,4 +16,6 @@ public interface IObjectiveContentsService extends IService<ObjectiveContents> {
String deleteById(String id); String deleteById(String id);
String saveWithCheck(ObjectiveContents objectiveContents);
} }

@ -0,0 +1,84 @@
package com.teaching.backend.service.impl.cms;
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.cms.CmsCategoryMapper;
import com.teaching.backend.model.entity.cms.CmsCategory;
import com.teaching.backend.service.cms.ICmsCategoryService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author author
* @since 2024-08-13
*/
@Service
public class CmsCategoryServiceImpl extends ServiceImpl<CmsCategoryMapper, CmsCategory> implements ICmsCategoryService {
/**
* 添加栏目
* @param cmsCategory
* @return
*/
@Override
public BaseResponse<String> addCategory(CmsCategory cmsCategory) {
save(cmsCategory);
return ResultUtils.success("添加成功");
}
/**'
* 删除栏目
* @param ids
* @return
*/
@Override
public BaseResponse<String> deleteCategory(List<Integer> ids) {
removeByIds(ids);
return ResultUtils.success("删除成功");
}
/**
* 编辑栏目
* @param cmsCategory
* @return
*/
@Override
public BaseResponse<String> editCategory(CmsCategory cmsCategory) {
updateById(cmsCategory);
return ResultUtils.success("编辑成功!");
}
/**
* 查询栏目
* @return
*/
@Override
public BaseResponse<List<?>> queryCategory() {
//先查父栏目并排序
List<CmsCategory> categoryPid = query()
.eq("category_pid", 0)
.orderByAsc("sort").list();
for (int i = 0; i < categoryPid.size(); i++) {
//查孩子并排序
categoryPid.get(i).setChildrenNode(query()
.eq("category_pid", categoryPid.get(i).getId())
.orderByAsc("sort").list());
}
return ResultUtils.success(categoryPid);
}
@Override
public BaseResponse<String> editStatus(CmsCategory cmsCategory) {
cmsCategory.setStatus(cmsCategory.getStatus() & 1);
updateById(cmsCategory);
return ResultUtils.success("修改成功");
}
}

@ -0,0 +1,55 @@
package com.teaching.backend.service.impl.cms;
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.cms.CmsEssayMapper;
import com.teaching.backend.model.entity.cms.CmsEssay;
import com.teaching.backend.service.cms.ICmsEssayService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author author
* @since 2024-08-13
*/
@Service
public class CmsEssayServiceImpl extends ServiceImpl<CmsEssayMapper, CmsEssay> implements ICmsEssayService {
@Override
public BaseResponse<String> addEssay(CmsEssay cmsEssay) {
save(cmsEssay);
return ResultUtils.success("添加成功");
}
@Override
public BaseResponse<String> deleteEssay(List<Integer> ids) {
removeByIds(ids);
return ResultUtils.success("删除成功");
}
@Override
public BaseResponse<String> editEssay(CmsEssay cmsEssay) {
updateById(cmsEssay);
return ResultUtils.success("编辑成功!");
}
@Override
public BaseResponse<List<?>> queryEssay(Integer category_id) {
List<CmsEssay> list = query().eq("category_id", category_id).list();
return ResultUtils.success(list);
}
@Override
public BaseResponse<String> editStatus(CmsEssay cmsEssay) {
cmsEssay.setStatus(cmsEssay.getStatus() & 1);
updateById(cmsEssay);
return ResultUtils.success("修改成功");
}
}

@ -3,7 +3,7 @@ package com.teaching.backend.service.impl.courses;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.teaching.backend.mapper.courses.CourseLearningNumberMapper; 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 com.teaching.backend.service.courses.ICourseLearningNumberService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;

@ -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.ObjectiveContentKnow;
import com.teaching.backend.model.entity.courses.ObjectiveContents; import com.teaching.backend.model.entity.courses.ObjectiveContents;
import com.teaching.backend.model.vo.courses.CourseObjectivesTreeVO; 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.service.courses.ICourseObjectivesService;
import com.teaching.backend.utils.CourseCode; import com.teaching.backend.utils.CourseCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -26,6 +28,7 @@ import java.util.List;
import java.util.Map; 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_HAS_NO_CHILD;
import static com.teaching.backend.utils.CourseCode.TOTAL_OBJECTIVE_TYPE;
/** /**
* <p> * <p>
@ -36,6 +39,7 @@ import static com.teaching.backend.utils.CourseCode.TOTAL_OBJECTIVE_HAS_NO_CHILD
* @since 2024-05-31 * @since 2024-05-31
*/ */
@Service @Service
@Slf4j
public class CourseObjectivesServiceImpl extends ServiceImpl<CourseObjectivesMapper, CourseObjectives> implements ICourseObjectivesService { public class CourseObjectivesServiceImpl extends ServiceImpl<CourseObjectivesMapper, CourseObjectives> implements ICourseObjectivesService {
@ -109,12 +113,12 @@ public class CourseObjectivesServiceImpl extends ServiceImpl<CourseObjectivesMap
throw new BusinessException(ErrorCode.NOT_FOUND_ERROR); throw new BusinessException(ErrorCode.NOT_FOUND_ERROR);
} }
Integer type = courseObjectives.getType(); Integer type = courseObjectives.getType();
if (type == CourseCode.TOTAL_OBJECTIVE_TYPE.getValue()){ if (type == TOTAL_OBJECTIVE_TYPE.getValue()){
throw new BusinessException(ErrorCode.OPERATION_ERROR,"课程总目标只需清除所列内容即可!"); throw new BusinessException(ErrorCode.OPERATION_ERROR,"课程总目标禁止删除!");
} }
//等到删完内容后判断还是上来就判断? //等到删完内容后判断还是上来就判断?
Long count = objectiveContentKnowMapper.selectCount(new LambdaQueryWrapper<ObjectiveContentKnow>() Long count = objectiveContentKnowMapper.selectCount(new LambdaQueryWrapper<ObjectiveContentKnow>()
.eq(ObjectiveContentKnow::getObjectiveOrContent, id)); .eq(ObjectiveContentKnow::getObjectiveContentId, id));
if(count > CourseCode.KNOWS_EXIT.getValue()){ if(count > CourseCode.KNOWS_EXIT.getValue()){
throw new BusinessException(ErrorCode.KNOWS_EXIT); throw new BusinessException(ErrorCode.KNOWS_EXIT);
} }
@ -204,6 +208,30 @@ public class CourseObjectivesServiceImpl extends ServiceImpl<CourseObjectivesMap
return roots; return roots;
} }
@Override
public List<CourseObjectivesVO> 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<CourseObjectives> objectivesLists = courseObjectivesMapper.selectList(new LambdaQueryWrapper<>(CourseObjectives.class)
.eq(CourseObjectives::getPid, courseTotalObjectiveId)
.select(CourseObjectives::getId,CourseObjectives::getType)
.orderByAsc(CourseObjectives::getType)
);
List<CourseObjectivesVO> 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<ObjectiveContents> fetchContentsForObjective(String objectiveId) { private List<ObjectiveContents> fetchContentsForObjective(String objectiveId) {
LambdaQueryWrapper<ObjectiveContents> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<ObjectiveContents> queryWrapper = new LambdaQueryWrapper<>();

@ -20,6 +20,7 @@ import com.teaching.backend.mapper.umsAdmin.UmsTeacherMapper;
import com.teaching.backend.mapper.umsAdmin.UmsUserMapper; import com.teaching.backend.mapper.umsAdmin.UmsUserMapper;
import com.teaching.backend.model.dto.courses.CoursesDTO; import com.teaching.backend.model.dto.courses.CoursesDTO;
import com.teaching.backend.model.dto.courses.PageDTO; import com.teaching.backend.model.dto.courses.PageDTO;
import com.teaching.backend.model.dto.umsAdmin.UmsStudentPageQueryDTO;
import com.teaching.backend.model.entity.chapter.Chapter; import com.teaching.backend.model.entity.chapter.Chapter;
import com.teaching.backend.model.entity.courses.*; import com.teaching.backend.model.entity.courses.*;
import com.teaching.backend.model.entity.records.CourseLearningRecord; import com.teaching.backend.model.entity.records.CourseLearningRecord;
@ -52,6 +53,7 @@ import java.io.File;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.*; import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.teaching.backend.constant.RoleConstants.TEACHER_ROLE; import static com.teaching.backend.constant.RoleConstants.TEACHER_ROLE;
@ -281,7 +283,7 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
contents+=content; contents+=content;
Long know = objectiveContentKnowMapper.selectCount(new LambdaQueryWrapper<ObjectiveContentKnow>() Long know = objectiveContentKnowMapper.selectCount(new LambdaQueryWrapper<ObjectiveContentKnow>()
.eq(ObjectiveContentKnow::getObjectiveOrContent, objectiveId)); .eq(ObjectiveContentKnow::getObjectiveContentId, objectiveId));
knows+=know; knows+=know;
} }
if(contents > 0){ if(contents > 0){
@ -359,22 +361,24 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
@Override @Override
public List<PersonalCenterStudentListVO> queryStudentList(String userId) { public List<PersonalCenterStudentListVO> queryStudentList(String userId) {
LinkedHashSet<UmsStudentManage> umsStudentManageList = queryTeacherByStudentList(userId); LinkedHashSet<UmsStudentManage> umsStudentManageList = queryTeacherByStudentLearningRecordList(userId);
List<PersonalCenterStudentListVO> personalCenterStudentListVOList = new ArrayList<>(); List<PersonalCenterStudentListVO> personalCenterStudentListVOList = new ArrayList<>();
PersonalCenterStudentListVO personalCenterStudentListVO = null; PersonalCenterStudentListVO personalCenterStudentListVO = null;
for (UmsStudentManage umsStudentManage : umsStudentManageList) { for (UmsStudentManage umsStudentManage : umsStudentManageList) {
personalCenterStudentListVO = new PersonalCenterStudentListVO(); if (umsStudentManage != null){
personalCenterStudentListVO.setIcon(umsStudentManage.getIcon()); personalCenterStudentListVO = new PersonalCenterStudentListVO();
personalCenterStudentListVO.setName(umsStudentManage.getName()); personalCenterStudentListVO.setIcon(umsStudentManage.getIcon());
personalCenterStudentListVO.setNumber(umsStudentManage.getNumber()); personalCenterStudentListVO.setName(umsStudentManage.getName());
personalCenterStudentListVOList.add(personalCenterStudentListVO); personalCenterStudentListVO.setNumber(umsStudentManage.getNumber());
personalCenterStudentListVOList.add(personalCenterStudentListVO);
}
} }
return personalCenterStudentListVOList; return personalCenterStudentListVOList;
} }
@Override @Override
public LinkedHashSet<UmsStudentManage> queryTeacherByStudentList(String userId) { public LinkedHashSet<UmsStudentManage> queryTeacherByStudentLearningRecordList(String userId) {
String roleId = umsUserMapper.getbyIdRoleId(userId); String roleId = umsUserMapper.getByIdRoleId(userId);
CourseQuery courseQuery = new CourseQuery(); CourseQuery courseQuery = new CourseQuery();
courseQuery.setUserId(userId); courseQuery.setUserId(userId);
LinkedHashSet<UmsStudentManage> umsStudentManageList = new LinkedHashSet<>(); LinkedHashSet<UmsStudentManage> umsStudentManageList = new LinkedHashSet<>();
@ -387,20 +391,47 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
List<CourseLearningRecord> courseLearningRecordList = new ArrayList<>(); List<CourseLearningRecord> courseLearningRecordList = new ArrayList<>();
for (StudentCourses studentUsername : studentUsernames) { for (StudentCourses studentUsername : studentUsernames) {
CourseLearningRecord courseLearningRecord = courseLearningRecordMapper.selectNewRecord(String.valueOf(studentUsername.getStudent())); CourseLearningRecord courseLearningRecord = courseLearningRecordMapper.selectNewRecord(String.valueOf(studentUsername.getStudent()));
courseLearningRecordList.add(courseLearningRecord); if (courseLearningRecord != null){
} courseLearningRecordList.add(courseLearningRecord);
courseLearningRecordList = courseLearningRecordList.stream().sorted(Comparator.comparing(CourseLearningRecord::getTimes).reversed()).collect(Collectors.toList()); }
for (CourseLearningRecord courseLearningRecord : courseLearningRecordList) {
UmsStudentManage umsStudentManage = umsStudentManageMapper.queryStudent(courseLearningRecord.getUserId());
umsStudentManageList.add(umsStudentManage);
} }
courseLearningRecordList = courseLearningRecordList.stream().sorted(Comparator.comparing(CourseLearningRecord::getTimes).reversed()).collect(Collectors.toList());
for (CourseLearningRecord courseLearningRecord : courseLearningRecordList) {
UmsStudentManage umsStudentManage = umsStudentManageMapper.queryStudent(courseLearningRecord.getUserId());
umsStudentManageList.add(umsStudentManage);
}
} }
return umsStudentManageList; return umsStudentManageList;
} }
throw new BusinessException(400,"只有老师才有此功能"); throw new BusinessException(400,"只有老师才有此功能");
} }
@Override
public List<UmsStudentManage> queryTeacherByStudentList(String userId) {
String roleId = umsUserMapper.getByIdRoleId(userId);
CourseQuery courseQuery = new CourseQuery();
courseQuery.setUserId(userId);
if (roleId.equals("1")){
PageDTO<CoursesVO> queryCourses = queryForTeacher(courseQuery);
List<CoursesVO> coursesList = queryCourses.getList();
// 首先,收集所有需要查询的学生ID
Set<Long> studentIds = coursesList.stream()
.map(CoursesVO::getId)
.flatMap(courseId -> studentCoursesMapper.selectBatchSomeStudent(courseId).stream()
.map(StudentCourses::getStudent)) // 假设getStudent返回Long类型
.collect(Collectors.toSet()); // 使用Set去重
// 然后,一次性查询所有学生信息
List<UmsStudentManage> umsStudentManageLists = studentIds.stream()
.map(studentId -> umsStudentManageMapper.queryStudent(String.valueOf(studentId))) // 假设queryStudent接受Long类型参数
.filter(Objects::nonNull)
.collect(Collectors.toList());
return umsStudentManageLists;
}
throw new BusinessException(400,"只有老师才有此功能");
}
@Override @Override
public List<CoursesVO> getPagePageSize(int page, int pageSize) { public List<CoursesVO> getPagePageSize(int page, int pageSize) {
@ -640,57 +671,76 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
} }
private List<CourseUserInfVO> queryCourseUserForTeacher(Long userId) { private List<CourseUserInfVO> queryCourseUserForTeacher(Long userId) {
// 查询所有与该教师相关的课程 // 1. 获取该教师负责的所有课程
List<Courses> teacherCoursesInf = coursesMapper.selectList( List<Courses> teacherCoursesInf = coursesMapper.selectList(new LambdaQueryWrapper<Courses>()
new LambdaQueryWrapper<Courses>() .apply("FIND_IN_SET({0}, teacher)", userId)
.apply("FIND_IN_SET({0}, teacher)", userId) .select(Courses::getId, Courses::getTeacher, Courses::getName)
.select(Courses::getId, Courses::getTeacher)
); );
// 2. 提取所有课程的ID
Set<String> courseIds = teacherCoursesInf.stream()
.map(Courses::getId)
.collect(Collectors.toSet());
// 3. 批量查询所有课程的学生ID
List<StudentCourses> studentCourses = studentCoursesMapper.selectList(
new LambdaQueryWrapper<StudentCourses>().in(StudentCourses::getCourse, courseIds)
);
// 4. 获取所有的学生ID
Set<Long> studentIds = studentCourses.stream()
.map(StudentCourses::getStudent)
.collect(Collectors.toSet());
// 5. 批量查询所有学生的信息
List<UmsStudent> students = umsStudentMapper.selectList(
new LambdaQueryWrapper<UmsStudent>().in(UmsStudent::getUserId, studentIds)
);
// 6. 将学生信息缓存到Map中,Key为学生ID
Map<Long, UmsStudent> studentMap = students.stream()
.collect(Collectors.toMap(UmsStudent::getUserId, Function.identity()));
// 7. 处理教师信息并构建返回结果
List<CourseUserInfVO> courseUserInfVOS = new ArrayList<>(); List<CourseUserInfVO> courseUserInfVOS = new ArrayList<>();
for (Courses courses : teacherCoursesInf) { for (Courses course : teacherCoursesInf) {
CourseUserInfVO courseUserInfVO = new CourseUserInfVO(); CourseUserInfVO courseUserInfVO = new CourseUserInfVO();
courseUserInfVO.setCourseId(course.getId());
courseUserInfVO.setCourseName(course.getName());
List<UserReadMessageTimeVO> userReadMessageTimeVOS = new ArrayList<>(); List<UserReadMessageTimeVO> userReadMessageTimeVOS = new ArrayList<>();
courseUserInfVO.setCourseId(courses.getId());
// 添加学生信息
// 查询与课程相关的所有学生 for (StudentCourses sc : studentCourses) {
List<Long> studentIds = studentCoursesMapper.selectList( if (sc.getCourse().equals(course.getId())) {
new LambdaQueryWrapper<>(StudentCourses.class) UmsStudent student = studentMap.get(sc.getStudent()); // 类型转换
.eq(StudentCourses::getCourse, courses.getId()) if (student != null) {
).stream().map(StudentCourses::getStudent).collect(Collectors.toList()); UserReadMessageTimeVO userReadMessageTimeVO = new UserReadMessageTimeVO();
userReadMessageTimeVO.setId(student.getUserId());
// 为每个学生创建一个新的 UserReadMessageTimeVO 对象 userReadMessageTimeVO.setReceiverName(student.getName());
for (Long studentId : studentIds) { userReadMessageTimeVOS.add(userReadMessageTimeVO);
UmsStudent umsStudent = umsStudentMapper.selectOne( } else {
new LambdaQueryWrapper<>(UmsStudent.class) log.error("学生不存在: {}", sc.getStudent());
.eq(UmsStudent::getUserId, studentId) throw new BusinessException(ErrorCode.PARAMS_USER_NOTEXISTS);
.select(UmsStudent::getName) }
);
if (umsStudent == null) {
log.error("用户不存在: {}",studentId);
throw new BusinessException(ErrorCode.PARAMS_USER_NOTEXISTS);
} }
UserReadMessageTimeVO userReadMessageTimeVO = new UserReadMessageTimeVO(); // 在循环中创建新对象
userReadMessageTimeVO.setId(studentId);
userReadMessageTimeVO.setReceiverName(umsStudent.getName());
userReadMessageTimeVOS.add(userReadMessageTimeVO);
} }
// 为每个教师创建一个新的 UserReadMessageTimeVO 对象 // 添加教师信息
String[] teacherUserIds = courses.getTeacher().split(","); String[] teacherUserIds = course.getTeacher().split(",");
for (String teacherId : teacherUserIds) { for (String teacherId : teacherUserIds) {
UmsTeacher umsTeacher = umsTeacherMapper.selectOne( UmsTeacher umsTeacher = umsTeacherMapper.selectOne(
new LambdaQueryWrapper<UmsTeacher>() new LambdaQueryWrapper<UmsTeacher>().eq(UmsTeacher::getUserId, teacherId)
.eq(UmsTeacher::getUserId, teacherId)
); );
if (umsTeacher == null) { if (umsTeacher != null) {
log.error("教师不存在: {}",teacherId); UserReadMessageTimeVO userReadMessageTimeVO = new UserReadMessageTimeVO();
userReadMessageTimeVO.setId(umsTeacher.getUserId());
userReadMessageTimeVO.setReceiverName(umsTeacher.getName());
userReadMessageTimeVOS.add(userReadMessageTimeVO);
} else {
log.error("教师不存在: {}", teacherId);
throw new BusinessException(ErrorCode.PARAMS_USER_NOTEXISTS); throw new BusinessException(ErrorCode.PARAMS_USER_NOTEXISTS);
} }
UserReadMessageTimeVO userReadMessageTimeVO = new UserReadMessageTimeVO(); // 在循环中创建新对象
userReadMessageTimeVO.setId(umsTeacher.getUserId());
userReadMessageTimeVO.setReceiverName(umsTeacher.getName());
userReadMessageTimeVOS.add(userReadMessageTimeVO);
} }
courseUserInfVO.setUsersInf(userReadMessageTimeVOS); courseUserInfVO.setUsersInf(userReadMessageTimeVOS);
@ -700,64 +750,94 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
} }
private List<CourseUserInfVO> queryCourseUserForStudent(Long userId) { private List<CourseUserInfVO> queryCourseUserForStudent(Long userId) {
// 查询学生所参与的所有课程 // 1. 获取学生参与的所有课程
List<StudentCourses> studentCoursesList = studentCoursesMapper.selectList( List<StudentCourses> studentCourses = studentCoursesMapper.selectList(
new LambdaQueryWrapper<StudentCourses>() new LambdaQueryWrapper<StudentCourses>().eq(StudentCourses::getStudent, userId)
.eq(StudentCourses::getStudent, userId) );
.select(StudentCourses::getCourse)
// 2. 提取所有课程的ID
Set<String> courseIds = studentCourses.stream()
.map(StudentCourses::getCourse)
.collect(Collectors.toSet());
// 3. 批量查询所有课程的信息
List<Courses> coursesList = coursesMapper.selectBatchIds(courseIds);
// 4. 获取所有的教师ID
Set<Long> teacherIds = coursesList.stream()
.flatMap(course -> Arrays.stream(course.getTeacher().split(",")))
.map(Long::parseLong)
.collect(Collectors.toSet());
// 5. 批量查询所有教师的信息
List<UmsTeacher> teachers = umsTeacherMapper.selectList(
new LambdaQueryWrapper<UmsTeacher>().in(UmsTeacher::getUserId, teacherIds)
);
// 6. 将教师信息缓存到Map中,Key为教师ID
Map<Long, UmsTeacher> teacherMap = teachers.stream()
.collect(Collectors.toMap(UmsTeacher::getUserId, Function.identity()));
// 7. 批量查询所有课程的学生信息
List<StudentCourses> allStudentCourses = studentCoursesMapper.selectList(
new LambdaQueryWrapper<StudentCourses>().in(StudentCourses::getCourse, courseIds)
);
// 8. 提取所有学生的ID
Set<Long> allStudentIds = allStudentCourses.stream()
.map(StudentCourses::getStudent)
.collect(Collectors.toSet());
// 9. 批量查询所有学生的信息
List<UmsStudent> students = umsStudentMapper.selectList(
new LambdaQueryWrapper<UmsStudent>().in(UmsStudent::getUserId, allStudentIds)
); );
// 10. 将学生信息缓存到Map中,Key为学生ID
Map<Long, UmsStudent> studentMap = students.stream()
.collect(Collectors.toMap(UmsStudent::getUserId, Function.identity()));
// 11. 处理课程信息并构建返回结果
List<CourseUserInfVO> courseUserInfVOS = new ArrayList<>(); List<CourseUserInfVO> courseUserInfVOS = new ArrayList<>();
for (StudentCourses studentCourse : studentCoursesList) { for (Courses course : coursesList) {
CourseUserInfVO courseUserInfVO = new CourseUserInfVO(); CourseUserInfVO courseUserInfVO = new CourseUserInfVO();
courseUserInfVO.setCourseId(course.getId());
courseUserInfVO.setCourseName(course.getName());
List<UserReadMessageTimeVO> userReadMessageTimeVOS = new ArrayList<>(); List<UserReadMessageTimeVO> userReadMessageTimeVOS = new ArrayList<>();
courseUserInfVO.setCourseId(studentCourse.getCourse());
// 添加教师信息
// 查询与课程相关的所有学生 String[] courseTeacherIds = course.getTeacher().split(",");
List<Long> studentIds = studentCoursesMapper.selectList( for (String teacherId : courseTeacherIds) {
new LambdaQueryWrapper<>(StudentCourses.class) UmsTeacher umsTeacher = teacherMap.get(Long.valueOf(teacherId));
.eq(StudentCourses::getCourse, studentCourse.getCourse()) if (umsTeacher != null) {
).stream().map(StudentCourses::getStudent).collect(Collectors.toList()); UserReadMessageTimeVO userReadMessageTimeVO = new UserReadMessageTimeVO();
userReadMessageTimeVO.setId(umsTeacher.getUserId());
// 为每个学生创建一个新的 UserReadMessageTimeVO 对象 userReadMessageTimeVO.setReceiverName(umsTeacher.getName());
for (Long studentId : studentIds) { userReadMessageTimeVOS.add(userReadMessageTimeVO);
UmsStudent umsStudent = umsStudentMapper.selectOne( } else {
new LambdaQueryWrapper<>(UmsStudent.class) log.error("教师不存在: {}", teacherId);
.eq(UmsStudent::getUserId, studentId)
.select(UmsStudent::getName)
);
if (umsStudent == null) {
log.error("用户不存在: {}", studentId);
throw new BusinessException(ErrorCode.PARAMS_USER_NOTEXISTS); throw new BusinessException(ErrorCode.PARAMS_USER_NOTEXISTS);
} }
UserReadMessageTimeVO userReadMessageTimeVO = new UserReadMessageTimeVO(); // 在循环中创建新对象
userReadMessageTimeVO.setId(studentId);
userReadMessageTimeVO.setReceiverName(umsStudent.getName());
userReadMessageTimeVOS.add(userReadMessageTimeVO);
} }
// 查询与课程相关的所有教师 // 添加学生信息
Courses course = coursesMapper.selectById(studentCourse.getCourse()); for (StudentCourses sc : allStudentCourses) {
if (course != null) { if (sc.getCourse().equals(course.getId())) {
String[] teacherUserIds = course.getTeacher().split(","); UmsStudent student = studentMap.get(sc.getStudent()); // 类型转换
for (String teacherId : teacherUserIds) { if (student != null) {
UmsTeacher umsTeacher = umsTeacherMapper.selectOne( UserReadMessageTimeVO userReadMessageTimeVO = new UserReadMessageTimeVO();
new LambdaQueryWrapper<UmsTeacher>() userReadMessageTimeVO.setId(student.getUserId());
.eq(UmsTeacher::getUserId, teacherId) userReadMessageTimeVO.setReceiverName(student.getName());
); userReadMessageTimeVOS.add(userReadMessageTimeVO);
if (umsTeacher == null) { } else {
log.error("教师不存在: {}", teacherId); log.error("学生不存在: {}", sc.getStudent());
throw new BusinessException(ErrorCode.PARAMS_USER_NOTEXISTS); throw new BusinessException(ErrorCode.PARAMS_USER_NOTEXISTS);
} }
UserReadMessageTimeVO userReadMessageTimeVO = new UserReadMessageTimeVO(); // 在循环中创建新对象
userReadMessageTimeVO.setId(umsTeacher.getUserId());
userReadMessageTimeVO.setReceiverName(umsTeacher.getName());
userReadMessageTimeVOS.add(userReadMessageTimeVO);
} }
} else {
log.error("课程不存在: {}", studentCourse.getCourse());
throw new BusinessException(ErrorCode.PARAMS_COURSE_NOTEXISTS);
} }
courseUserInfVO.setUsersInf(userReadMessageTimeVOS); courseUserInfVO.setUsersInf(userReadMessageTimeVOS);
@ -766,6 +846,8 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
return courseUserInfVOS; return courseUserInfVOS;
} }
} }

@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.teaching.backend.common.ErrorCode; import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.exception.BusinessException; 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.CourseObjectivesMapper;
import com.teaching.backend.mapper.courses.CoursesMapper; import com.teaching.backend.mapper.courses.CoursesMapper;
import com.teaching.backend.mapper.courses.ObjectiveContentKnowMapper; 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.CourseObjectives;
import com.teaching.backend.model.entity.courses.ObjectiveContentKnow; import com.teaching.backend.model.entity.courses.ObjectiveContentKnow;
import com.teaching.backend.model.entity.courses.ObjectiveContents; 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.courses.ObjectiveContentKnowVO;
import com.teaching.backend.model.vo.knowtmp.KnowTmpVO;
import com.teaching.backend.service.courses.IObjectiveContentKnowService; import com.teaching.backend.service.courses.IObjectiveContentKnowService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -40,8 +43,8 @@ public class ObjectiveContentKnowServiceImpl extends ServiceImpl<ObjectiveConten
@Autowired @Autowired
ObjectiveContentKnowMapper objectiveContentKnowMapper; ObjectiveContentKnowMapper objectiveContentKnowMapper;
// @Autowired @Autowired
// KnowMapper knowMapper; KnowtmpMapper knowtmpMapper;
@Autowired @Autowired
CourseObjectivesMapper courseObjectivesMapper; CourseObjectivesMapper courseObjectivesMapper;
@Autowired @Autowired
@ -53,114 +56,109 @@ public class ObjectiveContentKnowServiceImpl extends ServiceImpl<ObjectiveConten
@Override @Override
@Transactional @Transactional
public String saveKnowsWithObjectiveOrContent(ObjectiveContentKnowDTO objectiveContentKnowDTO) { public String saveKnowsWithObjectiveContent(ObjectiveContentKnowDTO objectiveContentKnowDTO) {
String objectiveOrContent = objectiveContentKnowDTO.getObjectiveOrContent();
if (objectiveOrContent == null || objectiveOrContent.equals("")){
throw new BusinessException(ErrorCode.OBJECTIVE_OR_CONTENT_NOT_EXIT);
}
//暂时约定前端传过来的的knows是“1,2,3” 用 , 隔开的 //暂时约定前端传过来的的knows是“1,2,3” 用 , 隔开的
String knows = objectiveContentKnowDTO.getKnow(); // String knows = objectiveContentKnowDTO.getKnow();
if (knows == null || knows.equals("")){ // if (knows == null || knows.equals("")){
throw new BusinessException(ErrorCode.KONWID_NOT_EXIT); // throw new BusinessException(ErrorCode.KONWID_NOT_EXIT);
} // }
List<String> knowIds = new ArrayList<>(Arrays.asList(knows.split(","))); // List<String> knowIds = new ArrayList<>(Arrays.asList(knows.split(",")));
List<ObjectiveContentKnow> objectiveContentKnowList = new ArrayList<>(); // List<ObjectiveContentKnow> objectiveContentKnowList = new ArrayList<>();
for (String knowId : knowIds) { // for (String knowId : knowIds) {
ObjectiveContentKnow objectiveContentKnow = new ObjectiveContentKnow(); // ObjectiveContentKnow objectiveContentKnow = new ObjectiveContentKnow();
// objectiveContentKnow.setId(snowflakeGenerator.next()); //// objectiveContentKnow.setId(snowflakeGenerator.next());
objectiveContentKnow.setObjectiveOrContent(objectiveOrContent); // objectiveContentKnow.setObjectiveOrContent(objectiveOrContent);
objectiveContentKnow.setKnow(knowId); // objectiveContentKnow.setKnow(knowId);
objectiveContentKnowList.add(objectiveContentKnow); // objectiveContentKnowList.add(objectiveContentKnow);
} // }
try { // try {
objectiveContentKnowMapper.insertBatchSomeColumn(objectiveContentKnowList); // objectiveContentKnowMapper.insertBatchSomeColumn(objectiveContentKnowList);
} catch (Exception e) { // } catch (Exception e) {
e.printStackTrace(); // e.printStackTrace();
throw new BusinessException(ErrorCode.OBJECTIVE_OR_CONTENT_EXIT); // 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 @Override
public ObjectiveContentKnowVO getCountData(String objectiveOrContentId) { public ObjectiveContentKnowVO getCountData(String objectiveContentId) {
// 查询分项目标或者是下面的内容关联的知识点数据(按设计要求,这个传的就是分项目标的id) // 创建ObjectiveContentKnowVO对象,用于存储和返回计算结果
List<ObjectiveContentKnow> objectiveContentKnows = objectiveContentKnowMapper.selectList( ObjectiveContentKnowVO objectiveContentKnowVO = new ObjectiveContentKnowVO();
new LambdaQueryWrapper<ObjectiveContentKnow>()
.eq(ObjectiveContentKnow::getObjectiveOrContent, objectiveOrContentId));
// 创建ObjectiveContentKnowVO对象,并计算相关数据 // 根据传入的目标内容ID找到课程ID和总学时
ObjectiveContentKnowVO objectiveContentKnowVO = createObjectiveContentKnowVO(objectiveOrContentId, objectiveContentKnows); String objectiveID = objectiveContentsMapper.selectOne(new LambdaQueryWrapper<ObjectiveContents>()
.eq(ObjectiveContents::getId, objectiveContentId)).getObjectiveId();
// 根据分项目标找到课程id
String pid = courseObjectivesMapper.selectOne(new LambdaQueryWrapper<CourseObjectives>() String pid = courseObjectivesMapper.selectOne(new LambdaQueryWrapper<CourseObjectives>()
.eq(CourseObjectives::getId, objectiveOrContentId)).getPid(); .eq(CourseObjectives::getId, objectiveID)).getPid();
String courseId = courseObjectivesMapper.selectOne(new LambdaQueryWrapper<CourseObjectives>() String courseId = courseObjectivesMapper.selectOne(new LambdaQueryWrapper<CourseObjectives>()
.eq(CourseObjectives::getId, pid)).getCourseId(); .eq(CourseObjectives::getId, pid)).getCourseId();
Integer classhours = coursesMapper.selectById(courseId).getClasshours(); Integer classhours = coursesMapper.selectById(courseId).getClasshours();
// 计算并设置比例(百分比) // 获取当前目标内容下关联的知识点数据
// BigDecimal percentage = calculatePercentage(objectiveContentKnowVO.getKnowsTime(), classhours); List<ObjectiveContentKnow> objectiveContentKnows = objectiveContentKnowMapper.selectList(
new LambdaQueryWrapper<ObjectiveContentKnow>()
// objectiveContentKnowVO.setPersent(percentage + "%"); .eq(ObjectiveContentKnow::getObjectiveContentId, objectiveContentId)
);
// 查找分项目标下的内容
List<ObjectiveContents> objectiveContents = objectiveContentsMapper.selectList(new LambdaQueryWrapper<ObjectiveContents>()
.eq(ObjectiveContents::getObjectiveId, objectiveOrContentId));
// 如果存在分项目标内容,处理并计算每个内容的相关数据 // 创建并设置ObjectiveContentKnowVO对象的属性
if (!CollectionUtils.isEmpty(objectiveContents)) { objectiveContentKnowVO = createObjectiveContentKnowVO(objectiveContentId, objectiveContentKnows);
List<ObjectiveContentKnowVO> contentKnowVOs = objectiveContents.stream()
.map(content -> createObjectiveContentKnowVO(content.getId(), objectiveContentKnowMapper.selectList(
new LambdaQueryWrapper<ObjectiveContentKnow>()
.eq(ObjectiveContentKnow::getObjectiveOrContent, content.getId())
)))
.collect(Collectors.toList());
// 计算每个内容的知识点总学时的比例(百分比) // 计算并设置该内容的知识点总学时的比例(百分比)
// contentKnowVOs.forEach(contentKnowVO -> { Double contentPercentage = calculatePercentage(objectiveContentKnowVO.getKnowsTime(), classhours);
// BigDecimal contentPercentage = calculatePercentage(contentKnowVO.getKnowsTime(), classhours); objectiveContentKnowVO.setPersent(contentPercentage);
// contentKnowVO.setPersent(contentPercentage + "%");
// });
// 设置内容的知识点数据 // 返回最终结果
objectiveContentKnowVO.setContentKnowsData(contentKnowVOs);
}
// 返回计算结果
return objectiveContentKnowVO; return objectiveContentKnowVO;
} }
// 创建ObjectiveContentKnowVO对象,并计算知识点数量和总时间 // 创建ObjectiveContentKnowVO对象,并计算知识点数量、总时间和关联的知识点部分数据
private ObjectiveContentKnowVO createObjectiveContentKnowVO(String objectiveOrContentId, List<ObjectiveContentKnow> objectiveContentKnows) { private ObjectiveContentKnowVO createObjectiveContentKnowVO(String objectiveOrContentId, List<ObjectiveContentKnow> objectiveContentKnows) {
ObjectiveContentKnowVO vo = new ObjectiveContentKnowVO(); ObjectiveContentKnowVO vo = new ObjectiveContentKnowVO();
vo.setObjectiveOrContent(objectiveOrContentId); vo.setObjectiveOrContent(objectiveOrContentId);
vo.setKnowsNumber(objectiveContentKnows.size()); vo.setKnowsNumber(objectiveContentKnows.size());
// 计算知识点的总时间 // 计算知识点的总时间,并收集关联的知识点部分数据
// BigDecimal knowsTime = objectiveContentKnows.stream() Double knowsTime = 0.0;
// .map(contentKnow -> { List<KnowTmpVO> knowTmpVOList = new ArrayList<>();
// Know know = knowMapper.selectOne(new LambdaQueryWrapper<Know>()
// .eq(Know::getId, contentKnow.getKnow())); for (ObjectiveContentKnow contentKnow : objectiveContentKnows) {
// if (know == null) { Knowtmp know = knowtmpMapper.selectOne(new LambdaQueryWrapper<Knowtmp>()
// throw new BusinessException(ErrorCode.KNOW_NOT_EXIT); .eq(Knowtmp::getId, contentKnow.getKnowId()));
// } if (know == null) {
// return know.getHour(); throw new BusinessException(ErrorCode.KNOW_NOT_EXIT);
// }) }
// .reduce(BigDecimal.ZERO, BigDecimal::add); knowsTime += know.getHour();
// vo.setKnowsTime(knowsTime); // 将当前知识点数据添加到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; return vo;
} }
// 计算知识点时间占总学时的比例,并转换为百分比 // 计算知识点学时占总学时的比例,并返回百分比形式的结果
private BigDecimal calculatePercentage(BigDecimal knowsTime, Integer classhours) { private Double calculatePercentage(Double knowsTime, Integer classhours) {
if (classhours == null || classhours == 0) { if (classhours == null || classhours == 0) {
return BigDecimal.ZERO; return 0.0;
} }
// 将classhours转换为BigDecimal类型,以便进行精确计算 return new BigDecimal(knowsTime)
BigDecimal classHoursBigDecimal = new BigDecimal(classhours); .divide(new BigDecimal(classhours), 4, RoundingMode.HALF_UP)
// 计算knowsTime占classhours的比例,先除以classhours再乘以100,保留两位小数,并四舍五入 .multiply(new BigDecimal(100))
return knowsTime.divide(classHoursBigDecimal, 4, RoundingMode.HALF_UP).multiply(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP); .setScale(2, RoundingMode.HALF_UP)
.doubleValue();
} }
} }

@ -5,16 +5,21 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.teaching.backend.common.ErrorCode; import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.exception.BusinessException; 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.ObjectiveContentKnowMapper;
import com.teaching.backend.mapper.courses.ObjectiveContentsMapper; 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.ObjectiveContentKnow;
import com.teaching.backend.model.entity.courses.ObjectiveContents; import com.teaching.backend.model.entity.courses.ObjectiveContents;
import com.teaching.backend.service.courses.IObjectiveContentsService; import com.teaching.backend.service.courses.IObjectiveContentsService;
import com.teaching.backend.utils.CourseCode; import com.teaching.backend.utils.CourseCode;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import static com.teaching.backend.utils.CourseCode.*;
/** /**
* <p> * <p>
* 服务实现类 * 服务实现类
@ -24,23 +29,50 @@ import org.springframework.stereotype.Service;
* @since 2024-06-05 * @since 2024-06-05
*/ */
@Service @Service
@Slf4j
public class ObjectiveContentsServiceImpl extends ServiceImpl<ObjectiveContentsMapper, ObjectiveContents> implements IObjectiveContentsService { public class ObjectiveContentsServiceImpl extends ServiceImpl<ObjectiveContentsMapper, ObjectiveContents> implements IObjectiveContentsService {
@Autowired @Autowired
ObjectiveContentKnowMapper objectiveContentKnowMapper; ObjectiveContentKnowMapper objectiveContentKnowMapper;
@Autowired @Autowired
ObjectiveContentsMapper objectiveContentsMapper; ObjectiveContentsMapper objectiveContentsMapper;
@Autowired
CourseObjectivesMapper courseObjectivesMapper;
@Override @Override
public String deleteById(String id) { public String deleteById(String id) {
if (id == null){ if (id == null){
throw new BusinessException(ErrorCode.CONTENT_NOT_EXIT); throw new BusinessException(ErrorCode.CONTENT_NOT_EXIT);
} }
Long count = objectiveContentKnowMapper.selectCount(new LambdaQueryWrapper<ObjectiveContentKnow>() Long count = objectiveContentKnowMapper.selectCount(new LambdaQueryWrapper<ObjectiveContentKnow>()
.eq(ObjectiveContentKnow::getObjectiveOrContent, id)); .eq(ObjectiveContentKnow::getObjectiveContentId, id));
if(count > CourseCode.KNOWS_EXIT.getValue()){ if(count > CourseCode.KNOWS_EXIT.getValue()){
throw new BusinessException(ErrorCode.KNOWS_EXIT); throw new BusinessException(ErrorCode.KNOWS_EXIT);
} }
int delete = objectiveContentsMapper.deleteById(id); int delete = objectiveContentsMapper.deleteById(id);
return delete > 0 ? "删除成功!" : "删除失败!"; 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 ? "添加内容成功" : "添加内容失败";
}
} }

@ -16,9 +16,6 @@ import com.teaching.backend.mapper.favour.SeCourseFavourMapper;
import com.teaching.backend.mapper.umsAdmin.UmsUserMapper; import com.teaching.backend.mapper.umsAdmin.UmsUserMapper;
import com.teaching.backend.model.entity.courses.Courses; import com.teaching.backend.model.entity.courses.Courses;
import com.teaching.backend.model.entity.favour.SeCourseFavour; import com.teaching.backend.model.entity.favour.SeCourseFavour;
import com.teaching.backend.model.entity.favour.SeKnowFavour;
import com.teaching.backend.model.entity.favour.SeResourceFavour;
import com.teaching.backend.model.entity.umsAdmin.UmsUser;
import com.teaching.backend.model.vo.courses.CoursesVO; import com.teaching.backend.model.vo.courses.CoursesVO;
import com.teaching.backend.model.vo.favour.CourseFavourDetailVO; import com.teaching.backend.model.vo.favour.CourseFavourDetailVO;
import com.teaching.backend.service.courses.ICoursesService; import com.teaching.backend.service.courses.ICoursesService;
@ -157,7 +154,7 @@ public class SeCourseFavourServiceImpl extends ServiceImpl<SeCourseFavourMapper,
@Override @Override
public List<CoursesVO> queryNewCollect(String userId) { public List<CoursesVO> queryNewCollect(String userId) {
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")){
//老师 //老师

@ -1,9 +1,25 @@
package com.teaching.backend.service.impl.know; package com.teaching.backend.service.impl.know;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import com.teaching.backend.common.BaseResponse; import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.common.ErrorCode; import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.common.ResultUtils; import com.teaching.backend.common.ResultUtils;
import com.teaching.backend.controller.Know.Edge;
import com.teaching.backend.controller.Know.KnowJson;
import com.teaching.backend.controller.Know.KnowJsonListVO;
import com.teaching.backend.mapper.Knowtemp.KnowtmpMapper;
import com.teaching.backend.mapper.chapter.ChapterMapper; import com.teaching.backend.mapper.chapter.ChapterMapper;
import com.teaching.backend.mapper.courses.CoursesMapper; import com.teaching.backend.mapper.courses.CoursesMapper;
import com.teaching.backend.mapper.know.KnowRepository; import com.teaching.backend.mapper.know.KnowRepository;
@ -29,6 +45,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.IOException;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -43,6 +60,9 @@ public class knowServiceImpl implements KnowService {
@Autowired @Autowired
private KnowRepository knowRepository; private KnowRepository knowRepository;
@Autowired
private KnowtmpMapper knowtmpMapper;
@Autowired @Autowired
private ChapterMapper chapterMapper; private ChapterMapper chapterMapper;
@ -51,7 +71,6 @@ public class knowServiceImpl implements KnowService {
private KnowtmpService knowtmpService; private KnowtmpService knowtmpService;
@Autowired @Autowired
CoursesMapper coursesMapper; CoursesMapper coursesMapper;
@ -59,107 +78,563 @@ public class knowServiceImpl implements KnowService {
private Neo4jClient neo4jClient; private Neo4jClient neo4jClient;
public BaseResponse<String> addRelationshipWithresources(Long id, Long resourceId){ public BaseResponse<String> addRelationshipWithresources(Long id, Long resourceId) {
int f = knowRepository.addResourceResourcesKnow(id,resourceId); int f = knowRepository.addResourceResourcesKnow(id, resourceId);
if(f <= 0){ if (f <= 0) {
throw new RuntimeException("添加关系失败"); throw new RuntimeException("添加关系失败");
} }
return ResultUtils.success("添加关系成功"); return ResultUtils.success("添加关系成功");
} }
@Override
public BaseResponse<BaseKnowReturn> getTwoLevelKnows(Long id) {
Collection<Map<String, Object>> all =
neo4jClient.query("match(n:Know)-[r*0..2]->(p:Know) where ID(n) = " + id + " return n as `n`,r as `r`,p as `p`,length(r) as `d`").fetch().all();
Map<Long, String> colorChoose = new
HashMap<>();
String color[] = new String[10];
String[] colorList = {"#91CC75", "#5470C6", "#FAC858", "#EE6666", "#73C0DE", "#EA7CCC", "#5577FF", "#5577FF", "#9DBFFF", "#78A7FF"};
for (int i = 0; i < 10; i++) {
colorChoose.put((long) i, colorList[i]);
}
Iterator<Map<String, Object>> iterator = all.iterator();
Set<KnowVO> knowList = new HashSet<>();
Set<Links> linksList = new HashSet<>();
KnowVO knowVO;
List node2 = new ArrayList<>();
Links links;
int p = 0;
while (iterator.hasNext()) {
Map<String, Object> element = iterator.next();
knowVO = new KnowVO();
Node node1 = (Node) element.get("p");
Long group = (Long) element.get("d");
knowVO.setColor(colorChoose.get(group));
Long id1 = node1.id();
String name1 = node1.get("name").asString();
knowVO.setId(id1);
knowVO.setLabel(name1);
knowList.add(knowVO);
node2 = (List) element.get("r");
for (int i = 0; i < node2.size(); i++) {
InternalRelationship e = (InternalRelationship) node2.get(i);
links = new Links();
links.setId(e.id());
links.setSource(e.startNodeId());
links.setTarget(e.endNodeId());
if ("contain".equals(e.type())) {
links.setLabel("包含");
} else if ("order".equals(e.type())) {
links.setLabel("顺序");
}
linksList.add(links);
}
}
BaseKnowReturn baseKnowReturn = new BaseKnowReturn(knowList, linksList);
return ResultUtils.success(baseKnowReturn);
}
@Override
public BaseResponse<BaseKnowReturn> getThreeLevelKnows(Long id) {
Collection<Map<String, Object>> all =
neo4jClient.query("match(n:Know)-[r*0..3]->(p:Know) where ID(n) = " + id + " return n as `n`,r as `r`,p as `p`,length(r) as `d`").fetch().all();
Map<Long, String> colorChoose = new
HashMap<>();
String color[] = new String[10];
String[] colorList = {"#91CC75", "#5470C6", "#FAC858", "#EE6666", "#73C0DE", "#EA7CCC", "#5577FF", "#5577FF", "#9DBFFF", "#78A7FF"};
for (int i = 0; i < 10; i++) {
colorChoose.put((long) i, colorList[i]);
}
Iterator<Map<String, Object>> iterator = all.iterator();
Set<KnowVO> knowList = new HashSet<>();
Set<Links> linksList = new HashSet<>();
KnowVO knowVO;
List node2 = new ArrayList<>();
Links links;
int p = 0;
while (iterator.hasNext()) {
Map<String, Object> element = iterator.next();
knowVO = new KnowVO();
Node node1 = (Node) element.get("p");
Long group = (Long) element.get("d");
knowVO.setColor(colorChoose.get(group));
Long id1 = node1.id();
String name1 = node1.get("name").asString();
knowVO.setId(id1);
knowVO.setLabel(name1);
knowList.add(knowVO);
node2 = (List) element.get("r");
for (int i = 0; i < node2.size(); i++) {
InternalRelationship e = (InternalRelationship) node2.get(i);
links = new Links();
links.setId(e.id());
links.setSource(e.startNodeId());
links.setTarget(e.endNodeId());
if ("contain".equals(e.type())) {
links.setLabel("包含");
} else if ("order".equals(e.type())) {
links.setLabel("顺序");
}
linksList.add(links);
}
}
BaseKnowReturn baseKnowReturn = new BaseKnowReturn(knowList, linksList);
return ResultUtils.success(baseKnowReturn);
}
@Override
public BaseResponse<BaseKnowReturn> getFourLevelKnows(Long id) {
Collection<Map<String, Object>> all =
neo4jClient.query("match(n:Know)-[r*0..4]->(p:Know) where ID(n) = " + id + " return n as `n`,r as `r`,p as `p`,length(r) as `d`").fetch().all();
Map<Long, String> colorChoose = new
HashMap<>();
String color[] = new String[10];
String[] colorList = {"#91CC75", "#5470C6", "#FAC858", "#EE6666", "#73C0DE", "#EA7CCC", "#5577FF", "#5577FF", "#9DBFFF", "#78A7FF"};
for (int i = 0; i < 10; i++) {
colorChoose.put((long) i, colorList[i]);
}
Iterator<Map<String, Object>> iterator = all.iterator();
Set<KnowVO> knowList = new HashSet<>();
Set<Links> linksList = new HashSet<>();
KnowVO knowVO;
List node2 = new ArrayList<>();
Links links;
int p = 0;
while (iterator.hasNext()) {
Map<String, Object> element = iterator.next();
knowVO = new KnowVO();
Node node1 = (Node) element.get("p");
Long group = (Long) element.get("d");
knowVO.setColor(colorChoose.get(group));
Long id1 = node1.id();
String name1 = node1.get("name").asString();
knowVO.setId(id1);
knowVO.setLabel(name1);
knowList.add(knowVO);
node2 = (List) element.get("r");
for (int i = 0; i < node2.size(); i++) {
InternalRelationship e = (InternalRelationship) node2.get(i);
links = new Links();
links.setId(e.id());
links.setSource(e.startNodeId());
links.setTarget(e.endNodeId());
if ("contain".equals(e.type())) {
links.setLabel("包含");
} else if ("order".equals(e.type())) {
links.setLabel("顺序");
}
linksList.add(links);
}
}
BaseKnowReturn baseKnowReturn = new BaseKnowReturn(knowList, linksList);
return ResultUtils.success(baseKnowReturn);
}
@Override
public BaseResponse<String> showGraphJson(String courseId) {
return addInformation(courseId);
}
@Override @Override
public BaseResponse<String> addAllKnow(String courseId) { public BaseResponse<String> addAllKnow(String courseId) {
try { try {
addAllKnowTransation(courseId) ; addAllKnowTransation(courseId);
}catch (Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return ResultUtils.error(ErrorCode.OPERATION_ERROR,e.getMessage()); return ResultUtils.error(ErrorCode.OPERATION_ERROR, e.getMessage());
} }
//6.返回成功信息,关闭事务 //6.返回成功信息,关闭事务
return ResultUtils.success("添加成功"); return ResultUtils.success("添加成功");
} }
private BaseResponse<String> addInformation(String courseId) {
// 创建 JSON 对象数组
JSONArray jsonArrayKnowNode = JSONUtil.createArray();
JSONArray jsonArrayCourseNode = JSONUtil.createArray();
JSONArray jsonArrayChapterNode = JSONUtil.createArray();
//查询数据库-课程
Courses courses = coursesMapper.selectById(courseId);
JSONObject obj1 = JSONUtil.createObj();
obj1.put("courseId", courseId);
obj1.put("name", courses.getName());
obj1.put("info", courses.getDescription());
obj1.put("hour", courses.getClasshours());
jsonArrayCourseNode.add(obj1);
//查询数据库-章-节
List<Chapter> chapterList = new ArrayList<>();
List<Chapter> chapterListPID = chapterMapper.selectChapterPIDByCourseId(courseId);
List<Long> chapterOneIds = new ArrayList<>();
List<Long> chapterTwoIds = new ArrayList<>();
for (int i = 0; i < chapterListPID.size(); i++) {
chapterList.add(chapterListPID.get(i));
chapterOneIds.add(chapterListPID.get(i).getId());
List<Chapter> chapterListSecond = chapterMapper.selectChapterChildrenOrderByNum(chapterListPID.get(i).getId());
for (int j = 0; j < chapterListSecond.size(); j++) {
chapterList.add(chapterListSecond.get(j));
chapterTwoIds.add(chapterListSecond.get(j).getId());
}
}
for (int i = 0; i < chapterList.size(); i++) {
Chapter chapter = chapterList.get(i);
JSONObject obj2 = JSONUtil.createObj();
obj2.put("chapterId", chapter.getId());
obj2.put("name", chapter.getName());
obj2.put("info", chapter.getContent());
obj2.put("hour", chapter.getTotalClassHours());
jsonArrayChapterNode.add(obj2);
}
//查询数据库-知识点
for (int i = 0; i < chapterList.size(); i++) {
Chapter chapter = chapterList.get(i);
if (chapter.getPid() != 0) {
List<Knowtmp> knowlist = knowtmpService.queryByChapterId(chapter.getId());
for (int j = 0; j < knowlist.size(); j++) {
Knowtmp knowtmp = knowlist.get(j);
JSONObject obj3 = JSONUtil.createObj();
obj3.put("knowId", knowtmp.getId());
obj3.put("name", knowtmp.getName());
obj3.put("info", knowtmp.getInfo());
obj3.put("hour", knowtmp.getHour());
jsonArrayKnowNode.add(obj3);
}
}
}
// =======创建关系
JSONArray edgesArray = JSONUtil.createArray();
// 创建边列表
// 课程-章节 父子
for (int i = 0; i < chapterListPID.size(); i++) {
Chapter chapter = chapterListPID.get(i);
JSONObject edge = JSONUtil.createObj();
edge.put("source", courses.getId());
edge.put("target", chapter.getId());
edge.put("type", "FatherAndSon");
edge.put("sta", 1);
edgesArray.add(edge);
}
//章-节 父子
for (int i = 0; i < chapterListPID.size(); i++) {
List<Chapter> chapterListSecond = chapterMapper.selectChapterChildrenOrderByNum(chapterListPID.get(i).getId());
for (int j = 0; j < chapterListSecond.size(); j++) {
JSONObject edge = JSONUtil.createObj();
edge.put("source", chapterListPID.get(i).getId());
edge.put("target", chapterListSecond.get(j).getId());
edge.put("type", "FatherAndSon");
edge.put("sta", 2);
edgesArray.add(edge);
}
}
//节与点父子
List<Long> knowIds = new ArrayList<>();
for (int i = 0; i < chapterTwoIds.size(); i++) {
List<Knowtmp> knowlist = knowtmpService.queryByChapterId(chapterTwoIds.get(i));
for (int j = 0; j < knowlist.size(); j++) {
Knowtmp knowtmp = knowlist.get(j);
JSONObject edge = JSONUtil.createObj();
edge.put("source", chapterTwoIds.get(i));
edge.put("target", knowtmp.getId());
edge.put("type", "FatherAndSon");
edge.put("sta", 3);
edgesArray.add(edge);
knowIds.add(knowtmp.getId());
}
}
//章-章 顺序
for (int i = 0; i < chapterOneIds.size() - 1; i++) {
JSONObject edge = JSONUtil.createObj();
edge.put("source", chapterOneIds.get(i));
edge.put("target", chapterOneIds.get(i + 1));
edge.put("type", "Subsequence");
edge.put("sta", 2);
edgesArray.add(edge);
}
//节与节 顺序
for (int i = 0; i < chapterTwoIds.size() - 1; i++) {
JSONObject edge = JSONUtil.createObj();
edge.put("source", chapterTwoIds.get(i));
edge.put("target", chapterTwoIds.get(i + 1));
edge.put("type", "Subsequence");
edge.put("sta", 2);
edgesArray.add(edge);
}
//点-点 顺序
for (int i = 0; i < knowIds.size() - 1; i++) {
JSONObject edge = JSONUtil.createObj();
edge.put("source", knowIds.get(i));
edge.put("target", knowIds.get(i + 1));
edge.put("type", "Subsequence");
edge.put("sta", 4);
edgesArray.add(edge);
}
String jsonNodeKnow = jsonArrayKnowNode.toString();
String jsonNodeChapter = jsonArrayChapterNode.toString();
String jsonNodeCourse = jsonArrayCourseNode.toString();
String jsonEdges = edgesArray.toString();
System.out.println("json node " + jsonNodeKnow);
System.out.println("json jsonNodeChapter " + jsonNodeChapter);
System.out.println("json edge " + jsonEdges);
return generateGraph(jsonNodeCourse, jsonNodeChapter, jsonNodeKnow, jsonEdges);
//将json保存在mysql表中
}
//todo 根据json串生成 图谱 保证事务
private BaseResponse<String> generateGraph(String jsonNodeCourse, String jsonNodeChapter, String jsonNodeKnow, String jsonEdges) {
//插入图
JSONArray jsonArrayCourse = JSONUtil.parseArray(jsonNodeCourse);
for (Object obj : jsonArrayCourse) {
JSONObject jsonObject = (JSONObject) obj;
String courseId = jsonObject.getStr("courseId");
String name = jsonObject.getStr("name");
String info = jsonObject.getStr("info");
Integer hour = jsonObject.getInt("hour");
//在图数据库中插入
Long res = knowRepository.addCourse(courseId, name, info, hour);
if (res == null) {
throw new RuntimeException("添加课程失败");
}
}
//插入章节
JSONArray jsonArray = JSONUtil.parseArray(jsonNodeChapter);
for (Object obj : jsonArray) {
JSONObject jsonObject = (JSONObject) obj;
Long chapterId = jsonObject.getLong("chapterId");
String name = jsonObject.getStr("name");
String info = jsonObject.getStr("info");
double hour = jsonObject.getDouble("hour");
//在图数据库中插入
Long res = knowRepository.addChapter(chapterId, name, info, hour);
if (res == null) {
throw new RuntimeException("添加章节失败");
}
}
//插入知识点
JSONArray jsonArrayKnow = JSONUtil.parseArray(jsonNodeKnow);
for (Object obj : jsonArrayKnow) {
JSONObject jsonObject = (JSONObject) obj;
Long knowId = jsonObject.getLong("knowId");
String name = jsonObject.getStr("name");
String info = jsonObject.getStr("info");
double hour = jsonObject.getDouble("hour");
//在图数据库中插入
Long res = knowRepository.addKnow(knowId, name, info, hour);
if (res == null) {
throw new RuntimeException("添加知识点失败");
}
}
//插入关系
JSONArray jsonArrayEdges = JSONUtil.parseArray(jsonEdges);
for (Object obj : jsonArrayEdges) {
JSONObject jsonObject = (JSONObject) obj;
String source = jsonObject.getStr("source");
String target = jsonObject.getStr("target");
String type = jsonObject.getStr("type");
Integer sta = jsonObject.getInt("sta");
//在图数据库中插入
if (sta != null && sta == 1) {
Long target1 = Long.parseLong(target);
int res = knowRepository.addCourseRelationship(source, target1, type);
if (res <= 0) {
throw new RuntimeException("添加关系 1 失败");
}
} else if (sta != null && sta == 2) {
Long source1 = Long.parseLong(source);
Long target1 = Long.parseLong(target);
int res = knowRepository.addChapterRelationship(source1, target1, type);
if (res <= 0) {
throw new RuntimeException("添加关系 2 失败");
}
} else if (sta != null && sta == 3) {
Long source1 = Long.parseLong(source);
Long target1 = Long.parseLong(target);
int res = knowRepository.addChapterToKnowRelationship(source1, target1, type);
if (res <= 0) {
throw new RuntimeException("添加关系 13失败");
}
} else if (sta != null && sta == 4) {
Long source1 = Long.parseLong(source);
Long target1 = Long.parseLong(target);
int res = knowRepository.addKnowRelationship(source1, target1, type);
if (res <= 0) {
throw new RuntimeException("添加关系 4 失败");
}
} else {
throw new RuntimeException("sta 错误");
}
}
return ResultUtils.success("添加节点关系成功");
}
@Transactional @Transactional
// todo 事务没有正确使用 public void addAllKnowTransation(String courseId) throws Exception {
public void addAllKnowTransation(String courseId) throws Exception{ int f;
//验证章节是否存在
//验证知识点是否存在,避免重复添加
//先添加节点
//后赋值关系
// 2.从课程表查出课程节点 并添加到 neo // 2.从课程表查出课程节点 并添加到 neo
Courses courses = coursesMapper.selectById(courseId); Courses courses = coursesMapper.selectById(courseId);
int f = knowRepository.addCourse(courseId,courses.getName(),courses.getDescription(),courses.getClasshours()); Long KnowCourseId = knowRepository.addCourse(courseId, courses.getName(), courses.getDescription(), courses.getClasshours());
if(f <= 0){
if (KnowCourseId == null) {
throw new RuntimeException("添加课程失败"); throw new RuntimeException("添加课程失败");
} }
// 3 从章节表查出章节节点 并添加到 neo // 3 从章节表查出章节节点 并添加到 neo
List<Chapter> chapterList = chapterMapper.selectSectionsByCourseId(courseId); List<Chapter> chapterList = new ArrayList<>();
List<Chapter> chapterListPID = chapterMapper.selectChapterPIDByCourseId(courseId);
for (int i = 0; i < chapterListPID.size(); i++) {
chapterList.add(chapterListPID.get(i));
List<Chapter> chapterListSecond = chapterMapper.selectChapterChildrenOrderByNum(chapterListPID.get(i).getId());
for (int j = 0; j < chapterListSecond.size(); j++) {
chapterList.add(chapterListSecond.get(j));
}
}
//添加节点
List<Long> chapterIds = new ArrayList<>();
List<Long> chapterOneIds = new ArrayList<>();
List<Long> chapterTwoIds = new ArrayList<>();
for (int i = 0; i < chapterList.size(); i++) { for (int i = 0; i < chapterList.size(); i++) {
Chapter chapter = chapterList.get(i); Chapter chapter = chapterList.get(i);
f =knowRepository.addChapter(chapter.getId(),chapter.getName(),chapter.getContent(),chapter.getTotalClassHours()); Long KnowChapterId = knowRepository.addChapter(chapter.getId(), chapter.getName(), chapter.getContent(), chapter.getTotalClassHours());
if(f <= 0){ if (chapter.getPid() == 0) {
chapterOneIds.add(KnowChapterId);
} else {
chapterTwoIds.add(KnowChapterId);
}
chapterIds.add(chapter.getId());
if (KnowChapterId == null) {
throw new RuntimeException("添加章节失败"); throw new RuntimeException("添加章节失败");
} }
} }
List<Long> idList = chapterList.stream()
.map(menu -> menu.getId())
.collect(Collectors.toList());
//获取chapterId 查询知识点 返回知识点集合 //获取chapterId 查询知识点 返回知识点集合
List<Knowtmp> knowlist = knowtmpService.queryByChapterIdList(idList); List<Long> knowIds = new ArrayList<>();
for (int i = 0; i < idList.size(); i++) { for (int i = 0; i < chapterList.size(); i++) {
List<Knowtmp> knowlist1 = knowtmpService.queryByChapterId(idList.get(i)); Chapter chapter = chapterList.get(i);
for (int j = 0; j < knowlist1.size(); j++) { if (chapter.getPid() != 0) {
Know know = knowRepository.addKnow(knowlist1.get(j).getName(),knowlist1.get(j).getInfo()); List<Knowtmp> knowlist = knowtmpService.queryByChapterId(chapter.getId());
if(know == null){ for (int j = 0; j < knowlist.size(); j++) {
throw new RuntimeException("添加知识点失败"); Long knowId = knowRepository.addKnow(knowlist.get(j).getId(), knowlist.get(j).getName(), knowlist.get(j).getInfo(), knowlist.get(j).getHour());
} knowIds.add(knowId);
f = knowRepository.addFatherAndSonWithKnow(know.getId(),idList.get(i)); if (knowId == null) {
if(f <= 0){ throw new RuntimeException("添加知识点失败");
throw new RuntimeException("添加知识点-章节失败"); }
//添加知识点关系
f = knowRepository.addContainWithKnow(knowId, chapterIds.get(i));
if (f <= 0) {
throw new RuntimeException("添加知识点-章节失败关系失败");
}
} }
} }
} }
for (int i = 0; i < chapterList.size(); i++) { for (int i = 0; i < chapterList.size(); i++) {
Chapter chapter = chapterList.get(i); Chapter chapter = chapterList.get(i);
if(chapter.getPid()== 0){ if (chapter.getPid() == 0) {
f = knowRepository.addFatherAndSonWithCourse(chapter.getCourseId(),chapter.getId()); f = knowRepository.addContainWithCourse(chapter.getCourseId(), chapter.getId());
if(f <= 0) throw new RuntimeException("添加课程-章节关系失败"); if (f <= 0) throw new RuntimeException("添加课程-章节关系失败");
}else{ } else {
f = knowRepository.addFatherAndSonWithChapter(chapter.getId(),chapter.getPid()); f = knowRepository.addContainWithChapter(chapter.getId(), chapter.getPid());
if(f <= 0) throw new RuntimeException("添加章节-章节关系失败"); if (f <= 0) throw new RuntimeException("添加章节-章节关系失败");
} }
} }
// for (int j = 0; j < knowlist.size(); j++) { //添加顺序关系
// Knowtmp knowtmp = knowlist.get(j);
// f = knowRepository.addFatherAndSonWithKnow(knowtmp.getId(),knowtmp.getChapterid());
// if(f <= 0) throw new RuntimeException("添加章节-知识点关系失败");
// }
} //给章添加顺序关系
for (int i = 0; i < chapterOneIds.size() - 1; i++) {
f = knowRepository.addOrderById(chapterOneIds.get(i), chapterOneIds.get(i + 1));
if (f <= 0) throw new RuntimeException("添加章-章 顺序关系失败");
}
@Override //给节添加顺序关系
public BaseResponse<String> addKnow(KnowRequest knowRequest) { for (int i = 0; i < chapterTwoIds.size() - 1; i++) {
Know know = new Know(); f = knowRepository.addOrderById(chapterTwoIds.get(i), chapterTwoIds.get(i + 1));
BeanUtils.copyProperties(knowRequest,know); if (f <= 0) throw new RuntimeException("添加节-节 顺序关系失败");
Know know1 = knowRepository.addKnow(know.getName(),know.getInfo()); }
if(know1 != null){ //给知识点添加顺序关系
return ResultUtils.success("添加知识点成功"); for (int i = 0; i < knowIds.size() - 1; i++) {
}else{ f = knowRepository.addOrderById(knowIds.get(i), knowIds.get(i + 1));
return ResultUtils.error(ErrorCode.OPERATION_ERROR,"添加知识点失败"); if (f <= 0) throw new RuntimeException("添加知识点-知识点 顺序关系失败");
} }
} }
// @Override
// public BaseResponse<String> addKnow(KnowRequest knowRequest) {
// Know know = new Know();
// BeanUtils.copyProperties(knowRequest,know);
// Long know1 = knowRepository.addKnow(know.getName(),know.getInfo());
// if(know1 != null){
// return ResultUtils.success("添加知识点成功");
// }else{
// return ResultUtils.error(ErrorCode.OPERATION_ERROR,"添加知识点失败");
// }
// }
@Override @Override
public BaseResponse<String> updateKnow(KnowUpdateRequest knowUpdateRequest) { public BaseResponse<String> updateKnow(KnowUpdateRequest knowUpdateRequest) {
Know know = new Know(); Know know = new Know();
BeanUtils.copyProperties(knowUpdateRequest,know); BeanUtils.copyProperties(knowUpdateRequest, know);
int f = knowRepository.updateKnow(know.getId(),know.getName(),know.getInfo()); int f = knowRepository.updateKnow(know.getId(), know.getName(), know.getInfo());
if(f > 0){ if (f > 0) {
return ResultUtils.success("修改知识点成功"); return ResultUtils.success("修改知识点成功");
}else{ } else {
return ResultUtils.error(ErrorCode.OPERATION_ERROR,"修改知识点失败"); return ResultUtils.error(ErrorCode.OPERATION_ERROR, "修改知识点失败");
} }
} }
@ -167,10 +642,10 @@ public class knowServiceImpl implements KnowService {
public BaseResponse<String> deleteKnow(Long id) { public BaseResponse<String> deleteKnow(Long id) {
// todo 判断知识点存在否 // todo 判断知识点存在否
int f = knowRepository.deleteKnow(id); int f = knowRepository.deleteKnow(id);
if(f > 0){ if (f > 0) {
return ResultUtils.success("删除知识点成功"); return ResultUtils.success("删除知识点成功");
}else{ } else {
return ResultUtils.error(ErrorCode.OPERATION_ERROR,"删除知识点失败"); return ResultUtils.error(ErrorCode.OPERATION_ERROR, "删除知识点失败");
} }
} }
@ -186,24 +661,24 @@ public class knowServiceImpl implements KnowService {
@Override @Override
public BaseResponse<String> addCourse(KnowCourseCreateRequest knowCourseCreateRequest) { public BaseResponse<String> addCourse(KnowCourseCreateRequest knowCourseCreateRequest) {
KnowCourse knowCourse = new KnowCourse(); KnowCourse knowCourse = new KnowCourse();
BeanUtils.copyProperties(knowCourseCreateRequest,knowCourse); BeanUtils.copyProperties(knowCourseCreateRequest, knowCourse);
int f = knowRepository.addCourse(knowCourse.getCourseId(),knowCourse.getName(),knowCourse.getInfo(),knowCourse.getHour()); Long knowCourse1 = knowRepository.addCourse(knowCourse.getCourseId(), knowCourse.getName(), knowCourse.getInfo(), knowCourse.getHour());
if(f >0){ if (knowCourse1 != null) {
return ResultUtils.success("添加知识点成功"); return ResultUtils.success("添加知识点成功");
}else{ } else {
return ResultUtils.error(ErrorCode.OPERATION_ERROR,"添加知识点失败"); return ResultUtils.error(ErrorCode.OPERATION_ERROR, "添加知识点失败");
} }
} }
@Override @Override
public BaseResponse<String> updateCourse(KnowCourseCreateRequest knowCourseCreateRequest) { public BaseResponse<String> updateCourse(KnowCourseCreateRequest knowCourseCreateRequest) {
KnowCourse knowCourse = new KnowCourse(); KnowCourse knowCourse = new KnowCourse();
BeanUtils.copyProperties(knowCourseCreateRequest,knowCourse); BeanUtils.copyProperties(knowCourseCreateRequest, knowCourse);
int f = knowRepository.updateCourse(knowCourse.getCourseId(),knowCourse.getName(),knowCourse.getInfo()); int f = knowRepository.updateCourse(knowCourse.getCourseId(), knowCourse.getName(), knowCourse.getInfo());
if(f > 0){ if (f > 0) {
return ResultUtils.success("修改知识点成功"); return ResultUtils.success("修改知识点成功");
}else{ } else {
return ResultUtils.error(ErrorCode.OPERATION_ERROR,"修改知识点失败"); return ResultUtils.error(ErrorCode.OPERATION_ERROR, "修改知识点失败");
} }
} }
@ -211,10 +686,10 @@ public class knowServiceImpl implements KnowService {
public BaseResponse<String> deleteCourse(String courseId) { public BaseResponse<String> deleteCourse(String courseId) {
int f = knowRepository.deleteCourse(courseId); int f = knowRepository.deleteCourse(courseId);
if(f > 0){ if (f > 0) {
return ResultUtils.success("删除知识点成功"); return ResultUtils.success("删除知识点成功");
}else{ } else {
return ResultUtils.error(ErrorCode.OPERATION_ERROR,"删除知识点失败"); return ResultUtils.error(ErrorCode.OPERATION_ERROR, "删除知识点失败");
} }
} }
@ -227,44 +702,43 @@ public class knowServiceImpl implements KnowService {
//========================= //=========================
@Override @Override
public BaseResponse<String> addChapter(KnowChapterCreateRequest knowChapterCreateRequest) { public BaseResponse<String> addChapter(KnowChapterCreateRequest knowChapterCreateRequest) {
KnowChapter knowChapter = new KnowChapter(); KnowChapter knowChapter = new KnowChapter();
BeanUtils.copyProperties(knowChapterCreateRequest,knowChapter); BeanUtils.copyProperties(knowChapterCreateRequest, knowChapter);
int f = knowRepository.addChapter(knowChapter.getChapterId(),knowChapter.getName(),knowChapter.getInfo(),knowChapter.getHour()); Long f = knowRepository.addChapter(knowChapter.getChapterId(), knowChapter.getName(), knowChapter.getInfo(), knowChapter.getHour());
if(f>0){ if (f > 0) {
return ResultUtils.success("添加章节成功"); return ResultUtils.success("添加章节成功");
}else{ } else {
return ResultUtils.error(ErrorCode.OPERATION_ERROR,"添加章节失败"); return ResultUtils.error(ErrorCode.OPERATION_ERROR, "添加章节失败");
} }
} }
@Override @Override
public BaseResponse<String> updateChapter(KnowChapterCreateRequest knowChapterCreateRequest) { public BaseResponse<String> updateChapter(KnowChapterCreateRequest knowChapterCreateRequest) {
KnowChapter knowChapter = new KnowChapter(); KnowChapter knowChapter = new KnowChapter();
BeanUtils.copyProperties(knowChapterCreateRequest,knowChapter); BeanUtils.copyProperties(knowChapterCreateRequest, knowChapter);
int f = knowRepository.updateChapter(knowChapter.getChapterId(),knowChapter.getName(),knowChapter.getInfo()); int f = knowRepository.updateChapter(knowChapter.getChapterId(), knowChapter.getName(), knowChapter.getInfo());
if(f > 0){ if (f > 0) {
return ResultUtils.success("修改知识点成功"); return ResultUtils.success("修改知识点成功");
}else{ } else {
return ResultUtils.error(ErrorCode.OPERATION_ERROR,"修改知识点失败"); return ResultUtils.error(ErrorCode.OPERATION_ERROR, "修改知识点失败");
} }
} }
@Override @Override
public BaseResponse<String> deleteChapter(Long chapterId) { public BaseResponse<String> deleteChapter(Long chapterId) {
int f = knowRepository.deleteChapter(chapterId); int f = knowRepository.deleteChapter(chapterId);
if(f > 0){ if (f > 0) {
return ResultUtils.success("删除知识点成功"); return ResultUtils.success("删除知识点成功");
}else{ } else {
return ResultUtils.error(ErrorCode.OPERATION_ERROR,"删除知识点失败"); return ResultUtils.error(ErrorCode.OPERATION_ERROR, "删除知识点失败");
} }
} }
@Override @Override
public BaseResponse<KnowChapter> queryChapter(Long chapterId) { public BaseResponse<KnowChapter> queryChapter(Long chapterId) {
KnowChapter knowChapter = knowRepository.queryChapter(chapterId); KnowChapter knowChapter = knowRepository.queryChapter(chapterId);
return ResultUtils.success(knowChapter); return ResultUtils.success(knowChapter);
} }
@ -274,18 +748,18 @@ public class knowServiceImpl implements KnowService {
@Override @Override
public BaseResponse<BaseKnowReturn> getAllKnowByCourseId(String id) { public BaseResponse<BaseKnowReturn> getAllKnowByCourseId(String id) {
Collection<Map<String, Object>> all = Collection<Map<String, Object>> all =
neo4jClient.query( "match(n:Know)-[r*0..]->(p:Know) where n.courseId = '"+id+"' return n as `n`,r as `r`,p as `p`,length(r) as `d`").fetch().all(); neo4jClient.query("match(n:Know)-[r:contain*0..4]->(p:Know) where n.courseId = '" + id + "' return n as `n`,r as `r`,p as `p`,length(r) as `d`").fetch().all();
Map<Long,String>colorChoose = new HashMap<>(); Map<Long, String> colorChoose = new HashMap<>();
String color[] = new String[10]; String color[] = new String[10];
String[] colorList = {"#91CC75", "#5470C6", "#FAC858", "#EE6666", "#73C0DE", "#EA7CCC", "#5577FF", "#5577FF", "#9DBFFF", "#78A7FF"}; String[] colorList = {"#91CC75", "#5470C6", "#FAC858", "#EE6666", "#73C0DE", "#EA7CCC", "#5577FF", "#5577FF", "#9DBFFF", "#78A7FF"};
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
colorChoose.put((long) i,colorList[i]); colorChoose.put((long) i, colorList[i]);
} }
Iterator<Map<String, Object>> iterator = all.iterator(); Iterator<Map<String, Object>> iterator = all.iterator();
Set<KnowVO> knowList = new HashSet<>(); Set<KnowVO> knowList = new HashSet<>();
Set<Links>linksList = new HashSet<>(); Set<Links> linksList = new HashSet<>();
KnowVO knowVO; KnowVO knowVO;
List node2 = new ArrayList<>(); List node2 = new ArrayList<>();
Links links; Links links;
@ -296,14 +770,73 @@ public class knowServiceImpl implements KnowService {
Node node1 = (Node) element.get("p"); Node node1 = (Node) element.get("p");
Long group = (Long) element.get("d"); Long group = (Long) element.get("d");
knowVO.setColor(colorChoose.get(group)); // knowVO.setColor(colorChoose.get(group));
if (node1 != null) {
Long id1 = node1.id();
String name1 = node1.get("name").asString();
knowVO.setId(id1);
knowVO.setLabel(name1);
knowList.add(knowVO);
knowVO.setColor(colorChoose.get(group));
}
node2 = (List) element.get("r");
if (!node2.isEmpty()) {
for (int i = 0; i < node2.size(); i++) {
InternalRelationship e = (InternalRelationship) node2.get(i);
links = new Links();
links.setId(e.id());
links.setSource(e.startNodeId());
links.setTarget(e.endNodeId());
if ("contain".equals(e.type())) {
links.setLabel("包含");
} else if ("order".equals(e.type())) {
links.setLabel("顺序");
}
linksList.add(links);
}
}
}
BaseKnowReturn baseKnowReturn = new BaseKnowReturn(knowList, linksList);
return ResultUtils.success(baseKnowReturn);
}
@Override
public BaseResponse<BaseKnowReturn> getsecondKnowsById(Long id) {
Collection<Map<String, Object>> all =
neo4jClient.query("match(n:Know)-[r*0..2]->(p:Know) where ID(n) = " + id + " return n as `n`,r as `r`,p as `p`,length(r) as `d`").fetch().all();
Map<Long, String> colorChoose = new HashMap<>();
String color[] = new String[10];
String[] colorList = {"#91CC75", "#5470C6", "#FAC858", "#EE6666", "#73C0DE", "#EA7CCC", "#5577FF", "#5577FF", "#9DBFFF", "#78A7FF"};
for (int i = 0; i < 10; i++) {
colorChoose.put((long) i, colorList[i]);
}
Iterator<Map<String, Object>> iterator = all.iterator();
Set<KnowVO> knowList = new HashSet<>();
Set<Links> linksList = new HashSet<>();
KnowVO knowVO;
List node2 = new ArrayList<>();
Links links;
int p = 0;
while (iterator.hasNext()) {
Map<String, Object> element = iterator.next();
knowVO = new KnowVO();
Node node1 = (Node) element.get("p");
Long group = (Long) element.get("d");
Long id1 = node1.id(); Long id1 = node1.id();
String name1 = node1.get("name").asString(); String name1 = node1.get("name").asString();
knowVO.setId(id1); knowVO.setId(id1);
knowVO.setLabel(name1); knowVO.setLabel(name1);
knowVO.setColor(colorChoose.get(group));
knowList.add(knowVO);
node2 = (List) element.get("r"); node2 = (List) element.get("r");
for (int i = 0; i < node2.size(); i++) { for (int i = 0; i < node2.size(); i++) {
@ -312,13 +845,18 @@ public class knowServiceImpl implements KnowService {
links.setId(e.id()); links.setId(e.id());
links.setSource(e.startNodeId()); links.setSource(e.startNodeId());
links.setTarget(e.endNodeId()); links.setTarget(e.endNodeId());
links.setLabel(e.type()); if ("contain".equals(e.type())) {
links.setLabel("包含");
} else if ("order".equals(e.type())) {
links.setLabel("顺序");
}
linksList.add(links); linksList.add(links);
} }
} }
BaseKnowReturn baseKnowReturn = new BaseKnowReturn(knowList,linksList);
BaseKnowReturn baseKnowReturn = new BaseKnowReturn(knowList, linksList);
return ResultUtils.success(baseKnowReturn); return ResultUtils.success(baseKnowReturn);
} }
@ -326,7 +864,7 @@ public class knowServiceImpl implements KnowService {
@Override @Override
public BaseResponse<Set<KnowVO1>> getAllResourcesByCourseId(String id) { public BaseResponse<Set<KnowVO1>> getAllResourcesByCourseId(String id) {
Collection<Map<String, Object>> all = Collection<Map<String, Object>> all =
neo4jClient.query( "match(n:Know)-[r*0..]->(p:Know) where n.courseId = '"+id+"' return p as `p`").fetch().all(); neo4jClient.query("match(n:Know)-[r*0..]->(p:Know) where n.courseId = '" + id + "' return p as `p`").fetch().all();
Iterator<Map<String, Object>> iterator = all.iterator(); Iterator<Map<String, Object>> iterator = all.iterator();
Set<KnowVO1> knowList = new HashSet<>(); Set<KnowVO1> knowList = new HashSet<>();
KnowVO1 knowVO; KnowVO1 knowVO;
@ -344,5 +882,4 @@ public class knowServiceImpl implements KnowService {
} }
} }

@ -3,7 +3,7 @@ package com.teaching.backend.service.impl.knowledge;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.teaching.backend.mapper.KnowGraph.KnowledgeLearningNumberMapper; 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 com.teaching.backend.service.KnowGraph.IKnowledgeLearningNumberService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;

@ -5,8 +5,10 @@ import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.common.ErrorCode; import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.common.ResultUtils; import com.teaching.backend.common.ResultUtils;
import com.teaching.backend.mapper.Knowtemp.KnowtmpMapper; import com.teaching.backend.mapper.Knowtemp.KnowtmpMapper;
import com.teaching.backend.mapper.chapter.ChapterMapper;
import com.teaching.backend.model.dto.Knowtmp.KnowtempAdd; import com.teaching.backend.model.dto.Knowtmp.KnowtempAdd;
import com.teaching.backend.model.dto.Knowtmp.KnowtempUpdate; import com.teaching.backend.model.dto.Knowtmp.KnowtempUpdate;
import com.teaching.backend.model.entity.chapter.Chapter;
import com.teaching.backend.model.entity.knowtmp.Knowtmp; import com.teaching.backend.model.entity.knowtmp.Knowtmp;
import com.teaching.backend.service.knowtmp.KnowtmpService; import com.teaching.backend.service.knowtmp.KnowtmpService;
import org.checkerframework.checker.units.qual.A; import org.checkerframework.checker.units.qual.A;
@ -14,6 +16,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
@ -24,9 +27,24 @@ import java.util.List;
@Service @Service
public class KnowtmpServiceImpl implements KnowtmpService { public class KnowtmpServiceImpl implements KnowtmpService {
@Autowired
private ChapterMapper chapterMapper;
@Autowired @Autowired
private KnowtmpMapper knowtmpMapper; private KnowtmpMapper knowtmpMapper;
@Override
public BaseResponse<Long> getAllKnows(String courseId) {
// 3 从章节表查出章节节点 并添加到 neo
List<Long> chapterIds = chapterMapper.selectChapterIdsByCourseId(courseId);
//获取chapterId 查询知识点 返回知识点集合
QueryWrapper<Knowtmp> objectQueryWrapper = new QueryWrapper<>();
objectQueryWrapper.in("chapterid",chapterIds);
Long count = knowtmpMapper.selectCount(objectQueryWrapper);
return ResultUtils.success(count);
}
@Override @Override
public BaseResponse<String> add(KnowtempAdd knowtempAdd) { public BaseResponse<String> add(KnowtempAdd knowtempAdd) {
Knowtmp knowtmp = new Knowtmp(); Knowtmp knowtmp = new Knowtmp();
@ -70,10 +88,7 @@ public class KnowtmpServiceImpl implements KnowtmpService {
@Override @Override
public List<Knowtmp> queryByChapterId(Long chapterId) { public List<Knowtmp> queryByChapterId(Long chapterId) {
Knowtmp knowtmp = new Knowtmp(); List<Knowtmp> knowtmps = knowtmpMapper.queryIdByChapterId(chapterId);
QueryWrapper<Knowtmp> knowtmpQueryWrapper = new QueryWrapper<>();
knowtmpQueryWrapper.eq("chapterId",chapterId);
List<Knowtmp> knowtmps = knowtmpMapper.selectList(knowtmpQueryWrapper);
return knowtmps; return knowtmps;
} }

@ -7,9 +7,11 @@ import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.exception.BusinessException; import com.teaching.backend.exception.BusinessException;
import com.teaching.backend.mapper.message.MessagesMapper; import com.teaching.backend.mapper.message.MessagesMapper;
import com.teaching.backend.mapper.message.UserInboxMapper; import com.teaching.backend.mapper.message.UserInboxMapper;
import com.teaching.backend.mapper.umsAdmin.UmsUserMapper;
import com.teaching.backend.model.dto.message.SysMessageDTO; import com.teaching.backend.model.dto.message.SysMessageDTO;
import com.teaching.backend.model.entity.message.SysMessages; import com.teaching.backend.model.entity.message.SysMessages;
import com.teaching.backend.model.entity.message.UserInbox; import com.teaching.backend.model.entity.message.UserInbox;
import com.teaching.backend.model.entity.umsAdmin.UmsUser;
import com.teaching.backend.service.message.IMessagesService; import com.teaching.backend.service.message.IMessagesService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
@ -38,6 +40,8 @@ public class MessagesServiceImpl extends ServiceImpl<MessagesMapper, SysMessages
@Autowired @Autowired
private UserInboxMapper userInboxMapper; private UserInboxMapper userInboxMapper;
@Autowired
private UmsUserMapper umsUserMapper;
@Override @Override
@Transactional @Transactional
public String sendMessageToUserInbox(SysMessageDTO sysMessageDTO) { public String sendMessageToUserInbox(SysMessageDTO sysMessageDTO) {
@ -51,8 +55,20 @@ public class MessagesServiceImpl extends ServiceImpl<MessagesMapper, SysMessages
List<Long> receiverIds = Arrays.stream(sysMessageDTO.getReceiverId().split(",")) List<Long> receiverIds = Arrays.stream(sysMessageDTO.getReceiverId().split(","))
.map(Long::valueOf) .map(Long::valueOf)
.collect(Collectors.toList()); .collect(Collectors.toList());
if (receiverIds.size()<1){
throw new BusinessException(ErrorCode.LEAST_ONE_USER);
}
// 4.判断是什么用户,只有教师可以群发,学生只能单发
String roleId = umsUserMapper.selectOne(new LambdaQueryWrapper<>(UmsUser.class)
.eq(UmsUser::getId, sysMessageDTO.getSenderId())).getRoleId();
if(roleId.equals("2")){
if (receiverIds.size()>1){
throw new BusinessException(ErrorCode.STUDENT_ROLE_CANT_MULTIPLESEND);
}
}
// 4.数据写入收件箱 // 5.数据写入收件箱
List<UserInbox> userInboxes = receiverIds.stream() List<UserInbox> userInboxes = receiverIds.stream()
.map(receiverId -> { .map(receiverId -> {
UserInbox userInbox = new UserInbox(); UserInbox userInbox = new UserInbox();
@ -68,7 +84,7 @@ public class MessagesServiceImpl extends ServiceImpl<MessagesMapper, SysMessages
throw new BusinessException(ErrorCode.OPERATION_ERROR, "收件箱数据插入失败!"); throw new BusinessException(ErrorCode.OPERATION_ERROR, "收件箱数据插入失败!");
} }
// 5.更新或保存消息数据 // 6.更新或保存消息数据
SysMessages sysMessages = new SysMessages(); SysMessages sysMessages = new SysMessages();
BeanUtils.copyProperties(sysMessageDTO, sysMessages); BeanUtils.copyProperties(sysMessageDTO, sysMessages);
sysMessages.setId(messageId); sysMessages.setId(messageId);

@ -56,7 +56,6 @@ public class UserInboxServiceImpl extends ServiceImpl<UserInboxMapper, UserInbox
@Autowired @Autowired
private UserInboxMapper userInboxMapper; private UserInboxMapper userInboxMapper;
//TODO 不需要特别指定“已读”或者是“未读”
@Override @Override
public PageDTO<SysMessageVO> queryReceiveMessages(MessagesQuery messagesQuery) { public PageDTO<SysMessageVO> queryReceiveMessages(MessagesQuery messagesQuery) {
// 先按用户的id找到其的消息列表 默认看未删除的,(是否读 作为筛选条件后传进去) // 先按用户的id找到其的消息列表 默认看未删除的,(是否读 作为筛选条件后传进去)
@ -126,10 +125,10 @@ public class UserInboxServiceImpl extends ServiceImpl<UserInboxMapper, UserInbox
@Override @Override
public PageDTO<SysMessageVO> querySendMessages(MessagesQuery messagesQuery) { public PageDTO<SysMessageVO> querySendMessages(MessagesQuery messagesQuery) {
// 初始化一个按发送时间降序排序的Page对象 // 1. 初始化一个按发送时间降序排序的Page对象
Page<SysMessages> page = messagesQuery.toMpPage("send_time", false); Page<SysMessages> page = messagesQuery.toMpPage("send_time", false);
// 根据条件查询SysMessages表 // 2. 根据条件查询SysMessages表
Page<SysMessages> p = messagesService.page(page, Page<SysMessages> p = messagesService.page(page,
new LambdaQueryWrapper<SysMessages>() new LambdaQueryWrapper<SysMessages>()
.eq(SysMessages::getSenderId, messagesQuery.getUserId()) .eq(SysMessages::getSenderId, messagesQuery.getUserId())
@ -138,7 +137,7 @@ public class UserInboxServiceImpl extends ServiceImpl<UserInboxMapper, UserInbox
.select(SysMessages::getId, SysMessages::getCourseId, SysMessages::getTitle, SysMessages::getSendTime) .select(SysMessages::getId, SysMessages::getCourseId, SysMessages::getTitle, SysMessages::getSendTime)
); );
// 将Page<SysMessages>转换为PageDTO<SysMessageVO> // 3. 将Page<SysMessages>转换为PageDTO<SysMessageVO>
PageDTO<SysMessageVO> messages = PageDTO.of(p, SysMessageVO.class); PageDTO<SysMessageVO> messages = PageDTO.of(p, SysMessageVO.class);
List<SysMessageVO> messagesList = messages.getList(); List<SysMessageVO> messagesList = messages.getList();
@ -146,31 +145,33 @@ public class UserInboxServiceImpl extends ServiceImpl<UserInboxMapper, UserInbox
throw new BusinessException(ErrorCode.MESSAGE_NO_EXIT); throw new BusinessException(ErrorCode.MESSAGE_NO_EXIT);
} }
// 批量查询课程名称 // 4. 批量查询课程ID
Set<String> courseIds = messagesList.stream() Set<String> courseIds = messagesList.stream()
.map(SysMessageVO::getCourseId) .map(SysMessageVO::getCourseId)
.filter(Objects::nonNull) .filter(Objects::nonNull)
.collect(Collectors.toSet()); .collect(Collectors.toSet());
// 5. 批量查询课程ID对应的课程名称 并把ID:name 对应到一起
Map<String, String> courseNames = coursesMapper.selectBatchIds(courseIds).stream() Map<String, String> courseNames = coursesMapper.selectBatchIds(courseIds).stream()
.collect(Collectors.toMap(Courses::getId, Courses::getName)); .collect(Collectors.toMap(Courses::getId, Courses::getName));
// 批量查询所有用户收件箱数据 // 6. 批量查询当前用户对应的消息集合messageIds
Set<Long> messageIds = messagesList.stream() Set<Long> messageIds = messagesList.stream()
.map(SysMessageVO::getId) .map(SysMessageVO::getId)
.collect(Collectors.toSet()); .collect(Collectors.toSet());
// 在用户邮箱中批量查询 对应消息的 信息(消息id,接受者id,是否已读)
List<UserInbox> allUserInboxes = userInboxMapper.selectList( List<UserInbox> allUserInboxes = userInboxMapper.selectList(
new LambdaQueryWrapper<UserInbox>() new LambdaQueryWrapper<UserInbox>()
.in(UserInbox::getMessageId, messageIds) .in(UserInbox::getMessageId, messageIds)
.select(UserInbox::getMessageId, UserInbox::getReceiverId, UserInbox::getIsRead) .select(UserInbox::getMessageId, UserInbox::getReceiverId, UserInbox::getIsRead)
); );
// 将UserInbox数据按消息ID进行分组 // 7. 将UserInbox数据按消息ID进行分组(已经初步得到了消息的详情)
Map<Long, List<UserInbox>> userInboxesByMessageId = allUserInboxes.stream() Map<Long, List<UserInbox>> userInboxesByMessageId = allUserInboxes.stream()
.collect(Collectors.groupingBy(UserInbox::getMessageId)); .collect(Collectors.groupingBy(UserInbox::getMessageId));
// 缓存用户名称以避免重复查询 // 8. 缓存用户名称以避免重复查询
Map<Long, String> userNamesCache = new HashMap<>(); Map<Long, String> userNamesCache = new HashMap<>();
for (SysMessageVO sysMessageVO : messagesList) { for (SysMessageVO sysMessageVO : messagesList) {
@ -201,7 +202,7 @@ public class UserInboxServiceImpl extends ServiceImpl<UserInboxMapper, UserInbox
UmsTeacher umsTeacher = umsTeacherMapper.selectOne( UmsTeacher umsTeacher = umsTeacherMapper.selectOne(
new LambdaQueryWrapper<UmsTeacher>().eq(UmsTeacher::getUserId, id) new LambdaQueryWrapper<UmsTeacher>().eq(UmsTeacher::getUserId, id)
); );
return umsTeacher != null ? umsTeacher.getName() : null; return umsTeacher != null ? umsTeacher.getName() : "教师不存在";
} }
}); });
@ -213,20 +214,27 @@ public class UserInboxServiceImpl extends ServiceImpl<UserInboxMapper, UserInbox
} }
} }
// 更新PageDTO中的消息列表并返回 // 9. 更新PageDTO中的消息列表并返回
messages.setList(messagesList); messages.setList(messagesList);
return messages; return messages;
} }
@Override @Override
public SysMessageVO getMessageDetail(MessagesQuery messagesQuery) { public SysMessageVO getMessageDetail(MessagesQuery messagesQuery) {
Long count = userInboxMapper.selectCount(new LambdaQueryWrapper<>(UserInbox.class)
.eq(UserInbox::getMessageId, messagesQuery.getMessageId())
.eq(UserInbox::getReceiverId, messagesQuery.getUserId()));
if (!(count > 0)){
throw new BusinessException(ErrorCode.MESSAGE_NO_EXIT);
}
SysMessages sysMessage = messagesService.getById(messagesQuery.getMessageId()); SysMessages sysMessage = messagesService.getById(messagesQuery.getMessageId());
SysMessageVO sysMessageVO = new SysMessageVO(); SysMessageVO sysMessageVO = new SysMessageVO();
sysMessageVO.setId(messagesQuery.getMessageId()); sysMessageVO.setId(messagesQuery.getMessageId());
sysMessageVO.setContent(sysMessage.getContent()); sysMessageVO.setContent(sysMessage.getContent());
sysMessageVO.setSenderId(messagesQuery.getUserId()); sysMessageVO.setSenderId(messagesQuery.getUserId());
// 获取发件人信息 //获取发件人信息
UmsTeacher umsTeacher = umsTeacherMapper.selectOne( UmsTeacher umsTeacher = umsTeacherMapper.selectOne(
new LambdaQueryWrapper<UmsTeacher>() new LambdaQueryWrapper<UmsTeacher>()
.eq(UmsTeacher::getUserId, sysMessage.getSenderId())); .eq(UmsTeacher::getUserId, sysMessage.getSenderId()));

@ -7,7 +7,7 @@ import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.common.ResultUtils; import com.teaching.backend.common.ResultUtils;
import com.teaching.backend.mapper.courses.CoursesMapper; import com.teaching.backend.mapper.courses.CoursesMapper;
import com.teaching.backend.mapper.records.CourseLearningRecordMapper; 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.mapper.umsAdmin.UmsUserMapper;
import com.teaching.backend.model.entity.courses.Courses; import com.teaching.backend.model.entity.courses.Courses;
import com.teaching.backend.model.entity.records.CourseLearningRecord; import com.teaching.backend.model.entity.records.CourseLearningRecord;
@ -74,6 +74,7 @@ public class CourseLearningRecordServiceImpl extends ServiceImpl<CourseLearningR
CourseLearningNumber courseLearningNumber = new CourseLearningNumber(); CourseLearningNumber courseLearningNumber = new CourseLearningNumber();
courseLearningNumber.setNumber(1); courseLearningNumber.setNumber(1);
courseLearningNumber.setCourseId(courseId); courseLearningNumber.setCourseId(courseId);
courseLearningNumber.setTeacherUserId(courseLearningRecord.getTeacherUserId());
courseLearningNumberService.save(courseLearningNumber); courseLearningNumberService.save(courseLearningNumber);
//System.out.println("该课程第一次被学习"); //System.out.println("该课程第一次被学习");
} }
@ -123,10 +124,10 @@ public class CourseLearningRecordServiceImpl extends ServiceImpl<CourseLearningR
@Override @Override
public List<CoursesVO> queryCourseList(String userId) { public List<CoursesVO> queryCourseList(String userId) {
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);
@ -148,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;
} }
} }

@ -10,20 +10,15 @@ 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.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.courses.CourseLearningNumber;
import com.teaching.backend.model.entity.courses.Courses;
import com.teaching.backend.model.entity.knowtmp.Knowtmp; import com.teaching.backend.model.entity.knowtmp.Knowtmp;
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.entity.records.RecordKnowledgeFinish;
import com.teaching.backend.model.vo.knowGraph.KnowVO; 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.Know.KnowService;
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.knowtmp.KnowtmpService; import com.teaching.backend.service.knowtmp.KnowtmpService;
import com.teaching.backend.service.records.IKnowledgeLearningRecordService; import com.teaching.backend.service.records.IKnowledgeLearningRecordService;
@ -56,6 +51,8 @@ public class KnowledgeLearningRecordServiceImpl extends ServiceImpl<KnowledgeLea
private KnowledgeLearningRecordMapper knowledgeLearningRecordMapper; private KnowledgeLearningRecordMapper knowledgeLearningRecordMapper;
@Resource @Resource
private KnowtmpService knowtmpService; private KnowtmpService knowtmpService;
@Resource
private RecordKnowledgeFinishServiceImpl recordKnowledgeFinishService;
@Override @Override
public BaseResponse<String> saveCoursesRecords(KnowledgeLearningRecord knowledgeLearningRecord) { public BaseResponse<String> saveCoursesRecords(KnowledgeLearningRecord knowledgeLearningRecord) {
@ -84,7 +81,14 @@ public class KnowledgeLearningRecordServiceImpl extends ServiceImpl<KnowledgeLea
.eq("course_id", courseId) .eq("course_id", courseId)
.eq("knowledge_id",knowledgeId).update(); .eq("knowledge_id",knowledgeId).update();
System.out.println("用户:"+userId+":第一次学这门课"); System.out.println("用户:"+userId+":第一次学这门课");
//添加完成状态
recordKnowledgeFinishService.addFinish(knowledgeLearningRecord);
}//自己学过
else {
if (knowledgeLearningRecord.getFinish() == 1){
//改变完成状态
recordKnowledgeFinishService.editFinish(knowledgeLearningRecord);
}
} }
}else {//没人学过(自己肯定也没学) }else {//没人学过(自己肯定也没学)
//该课程第一次被学,人数设置为1 //该课程第一次被学,人数设置为1
@ -93,18 +97,25 @@ public class KnowledgeLearningRecordServiceImpl extends ServiceImpl<KnowledgeLea
knowledgeLearningNumber.setCourseId(courseId); knowledgeLearningNumber.setCourseId(courseId);
knowledgeLearningNumber.setKnowledgeId(knowledgeId); knowledgeLearningNumber.setKnowledgeId(knowledgeId);
knowledgeLearningNumberService.save(knowledgeLearningNumber); knowledgeLearningNumberService.save(knowledgeLearningNumber);
//添加完成状态
recordKnowledgeFinishService.addFinish(knowledgeLearningRecord);
} }
//设置人数 //设置人数
String numberId = knowledgeLearningNumberService.query() String numberId = knowledgeLearningNumberService.query()
.eq("course_id", courseId) .eq("course_id", courseId)
.eq("knowledge_id",knowledgeId).one().getId(); .eq("knowledge_id",knowledgeId).one().getId();
knowledgeLearningRecord.setNumber(numberId); knowledgeLearningRecord.setNumber(numberId);
//设置完成状态
Integer finishId = recordKnowledgeFinishService.query()
.eq("course_id", courseId)
.eq("knowledge_id", knowledgeId)
.eq("user_id",userId).one().getId();
knowledgeLearningRecord.setFinish(finishId);
//保存记录 //保存记录
save(knowledgeLearningRecord); save(knowledgeLearningRecord);
return ResultUtils.success("添加成功"); return ResultUtils.success("添加成功");
} }
@Override @Override
public BaseResponse<Page> getPage(int pagenum, int pagesize, String userId, String courseId) { public BaseResponse<Page> getPage(int pagenum, int pagesize, String userId, String courseId) {
//格式化时间 //格式化时间
@ -117,6 +128,7 @@ public class KnowledgeLearningRecordServiceImpl extends ServiceImpl<KnowledgeLea
.eq("courses_id",courseId).page(new Page<>(pagenum, pagesize)); .eq("courses_id",courseId).page(new Page<>(pagenum, pagesize));
Page<KnowledgeLearningRecordVo> page1 = new Page<>(); Page<KnowledgeLearningRecordVo> page1 = new Page<>();
List<KnowledgeLearningRecord> records = page.getRecords(); List<KnowledgeLearningRecord> records = page.getRecords();
//System.out.println(records);
BeanUtil.copyProperties(page, page1); BeanUtil.copyProperties(page, page1);
List<KnowledgeLearningRecordVo> recordsVos = new ArrayList<>(); List<KnowledgeLearningRecordVo> recordsVos = new ArrayList<>();
//copy集合 //copy集合
@ -127,8 +139,11 @@ public class KnowledgeLearningRecordServiceImpl extends ServiceImpl<KnowledgeLea
knowledgeLearningRecordVo.setTime(sdf.format(date)); knowledgeLearningRecordVo.setTime(sdf.format(date));
// //填充学习人数 // //填充学习人数
knowledgeLearningRecordVo.setNumber(knowledgeLearningNumberService.getById(knowledgeLearningRecord.getNumber()).getNumber()); knowledgeLearningRecordVo.setNumber(knowledgeLearningNumberService.getById(knowledgeLearningRecord.getNumber()).getNumber());
//获取完成状态
knowledgeLearningRecordVo.setFinish(recordKnowledgeFinishService.getById(knowledgeLearningRecord.getFinish()).getFinish());
recordsVos.add(knowledgeLearningRecordVo); recordsVos.add(knowledgeLearningRecordVo);
}); });
//System.out.println(recordsVos);
page1.setRecords(recordsVos); page1.setRecords(recordsVos);
return ResultUtils.success(page1); return ResultUtils.success(page1);
} }
@ -141,7 +156,7 @@ public class KnowledgeLearningRecordServiceImpl extends ServiceImpl<KnowledgeLea
@Override @Override
public List<KnowVO> queryMaxKnowledge(String userId) { public List<KnowVO> queryMaxKnowledge(String userId) {
String roleId = umsUserMapper.getbyIdRoleId(userId); String roleId = umsUserMapper.getByIdRoleId(userId);
List<KnowVO> coursesList = new ArrayList<>(); List<KnowVO> coursesList = new ArrayList<>();
KnowVO knowVO = null; KnowVO knowVO = null;
if (roleId.equals("1")){ if (roleId.equals("1")){
@ -177,4 +192,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;
}
} }

@ -0,0 +1,64 @@
package com.teaching.backend.service.impl.records;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.teaching.backend.mapper.records.RecordKnowledgeFinishMapper;
import com.teaching.backend.model.entity.records.KnowledgeLearningRecord;
import com.teaching.backend.model.entity.records.RecordKnowledgeFinish;
import com.teaching.backend.model.entity.records.ResourceLearningRecord;
import com.teaching.backend.service.records.IRecordKnowledgeFinishService;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author author
* @since 2024-08-20
*/
@Service
public class RecordKnowledgeFinishServiceImpl extends ServiceImpl<RecordKnowledgeFinishMapper, RecordKnowledgeFinish> 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);
}
}

@ -0,0 +1,53 @@
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;
/**
* <p>
* 服务实现类
* </p>
*
* @author author
* @since 2024-08-20
*/
@Service
public class RecordResourceFinishServiceImpl extends ServiceImpl<RecordResourceFinishMapper, RecordResourceFinish> 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);
}
}

@ -7,6 +7,7 @@ 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.ResourceLearningRecordMapper; 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.ResourceLearningNumber;
import com.teaching.backend.model.entity.records.ResourceLearningRecord; import com.teaching.backend.model.entity.records.ResourceLearningRecord;
@ -35,6 +36,8 @@ public class ResourceLearningRecordServiceImpl extends ServiceImpl<ResourceLearn
@Resource @Resource
private ResourceLearningNumberServiceImpl resourceLearningNumberService; private ResourceLearningNumberServiceImpl resourceLearningNumberService;
@Resource
private RecordResourceFinishServiceImpl recordResourceFinishService;
@Override @Override
public BaseResponse<String> saveCoursesRecords(ResourceLearningRecord resourceLearningRecord) { public BaseResponse<String> saveCoursesRecords(ResourceLearningRecord resourceLearningRecord) {
@ -65,6 +68,13 @@ public class ResourceLearningRecordServiceImpl extends ServiceImpl<ResourceLearn
.eq("knowledge_id",knowledgeId) .eq("knowledge_id",knowledgeId)
.eq("resource_id",resourceId).update(); .eq("resource_id",resourceId).update();
// System.out.println("用户:"+userId+"第一次学这门课"); // System.out.println("用户:"+userId+"第一次学这门课");
//添加完成状态
recordResourceFinishService.addFinish(resourceLearningRecord);
}else {
if (resourceLearningRecord.getFinish() == 1){
//改变完成状态
recordResourceFinishService.editFinish(resourceLearningRecord);
}
} }
}else { }else {
//该课程第一次被学,人数设置为1 //该课程第一次被学,人数设置为1
@ -74,6 +84,8 @@ public class ResourceLearningRecordServiceImpl extends ServiceImpl<ResourceLearn
resourceLearningNumber.setKnowledgeId(knowledgeId); resourceLearningNumber.setKnowledgeId(knowledgeId);
resourceLearningNumber.setResourceId(resourceId); resourceLearningNumber.setResourceId(resourceId);
resourceLearningNumberService.save(resourceLearningNumber); resourceLearningNumberService.save(resourceLearningNumber);
//添加完成状态
recordResourceFinishService.addFinish(resourceLearningRecord);
} }
//设置人数 //设置人数
String numberId = resourceLearningNumberService.query() String numberId = resourceLearningNumberService.query()
@ -81,6 +93,12 @@ public class ResourceLearningRecordServiceImpl extends ServiceImpl<ResourceLearn
.eq("knowledge_id",knowledgeId) .eq("knowledge_id",knowledgeId)
.eq("resource_id",resourceId).one().getId(); .eq("resource_id",resourceId).one().getId();
resourceLearningRecord.setNumber(numberId); resourceLearningRecord.setNumber(numberId);
//设置完成状态
Integer finishId = recordResourceFinishService.query()
.eq("course_id", courseId)
.eq("knowledge_id", knowledgeId)
.eq("user_id",userId).one().getId();
resourceLearningRecord.setFinish(finishId);
//保存记录 //保存记录
save(resourceLearningRecord); save(resourceLearningRecord);
return ResultUtils.success("添加成功"); return ResultUtils.success("添加成功");
@ -88,7 +106,7 @@ public class ResourceLearningRecordServiceImpl extends ServiceImpl<ResourceLearn
@Override @Override
public BaseResponse<Page> getPage(int pagenum, int pagesize, String userId, String knowledgeId, String courseId) { public BaseResponse<Page> getPage(int pagenum, int pagesize, String userId, String knowledgeId, String courseId) {
//格式化时间 //格式化时间
String strDateFormat = "yyyy-MM-dd HH:mm:ss"; String strDateFormat = "yyyy-MM-dd HH:mm:ss";
SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat); SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat);
//分页查询 //分页查询

@ -164,6 +164,13 @@ public class ResourceServiceImpl implements ResourceService {
return ResultUtils.success(resourcesSet); return ResultUtils.success(resourcesSet);
} }
@Override
public BaseResponse<Set<Resources>> queryResourcesByKnowId(Long KnowId) {
// todo 判空,查询
Set<Resources>resourcesSet ;
resourcesSet = resourcesRepository.queryResourcesByKnowId(KnowId);
return ResultUtils.success(resourcesSet);
}
} }

@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DriverManager; import java.sql.DriverManager;
@ -53,7 +54,7 @@ public class UmsStudentManageServiceImpl extends ServiceImpl<UmsStudentManageMap
@Override @Override
public Map<String, Object> pageQuery(UmsStudentPageQueryDTO umsStudentPageQueryDTO) { public Map<String, Object> pageQuery(UmsStudentPageQueryDTO umsStudentPageQueryDTO) {
LinkedHashSet<UmsStudentManage> umsStudentManages = coursesService.queryTeacherByStudentList(umsStudentPageQueryDTO.getUserId()); List<UmsStudentManage> umsStudentManages = coursesService.queryTeacherByStudentList(umsStudentPageQueryDTO.getUserId());
//总记录数 //总记录数
int totalCount = umsStudentManages.size(); int totalCount = umsStudentManages.size();
@ -61,17 +62,40 @@ public class UmsStudentManageServiceImpl extends ServiceImpl<UmsStudentManageMap
//总页数 //总页数
int totalPages = (int) Math.ceil((double) totalCount / umsStudentPageQueryDTO.getPageSize()); int totalPages = (int) Math.ceil((double) totalCount / umsStudentPageQueryDTO.getPageSize());
List<UmsStudentManage> umsStudentManageList = umsStudentManages.stream()
.skip((umsStudentPageQueryDTO.getPage() - 1) * umsStudentPageQueryDTO.getPageSize())
.limit(umsStudentPageQueryDTO.getPageSize())
.collect(Collectors.toList());
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
result.put("Records", umsStudentManageList);
result.put("totalCount", totalCount); result.put("totalCount", totalCount);
result.put("totalPages", totalPages); result.put("totalPages", totalPages);
result.put("currentPage", umsStudentPageQueryDTO.getPage()); result.put("currentPage", umsStudentPageQueryDTO.getPage());
//对集合里的数据进行模糊和分页查询
if (StringUtils.hasText(umsStudentPageQueryDTO.getName())){
List<UmsStudentManage> umsStudentManageList = umsStudentManages.stream()
.filter(studentManage ->
studentManage != null &&
studentManage.getName() != null &&
studentManage.getName().contains(umsStudentPageQueryDTO.getName()))
.skip((umsStudentPageQueryDTO.getPage() - 1) * umsStudentPageQueryDTO.getPageSize())
.limit(umsStudentPageQueryDTO.getPageSize())
.collect(Collectors.toList());
result.put("Records", umsStudentManageList);
}else if (StringUtils.hasText(umsStudentPageQueryDTO.getNumber())){
List<UmsStudentManage> umsStudentManageList = umsStudentManages.stream()
.filter(studentManage ->
studentManage != null &&
studentManage.getNumber() != null &&
studentManage.getNumber().contains(umsStudentPageQueryDTO.getNumber()))
.skip((umsStudentPageQueryDTO.getPage() - 1) * umsStudentPageQueryDTO.getPageSize())
.limit(umsStudentPageQueryDTO.getPageSize())
.collect(Collectors.toList());
result.put("Records", umsStudentManageList);
}else {
List<UmsStudentManage> umsStudentManageList = umsStudentManages.stream()
.skip((umsStudentPageQueryDTO.getPage() - 1) * umsStudentPageQueryDTO.getPageSize())
.limit(umsStudentPageQueryDTO.getPageSize())
.collect(Collectors.toList());
result.put("Records", umsStudentManageList);
}
return result; return result;
} }
@ -91,7 +115,7 @@ public class UmsStudentManageServiceImpl extends ServiceImpl<UmsStudentManageMap
} }
UmsUser umsUser = new UmsUser(); UmsUser umsUser = new UmsUser();
BeanUtils.copyProperties(umsStudentManage, umsUser); BeanUtils.copyProperties(umsStudentManage, umsUser);
umsUser.setId(Long.valueOf(umsStudentManage.getUserId())); umsUser.setId(umsStudentManage.getUserId());
boolean userInformation = umsUserMapper.updateUserInformation(umsUser); boolean userInformation = umsUserMapper.updateUserInformation(umsUser);
if (userInformation == false){ if (userInformation == false){
throw new BusinessException(400,"修改失败"); throw new BusinessException(400,"修改失败");
@ -100,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

@ -42,8 +42,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import static com.teaching.backend.constant.RoleConstants.TEACHER_ROLE;
@Service @Service
@Slf4j @Slf4j
public class UmsUserServiceImpl extends ServiceImpl<UmsUserMapper, UmsUser> implements UmsUserService { public class UmsUserServiceImpl extends ServiceImpl<UmsUserMapper, UmsUser> implements UmsUserService {
@ -90,7 +88,7 @@ public class UmsUserServiceImpl extends ServiceImpl<UmsUserMapper, UmsUser> impl
UmsUser byUsername = lambdaQuery().eq(UmsUser::getUsername, umsUser.getUsername()) UmsUser byUsername = lambdaQuery().eq(UmsUser::getUsername, umsUser.getUsername())
.one(); .one();
UmsStudent umsStudent = new UmsStudent(); UmsStudent umsStudent = new UmsStudent();
umsStudent.setUserId(Math.toIntExact(byUsername.getId())); umsStudent.setUserId(byUsername.getId());
umsStudentMapper.insert(umsStudent); umsStudentMapper.insert(umsStudent);
return umsUser; return umsUser;
@ -105,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());
@ -246,7 +244,7 @@ public class UmsUserServiceImpl extends ServiceImpl<UmsUserMapper, UmsUser> impl
} }
UmsUser umsUser = userList.get(0); UmsUser umsUser = userList.get(0);
if(!passwordEncoder.matches(param.getOldPassword(),umsUser.getPassword())){ if(!passwordEncoder.matches(param.getOldPassword(),umsUser.getPassword())){
throw new BusinessException(400,"密码重复"); throw new BusinessException(400,"原密码错误");
} }
umsUser.setPassword(passwordEncoder.encode(param.getNewPassword())); umsUser.setPassword(passwordEncoder.encode(param.getNewPassword()));
updateById(umsUser); updateById(umsUser);
@ -311,7 +309,7 @@ public class UmsUserServiceImpl extends ServiceImpl<UmsUserMapper, UmsUser> impl
UmsUser byUsername = lambdaQuery().eq(UmsUser::getPhone, umsUser.getPhone()) UmsUser byUsername = lambdaQuery().eq(UmsUser::getPhone, umsUser.getPhone())
.one(); .one();
UmsStudent umsStudent = new UmsStudent(); UmsStudent umsStudent = new UmsStudent();
umsStudent.setUserId(Math.toIntExact(byUsername.getId())); umsStudent.setUserId(byUsername.getId());
umsStudentMapper.insert(umsStudent); umsStudentMapper.insert(umsStudent);
return umsUser; return umsUser;

@ -13,6 +13,10 @@ import java.util.List;
* @Description: * @Description:
*/ */
public interface KnowtmpService { public interface KnowtmpService {
//查询
BaseResponse<Long> getAllKnows(String courseId);
// 添加知识点 // 添加知识点
BaseResponse<String> add(KnowtempAdd knowtempAdd); BaseResponse<String> add(KnowtempAdd knowtempAdd);

@ -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);
} }

@ -0,0 +1,24 @@
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.RecordKnowledgeFinish;
import com.teaching.backend.model.entity.records.RecordResourceFinish;
import com.teaching.backend.model.entity.records.ResourceLearningRecord;
/**
* <p>
* 服务类
* </p>
*
* @author author
* @since 2024-08-20
*/
public interface IRecordKnowledgeFinishService extends IService<RecordKnowledgeFinish> {
void addFinish(KnowledgeLearningRecord knowledgeLearningRecord);
void addFinish(ResourceLearningRecord resourceLearningRecord);
void editFinish(KnowledgeLearningRecord knowledgeLearningRecord);
void editFinish(ResourceLearningRecord resourceLearningRecord);
}

@ -0,0 +1,21 @@
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;
/**
* <p>
* 服务类
* </p>
*
* @author author
* @since 2024-08-20
*/
public interface IRecordResourceFinishService extends IService<RecordResourceFinish> {
void addFinish(ResourceLearningRecord resourceLearningRecord);
void editFinish(ResourceLearningRecord resourceLearningRecord);
}

@ -40,5 +40,7 @@ public interface ResourceService {
//查询二级节点下资源 //查询二级节点下资源
BaseResponse<Set<Resources>> queryBesidesKnowToResources(Long KnowId); BaseResponse<Set<Resources>> queryBesidesKnowToResources(Long KnowId);
BaseResponse<Set<Resources>> queryResourcesByKnowId(Long KnowId);
} }

@ -5,15 +5,8 @@ import com.teaching.backend.exception.BusinessException;
import com.teaching.backend.mapper.chapter.TemporaryChapterMapper; import com.teaching.backend.mapper.chapter.TemporaryChapterMapper;
import com.teaching.backend.model.dto.chapter.ChapterExcelDTO; import com.teaching.backend.model.dto.chapter.ChapterExcelDTO;
import com.teaching.backend.service.chapter.IChapterService; import com.teaching.backend.service.chapter.IChapterService;
import jdk.nashorn.internal.ir.IfNode;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.CellReference;
import org.apache.poi.xssf.eventusermodel.XSSFSheetXMLHandler; import org.apache.poi.xssf.eventusermodel.XSSFSheetXMLHandler;
import org.apache.poi.xssf.usermodel.XSSFComment; import org.apache.poi.xssf.usermodel.XSSFComment;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal; import java.math.BigDecimal;

@ -0,0 +1,26 @@
package com.teaching.backend.utils;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.util.Date;
/**
* 自动填充时间
*/
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
@Override
public void insertFill(MetaObject metaObject) {
this.setFieldValByName("createTime", LocalDateTime.now(), metaObject);
this.setFieldValByName("updateTime", LocalDateTime.now(), metaObject);
}
@Override
public void updateFill(MetaObject metaObject) {
this.setFieldValByName("updateTime", LocalDateTime.now(), metaObject);
}
}

@ -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;

@ -76,7 +76,7 @@
WHERE WHERE
s.user_id = #{id} s.user_id = #{id}
</select> </select>
<select id="getbyIdRoleId" parameterType="java.lang.String" resultType="java.lang.String"> <select id="getByIdRoleId" parameterType="java.lang.String" resultType="java.lang.String">
SELECT SELECT
us.role_id roleId us.role_id roleId
FROM FROM

Loading…
Cancel
Save