diff --git a/src/main/java/com/teaching/backend/common/ErrorCode.java b/src/main/java/com/teaching/backend/common/ErrorCode.java index a67b684..9679c72 100644 --- a/src/main/java/com/teaching/backend/common/ErrorCode.java +++ b/src/main/java/com/teaching/backend/common/ErrorCode.java @@ -22,6 +22,11 @@ public enum ErrorCode { INVALID_ROLE(400010, "角色不存在"), MESSAGE_NO_READ(400011, "消息未读,禁止删除!"), MESSAGE_NO_EXIT(400012, "消息不存在!"), + + TOTOAL_OBJECTIVE_CANT_DELETE(400013, "课程总目标内容禁止删除!"), + CONTENT_HAS_NO_KNOWS(400014, "当前课程目标下面没有关联的知识点!"), + + NOT_LOGIN_ERROR(40100, "未登录"), NO_AUTH_ERROR(40101, "无权限"), NOT_FOUND_ERROR(40400, "请求数据不存在"), diff --git a/src/main/java/com/teaching/backend/controller/Know/KnowController.java b/src/main/java/com/teaching/backend/controller/Know/KnowController.java index cd67565..989f77e 100644 --- a/src/main/java/com/teaching/backend/controller/Know/KnowController.java +++ b/src/main/java/com/teaching/backend/controller/Know/KnowController.java @@ -17,8 +17,12 @@ import com.teaching.backend.model.vo.knowGraph.KnowVO1; import com.teaching.backend.service.Know.KnowService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.neo4j.core.Neo4jClient; import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; +import java.util.Collection; +import java.util.Map; import java.util.Set; @@ -31,6 +35,9 @@ public class KnowController { @Autowired private KnowRepository knowRepository; + @Resource + private Neo4jClient neo4jClient; + @@ -54,8 +61,11 @@ public class KnowController { //通过courseId 显示图的JSON @GetMapping("/test") - void test(@RequestParam String courseId){ - int res = knowRepository.addCourseRelationship(courseId,932L,"related"); + void test(){ + 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> res = neo4jClient.query(str).fetch().all(); + System.out.println(res); } //通过courseId 显示图的JSON diff --git a/src/main/java/com/teaching/backend/controller/cms/CmsEssayController.java b/src/main/java/com/teaching/backend/controller/cms/CmsEssayController.java index 8b3621c..19e79df 100644 --- a/src/main/java/com/teaching/backend/controller/cms/CmsEssayController.java +++ b/src/main/java/com/teaching/backend/controller/cms/CmsEssayController.java @@ -74,7 +74,7 @@ public class CmsEssayController { * @return */ @PutMapping("/edit/status") - public BaseResponse editStatus(CmsEssay cmsEssay){ + public BaseResponse editStatus(@RequestBody CmsEssay cmsEssay){ return cmsEssayService.editStatus(cmsEssay); } } diff --git a/src/main/java/com/teaching/backend/controller/records/KnowledgeLearningRecordController.java b/src/main/java/com/teaching/backend/controller/records/KnowledgeLearningRecordController.java index 8c132cb..1faff85 100644 --- a/src/main/java/com/teaching/backend/controller/records/KnowledgeLearningRecordController.java +++ b/src/main/java/com/teaching/backend/controller/records/KnowledgeLearningRecordController.java @@ -96,4 +96,16 @@ public class KnowledgeLearningRecordController { return CommonResult.success(coursesVOList); } + /** + * 学生知识点的完成度 + * @param userId + * @param courseId + * @return + */ + @ApiOperation("学生知识点的完成度") + @PostMapping("/studentfinish") + public BaseResponse studentFinish(@RequestParam String userId, @RequestParam String courseId) { + return knowledgeLearningRecordService.studentFinish(userId,courseId); + } + } diff --git a/src/main/java/com/teaching/backend/controller/system/SystemSettingsController.java b/src/main/java/com/teaching/backend/controller/system/SystemSettingsController.java new file mode 100644 index 0000000..d67125d --- /dev/null +++ b/src/main/java/com/teaching/backend/controller/system/SystemSettingsController.java @@ -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 save(){ + SystemSettingVO systemSettings = systemSettingsService.getSystemSettings(); + return CommonResult.success(systemSettings); + } + + /** + * 编辑系统设置信息 + * @param systemSetting + * @return + */ + @PutMapping + @ApiOperation("编辑系统设置信息") + public CommonResult update(@RequestBody SystemSetting systemSetting){ + return systemSettingsService.updateSystemSettings(systemSetting); + } + +} diff --git a/src/main/java/com/teaching/backend/mapper/know/KnowRepository.java b/src/main/java/com/teaching/backend/mapper/know/KnowRepository.java index 958a8ac..c1861d7 100644 --- a/src/main/java/com/teaching/backend/mapper/know/KnowRepository.java +++ b/src/main/java/com/teaching/backend/mapper/know/KnowRepository.java @@ -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.KnowCourse; 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.query.Query; import org.springframework.data.repository.query.Param; +import java.util.Collections; import java.util.List; import java.util.Set; @@ -101,12 +103,14 @@ public interface KnowRepository extends Neo4jRepository { //========== //建立关系 all -课程 - @Query("MATCH (p:Know {courseId: $courseId}), (j:Know {chapterId: $chapterId}) CREATE (p)-[r:顺序]->(j) return count(p);") - int addCourseRelationship(String courseId,Long chapterId,String type); + @Query("MATCH (p:Know {courseId: $courseId}), (j:Know {chapterId: $chapterId}) CREATE (p)-[r:contain]->(j) return count(p);") + Long addCourseRelationship(String courseId,Long chapterId); + + //建立关系 all -章节 - @Query("MATCH (p:Know), (j:Know) WHERE p.chapterId= $chapterId1 AND ID(j)= $chapterId2 CREATE (p)-[r: "+"$type"+"]->(j) return count(r);") - int addChapterRelationship(Long chapterId1, Long chapterId2, @Param("type")String type); +// @Query({str}) +// int addChapterRelationship(String str); //建立关系 all -节 - 点 @Query("MATCH (p:Know), (j:Know) WHERE p.chapterId= $chapterId AND j.knowId= $knowId CREATE (p)-[r: $type]->(j) return count(r);") diff --git a/src/main/java/com/teaching/backend/mapper/report/ReportMapper.java b/src/main/java/com/teaching/backend/mapper/report/ReportMapper.java index 6da6396..a74f15a 100644 --- a/src/main/java/com/teaching/backend/mapper/report/ReportMapper.java +++ b/src/main/java/com/teaching/backend/mapper/report/ReportMapper.java @@ -3,9 +3,11 @@ package com.teaching.backend.mapper.report; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.teaching.backend.model.dto.report.ReportDTO; import com.teaching.backend.model.entity.report.Report; +import org.apache.ibatis.annotations.Mapper; import java.time.LocalDate; +@Mapper public interface ReportMapper extends BaseMapper { String getBrowseByTime(LocalDate day); diff --git a/src/main/java/com/teaching/backend/mapper/system/SystemSettingsMapper.java b/src/main/java/com/teaching/backend/mapper/system/SystemSettingsMapper.java new file mode 100644 index 0000000..116e5b0 --- /dev/null +++ b/src/main/java/com/teaching/backend/mapper/system/SystemSettingsMapper.java @@ -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 { + boolean updateSystemSettings(SystemSetting systemSetting); +} diff --git a/src/main/java/com/teaching/backend/mapper/umsAdmin/UmsStudentMapper.java b/src/main/java/com/teaching/backend/mapper/umsAdmin/UmsStudentMapper.java index fb58d74..946f34f 100644 --- a/src/main/java/com/teaching/backend/mapper/umsAdmin/UmsStudentMapper.java +++ b/src/main/java/com/teaching/backend/mapper/umsAdmin/UmsStudentMapper.java @@ -2,6 +2,7 @@ package com.teaching.backend.mapper.umsAdmin; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.teaching.backend.model.entity.umsAdmin.UmsStudent; +import org.apache.ibatis.annotations.Mapper; /** *

@@ -11,6 +12,8 @@ import com.teaching.backend.model.entity.umsAdmin.UmsStudent; * @author zjh * @since 2024-06-12 */ + +@Mapper public interface UmsStudentMapper extends BaseMapper { boolean updateStudentInfo(UmsStudent umsStudent); diff --git a/src/main/java/com/teaching/backend/mapper/umsAdmin/UmsTeacherMapper.java b/src/main/java/com/teaching/backend/mapper/umsAdmin/UmsTeacherMapper.java index 04e99e9..8e58a6c 100644 --- a/src/main/java/com/teaching/backend/mapper/umsAdmin/UmsTeacherMapper.java +++ b/src/main/java/com/teaching/backend/mapper/umsAdmin/UmsTeacherMapper.java @@ -2,6 +2,7 @@ package com.teaching.backend.mapper.umsAdmin; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.teaching.backend.model.entity.umsAdmin.UmsTeacher; +import org.apache.ibatis.annotations.Mapper; /** *

@@ -11,6 +12,8 @@ import com.teaching.backend.model.entity.umsAdmin.UmsTeacher; * @author zjh * @since 2024-06-12 */ + +@Mapper public interface UmsTeacherMapper extends BaseMapper { boolean updateTeacherInfo(UmsTeacher umsTeacher); diff --git a/src/main/java/com/teaching/backend/model/entity/courses/ObjectiveContentKnow.java b/src/main/java/com/teaching/backend/model/entity/courses/ObjectiveContentKnow.java index 023b03b..f150bc6 100644 --- a/src/main/java/com/teaching/backend/model/entity/courses/ObjectiveContentKnow.java +++ b/src/main/java/com/teaching/backend/model/entity/courses/ObjectiveContentKnow.java @@ -45,7 +45,7 @@ public class ObjectiveContentKnow implements Serializable { * 关联的知识点 */ // private String know; - private Integer knowId; + private Long knowId; } diff --git a/src/main/java/com/teaching/backend/model/entity/system/SystemSetting.java b/src/main/java/com/teaching/backend/model/entity/system/SystemSetting.java new file mode 100644 index 0000000..d19762a --- /dev/null +++ b/src/main/java/com/teaching/backend/model/entity/system/SystemSetting.java @@ -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; +} diff --git a/src/main/java/com/teaching/backend/model/vo/knowGraph/KnowVO.java b/src/main/java/com/teaching/backend/model/vo/knowGraph/KnowVO.java index beaa1a2..c6bdbc3 100644 --- a/src/main/java/com/teaching/backend/model/vo/knowGraph/KnowVO.java +++ b/src/main/java/com/teaching/backend/model/vo/knowGraph/KnowVO.java @@ -21,7 +21,7 @@ public class KnowVO implements Serializable { private String label; /** - * 信息 + * color */ private String color; diff --git a/src/main/java/com/teaching/backend/model/vo/system/SystemSettingVO.java b/src/main/java/com/teaching/backend/model/vo/system/SystemSettingVO.java new file mode 100644 index 0000000..eb21803 --- /dev/null +++ b/src/main/java/com/teaching/backend/model/vo/system/SystemSettingVO.java @@ -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; +} diff --git a/src/main/java/com/teaching/backend/service/impl/cms/CmsEssayServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/cms/CmsEssayServiceImpl.java index 5e091fc..61420bf 100644 --- a/src/main/java/com/teaching/backend/service/impl/cms/CmsEssayServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/cms/CmsEssayServiceImpl.java @@ -9,6 +9,7 @@ import com.teaching.backend.model.entity.cms.CmsEssay; import com.teaching.backend.service.cms.ICmsEssayService; import org.springframework.stereotype.Service; +import java.time.LocalDate; import java.util.List; /** @@ -24,6 +25,7 @@ public class CmsEssayServiceImpl extends ServiceImpl i @Override public BaseResponse addEssay(CmsEssay cmsEssay) { + cmsEssay.setPublishTime(LocalDate.now()); save(cmsEssay); return ResultUtils.success("添加成功"); } diff --git a/src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java index f6d9ba7..ad6789e 100644 --- a/src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java @@ -164,6 +164,12 @@ public class CoursesServiceImpl extends ServiceImpl impl courseObjectivesMapper.updateById(courseTotalObjectives); } + // 在总目标里面插入一个内容 + ObjectiveContents objectiveContents = new ObjectiveContents(); + objectiveContents.setObjectiveId(courseTotalObjectivesId); + objectiveContents.setContent("请添加课程总目标"); + objectiveContentsMapper.insert(objectiveContents); + return "添加成功"; } @@ -424,7 +430,7 @@ public class CoursesServiceImpl extends ServiceImpl impl // 然后,一次性查询所有学生信息 List umsStudentManageLists = studentIds.stream() - .map(studentId -> umsStudentManageMapper.queryStudent(String.valueOf(studentId))) // 假设queryStudent接受Long类型参数 + .map(studentId -> umsStudentManageMapper.queryStudent(String.valueOf(studentId))) .filter(Objects::nonNull) .collect(Collectors.toList()); @@ -720,8 +726,8 @@ public class CoursesServiceImpl extends ServiceImpl impl userReadMessageTimeVO.setReceiverName(student.getName()); userReadMessageTimeVOS.add(userReadMessageTimeVO); } else { - log.error("学生不存在: {}", sc.getStudent()); - throw new BusinessException(ErrorCode.PARAMS_USER_NOTEXISTS); + log.warn("学生不存在: {}", sc.getStudent()); + continue; } } } @@ -738,8 +744,8 @@ public class CoursesServiceImpl extends ServiceImpl impl userReadMessageTimeVO.setReceiverName(umsTeacher.getName()); userReadMessageTimeVOS.add(userReadMessageTimeVO); } else { - log.error("教师不存在: {}", teacherId); - throw new BusinessException(ErrorCode.PARAMS_USER_NOTEXISTS); + log.warn("教师不存在: {}", teacherId); + continue; } } @@ -819,8 +825,8 @@ public class CoursesServiceImpl extends ServiceImpl impl userReadMessageTimeVO.setReceiverName(umsTeacher.getName()); userReadMessageTimeVOS.add(userReadMessageTimeVO); } else { - log.error("教师不存在: {}", teacherId); - throw new BusinessException(ErrorCode.PARAMS_USER_NOTEXISTS); + log.warn("教师不存在: {}", teacherId); + continue; } } @@ -834,8 +840,8 @@ public class CoursesServiceImpl extends ServiceImpl impl userReadMessageTimeVO.setReceiverName(student.getName()); userReadMessageTimeVOS.add(userReadMessageTimeVO); } else { - log.error("学生不存在: {}", sc.getStudent()); - throw new BusinessException(ErrorCode.PARAMS_USER_NOTEXISTS); + log.warn("学生不存在: {}", sc.getStudent()); + continue; } } } diff --git a/src/main/java/com/teaching/backend/service/impl/courses/ObjectiveContentKnowServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/courses/ObjectiveContentKnowServiceImpl.java index c1ee035..7ef7db2 100644 --- a/src/main/java/com/teaching/backend/service/impl/courses/ObjectiveContentKnowServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/courses/ObjectiveContentKnowServiceImpl.java @@ -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.knowtmp.KnowTmpVO; 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.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -28,6 +31,7 @@ import java.math.RoundingMode; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; /** @@ -39,6 +43,7 @@ import java.util.stream.Collectors; * @since 2024-06-13 */ @Service +@Slf4j public class ObjectiveContentKnowServiceImpl extends ServiceImpl implements IObjectiveContentKnowService { @Autowired @@ -94,12 +99,19 @@ public class ObjectiveContentKnowServiceImpl extends ServiceImpl() - .eq(ObjectiveContents::getId, objectiveContentId)).getObjectiveId(); - String pid = courseObjectivesMapper.selectOne(new LambdaQueryWrapper() - .eq(CourseObjectives::getId, objectiveID)).getPid(); - String courseId = courseObjectivesMapper.selectOne(new LambdaQueryWrapper() - .eq(CourseObjectives::getId, pid)).getCourseId(); + String objectiveID = objectiveContentsMapper.selectById(objectiveContentId).getObjectiveId(); + CourseObjectives courseObjective = courseObjectivesMapper.selectOne(new LambdaQueryWrapper() + .eq(CourseObjectives::getId, objectiveID)); + String pid = courseObjective.getPid(); + //当前内容属于总目标类型的 + String courseId; + if(pid.equals(String.valueOf(CourseCode.CONTENT_BELONGS_TO_TOTAL_OBJECTIVE.getValue()))){ + courseId = courseObjective.getCourseId(); + } + else { + courseId = courseObjectivesMapper.selectOne(new LambdaQueryWrapper() + .eq(CourseObjectives::getId, pid)).getCourseId(); + } Integer classhours = coursesMapper.selectById(courseId).getClasshours(); // 获取当前目标内容下关联的知识点数据 @@ -107,6 +119,10 @@ public class ObjectiveContentKnowServiceImpl extends ServiceImpl() .eq(ObjectiveContentKnow::getObjectiveContentId, objectiveContentId) ); + if(objectiveContentKnows.isEmpty()){ + log.warn("当前课程目标下面没有关联的知识点contentId:{}",objectiveContentId); + throw new BusinessException(ErrorCode.CONTENT_HAS_NO_KNOWS); + } // 创建并设置ObjectiveContentKnowVO对象的属性 objectiveContentKnowVO = createObjectiveContentKnowVO(objectiveContentId, objectiveContentKnows); @@ -125,16 +141,30 @@ public class ObjectiveContentKnowServiceImpl extends ServiceImpl knowIds = objectiveContentKnows.stream() + .map(ObjectiveContentKnow::getKnowId) + .collect(Collectors.toList()); + + // 一次性查询所有需要的 Knowtmp 数据 + List knows = knowtmpMapper.selectList(new LambdaQueryWrapper() + .in(Knowtmp::getId, knowIds)); + + // 使用 Map 来存储 Knowtmp 数据,以便快速查找 + Map knowMap = knows.stream() + .collect(Collectors.toMap(Knowtmp::getId, know -> know)); + Double knowsTime = 0.0; List knowTmpVOList = new ArrayList<>(); for (ObjectiveContentKnow contentKnow : objectiveContentKnows) { - Knowtmp know = knowtmpMapper.selectOne(new LambdaQueryWrapper() - .eq(Knowtmp::getId, contentKnow.getKnowId())); + Knowtmp know = knowMap.get(contentKnow.getKnowId()); 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(); // 将当前知识点数据添加到knowTmpVOList中 @@ -150,6 +180,7 @@ public class ObjectiveContentKnowServiceImpl extends ServiceImpl CourseCode.KNOWS_EXIT.getValue()){ 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); return delete > 0 ? "删除成功!" : "删除失败!"; } diff --git a/src/main/java/com/teaching/backend/service/impl/know/knowServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/know/knowServiceImpl.java index 8744014..bed4f66 100644 --- a/src/main/java/com/teaching/backend/service/impl/know/knowServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/know/knowServiceImpl.java @@ -41,6 +41,7 @@ import org.neo4j.driver.types.Node; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.neo4j.core.Neo4jClient; +import org.springframework.data.neo4j.core.Neo4jTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -113,7 +114,7 @@ public class knowServiceImpl implements KnowService { Node node1 = (Node) element.get("p"); Long group = (Long) element.get("d"); - knowVO.setColor(colorChoose.get(group)); +// knowVO.setColor(colorChoose.get(group)); Long id1 = node1.id(); String name1 = node1.get("name").asString(); @@ -168,8 +169,8 @@ public class knowServiceImpl implements KnowService { knowVO = new KnowVO(); Node node1 = (Node) element.get("p"); - Long group = (Long) element.get("d"); - knowVO.setColor(colorChoose.get(group)); +// Long group = (Long) element.get("d"); +// knowVO.setColor(colorChoose.get(group)); Long id1 = node1.id(); String name1 = node1.get("name").asString(); @@ -225,7 +226,7 @@ public class knowServiceImpl implements KnowService { Node node1 = (Node) element.get("p"); Long group = (Long) element.get("d"); - knowVO.setColor(colorChoose.get(group)); +// knowVO.setColor(colorChoose.get(group)); Long id1 = node1.id(); 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> result = neo4jClient.query(str).fetch().all(); + Iterator> iterator = result.iterator(); + res = -1L; + while (iterator.hasNext()){ + Map 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> result = neo4jClient.query(str).fetch().all(); + Iterator> iterator = result.iterator(); + res = -1L; + while (iterator.hasNext()){ + Map 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> result = neo4jClient.query(str).fetch().all(); + Iterator> iterator = result.iterator(); + res = -1L; + while (iterator.hasNext()){ + Map element = iterator.next(); + res = (Long) element.get("count"); + } + if (res < 0L) { + throw new RuntimeException("添加知识点-知识点 关系"+type+"失败"); + } + return res; + } else { + throw new RuntimeException("执行 错误"); + } + + } + //todo 根据json串生成 图谱 保证事务 private BaseResponse 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); for (Object obj : jsonArrayEdges) { JSONObject jsonObject = (JSONObject) obj; @@ -476,43 +547,14 @@ public class knowServiceImpl implements KnowService { String target = jsonObject.getStr("target"); String type = jsonObject.getStr("type"); Integer sta = jsonObject.getInt("sta"); - //在图数据库中插入 - if (sta != null && sta == 1) { - Long target1 = Long.parseLong(target); - int res = knowRepository.addCourseRelationship(source, target1, type); - if (res <= 0) { - throw new RuntimeException("添加关系 1 失败"); - } - } else if (sta != null && sta == 2) { - Long source1 = Long.parseLong(source); - Long target1 = Long.parseLong(target); - int res = knowRepository.addChapterRelationship(source1, target1, type); - if (res <= 0) { - throw new RuntimeException("添加关系 2 失败"); - } - - } else if (sta != null && sta == 3) { - Long source1 = Long.parseLong(source); - Long target1 = Long.parseLong(target); - int res = knowRepository.addChapterToKnowRelationship(source1, target1, type); - if (res <= 0) { - throw new RuntimeException("添加关系 13失败"); - } - } else if (sta != null && sta == 4) { - Long source1 = Long.parseLong(source); - Long target1 = Long.parseLong(target); - int res = knowRepository.addKnowRelationship(source1, target1, type); - if (res <= 0) { - throw new RuntimeException("添加关系 4 失败"); - } - } else { - throw new RuntimeException("sta 错误"); + try { + opResult(source,target,type,sta); + }catch (Exception e){ + e.printStackTrace(); + return ResultUtils.error(ErrorCode.SYSTEM_ERROR,"添加节点关系失败"); + } } - - } return ResultUtils.success("添加节点关系成功"); - - } @@ -748,7 +790,10 @@ public class knowServiceImpl implements KnowService { @Override public BaseResponse getAllKnowByCourseId(String id) { Collection> 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> all2 = + neo4jClient.query("match(n:Know)-[r*]->(p:Know) where n.courseId = '" + id + "' return r as `r`").fetch().all(); + Map colorChoose = new HashMap<>(); String color[] = new String[10]; @@ -758,6 +803,7 @@ public class knowServiceImpl implements KnowService { } Iterator> iterator = all.iterator(); + Iterator> iterator2 = all2.iterator(); Set knowList = new HashSet<>(); Set linksList = new HashSet<>(); KnowVO knowVO; @@ -768,9 +814,8 @@ public class knowServiceImpl implements KnowService { Map element = iterator.next(); knowVO = new KnowVO(); Node node1 = (Node) element.get("p"); - Long group = (Long) element.get("d"); -// knowVO.setColor(colorChoose.get(group)); + knowVO.setColor(colorChoose.get(group)); if (node1 != null) { Long id1 = node1.id(); String name1 = node1.get("name").asString(); @@ -778,9 +823,29 @@ public class knowServiceImpl implements KnowService { knowVO.setLabel(name1); knowList.add(knowVO); knowVO.setColor(colorChoose.get(group)); + } + node2 = (List) element.get("r"); + if (!node2.isEmpty()) { + for (int i = 0; i < node2.size(); i++) { + InternalRelationship e = (InternalRelationship) node2.get(i); + links = new Links(); + links.setId(e.id()); + links.setSource(e.startNodeId()); + links.setTarget(e.endNodeId()); + if ("contain".equals(e.type())) { + links.setLabel("包含"); + } else if ("order".equals(e.type())) { + links.setLabel("顺序"); + } + linksList.add(links); + } } + + } + while (iterator2.hasNext()) { + Map element = iterator2.next(); node2 = (List) element.get("r"); if (!node2.isEmpty()) { for (int i = 0; i < node2.size(); i++) { diff --git a/src/main/java/com/teaching/backend/service/impl/records/KnowledgeLearningRecordServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/records/KnowledgeLearningRecordServiceImpl.java index b120f8a..6d389a1 100644 --- a/src/main/java/com/teaching/backend/service/impl/records/KnowledgeLearningRecordServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/records/KnowledgeLearningRecordServiceImpl.java @@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 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.Knowtemp.KnowtmpMapper; import com.teaching.backend.mapper.records.KnowledgeLearningRecordMapper; import com.teaching.backend.mapper.umsAdmin.UmsUserMapper; @@ -54,6 +55,7 @@ public class KnowledgeLearningRecordServiceImpl extends ServiceImpl saveCoursesRecords(KnowledgeLearningRecord knowledgeLearningRecord) { //知识点id @@ -213,4 +215,18 @@ public class KnowledgeLearningRecordServiceImpl extends ServiceImpl studentFinish(String userId, String courseId) { + //获取学生该课程已完成的知识点数量 + Long count = recordKnowledgeFinishService.query() + .eq("user_id", userId) + .eq("course_id", courseId) + .count(); + //获取这门课程的总知识点数 + BaseResponse allKnows = knowtmpService.getAllKnows(courseId); + double finish = (double) count /allKnows.getData() * 100; + System.out.println(finish); + return ResultUtils.success(String.valueOf(finish)); + } + } diff --git a/src/main/java/com/teaching/backend/service/impl/system/SystemSettingsServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/system/SystemSettingsServiceImpl.java new file mode 100644 index 0000000..20dc9c0 --- /dev/null +++ b/src/main/java/com/teaching/backend/service/impl/system/SystemSettingsServiceImpl.java @@ -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 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("修改失败"); + } + } +} diff --git a/src/main/java/com/teaching/backend/service/records/IKnowledgeLearningRecordService.java b/src/main/java/com/teaching/backend/service/records/IKnowledgeLearningRecordService.java index a90f9c4..b2858af 100644 --- a/src/main/java/com/teaching/backend/service/records/IKnowledgeLearningRecordService.java +++ b/src/main/java/com/teaching/backend/service/records/IKnowledgeLearningRecordService.java @@ -31,5 +31,7 @@ public interface IKnowledgeLearningRecordService extends IService queryMaxKnowledge(String userId); List queryRecommendKnowledge(String userId); + + BaseResponse studentFinish(String userId, String courseId); } diff --git a/src/main/java/com/teaching/backend/service/system/SystemSettingsService.java b/src/main/java/com/teaching/backend/service/system/SystemSettingsService.java new file mode 100644 index 0000000..f6dea64 --- /dev/null +++ b/src/main/java/com/teaching/backend/service/system/SystemSettingsService.java @@ -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 { + SystemSettingVO getSystemSettings(); + + CommonResult updateSystemSettings(SystemSetting systemSetting); +} diff --git a/src/main/java/com/teaching/backend/utils/CourseCode.java b/src/main/java/com/teaching/backend/utils/CourseCode.java index b7b2465..50a2d6e 100644 --- a/src/main/java/com/teaching/backend/utils/CourseCode.java +++ b/src/main/java/com/teaching/backend/utils/CourseCode.java @@ -12,7 +12,7 @@ public enum CourseCode { TOTAL_OBJECTIVE_TYPE(0, "课程总目标"), TOTAL_OBJECTIVE_HAS_NO_CHILD(0, "课程总目标下面没有分项目标"), - Total_EXIT(0, "课程总目标"), + CONTENT_BELONGS_TO_TOTAL_OBJECTIVE(0, "该内容属于总目标"), COURSE_UPDATING(1, "课程正在修改中"); diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index d0c7383..19604a4 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -54,7 +54,6 @@ secure: ignored: urls: # - /swagger-ui/ - - /** # - /swagger-resources/** # - /**/v2/api-docs # - /**/*.html @@ -71,7 +70,7 @@ secure: # - /user/info # - /user/logout # - /minio/upload - + - /** aliyun: diff --git a/src/main/resources/mapper/CourseLearningRecordMapper.xml b/src/main/resources/mapper/CourseLearningRecordMapper.xml index 7ec9971..288ae60 100644 --- a/src/main/resources/mapper/CourseLearningRecordMapper.xml +++ b/src/main/resources/mapper/CourseLearningRecordMapper.xml @@ -5,27 +5,27 @@ SELECT * FROM - course_learning_record clr + record_course_learning rcl WHERE - clr.user_id = #{student} + rcl.user_id = #{student} ORDER BY times DESC LIMIT 1; SELECT - kln.knowledge_id knowledgeId + rkn.knowledge_id knowledgeId FROM - knowledge_learning_number kln + record_knowledge_number rkn ORDER BY number DESC; diff --git a/src/main/resources/mapper/SystemSettingsMapper.xml b/src/main/resources/mapper/SystemSettingsMapper.xml new file mode 100644 index 0000000..d5b2e9b --- /dev/null +++ b/src/main/resources/mapper/SystemSettingsMapper.xml @@ -0,0 +1,48 @@ + + + + + + update system_settings + + + name = #{name,jdbcType=VARCHAR}, + + + logo = #{logo,jdbcType=VARCHAR}, + + + promotional_images = #{promotionalImages,jdbcType=VARCHAR}, + + + login_address = #{loginAddress,jdbcType=VARCHAR}, + + + title = #{title,jdbcType=VARCHAR}, + + + copyright_information = #{copyrightInformation,jdbcType=VARCHAR}, + + + record_number = #{recordNumber,jdbcType=VARCHAR}, + + + qq_number = #{qqNumber,jdbcType=VARCHAR}, + + + mailbox = #{mailbox,jdbcType=VARCHAR}, + + + phone = #{phone,jdbcType=VARCHAR}, + + + address = #{address,jdbcType=VARCHAR}, + + + qr_code = #{qrCode,jdbcType=VARCHAR}, + + + where id = #{id,jdbcType=BIGINT} + + + diff --git a/src/main/resources/mapper/UmsStudentManageService.xml b/src/main/resources/mapper/UmsStudentManageMapper.xml similarity index 100% rename from src/main/resources/mapper/UmsStudentManageService.xml rename to src/main/resources/mapper/UmsStudentManageMapper.xml diff --git a/tempFile/19854ab3-b8bc-4660-bb40-b4ee6184cd30/1.组织学绪论.ppt b/tempFile/19854ab3-b8bc-4660-bb40-b4ee6184cd30/1.组织学绪论.ppt new file mode 100644 index 0000000..313a46a Binary files /dev/null and b/tempFile/19854ab3-b8bc-4660-bb40-b4ee6184cd30/1.组织学绪论.ppt differ diff --git a/tempFile/2b9dae36-8ef9-45b0-b720-08ba444ba741/上皮组织作业.doc b/tempFile/2b9dae36-8ef9-45b0-b720-08ba444ba741/上皮组织作业.doc new file mode 100644 index 0000000..74bfaf5 Binary files /dev/null and b/tempFile/2b9dae36-8ef9-45b0-b720-08ba444ba741/上皮组织作业.doc differ