Merge remote-tracking branch 'origin/master'

master
小萌新 2 months ago
commit aeadc75e7a
  1. 1029
      sql/teaching_db6.0.sql
  2. 8
      sql/teaching_db6.1.sql
  3. 1
      src/main/java/com/teaching/backend/common/ErrorCode.java
  4. 4
      src/main/java/com/teaching/backend/controller/FavourInformation/FavourInformationController.java
  5. 197
      src/main/java/com/teaching/backend/controller/Know/KnowController.java
  6. 21
      src/main/java/com/teaching/backend/controller/Know/KnowPathVO.java
  7. 24
      src/main/java/com/teaching/backend/controller/Know/RelsNodesVO.java
  8. 19
      src/main/java/com/teaching/backend/controller/Knowtmp/KnowtmpController.java
  9. 24
      src/main/java/com/teaching/backend/controller/cms/CmsEssayController.java
  10. 2
      src/main/java/com/teaching/backend/controller/courses/CoursesController.java
  11. 4
      src/main/java/com/teaching/backend/controller/favour/SeKnowFavourController.java
  12. 4
      src/main/java/com/teaching/backend/controller/favour/SeResourceFavourController.java
  13. 2
      src/main/java/com/teaching/backend/controller/message/MessagesController.java
  14. 2
      src/main/java/com/teaching/backend/controller/records/ResourceLearningRecordController.java
  15. 48
      src/main/java/com/teaching/backend/controller/resource/ResourceController.java
  16. 78
      src/main/java/com/teaching/backend/controller/resource/ResourceGraphController.java
  17. 43
      src/main/java/com/teaching/backend/controller/resource/ResourceMysqlController.java
  18. 4
      src/main/java/com/teaching/backend/controller/thumb/SeKnowThumbController.java
  19. 4
      src/main/java/com/teaching/backend/controller/thumb/SeResourceThumbController.java
  20. 23
      src/main/java/com/teaching/backend/mapper/Knowtemp/KnowstrMapper.java
  21. 22
      src/main/java/com/teaching/backend/mapper/know/KnowRepository.java
  22. 17
      src/main/java/com/teaching/backend/mapper/resource/ResourceMysqlMapper.java
  23. 35
      src/main/java/com/teaching/backend/mapper/resource/ResourcesRepository.java
  24. 1
      src/main/java/com/teaching/backend/model/dto/Knowtmp/KnowtempAdd.java
  25. 3
      src/main/java/com/teaching/backend/model/entity/cms/CmsEssay.java
  26. 30
      src/main/java/com/teaching/backend/model/entity/know/KnowStr.java
  27. 29
      src/main/java/com/teaching/backend/model/entity/know/LinksVO.java
  28. 65
      src/main/java/com/teaching/backend/model/entity/resource/ResourceMysql.java
  29. 3
      src/main/java/com/teaching/backend/model/entity/system/SystemSetting.java
  30. 2
      src/main/java/com/teaching/backend/model/entity/umsAdmin/UmsStudentManage.java
  31. 3
      src/main/java/com/teaching/backend/model/vo/system/SystemSettingVO.java
  32. 85
      src/main/java/com/teaching/backend/service/Know/KnowService.java
  33. 4
      src/main/java/com/teaching/backend/service/cms/ICmsEssayService.java
  34. 46
      src/main/java/com/teaching/backend/service/impl/cms/CmsEssayServiceImpl.java
  35. 1053
      src/main/java/com/teaching/backend/service/impl/know/knowServiceImpl.java
  36. 22
      src/main/java/com/teaching/backend/service/impl/knowtmp/KnowtmpServiceImpl.java
  37. 7
      src/main/java/com/teaching/backend/service/impl/message/MessagesServiceImpl.java
  38. 2
      src/main/java/com/teaching/backend/service/impl/records/RecordKnowledgeFinishServiceImpl.java
  39. 2
      src/main/java/com/teaching/backend/service/impl/records/RecordResourceFinishServiceImpl.java
  40. 5
      src/main/java/com/teaching/backend/service/impl/records/ResourceLearningRecordServiceImpl.java
  41. 146
      src/main/java/com/teaching/backend/service/impl/resource/ResourceGraphServiceImpl.java
  42. 34
      src/main/java/com/teaching/backend/service/impl/resource/ResourceMysqlServiceImpl.java
  43. 84
      src/main/java/com/teaching/backend/service/impl/resource/ResourceServiceImpl.java
  44. 5
      src/main/java/com/teaching/backend/service/knowtmp/KnowtmpService.java
  45. 2
      src/main/java/com/teaching/backend/service/records/IResourceLearningRecordService.java
  46. 19
      src/main/java/com/teaching/backend/service/resource/IResourceMysqlService.java
  47. 39
      src/main/java/com/teaching/backend/service/resource/ResourceGraphService.java
  48. 23
      src/main/java/com/teaching/backend/service/resource/ResourceService.java
  49. 0
      src/main/resources/mapper/IResourceMysqlService.xml
  50. 6
      src/main/resources/mapper/SystemSettingsMapper.xml
  51. 151
      src/test/java/com/teaching/TeachingBackendApplicationTests.java

File diff suppressed because it is too large Load Diff

@ -239,10 +239,10 @@ INSERT INTO `objectives_type` VALUES (2, '知识目标');
INSERT INTO `objectives_type` VALUES (3, '素质目标'); INSERT INTO `objectives_type` VALUES (3, '素质目标');
-- ---------------------------- -- ----------------------------
-- Table structure for resource -- Table structure for resourceMysql
-- ---------------------------- -- ----------------------------
DROP TABLE IF EXISTS `resource`; DROP TABLE IF EXISTS `resourceMysql`;
CREATE TABLE `resource` ( CREATE TABLE `resourceMysql` (
`id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '主键', `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '主键',
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '资源名称', `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '资源名称',
`type` int(11) NULL DEFAULT NULL COMMENT '资源类型', `type` int(11) NULL DEFAULT NULL COMMENT '资源类型',
@ -253,7 +253,7 @@ CREATE TABLE `resource` (
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC; ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;
-- ---------------------------- -- ----------------------------
-- Records of resource -- Records of resourceMysql
-- ---------------------------- -- ----------------------------
-- ---------------------------- -- ----------------------------

@ -33,6 +33,7 @@ public enum ErrorCode {
CONTENT_EXISTS(41000, "内容存在"), CONTENT_EXISTS(41000, "内容存在"),
STUDENT_ROLE_CANT_MULTIPLESEND(41001, "学生用户不能群发,只能单发"), STUDENT_ROLE_CANT_MULTIPLESEND(41001, "学生用户不能群发,只能单发"),
LEAST_ONE_USER(41002, "最少选择一个用户"), LEAST_ONE_USER(41002, "最少选择一个用户"),
MOST_ONE_COURSE(41003, "您一次性最多只能在一个课程下发消息!"),
KNOWS_EXISTS(41001, "存在关联的知识点"), KNOWS_EXISTS(41001, "存在关联的知识点"),
ADD_RELATION_FAILED(41002, "添加关系失败"), ADD_RELATION_FAILED(41002, "添加关系失败"),

@ -7,7 +7,7 @@
//import com.teaching.backend.model.entity.resource.CourseResources; //import com.teaching.backend.model.entity.resource.CourseResources;
//import org.springframework.web.bind.annotation.*; //import org.springframework.web.bind.annotation.*;
// //
//import javax.annotation.Resource; //import javax.annotation.ResourceMysql;
//import java.util.List; //import java.util.List;
// //
///** ///**
@ -24,7 +24,7 @@
//public class FavourInformationController{ //public class FavourInformationController{
// //
// //
// @Resource // @ResourceMysql
// CourseResourcesService courseResourcesService; // CourseResourcesService courseResourcesService;
// //
// //

@ -6,183 +6,128 @@ package com.teaching.backend.controller.Know;
* @Description: * @Description:
*/ */
import com.teaching.backend.common.BaseResponse; import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.mapper.know.KnowRepository;
import com.teaching.backend.model.dto.Know.*; import com.teaching.backend.model.dto.Know.*;
import com.teaching.backend.model.entity.know.Know; import com.teaching.backend.model.entity.know.*;
import com.teaching.backend.model.entity.know.KnowChapter; import com.teaching.backend.model.entity.knowtmp.Knowtmp;
import com.teaching.backend.model.entity.know.KnowCourse; import com.teaching.backend.model.vo.knowGraph.KnowVO;
import com.teaching.backend.model.entity.resource.Resources;
import com.teaching.backend.model.vo.knowGraph.KnowVO1;
import com.teaching.backend.service.Know.KnowService; import com.teaching.backend.service.Know.KnowService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
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 java.util.List;
import javax.annotation.Resource;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
@RestController @RestController
@RequestMapping("/api/knowNeo") @RequestMapping("/api/knowNeo")
@Api(tags= "图-知识点管理")
public class KnowController { public class KnowController {
@Autowired @Autowired
private KnowService knowService; private KnowService knowService;
@Autowired
private KnowRepository knowRepository;
@Resource
private Neo4jClient neo4jClient;
//通过courseId 查询所有结点,存储成JSON
@ApiOperation(value = "通过courseId 查询所有结点,存储成JSON")
//返回2层知识点
@GetMapping("/twoLevelKnows")
BaseResponse<BaseKnowReturn> getTwoLevelKnows(@RequestParam Long id){
return knowService.getTwoLevelKnows(id);
}
//返回3层知识点
@GetMapping("/threeLevelKnows")
BaseResponse<BaseKnowReturn> getThreeLevelKnows(@RequestParam Long id){
return knowService.getThreeLevelKnows(id);
}
//返回4层知识点
@GetMapping("/fourLevelKnows")
BaseResponse<BaseKnowReturn> getFourLevelKnows(@RequestParam Long id){
return knowService.getFourLevelKnows(id);
}
//通过courseId 显示图的JSON
@GetMapping("/test")
void test(){
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
@GetMapping("/showGraphJson") @GetMapping("/showGraphJson")
BaseResponse<String> showGraphJson(@RequestParam String courseId){ BaseResponse<String> showGraphJson(@RequestParam String courseId){
return knowService.showGraphJson(courseId); return knowService.showGraphJson(courseId);
} }
//通过courseId 查询 JSON 生成图
// 添加全部知识点 @ApiOperation(value = "通过courseId 查询 JSON 生成图")
@PostMapping("/addAllKnow") @GetMapping("/generateGraph")
BaseResponse<String> addAllKnow(@RequestParam String courseId){ BaseResponse<String> generateGraph(@RequestParam String courseId){
return knowService.addAllKnow(courseId); return knowService.generateGraph(courseId);
} }
// 添加知识点与资源的关系
@PostMapping("/addRelationship/Withresources")
BaseResponse<String> addRelationshipWithresources(@RequestParam Long id,@RequestParam Long resourceId){
return knowService.addRelationshipWithresources(id,resourceId);
}
//===================
// // 添加知识点 //生成知识点学习路径 默认从第一个知识点到第最后个知识点
// @PostMapping("/addKnow") @ApiOperation(value = "生成知识点学习路径")
// BaseResponse<String> addKnow(@RequestBody KnowRequest knowRequest){ @GetMapping("/knowLearnPath")
// return knowService.addKnow(knowRequest); BaseResponse<List<KnowPathVO>> knowLearnPath(@RequestParam String corseId){
// } return knowService.knowLearnPath(corseId);
// 修改知识点
@PostMapping("/updateKnow")
BaseResponse<String> updateKnow(@RequestBody KnowUpdateRequest knowUpdateRequest){
return knowService.updateKnow(knowUpdateRequest);
} }
//生成知识点学习路径 默认从第一个知识点到第最后个知识点
// 删除知识点 @ApiOperation(value = "生成知识点学习路径-图信息")
@GetMapping("/deleteKnow") @GetMapping("/knowLearnPathGraph")
BaseResponse<String> deleteKnow(@RequestParam Long id){ BaseResponse<BaseKnowReturn> knowLearnPathGraph(@RequestParam String corseId){
return knowService.deleteKnow(id); return knowService.knowLearnPathGraph(corseId);
} }
//查询知识点通过id //返回depth层知识点
@GetMapping("/queryKnow") @ApiOperation(value = "返回depth层知识点")
BaseResponse<Know> queryKnow(@RequestParam Long id){ @GetMapping("/getNodeByDepth")
return knowService.queryKnow(id); BaseResponse<BaseKnowReturn> getNodeByDepth(@RequestParam Long id,@RequestParam Long depth){
} return knowService.getNodeByDepth(id,depth);
//======================================
// 添加课程
@PostMapping("/addCourse")
BaseResponse<String> addCourse(@RequestBody KnowCourseCreateRequest knowCourseCreateRequest){
return knowService.addCourse(knowCourseCreateRequest);
} }
// 修改课程 //通过courseId 返回depth层知识点
@PostMapping("/updateCourse") @ApiOperation(value = "通过courseId-返回depth层知识点")
BaseResponse<String> updateCourse(@RequestBody KnowCourseCreateRequest knowCourseCreateRequest){ @GetMapping("/getDepthNodeByCourseId")
return knowService.updateCourse(knowCourseCreateRequest); BaseResponse<BaseKnowReturn> getDepthNodeByCourseId(@RequestParam String courseId,@RequestParam Long depth){
return knowService.getDepthNodeByCourseId(courseId,depth);
} }
// 删除课程 //返回课程下指定关系的知识图谱
@PostMapping("/deleteCourse") @ApiOperation(value = "返回课程下指定关系的知识图谱")
BaseResponse<String> deleteCourse(@RequestParam String courseId){ @PostMapping("/getRelsNodesByCourseId")
return knowService.deleteCourse(courseId); BaseResponse<BaseKnowReturn> getRelsNodesByCourseId(@RequestBody RelsNodesVO relsNodesVO){
String courseId = relsNodesVO.getCourseId();
Integer level = relsNodesVO.getLevel();
List<String> types = relsNodesVO.getTypes();
return knowService.getRelsNodesByCourseId(courseId, level,types);
} }
//查询课程通过courseid //返回知识点的前后知识点
@GetMapping ("/queryCourse") @ApiOperation(value = "返回知识点的前后知识点")
BaseResponse<KnowCourse> queryCourse(@RequestParam String courseId){ @GetMapping("/getFontedAndBackKnows")
return knowService.queryCourse(courseId); BaseResponse<List<KnowVO>> getFontedAndBackKnows(@RequestParam Long id){
return knowService.getFontedAndBackKnows(id);
} }
//=========================
// 添加章节
@PostMapping("/addChapter")
BaseResponse<String> addChapter(@RequestBody KnowChapterCreateRequest knowChapterCreateRequest){
return knowService.addChapter(knowChapterCreateRequest);
}
// 修改章节 //返回知识点下指定关系的知识图谱
@PostMapping("/updateChapter") @ApiOperation(value = "返回知识点下指定关系的知识图谱")
BaseResponse<String> updateChapter(@RequestBody KnowChapterCreateRequest knowChapterCreateRequest){ @GetMapping("/getRelsNodesById")
return knowService.updateChapter(knowChapterCreateRequest); BaseResponse<BaseKnowReturn> getRelsNodesById(@RequestParam Long id,@RequestParam List<String>types){
return knowService.getRelsNodesById(id,types);
} }
// 删除章节 //重置 知识点下 知识图谱
@GetMapping("/deleteChapter") @ApiOperation(value = "重置-知识点下-知识图谱")
BaseResponse<String> deleteChapter(@RequestParam Long chapterId){ @GetMapping("/getKnowGraphById")
return knowService.deleteChapter(chapterId); BaseResponse<BaseKnowReturn> getKnowGraphById(@RequestParam Long id){
return knowService.getKnowGraphById(id);
} }
//查询章节通过chapterId
@PostMapping("/queryChapter")
BaseResponse<KnowChapter> queryChapter(@RequestParam Long chapterId){
return knowService.queryChapter(chapterId);
}
//=====================
//通过courseId 删除所有节点
@ApiOperation(value = "通过courseId 删除所有节点")
@GetMapping("/deleteAllByCourseId")
BaseResponse<String> deleteAllByCourseId(@RequestParam String courseId){
return knowService.deleteAllByCourseId(courseId);
}
//获取课程下的所有知识点 //获取课程下的所有知识点
@ApiOperation(value = "获取课程下的所有知识点")
@GetMapping("/getAllKnowByCourseId") @GetMapping("/getAllKnowByCourseId")
BaseResponse<BaseKnowReturn> getAllKnowByCourseId(@RequestParam String id){ BaseResponse<BaseKnowReturn> getAllKnowByCourseId(@RequestParam String id){
return knowService.getAllKnowByCourseId(id); return knowService.getAllKnowByCourseId(id);
} }
//批量修改节点关系
//获取二级知识图谱 @ApiOperation(value = "批量修改节点关系")
@GetMapping("/getsecondKnowsById") @PostMapping("/updateLinks")
BaseResponse<BaseKnowReturn> getsecondKnowsById(@RequestParam Long id){ BaseResponse<String> updateLinks(@RequestBody List<LinksVO> linksList){
return knowService.getsecondKnowsById(id); return knowService.updateLinks(linksList);
} }
} }

@ -0,0 +1,21 @@
package com.teaching.backend.controller.Know;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @Author:youhang
* @Date:2024-08-29-11:23
* @Description:
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class KnowPathVO {
private List<String>nodeList;
private Double weight;
}

@ -0,0 +1,24 @@
package com.teaching.backend.controller.Know;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
* @Author:youhang
* @Date:2024-09-02-9:47
* @Description:
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class RelsNodesVO {
@NonNull
private String courseId;
private Integer level;
private List<String> types;
}

@ -6,6 +6,9 @@ import com.teaching.backend.model.dto.Knowtmp.KnowtempAdd;
import com.teaching.backend.model.dto.Knowtmp.KnowtempUpdate; import com.teaching.backend.model.dto.Knowtmp.KnowtempUpdate;
import com.teaching.backend.model.entity.knowtmp.Knowtmp; import com.teaching.backend.model.entity.knowtmp.Knowtmp;
import com.teaching.backend.service.knowtmp.KnowtmpService; import com.teaching.backend.service.knowtmp.KnowtmpService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -18,21 +21,25 @@ import java.util.List;
*/ */
@RestController @RestController
@RequestMapping("/knowtmp") @RequestMapping("/knowtmp")
@Api(tags="Mysql-知识点管理")
public class KnowtmpController { public class KnowtmpController {
@Autowired @Autowired
private KnowtmpService knowtmpService; private KnowtmpService knowtmpService;
//返回课程下所有知识点 //返回课程下所有知识点
@ApiOperation(value = "返回课程下所有知识点")
@GetMapping("/getAllKnows") @GetMapping("/getAllKnows")
BaseResponse<Long> getAllKnows(@RequestParam String courseId){ BaseResponse<Long> getAllKnows(@RequestParam String courseId){
return knowtmpService.getAllKnows(courseId); return knowtmpService.getAllKnows(courseId);
} }
// 添加知识点 // 添加知识点
@ApiOperation(value = "添加知识点")
@PostMapping("/addKnow") @PostMapping("/addKnow")
BaseResponse<String> add(@RequestBody KnowtempAdd knowtempAdd){ BaseResponse<String> add(@RequestBody KnowtempAdd knowtempAdd){
return knowtmpService.add(knowtempAdd); return knowtmpService.add(knowtempAdd);
@ -40,26 +47,30 @@ public class KnowtmpController {
//修改知识点 //修改知识点
@ApiOperation(value = "修改知识点")
@PostMapping("/updateKnow") @PostMapping("/updateKnow")
BaseResponse<String> update(@RequestBody KnowtempUpdate knowtempUpdate){ BaseResponse<String> update(@RequestBody KnowtempUpdate knowtempUpdate){
return knowtmpService.update(knowtempUpdate); return knowtmpService.update(knowtempUpdate);
} }
//删除知识点 //删除知识点
@ApiOperation(value = "删除知识点")
@GetMapping("/deleteKnow") @GetMapping("/deleteKnow")
BaseResponse<String> delete(Long id){ BaseResponse<String> delete(Long id){
return knowtmpService.delete(id); return knowtmpService.delete(id);
} }
//查询通过chapterId List //查询通过chapterId List
@ApiOperation(value = "查询通过chapterId List")
@GetMapping("/query") @GetMapping("/query")
BaseResponse<Knowtmp> query(Long id){ BaseResponse<Knowtmp> query(Long id){
return knowtmpService.query(id); return knowtmpService.query(id);
} }
//查询通过chapterId List //查询通过chapterId List
@ApiOperation(value = "查询通过chapterId List")
@GetMapping("/queryKnow") @GetMapping("/queryKnow")
List<Knowtmp> queryByChapterId(Long chapterId){ BaseResponse<List<Knowtmp>> queryByChapterId(Long chapterId){
return knowtmpService.queryByChapterId(chapterId); return knowtmpService.queryByChapterId(chapterId);
} }
} }

@ -33,7 +33,7 @@ public class CmsEssayController {
* @return * @return
*/ */
@PostMapping("/add") @PostMapping("/add")
public BaseResponse<String> addEssay(CmsEssay cmsEssay){ public BaseResponse<String> addEssay(@RequestBody CmsEssay cmsEssay){
return cmsEssayService.addEssay(cmsEssay); return cmsEssayService.addEssay(cmsEssay);
} }
@ -59,7 +59,7 @@ public class CmsEssayController {
} }
/** /**
* 查询文章 * 根据栏目id查询文章
* @param category_id * @param category_id
* @return * @return
*/ */
@ -68,6 +68,16 @@ public class CmsEssayController {
return cmsEssayService.queryEssay(category_id); return cmsEssayService.queryEssay(category_id);
} }
/**
* 根据文章id查询文章
* @param essay_id
* @return
*/
@GetMapping("/queryessaybyid")
public BaseResponse<CmsEssay> queryEssayById(Integer essay_id){
return cmsEssayService.queryEssayById(essay_id);
}
/** /**
* 取消发布 * 取消发布
* @param cmsEssay * @param cmsEssay
@ -77,4 +87,14 @@ public class CmsEssayController {
public BaseResponse<String> editStatus(@RequestBody CmsEssay cmsEssay){ public BaseResponse<String> editStatus(@RequestBody CmsEssay cmsEssay){
return cmsEssayService.editStatus(cmsEssay); return cmsEssayService.editStatus(cmsEssay);
} }
/**
* 浏览量
* @param id
* @return
*/
@PutMapping("/views/{id}")
public BaseResponse<String> views(@PathVariable Integer id){
return cmsEssayService.views(id);
}
} }

@ -140,7 +140,7 @@ public class CoursesController {
} }
@ApiOperation("根据用户id,查询与用户有关的课程列表,并在课程列表显示所有用户信息") @ApiOperation("根据用户id,查询与用户有关的课程列表,并在课程列表显示所有用户信息")
// @ValidateParams({"userId"}) @ValidateParams({"userId"})
@GetMapping("/page/courseusers") @GetMapping("/page/courseusers")
public BaseResponse<List<CourseUserInfVO>> getUserInfByCourse(@RequestParam Long userId){ public BaseResponse<List<CourseUserInfVO>> getUserInfByCourse(@RequestParam Long userId){
List<CourseUserInfVO> courseUsersInfList = coursesService.getUserInfByCourse(userId); List<CourseUserInfVO> courseUsersInfList = coursesService.getUserInfByCourse(userId);

@ -12,7 +12,7 @@
//import org.springframework.web.bind.annotation.RequestMapping; //import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController; //import org.springframework.web.bind.annotation.RestController;
// //
//import javax.annotation.Resource; //import javax.annotation.ResourceMysql;
// //
///** ///**
// * @Author:youhang // * @Author:youhang
@ -24,7 +24,7 @@
//@Slf4j //@Slf4j
//public class SeKnowFavourController { //public class SeKnowFavourController {
// //
// @Resource // @ResourceMysql
// private SeKnowFavourService seKnowFavourService; // private SeKnowFavourService seKnowFavourService;
// //
// //

@ -16,7 +16,7 @@
//import org.springframework.web.bind.annotation.RequestMapping; //import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController; //import org.springframework.web.bind.annotation.RestController;
// //
//import javax.annotation.Resource; //import javax.annotation.ResourceMysql;
// //
///** ///**
// * @Author:youhang // * @Author:youhang
@ -28,7 +28,7 @@
//@Slf4j //@Slf4j
//public class SeResourceFavourController { //public class SeResourceFavourController {
// //
// @Resource // @ResourceMysql
// private SeResourceFavourService seResourceFavourService; // private SeResourceFavourService seResourceFavourService;
// //
// //

@ -37,7 +37,7 @@ public class MessagesController {
private IMessagesService messagesService; private IMessagesService messagesService;
@ApiOperation("发送消息") @ApiOperation("发送消息")
@ValidateParams({"senderId","title","content","receiverId"}) // 需要校验的参数 @ValidateParams({"senderId","title","content","receiverId","courseId"}) // 需要校验的参数
@PostMapping("/addmessage") @PostMapping("/addmessage")
public BaseResponse<String> sendMessage(@RequestBody SysMessageDTO sysMessageDTO){ public BaseResponse<String> sendMessage(@RequestBody SysMessageDTO sysMessageDTO){
String data = messagesService.sendMessageToUserInbox(sysMessageDTO); String data = messagesService.sendMessageToUserInbox(sysMessageDTO);

@ -37,7 +37,7 @@ public class ResourceLearningRecordController {
// @ValidateParams({"userId","type","coursesId"}) // @ValidateParams({"userId","type","coursesId"})
@PostMapping("/saverecords") @PostMapping("/saverecords")
public BaseResponse<String> saveResourceRecords(@RequestBody ResourceLearningRecord resourceLearningRecord) { public BaseResponse<String> saveResourceRecords(@RequestBody ResourceLearningRecord resourceLearningRecord) {
return resourceLearningRecordService.saveCoursesRecords(resourceLearningRecord); return resourceLearningRecordService.saveResourceRecords(resourceLearningRecord);
} }
/** /**

@ -8,21 +8,21 @@ package com.teaching.backend.controller.resource;
import com.teaching.backend.common.BaseResponse; import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.model.dto.resource.ResourceUploadDto; import com.teaching.backend.model.entity.resource.ResourceMysql;
import com.teaching.backend.model.entity.resource.Resources; import com.teaching.backend.model.entity.resource.Resources;
import com.teaching.backend.service.resource.ResourceService; import com.teaching.backend.service.resource.ResourceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.InputStreamResource; import org.springframework.core.io.InputStreamResource;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.util.List;
import java.util.Set;
@RestController @RestController
@RequestMapping("/api/resource") @RequestMapping("/api/resource")
@Api(tags= "资源管理")
public class ResourceController { public class ResourceController {
@Autowired @Autowired
@ -32,6 +32,7 @@ public class ResourceController {
//添加知识点 //添加知识点
@PostMapping("/upload") @PostMapping("/upload")
@ResponseBody @ResponseBody
@ApiOperation(value = "添加资源")
public BaseResponse<Resources> uploadFile(@RequestPart("file") MultipartFile file) { public BaseResponse<Resources> uploadFile(@RequestPart("file") MultipartFile file) {
return resourceService.upload(file); return resourceService.upload(file);
} }
@ -39,51 +40,16 @@ public class ResourceController {
//删除资源 //删除资源
@GetMapping ("delete") @GetMapping ("delete")
@ResponseBody @ResponseBody
@ApiOperation(value = "删除资源")
public BaseResponse<String> deleteResource(@RequestParam("filename") String filename) { public BaseResponse<String> deleteResource(@RequestParam("filename") String filename) {
return resourceService.delete(filename); return resourceService.delete(filename);
} }
@GetMapping("/read") @GetMapping("/read")
@ApiOperation(value = "查询资源")
public ResponseEntity<InputStreamResource> readFile(@RequestParam String filename) { public ResponseEntity<InputStreamResource> readFile(@RequestParam String filename) {
return resourceService.readFile(filename); return resourceService.readFile(filename);
} }
@GetMapping("/addRelationship/BetweenCourseAndResources")
public BaseResponse<String> addResourcesAndKnowByCourseId(@RequestParam String courseId, @RequestParam List<Long> resourcesIds){
return resourceService.addResourcesAndKnowByCourseId(courseId,resourcesIds);
}
@GetMapping("/addRelationship/BetweenChapterAndResources")
public BaseResponse<String> addResourcesAndKnowByChapterId(@RequestParam Long chapterId,@RequestParam List<Long> resourcesIds){
return resourceService.addResourcesAndKnowByChapterId(chapterId,resourcesIds);
}
@GetMapping("/addRelationship/BetweenKnowAndResources")
public BaseResponse<String> addResourcesAndKnowById(@RequestParam Long id, @RequestParam List<Long> resourcesIds){
return resourceService.addResourcesAndKnowById(id,resourcesIds);
}
//查询课程下资源
@GetMapping("/queryByCourseId")
BaseResponse<Set<Resources>> queryResourcesByCourseId(@RequestParam String courseId){
return resourceService.queryResourcesByCourseId(courseId);
}
//查询章节下资源
@GetMapping("/queryByChapterId")
BaseResponse<Set<Resources>> queryResourcesByChapterId(@RequestParam Long chapterId){
return resourceService.queryResourcesByChapterId(chapterId);
}
//查询二级节点下资源
@GetMapping("/queryBesidesKnow")
BaseResponse<Set<Resources>> queryBesidesKnowToResources(@RequestParam Long KnowId){
return resourceService.queryBesidesKnowToResources(KnowId);
}
//查询知识点下资源
@GetMapping("/queryResourcesByKnowId")
BaseResponse<Set<Resources>> queryResourcesByKnowId(@RequestParam Long KnowId){
return resourceService.queryResourcesByKnowId(KnowId);
}
} }

@ -0,0 +1,78 @@
package com.teaching.backend.controller.resource;
/**
* @Author:youhang
* @Date:2024-06-09-9:55
* @Description:
*/
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.model.entity.resource.Resources;
import com.teaching.backend.service.resource.ResourceGraphService;
import com.teaching.backend.service.resource.ResourceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
import java.util.Set;
@RestController
@RequestMapping("/api/resource/graph")
@Api(tags= "资源与图管理")
public class ResourceGraphController {
@Autowired
private ResourceGraphService resourceGraphService;
@GetMapping("/addRelationship/BetweenKnowAndResources")
@ApiOperation(value = "添加知识点资源关系")
public BaseResponse<String> addResourcesByIdAndResourcesId(@RequestParam Long id,@RequestParam Long resourcesId){
return resourceGraphService.addResourcesByIdAndResourcesId(id,resourcesId);
}
@GetMapping("/deleteRelationship/BetweenKnowAndResources")
@ApiOperation(value = "删除知识点资源关系")
public BaseResponse<String> deleteResourcesAndKnowById(@RequestParam Long id, @RequestParam Long resourcesId){
return resourceGraphService.deleteResourcesAndKnowById(id,resourcesId);
}
//查询课程下资源
@GetMapping("/queryByCourseId")
@ApiOperation(value = "查询课程下资源")
BaseResponse<Set<Resources>> queryResourcesByCourseId(@RequestParam String courseId){
return resourceGraphService.queryResourcesByCourseId(courseId);
}
//查询章节下资源
@GetMapping("/queryByChapterId")
@ApiOperation(value = "查询章节下资源")
BaseResponse<Set<Resources>> queryResourcesByChapterId(@RequestParam Long chapterId){
return resourceGraphService.queryResourcesByChapterId(chapterId);
}
//查询二级节点下资源
@ApiOperation(value = "查询二级节点下资源")
@GetMapping("/queryBesidesKnow")
BaseResponse<Set<Resources>> queryBesidesKnowToResources(@RequestParam Long knowId){
return resourceGraphService.queryBesidesKnowToResources(knowId);
}
//查询知识点下资源
@GetMapping("/queryResourcesByKnowId")
@ApiOperation(value = "查询知识点下资源")
BaseResponse<Set<Resources>> queryResourcesByKnowId(@RequestParam Long knowId){
return resourceGraphService.queryResourcesByKnowId(knowId);
}
}

@ -0,0 +1,43 @@
package com.teaching.backend.controller.resource;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.common.ResultUtils;
import com.teaching.backend.model.entity.resource.ResourceMysql;
import com.teaching.backend.service.impl.resource.ResourceMysqlServiceImpl;
import com.teaching.backend.service.impl.resource.ResourceServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
/**
* <p>
* 前端控制器
* </p>
*
* @author author
* @since 2024-09-02
*/
@RestController
@RequestMapping("/resourcemysql")
@Api(tags= "数据库资源管理")
public class ResourceMysqlController {
private ResourceMysqlServiceImpl resourceMysqlService;
private ResourceServiceImpl resourceService;
//添加资源
@PostMapping("/add")
@ApiOperation(value = "添加资源")
public BaseResponse<String> addFile(@RequestPart("file") MultipartFile file, ResourceMysql resourceMysql) {
System.out.println("资源:"+ resourceMysql);
System.out.println(file);
String url = resourceService.upload(file).getData().getUrl();
System.out.println(url);
//return ResultUtils.success("添加xx");
return resourceMysqlService.resourceUpload(file, resourceMysql);
}
}

@ -12,7 +12,7 @@
//import org.springframework.web.bind.annotation.RequestMapping; //import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController; //import org.springframework.web.bind.annotation.RestController;
// //
//import javax.annotation.Resource; //import javax.annotation.ResourceMysql;
// //
///** ///**
// * @Author:youhang // * @Author:youhang
@ -24,7 +24,7 @@
//@Slf4j //@Slf4j
//public class SeKnowThumbController { //public class SeKnowThumbController {
// //
// @Resource // @ResourceMysql
// private SeKnowThumbService seKnowThumbService; // private SeKnowThumbService seKnowThumbService;
// //
// //

@ -12,7 +12,7 @@
//import org.springframework.web.bind.annotation.RequestMapping; //import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController; //import org.springframework.web.bind.annotation.RestController;
// //
//import javax.annotation.Resource; //import javax.annotation.ResourceMysql;
// //
///** ///**
// * @Author:youhang // * @Author:youhang
@ -24,7 +24,7 @@
//@Slf4j //@Slf4j
//public class SeResourceThumbController { //public class SeResourceThumbController {
// //
// @Resource // @ResourceMysql
// private SeResourceThumbService seResourceThumbService; // private SeResourceThumbService seResourceThumbService;
// //
// //

@ -0,0 +1,23 @@
package com.teaching.backend.mapper.Knowtemp;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.teaching.backend.model.entity.know.KnowStr;
import com.teaching.backend.model.entity.knowtmp.Knowtmp;
import io.lettuce.core.dynamic.annotation.Param;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
*
*/
@Mapper
public interface KnowstrMapper extends BaseMapper<KnowStr> {
}

@ -23,6 +23,14 @@ import java.util.Set;
public interface KnowRepository extends Neo4jRepository<Know, Long> { public interface KnowRepository extends Neo4jRepository<Know, Long> {
@Query("MATCH (n:Know) WHERE n.courseId = $courseId OPTIONAL MATCH p=(n)-[*0..]->() DETACH DELETE p return count(p);")
Long deleteAllByCourseId(String courseId);
@Query("MATCH (n:Know) WHERE ID(n)= ${id} DETACH DELETE n;")
Long deleteNode(Long id);
//=============
@Query("MATCH (p:Know)-[:FatherAndSon]->(n:Know) WHERE p.chapterId = $chapterId RETURN p.id ORDER BY ordernum;") @Query("MATCH (p:Know)-[:FatherAndSon]->(n:Know) WHERE p.chapterId = $chapterId RETURN p.id ORDER BY ordernum;")
@ -42,15 +50,21 @@ public interface KnowRepository extends Neo4jRepository<Know, Long> {
@Query("MATCH ID(p:Know) = $id delete p RETURN count(p);") @Query("MATCH ID(p:Know) = $id delete p RETURN count(p);")
int deleteKnow(Long id); int deleteKnow(Long id);
@Query("MATCH ID(p:Know) = $id RETURN p;") @Query("MATCH (p:Know) where ID(p) = $id RETURN count(p);")
Know queryKnow(Long id); int queryNode(Long id);
@Query("MATCH (p:Know) where ID(p) = $id RETURN p;")
Know queryNodeT(Long id);
@Query("MATCH (p:Know) where p.knowId = $knowId RETURN p;")
Know queryKnowByKnowId(Long knowId);
//============================= //=============================
@Query("CREATE (n:Know {name: $name, courseId: $courseId,info:$info,hour:$hour}) return ID(n) as id") @Query("CREATE (n:Know {courseId: $courseId,name: $name,info:$info,hour:$hour}) return ID(n) as id")
Long addCourse(String courseId, String name, String info, double hour); Long addCourse(String courseId, String name, String info, double hour);
@Query("MATCH (p:Know {courseId:$courseId }) SET p.name = $name set p.info= $info RETURN count(p);") @Query("MATCH (p:Know {courseId:$courseId}) SET p.name = $name set p.info= $info RETURN count(p);")
int updateCourse(String courseId, String name, String info); int updateCourse(String courseId, String name, String info);
@Query("MATCH (p:Know {courseId:$courseId }) delete p RETURN count(p);") @Query("MATCH (p:Know {courseId:$courseId }) delete p RETURN count(p);")

@ -0,0 +1,17 @@
package com.teaching.backend.mapper.resource;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.teaching.backend.model.entity.resource.ResourceMysql;
/**
* <p>
* Mapper 接口
* </p>
*
* @author author
* @since 2024-09-02
*/
public interface ResourceMysqlMapper extends BaseMapper<ResourceMysql> {
}

@ -16,37 +16,56 @@ import java.util.Set;
public interface ResourcesRepository extends Neo4jRepository<Resources, Long> { public interface ResourcesRepository extends Neo4jRepository<Resources, Long> {
//查询资源
@Query("MATCH (b:Resources) WHERE ID(b) = $resourceIds RETURN b")
Resources queryResourcesByIds(Long resourceIds);
//查询资源 - 知识点
@Query("MATCH (p:Know)<-[r:resources]-(c:Resources) WHERE ID(p) = $id AND ID(c) = $resourcesId return count(r)")
int queryExisitRel(Long id, Long resourcesId);
//添加知识点与资源关系
@Query("MATCH (p:Know), (c:Resources) WHERE ID(p) = $id AND ID(c) = $resourcesId CREATE (c)-[r:resources]->(p) return count(r)")
int addResourcesAndKnowById(Long id, Long resourcesId);
//删除资源节点 //删除资源节点
@Query("MATCH(n:Resources) where n.name = $name DETACH DELETE n RETURN COUNT(n) >0;") @Query("MATCH(n:Resources) where n.name = $name DETACH DELETE n RETURN COUNT(n) >0;")
Boolean deleteByobjectName(String name); Boolean deleteByobjectName(String name);
//添加课程与资源关系 //添加课程与资源关系
@Query("MATCH (p:Know), (c:Resources) WHERE p.courseId = $courseId AND ID(c) in $resourcesIds CREATE (p)-[r:resources]->(c) return count(r)") @Query("MATCH (p:Know), (c:Resources) WHERE p.courseId = $courseId AND ID(c) in $resourcesIds CREATE (c)-[r:resources]->(p) return count(r)")
int addResourcesAndKnowByCourseId(String courseId, List<Long> resourcesIds); int addResourcesAndKnowByCourseId(String courseId, List<Long> resourcesIds);
//添加章节与资源关系 //添加章节与资源关系
@Query("MATCH (p:Know), (c:Resources) WHERE p.chapterId = $chapterId AND ID(c) in $resourcesIds CREATE (p)-[r:resources]->(c) return count(r)") @Query("MATCH (p:Know), (c:Resources) WHERE p.chapterId = $chapterId AND ID(c) in $resourcesIds CREATE (c)-[r:resources]->(p) return count(r)")
int addResourcesAndKnowByChapterId(Long chapterId, List<Long> resourcesIds); int addResourcesAndKnowByChapterId(Long chapterId, List<Long> resourcesIds);
//删除知识点与资源关系
@Query("MATCH (c:Resources)-[r:resources]->(p:Know) WHERE ID(c) = $resourcesId AND ID(p) = $id delete r return count(r)")
int deleteResourcesAndKnowById(Long id, Long resourcesId);
//添加知识点与资源关系 //添加知识点与资源关系
@Query("MATCH (p:Know), (c:Resources) WHERE ID(p) = $id AND ID(c) in $resourcesIds CREATE (p)-[r:resources]->(c) return count(r)") @Query("MATCH (p:Know), (c:Resources) WHERE ID(p) = $id AND ID(c) in $resourcesIds CREATE (c)-[r:resources]->(p) return count(r)")
int addResourcesAndKnowById(Long id, List<Long> resourcesIds); int addResourcesAndKnowById(Long id, List<Long> resourcesIds);
//查询课程下资源 //查询课程下资源
@Query("MATCH p = (a:Know)-[rels*]-(b:Resources) WHERE a.courseId = $courseId and ANY(rel IN rels WHERE TYPE(rel) = 'resources') RETURN b") @Query("MATCH (a:Know)-[*]->(c:Know)<-[r:resources]-(b:Resources) WHERE a.courseId = $courseId RETURN b")
Set<Resources> queryResourcesByCourseId(String courseId); Set<Resources> queryResourcesByCourseId(String courseId);
//查询章节下资源 //查询章节下资源
@Query("MATCH p = (a:Know)-[rels*]-(b:Resources) WHERE a.chapterId = $chapterId and ANY(rel IN rels WHERE TYPE(rel) = 'resources') RETURN b") @Query("MATCH (a:Know)-[*]->(c:Know)<-[r:resources]-(b:Resources) WHERE a.chapterId = $chapterId RETURN b")
Set<Resources> queryResourcesByChapterId(Long chapterId); Set<Resources> queryResourcesByChapterId(Long chapterId);
//查询二级节点下资源 //查询二级节点下资源
@Query("MATCh (p:Know)-[*0..1]->(n:Know)-[:resources]->(m:Resources) WHERE ID(p) = $KnowId RETURN m") @Query("MATCh (p:Know)-[*0..1]->(n:Know)<-[:resources]-(m:Resources) WHERE ID(p) = $KnowId RETURN m")
Set<Resources> queryBesidesKnowToResources(Long KnowId); Set<Resources> queryBesidesKnowToResources(Long KnowId);
// //
@Query("MATCH (p)-[r:resources]->(c) WHERE ID(p) = $KnowId RETURN c") @Query("MATCH (p)<-[r:resources]-(c) WHERE ID(p) = $KnowId RETURN c")
Set<Resources> queryResourcesByKnowId(Long KnowId); Set<Resources> queryResourcesByKnowId(Long KnowId);
@ -55,7 +74,7 @@ public interface ResourcesRepository extends Neo4jRepository<Resources, Long> {
// //
// //
// @Query("MATCH(n:Know)-[r:resources]->(nn:Resources) where ID(nn) = $id RETURN nn") // @Query("MATCH(n:Know)-[r:resources]->(nn:Resources) where ID(nn) = $id RETURN nn")
// List<Resource> queryResourceAllId(Long id); // List<ResourceMysql> queryResourceAllId(Long id);
// //
// @Query("MATCH p = (a:Know)-[rels*]-(b:Resources) WHERE ID(a) = $KnowId and ANY(rel IN rels WHERE TYPE(rel) = 'resources') RETURN b") // @Query("MATCH p = (a:Know)-[rels*]-(b:Resources) WHERE ID(a) = $KnowId and ANY(rel IN rels WHERE TYPE(rel) = 'resources') RETURN b")
// Set<Resources> queryCourseKnowToResources(Long KnowId); // Set<Resources> queryCourseKnowToResources(Long KnowId);

@ -21,7 +21,6 @@ public class KnowtempAdd implements Serializable {
private Long chapterid; private Long chapterid;
private Integer ordernum; private Integer ordernum;
private double hour; private double hour;

@ -58,6 +58,9 @@ public class CmsEssay implements Serializable {
@ApiModelProperty(value = "发布文章的用户id") @ApiModelProperty(value = "发布文章的用户id")
private Integer userId; private Integer userId;
// @TableField(exist = false)
private String username;
@ApiModelProperty(value = "文章文件") @ApiModelProperty(value = "文章文件")
private String file; private String file;

@ -0,0 +1,30 @@
package com.teaching.backend.model.entity.know;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import javax.xml.soap.Text;
import java.io.Serializable;
/**
* @Author:youhang
* @Date:2024-08-23-17:29
* @Description:
*/
@Data
@TableName("know_str")
public class KnowStr implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Long id;
private String courseId;
private String coursestr;
private String chapterstr;
private String knowstr;
private String edgestr;
}

@ -0,0 +1,29 @@
package com.teaching.backend.model.entity.know;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.checkerframework.checker.units.qual.A;
import org.springframework.data.neo4j.core.schema.GeneratedValue;
import org.springframework.data.neo4j.core.schema.Id;
import org.springframework.data.neo4j.core.schema.Node;
import org.springframework.data.neo4j.core.schema.Property;
/**
* @Author:youhang
* @Date:2024-07-21-16:32
* @Description:
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class LinksVO {
private Long source;
private Long target;
private String label;
}

@ -0,0 +1,65 @@
package com.teaching.backend.model.entity.resource;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
*
* </p>
*
* @author wenyu
* @since 2024-09-02
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("resource")
@ApiModel(value="Resource对象", description="")
public class ResourceMysql implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键")
@TableId(value = "id", type = IdType.ASSIGN_ID)
private String id;
@ApiModelProperty(value = "课程id")
private String courseId;
@ApiModelProperty(value = "章节id")
private String chapterId;
@ApiModelProperty(value = "知识点id")
private String knowledgeId;
@ApiModelProperty(value = "资源名称")
private String name;
@ApiModelProperty(value = "资源类型")
private Integer type;
@ApiModelProperty(value = "资源路径")
private String path;
@ApiModelProperty(value = "资源状态")
private Integer status;
@ApiModelProperty(value = "标签")
private String tags;
@ApiModelProperty(value = "简介")
private String description;
@ApiModelProperty(value = "封面")
private String img;
}

@ -39,6 +39,9 @@ public class SystemSetting implements Serializable {
//备案号 //备案号
private String recordNumber; private String recordNumber;
//备案信息
private String recordInformation;
//QQ //QQ
private String qqNumber; private String qqNumber;

@ -45,7 +45,7 @@ public class UmsStudentManage implements Serializable {
private LocalDateTime createTime; private LocalDateTime createTime;
//账号状态 //账号状态
private Integer status; private String status;
//姓名 //姓名
private String name; private String name;

@ -37,6 +37,9 @@ public class SystemSettingVO implements Serializable {
//备案号 //备案号
private String recordNumber; private String recordNumber;
//备案信息
private String recordInformation;
//QQ //QQ
private String qqNumber; private String qqNumber;

@ -1,14 +1,16 @@
package com.teaching.backend.service.Know; package com.teaching.backend.service.Know;
import com.teaching.backend.common.BaseResponse; import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.controller.Know.KnowPathVO;
import com.teaching.backend.model.dto.Know.*; import com.teaching.backend.model.dto.Know.*;
import com.teaching.backend.model.entity.know.Know; import com.teaching.backend.model.entity.know.*;
import com.teaching.backend.model.entity.know.KnowChapter; import com.teaching.backend.model.entity.knowtmp.Knowtmp;
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 com.teaching.backend.model.vo.knowGraph.KnowVO;
import com.teaching.backend.model.vo.knowGraph.KnowVO1; import com.teaching.backend.model.vo.knowGraph.KnowVO1;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
import java.util.Set; import java.util.Set;
/** /**
@ -17,78 +19,35 @@ import java.util.Set;
* @Description: * @Description:
*/ */
public interface KnowService { public interface KnowService {
public BaseResponse<BaseKnowReturn> getDepthNodeByCourseId(String CourseId,Long depth);
public BaseResponse<BaseKnowReturn> getNodeByDepth(long id,Long depth);
BaseResponse<BaseKnowReturn> getTwoLevelKnows(Long id); BaseResponse<List<KnowPathVO>> knowLearnPath(String corseId);
BaseResponse<BaseKnowReturn> getThreeLevelKnows(Long id); BaseResponse<BaseKnowReturn>knowLearnPathGraph(String corseId);
BaseResponse<BaseKnowReturn> getFourLevelKnows(Long id);
//通过courseId 显示图的JSON BaseResponse<String> updateLinks(List<LinksVO> linksList);
BaseResponse<String> showGraphJson(String courseId); BaseResponse<String> deleteAllByCourseId(String courseId1);
BaseResponse<String> generateGraph(String courseId1);
//通过courseId 添加所有节点
BaseResponse<String> addAllKnow(String courseId);
BaseResponse<String> addRelationshipWithresources(Long id, Long resourceId);
//=====================
// // 添加知识点
// BaseResponse<String> addKnow(KnowRequest knowRequest);
// 修改知识点
BaseResponse<String> updateKnow(KnowUpdateRequest knowUpdateRequest);
// 删除知识点
BaseResponse<String> deleteKnow(Long id);
//查询知识点通过id
BaseResponse<Know> queryKnow(Long id);
//======================================
// 添加课程
BaseResponse<String> addCourse(KnowCourseCreateRequest knowCourseCreateRequest);
// 修改课程 //通过courseId 显示图的JSON
BaseResponse<String> updateCourse(KnowCourseCreateRequest knowCourseCreateRequest); BaseResponse<String> showGraphJson(String courseId);
// 删除课程
BaseResponse<String> deleteCourse(String courseId);
//查询课程通过courseid
BaseResponse<KnowCourse> queryCourse(String courseId);
//=========================
// 添加章节
BaseResponse<String> addChapter(KnowChapterCreateRequest knowChapterCreateRequest);
// 修改章节
BaseResponse<String> updateChapter(KnowChapterCreateRequest knowChapterCreateRequest);
// 删除章节
BaseResponse<String> deleteChapter(Long chapterId);
//查询章节通过chapterId
BaseResponse<KnowChapter> queryChapter(Long chapterId);
//=====================
//获取课程下的所有知识点 //获取课程下的所有知识点
BaseResponse<BaseKnowReturn> getAllKnowByCourseId(String id); BaseResponse<BaseKnowReturn> getAllKnowByCourseId(String id);
//获取课程下的所有知识点
BaseResponse<BaseKnowReturn> getsecondKnowsById(Long id);
//返回课程下指定关系的知识图谱
BaseResponse<BaseKnowReturn> getRelsNodesByCourseId(String courseId, Integer level,List<String>types);
//获取课程下的所有资源
BaseResponse<Set<KnowVO1>> getAllResourcesByCourseId(String id);
//返回课程下指定关系的知识图谱
BaseResponse<BaseKnowReturn> getRelsNodesById(Long id,List<String>types);
//返回课程下指定关系的知识图谱
BaseResponse<BaseKnowReturn> getKnowGraphById(Long id);
//查询
BaseResponse<List<KnowVO>> getFontedAndBackKnows(Long id);
} }

@ -26,4 +26,8 @@ public interface ICmsEssayService extends IService<CmsEssay> {
BaseResponse<List<?>> queryEssay(Integer category_id); BaseResponse<List<?>> queryEssay(Integer category_id);
BaseResponse<String> editStatus(CmsEssay cmsEssay); BaseResponse<String> editStatus(CmsEssay cmsEssay);
BaseResponse<CmsEssay> queryEssayById(Integer essayId);
BaseResponse<String> views(Integer id);
} }

@ -6,9 +6,12 @@ import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.common.ResultUtils; import com.teaching.backend.common.ResultUtils;
import com.teaching.backend.mapper.cms.CmsEssayMapper; import com.teaching.backend.mapper.cms.CmsEssayMapper;
import com.teaching.backend.model.entity.cms.CmsEssay; import com.teaching.backend.model.entity.cms.CmsEssay;
import com.teaching.backend.model.entity.umsAdmin.UmsUser;
import com.teaching.backend.service.cms.ICmsEssayService; import com.teaching.backend.service.cms.ICmsEssayService;
import com.teaching.backend.service.impl.umsAdmin.UmsUserServiceImpl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.List; import java.util.List;
@ -23,21 +26,53 @@ import java.util.List;
@Service @Service
public class CmsEssayServiceImpl extends ServiceImpl<CmsEssayMapper, CmsEssay> implements ICmsEssayService { public class CmsEssayServiceImpl extends ServiceImpl<CmsEssayMapper, CmsEssay> implements ICmsEssayService {
@Resource
private UmsUserServiceImpl userService;
@Override @Override
public BaseResponse<String> addEssay(CmsEssay cmsEssay) { public BaseResponse<String> addEssay(CmsEssay cmsEssay) {
//设置文章发布时间
cmsEssay.setPublishTime(LocalDate.now()); cmsEssay.setPublishTime(LocalDate.now());
//设置发布人姓名
String nickName = userService.getById(cmsEssay.getUserId()).getNickName();
cmsEssay.setUsername(nickName);
//将浏览次数设置为0
cmsEssay.setReadingNumber(0);
//如果数据库里没有文章,文章id设为2
Long count = query().count();
if (count == 0){
cmsEssay.setId(2);
}
save(cmsEssay); save(cmsEssay);
return ResultUtils.success("添加成功"); return ResultUtils.success("添加成功");
} }
@Override @Override
public BaseResponse<String> deleteEssay(List<Integer> ids) { public BaseResponse<String> deleteEssay(List<Integer> ids) {
//如果要删除的文章中包含id为1的文章(就是包含关于我们)就删除失败
if (ids.contains(1)){
return ResultUtils.success("删除失败,不能删除关于我们!");
}
removeByIds(ids); removeByIds(ids);
return ResultUtils.success("删除成功"); return ResultUtils.success("删除成功");
} }
@Override @Override
public BaseResponse<String> editEssay(CmsEssay cmsEssay) { public BaseResponse<String> editEssay(CmsEssay cmsEssay) {
//设置发布人姓名
String nickName = userService.getById(cmsEssay.getUserId()).getNickName();
cmsEssay.setUsername(nickName);
//获取要修改的文章id
Integer id = cmsEssay.getId();
//判断文章id是否为1
if (id == 1){
Long count = query().eq("id", id).count();
//如果数据库里没id为的文章就先新增
if (count == 0){
save(cmsEssay);
return ResultUtils.success("添加成功!");
}
}
updateById(cmsEssay); updateById(cmsEssay);
return ResultUtils.success("编辑成功!"); return ResultUtils.success("编辑成功!");
} }
@ -54,4 +89,15 @@ public class CmsEssayServiceImpl extends ServiceImpl<CmsEssayMapper, CmsEssay> i
updateById(cmsEssay); updateById(cmsEssay);
return ResultUtils.success("修改成功"); return ResultUtils.success("修改成功");
} }
@Override
public BaseResponse<CmsEssay> queryEssayById(Integer essayId) {
return ResultUtils.success(getById(essayId));
}
@Override
public BaseResponse<String> views(Integer id) {
boolean update = update().setSql("reading_number = reading_number + 1 where id = " + id).update();
return update ? ResultUtils.success("浏览次数加1") : ResultUtils.success("error!!!");
}
} }

@ -34,6 +34,8 @@ public class KnowtmpServiceImpl implements KnowtmpService {
@Autowired @Autowired
private KnowtmpMapper knowtmpMapper; private KnowtmpMapper knowtmpMapper;
@Override @Override
public BaseResponse<Long> getAllKnows(String courseId) { public BaseResponse<Long> getAllKnows(String courseId) {
// 3 从章节表查出章节节点 并添加到 neo // 3 从章节表查出章节节点 并添加到 neo
@ -61,6 +63,10 @@ public class KnowtmpServiceImpl implements KnowtmpService {
public BaseResponse<String> update(KnowtempUpdate knowtempUpdate) { public BaseResponse<String> update(KnowtempUpdate knowtempUpdate) {
Knowtmp knowtmp = new Knowtmp(); Knowtmp knowtmp = new Knowtmp();
BeanUtils.copyProperties(knowtempUpdate,knowtmp); BeanUtils.copyProperties(knowtempUpdate,knowtmp);
Knowtmp knowtmpOld = knowtmpMapper.selectById(knowtmp.getId());
if(knowtmpOld == null){
return ResultUtils.error(ErrorCode.OPERATION_ERROR,"数据不存在");
}
int f = knowtmpMapper.updateById(knowtmp); int f = knowtmpMapper.updateById(knowtmp);
if(f > 0){ if(f > 0){
return ResultUtils.success("修改成功"); return ResultUtils.success("修改成功");
@ -71,7 +77,11 @@ public class KnowtmpServiceImpl implements KnowtmpService {
@Override @Override
public BaseResponse<String> delete(Long id) { public BaseResponse<String> delete(Long id) {
// todo 查询 id
Knowtmp knowtmpOld = knowtmpMapper.selectById(id);
if(knowtmpOld == null){
return ResultUtils.error(ErrorCode.OPERATION_ERROR,"数据不存在");
}
int f = knowtmpMapper.deleteById(id); int f = knowtmpMapper.deleteById(id);
if(f > 0){ if(f > 0){
return ResultUtils.success("删除成功"); return ResultUtils.success("删除成功");
@ -83,13 +93,19 @@ public class KnowtmpServiceImpl implements KnowtmpService {
@Override @Override
public BaseResponse<Knowtmp> query(Long id) { public BaseResponse<Knowtmp> query(Long id) {
Knowtmp knowtmp = knowtmpMapper.selectById(id); Knowtmp knowtmp = knowtmpMapper.selectById(id);
if(knowtmp == null){
return ResultUtils.error(ErrorCode.OPERATION_ERROR,"数据不存在");
}
return ResultUtils.success(knowtmp); return ResultUtils.success(knowtmp);
} }
@Override @Override
public List<Knowtmp> queryByChapterId(Long chapterId) { public BaseResponse<List<Knowtmp>> queryByChapterId(Long chapterId) {
List<Knowtmp> knowtmps = knowtmpMapper.queryIdByChapterId(chapterId); List<Knowtmp> knowtmps = knowtmpMapper.queryIdByChapterId(chapterId);
return knowtmps; if(knowtmps == null){
return ResultUtils.error(ErrorCode.OPERATION_ERROR,"数据不存在");
}
return ResultUtils.success(knowtmps);
} }
@Override @Override

@ -59,6 +59,13 @@ public class MessagesServiceImpl extends ServiceImpl<MessagesMapper, SysMessages
throw new BusinessException(ErrorCode.LEAST_ONE_USER); throw new BusinessException(ErrorCode.LEAST_ONE_USER);
} }
List<String> courseIds = Arrays.stream(sysMessageDTO.getCourseId().split(","))
.map(String::valueOf)
.collect(Collectors.toList());
if (courseIds.size()>1){
throw new BusinessException(ErrorCode.MOST_ONE_COURSE);
}
// 4.判断是什么用户,只有教师可以群发,学生只能单发 // 4.判断是什么用户,只有教师可以群发,学生只能单发
String roleId = umsUserMapper.selectOne(new LambdaQueryWrapper<>(UmsUser.class) String roleId = umsUserMapper.selectOne(new LambdaQueryWrapper<>(UmsUser.class)
.eq(UmsUser::getId, sysMessageDTO.getSenderId())).getRoleId(); .eq(UmsUser::getId, sysMessageDTO.getSenderId())).getRoleId();

@ -53,11 +53,13 @@ public class RecordKnowledgeFinishServiceImpl extends ServiceImpl<RecordKnowledg
@Override @Override
public void editFinish(ResourceLearningRecord resourceLearningRecord) { public void editFinish(ResourceLearningRecord resourceLearningRecord) {
System.out.println(resourceLearningRecord);
//设置完成状态 //设置完成状态
RecordKnowledgeFinish one = query() RecordKnowledgeFinish one = query()
.eq("course_id", resourceLearningRecord.getCoursesId()) .eq("course_id", resourceLearningRecord.getCoursesId())
.eq("knowledge_id", resourceLearningRecord.getKnowledgeId()) .eq("knowledge_id", resourceLearningRecord.getKnowledgeId())
.eq("user_id", resourceLearningRecord.getUserId()).one(); .eq("user_id", resourceLearningRecord.getUserId()).one();
System.out.println(one);
one.setFinish(1); one.setFinish(1);
updateById(one); updateById(one);
} }

@ -36,7 +36,7 @@ public class RecordResourceFinishServiceImpl extends ServiceImpl<RecordResourceF
recordResourceFinish.setKnowledgeId(resourceLearningRecord.getKnowledgeId()); recordResourceFinish.setKnowledgeId(resourceLearningRecord.getKnowledgeId());
recordResourceFinish.setResourceId(resourceLearningRecord.getResourceId()); recordResourceFinish.setResourceId(resourceLearningRecord.getResourceId());
recordResourceFinish.setFinish(resourceLearningRecord.getFinish()); recordResourceFinish.setFinish(resourceLearningRecord.getFinish());
System.out.println(recordResourceFinish); System.out.println("资源完成:"+recordResourceFinish);
save(recordResourceFinish); save(recordResourceFinish);
} }

@ -40,7 +40,7 @@ public class ResourceLearningRecordServiceImpl extends ServiceImpl<ResourceLearn
private RecordResourceFinishServiceImpl recordResourceFinishService; private RecordResourceFinishServiceImpl recordResourceFinishService;
@Override @Override
public BaseResponse<String> saveCoursesRecords(ResourceLearningRecord resourceLearningRecord) { public BaseResponse<String> saveResourceRecords(ResourceLearningRecord resourceLearningRecord) {
//课程id //课程id
String courseId = resourceLearningRecord.getCoursesId(); String courseId = resourceLearningRecord.getCoursesId();
String knowledgeId = resourceLearningRecord.getKnowledgeId(); String knowledgeId = resourceLearningRecord.getKnowledgeId();
@ -67,7 +67,7 @@ public class ResourceLearningRecordServiceImpl extends ServiceImpl<ResourceLearn
.eq("course_id",courseId) .eq("course_id",courseId)
.eq("knowledge_id",knowledgeId) .eq("knowledge_id",knowledgeId)
.eq("resource_id",resourceId).update(); .eq("resource_id",resourceId).update();
// System.out.println("用户:"+userId+"第一次学这门课"); System.out.println("用户:"+userId+"第一次学这门课");
//添加完成状态 //添加完成状态
recordResourceFinishService.addFinish(resourceLearningRecord); recordResourceFinishService.addFinish(resourceLearningRecord);
}else { }else {
@ -103,7 +103,6 @@ public class ResourceLearningRecordServiceImpl extends ServiceImpl<ResourceLearn
save(resourceLearningRecord); save(resourceLearningRecord);
return ResultUtils.success("添加成功"); return ResultUtils.success("添加成功");
} }
@Override @Override
public BaseResponse<Page> getPage(int pagenum, int pagesize, String userId, String knowledgeId, String courseId) { public BaseResponse<Page> getPage(int pagenum, int pagesize, String userId, String knowledgeId, String courseId) {
//格式化时间 //格式化时间

@ -0,0 +1,146 @@
package com.teaching.backend.service.impl.resource;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.common.ResultUtils;
import com.teaching.backend.mapper.know.KnowRepository;
import com.teaching.backend.mapper.resource.ResourcesRepository;
import com.teaching.backend.model.dto.resource.ResourceUploadDto;
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 com.teaching.backend.service.resource.ResourceGraphService;
import com.teaching.backend.service.resource.ResourceService;
import com.teaching.backend.utils.MinioUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.InputStreamResource;
import org.springframework.data.neo4j.core.Neo4jClient;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.util.List;
import java.util.Set;
/**
* @Author:youhang
* @Date:2024-07-26-13:58
* @Description:
*/
@Service
public class ResourceGraphServiceImpl implements ResourceGraphService {
@Autowired
private ResourcesRepository resourcesRepository;
@Autowired
private KnowRepository knowRepository;
@Override
public BaseResponse<String> addResourcesByIdAndResourcesId(Long id,Long resourcesId) {
// 查询知识点是否存在 ,资源是否存在
int f = knowRepository.queryNode(id);
if(f <= 0){
return ResultUtils.error(ErrorCode.PARAMS_ERROR,"知识点不存在");
}
Resources resources = resourcesRepository.queryResourcesByIds(resourcesId);
if(resources == null){
return ResultUtils.error(ErrorCode.PARAMS_ERROR,"资源不存在");
}
//查询关系是否存在
int g = resourcesRepository.queryExisitRel(id,resourcesId);
if(g >0){
return ResultUtils.error(ErrorCode.PARAMS_ERROR,"关系已经存在");
}
//添加关系 addResourcesAndKnowById
f = resourcesRepository.addResourcesAndKnowById(id,resourcesId);
if(f<= 0){
return ResultUtils.error(ErrorCode.PARAMS_ERROR,"创建关系失败");
}
return ResultUtils.success("添加关系成功");
}
@Override
public BaseResponse<String> deleteResourcesAndKnowById(Long id, Long resourcesId) {
// 查询知识点是否存在 ,资源是否存在
int f = knowRepository.queryNode(id);
if(f <= 0){
return ResultUtils.error(ErrorCode.PARAMS_ERROR,"知识点不存在");
}
Resources resources = resourcesRepository.queryResourcesByIds(resourcesId);
if(resources == null){
return ResultUtils.error(ErrorCode.PARAMS_ERROR,"资源不存在");
}
//查询关系是否存在
int g = resourcesRepository.queryExisitRel(id,resourcesId);
if(g < 0){
return ResultUtils.error(ErrorCode.PARAMS_ERROR,"关系未存在");
}
//删除关系
f = resourcesRepository.deleteResourcesAndKnowById(id,resourcesId);
if(f<= 0){
return ResultUtils.error(ErrorCode.PARAMS_ERROR,"删除关系失败");
}
return ResultUtils.success("删除关系成功");
}
@Override
//查询课程下资源
public BaseResponse<Set<Resources>> queryResourcesByCourseId(String courseId){
// 判空,查询
KnowCourse knowCourse = knowRepository.queryCourse(courseId);
if(knowCourse == null){
return ResultUtils.error(ErrorCode.NOT_FOUND_ERROR,"课程不存在");
}
Set<Resources> resourcesSet = resourcesRepository.queryResourcesByCourseId(courseId);
return ResultUtils.success(resourcesSet);
}
@Override
//查询章节下资源
public BaseResponse<Set<Resources>> queryResourcesByChapterId(Long chapterId){
// 判空,查询
KnowChapter knowChapter = knowRepository.queryChapter(chapterId);
if(knowChapter == null){
return ResultUtils.error(ErrorCode.NOT_FOUND_ERROR,"章节不存在");
}
Set<Resources>resourcesSet ;
resourcesSet = resourcesRepository.queryResourcesByChapterId(chapterId);
return ResultUtils.success(resourcesSet);
}
@Override
//查询二级节点下资源
public BaseResponse<Set<Resources>> queryBesidesKnowToResources(Long knowId){
// 判空,查询
int i = knowRepository.queryNode(knowId);
if(i <= 0){
return ResultUtils.error(ErrorCode.NOT_FOUND_ERROR,"知识点不存在");
}
Set<Resources> resourcesSet = resourcesRepository.queryBesidesKnowToResources(knowId);
return ResultUtils.success(resourcesSet);
}
@Override
public BaseResponse<Set<Resources>> queryResourcesByKnowId(Long knowId) {
// 判空,查询
int i = knowRepository.queryNode(knowId);
if(i <= 0){
return ResultUtils.error(ErrorCode.NOT_FOUND_ERROR,"知识点不存在");
}
Set<Resources> resourcesSet = resourcesRepository.queryResourcesByKnowId(knowId);
return ResultUtils.success(resourcesSet);
}
}

@ -0,0 +1,34 @@
package com.teaching.backend.service.impl.resource;
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.resource.ResourceMysqlMapper;
import com.teaching.backend.model.entity.resource.ResourceMysql;
import com.teaching.backend.service.resource.IResourceMysqlService;
import org.apache.ibatis.annotations.Results;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
/**
* <p>
* 服务实现类
* </p>
*
* @author author
* @since 2024-09-02
*/
@Service
public class ResourceMysqlServiceImpl extends ServiceImpl<ResourceMysqlMapper, ResourceMysql> implements IResourceMysqlService {
private ResourceServiceImpl resourceService;
@Override
public BaseResponse<String> resourceUpload(MultipartFile file, ResourceMysql resourceMysql) {
System.out.println(1);
System.out.println(file);
String url = resourceService.upload(file).getData().getUrl();
resourceMysql.setPath(url);
save(resourceMysql);
return ResultUtils.success("添加成功");
}
}

@ -1,39 +1,28 @@
package com.teaching.backend.service.impl.resource; package com.teaching.backend.service.impl.resource;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.json.JSONUtil;
import com.teaching.backend.common.BaseResponse; import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.common.ErrorCode; import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.common.ResultUtils; import com.teaching.backend.common.ResultUtils;
import com.teaching.backend.constant.ViewContentTypeEnum;
import com.teaching.backend.mapper.know.KnowRepository;
import com.teaching.backend.mapper.resource.ResourcesRepository; import com.teaching.backend.mapper.resource.ResourcesRepository;
import com.teaching.backend.model.dto.resource.BucketPolicyConfigDto;
import com.teaching.backend.model.dto.resource.ResourceUploadDto; import com.teaching.backend.model.dto.resource.ResourceUploadDto;
import com.teaching.backend.model.entity.resource.ResourceMysql;
import com.teaching.backend.model.entity.resource.Resources; import com.teaching.backend.model.entity.resource.Resources;
import com.teaching.backend.service.resource.ResourceService; import com.teaching.backend.service.resource.ResourceService;
import com.teaching.backend.utils.MinioUtils; import com.teaching.backend.utils.MinioUtils;
import io.minio.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.InputStreamResource; import org.springframework.core.io.InputStreamResource;
import org.springframework.data.neo4j.core.Neo4jClient; import org.springframework.data.neo4j.core.Neo4jClient;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/** /**
@ -47,6 +36,10 @@ public class ResourceServiceImpl implements ResourceService {
@Autowired @Autowired
private ResourcesRepository resourcesRepository; private ResourcesRepository resourcesRepository;
@Autowired
private KnowRepository knowRepository;
private static final Logger LOGGER = LoggerFactory.getLogger(ResourceService.class); private static final Logger LOGGER = LoggerFactory.getLogger(ResourceService.class);
@Autowired @Autowired
@ -108,69 +101,4 @@ public class ResourceServiceImpl implements ResourceService {
public ResponseEntity<InputStreamResource> readFile(String filename) { public ResponseEntity<InputStreamResource> readFile(String filename) {
return minioUtils.readFile(filename); return minioUtils.readFile(filename);
} }
@Override
public BaseResponse<String> addResourcesAndKnowByCourseId(String courseId, List<Long> resourcesIds){
// todo 查询课程是否存在 ,资源是否存在
int count = resourcesRepository.addResourcesAndKnowByCourseId(courseId,resourcesIds);
if(count == resourcesIds.size()){
return ResultUtils.success("添加关系成功");
}else{
return ResultUtils.error(ErrorCode.OPERATION_ERROR,"添加失败");
}
}
@Override
public BaseResponse<String> addResourcesAndKnowByChapterId(Long chapterId, List<Long> resourcesIds){
// todo 查询章节是否存在 ,资源是否存在
int count = resourcesRepository.addResourcesAndKnowByChapterId(chapterId,resourcesIds);
if(count == resourcesIds.size()){
return ResultUtils.success("添加关系成功");
}else{
return ResultUtils.error(ErrorCode.OPERATION_ERROR,"添加失败");
}
}
@Override
public BaseResponse<String> addResourcesAndKnowById(Long id, List<Long> resourcesIds){
// todo 查询知识点是否存在 ,资源是否存在
int count = resourcesRepository.addResourcesAndKnowById(id,resourcesIds);
if(count == resourcesIds.size()){
return ResultUtils.success("添加关系成功");
}else{
return ResultUtils.error(ErrorCode.OPERATION_ERROR,"添加失败");
}
}
@Override
//查询课程下资源
public BaseResponse<Set<Resources>> queryResourcesByCourseId(String courseId){
// todo 判空,查询
Set<Resources>resourcesSet;
resourcesSet = resourcesRepository.queryResourcesByCourseId(courseId);
return ResultUtils.success(resourcesSet);
}
@Override
//查询章节下资源
public BaseResponse<Set<Resources>> queryResourcesByChapterId(Long chapterId){
// todo 判空,查询
Set<Resources>resourcesSet ;
resourcesSet = resourcesRepository.queryResourcesByChapterId(chapterId);
return ResultUtils.success(resourcesSet);
}
@Override
//查询二级节点下资源
public BaseResponse<Set<Resources>> queryBesidesKnowToResources(Long KnowId){
// todo 判空,查询
Set<Resources>resourcesSet ;
resourcesSet = resourcesRepository.queryBesidesKnowToResources(KnowId);
return ResultUtils.success(resourcesSet);
}
@Override
public BaseResponse<Set<Resources>> queryResourcesByKnowId(Long KnowId) {
// todo 判空,查询
Set<Resources>resourcesSet ;
resourcesSet = resourcesRepository.queryResourcesByKnowId(KnowId);
return ResultUtils.success(resourcesSet);
}
} }

@ -13,6 +13,9 @@ import java.util.List;
* @Description: * @Description:
*/ */
public interface KnowtmpService { public interface KnowtmpService {
//查询 //查询
BaseResponse<Long> getAllKnows(String courseId); BaseResponse<Long> getAllKnows(String courseId);
@ -30,7 +33,7 @@ public interface KnowtmpService {
BaseResponse<Knowtmp> query(Long id); BaseResponse<Knowtmp> query(Long id);
//查询通过chapterId List //查询通过chapterId List
List<Knowtmp> queryByChapterId(Long chapterId); BaseResponse<List<Knowtmp>> queryByChapterId(Long chapterId);
//查询通过chapterId List //查询通过chapterId List
List<Knowtmp> queryByChapterIdList(List<Long> chapterIdList); List<Knowtmp> queryByChapterIdList(List<Long> chapterIdList);

@ -18,7 +18,7 @@ import java.util.List;
*/ */
public interface IResourceLearningRecordService extends IService<ResourceLearningRecord> { public interface IResourceLearningRecordService extends IService<ResourceLearningRecord> {
BaseResponse<String> saveCoursesRecords(ResourceLearningRecord resourceLearningRecord); BaseResponse<String> saveResourceRecords(ResourceLearningRecord resourceLearningRecord);
BaseResponse<Page> getPage(int pagenum, int pagesize, String userId, String knowledgeId, String courseId); BaseResponse<Page> getPage(int pagenum, int pagesize, String userId, String knowledgeId, String courseId);

@ -0,0 +1,19 @@
package com.teaching.backend.service.resource;
import com.baomidou.mybatisplus.extension.service.IService;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.model.entity.resource.ResourceMysql;
import org.springframework.web.multipart.MultipartFile;
/**
* <p>
* 服务类
* </p>
*
* @author author
* @since 2024-09-02
*/
public interface IResourceMysqlService extends IService<ResourceMysql> {
BaseResponse<String> resourceUpload(MultipartFile file, ResourceMysql resourceMysql);
}

@ -0,0 +1,39 @@
package com.teaching.backend.service.resource;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.model.entity.resource.Resources;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
import java.util.Set;
/**
* @Author:youhang
* @Date:2024-07-26-13:55
* @Description:
*/
public interface ResourceGraphService {
public BaseResponse<String> deleteResourcesAndKnowById(Long id, Long resourcesId);
BaseResponse<String> addResourcesByIdAndResourcesId(Long id, Long resourcesId);
//查询课程下资源
BaseResponse<Set<Resources>> queryResourcesByCourseId(String courseId);
//查询章节下资源
BaseResponse<Set<Resources>> queryResourcesByChapterId(Long chapterId);
//查询二级节点下资源
BaseResponse<Set<Resources>> queryBesidesKnowToResources(Long knowId);
BaseResponse<Set<Resources>> queryResourcesByKnowId(Long knowId);
}

@ -2,16 +2,12 @@ package com.teaching.backend.service.resource;
import com.teaching.backend.common.BaseResponse; import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.model.dto.resource.ResourceUploadDto; import com.teaching.backend.model.entity.resource.ResourceMysql;
import com.teaching.backend.model.entity.resource.Resources; import com.teaching.backend.model.entity.resource.Resources;
import org.springframework.core.io.InputStreamResource; import org.springframework.core.io.InputStreamResource;
import org.springframework.data.neo4j.repository.query.Query;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.util.List;
import java.util.Set;
/** /**
* @Author:youhang * @Author:youhang
* @Date:2024-07-26-13:55 * @Date:2024-07-26-13:55
@ -25,22 +21,5 @@ public interface ResourceService {
BaseResponse<String> delete(String filename) ; BaseResponse<String> delete(String filename) ;
ResponseEntity<InputStreamResource> readFile(String filename); ResponseEntity<InputStreamResource> readFile(String filename);
BaseResponse<String> addResourcesAndKnowByCourseId(String courseId, List<Long> resourcesIds);
BaseResponse<String> addResourcesAndKnowByChapterId(Long chapterId, List<Long> resourcesIds);
BaseResponse<String> addResourcesAndKnowById(Long id, List<Long> resourcesIds);
//查询课程下资源
BaseResponse<Set<Resources>> queryResourcesByCourseId(String courseId);
//查询章节下资源
BaseResponse<Set<Resources>> queryResourcesByChapterId(Long chapterId);
//查询二级节点下资源
BaseResponse<Set<Resources>> queryBesidesKnowToResources(Long KnowId);
BaseResponse<Set<Resources>> queryResourcesByKnowId(Long KnowId);
} }

@ -5,6 +5,9 @@
<update id="updateSystemSettings"> <update id="updateSystemSettings">
update system_settings update system_settings
<set> <set>
<if test="home != null and home != ''">
name = #{home,jdbcType=VARCHAR},
</if>
<if test="name != null and name != ''"> <if test="name != null and name != ''">
name = #{name,jdbcType=VARCHAR}, name = #{name,jdbcType=VARCHAR},
</if> </if>
@ -26,6 +29,9 @@
<if test="recordNumber != null and recordNumber != ''"> <if test="recordNumber != null and recordNumber != ''">
record_number = #{recordNumber,jdbcType=VARCHAR}, record_number = #{recordNumber,jdbcType=VARCHAR},
</if> </if>
<if test="recordInformation != null and recordInformation != ''">
record_information = #{recordInformation,jdbcType=VARCHAR},
</if>
<if test="qqNumber != null and qqNumber != ''"> <if test="qqNumber != null and qqNumber != ''">
qq_number = #{qqNumber,jdbcType=VARCHAR}, qq_number = #{qqNumber,jdbcType=VARCHAR},
</if> </if>

@ -8,156 +8,7 @@ import java.util.*;
@SpringBootTest @SpringBootTest
class TeachingBackendApplicationTests { class TeachingBackendApplicationTests {
// Map<String, List<String>> userLearningRecords = new HashMap<>(); public static void main(String[] args) {
public static void main(String[] args) {
// String[] data = {"1", "2", "3", "7", "4", "1-1", "1-5", "1-4", "1-9", "1-2", "3-1", "3-2","1-3","1-6"};
List<String> linkedList = new ArrayList<>();
linkedList.add("1");
linkedList.add("1-1");
linkedList.add("1-2");
linkedList.add("1-3");
linkedList.add("2");
linkedList.add("2-1");
linkedList.add("2-2");
linkedList.add("2-3");
linkedList.add("3");
linkedList.add("3-1");
linkedList.add("3-2");
linkedList.add("3-3");
linkedList.add("4");
linkedList.add("5");
// String x="1";
// String x1="1011-2456";
// String[] split = x1.split("-");
// System.out.println(split[0]);
// System.out.println(split[1]);
// int i = x.indexOf("-");
// System.out.println(i);
// for (String str : data) {
//
// insertInOrder(linkedList, str);
// }
System.out.println("9999");
System.out.println(linkedList);
// String x="2";
String x1="2-1";
int count=0,j=0;
List<String> list = new ArrayList<>();
String[] split1 = x1.split("-");
System.out.println(String.valueOf(Integer.parseInt(split1[0])+1));
for (int i=0;i<linkedList.size();i++){
if (linkedList.get(i).equals(String.valueOf(Integer.parseInt(split1[0])+1))){
j=i;
}
if (linkedList.get(i)==x1){
count=i;
}else{
list.add(linkedList.get(i));
}
} }
System.out.println(j);
System.out.println(count);
for (int i=count;i<j-1;i++){
String[] split = list.get(i).split("-");
// System.out.println(split[0]);
// System.out.println(split[1]);
String s = String.valueOf(Integer.parseInt(split[1]) - 1);
list.set(i,split[0]+"-"+s);
}
// for (int i=0;i<linkedList.size();i++){
// if (linkedList.get(i)==x){
//
// j=i;
// }else if (linkedList.get(i).contains(x+"-")){
// count++;
// } else{
// list.add(linkedList.get(i));
// }
// }
// for (int i=j;i<list.size();i++){
// if (list.get(i).indexOf("-")==-1){
// list.set(i,String.valueOf(Integer.parseInt(list.get(i))-1));
// }else{
// String[] split = list.get(i).split("-");
// String s = String.valueOf(Integer.parseInt(split[0]) - 1);
// list.set(i,s+"-"+split[1]);
// }
//
// }
System.out.println(list);
//
// String newData = "1";
// insertInOrder(linkedList, newData);
// printList(linkedList);
//
// deleteEntry(linkedList, newData);
// printList(linkedList);
// deleteEntry(linkedList, "1");
// printList(linkedList);
}
// private static void insertInOrder(LinkedList<String> linkedList, String newData) {
// ListIterator<String> iterator = linkedList.listIterator();
//
// while (iterator.hasNext()) {
// String current = iterator.next();
//
// if (newData.compareTo(current) <= 0) {
// iterator.previous(); // 回到插入位置
// iterator.add(newData);
// return;
// }
// }
//
// linkedList.addLast(newData);
// }
// private static void deleteEntry(LinkedList<String> linkedList, String target) {
// ListIterator<String> iterator = linkedList.listIterator();
//
// while (iterator.hasNext()) {
// String current = iterator.next();
//
// if (current.equals(target)) {
// // 获取target的前缀和序号
// int dashIndex = target.indexOf("-");
// if (dashIndex != -1) {
// String prefix = target.substring(0, dashIndex);
// int number = Integer.parseInt(target.substring(dashIndex + 1));
//
// while (iterator.hasNext()) {
// String next = iterator.next();
// if (next.startsWith(prefix + "-")) {
// // 更新数据序号
// int nextNumber = Integer.parseInt(next.substring(dashIndex + 1));
// String newEntry = prefix + "-" + (nextNumber - 1);
// iterator.remove();
// iterator.add(newEntry);
// } else {
// iterator.previous(); // 回退到上一个位置
// break;
// }
// }
// }
// }
// }
// }
//
// private static void printList(List<String> list) {
// for (String str : list) {
// System.out.print(str + " ");
// }
// System.out.println();
// }
} }

Loading…
Cancel
Save