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, "角色不存在"),
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, "请求数据不存在"),

@ -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<Map<String, Object>> res = neo4jClient.query(str).fetch().all();
System.out.println(res);
}
//通过courseId 显示图的JSON

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

@ -96,4 +96,16 @@ public class KnowledgeLearningRecordController {
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.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<Know, Long> {
//==========
//建立关系 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);")

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

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

@ -45,7 +45,7 @@ public class ObjectiveContentKnow implements Serializable {
* 关联的知识点
*/
// 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;
/**
* 信息
* 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 org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.util.List;
/**
@ -24,6 +25,7 @@ public class CmsEssayServiceImpl extends ServiceImpl<CmsEssayMapper, CmsEssay> i
@Override
public BaseResponse<String> addEssay(CmsEssay cmsEssay) {
cmsEssay.setPublishTime(LocalDate.now());
save(cmsEssay);
return ResultUtils.success("添加成功");
}

@ -164,6 +164,12 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> 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<CoursesMapper, Courses> impl
// 然后,一次性查询所有学生信息
List<UmsStudentManage> 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<CoursesMapper, Courses> 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<CoursesMapper, Courses> 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<CoursesMapper, Courses> 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<CoursesMapper, Courses> 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;
}
}
}

@ -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<ObjectiveContentKnowMapper, ObjectiveContentKnow> implements IObjectiveContentKnowService {
@Autowired
@ -94,12 +99,19 @@ public class ObjectiveContentKnowServiceImpl extends ServiceImpl<ObjectiveConten
ObjectiveContentKnowVO objectiveContentKnowVO = new ObjectiveContentKnowVO();
// 根据传入的目标内容ID找到课程ID和总学时
String objectiveID = objectiveContentsMapper.selectOne(new LambdaQueryWrapper<ObjectiveContents>()
.eq(ObjectiveContents::getId, objectiveContentId)).getObjectiveId();
String pid = courseObjectivesMapper.selectOne(new LambdaQueryWrapper<CourseObjectives>()
.eq(CourseObjectives::getId, objectiveID)).getPid();
String courseId = courseObjectivesMapper.selectOne(new LambdaQueryWrapper<CourseObjectives>()
.eq(CourseObjectives::getId, pid)).getCourseId();
String objectiveID = objectiveContentsMapper.selectById(objectiveContentId).getObjectiveId();
CourseObjectives courseObjective = courseObjectivesMapper.selectOne(new LambdaQueryWrapper<CourseObjectives>()
.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<CourseObjectives>()
.eq(CourseObjectives::getId, pid)).getCourseId();
}
Integer classhours = coursesMapper.selectById(courseId).getClasshours();
// 获取当前目标内容下关联的知识点数据
@ -107,6 +119,10 @@ public class ObjectiveContentKnowServiceImpl extends ServiceImpl<ObjectiveConten
new LambdaQueryWrapper<ObjectiveContentKnow>()
.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<ObjectiveConten
vo.setObjectiveOrContent(objectiveOrContentId);
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;
List<KnowTmpVO> knowTmpVOList = new ArrayList<>();
for (ObjectiveContentKnow contentKnow : objectiveContentKnows) {
Knowtmp know = knowtmpMapper.selectOne(new LambdaQueryWrapper<Knowtmp>()
.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<ObjectiveConten
return vo;
}
// 计算知识点学时占总学时的比例,并返回百分比形式的结果
private Double calculatePercentage(Double knowsTime, Integer classhours) {
if (classhours == null || classhours == 0) {

@ -48,6 +48,11 @@ public class ObjectiveContentsServiceImpl extends ServiceImpl<ObjectiveContentsM
if(count > 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 ? "删除成功!" : "删除失败!";
}

@ -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<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串生成 图谱 保证事务
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);
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<BaseKnowReturn> getAllKnowByCourseId(String id) {
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<>();
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>> iterator2 = all2.iterator();
Set<KnowVO> knowList = new HashSet<>();
Set<Links> linksList = new HashSet<>();
KnowVO knowVO;
@ -768,9 +814,8 @@ public class knowServiceImpl implements KnowService {
Map<String, Object> element = iterator.next();
knowVO = new KnowVO();
Node node1 = (Node) element.get("p");
Long group = (Long) element.get("d");
// knowVO.setColor(colorChoose.get(group));
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<String, Object> element = iterator2.next();
node2 = (List) element.get("r");
if (!node2.isEmpty()) {
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.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<KnowledgeLea
@Resource
private RecordKnowledgeFinishServiceImpl recordKnowledgeFinishService;
@Override
public BaseResponse<String> saveCoursesRecords(KnowledgeLearningRecord knowledgeLearningRecord) {
//知识点id
@ -213,4 +215,18 @@ public class KnowledgeLearningRecordServiceImpl extends ServiceImpl<KnowledgeLea
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> 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_HAS_NO_CHILD(0, "课程总目标下面没有分项目标"),
Total_EXIT(0, "课程总目标"),
CONTENT_BELONGS_TO_TOTAL_OBJECTIVE(0, "该内容属于总目标"),
COURSE_UPDATING(1, "课程正在修改中");

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

@ -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>
<select id="selectMaxNumber" resultType="java.lang.String" parameterType="java.lang.String">
SELECT
cln.course_id courseId
rcn.course_id courseId
FROM
course_learning_number cln
record_course_number rcn
WHERE
CONCAT(',', cln.teacher_user_id, ',') LIKE CONCAT('%,', #{userId}, ',%')
CONCAT(',', rcn.teacher_user_id, ',') LIKE CONCAT('%,', #{userId}, ',%')
ORDER BY
number
DESC;
</select>
<select id="selectMaxCourseId" resultType="java.lang.String" parameterType="java.lang.String">
SELECT course_id, COUNT(*) as frequency
FROM course_learning_record
FROM record_course_learning
WHERE user_id = #{userId}
GROUP BY course_id
ORDER BY frequency DESC;

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