Merge branch 'master' of 39.106.16.162:/home/git/teaching-backend/teaching-backend

master
youhang20021127 3 months ago
commit b0470ad9f5
  1. 2
      src/main/java/com/teaching/backend/common/ErrorCode.java
  2. 3
      src/main/java/com/teaching/backend/controller/cms/CmsEssayController.java
  3. 8
      src/main/java/com/teaching/backend/controller/courses/CourseObjectivesController.java
  4. 8
      src/main/java/com/teaching/backend/controller/courses/ObjectiveContentKnowController.java
  5. 4
      src/main/java/com/teaching/backend/controller/courses/ObjectiveContentsController.java
  6. 3
      src/main/java/com/teaching/backend/controller/records/CourseLearningRecordController.java
  7. 11
      src/main/java/com/teaching/backend/controller/records/KnowledgeLearningRecordController.java
  8. 2
      src/main/java/com/teaching/backend/mapper/KnowGraph/KnowledgeLearningNumberMapper.java
  9. 2
      src/main/java/com/teaching/backend/mapper/courses/CourseLearningNumberMapper.java
  10. 2
      src/main/java/com/teaching/backend/mapper/records/CourseLearningRecordMapper.java
  11. 2
      src/main/java/com/teaching/backend/mapper/records/KnowledgeLearningRecordMapper.java
  12. 17
      src/main/java/com/teaching/backend/mapper/records/RecordKnowledgeFinishMapper.java
  13. 17
      src/main/java/com/teaching/backend/mapper/records/RecordResourceFinishMapper.java
  14. 2
      src/main/java/com/teaching/backend/model/dto/courses/ObjectiveContentKnowDTO.java
  15. 3
      src/main/java/com/teaching/backend/model/dto/umsAdmin/UmsStudentAndTeacherDTO.java
  16. 5
      src/main/java/com/teaching/backend/model/entity/cms/CmsEssay.java
  17. 6
      src/main/java/com/teaching/backend/model/entity/courses/ObjectiveContentKnow.java
  18. 4
      src/main/java/com/teaching/backend/model/entity/courses/ObjectiveContents.java
  19. 1
      src/main/java/com/teaching/backend/model/entity/knowtmp/Knowtmp.java
  20. 4
      src/main/java/com/teaching/backend/model/entity/records/CourseLearningNumber.java
  21. 2
      src/main/java/com/teaching/backend/model/entity/records/CourseLearningRecord.java
  22. 4
      src/main/java/com/teaching/backend/model/entity/records/KnowledgeLearningNumber.java
  23. 6
      src/main/java/com/teaching/backend/model/entity/records/KnowledgeLearningRecord.java
  24. 47
      src/main/java/com/teaching/backend/model/entity/records/RecordKnowledgeFinish.java
  25. 50
      src/main/java/com/teaching/backend/model/entity/records/RecordResourceFinish.java
  26. 2
      src/main/java/com/teaching/backend/model/entity/records/ResourceLearningNumber.java
  27. 15
      src/main/java/com/teaching/backend/model/entity/records/ResourceLearningRecord.java
  28. 2
      src/main/java/com/teaching/backend/model/entity/umsAdmin/AdminUserDetails.java
  29. 23
      src/main/java/com/teaching/backend/model/vo/courses/CourseObjectivesVO.java
  30. 11
      src/main/java/com/teaching/backend/model/vo/courses/ObjectiveContentKnowVO.java
  31. 29
      src/main/java/com/teaching/backend/model/vo/knowtmp/KnowTmpVO.java
  32. 4
      src/main/java/com/teaching/backend/model/vo/records/KnowledgeLearningRecordVo.java
  33. 6
      src/main/java/com/teaching/backend/model/vo/records/ResourceLearingRecordVo.java
  34. 2
      src/main/java/com/teaching/backend/service/KnowGraph/IKnowledgeLearningNumberService.java
  35. 2
      src/main/java/com/teaching/backend/service/courses/ICourseLearningNumberService.java
  36. 3
      src/main/java/com/teaching/backend/service/courses/ICourseObjectivesService.java
  37. 2
      src/main/java/com/teaching/backend/service/courses/ICoursesService.java
  38. 2
      src/main/java/com/teaching/backend/service/courses/IObjectiveContentKnowService.java
  39. 2
      src/main/java/com/teaching/backend/service/courses/IObjectiveContentsService.java
  40. 2
      src/main/java/com/teaching/backend/service/impl/courses/CourseLearningNumberServiceImpl.java
  41. 34
      src/main/java/com/teaching/backend/service/impl/courses/CourseObjectivesServiceImpl.java
  42. 33
      src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java
  43. 166
      src/main/java/com/teaching/backend/service/impl/courses/ObjectiveContentKnowServiceImpl.java
  44. 34
      src/main/java/com/teaching/backend/service/impl/courses/ObjectiveContentsServiceImpl.java
  45. 2
      src/main/java/com/teaching/backend/service/impl/knowledge/KnowledgeLearningNumberServiceImpl.java
  46. 25
      src/main/java/com/teaching/backend/service/impl/records/CourseLearningRecordServiceImpl.java
  47. 48
      src/main/java/com/teaching/backend/service/impl/records/KnowledgeLearningRecordServiceImpl.java
  48. 64
      src/main/java/com/teaching/backend/service/impl/records/RecordKnowledgeFinishServiceImpl.java
  49. 53
      src/main/java/com/teaching/backend/service/impl/records/RecordResourceFinishServiceImpl.java
  50. 20
      src/main/java/com/teaching/backend/service/impl/records/ResourceLearningRecordServiceImpl.java
  51. 17
      src/main/java/com/teaching/backend/service/impl/umsAdmin/UmsStudentManageServiceImpl.java
  52. 2
      src/main/java/com/teaching/backend/service/impl/umsAdmin/UmsUserServiceImpl.java
  53. 3
      src/main/java/com/teaching/backend/service/records/IKnowledgeLearningRecordService.java
  54. 24
      src/main/java/com/teaching/backend/service/records/IRecordKnowledgeFinishService.java
  55. 21
      src/main/java/com/teaching/backend/service/records/IRecordResourceFinishService.java
  56. 4
      src/main/resources/mapper/CourseLearningRecordMapper.xml

@ -10,7 +10,7 @@ public enum ErrorCode {
SUCCESS(200, "ok"),
PARAMS_ERROR(40000, "请求参数错误"),
OBJECTIVE_OR_CONTENT_NOT_EXIT(40001, "目标内容id不存在"),
OBJECTIVE_CONTENT_NOT_EXIT(40001, "目标内容不存在"),
KONWID_NOT_EXIT(40002, "没有选择知识点"),
OBJECTIVE_OR_CONTENT_EXIT(40003, "该记录已存在"),
KNOW_NOT_EXIT(40004, "知识点不存在"),

@ -53,7 +53,8 @@ public class CmsEssayController {
* @return
*/
@PutMapping("/edit")
public BaseResponse<String> editEssay(CmsEssay cmsEssay){
public BaseResponse<String> editEssay(@RequestBody CmsEssay cmsEssay){
System.out.println(cmsEssay);
return cmsEssayService.editEssay(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.entity.courses.CourseObjectives;
import com.teaching.backend.model.vo.courses.CourseObjectivesTreeVO;
import com.teaching.backend.model.vo.courses.CourseObjectivesVO;
import com.teaching.backend.service.courses.ICourseObjectivesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -76,5 +77,12 @@ public class CourseObjectivesController {
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;
@ApiOperation("给分项目标或者是内容添加知识点")
// @ValidateParams({"objectiveId","know"})
@ApiOperation("给知识点关联--目标内容")
@ValidateParams({"objectiveContentId","knowId"})
@PostMapping("/addknows")
public BaseResponse<String> saveKnowsWithObjectiveOrContent(@RequestBody ObjectiveContentKnowDTO objectiveContentKnowDTO){
String data = objectiveContentKnowService.saveKnowsWithObjectiveOrContent(objectiveContentKnowDTO);
public BaseResponse<String> saveKnowsWithObjectiveContent(@RequestBody ObjectiveContentKnowDTO objectiveContentKnowDTO){
String data = objectiveContentKnowService.saveKnowsWithObjectiveContent(objectiveContentKnowDTO);
return ResultUtils.success(data);
}

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

@ -79,9 +79,6 @@ public class CourseLearningRecordController {
@PostMapping("/recommendCourses")
public CommonResult<List<CoursesVO>> recommendCourses(@RequestParam String userId) {
List<CoursesVO> coursesVOList = courseLearningRecordService.queryrecommendCourses(userId);
if (coursesVOList == null){
CommonResult.failed("用户或角色错误");
}
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.model.entity.records.CourseLearningRecord;
import com.teaching.backend.model.entity.records.KnowledgeLearningRecord;
import com.teaching.backend.model.vo.courses.CoursesVO;
import com.teaching.backend.model.vo.knowGraph.KnowVO;
import com.teaching.backend.service.impl.records.KnowledgeLearningRecordServiceImpl;
import io.swagger.annotations.ApiOperation;
@ -84,5 +85,15 @@ public class KnowledgeLearningRecordController {
return CommonResult.success(knowVO);
}
/**
* 推荐知识点
* @return
*/
@ApiOperation("推荐知识点")
@PostMapping("/recommendKnowledge")
public CommonResult<List<KnowVO>> recommendCourses(@RequestParam String userId) {
List<KnowVO> coursesVOList = knowledgeLearningRecordService.queryRecommendKnowledge(userId);
return CommonResult.success(coursesVOList);
}
}

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

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

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

@ -20,7 +20,7 @@ import java.util.List;
*/
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> 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> {
}

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

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

@ -2,8 +2,10 @@ 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;
@ -44,7 +46,8 @@ public class CmsEssay implements Serializable {
private String content;
@ApiModelProperty(value = "发布时间")
private LocalDateTime publishTime;
@JsonFormat (locale= "zh", timezone= "GMT+8", pattern= "yyyy-MM-dd")
private LocalDate publishTime;
@ApiModelProperty(value = "浏览次数")
private Integer readingNumber;

@ -38,12 +38,14 @@ public class ObjectiveContentKnow implements Serializable {
/**
* 分项目标或内容 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)
private String content;
@ApiModelProperty(value = "排序字段",required = true)
@ApiModelProperty(value = "排序字段")
private Float orderNum;
}

@ -36,5 +36,4 @@ public class Knowtmp implements Serializable {
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.TableName;
@ -22,7 +22,7 @@ import lombok.experimental.Accessors;
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("course_learning_number")
@TableName("record_course_number")
@ApiModel(value="CourseLearningNumber对象", description="")
public class CourseLearningNumber implements Serializable {

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

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

@ -23,7 +23,7 @@ import lombok.experimental.Accessors;
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("knowledge_learning_record")
@TableName("record_knowledge_learning")
@ApiModel(value="KnowledgeLearningRecord对象", description="")
public class KnowledgeLearningRecord implements Serializable {
@ -61,5 +61,9 @@ public class KnowledgeLearningRecord implements Serializable {
@TableField("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
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("resource_learning_number")
@TableName("record_resource_number")
@ApiModel(value="ResourceLearningNumber对象", description="")
public class ResourceLearningNumber implements Serializable {

@ -23,7 +23,7 @@ import lombok.experimental.Accessors;
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("resource_learning_record")
@TableName("record_resource_learning")
@ApiModel(value="ResourceLearningRecord对象", description="")
public class ResourceLearningRecord implements Serializable {
@ -67,19 +67,22 @@ public class ResourceLearningRecord implements Serializable {
@ApiModelProperty(value = "学习时长")
@TableField("duration")
private Integer duration;
private double duration;
@ApiModelProperty(value = "总时长")
@TableField("total_duration")
private double totalDuration;
@ApiModelProperty(value = "是否完成观看")
@TableField("finish")
private Integer finish;
@ApiModelProperty(value = "记录封面")
@TableField("img")
private String img;
@ApiModelProperty(value = "最近学习时间")
@TableField("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
public boolean isEnabled() {
return umsAdmin.getStatus().equals(1);
return umsAdmin.getStatus().equals("1");
}
}

@ -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;
import com.teaching.backend.model.vo.knowtmp.KnowTmpVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -12,7 +13,7 @@ import java.util.List;
public class ObjectiveContentKnowVO {
/**
* 分项目标内容 id
* 目标内容 id
*/
private String objectiveOrContent;
@ -26,17 +27,17 @@ public class ObjectiveContentKnowVO {
* 关联的知识点学时合计
*/
@ApiModelProperty(value = "关联的知识点学时合计")
private BigDecimal knowsTime;
private Double knowsTime;
/**
* 关联的知识点学时占比
*/
@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;
}

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

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

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

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

@ -54,7 +54,7 @@ public interface ICoursesService extends IService<Courses> {
List<PersonalCenterStudentListVO> queryStudentList(String userId);
LinkedHashSet<UmsStudentManage> queryTeacherByStudentLearningRecordList(String userId);
LinkedHashSet<UmsStudentManage> queryTeacherByStudentList(String userId);
List<UmsStudentManage> queryTeacherByStudentList(String userId);
List<CourseUserInfVO> getUserInfByCourse(Long userId);
}

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

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

@ -3,7 +3,7 @@ package com.teaching.backend.service.impl.courses;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
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 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.ObjectiveContents;
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.utils.CourseCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -26,6 +28,7 @@ import java.util.List;
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_TYPE;
/**
* <p>
@ -36,6 +39,7 @@ import static com.teaching.backend.utils.CourseCode.TOTAL_OBJECTIVE_HAS_NO_CHILD
* @since 2024-05-31
*/
@Service
@Slf4j
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);
}
Integer type = courseObjectives.getType();
if (type == CourseCode.TOTAL_OBJECTIVE_TYPE.getValue()){
throw new BusinessException(ErrorCode.OPERATION_ERROR,"课程总目标只需清除所列内容即可!");
if (type == TOTAL_OBJECTIVE_TYPE.getValue()){
throw new BusinessException(ErrorCode.OPERATION_ERROR,"课程总目标禁止删除!");
}
//等到删完内容后判断还是上来就判断?
Long count = objectiveContentKnowMapper.selectCount(new LambdaQueryWrapper<ObjectiveContentKnow>()
.eq(ObjectiveContentKnow::getObjectiveOrContent, id));
.eq(ObjectiveContentKnow::getObjectiveContentId, id));
if(count > CourseCode.KNOWS_EXIT.getValue()){
throw new BusinessException(ErrorCode.KNOWS_EXIT);
}
@ -204,6 +208,30 @@ public class CourseObjectivesServiceImpl extends ServiceImpl<CourseObjectivesMap
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) {
LambdaQueryWrapper<ObjectiveContents> queryWrapper = new LambdaQueryWrapper<>();

@ -283,7 +283,7 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
contents+=content;
Long know = objectiveContentKnowMapper.selectCount(new LambdaQueryWrapper<ObjectiveContentKnow>()
.eq(ObjectiveContentKnow::getObjectiveOrContent, objectiveId));
.eq(ObjectiveContentKnow::getObjectiveContentId, objectiveId));
knows+=know;
}
if(contents > 0){
@ -407,25 +407,28 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
}
@Override
public LinkedHashSet<UmsStudentManage> queryTeacherByStudentList(String userId) {
public List<UmsStudentManage> queryTeacherByStudentList(String userId) {
String roleId = umsUserMapper.getByIdRoleId(userId);
CourseQuery courseQuery = new CourseQuery();
courseQuery.setUserId(userId);
LinkedHashSet<UmsStudentManage> umsStudentManageList = new LinkedHashSet<>();
if (roleId.equals("1")){
PageDTO<CoursesVO> queryCourses = queryCourses(courseQuery);
PageDTO<CoursesVO> queryCourses = queryForTeacher(courseQuery);
List<CoursesVO> coursesList = queryCourses.getList();
List<String> courseIds = coursesList.stream().map(CoursesVO::getId).collect(Collectors.toList());
for (String courseId : courseIds) {
List<StudentCourses> studentUsernames = studentCoursesMapper.selectBatchSomeStudent(courseId);
for (StudentCourses studentUsername : studentUsernames) {
UmsStudentManage umsStudentManage = umsStudentManageMapper.queryStudent(String.valueOf(studentUsername.getStudent()));
if (umsStudentManage != null){
umsStudentManageList.add(umsStudentManage);
}
}
}
return umsStudentManageList;
// 首先,收集所有需要查询的学生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,"只有老师才有此功能");
}

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

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

@ -7,7 +7,7 @@ import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.common.ResultUtils;
import com.teaching.backend.mapper.courses.CoursesMapper;
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.model.entity.courses.Courses;
import com.teaching.backend.model.entity.records.CourseLearningRecord;
@ -127,7 +127,7 @@ public class CourseLearningRecordServiceImpl extends ServiceImpl<CourseLearningR
String roleId = umsUserMapper.getByIdRoleId(userId);
List<Courses> coursesList = new ArrayList<>();
if (roleId.equals("1")){
List<String> courseIds = courseLearningRecordMapper.selectMaxNumber();
List<String> courseIds = courseLearningRecordMapper.selectMaxNumber(userId);
for (String courseId : courseIds) {
Courses courses = coursesMapper.selectById(courseId);
coursesList.add(courses);
@ -149,18 +149,15 @@ public class CourseLearningRecordServiceImpl extends ServiceImpl<CourseLearningR
@Override
public List<CoursesVO> queryrecommendCourses(String userId) {
String roleId = umsUserMapper.getByIdRoleId(userId);
if (roleId.equals("1")) {
return null;
} else if (roleId.equals("2")) {
return null;
}else {
return null;
List<Courses> coursesList = new ArrayList<>();
List<String> courseIds = courseLearningRecordMapper.selectMaxNumber(userId);
for (String courseId : courseIds) {
Courses courses = coursesMapper.selectById(courseId);
if (courses != null){
coursesList.add(courses);
}
}
List<CoursesVO> coursesVOList = BeanUtil.copyToList(coursesList, CoursesVO.class);
return coursesVOList;
}
}

@ -10,11 +10,12 @@ import com.teaching.backend.common.ResultUtils;
import com.teaching.backend.mapper.records.KnowledgeLearningRecordMapper;
import com.teaching.backend.mapper.umsAdmin.UmsUserMapper;
import com.teaching.backend.model.entity.KnowGraph.KnowledgeLearningNumber;
import com.teaching.backend.model.entity.records.KnowledgeLearningNumber;
import com.teaching.backend.model.entity.knowtmp.Knowtmp;
import com.teaching.backend.model.entity.records.KnowledgeLearningRecord;
import com.teaching.backend.model.entity.records.RecordKnowledgeFinish;
import com.teaching.backend.model.vo.knowGraph.KnowVO;
import com.teaching.backend.model.vo.records.KnowledgeLearningRecordVo;
@ -50,6 +51,8 @@ public class KnowledgeLearningRecordServiceImpl extends ServiceImpl<KnowledgeLea
private KnowledgeLearningRecordMapper knowledgeLearningRecordMapper;
@Resource
private KnowtmpService knowtmpService;
@Resource
private RecordKnowledgeFinishServiceImpl recordKnowledgeFinishService;
@Override
public BaseResponse<String> saveCoursesRecords(KnowledgeLearningRecord knowledgeLearningRecord) {
@ -78,7 +81,14 @@ public class KnowledgeLearningRecordServiceImpl extends ServiceImpl<KnowledgeLea
.eq("course_id", courseId)
.eq("knowledge_id",knowledgeId).update();
System.out.println("用户:"+userId+":第一次学这门课");
//添加完成状态
recordKnowledgeFinishService.addFinish(knowledgeLearningRecord);
}//自己学过
else {
if (knowledgeLearningRecord.getFinish() == 1){
//改变完成状态
recordKnowledgeFinishService.editFinish(knowledgeLearningRecord);
}
}
}else {//没人学过(自己肯定也没学)
//该课程第一次被学,人数设置为1
@ -87,18 +97,25 @@ public class KnowledgeLearningRecordServiceImpl extends ServiceImpl<KnowledgeLea
knowledgeLearningNumber.setCourseId(courseId);
knowledgeLearningNumber.setKnowledgeId(knowledgeId);
knowledgeLearningNumberService.save(knowledgeLearningNumber);
//添加完成状态
recordKnowledgeFinishService.addFinish(knowledgeLearningRecord);
}
//设置人数
String numberId = knowledgeLearningNumberService.query()
.eq("course_id", courseId)
.eq("knowledge_id",knowledgeId).one().getId();
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);
return ResultUtils.success("添加成功");
}
@Override
public BaseResponse<Page> getPage(int pagenum, int pagesize, String userId, String courseId) {
//格式化时间
@ -111,6 +128,7 @@ public class KnowledgeLearningRecordServiceImpl extends ServiceImpl<KnowledgeLea
.eq("courses_id",courseId).page(new Page<>(pagenum, pagesize));
Page<KnowledgeLearningRecordVo> page1 = new Page<>();
List<KnowledgeLearningRecord> records = page.getRecords();
//System.out.println(records);
BeanUtil.copyProperties(page, page1);
List<KnowledgeLearningRecordVo> recordsVos = new ArrayList<>();
//copy集合
@ -121,8 +139,11 @@ public class KnowledgeLearningRecordServiceImpl extends ServiceImpl<KnowledgeLea
knowledgeLearningRecordVo.setTime(sdf.format(date));
// //填充学习人数
knowledgeLearningRecordVo.setNumber(knowledgeLearningNumberService.getById(knowledgeLearningRecord.getNumber()).getNumber());
//获取完成状态
knowledgeLearningRecordVo.setFinish(recordKnowledgeFinishService.getById(knowledgeLearningRecord.getFinish()).getFinish());
recordsVos.add(knowledgeLearningRecordVo);
});
//System.out.println(recordsVos);
page1.setRecords(recordsVos);
return ResultUtils.success(page1);
}
@ -171,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.ResultUtils;
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.ResourceLearningRecord;
@ -35,6 +36,8 @@ public class ResourceLearningRecordServiceImpl extends ServiceImpl<ResourceLearn
@Resource
private ResourceLearningNumberServiceImpl resourceLearningNumberService;
@Resource
private RecordResourceFinishServiceImpl recordResourceFinishService;
@Override
public BaseResponse<String> saveCoursesRecords(ResourceLearningRecord resourceLearningRecord) {
@ -65,6 +68,13 @@ public class ResourceLearningRecordServiceImpl extends ServiceImpl<ResourceLearn
.eq("knowledge_id",knowledgeId)
.eq("resource_id",resourceId).update();
// System.out.println("用户:"+userId+"第一次学这门课");
//添加完成状态
recordResourceFinishService.addFinish(resourceLearningRecord);
}else {
if (resourceLearningRecord.getFinish() == 1){
//改变完成状态
recordResourceFinishService.editFinish(resourceLearningRecord);
}
}
}else {
//该课程第一次被学,人数设置为1
@ -74,6 +84,8 @@ public class ResourceLearningRecordServiceImpl extends ServiceImpl<ResourceLearn
resourceLearningNumber.setKnowledgeId(knowledgeId);
resourceLearningNumber.setResourceId(resourceId);
resourceLearningNumberService.save(resourceLearningNumber);
//添加完成状态
recordResourceFinishService.addFinish(resourceLearningRecord);
}
//设置人数
String numberId = resourceLearningNumberService.query()
@ -81,6 +93,12 @@ public class ResourceLearningRecordServiceImpl extends ServiceImpl<ResourceLearn
.eq("knowledge_id",knowledgeId)
.eq("resource_id",resourceId).one().getId();
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);
return ResultUtils.success("添加成功");
@ -88,7 +106,7 @@ public class ResourceLearningRecordServiceImpl extends ServiceImpl<ResourceLearn
@Override
public BaseResponse<Page> getPage(int pagenum, int pagesize, String userId, String knowledgeId, String courseId) {
//格式化时间
//格式化时间
String strDateFormat = "yyyy-MM-dd HH:mm:ss";
SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat);
//分页查询

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

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

@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.model.entity.records.KnowledgeLearningRecord;
import com.teaching.backend.model.vo.courses.CoursesVO;
import io.swagger.models.auth.In;
import com.teaching.backend.model.vo.knowGraph.KnowVO;
@ -28,5 +29,7 @@ public interface IKnowledgeLearningRecordService extends IService<KnowledgeLearn
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);
}

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

Loading…
Cancel
Save