From 372e0c84c992f93b6ee1f2d4c201bd72920006f0 Mon Sep 17 00:00:00 2001 From: youahng <2998465706@qq.com> Date: Sat, 10 Aug 2024 12:49:41 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AB=A0=E8=8A=82=E4=BF=AE=E6=94=B9double=20?= =?UTF-8?q?=E5=AE=8C=E5=96=84=E7=9F=A5=E8=AF=86=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/文档说明.md | 1 + .../controller/Know/KnowController.java | 13 +----------- .../backend/controller/records/Bf.java | 2 +- .../resource/ResourceController.java | 6 +++--- .../backend/mapper/know/KnowRepository.java | 8 ++++---- .../dto/Know/KnowChapterCreateRequest.java | 6 ++++++ .../dto/Know/KnowCourseCreateRequest.java | 3 +++ .../model/dto/Knowtmp/KnowtempAdd.java | 1 + .../model/dto/Knowtmp/KnowtempUpdate.java | 1 + .../backend/model/dto/chapter/ChapterDTO.java | 2 +- .../backend/model/entity/chapter/Chapter.java | 2 +- .../backend/model/entity/know/Know.java | 6 ++++++ .../model/entity/know/KnowChapter.java | 5 +++++ .../backend/model/entity/know/KnowCourse.java | 1 + .../backend/model/entity/knowtmp/Knowtmp.java | 4 ++++ .../backend/service/Know/KnowService.java | 5 ++--- .../impl/chapter/ChapterServiceImpl.java | 8 ++++---- .../impl/courses/CoursesServiceImpl.java | 4 ++-- .../service/impl/know/knowServiceImpl.java | 20 +++++++------------ .../impl/resource/ResourceServiceImpl.java | 12 +++++------ .../service/resource/ResourceService.java | 6 +++--- .../teaching/backend/utils/MinioUtils.java | 2 +- 22 files changed, 64 insertions(+), 54 deletions(-) diff --git a/docs/文档说明.md b/docs/文档说明.md index 0d63d00..876e53d 100644 --- a/docs/文档说明.md +++ b/docs/文档说明.md @@ -33,3 +33,4 @@ http://39.106.16.162:7474/ 用户名 neo4j 密码123456 + diff --git a/src/main/java/com/teaching/backend/controller/Know/KnowController.java b/src/main/java/com/teaching/backend/controller/Know/KnowController.java index 5903b7e..9e3bc6f 100644 --- a/src/main/java/com/teaching/backend/controller/Know/KnowController.java +++ b/src/main/java/com/teaching/backend/controller/Know/KnowController.java @@ -124,20 +124,9 @@ public class KnowController { //获取课程下的所有知识点 @GetMapping("/getAllKnowByCourseId") - BaseKnowReturn getAllKnowByCourseId(@RequestParam String id){ + BaseResponse getAllKnowByCourseId(@RequestParam String id){ return knowService.getAllKnowByCourseId(id); } - //获取课程下的所有资源 - @GetMapping("/getAllResourcesByCourseId") - BaseResponse> getAllResourcesByCourseId(@RequestParam String id){ - return knowService.getAllResourcesByCourseId(id); - } - - //获取知识点下二级的所有资源 - @GetMapping("/getSecondResources") - Set getSecondResources(@RequestParam Long id){ - return knowService.getSecondResources(id); - } } diff --git a/src/main/java/com/teaching/backend/controller/records/Bf.java b/src/main/java/com/teaching/backend/controller/records/Bf.java index f0a8d95..ab83b32 100644 --- a/src/main/java/com/teaching/backend/controller/records/Bf.java +++ b/src/main/java/com/teaching/backend/controller/records/Bf.java @@ -8,7 +8,7 @@ import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletResponse; import java.io.FileInputStream; import java.io.OutputStream; - +import java.util.AbstractCollection; @RestController @RequestMapping("/api/bf") public class Bf { diff --git a/src/main/java/com/teaching/backend/controller/resource/ResourceController.java b/src/main/java/com/teaching/backend/controller/resource/ResourceController.java index 2633406..1dc7cc1 100644 --- a/src/main/java/com/teaching/backend/controller/resource/ResourceController.java +++ b/src/main/java/com/teaching/backend/controller/resource/ResourceController.java @@ -62,19 +62,19 @@ public class ResourceController { //查询课程下资源 @GetMapping("/queryByCourseId") - Set queryResourcesByCourseId(String courseId){ + BaseResponse> queryResourcesByCourseId(@RequestParam String courseId){ return resourceService.queryResourcesByCourseId(courseId); } //查询章节下资源 @GetMapping("/queryByChapterId") - Set queryResourcesByChapterId(Long chapterId){ + BaseResponse> queryResourcesByChapterId(@RequestParam Long chapterId){ return resourceService.queryResourcesByChapterId(chapterId); } //查询二级节点下资源 @GetMapping("/queryBesidesKnow") - Set queryBesidesKnowToResources(Long KnowId){ + BaseResponse> queryBesidesKnowToResources(@RequestParam Long KnowId){ return resourceService.queryBesidesKnowToResources(KnowId); } diff --git a/src/main/java/com/teaching/backend/mapper/know/KnowRepository.java b/src/main/java/com/teaching/backend/mapper/know/KnowRepository.java index b1c5d8d..e58df2f 100644 --- a/src/main/java/com/teaching/backend/mapper/know/KnowRepository.java +++ b/src/main/java/com/teaching/backend/mapper/know/KnowRepository.java @@ -36,8 +36,8 @@ public interface KnowRepository extends Neo4jRepository { //============================= - @Query("CREATE (n:Know {name: $name, courseId: $courseId,info:$info}) return count(n)") - int addCourse(String courseId, String name, String info); + @Query("CREATE (n:Know {name: $name, courseId: $courseId,info:$info,hour:$hour}) return count(n)") + int 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);") int updateCourse(String courseId, String name, String info); @@ -50,8 +50,8 @@ public interface KnowRepository extends Neo4jRepository { //==================== - @Query("CREATE (n:Know {name: $name, chapterId:$chapterId,info:$info}) return count(n)") - int addChapter(Long chapterId, String name, String info); + @Query("CREATE (n:Know {name: $name, chapterId:$chapterId,info:$info,hour:$hour}) return count(n)") + int addChapter(Long chapterId, String name, String info,double hour); @Query("MATCH (p:Know {chapterId:$chapterId }) SET p.name = $name set p.info= $info RETURN count(p);") int updateChapter(Long chapterId, String name, String info); diff --git a/src/main/java/com/teaching/backend/model/dto/Know/KnowChapterCreateRequest.java b/src/main/java/com/teaching/backend/model/dto/Know/KnowChapterCreateRequest.java index 293b44c..d90fc60 100644 --- a/src/main/java/com/teaching/backend/model/dto/Know/KnowChapterCreateRequest.java +++ b/src/main/java/com/teaching/backend/model/dto/Know/KnowChapterCreateRequest.java @@ -23,6 +23,12 @@ public class KnowChapterCreateRequest implements Serializable { private String info; + /** + * 学时 + */ + + private double hour; + } diff --git a/src/main/java/com/teaching/backend/model/dto/Know/KnowCourseCreateRequest.java b/src/main/java/com/teaching/backend/model/dto/Know/KnowCourseCreateRequest.java index 61815f2..61ade3d 100644 --- a/src/main/java/com/teaching/backend/model/dto/Know/KnowCourseCreateRequest.java +++ b/src/main/java/com/teaching/backend/model/dto/Know/KnowCourseCreateRequest.java @@ -23,6 +23,9 @@ public class KnowCourseCreateRequest implements Serializable { private String info; + private double hour; + + diff --git a/src/main/java/com/teaching/backend/model/dto/Knowtmp/KnowtempAdd.java b/src/main/java/com/teaching/backend/model/dto/Knowtmp/KnowtempAdd.java index 3c09119..fc5cbe7 100644 --- a/src/main/java/com/teaching/backend/model/dto/Knowtmp/KnowtempAdd.java +++ b/src/main/java/com/teaching/backend/model/dto/Knowtmp/KnowtempAdd.java @@ -23,6 +23,7 @@ public class KnowtempAdd implements Serializable { private Integer ordernum; + private double hour; } diff --git a/src/main/java/com/teaching/backend/model/dto/Knowtmp/KnowtempUpdate.java b/src/main/java/com/teaching/backend/model/dto/Knowtmp/KnowtempUpdate.java index 2002e75..6dcf4d6 100644 --- a/src/main/java/com/teaching/backend/model/dto/Knowtmp/KnowtempUpdate.java +++ b/src/main/java/com/teaching/backend/model/dto/Knowtmp/KnowtempUpdate.java @@ -24,6 +24,7 @@ public class KnowtempUpdate implements Serializable { private Long chapterid; private Integer ordernum; + private double hour; } diff --git a/src/main/java/com/teaching/backend/model/dto/chapter/ChapterDTO.java b/src/main/java/com/teaching/backend/model/dto/chapter/ChapterDTO.java index de5a912..ab71af7 100644 --- a/src/main/java/com/teaching/backend/model/dto/chapter/ChapterDTO.java +++ b/src/main/java/com/teaching/backend/model/dto/chapter/ChapterDTO.java @@ -62,7 +62,7 @@ public class ChapterDTO implements Serializable { private String courseObjectivesId; @ApiModelProperty(value = "总学时") - private String totalClassHours; + private double totalClassHours; @ApiModelProperty(value = "要求") private String requirement; diff --git a/src/main/java/com/teaching/backend/model/entity/chapter/Chapter.java b/src/main/java/com/teaching/backend/model/entity/chapter/Chapter.java index c7d6e80..5f2e46d 100644 --- a/src/main/java/com/teaching/backend/model/entity/chapter/Chapter.java +++ b/src/main/java/com/teaching/backend/model/entity/chapter/Chapter.java @@ -70,7 +70,7 @@ public class Chapter implements Serializable { private String courseObjectivesId; @ApiModelProperty(value = "总学时") - private String totalClassHours; + private double totalClassHours; @ApiModelProperty(value = "要求") private String requirement; diff --git a/src/main/java/com/teaching/backend/model/entity/know/Know.java b/src/main/java/com/teaching/backend/model/entity/know/Know.java index b570705..5342053 100644 --- a/src/main/java/com/teaching/backend/model/entity/know/Know.java +++ b/src/main/java/com/teaching/backend/model/entity/know/Know.java @@ -31,5 +31,11 @@ public class Know implements Serializable { @Property private String info; + /** + * 学时 + */ + @Property + private double hour; + } diff --git a/src/main/java/com/teaching/backend/model/entity/know/KnowChapter.java b/src/main/java/com/teaching/backend/model/entity/know/KnowChapter.java index b4759c5..5691d8b 100644 --- a/src/main/java/com/teaching/backend/model/entity/know/KnowChapter.java +++ b/src/main/java/com/teaching/backend/model/entity/know/KnowChapter.java @@ -37,6 +37,11 @@ public class KnowChapter implements Serializable { */ private String info; + /** + * 学时 + */ + + private double hour; } diff --git a/src/main/java/com/teaching/backend/model/entity/know/KnowCourse.java b/src/main/java/com/teaching/backend/model/entity/know/KnowCourse.java index 56399af..e856fb5 100644 --- a/src/main/java/com/teaching/backend/model/entity/know/KnowCourse.java +++ b/src/main/java/com/teaching/backend/model/entity/know/KnowCourse.java @@ -35,6 +35,7 @@ public class KnowCourse implements Serializable { * 信息 */ private String info; + private double hour; diff --git a/src/main/java/com/teaching/backend/model/entity/knowtmp/Knowtmp.java b/src/main/java/com/teaching/backend/model/entity/knowtmp/Knowtmp.java index 1668352..978d8e4 100644 --- a/src/main/java/com/teaching/backend/model/entity/knowtmp/Knowtmp.java +++ b/src/main/java/com/teaching/backend/model/entity/knowtmp/Knowtmp.java @@ -3,6 +3,7 @@ package com.teaching.backend.model.entity.knowtmp; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; import java.io.Serializable; @@ -16,6 +17,7 @@ import java.io.Serializable; * @since 2024-05-31 */ @Data +@TableName(value = "knowtmp") public class Knowtmp implements Serializable { @TableField(exist = false) @@ -32,5 +34,7 @@ public class Knowtmp implements Serializable { private Long chapterid; + private double hour; + } diff --git a/src/main/java/com/teaching/backend/service/Know/KnowService.java b/src/main/java/com/teaching/backend/service/Know/KnowService.java index 41c54eb..f50b2be 100644 --- a/src/main/java/com/teaching/backend/service/Know/KnowService.java +++ b/src/main/java/com/teaching/backend/service/Know/KnowService.java @@ -72,13 +72,12 @@ public interface KnowService { //===================== //获取课程下的所有知识点 - BaseKnowReturn getAllKnowByCourseId(String id); + BaseResponse getAllKnowByCourseId(String id); //获取课程下的所有资源 BaseResponse> getAllResourcesByCourseId(String id); - //获取知识点下二级的所有资源 - Set getSecondResources(Long id); + } diff --git a/src/main/java/com/teaching/backend/service/impl/chapter/ChapterServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/chapter/ChapterServiceImpl.java index b763758..109c5ee 100644 --- a/src/main/java/com/teaching/backend/service/impl/chapter/ChapterServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/chapter/ChapterServiceImpl.java @@ -445,17 +445,17 @@ public class ChapterServiceImpl extends ServiceImpl impl List subChapters = chapterMapper.selectByIdAndPid(chapterId, courseId); - BigDecimal totalClassHours = BigDecimal.ZERO; + double totalClassHours = 0.0; for (Chapter subChapter : subChapters) { try { - BigDecimal classHours = new BigDecimal(subChapter.getTotalClassHours()); - totalClassHours = totalClassHours.add(classHours); + double classHours = subChapter.getTotalClassHours(); + totalClassHours = totalClassHours+classHours; } catch (NumberFormatException e) { throw new BusinessException(ErrorCode.OPERATION_ERROR, "无效的总学时数据"); } } - chapter.setTotalClassHours(String.valueOf(totalClassHours)); + chapter.setTotalClassHours(totalClassHours); } else { chapter.setTotalClassHours(chapter.getTotalClassHours()); } diff --git a/src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java index 76f4725..351d0ca 100644 --- a/src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java @@ -411,8 +411,8 @@ public class CoursesServiceImpl extends ServiceImpl impl List list = chapterMapper.selectList(wrapper); int total=0; for (Chapter sum: list){ - String totalclasshours = sum.getTotalClassHours(); - total= total+Integer.parseInt(totalclasshours); + double totalclasshours = sum.getTotalClassHours(); + total= total+(int) totalclasshours; } // System.out.println(size); return total; diff --git a/src/main/java/com/teaching/backend/service/impl/know/knowServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/know/knowServiceImpl.java index 8277c60..c86cbca 100644 --- a/src/main/java/com/teaching/backend/service/impl/know/knowServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/know/knowServiceImpl.java @@ -85,7 +85,7 @@ public class knowServiceImpl implements KnowService { public void addAllKnowTransation(String courseId) throws Exception{ // 2.从课程表查出课程节点 并添加到 neo Courses courses = coursesMapper.selectById(courseId); - int f = knowRepository.addCourse(courseId,courses.getName(),courses.getDescription()); + int f = knowRepository.addCourse(courseId,courses.getName(),courses.getDescription(),courses.getClasshours()); if(f <= 0){ throw new RuntimeException("添加课程失败"); } @@ -93,7 +93,7 @@ public class knowServiceImpl implements KnowService { List chapterList = chapterMapper.selectSectionsByCourseId(courseId); for (int i = 0; i < chapterList.size(); i++) { Chapter chapter = chapterList.get(i); - f =knowRepository.addChapter(chapter.getId(),chapter.getName(),chapter.getContent()); + f =knowRepository.addChapter(chapter.getId(),chapter.getName(),chapter.getContent(),chapter.getTotalClassHours()); if(f <= 0){ throw new RuntimeException("添加章节失败"); } @@ -187,7 +187,7 @@ public class knowServiceImpl implements KnowService { public BaseResponse addCourse(KnowCourseCreateRequest knowCourseCreateRequest) { KnowCourse knowCourse = new KnowCourse(); BeanUtils.copyProperties(knowCourseCreateRequest,knowCourse); - int f = knowRepository.addCourse(knowCourse.getCourseId(),knowCourse.getName(),knowCourse.getInfo()); + int f = knowRepository.addCourse(knowCourse.getCourseId(),knowCourse.getName(),knowCourse.getInfo(),knowCourse.getHour()); if(f >0){ return ResultUtils.success("添加知识点成功"); }else{ @@ -232,7 +232,7 @@ public class knowServiceImpl implements KnowService { public BaseResponse addChapter(KnowChapterCreateRequest knowChapterCreateRequest) { KnowChapter knowChapter = new KnowChapter(); BeanUtils.copyProperties(knowChapterCreateRequest,knowChapter); - int f = knowRepository.addChapter(knowChapter.getChapterId(),knowChapter.getName(),knowChapter.getInfo()); + int f = knowRepository.addChapter(knowChapter.getChapterId(),knowChapter.getName(),knowChapter.getInfo(),knowChapter.getHour()); if(f>0){ return ResultUtils.success("添加章节成功"); }else{ @@ -272,7 +272,7 @@ public class knowServiceImpl implements KnowService { //获取课程下的所有知识点 @Override - public BaseKnowReturn getAllKnowByCourseId(String id) { + public BaseResponse getAllKnowByCourseId(String id) { Collection> all = neo4jClient.query( "match(n:Know)-[r*0..]->(p:Know) where n.courseId = '"+id+"' return n as `n`,r as `r`,p as `p`,length(r) as `d`").fetch().all(); @@ -319,7 +319,7 @@ public class knowServiceImpl implements KnowService { } BaseKnowReturn baseKnowReturn = new BaseKnowReturn(knowList,linksList); - return baseKnowReturn; + return ResultUtils.success(baseKnowReturn); } //获取课程下的所有资源 @@ -343,12 +343,6 @@ public class knowServiceImpl implements KnowService { return ResultUtils.success(knowList); } - //获取知识点下二级的所有资源 - @Override - public Set getSecondResources(Long id) { - SetresourcesSet ; - resourcesSet = knowRepository.queryBesidesKnowToResources(id); - return resourcesSet; - } + } diff --git a/src/main/java/com/teaching/backend/service/impl/resource/ResourceServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/resource/ResourceServiceImpl.java index f59cab9..dbfd340 100644 --- a/src/main/java/com/teaching/backend/service/impl/resource/ResourceServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/resource/ResourceServiceImpl.java @@ -139,28 +139,28 @@ public class ResourceServiceImpl implements ResourceService { } @Override //查询课程下资源 - public Set queryResourcesByCourseId(String courseId){ + public BaseResponse> queryResourcesByCourseId(String courseId){ // todo 判空,查询 SetresourcesSet; resourcesSet = resourcesRepository.queryResourcesByCourseId(courseId); - return resourcesSet; + return ResultUtils.success(resourcesSet); } @Override //查询章节下资源 - public Set queryResourcesByChapterId(Long chapterId){ + public BaseResponse> queryResourcesByChapterId(Long chapterId){ // todo 判空,查询 SetresourcesSet ; resourcesSet = resourcesRepository.queryResourcesByChapterId(chapterId); - return resourcesSet; + return ResultUtils.success(resourcesSet); } @Override //查询二级节点下资源 - public Set queryBesidesKnowToResources(Long KnowId){ + public BaseResponse> queryBesidesKnowToResources(Long KnowId){ // todo 判空,查询 SetresourcesSet ; resourcesSet = resourcesRepository.queryBesidesKnowToResources(KnowId); - return resourcesSet; + return ResultUtils.success(resourcesSet); } diff --git a/src/main/java/com/teaching/backend/service/resource/ResourceService.java b/src/main/java/com/teaching/backend/service/resource/ResourceService.java index c8c5fab..d44a7ba 100644 --- a/src/main/java/com/teaching/backend/service/resource/ResourceService.java +++ b/src/main/java/com/teaching/backend/service/resource/ResourceService.java @@ -32,13 +32,13 @@ public interface ResourceService { BaseResponse addResourcesAndKnowById(Long id, List resourcesIds); //查询课程下资源 - Set queryResourcesByCourseId(String courseId); + BaseResponse> queryResourcesByCourseId(String courseId); //查询章节下资源 - Set queryResourcesByChapterId(Long chapterId); + BaseResponse> queryResourcesByChapterId(Long chapterId); //查询二级节点下资源 - Set queryBesidesKnowToResources(Long KnowId); + BaseResponse> queryBesidesKnowToResources(Long KnowId); } diff --git a/src/main/java/com/teaching/backend/utils/MinioUtils.java b/src/main/java/com/teaching/backend/utils/MinioUtils.java index e422d2a..df7188c 100644 --- a/src/main/java/com/teaching/backend/utils/MinioUtils.java +++ b/src/main/java/com/teaching/backend/utils/MinioUtils.java @@ -109,7 +109,7 @@ public class MinioUtils { .Action("s3:GetObject") .Resource("arn:aws:s3:::"+bucketName+"/*.**").build(); return BucketPolicyConfigDto.builder() - .Version("2012-10-17") + .Version("2024-8-10") .Statement(CollUtil.toList(statement)) .build(); }