Merge remote-tracking branch 'origin/master'

master
小萌新 3 months ago
commit 79660db3fc
  1. 5
      src/main/java/com/teaching/backend/common/ErrorCode.java
  2. 14
      src/main/java/com/teaching/backend/controller/Know/KnowController.java
  3. 2
      src/main/java/com/teaching/backend/controller/cms/CmsEssayController.java
  4. 12
      src/main/java/com/teaching/backend/controller/records/KnowledgeLearningRecordController.java
  5. 45
      src/main/java/com/teaching/backend/controller/system/SystemSettingsController.java
  6. 12
      src/main/java/com/teaching/backend/mapper/know/KnowRepository.java
  7. 2
      src/main/java/com/teaching/backend/mapper/report/ReportMapper.java
  8. 11
      src/main/java/com/teaching/backend/mapper/system/SystemSettingsMapper.java
  9. 3
      src/main/java/com/teaching/backend/mapper/umsAdmin/UmsStudentMapper.java
  10. 3
      src/main/java/com/teaching/backend/mapper/umsAdmin/UmsTeacherMapper.java
  11. 2
      src/main/java/com/teaching/backend/model/entity/courses/ObjectiveContentKnow.java
  12. 56
      src/main/java/com/teaching/backend/model/entity/system/SystemSetting.java
  13. 2
      src/main/java/com/teaching/backend/model/vo/knowGraph/KnowVO.java
  14. 54
      src/main/java/com/teaching/backend/model/vo/system/SystemSettingVO.java
  15. 2
      src/main/java/com/teaching/backend/service/impl/cms/CmsEssayServiceImpl.java
  16. 24
      src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java
  17. 51
      src/main/java/com/teaching/backend/service/impl/courses/ObjectiveContentKnowServiceImpl.java
  18. 5
      src/main/java/com/teaching/backend/service/impl/courses/ObjectiveContentsServiceImpl.java
  19. 153
      src/main/java/com/teaching/backend/service/impl/know/knowServiceImpl.java
  20. 16
      src/main/java/com/teaching/backend/service/impl/records/KnowledgeLearningRecordServiceImpl.java
  21. 45
      src/main/java/com/teaching/backend/service/impl/system/SystemSettingsServiceImpl.java
  22. 2
      src/main/java/com/teaching/backend/service/records/IKnowledgeLearningRecordService.java
  23. 12
      src/main/java/com/teaching/backend/service/system/SystemSettingsService.java
  24. 2
      src/main/java/com/teaching/backend/utils/CourseCode.java
  25. 3
      src/main/resources/application.yml
  26. 12
      src/main/resources/mapper/CourseLearningRecordMapper.xml
  27. 6
      src/main/resources/mapper/KnowledgeLearningRecordMapper.xml
  28. 48
      src/main/resources/mapper/SystemSettingsMapper.xml
  29. 0
      src/main/resources/mapper/UmsStudentManageMapper.xml
  30. BIN
      tempFile/19854ab3-b8bc-4660-bb40-b4ee6184cd30/1.组织学绪论.ppt
  31. BIN
      tempFile/2b9dae36-8ef9-45b0-b720-08ba444ba741/上皮组织作业.doc

@ -22,6 +22,11 @@ public enum ErrorCode {
INVALID_ROLE(400010, "角色不存在"), INVALID_ROLE(400010, "角色不存在"),
MESSAGE_NO_READ(400011, "消息未读,禁止删除!"), MESSAGE_NO_READ(400011, "消息未读,禁止删除!"),
MESSAGE_NO_EXIT(400012, "消息不存在!"), MESSAGE_NO_EXIT(400012, "消息不存在!"),
TOTOAL_OBJECTIVE_CANT_DELETE(400013, "课程总目标内容禁止删除!"),
CONTENT_HAS_NO_KNOWS(400014, "当前课程目标下面没有关联的知识点!"),
NOT_LOGIN_ERROR(40100, "未登录"), NOT_LOGIN_ERROR(40100, "未登录"),
NO_AUTH_ERROR(40101, "无权限"), NO_AUTH_ERROR(40101, "无权限"),
NOT_FOUND_ERROR(40400, "请求数据不存在"), NOT_FOUND_ERROR(40400, "请求数据不存在"),

@ -17,8 +17,12 @@ import com.teaching.backend.model.vo.knowGraph.KnowVO1;
import com.teaching.backend.service.Know.KnowService; import com.teaching.backend.service.Know.KnowService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.neo4j.core.Neo4jClient;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Collection;
import java.util.Map;
import java.util.Set; import java.util.Set;
@ -31,6 +35,9 @@ public class KnowController {
@Autowired @Autowired
private KnowRepository knowRepository; private KnowRepository knowRepository;
@Resource
private Neo4jClient neo4jClient;
@ -54,8 +61,11 @@ public class KnowController {
//通过courseId 显示图的JSON //通过courseId 显示图的JSON
@GetMapping("/test") @GetMapping("/test")
void test(@RequestParam String courseId){ void test(){
int res = knowRepository.addCourseRelationship(courseId,932L,"related"); String t = "related";
String str = "MATCH (p:Know), (j:Know) WHERE ID(p)= "+407+" AND ID(j)= "+389+" CREATE (p)-[r: "+t+" ]->(j) return count(r);";
Collection<Map<String, Object>> res = neo4jClient.query(str).fetch().all();
System.out.println(res);
} }
//通过courseId 显示图的JSON //通过courseId 显示图的JSON

@ -74,7 +74,7 @@ public class CmsEssayController {
* @return * @return
*/ */
@PutMapping("/edit/status") @PutMapping("/edit/status")
public BaseResponse<String> editStatus(CmsEssay cmsEssay){ public BaseResponse<String> editStatus(@RequestBody CmsEssay cmsEssay){
return cmsEssayService.editStatus(cmsEssay); return cmsEssayService.editStatus(cmsEssay);
} }
} }

@ -96,4 +96,16 @@ public class KnowledgeLearningRecordController {
return CommonResult.success(coursesVOList); return CommonResult.success(coursesVOList);
} }
/**
* 学生知识点的完成度
* @param userId
* @param courseId
* @return
*/
@ApiOperation("学生知识点的完成度")
@PostMapping("/studentfinish")
public BaseResponse<String> studentFinish(@RequestParam String userId, @RequestParam String courseId) {
return knowledgeLearningRecordService.studentFinish(userId,courseId);
}
} }

@ -0,0 +1,45 @@
package com.teaching.backend.controller.system;
import com.teaching.backend.common.CommonResult;
import com.teaching.backend.model.entity.system.SystemSetting;
import com.teaching.backend.model.vo.system.SystemSettingVO;
import com.teaching.backend.service.system.SystemSettingsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@Api(tags = "系统设置接口")
@RequestMapping("/api/systemSettings")
@Slf4j
public class SystemSettingsController {
@Autowired
private SystemSettingsService systemSettingsService;
/**
* 查询系统设置信息
* @param
* @return
*/
@GetMapping("/save")
@ApiOperation("查询系统设置信息")
public CommonResult<SystemSettingVO> save(){
SystemSettingVO systemSettings = systemSettingsService.getSystemSettings();
return CommonResult.success(systemSettings);
}
/**
* 编辑系统设置信息
* @param systemSetting
* @return
*/
@PutMapping
@ApiOperation("编辑系统设置信息")
public CommonResult update(@RequestBody SystemSetting systemSetting){
return systemSettingsService.updateSystemSettings(systemSetting);
}
}

@ -12,10 +12,12 @@ 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.core.Neo4jTemplate;
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 org.springframework.data.repository.query.Param;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -101,12 +103,14 @@ public interface KnowRepository extends Neo4jRepository<Know, Long> {
//========== //==========
//建立关系 all -课程 //建立关系 all -课程
@Query("MATCH (p:Know {courseId: $courseId}), (j:Know {chapterId: $chapterId}) CREATE (p)-[r:顺序]->(j) return count(p);") @Query("MATCH (p:Know {courseId: $courseId}), (j:Know {chapterId: $chapterId}) CREATE (p)-[r:contain]->(j) return count(p);")
int addCourseRelationship(String courseId,Long chapterId,String type); Long addCourseRelationship(String courseId,Long chapterId);
//建立关系 all -章节 //建立关系 all -章节
@Query("MATCH (p:Know), (j:Know) WHERE p.chapterId= $chapterId1 AND ID(j)= $chapterId2 CREATE (p)-[r: "+"$type"+"]->(j) return count(r);") // @Query({str})
int addChapterRelationship(Long chapterId1, Long chapterId2, @Param("type")String type); // int addChapterRelationship(String str);
//建立关系 all -节 - 点 //建立关系 all -节 - 点
@Query("MATCH (p:Know), (j:Know) WHERE p.chapterId= $chapterId AND j.knowId= $knowId CREATE (p)-[r: $type]->(j) return count(r);") @Query("MATCH (p:Know), (j:Know) WHERE p.chapterId= $chapterId AND j.knowId= $knowId CREATE (p)-[r: $type]->(j) return count(r);")

@ -3,9 +3,11 @@ package com.teaching.backend.mapper.report;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.teaching.backend.model.dto.report.ReportDTO; import com.teaching.backend.model.dto.report.ReportDTO;
import com.teaching.backend.model.entity.report.Report; import com.teaching.backend.model.entity.report.Report;
import org.apache.ibatis.annotations.Mapper;
import java.time.LocalDate; import java.time.LocalDate;
@Mapper
public interface ReportMapper extends BaseMapper<Report> { public interface ReportMapper extends BaseMapper<Report> {
String getBrowseByTime(LocalDate day); String getBrowseByTime(LocalDate day);

@ -0,0 +1,11 @@
package com.teaching.backend.mapper.system;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.teaching.backend.model.entity.system.SystemSetting;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface SystemSettingsMapper extends BaseMapper<SystemSetting> {
boolean updateSystemSettings(SystemSetting systemSetting);
}

@ -2,6 +2,7 @@ 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.umsAdmin.UmsStudent; import com.teaching.backend.model.entity.umsAdmin.UmsStudent;
import org.apache.ibatis.annotations.Mapper;
/** /**
* <p> * <p>
@ -11,6 +12,8 @@ import com.teaching.backend.model.entity.umsAdmin.UmsStudent;
* @author zjh * @author zjh
* @since 2024-06-12 * @since 2024-06-12
*/ */
@Mapper
public interface UmsStudentMapper extends BaseMapper<UmsStudent> { public interface UmsStudentMapper extends BaseMapper<UmsStudent> {
boolean updateStudentInfo(UmsStudent umsStudent); boolean updateStudentInfo(UmsStudent umsStudent);

@ -2,6 +2,7 @@ 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.umsAdmin.UmsTeacher; import com.teaching.backend.model.entity.umsAdmin.UmsTeacher;
import org.apache.ibatis.annotations.Mapper;
/** /**
* <p> * <p>
@ -11,6 +12,8 @@ import com.teaching.backend.model.entity.umsAdmin.UmsTeacher;
* @author zjh * @author zjh
* @since 2024-06-12 * @since 2024-06-12
*/ */
@Mapper
public interface UmsTeacherMapper extends BaseMapper<UmsTeacher> { public interface UmsTeacherMapper extends BaseMapper<UmsTeacher> {
boolean updateTeacherInfo(UmsTeacher umsTeacher); boolean updateTeacherInfo(UmsTeacher umsTeacher);

@ -45,7 +45,7 @@ public class ObjectiveContentKnow implements Serializable {
* 关联的知识点 * 关联的知识点
*/ */
// private String know; // private String know;
private Integer knowId; private Long knowId;
} }

@ -0,0 +1,56 @@
package com.teaching.backend.model.entity.system;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
@Data
@TableName("system_settings")
public class SystemSetting implements Serializable {
//主键
@TableId(type = IdType.AUTO)
private Long id;
//门户首页
private String home;
//系统名称
private String name;
//LOGO
private String logo;
//宣传图片
private String promotionalImages;
//登录地址
private String loginAddress;
//标题
private String title;
//版权信息
private String copyrightInformation;
//备案号
private String recordNumber;
//QQ
private String qqNumber;
//邮箱
private String mailbox;
//手机号
private String phone;
//地址
private String address;
//二维码
private String qrCode;
}

@ -21,7 +21,7 @@ public class KnowVO implements Serializable {
private String label; private String label;
/** /**
* 信息 * color
*/ */
private String color; private String color;

@ -0,0 +1,54 @@
package com.teaching.backend.model.vo.system;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import java.io.Serializable;
@Data
public class SystemSettingVO implements Serializable {
//主键
@TableId(type = IdType.AUTO)
private Long id;
//门户首页
private String home;
//系统名称
private String name;
//LOGO
private String logo;
//宣传图片
private String promotionalImages;
//登录地址
private String loginAddress;
//标题
private String title;
//版权信息
private String copyrightInformation;
//备案号
private String recordNumber;
//QQ
private String qqNumber;
//邮箱
private String mailbox;
//手机号
private String phone;
//地址
private String address;
//二维码
private String qrCode;
}

@ -9,6 +9,7 @@ import com.teaching.backend.model.entity.cms.CmsEssay;
import com.teaching.backend.service.cms.ICmsEssayService; import com.teaching.backend.service.cms.ICmsEssayService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.util.List; import java.util.List;
/** /**
@ -24,6 +25,7 @@ public class CmsEssayServiceImpl extends ServiceImpl<CmsEssayMapper, CmsEssay> i
@Override @Override
public BaseResponse<String> addEssay(CmsEssay cmsEssay) { public BaseResponse<String> addEssay(CmsEssay cmsEssay) {
cmsEssay.setPublishTime(LocalDate.now());
save(cmsEssay); save(cmsEssay);
return ResultUtils.success("添加成功"); return ResultUtils.success("添加成功");
} }

@ -164,6 +164,12 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
courseObjectivesMapper.updateById(courseTotalObjectives); courseObjectivesMapper.updateById(courseTotalObjectives);
} }
// 在总目标里面插入一个内容
ObjectiveContents objectiveContents = new ObjectiveContents();
objectiveContents.setObjectiveId(courseTotalObjectivesId);
objectiveContents.setContent("请添加课程总目标");
objectiveContentsMapper.insert(objectiveContents);
return "添加成功"; return "添加成功";
} }
@ -424,7 +430,7 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
// 然后,一次性查询所有学生信息 // 然后,一次性查询所有学生信息
List<UmsStudentManage> umsStudentManageLists = studentIds.stream() List<UmsStudentManage> umsStudentManageLists = studentIds.stream()
.map(studentId -> umsStudentManageMapper.queryStudent(String.valueOf(studentId))) // 假设queryStudent接受Long类型参数 .map(studentId -> umsStudentManageMapper.queryStudent(String.valueOf(studentId)))
.filter(Objects::nonNull) .filter(Objects::nonNull)
.collect(Collectors.toList()); .collect(Collectors.toList());
@ -720,8 +726,8 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
userReadMessageTimeVO.setReceiverName(student.getName()); userReadMessageTimeVO.setReceiverName(student.getName());
userReadMessageTimeVOS.add(userReadMessageTimeVO); userReadMessageTimeVOS.add(userReadMessageTimeVO);
} else { } else {
log.error("学生不存在: {}", sc.getStudent()); log.warn("学生不存在: {}", sc.getStudent());
throw new BusinessException(ErrorCode.PARAMS_USER_NOTEXISTS); continue;
} }
} }
} }
@ -738,8 +744,8 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
userReadMessageTimeVO.setReceiverName(umsTeacher.getName()); userReadMessageTimeVO.setReceiverName(umsTeacher.getName());
userReadMessageTimeVOS.add(userReadMessageTimeVO); userReadMessageTimeVOS.add(userReadMessageTimeVO);
} else { } else {
log.error("教师不存在: {}", teacherId); log.warn("教师不存在: {}", teacherId);
throw new BusinessException(ErrorCode.PARAMS_USER_NOTEXISTS); continue;
} }
} }
@ -819,8 +825,8 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
userReadMessageTimeVO.setReceiverName(umsTeacher.getName()); userReadMessageTimeVO.setReceiverName(umsTeacher.getName());
userReadMessageTimeVOS.add(userReadMessageTimeVO); userReadMessageTimeVOS.add(userReadMessageTimeVO);
} else { } else {
log.error("教师不存在: {}", teacherId); log.warn("教师不存在: {}", teacherId);
throw new BusinessException(ErrorCode.PARAMS_USER_NOTEXISTS); continue;
} }
} }
@ -834,8 +840,8 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
userReadMessageTimeVO.setReceiverName(student.getName()); userReadMessageTimeVO.setReceiverName(student.getName());
userReadMessageTimeVOS.add(userReadMessageTimeVO); userReadMessageTimeVOS.add(userReadMessageTimeVO);
} else { } else {
log.error("学生不存在: {}", sc.getStudent()); log.warn("学生不存在: {}", sc.getStudent());
throw new BusinessException(ErrorCode.PARAMS_USER_NOTEXISTS); continue;
} }
} }
} }

@ -18,6 +18,9 @@ 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.model.vo.knowtmp.KnowTmpVO;
import com.teaching.backend.service.courses.IObjectiveContentKnowService; import com.teaching.backend.service.courses.IObjectiveContentKnowService;
import com.teaching.backend.utils.CourseCode;
import lombok.extern.slf4j.Slf4j;
import org.neo4j.driver.internal.value.StringValue;
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;
@ -28,6 +31,7 @@ import java.math.RoundingMode;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -39,6 +43,7 @@ import java.util.stream.Collectors;
* @since 2024-06-13 * @since 2024-06-13
*/ */
@Service @Service
@Slf4j
public class ObjectiveContentKnowServiceImpl extends ServiceImpl<ObjectiveContentKnowMapper, ObjectiveContentKnow> implements IObjectiveContentKnowService { public class ObjectiveContentKnowServiceImpl extends ServiceImpl<ObjectiveContentKnowMapper, ObjectiveContentKnow> implements IObjectiveContentKnowService {
@Autowired @Autowired
@ -94,12 +99,19 @@ public class ObjectiveContentKnowServiceImpl extends ServiceImpl<ObjectiveConten
ObjectiveContentKnowVO objectiveContentKnowVO = new ObjectiveContentKnowVO(); ObjectiveContentKnowVO objectiveContentKnowVO = new ObjectiveContentKnowVO();
// 根据传入的目标内容ID找到课程ID和总学时 // 根据传入的目标内容ID找到课程ID和总学时
String objectiveID = objectiveContentsMapper.selectOne(new LambdaQueryWrapper<ObjectiveContents>() String objectiveID = objectiveContentsMapper.selectById(objectiveContentId).getObjectiveId();
.eq(ObjectiveContents::getId, objectiveContentId)).getObjectiveId(); CourseObjectives courseObjective = courseObjectivesMapper.selectOne(new LambdaQueryWrapper<CourseObjectives>()
String pid = courseObjectivesMapper.selectOne(new LambdaQueryWrapper<CourseObjectives>() .eq(CourseObjectives::getId, objectiveID));
.eq(CourseObjectives::getId, objectiveID)).getPid(); String pid = courseObjective.getPid();
String courseId = courseObjectivesMapper.selectOne(new LambdaQueryWrapper<CourseObjectives>() //当前内容属于总目标类型的
.eq(CourseObjectives::getId, pid)).getCourseId(); String courseId;
if(pid.equals(String.valueOf(CourseCode.CONTENT_BELONGS_TO_TOTAL_OBJECTIVE.getValue()))){
courseId = courseObjective.getCourseId();
}
else {
courseId = courseObjectivesMapper.selectOne(new LambdaQueryWrapper<CourseObjectives>()
.eq(CourseObjectives::getId, pid)).getCourseId();
}
Integer classhours = coursesMapper.selectById(courseId).getClasshours(); Integer classhours = coursesMapper.selectById(courseId).getClasshours();
// 获取当前目标内容下关联的知识点数据 // 获取当前目标内容下关联的知识点数据
@ -107,6 +119,10 @@ public class ObjectiveContentKnowServiceImpl extends ServiceImpl<ObjectiveConten
new LambdaQueryWrapper<ObjectiveContentKnow>() new LambdaQueryWrapper<ObjectiveContentKnow>()
.eq(ObjectiveContentKnow::getObjectiveContentId, objectiveContentId) .eq(ObjectiveContentKnow::getObjectiveContentId, objectiveContentId)
); );
if(objectiveContentKnows.isEmpty()){
log.warn("当前课程目标下面没有关联的知识点contentId:{}",objectiveContentId);
throw new BusinessException(ErrorCode.CONTENT_HAS_NO_KNOWS);
}
// 创建并设置ObjectiveContentKnowVO对象的属性 // 创建并设置ObjectiveContentKnowVO对象的属性
objectiveContentKnowVO = createObjectiveContentKnowVO(objectiveContentId, objectiveContentKnows); objectiveContentKnowVO = createObjectiveContentKnowVO(objectiveContentId, objectiveContentKnows);
@ -125,16 +141,30 @@ public class ObjectiveContentKnowServiceImpl extends ServiceImpl<ObjectiveConten
vo.setObjectiveOrContent(objectiveOrContentId); vo.setObjectiveOrContent(objectiveOrContentId);
vo.setKnowsNumber(objectiveContentKnows.size()); vo.setKnowsNumber(objectiveContentKnows.size());
// 计算知识点的总时间,并收集关联的知识点部分数据 // 提取所有的 Know IDs
List<Long> knowIds = objectiveContentKnows.stream()
.map(ObjectiveContentKnow::getKnowId)
.collect(Collectors.toList());
// 一次性查询所有需要的 Knowtmp 数据
List<Knowtmp> knows = knowtmpMapper.selectList(new LambdaQueryWrapper<Knowtmp>()
.in(Knowtmp::getId, knowIds));
// 使用 Map 来存储 Knowtmp 数据,以便快速查找
Map<Long, Knowtmp> knowMap = knows.stream()
.collect(Collectors.toMap(Knowtmp::getId, know -> know));
Double knowsTime = 0.0; Double knowsTime = 0.0;
List<KnowTmpVO> knowTmpVOList = new ArrayList<>(); List<KnowTmpVO> knowTmpVOList = new ArrayList<>();
for (ObjectiveContentKnow contentKnow : objectiveContentKnows) { for (ObjectiveContentKnow contentKnow : objectiveContentKnows) {
Knowtmp know = knowtmpMapper.selectOne(new LambdaQueryWrapper<Knowtmp>() Knowtmp know = knowMap.get(contentKnow.getKnowId());
.eq(Knowtmp::getId, contentKnow.getKnowId()));
if (know == null) { if (know == null) {
throw new BusinessException(ErrorCode.KNOW_NOT_EXIT); log.warn("知识点不存在,id:{}", contentKnow.getKnowId());
// throw new BusinessException(ErrorCode.KNOW_NOT_EXIT);
continue; // 知识点不存在时跳过
} }
knowsTime += know.getHour(); knowsTime += know.getHour();
// 将当前知识点数据添加到knowTmpVOList中 // 将当前知识点数据添加到knowTmpVOList中
@ -150,6 +180,7 @@ public class ObjectiveContentKnowServiceImpl extends ServiceImpl<ObjectiveConten
return vo; return vo;
} }
// 计算知识点学时占总学时的比例,并返回百分比形式的结果 // 计算知识点学时占总学时的比例,并返回百分比形式的结果
private Double calculatePercentage(Double knowsTime, Integer classhours) { private Double calculatePercentage(Double knowsTime, Integer classhours) {
if (classhours == null || classhours == 0) { if (classhours == null || classhours == 0) {

@ -48,6 +48,11 @@ public class ObjectiveContentsServiceImpl extends ServiceImpl<ObjectiveContentsM
if(count > CourseCode.KNOWS_EXIT.getValue()){ if(count > CourseCode.KNOWS_EXIT.getValue()){
throw new BusinessException(ErrorCode.KNOWS_EXIT); throw new BusinessException(ErrorCode.KNOWS_EXIT);
} }
String objectiveId = objectiveContentsMapper.selectById(id).getObjectiveId();
Integer type = courseObjectivesMapper.selectById(objectiveId).getType();
if (type == TOTAL_OBJECTIVE_TYPE.getValue()){
throw new BusinessException(ErrorCode.TOTOAL_OBJECTIVE_CANT_DELETE);
}
int delete = objectiveContentsMapper.deleteById(id); int delete = objectiveContentsMapper.deleteById(id);
return delete > 0 ? "删除成功!" : "删除失败!"; return delete > 0 ? "删除成功!" : "删除失败!";
} }

@ -41,6 +41,7 @@ import org.neo4j.driver.types.Node;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.neo4j.core.Neo4jClient; import org.springframework.data.neo4j.core.Neo4jClient;
import org.springframework.data.neo4j.core.Neo4jTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -113,7 +114,7 @@ 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));
Long id1 = node1.id(); Long id1 = node1.id();
String name1 = node1.get("name").asString(); String name1 = node1.get("name").asString();
@ -168,8 +169,8 @@ public class knowServiceImpl implements KnowService {
knowVO = new KnowVO(); knowVO = new KnowVO();
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));
Long id1 = node1.id(); Long id1 = node1.id();
String name1 = node1.get("name").asString(); String name1 = node1.get("name").asString();
@ -225,7 +226,7 @@ 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));
Long id1 = node1.id(); Long id1 = node1.id();
String name1 = node1.get("name").asString(); String name1 = node1.get("name").asString();
@ -420,6 +421,77 @@ public class knowServiceImpl implements KnowService {
} }
Long opResult( String source, String target, String type, Integer sta){
Long res = -1L;
String weight = null;
if("contain".equals(type)){
weight = " {weight:5}";
}else if("dependent".equals(type)){
weight = " {weight:9}";
}else if("order".equals(type)){
weight = " {weight: 1}";
}
if(sta != null && sta == 1){
res = -1L;
Long target1 = Long.parseLong(target);
res = knowRepository.addCourseRelationship(source,target1);
if (res< 0L) {
throw new RuntimeException("添加课程-章节 包含 失败");
}
return res;
}
else if (sta != null && sta == 2) {
Long source1 = Long.parseLong(source);
Long target1 = Long.parseLong(target);
String str = "MATCH (p:Know), (j:Know) WHERE p.chapterId= "+source1+" AND j.chapterId= "+target1+" CREATE (p)-[r: "+type+weight+" ]->(j) return count(r) as `count`;";
Collection<Map<String, Object>> result = neo4jClient.query(str).fetch().all();
Iterator<Map<String, Object>> iterator = result.iterator();
res = -1L;
while (iterator.hasNext()){
Map<String, Object> element = iterator.next();
res = (Long) element.get("count");
}
if (res<=0L) {
throw new RuntimeException("添加章节-章节"+type+"失败");
}
return res;
} else if (sta != null && sta == 3) {
Long source1 = Long.parseLong(source);
Long target1 = Long.parseLong(target);
String str = "MATCH (p:Know), (j:Know) WHERE p.chapterId= "+source1+" AND j.knowId= "+target1+" CREATE (p)-[r: "+type+weight+" ]->(j) return count(r) as `count`;";
Collection<Map<String, Object>> result = neo4jClient.query(str).fetch().all();
Iterator<Map<String, Object>> iterator = result.iterator();
res = -1L;
while (iterator.hasNext()){
Map<String, Object> element = iterator.next();
res = (Long) element.get("count");
}
if (res < 0) {
throw new RuntimeException("添加章节-知识点"+type+"失败");
}
return res;
} else if (sta != null && sta == 4) {
Long source1 = Long.parseLong(source);
Long target1 = Long.parseLong(target);
String str = "MATCH (p:Know), (j:Know) WHERE p.chapterId= "+source1+" AND j.knowId= "+target1+" CREATE (p)-[r: "+type+weight+" ]->(j) return count(r) as `count`;";
Collection<Map<String, Object>> result = neo4jClient.query(str).fetch().all();
Iterator<Map<String, Object>> iterator = result.iterator();
res = -1L;
while (iterator.hasNext()){
Map<String, Object> element = iterator.next();
res = (Long) element.get("count");
}
if (res < 0L) {
throw new RuntimeException("添加知识点-知识点 关系"+type+"失败");
}
return res;
} else {
throw new RuntimeException("执行 错误");
}
}
//todo 根据json串生成 图谱 保证事务 //todo 根据json串生成 图谱 保证事务
private BaseResponse<String> generateGraph(String jsonNodeCourse, String jsonNodeChapter, String jsonNodeKnow, String jsonEdges) { private BaseResponse<String> generateGraph(String jsonNodeCourse, String jsonNodeChapter, String jsonNodeKnow, String jsonEdges) {
//插入图 //插入图
@ -467,8 +539,7 @@ public class knowServiceImpl implements KnowService {
} }
} }
//插入关系 // 1 课程-章节 2 章节 - 章节 3 章节 - 知识点 4 点 - 点
//插入关系
JSONArray jsonArrayEdges = JSONUtil.parseArray(jsonEdges); JSONArray jsonArrayEdges = JSONUtil.parseArray(jsonEdges);
for (Object obj : jsonArrayEdges) { for (Object obj : jsonArrayEdges) {
JSONObject jsonObject = (JSONObject) obj; JSONObject jsonObject = (JSONObject) obj;
@ -476,43 +547,14 @@ public class knowServiceImpl implements KnowService {
String target = jsonObject.getStr("target"); String target = jsonObject.getStr("target");
String type = jsonObject.getStr("type"); String type = jsonObject.getStr("type");
Integer sta = jsonObject.getInt("sta"); Integer sta = jsonObject.getInt("sta");
//在图数据库中插入 try {
if (sta != null && sta == 1) { opResult(source,target,type,sta);
Long target1 = Long.parseLong(target); }catch (Exception e){
int res = knowRepository.addCourseRelationship(source, target1, type); e.printStackTrace();
if (res <= 0) { return ResultUtils.error(ErrorCode.SYSTEM_ERROR,"添加节点关系失败");
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("添加节点关系成功"); return ResultUtils.success("添加节点关系成功");
} }
@ -748,7 +790,10 @@ 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: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(); neo4jClient.query("match(n:Know)-[r:contain*0..]->(p:Know) where n.courseId = '" + id + "' return n as `n`,r as `r`,p as `p`,length(r) as `d`").fetch().all();
Collection<Map<String, Object>> all2 =
neo4jClient.query("match(n:Know)-[r*]->(p:Know) where n.courseId = '" + id + "' return r as `r`").fetch().all();
Map<Long, String> colorChoose = new HashMap<>(); Map<Long, String> colorChoose = new HashMap<>();
String color[] = new String[10]; String color[] = new String[10];
@ -758,6 +803,7 @@ public class knowServiceImpl implements KnowService {
} }
Iterator<Map<String, Object>> iterator = all.iterator(); Iterator<Map<String, Object>> iterator = all.iterator();
Iterator<Map<String, Object>> iterator2 = all2.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;
@ -768,9 +814,8 @@ public class knowServiceImpl implements KnowService {
Map<String, Object> element = iterator.next(); Map<String, Object> element = iterator.next();
knowVO = new KnowVO(); knowVO = new KnowVO();
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) { if (node1 != null) {
Long id1 = node1.id(); Long id1 = node1.id();
String name1 = node1.get("name").asString(); String name1 = node1.get("name").asString();
@ -778,9 +823,29 @@ public class knowServiceImpl implements KnowService {
knowVO.setLabel(name1); knowVO.setLabel(name1);
knowList.add(knowVO); knowList.add(knowVO);
knowVO.setColor(colorChoose.get(group)); 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);
}
} }
}
while (iterator2.hasNext()) {
Map<String, Object> element = iterator2.next();
node2 = (List) element.get("r"); node2 = (List) element.get("r");
if (!node2.isEmpty()) { if (!node2.isEmpty()) {
for (int i = 0; i < node2.size(); i++) { for (int i = 0; i < node2.size(); i++) {

@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 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.Knowtemp.KnowtmpMapper;
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;
@ -54,6 +55,7 @@ public class KnowledgeLearningRecordServiceImpl extends ServiceImpl<KnowledgeLea
@Resource @Resource
private RecordKnowledgeFinishServiceImpl recordKnowledgeFinishService; private RecordKnowledgeFinishServiceImpl recordKnowledgeFinishService;
@Override @Override
public BaseResponse<String> saveCoursesRecords(KnowledgeLearningRecord knowledgeLearningRecord) { public BaseResponse<String> saveCoursesRecords(KnowledgeLearningRecord knowledgeLearningRecord) {
//知识点id //知识点id
@ -213,4 +215,18 @@ public class KnowledgeLearningRecordServiceImpl extends ServiceImpl<KnowledgeLea
return coursesList; return coursesList;
} }
@Override
public BaseResponse<String> studentFinish(String userId, String courseId) {
//获取学生该课程已完成的知识点数量
Long count = recordKnowledgeFinishService.query()
.eq("user_id", userId)
.eq("course_id", courseId)
.count();
//获取这门课程的总知识点数
BaseResponse<Long> allKnows = knowtmpService.getAllKnows(courseId);
double finish = (double) count /allKnows.getData() * 100;
System.out.println(finish);
return ResultUtils.success(String.valueOf(finish));
}
} }

@ -0,0 +1,45 @@
package com.teaching.backend.service.impl.system;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.teaching.backend.common.CommonResult;
import com.teaching.backend.mapper.system.SystemSettingsMapper;
import com.teaching.backend.model.entity.system.SystemSetting;
import com.teaching.backend.model.vo.system.SystemSettingVO;
import com.teaching.backend.service.system.SystemSettingsService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
@Service
public class SystemSettingsServiceImpl extends ServiceImpl<SystemSettingsMapper, SystemSetting> implements SystemSettingsService {
@Autowired
private SystemSettingsMapper systemSettingsMapper;
@Override
public SystemSettingVO getSystemSettings() {
SystemSetting systemSetting = lambdaQuery().one();
if (systemSetting == null){
SystemSetting setting = new SystemSetting();
setting.setId(1L);
save(setting);
SystemSettingVO systemSettingVO = new SystemSettingVO();
BeanUtils.copyProperties(setting,systemSettingVO);
return systemSettingVO;
}
SystemSettingVO systemSettingVO = new SystemSettingVO();
BeanUtils.copyProperties(systemSetting,systemSettingVO);
return systemSettingVO;
}
@Override
public CommonResult updateSystemSettings(SystemSetting systemSetting) {
boolean systemSettings = systemSettingsMapper.updateSystemSettings(systemSetting);
if (systemSettings == true){
return CommonResult.success("修改成功");
}else {
return CommonResult.failed("修改失败");
}
}
}

@ -31,5 +31,7 @@ public interface IKnowledgeLearningRecordService extends IService<KnowledgeLearn
List<KnowVO> queryMaxKnowledge(String userId); List<KnowVO> queryMaxKnowledge(String userId);
List<KnowVO> queryRecommendKnowledge(String userId); List<KnowVO> queryRecommendKnowledge(String userId);
BaseResponse<String> studentFinish(String userId, String courseId);
} }

@ -0,0 +1,12 @@
package com.teaching.backend.service.system;
import com.baomidou.mybatisplus.extension.service.IService;
import com.teaching.backend.common.CommonResult;
import com.teaching.backend.model.entity.system.SystemSetting;
import com.teaching.backend.model.vo.system.SystemSettingVO;
public interface SystemSettingsService extends IService<SystemSetting> {
SystemSettingVO getSystemSettings();
CommonResult updateSystemSettings(SystemSetting systemSetting);
}

@ -12,7 +12,7 @@ public enum CourseCode {
TOTAL_OBJECTIVE_TYPE(0, "课程总目标"), TOTAL_OBJECTIVE_TYPE(0, "课程总目标"),
TOTAL_OBJECTIVE_HAS_NO_CHILD(0, "课程总目标下面没有分项目标"), TOTAL_OBJECTIVE_HAS_NO_CHILD(0, "课程总目标下面没有分项目标"),
Total_EXIT(0, "课程总目标"), CONTENT_BELONGS_TO_TOTAL_OBJECTIVE(0, "该内容属于总目标"),
COURSE_UPDATING(1, "课程正在修改中"); COURSE_UPDATING(1, "课程正在修改中");

@ -54,7 +54,6 @@ secure:
ignored: ignored:
urls: urls:
# - /swagger-ui/ # - /swagger-ui/
- /**
# - /swagger-resources/** # - /swagger-resources/**
# - /**/v2/api-docs # - /**/v2/api-docs
# - /**/*.html # - /**/*.html
@ -71,7 +70,7 @@ secure:
# - /user/info # - /user/info
# - /user/logout # - /user/logout
# - /minio/upload # - /minio/upload
- /**
aliyun: aliyun:

@ -5,27 +5,27 @@
SELECT SELECT
* *
FROM FROM
course_learning_record clr record_course_learning rcl
WHERE WHERE
clr.user_id = #{student} rcl.user_id = #{student}
ORDER BY ORDER BY
times times
DESC LIMIT 1; DESC LIMIT 1;
</select> </select>
<select id="selectMaxNumber" resultType="java.lang.String" parameterType="java.lang.String"> <select id="selectMaxNumber" resultType="java.lang.String" parameterType="java.lang.String">
SELECT SELECT
cln.course_id courseId rcn.course_id courseId
FROM FROM
course_learning_number cln record_course_number rcn
WHERE WHERE
CONCAT(',', cln.teacher_user_id, ',') LIKE CONCAT('%,', #{userId}, ',%') CONCAT(',', rcn.teacher_user_id, ',') LIKE CONCAT('%,', #{userId}, ',%')
ORDER BY ORDER BY
number number
DESC; DESC;
</select> </select>
<select id="selectMaxCourseId" resultType="java.lang.String" parameterType="java.lang.String"> <select id="selectMaxCourseId" resultType="java.lang.String" parameterType="java.lang.String">
SELECT course_id, COUNT(*) as frequency SELECT course_id, COUNT(*) as frequency
FROM course_learning_record FROM record_course_learning
WHERE user_id = #{userId} WHERE user_id = #{userId}
GROUP BY course_id GROUP BY course_id
ORDER BY frequency DESC; ORDER BY frequency DESC;

@ -4,16 +4,16 @@
<select id="queryStudyKnowledgeMaxNumber" resultType="java.lang.String"> <select id="queryStudyKnowledgeMaxNumber" resultType="java.lang.String">
SELECT SELECT
kln.knowledge_id knowledgeId rkn.knowledge_id knowledgeId
FROM FROM
knowledge_learning_number kln record_knowledge_number rkn
ORDER BY ORDER BY
number number
DESC; DESC;
</select> </select>
<select id="queryStudyMaxKnowledgeId" resultType="java.lang.String"> <select id="queryStudyMaxKnowledgeId" resultType="java.lang.String">
SELECT knowledge_id,knowledge_name SELECT knowledge_id,knowledge_name
FROM knowledge_learning_record FROM record_knowledge_learning
WHERE user_id = #{userId} WHERE user_id = #{userId}
ORDER BY times DESC; ORDER BY times DESC;
</select> </select>

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.teaching.backend.mapper.system.SystemSettingsMapper">
<update id="updateSystemSettings">
update system_settings
<set>
<if test="name != null and name != ''">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="logo != null and logo != ''">
logo = #{logo,jdbcType=VARCHAR},
</if>
<if test="promotionalImages != null and promotionalImages != ''">
promotional_images = #{promotionalImages,jdbcType=VARCHAR},
</if>
<if test="loginAddress != null and loginAddress != ''">
login_address = #{loginAddress,jdbcType=VARCHAR},
</if>
<if test="title != null and title != ''">
title = #{title,jdbcType=VARCHAR},
</if>
<if test="copyrightInformation != null and copyrightInformation != ''">
copyright_information = #{copyrightInformation,jdbcType=VARCHAR},
</if>
<if test="recordNumber != null and recordNumber != ''">
record_number = #{recordNumber,jdbcType=VARCHAR},
</if>
<if test="qqNumber != null and qqNumber != ''">
qq_number = #{qqNumber,jdbcType=VARCHAR},
</if>
<if test="mailbox != null and mailbox != ''">
mailbox = #{mailbox,jdbcType=VARCHAR},
</if>
<if test="phone != null and phone != ''">
phone = #{phone,jdbcType=VARCHAR},
</if>
<if test="address != null and address != ''">
address = #{address,jdbcType=VARCHAR},
</if>
<if test="qrCode != null and qrCode != ''">
qr_code = #{qrCode,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>
Loading…
Cancel
Save