diff --git a/docs/文档说明.md b/docs/文档说明.md new file mode 100644 index 0000000..876e53d --- /dev/null +++ b/docs/文档说明.md @@ -0,0 +1,36 @@ +## 文档说明 + +##### 资源接口 + + resourcesController 资源上传 uploadFile / 下载 deleteResource / 预览 readFile + +用minio 作为资源管理 + +minio 网址:http://39.106.16.162:9001/ +用户名:minioadmin +密码:minioadmin + +以日期分类 文件类型 文件名前10个(超出10)+yyyymmddhhmmss + +yml 配置 + +```java +minio: + endpoint: http://39.106.16.162:9090 #MinIO服务所在地址 + bucketName: teaching # 存储桶名称 + accessKey: minioadmin # 访问的key + secretKey: minioadmin # 访问的秘钥 +``` + +minioutils 工具类 + +> 逻辑就是,文件上传之后,存入图数据库,返回节点信息 , 删除文件 也得删除文件在图数据库的节点 + +##### 图数据库 + +http://39.106.16.162:7474/ + +用户名 neo4j + +密码123456 + diff --git a/pom.xml b/pom.xml index 4e9e452..f3f4d71 100644 --- a/pom.xml +++ b/pom.xml @@ -227,8 +227,6 @@ commons-lang 2.6 - - commons-fileupload 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 ee8b95d..9e3bc6f 100644 --- a/src/main/java/com/teaching/backend/controller/Know/KnowController.java +++ b/src/main/java/com/teaching/backend/controller/Know/KnowController.java @@ -28,6 +28,20 @@ public class KnowController { @Autowired private KnowService knowService; + // 添加全部知识点 + @PostMapping("/addAllKnow") + BaseResponse addAllKnow(@RequestParam String courseId){ + return knowService.addAllKnow(courseId); + } + + // 添加知识点与资源的关系 + @PostMapping("/addRelationship/Withresources") + BaseResponse addRelationshipWithresources(@RequestParam Long id,@RequestParam Long resourceId){ + return knowService.addRelationshipWithresources(id,resourceId); + } + + //=================== + // 添加知识点 @PostMapping("/addKnow") BaseResponse addKnow(@RequestBody KnowRequest knowRequest){ @@ -110,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/Knowtmp/KnowtmpController.java b/src/main/java/com/teaching/backend/controller/Knowtmp/KnowtmpController.java index dbb122a..85ab55d 100644 --- a/src/main/java/com/teaching/backend/controller/Knowtmp/KnowtmpController.java +++ b/src/main/java/com/teaching/backend/controller/Knowtmp/KnowtmpController.java @@ -50,7 +50,7 @@ public class KnowtmpController { } //查询通过chapterId List @GetMapping("/queryKnow") - BaseResponse> queryByChapterId(Long chapterId){ + List queryByChapterId(Long chapterId){ return knowtmpService.queryByChapterId(chapterId); } } diff --git a/src/main/java/com/teaching/backend/controller/courses/CoursesController.java b/src/main/java/com/teaching/backend/controller/courses/CoursesController.java index 7e14395..adba450 100644 --- a/src/main/java/com/teaching/backend/controller/courses/CoursesController.java +++ b/src/main/java/com/teaching/backend/controller/courses/CoursesController.java @@ -22,6 +22,7 @@ import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; import java.util.HashMap; import java.util.LinkedHashSet; +import java.util.List; import java.util.Map; /** @@ -132,8 +133,8 @@ public class CoursesController { @ApiOperation("查询学生列表") @PostMapping("/studentList") - public CommonResult> getStudentList(@RequestParam String userId){ - LinkedHashSet umsStudentList = coursesService.queryStudentList(userId); + public CommonResult> getStudentList(@RequestParam String userId){ + List umsStudentList = coursesService.queryStudentList(userId); return CommonResult.success(umsStudentList); } 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/records/CourseLearningRecordController.java b/src/main/java/com/teaching/backend/controller/records/CourseLearningRecordController.java index ed7b1b3..32be4d1 100644 --- a/src/main/java/com/teaching/backend/controller/records/CourseLearningRecordController.java +++ b/src/main/java/com/teaching/backend/controller/records/CourseLearningRecordController.java @@ -70,4 +70,19 @@ public class CourseLearningRecordController { } return CommonResult.success(coursesVOList); } + + /** + * 推荐课程 + * @return + */ + @ApiOperation("推荐课程") + @PostMapping("/recommendCourses") + public CommonResult> recommendCourses(@RequestParam String userId) { + List coursesVOList = courseLearningRecordService.queryrecommendCourses(userId); + if (coursesVOList == null){ + CommonResult.failed("用户或角色错误"); + } + return CommonResult.success(coursesVOList); + } + } diff --git a/src/main/java/com/teaching/backend/controller/records/ResourceLearningRecordController.java b/src/main/java/com/teaching/backend/controller/records/ResourceLearningRecordController.java index 29a3aca..29b19b9 100644 --- a/src/main/java/com/teaching/backend/controller/records/ResourceLearningRecordController.java +++ b/src/main/java/com/teaching/backend/controller/records/ResourceLearningRecordController.java @@ -1,102 +1,103 @@ -//package com.teaching.backend.controller.records; -// -//import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -//import com.teaching.backend.common.BaseResponse; -//import com.teaching.backend.common.ResultUtils; -//import com.teaching.backend.filter.ValidateParams; -//import com.teaching.backend.mapper.records.ResourceLearningRecordMapper; -//import com.teaching.backend.model.entity.records.KnowledgeLearningRecord; -//import com.teaching.backend.model.entity.records.ResourceLearningRecord; -//import com.teaching.backend.service.impl.records.KnowledgeLearningRecordServiceImpl; -//import com.teaching.backend.service.impl.records.ResourceLearningRecordServiceImpl; -//import com.teaching.backend.utils.UploadUtils; -//import io.swagger.annotations.ApiOperation; -//import org.springframework.http.MediaType; -//import org.springframework.web.bind.annotation.*; -//import org.springframework.web.multipart.MultipartFile; -// -//import javax.annotation.Resource; -//import javax.servlet.http.HttpServletRequest; -//import javax.servlet.http.HttpServletResponse; -//import java.io.File; -//import java.io.IOException; -//import java.util.List; -// -//@RestController -//@RequestMapping("/api/resourcelearningrecords") -//public class ResourceLearningRecordController { -// @Resource -// private ResourceLearningRecordServiceImpl resourceLearningRecordService; -// @Resource -// private ResourceLearningRecordMapper resourceLearningRecordMapper; -// -// -// -// @ApiOperation("添加资源学习记录") -//// @ValidateParams({"userId","type","coursesId"}) -// @PostMapping("/saverecords") -// public BaseResponse saveResourceRecords(@RequestBody ResourceLearningRecord resourceLearningRecord) { -// return resourceLearningRecordService.saveCoursesRecords(resourceLearningRecord); -// } -// -// /** -// * 获取当前登录用户的学习资源记录 -// * @param pagenum -// * @param pagesize -// * @return -// */ -// @ApiOperation("根据用户id查询学习记录") -// @ValidateParams({"userId"}) -// @GetMapping("/page") -// public BaseResponse getAll(@RequestParam(value = "pagenum", defaultValue = "1") int pagenum, -// @RequestParam(value = "pagesize", defaultValue = "10") int pagesize, -// @RequestParam String userId, -// @RequestParam String courseId, -// @RequestParam String knowledgeId){ -// return resourceLearningRecordService.getPage(pagenum, pagesize, userId, knowledgeId,courseId); -// -// } -// /** -// * 根据ids删除 -// * @param ids -// * @return -// */ -// @ApiOperation("学习记录删除") -// @DeleteMapping("/delete") -// public BaseResponse deleteRecords(@RequestParam List ids){ -// return resourceLearningRecordService.removeResourceRecord(ids); -// } -// -// /** -// * 统计单个学生学习资源数量 -// * @param userId -// * @return -// */ -// @ApiOperation("统计单个学生学习资源数量") -// @GetMapping("/countresourcenumber") -// public BaseResponse countResourceNumber(@RequestParam String userId) { -// return ResultUtils.success(resourceLearningRecordMapper.selectDistinctResourceIdsByUser(userId).size()); -// } -// -// -// @ApiOperation("上传图片") -// @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) -// public BaseResponse upload(@RequestPart("filedata") MultipartFile filedata) throws IOException { -// //调用ser -// System.out.println(filedata.getResource()); -// System.out.println(UploadUtils.saveFileByDirectory(filedata)); -//// File file = filedata.getResource().getFile(); -//// UploadUtils.Chunk(file); -//// UploadUtils.Merge(file); -// //源文件 -//// File sourseFile = (File) file; -// return ResultUtils.success("hello"); -// }; -// -// @GetMapping("/bf") -// public BaseResponse bf(@RequestParam String path, File file,HttpServletRequest request, HttpServletResponse response){ -// File sourseFile = new File(path); -// return ResultUtils.success(path); -// }; -// -//} +package com.teaching.backend.controller.records; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.teaching.backend.common.BaseResponse; +import com.teaching.backend.common.ResultUtils; +import com.teaching.backend.filter.ValidateParams; +import com.teaching.backend.mapper.records.ResourceLearningRecordMapper; +import com.teaching.backend.model.entity.records.KnowledgeLearningRecord; +import com.teaching.backend.model.entity.records.ResourceLearningRecord; +import com.teaching.backend.service.impl.records.KnowledgeLearningRecordServiceImpl; +import com.teaching.backend.service.impl.records.ResourceLearningRecordServiceImpl; +import com.teaching.backend.utils.UploadUtils; +import io.swagger.annotations.ApiOperation; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.File; +import java.io.IOException; +import java.util.List; + +@RestController +@RequestMapping("/api/resourcelearningrecords") +public class ResourceLearningRecordController { + + @Resource + private ResourceLearningRecordServiceImpl resourceLearningRecordService; + @Resource + private ResourceLearningRecordMapper resourceLearningRecordMapper; + + + + @ApiOperation("添加资源学习记录") +// @ValidateParams({"userId","type","coursesId"}) + @PostMapping("/saverecords") + public BaseResponse saveResourceRecords(@RequestBody ResourceLearningRecord resourceLearningRecord) { + return resourceLearningRecordService.saveCoursesRecords(resourceLearningRecord); + } + + /** + * 获取当前登录用户的学习资源记录 + * @param pagenum + * @param pagesize + * @return + */ + @ApiOperation("根据用户id查询学习记录") + @ValidateParams({"userId"}) + @GetMapping("/page") + public BaseResponse getAll(@RequestParam(value = "pagenum", defaultValue = "1") int pagenum, + @RequestParam(value = "pagesize", defaultValue = "10") int pagesize, + @RequestParam String userId, + @RequestParam String courseId, + @RequestParam String knowledgeId){ + return resourceLearningRecordService.getPage(pagenum, pagesize, userId, knowledgeId,courseId); + + } + /** + * 根据ids删除 + * @param ids + * @return + */ + @ApiOperation("学习记录删除") + @DeleteMapping("/delete") + public BaseResponse deleteRecords(@RequestParam List ids){ + return resourceLearningRecordService.removeResourceRecord(ids); + } + + /** + * 统计单个学生学习资源数量 + * @param userId + * @return + */ + @ApiOperation("统计单个学生学习资源数量") + @GetMapping("/countresourcenumber") + public BaseResponse countResourceNumber(@RequestParam String userId) { + return ResultUtils.success(resourceLearningRecordMapper.selectDistinctResourceIdsByUser(userId).size()); + } + + + @ApiOperation("上传图片") + @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + public BaseResponse upload(@RequestPart("filedata") MultipartFile filedata) throws IOException { + //调用ser + System.out.println(filedata.getResource()); + System.out.println(UploadUtils.saveFileByDirectory(filedata)); +// File file = filedata.getResource().getFile(); +// UploadUtils.Chunk(file); +// UploadUtils.Merge(file); + //源文件 +// File sourseFile = (File) file; + return ResultUtils.success("hello"); + }; + + @GetMapping("/bf") + public BaseResponse bf(@RequestParam String path, File file,HttpServletRequest request, HttpServletResponse response){ + File sourseFile = new File(path); + return ResultUtils.success(path); + }; + +} 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 71b0884..1dc7cc1 100644 --- a/src/main/java/com/teaching/backend/controller/resource/ResourceController.java +++ b/src/main/java/com/teaching/backend/controller/resource/ResourceController.java @@ -32,7 +32,7 @@ public class ResourceController { //添加知识点 @PostMapping("/upload") @ResponseBody - public BaseResponse uploadFile(@RequestPart("file") MultipartFile file) { + public BaseResponse uploadFile(@RequestPart("file") MultipartFile file) { return resourceService.upload(file); } @@ -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/controller/umsAdmin/UmsStudentManageController.java b/src/main/java/com/teaching/backend/controller/umsAdmin/UmsStudentManageController.java new file mode 100644 index 0000000..6dbf21c --- /dev/null +++ b/src/main/java/com/teaching/backend/controller/umsAdmin/UmsStudentManageController.java @@ -0,0 +1,72 @@ +package com.teaching.backend.controller.umsAdmin; + +import com.teaching.backend.common.CommonResult; +import com.teaching.backend.model.dto.umsAdmin.UmsStudentPageQueryDTO; +import com.teaching.backend.model.entity.umsAdmin.UmsStudentManage; +import com.teaching.backend.service.umsAdmin.UmsStudentManageService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import java.util.Map; + +@RestController +@Api(tags = "学生管理") +@RequestMapping("/api/studentManage") +@Slf4j +public class UmsStudentManageController { + + @Autowired + private UmsStudentManageService umsStudentManageService; + + /** + * 学生管理分页查询 + * @param umsStudentPageQueryDTO + * @return + */ + @GetMapping("/page") + @ApiOperation("学生管理分页查询") + public CommonResult> page(UmsStudentPageQueryDTO umsStudentPageQueryDTO){ + Map pageResult = umsStudentManageService.pageQuery(umsStudentPageQueryDTO); + return CommonResult.success(pageResult); + } + + /** + * 启用禁用学生账号 + * @param status + * @param id + * @return + */ + @PostMapping("/status/{status}") + @ApiOperation("启用禁用员工账号") + public CommonResult startOrStop(@PathVariable String status, Long id){ + umsStudentManageService.startOrStop(status,id); + return CommonResult.success("修改成功"); + } + + /** + * 根据id查询学生信息 + * @param id + * @return + */ + @GetMapping("/{id}") + @ApiOperation("根据id查询学生信息") + public CommonResult getById(@PathVariable Long id){ + UmsStudentManage umsStudentManage = umsStudentManageService.getByIdStudentAndUser(id); + return CommonResult.success(umsStudentManage); + } + + /** + * 编辑学生信息 + * @param umsStudentManage + * @return + */ + @PutMapping + @ApiOperation("编辑学生信息") + public CommonResult update(@RequestBody UmsStudentManage umsStudentManage){ + log.info("编辑学生信息: {}",umsStudentManage); + umsStudentManageService.updateStudentAndUser(umsStudentManage); + return CommonResult.success("修改成功"); + } +} diff --git a/src/main/java/com/teaching/backend/controller/umsStudent/UmsStudentController.java b/src/main/java/com/teaching/backend/controller/umsStudent/UmsStudentController.java deleted file mode 100644 index a2db786..0000000 --- a/src/main/java/com/teaching/backend/controller/umsStudent/UmsStudentController.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.teaching.backend.controller.umsStudent; - -import io.swagger.annotations.Api; -import lombok.extern.slf4j.Slf4j; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@Api(tags = "UmsStudentController") -@RequestMapping("/api/student") -@Slf4j -public class UmsStudentController { -} 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 9871a0d..e58df2f 100644 --- a/src/main/java/com/teaching/backend/mapper/know/KnowRepository.java +++ b/src/main/java/com/teaching/backend/mapper/know/KnowRepository.java @@ -14,12 +14,15 @@ import com.teaching.backend.model.entity.resource.Resources; import org.springframework.data.neo4j.repository.Neo4jRepository; import org.springframework.data.neo4j.repository.query.Query; +import java.util.List; import java.util.Set; public interface KnowRepository extends Neo4jRepository { - @Query("CREATE (n:Know {name: $name,info:$info}) return count(n)") - int addKnow(String name,String info); + //====================== + + @Query("CREATE (n:Know {name: $name,info:$info}) return n;") + Know addKnow(String name,String info); @Query("MATCH ID(p:Know) = $id SET p.name = $name set p.info= $info RETURN count(p);") @@ -33,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); @@ -47,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); @@ -63,4 +66,19 @@ public interface KnowRepository extends Neo4jRepository { @Query("MATCH (p:Know)-[:FatherAndSon]->(n:Know)-[:resources]->(m:Resources) WHERE ID(p) = $id RETURN m") Set queryBesidesKnowToResources(Long id); + //建立关系 课程 - 章节 + @Query("MATCH (p:Know {courseId: $courseId}), (c:Know {chapterId: $chapterId}) CREATE (p)-[r:FatherAndSon]->(c) return count(r);") + int addFatherAndSonWithCourse(String courseId,Long chapterId); + + //建立关系 章节与章节 + @Query("MATCH (p:Know {chapterId: $chapterId1}), (c:Know {chapterId: $chapterId2}) CREATE (c)-[r:FatherAndSon]->(p) return count(r);") + int addFatherAndSonWithChapter(Long chapterId1,Long chapterId2); + + //建立关系 章节与知识点 + @Query("MATCH (p:Know), (j:Know) WHERE p.chapterId= $chapterId AND ID(j) = $id CREATE (p)-[r:FatherAndSon]->(j) return count(r);") + int addFatherAndSonWithKnow(Long id,Long chapterId); + + @Query("MATCH (p:Know), (c:Resources) WHERE ID(p) = $id AND ID(c) = $ResourcesId CREATE (p)-[r:resources]->(c) return count(r)") + int addResourceResourcesKnow(Long id, Long ResourcesId); + } diff --git a/src/main/java/com/teaching/backend/mapper/records/ResourceLearningNumberMapper.java b/src/main/java/com/teaching/backend/mapper/records/ResourceLearningNumberMapper.java new file mode 100644 index 0000000..61d1e8b --- /dev/null +++ b/src/main/java/com/teaching/backend/mapper/records/ResourceLearningNumberMapper.java @@ -0,0 +1,17 @@ +package com.teaching.backend.mapper.records; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.teaching.backend.model.entity.records.ResourceLearningNumber; + +/** + *

+ * Mapper 接口 + *

+ * + * @author author + * @since 2024-07-29 + */ +public interface ResourceLearningNumberMapper extends BaseMapper { + +} diff --git a/src/main/java/com/teaching/backend/mapper/resource/ResourcesRepository.java b/src/main/java/com/teaching/backend/mapper/resource/ResourcesRepository.java index 16286ed..94889d6 100644 --- a/src/main/java/com/teaching/backend/mapper/resource/ResourcesRepository.java +++ b/src/main/java/com/teaching/backend/mapper/resource/ResourcesRepository.java @@ -38,7 +38,7 @@ public interface ResourcesRepository extends Neo4jRepository { Set 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 p = (a:Know)-[rels*]-(b:Resources) WHERE a.chapterId = $chapterId and ANY(rel IN rels WHERE TYPE(rel) = 'resources') RETURN b") Set queryResourcesByChapterId(Long chapterId); //查询二级节点下资源 diff --git a/src/main/java/com/teaching/backend/mapper/umsAdmin/UmsStudentManageMapper.java b/src/main/java/com/teaching/backend/mapper/umsAdmin/UmsStudentManageMapper.java new file mode 100644 index 0000000..43a2fe7 --- /dev/null +++ b/src/main/java/com/teaching/backend/mapper/umsAdmin/UmsStudentManageMapper.java @@ -0,0 +1,22 @@ +package com.teaching.backend.mapper.umsAdmin; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.teaching.backend.model.dto.umsAdmin.UmsStudentPageQueryDTO; +import com.teaching.backend.model.entity.umsAdmin.*; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +@Mapper +public interface UmsStudentManageMapper extends BaseMapper { + + UmsStudentManage queryStudent(String userId); + + List pageQueryStudent(UmsStudentPageQuery umsStudentPageQuery); + + int pageQueryStudentCount(UmsStudentPageQueryDTO umsStudentPageQueryDTO); + + UmsStudentManage getByIdStudentAndUser(Long id); + +} diff --git a/src/main/java/com/teaching/backend/mapper/umsAdmin/UmsStudentMapper.java b/src/main/java/com/teaching/backend/mapper/umsAdmin/UmsStudentMapper.java index 438b200..bd3b04a 100644 --- a/src/main/java/com/teaching/backend/mapper/umsAdmin/UmsStudentMapper.java +++ b/src/main/java/com/teaching/backend/mapper/umsAdmin/UmsStudentMapper.java @@ -15,4 +15,5 @@ public interface UmsStudentMapper extends BaseMapper { boolean updateStudentInfo(UmsStudent umsStudent); UmsStudent selectByUserId(Integer userId); + } 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/dto/umsAdmin/UmsStudentPageQueryDTO.java b/src/main/java/com/teaching/backend/model/dto/umsAdmin/UmsStudentPageQueryDTO.java new file mode 100644 index 0000000..f0813bf --- /dev/null +++ b/src/main/java/com/teaching/backend/model/dto/umsAdmin/UmsStudentPageQueryDTO.java @@ -0,0 +1,25 @@ +package com.teaching.backend.model.dto.umsAdmin; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class UmsStudentPageQueryDTO implements Serializable { + + //学生姓名 + private String name; + + //学号 + private String number; + + //页码 + private int page; + + //每页显示记录数 + private int pageSize; + + //学号 + private String userId; + +} 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 07e330a..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 @@ -8,7 +8,7 @@ import org.springframework.data.neo4j.core.schema.Property; import java.io.Serializable; -@Node + @Data public class KnowChapter implements Serializable { @@ -16,27 +16,32 @@ public class KnowChapter implements Serializable { /** * id */ - @Id - @GeneratedValue + private Long id; /** * 章节id */ + private Long chapterId; /** * 知识点名称 */ - @Property + private String name; /** * 信息 */ - @Property + 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 f85d1d2..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 @@ -8,7 +8,6 @@ import org.springframework.data.neo4j.core.schema.Property; import java.io.Serializable; -@Node @Data public class KnowCourse implements Serializable { @@ -16,27 +15,27 @@ public class KnowCourse implements Serializable { /** * id */ - @Id - @GeneratedValue + private Long id; /** * 课程id */ + private String courseId; /** * 知识点名称 */ - @Property + private String name; /** * 信息 */ - @Property 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/model/entity/records/ResourceLearningNumber.java b/src/main/java/com/teaching/backend/model/entity/records/ResourceLearningNumber.java new file mode 100644 index 0000000..57638e2 --- /dev/null +++ b/src/main/java/com/teaching/backend/model/entity/records/ResourceLearningNumber.java @@ -0,0 +1,47 @@ +package com.teaching.backend.model.entity.records; + +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; + +/** + *

+ * + *

+ * + * @author author + * @since 2024-07-29 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("resource_learning_number") +@ApiModel(value="ResourceLearningNumber对象", description="") +public class ResourceLearningNumber implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "资源学习记录id") + @TableId(value = "id", type = IdType.ASSIGN_ID) + private String id; + + @ApiModelProperty(value = "课程id") + private String courseId; + + @ApiModelProperty(value = "知识点id") + private String knowledgeId; + + @ApiModelProperty(value = "资源id") + private String resourceId; + + @ApiModelProperty(value = "学习人数") + private Integer number; + + +} diff --git a/src/main/java/com/teaching/backend/model/entity/umsAdmin/UmsStudentManage.java b/src/main/java/com/teaching/backend/model/entity/umsAdmin/UmsStudentManage.java new file mode 100644 index 0000000..9974bc2 --- /dev/null +++ b/src/main/java/com/teaching/backend/model/entity/umsAdmin/UmsStudentManage.java @@ -0,0 +1,84 @@ +package com.teaching.backend.model.entity.umsAdmin; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.time.LocalDate; +import java.time.LocalDateTime; + +/** + *

+ * + *

+ * + * @author zjh + * @since 2024-06-12 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +public class UmsStudentManage implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + //用户名 + private String username; + + //密码 + private String password; + + //昵称 + private String nickName; + + //头像 + private String icon; + + //注册时间 + private LocalDateTime createTime; + + //账号状态 + private Integer status; + + //姓名 + private String name; + + //性别 + private String sex; + + //民族 + private String nationality; + + //学号 + private String number; + + //生日 + private LocalDateTime birthday; + + //手机号 + private String phone; + + //院系 + private String faculty; + + //专业 + private String major; + + //入学年份 + private LocalDate yearAge; + + //班级 + private String className; + + //user_id + private Integer userId; + + +} diff --git a/src/main/java/com/teaching/backend/model/entity/umsAdmin/UmsStudentPageQuery.java b/src/main/java/com/teaching/backend/model/entity/umsAdmin/UmsStudentPageQuery.java new file mode 100644 index 0000000..cf8707e --- /dev/null +++ b/src/main/java/com/teaching/backend/model/entity/umsAdmin/UmsStudentPageQuery.java @@ -0,0 +1,21 @@ +package com.teaching.backend.model.entity.umsAdmin; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class UmsStudentPageQuery implements Serializable { + + //学生姓名 + private String name; + + //学号 + private String number; + + //每页显示记录数 + private int pageSize; + + //偏移量 + private int offset; +} diff --git a/src/main/java/com/teaching/backend/model/entity/umsAdmin/UmsUser.java b/src/main/java/com/teaching/backend/model/entity/umsAdmin/UmsUser.java index d05dad7..bf16927 100644 --- a/src/main/java/com/teaching/backend/model/entity/umsAdmin/UmsUser.java +++ b/src/main/java/com/teaching/backend/model/entity/umsAdmin/UmsUser.java @@ -3,6 +3,7 @@ package com.teaching.backend.model.entity.umsAdmin; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Builder; import lombok.Data; import java.io.Serializable; @@ -35,7 +36,7 @@ public class UmsUser implements Serializable { private LocalDateTime createTime; //账号状态 - private Integer status; + private String status; //角色id private String roleId; 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 14cdb91..f50b2be 100644 --- a/src/main/java/com/teaching/backend/service/Know/KnowService.java +++ b/src/main/java/com/teaching/backend/service/Know/KnowService.java @@ -7,6 +7,7 @@ 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.model.vo.knowGraph.KnowVO1; +import org.springframework.web.bind.annotation.RequestParam; import java.util.Set; @@ -17,6 +18,15 @@ import java.util.Set; */ public interface KnowService { + //通过courseId 添加所有节点 + BaseResponse addAllKnow(String courseId); + + BaseResponse addRelationshipWithresources(Long id, Long resourceId); + + + + //===================== + // 添加知识点 BaseResponse addKnow(KnowRequest knowRequest); @@ -62,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/courses/ICoursesService.java b/src/main/java/com/teaching/backend/service/courses/ICoursesService.java index dcd643c..9f619a2 100644 --- a/src/main/java/com/teaching/backend/service/courses/ICoursesService.java +++ b/src/main/java/com/teaching/backend/service/courses/ICoursesService.java @@ -6,6 +6,8 @@ import com.teaching.backend.model.dto.courses.CoursesDTO; import com.teaching.backend.model.dto.courses.PageDTO; import com.teaching.backend.model.entity.courses.Courses; import com.teaching.backend.model.entity.umsAdmin.UmsStudent; +import com.teaching.backend.model.entity.umsAdmin.UmsStudentManage; +import com.teaching.backend.model.entity.umsAdmin.UmsUser; import com.teaching.backend.model.query.CourseQuery; import com.teaching.backend.model.vo.courses.CoursesVO; import com.teaching.backend.model.vo.courses.PersonalCenterStudentListVO; @@ -47,5 +49,6 @@ public interface ICoursesService extends IService { Map getPagePageSize2(int page, int pageSize); - LinkedHashSet queryStudentList(String userId); + List queryStudentList(String userId); + LinkedHashSet queryTeacherByStudentList(String userId); } 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..313528a 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 @@ -14,6 +14,7 @@ import com.teaching.backend.mapper.chapter.ChapterMapper; import com.teaching.backend.mapper.courses.*; import com.teaching.backend.mapper.records.CourseLearningRecordMapper; import com.teaching.backend.mapper.records.LearningRecordsMapper; +import com.teaching.backend.mapper.umsAdmin.UmsStudentManageMapper; import com.teaching.backend.mapper.umsAdmin.UmsStudentMapper; import com.teaching.backend.mapper.umsAdmin.UmsTeacherMapper; import com.teaching.backend.mapper.umsAdmin.UmsUserMapper; @@ -24,6 +25,7 @@ import com.teaching.backend.model.entity.courses.*; import com.teaching.backend.model.entity.records.CourseLearningRecord; import com.teaching.backend.model.entity.records.LearningRecords; import com.teaching.backend.model.entity.umsAdmin.UmsStudent; +import com.teaching.backend.model.entity.umsAdmin.UmsStudentManage; import com.teaching.backend.model.entity.umsAdmin.UmsTeacher; import com.teaching.backend.model.entity.umsAdmin.UmsUser; import com.teaching.backend.model.query.CourseQuery; @@ -93,6 +95,8 @@ public class CoursesServiceImpl extends ServiceImpl impl private LearningRecordsMapper learningRecordsMapper; @Autowired CourseLearningRecordMapper courseLearningRecordMapper; + @Autowired + private UmsStudentManageMapper umsStudentManageMapper; @Override @@ -350,15 +354,30 @@ public class CoursesServiceImpl extends ServiceImpl impl } @Override - public LinkedHashSet queryStudentList(String userId) { + public List queryStudentList(String userId) { + LinkedHashSet umsStudentManageList = queryTeacherByStudentList(userId); + List personalCenterStudentListVOList = new ArrayList<>(); + PersonalCenterStudentListVO personalCenterStudentListVO = null; + for (UmsStudentManage umsStudentManage : umsStudentManageList) { + personalCenterStudentListVO = new PersonalCenterStudentListVO(); + personalCenterStudentListVO.setIcon(umsStudentManage.getIcon()); + personalCenterStudentListVO.setName(umsStudentManage.getName()); + personalCenterStudentListVO.setNumber(umsStudentManage.getNumber()); + personalCenterStudentListVOList.add(personalCenterStudentListVO); + } + return personalCenterStudentListVOList; + } + + @Override + public LinkedHashSet queryTeacherByStudentList(String userId) { String roleId = umsUserMapper.getbyIdRoleId(userId); CourseQuery courseQuery = new CourseQuery(); courseQuery.setUserId(userId); + LinkedHashSet umsStudentManageList = new LinkedHashSet<>(); if (roleId.equals("1")){ PageDTO queryCourses = queryCourses(courseQuery); List coursesList = queryCourses.getList(); List courseIds = coursesList.stream().map(CoursesVO::getId).collect(Collectors.toList()); - LinkedHashSet studentNameList = new LinkedHashSet<>(); for (String courseId : courseIds) { List studentUsernames = studentCoursesMapper.selectBatchSomeStudent(courseId); List courseLearningRecordList = new ArrayList<>(); @@ -368,16 +387,11 @@ public class CoursesServiceImpl extends ServiceImpl impl } courseLearningRecordList = courseLearningRecordList.stream().sorted(Comparator.comparing(CourseLearningRecord::getTimes).reversed()).collect(Collectors.toList()); for (CourseLearningRecord courseLearningRecord : courseLearningRecordList) { - UmsStudent umsStudent = umsStudentMapper.selectByUserId(Integer.valueOf(courseLearningRecord.getUserId())); - UmsUser user = umsUserMapper.selectById(courseLearningRecord.getUserId()); - PersonalCenterStudentListVO pcsl = new PersonalCenterStudentListVO(); - pcsl.setName(umsStudent.getName()); - pcsl.setNumber(umsStudent.getNumber()); - pcsl.setIcon(user.getIcon()); - studentNameList.add(pcsl); + UmsStudentManage umsStudentManage = umsStudentManageMapper.queryStudent(courseLearningRecord.getUserId()); + umsStudentManageList.add(umsStudentManage); } } - return studentNameList; + return umsStudentManageList; } throw new BusinessException(400,"只有老师才有此功能"); } @@ -411,8 +425,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 ae58db6..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 @@ -1,27 +1,36 @@ package com.teaching.backend.service.impl.know; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.teaching.backend.common.BaseResponse; import com.teaching.backend.common.ErrorCode; import com.teaching.backend.common.ResultUtils; +import com.teaching.backend.mapper.chapter.ChapterMapper; +import com.teaching.backend.mapper.courses.CoursesMapper; import com.teaching.backend.mapper.know.KnowRepository; import com.teaching.backend.model.dto.Know.*; +import com.teaching.backend.model.entity.chapter.Chapter; +import com.teaching.backend.model.entity.courses.Courses; import com.teaching.backend.model.entity.know.Know; import com.teaching.backend.model.entity.know.KnowChapter; import com.teaching.backend.model.entity.know.KnowCourse; import com.teaching.backend.model.entity.know.Links; +import com.teaching.backend.model.entity.knowtmp.Knowtmp; 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.service.Know.KnowService; +import com.teaching.backend.service.knowtmp.KnowtmpService; import org.neo4j.driver.internal.InternalRelationship; import org.neo4j.driver.types.Node; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.neo4j.core.Neo4jClient; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.*; +import java.util.stream.Collectors; /** * @Author:youhang @@ -34,15 +43,108 @@ public class knowServiceImpl implements KnowService { @Autowired private KnowRepository knowRepository; + + @Autowired + private ChapterMapper chapterMapper; + + @Autowired + private KnowtmpService knowtmpService; + + + + @Autowired + CoursesMapper coursesMapper; + @Resource private Neo4jClient neo4jClient; + + public BaseResponse addRelationshipWithresources(Long id, Long resourceId){ + int f = knowRepository.addResourceResourcesKnow(id,resourceId); + if(f <= 0){ + throw new RuntimeException("添加关系失败"); + } + return ResultUtils.success("添加关系成功"); + } + + + @Override + public BaseResponse addAllKnow(String courseId) { + try { + addAllKnowTransation(courseId) ; + }catch (Exception e){ + e.printStackTrace(); + return ResultUtils.error(ErrorCode.OPERATION_ERROR,e.getMessage()); + } + //6.返回成功信息,关闭事务 + return ResultUtils.success("添加成功"); + } + + @Transactional + // todo 事务没有正确使用 + public void addAllKnowTransation(String courseId) throws Exception{ + // 2.从课程表查出课程节点 并添加到 neo + Courses courses = coursesMapper.selectById(courseId); + int f = knowRepository.addCourse(courseId,courses.getName(),courses.getDescription(),courses.getClasshours()); + if(f <= 0){ + throw new RuntimeException("添加课程失败"); + } + // 3 从章节表查出章节节点 并添加到 neo + 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(),chapter.getTotalClassHours()); + if(f <= 0){ + throw new RuntimeException("添加章节失败"); + } + } + List idList = chapterList.stream() + .map(menu -> menu.getId()) + .collect(Collectors.toList()); + + //获取chapterId 查询知识点 返回知识点集合 + List knowlist = knowtmpService.queryByChapterIdList(idList); + for (int i = 0; i < idList.size(); i++) { + List knowlist1 = knowtmpService.queryByChapterId(idList.get(i)); + for (int j = 0; j < knowlist1.size(); j++) { + Know know = knowRepository.addKnow(knowlist1.get(j).getName(),knowlist1.get(j).getInfo()); + if(know == null){ + throw new RuntimeException("添加知识点失败"); + } + f = knowRepository.addFatherAndSonWithKnow(know.getId(),idList.get(i)); + if(f <= 0){ + throw new RuntimeException("添加知识点-章节失败"); + } + } + } + + for (int i = 0; i < chapterList.size(); i++) { + Chapter chapter = chapterList.get(i); + if(chapter.getPid()== 0){ + f = knowRepository.addFatherAndSonWithCourse(chapter.getCourseId(),chapter.getId()); + if(f <= 0) throw new RuntimeException("添加课程-章节关系失败"); + }else{ + f = knowRepository.addFatherAndSonWithChapter(chapter.getId(),chapter.getPid()); + if(f <= 0) throw new RuntimeException("添加章节-章节关系失败"); + } + + } + +// for (int j = 0; j < knowlist.size(); j++) { +// Knowtmp knowtmp = knowlist.get(j); +// f = knowRepository.addFatherAndSonWithKnow(knowtmp.getId(),knowtmp.getChapterid()); +// if(f <= 0) throw new RuntimeException("添加章节-知识点关系失败"); +// } + + + } + @Override public BaseResponse addKnow(KnowRequest knowRequest) { Know know = new Know(); BeanUtils.copyProperties(knowRequest,know); - int f = knowRepository.addKnow(know.getName(),know.getInfo()); - if(f > 0){ + Know know1 = knowRepository.addKnow(know.getName(),know.getInfo()); + if(know1 != null){ return ResultUtils.success("添加知识点成功"); }else{ return ResultUtils.error(ErrorCode.OPERATION_ERROR,"添加知识点失败"); @@ -85,8 +187,8 @@ 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()); - if(f > 0){ + int f = knowRepository.addCourse(knowCourse.getCourseId(),knowCourse.getName(),knowCourse.getInfo(),knowCourse.getHour()); + if(f >0){ return ResultUtils.success("添加知识点成功"); }else{ return ResultUtils.error(ErrorCode.OPERATION_ERROR,"添加知识点失败"); @@ -130,11 +232,11 @@ 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()); - if(f > 0){ - return ResultUtils.success("添加知识点成功"); + int f = knowRepository.addChapter(knowChapter.getChapterId(),knowChapter.getName(),knowChapter.getInfo(),knowChapter.getHour()); + if(f>0){ + return ResultUtils.success("添加章节成功"); }else{ - return ResultUtils.error(ErrorCode.OPERATION_ERROR,"添加知识点失败"); + return ResultUtils.error(ErrorCode.OPERATION_ERROR,"添加章节失败"); } } @@ -170,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(); @@ -217,7 +319,7 @@ public class knowServiceImpl implements KnowService { } BaseKnowReturn baseKnowReturn = new BaseKnowReturn(knowList,linksList); - return baseKnowReturn; + return ResultUtils.success(baseKnowReturn); } //获取课程下的所有资源 @@ -241,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/knowtmp/KnowtmpServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/knowtmp/KnowtmpServiceImpl.java index 8165dae..ab78ee0 100644 --- a/src/main/java/com/teaching/backend/service/impl/knowtmp/KnowtmpServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/knowtmp/KnowtmpServiceImpl.java @@ -69,11 +69,19 @@ public class KnowtmpServiceImpl implements KnowtmpService { } @Override - public BaseResponse> queryByChapterId(Long chapterId) { + public List queryByChapterId(Long chapterId) { Knowtmp knowtmp = new Knowtmp(); - final QueryWrapper knowtmpQueryWrapper = new QueryWrapper<>(); + QueryWrapper knowtmpQueryWrapper = new QueryWrapper<>(); knowtmpQueryWrapper.eq("chapterId",chapterId); List knowtmps = knowtmpMapper.selectList(knowtmpQueryWrapper); - return ResultUtils.success(knowtmps); + return knowtmps; + } + + @Override + public List queryByChapterIdList(List chapterIdList) { + QueryWrapper knowtmpQueryWrapper = new QueryWrapper<>(); + knowtmpQueryWrapper.in("chapterId",chapterIdList); + List knowtmps = knowtmpMapper.selectList(knowtmpQueryWrapper); + return knowtmps; } } diff --git a/src/main/java/com/teaching/backend/service/impl/records/CourseLearningRecordServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/records/CourseLearningRecordServiceImpl.java index 2ce1a62..4c9eae5 100644 --- a/src/main/java/com/teaching/backend/service/impl/records/CourseLearningRecordServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/records/CourseLearningRecordServiceImpl.java @@ -145,4 +145,21 @@ public class CourseLearningRecordServiceImpl extends ServiceImpl queryrecommendCourses(String userId) { + String roleId = umsUserMapper.getbyIdRoleId(userId); + + if (roleId.equals("1")) { + + return null; + } else if (roleId.equals("2")) { + + return null; + }else { + + return null; + } + } + } diff --git a/src/main/java/com/teaching/backend/service/impl/records/ResourceLearningNumberServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/records/ResourceLearningNumberServiceImpl.java new file mode 100644 index 0000000..d6d4e71 --- /dev/null +++ b/src/main/java/com/teaching/backend/service/impl/records/ResourceLearningNumberServiceImpl.java @@ -0,0 +1,22 @@ +package com.teaching.backend.service.impl.records; + + + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.teaching.backend.mapper.records.ResourceLearningNumberMapper; +import com.teaching.backend.model.entity.records.ResourceLearningNumber; +import com.teaching.backend.service.records.IResourceLearningNumberService; +import org.springframework.stereotype.Service; + +/** + *

+ * 服务实现类 + *

+ * + * @author author + * @since 2024-07-29 + */ +@Service +public class ResourceLearningNumberServiceImpl extends ServiceImpl implements IResourceLearningNumberService { + +} diff --git a/src/main/java/com/teaching/backend/service/impl/records/ResourceLearningRecordServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/records/ResourceLearningRecordServiceImpl.java index be8672c..293c056 100644 --- a/src/main/java/com/teaching/backend/service/impl/records/ResourceLearningRecordServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/records/ResourceLearningRecordServiceImpl.java @@ -1,127 +1,125 @@ -//package com.teaching.backend.service.impl.records; -// -// -//import cn.hutool.core.bean.BeanUtil; -//import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -//import com.teaching.backend.common.BaseResponse; -//import com.teaching.backend.common.ResultUtils; -//import com.teaching.backend.mapper.records.ResourceLearningRecordMapper; -//import com.teaching.backend.model.entity.records.KnowledgeLearningRecord; -//import com.teaching.backend.model.entity.records.ResourceLearningRecord; -//import com.teaching.backend.model.entity.resource.ResourceLearningNumber; -//import com.teaching.backend.model.vo.records.KnowledgeLearningRecordVo; -//import com.teaching.backend.model.vo.records.ResourceLearingRecordVo; -//import com.teaching.backend.service.impl.resource.ResourceLearningNumberServiceImpl; -//import com.teaching.backend.service.records.IResourceLearningRecordService; -//import org.springframework.stereotype.Service; -// -//import javax.annotation.Resource; -//import java.text.SimpleDateFormat; -//import java.time.LocalDateTime; -//import java.time.ZoneId; -//import java.util.ArrayList; -//import java.util.Date; -//import java.util.List; -// -///** -// *

-// * 服务实现类 -// *

-// * -// * @author author -// * @since 2024-07-24 -// */ -//@Service -//public class ResourceLearningRecordServiceImpl extends ServiceImpl implements IResourceLearningRecordService { -// -// @Resource -// private ResourceLearningNumberServiceImpl resourceLearningNumberService; -// -// @Override -// public BaseResponse saveCoursesRecords(ResourceLearningRecord resourceLearningRecord) { -// //课程id -// String courseId = resourceLearningRecord.getCoursesId(); -// String knowledgeId = resourceLearningRecord.getKnowledgeId(); -// String resourceId = resourceLearningRecord.getResourceId(); -// String userId = resourceLearningRecord.getUserId(); -// //1.生成学习时间 -// resourceLearningRecord.setTimes(LocalDateTime.now()); -// //2.设置人数 -// //2.1查人数 -// Long count = resourceLearningNumberService.query() -// .eq("course_id", courseId) -// .eq("knowledge_id",knowledgeId) -// .eq("resource_id",resourceId).count(); -// //2.2判断自己是否学习过 -// Long count1 = query() -// .eq("user_id", userId) -// .eq("courses_id", courseId) -// .eq("knowledge_id",knowledgeId) -// .eq("resource_id",resourceId).count(); -// if (count > 0){ -// //自己没学过,人数加1 -// if (count1 == 0){ -// resourceLearningNumberService.update().setSql("number = number + 1") -// .eq("course_id",courseId) -// .eq("knowledge_id",knowledgeId) -// .eq("resource_id",resourceId).update(); -//// System.out.println("用户:"+userId+"第一次学这门课"); -// } -// }else { -// //该课程第一次被学,人数设置为1 -// ResourceLearningNumber resourceLearningNumber = new ResourceLearningNumber(); -// resourceLearningNumber.setNumber(1); -// resourceLearningNumber.setCourseId(courseId); -// resourceLearningNumber.setKnowledgeId(knowledgeId); -// resourceLearningNumber.setResourceId(resourceId); -// resourceLearningNumberService.save(resourceLearningNumber); -// } -// //设置人数 -// String numberId = resourceLearningNumberService.query() -// .eq("course_id", courseId) -// .eq("knowledge_id",knowledgeId) -// .eq("resource_id",resourceId).one().getId(); -// resourceLearningRecord.setNumber(numberId); -// //保存记录 -// save(resourceLearningRecord); -// return ResultUtils.success("添加成功"); -// } -// -// @Override -// public BaseResponse getPage(int pagenum, int pagesize, String userId, String knowledgeId, String courseId) { -////格式化时间 -// String strDateFormat = "yyyy-MM-dd HH:mm:ss"; -// SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat); -// //分页查询 -// Page page = query() -// .orderByDesc("times") -// .eq("user_id", userId) -// .eq("knowledge_id",knowledgeId) -// .eq("courses_id",courseId).page(new Page<>(pagenum, pagesize)); -// Page page1 = new Page<>(); -// List records = page.getRecords(); -// BeanUtil.copyProperties(page, page1); -// List recordsVos = new ArrayList<>(); -// //copy集合 -// records.forEach(resourceLearningRecord -> { -// ResourceLearingRecordVo resourceLearingRecordVo = new ResourceLearingRecordVo(); -// BeanUtil.copyProperties(resourceLearningRecord,resourceLearingRecordVo); -// Date date = Date.from(resourceLearningRecord.getTimes().atZone(ZoneId.systemDefault()).toInstant()); -// resourceLearingRecordVo.setTime(sdf.format(date)); -//// //填充学习人数 -// resourceLearingRecordVo.setNumber(resourceLearningNumberService.getById(resourceLearningRecord.getNumber()).getNumber()); -// recordsVos.add(resourceLearingRecordVo); -// }); -// page1.setRecords(recordsVos); -// return ResultUtils.success(page1); -// } -// -// @Override -// public BaseResponse removeResourceRecord(List ids) { -// removeByIds(ids); -// return ResultUtils.success("删除成功!"); -// } -// -// -//} +package com.teaching.backend.service.impl.records; + + +import cn.hutool.core.bean.BeanUtil; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.teaching.backend.common.BaseResponse; +import com.teaching.backend.common.ResultUtils; +import com.teaching.backend.mapper.records.ResourceLearningRecordMapper; +import com.teaching.backend.model.entity.records.ResourceLearningNumber; +import com.teaching.backend.model.entity.records.ResourceLearningRecord; + +import com.teaching.backend.model.vo.records.ResourceLearingRecordVo; +import com.teaching.backend.service.records.IResourceLearningRecordService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.text.SimpleDateFormat; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + *

+ * 服务实现类 + *

+ * + * @author author + * @since 2024-07-24 + */ +@Service +public class ResourceLearningRecordServiceImpl extends ServiceImpl implements IResourceLearningRecordService { + + @Resource + private ResourceLearningNumberServiceImpl resourceLearningNumberService; + + @Override + public BaseResponse saveCoursesRecords(ResourceLearningRecord resourceLearningRecord) { + //课程id + String courseId = resourceLearningRecord.getCoursesId(); + String knowledgeId = resourceLearningRecord.getKnowledgeId(); + String resourceId = resourceLearningRecord.getResourceId(); + String userId = resourceLearningRecord.getUserId(); + //1.生成学习时间 + resourceLearningRecord.setTimes(LocalDateTime.now()); + //2.设置人数 + //2.1查人数 + Long count = resourceLearningNumberService.query() + .eq("course_id", courseId) + .eq("knowledge_id",knowledgeId) + .eq("resource_id",resourceId).count(); + //2.2判断自己是否学习过 + Long count1 = query() + .eq("user_id", userId) + .eq("courses_id", courseId) + .eq("knowledge_id",knowledgeId) + .eq("resource_id",resourceId).count(); + if (count > 0){ + //自己没学过,人数加1 + if (count1 == 0){ + resourceLearningNumberService.update().setSql("number = number + 1") + .eq("course_id",courseId) + .eq("knowledge_id",knowledgeId) + .eq("resource_id",resourceId).update(); +// System.out.println("用户:"+userId+"第一次学这门课"); + } + }else { + //该课程第一次被学,人数设置为1 + ResourceLearningNumber resourceLearningNumber = new ResourceLearningNumber(); + resourceLearningNumber.setNumber(1); + resourceLearningNumber.setCourseId(courseId); + resourceLearningNumber.setKnowledgeId(knowledgeId); + resourceLearningNumber.setResourceId(resourceId); + resourceLearningNumberService.save(resourceLearningNumber); + } + //设置人数 + String numberId = resourceLearningNumberService.query() + .eq("course_id", courseId) + .eq("knowledge_id",knowledgeId) + .eq("resource_id",resourceId).one().getId(); + resourceLearningRecord.setNumber(numberId); + //保存记录 + save(resourceLearningRecord); + return ResultUtils.success("添加成功"); + } + + @Override + public BaseResponse getPage(int pagenum, int pagesize, String userId, String knowledgeId, String courseId) { +//格式化时间 + String strDateFormat = "yyyy-MM-dd HH:mm:ss"; + SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat); + //分页查询 + Page page = query() + .orderByDesc("times") + .eq("user_id", userId) + .eq("knowledge_id",knowledgeId) + .eq("courses_id",courseId).page(new Page<>(pagenum, pagesize)); + Page page1 = new Page<>(); + List records = page.getRecords(); + BeanUtil.copyProperties(page, page1); + List recordsVos = new ArrayList<>(); + //copy集合 + records.forEach(resourceLearningRecord -> { + ResourceLearingRecordVo resourceLearingRecordVo = new ResourceLearingRecordVo(); + BeanUtil.copyProperties(resourceLearningRecord,resourceLearingRecordVo); + Date date = Date.from(resourceLearningRecord.getTimes().atZone(ZoneId.systemDefault()).toInstant()); + resourceLearingRecordVo.setTime(sdf.format(date)); +// //填充学习人数 + resourceLearingRecordVo.setNumber(resourceLearningNumberService.getById(resourceLearningRecord.getNumber()).getNumber()); + recordsVos.add(resourceLearingRecordVo); + }); + page1.setRecords(recordsVos); + return ResultUtils.success(page1); + } + + @Override + public BaseResponse removeResourceRecord(List ids) { + removeByIds(ids); + return ResultUtils.success("删除成功!"); + } + + +} diff --git a/src/main/java/com/teaching/backend/service/impl/report/ReportServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/report/ReportServiceImpl.java index dd42ddc..e0c6845 100644 --- a/src/main/java/com/teaching/backend/service/impl/report/ReportServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/report/ReportServiceImpl.java @@ -30,7 +30,6 @@ public class ReportServiceImpl extends ServiceImpl impleme List ThisMonthBrowseList = new ArrayList<>(); //存放上个月访问的前一天至前七天的每天对应的浏览量 List LastMonthBrowseList = new ArrayList<>(); - //获取今天的日期 LocalDate end = LocalDate.now(); @@ -51,7 +50,6 @@ public class ReportServiceImpl extends ServiceImpl impleme //查询上个月的今天对应的浏览量 String lastMonthBrowse = reportMapper.getBrowseByTime(lastMonth); - LastMonthBrowseList.add(lastMonthBrowse); } 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 b8ba096..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 @@ -67,7 +67,7 @@ public class ResourceServiceImpl implements ResourceService { private Neo4jClient neo4jClient; @Override - public BaseResponse upload(MultipartFile file) { + public BaseResponse upload(MultipartFile file) { ResourceUploadDto resourceUploadDto = minioUtils.upload(file); if (resourceUploadDto == null) { return ResultUtils.error(ErrorCode.OPERATION_ERROR, "上传失败"); @@ -83,7 +83,7 @@ public class ResourceServiceImpl implements ResourceService { resource.setUrl(url); resourcesRepository.save(resource); - return ResultUtils.success(resourceUploadDto); + return ResultUtils.success(resource); } @Override @@ -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/impl/umsAdmin/UmsStudentManageServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/umsAdmin/UmsStudentManageServiceImpl.java new file mode 100644 index 0000000..5dea081 --- /dev/null +++ b/src/main/java/com/teaching/backend/service/impl/umsAdmin/UmsStudentManageServiceImpl.java @@ -0,0 +1,94 @@ +package com.teaching.backend.service.impl.umsAdmin; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.teaching.backend.exception.BusinessException; +import com.teaching.backend.mapper.umsAdmin.*; +import com.teaching.backend.model.dto.umsAdmin.UmsStudentPageQueryDTO; +import com.teaching.backend.model.entity.umsAdmin.*; +import com.teaching.backend.service.impl.courses.CoursesServiceImpl; +import com.teaching.backend.service.umsAdmin.UmsStudentManageService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + + +@Service +@Slf4j +public class UmsStudentManageServiceImpl extends ServiceImpl implements UmsStudentManageService { + + @Autowired + private UmsStudentManageMapper umsStudentManageMapper; + @Autowired + private UmsStudentMapper umsStudentMapper; + @Autowired + private UmsUserMapper umsUserMapper; + @Autowired + private CoursesServiceImpl coursesService; + + + @Override + public Map pageQuery(UmsStudentPageQueryDTO umsStudentPageQueryDTO) { + + LinkedHashSet umsStudentManages = coursesService.queryTeacherByStudentList(umsStudentPageQueryDTO.getUserId()); + + //总记录数 + int totalCount = umsStudentManages.size(); + + //总页数 + int totalPages = (int) Math.ceil((double) totalCount / umsStudentPageQueryDTO.getPageSize()); + + List umsStudentManageList = umsStudentManages.stream() + .skip((umsStudentPageQueryDTO.getPage() - 1) * umsStudentPageQueryDTO.getPageSize()) + .limit(umsStudentPageQueryDTO.getPageSize()) + .collect(Collectors.toList()); + + Map result = new HashMap<>(); + result.put("Records", umsStudentManageList); + result.put("totalCount", totalCount); + result.put("totalPages", totalPages); + result.put("currentPage", umsStudentPageQueryDTO.getPage()); + + return result; + } + + @Override + public UmsStudentManage getByIdStudentAndUser(Long id) { + UmsStudentManage studentAndUser = umsStudentManageMapper.getByIdStudentAndUser(id); + return studentAndUser; + } + + @Override + public void updateStudentAndUser(UmsStudentManage umsStudentManage) { + UmsStudent umsStudent = new UmsStudent(); + BeanUtils.copyProperties(umsStudentManage,umsStudent); + boolean studentInfo = umsStudentMapper.updateStudentInfo(umsStudent); + if (studentInfo == false){ + throw new BusinessException(400,"修改失败"); + } + UmsUser umsUser = new UmsUser(); + BeanUtils.copyProperties(umsStudentManage, umsUser); + umsUser.setId(Long.valueOf(umsStudentManage.getUserId())); + boolean userInformation = umsUserMapper.updateUserInformation(umsUser); + if (userInformation == false){ + throw new BusinessException(400,"修改失败"); + } + } + + @Override + public void startOrStop(String status, Long id) { + UmsUser umsUser = new UmsUser(); + umsUser.setStatus(status); + umsUser.setId(id); + boolean updateUserInformation = umsUserMapper.updateUserInformation(umsUser); + if (updateUserInformation == false){ + throw new BusinessException(400,"账号状态修改失败"); + } + } +} diff --git a/src/main/java/com/teaching/backend/service/impl/umsAdmin/UmsUserServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/umsAdmin/UmsUserServiceImpl.java index ef82ab9..e691525 100644 --- a/src/main/java/com/teaching/backend/service/impl/umsAdmin/UmsUserServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/umsAdmin/UmsUserServiceImpl.java @@ -70,7 +70,7 @@ public class UmsUserServiceImpl extends ServiceImpl impl UmsUser umsUser = new UmsUser(); BeanUtils.copyProperties(umsAdminParam, umsUser); umsUser.setCreateTime(LocalDateTime.now()); - umsUser.setStatus(1); + umsUser.setStatus("1"); //查询是否有相同用户名的用户 List umsAdminList = lambdaQuery() .eq(UmsUser::getUsername, umsUser.getUsername()) @@ -291,7 +291,7 @@ public class UmsUserServiceImpl extends ServiceImpl impl UmsUser umsUser = new UmsUser(); BeanUtils.copyProperties(umsUserParam, umsUser); umsUser.setCreateTime(LocalDateTime.now()); - umsUser.setStatus(1); + umsUser.setStatus("1"); //查询是否有相同手机号的用户 List umsUserList = lambdaQuery() .eq(UmsUser::getPhone,umsUserParam.getPhone()) diff --git a/src/main/java/com/teaching/backend/service/knowtmp/KnowtmpService.java b/src/main/java/com/teaching/backend/service/knowtmp/KnowtmpService.java index 193fe44..e8ab344 100644 --- a/src/main/java/com/teaching/backend/service/knowtmp/KnowtmpService.java +++ b/src/main/java/com/teaching/backend/service/knowtmp/KnowtmpService.java @@ -26,6 +26,9 @@ public interface KnowtmpService { BaseResponse query(Long id); //查询通过chapterId List - BaseResponse> queryByChapterId(Long chapterId); + List queryByChapterId(Long chapterId); + + //查询通过chapterId List + List queryByChapterIdList(List chapterIdList); } diff --git a/src/main/java/com/teaching/backend/service/records/ICourseLearningRecordService.java b/src/main/java/com/teaching/backend/service/records/ICourseLearningRecordService.java index 686d4d0..d9b77ef 100644 --- a/src/main/java/com/teaching/backend/service/records/ICourseLearningRecordService.java +++ b/src/main/java/com/teaching/backend/service/records/ICourseLearningRecordService.java @@ -28,4 +28,6 @@ public interface ICourseLearningRecordService extends IService removeCoursesRecords(List ids); List queryCourseList(String userId); + + List queryrecommendCourses(String userId); } diff --git a/src/main/java/com/teaching/backend/service/records/IResourceLearningNumberService.java b/src/main/java/com/teaching/backend/service/records/IResourceLearningNumberService.java new file mode 100644 index 0000000..de6abdf --- /dev/null +++ b/src/main/java/com/teaching/backend/service/records/IResourceLearningNumberService.java @@ -0,0 +1,17 @@ +package com.teaching.backend.service.records; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.teaching.backend.model.entity.records.ResourceLearningNumber; + +/** + *

+ * 服务类 + *

+ * + * @author author + * @since 2024-07-29 + */ +public interface IResourceLearningNumberService extends IService { + +} 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 a916e24..d44a7ba 100644 --- a/src/main/java/com/teaching/backend/service/resource/ResourceService.java +++ b/src/main/java/com/teaching/backend/service/resource/ResourceService.java @@ -20,7 +20,7 @@ import java.util.Set; public interface ResourceService { - BaseResponse upload(MultipartFile file) ; + BaseResponse upload(MultipartFile file) ; BaseResponse delete(String filename) ; @@ -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/service/umsAdmin/UmsStudentManageService.java b/src/main/java/com/teaching/backend/service/umsAdmin/UmsStudentManageService.java new file mode 100644 index 0000000..cc741bf --- /dev/null +++ b/src/main/java/com/teaching/backend/service/umsAdmin/UmsStudentManageService.java @@ -0,0 +1,21 @@ +package com.teaching.backend.service.umsAdmin; + + +import cn.hutool.db.PageResult; +import com.baomidou.mybatisplus.extension.service.IService; +import com.teaching.backend.model.dto.umsAdmin.UmsStudentPageQueryDTO; +import com.teaching.backend.model.entity.umsAdmin.UmsStudentManage; + +import java.util.Map; + +public interface UmsStudentManageService extends IService { + + + Map pageQuery(UmsStudentPageQueryDTO umsStudentPageQueryDTO); + + UmsStudentManage getByIdStudentAndUser(Long id); + + void updateStudentAndUser(UmsStudentManage umsStudentManage); + + void startOrStop(String status, Long id); +} 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(); } diff --git a/src/main/resources/mapper/UmsPermissionMapper.xml b/src/main/resources/mapper/UmsPermissionMapper.xml deleted file mode 100644 index 1a9856c..0000000 --- a/src/main/resources/mapper/UmsPermissionMapper.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/src/main/resources/mapper/UmsStudentManageService.xml b/src/main/resources/mapper/UmsStudentManageService.xml new file mode 100644 index 0000000..f7e4ec2 --- /dev/null +++ b/src/main/resources/mapper/UmsStudentManageService.xml @@ -0,0 +1,46 @@ + + + + + + + + + + diff --git a/src/main/resources/mapper/UmsStudentMapper.xml b/src/main/resources/mapper/UmsStudentMapper.xml index 3a452f1..a985f3c 100644 --- a/src/main/resources/mapper/UmsStudentMapper.xml +++ b/src/main/resources/mapper/UmsStudentMapper.xml @@ -5,34 +5,34 @@ update ums_student - + name = #{name,jdbcType=VARCHAR}, - + sex = #{sex}, - + nationality = #{nationality,jdbcType=VARCHAR}, - + number = #{number,jdbcType=VARCHAR}, - + birthday = #{birthday,jdbcType=VARCHAR}, - + phone = #{phone,jdbcType=TIMESTAMP}, - + faculty = #{faculty,jdbcType=INTEGER}, - + major = #{major,jdbcType=INTEGER}, - + year_age = #{yearAge,jdbcType=INTEGER}, - + class_name = #{className,jdbcType=INTEGER}, diff --git a/src/main/resources/mapper/UmsUserMapper.xml b/src/main/resources/mapper/UmsUserMapper.xml index d09d5a0..5b56d4a 100644 --- a/src/main/resources/mapper/UmsUserMapper.xml +++ b/src/main/resources/mapper/UmsUserMapper.xml @@ -5,25 +5,25 @@ update ums_user - + username = #{username,jdbcType=VARCHAR}, - + password = #{password}, - + phone = #{phone,jdbcType=VARCHAR}, - + nick_name = #{nickName,jdbcType=VARCHAR}, - + icon = #{icon,jdbcType=VARCHAR}, - + create_time = #{createTime,jdbcType=TIMESTAMP}, - + status = #{status,jdbcType=INTEGER}, diff --git a/src/test/java/com/teaching/MinioTest.java b/src/test/java/com/teaching/MinioTest.java deleted file mode 100644 index cbdb77d..0000000 --- a/src/test/java/com/teaching/MinioTest.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.teaching; - -import org.junit.jupiter.api.Test; -import org.springframework.util.DigestUtils; - -import java.io.*; -import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -public class MinioTest { - //分块测试 - @Test - public void testChunk() throws IOException { - //源文件 - File sourseFile = new File("D:/Users/Desktop/image/剪映/7.18/7月20.mp4"); - //分块文件存储路径 - String chunkFilePath = "D:/Users/Desktop/image/剪映/7.18/chunk/"; - //分块文件大小 - int chunkSize = 1024 * 1024 * 1; - //分块文件个数 - int chunkNum = (int) Math.ceil(sourseFile.length() * 1.0 / chunkSize); - //使用流从源文件读数据,向分块文件中写数据 - RandomAccessFile raf_r = new RandomAccessFile(sourseFile, "r"); - //缓存区 - byte[] bytes = new byte[1024]; - for (int i = 0; i < chunkNum; i++) { - File chunkFile = new File(chunkFilePath + i); - //分块文件写入流 - RandomAccessFile raf_rw = new RandomAccessFile(chunkFile, "rw"); - int len = -1; - while((len=raf_r.read(bytes)) != -1){ - raf_rw.write(bytes, 0, len); - if (chunkFile.length() >= chunkSize){ - break; - } - } - raf_rw.close(); - } - raf_r.close(); - } - - //将分块进行合并 - @Test - public void testMerge() throws IOException { - //块文件目录 - File chunkFolder = new File("D:\\Users\\Desktop\\image\\剪映\\7.18\\chunk"); - //源文件 - File sourseFile = new File("D:/Users/Desktop/image/剪映/7.18/7月20.mp4"); - //合并后的文件 - File mergeFile = new File("D:/Users/Desktop/image/剪映/7.18/7月20_merge.mp4"); - - //取出所有分块文件 - File[] files = chunkFolder.listFiles(); - //将数组转成list - List fileList = Arrays.asList(files); - //对分块文件排序 - Collections.sort(fileList, new Comparator() { - @Override - public int compare(File o1, File o2) { - return Integer.parseInt(o1.getName()) - Integer.parseInt(o2.getName()); //升序 - } - }); - //向合并文件写的流 - RandomAccessFile raf_rw = new RandomAccessFile(mergeFile, "rw"); - //缓存区 - byte[] bytes = new byte[1024]; - //遍历分块文件,向合并的文件写 - for (File file : fileList) { - //读分块的流 - RandomAccessFile raf_r = new RandomAccessFile(file, "r"); - int len = -1; - while((len = raf_r.read(bytes)) != -1){ - raf_rw.write(bytes, 0, len); - } - raf_r.close(); - } - raf_rw.close(); - //合并文件完成后对合并的文件校验 - FileInputStream fileInputStream_merge = new FileInputStream(mergeFile); - FileInputStream fileInputStream_source = new FileInputStream(sourseFile); - String md5_merge = DigestUtils.md5DigestAsHex(fileInputStream_merge); - String md5_source = DigestUtils.md5DigestAsHex(fileInputStream_source); - if (md5_merge.equals(md5_source)){ - System.out.println("文件合并成功!"); - } - } - - //将分块文件上传到minio - public void uploadChunk(){ - - } - - //调用minio接口合并分块 - - - //批量清理分块文件 - - -} diff --git a/src/test/java/com/teaching/test.java b/src/test/java/com/teaching/test.java deleted file mode 100644 index 6d75620..0000000 --- a/src/test/java/com/teaching/test.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.teaching; - - -import lombok.extern.slf4j.Slf4j; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; - -import javax.annotation.Resource; - -@Slf4j -@SpringBootTest -public class test { - - - @Test - public void countknowledge(){ - String userId = "2"; -// System.out.println(knowledgeLearningCountService.list()); -// List list = knowledgeLearningCountService.query().eq("user_id", userId).list(); -// HashSet set = new HashSet<>(list); -// System.out.println(set.size()); -// Long count = knowledgeLearningCountService.query().eq("user_id", userId).count(); -// if (count == 0){ -// KnowledgeLearningCount knowledgeLearningCount = new KnowledgeLearningCount(); -// knowledgeLearningCount.setUserId(userId); -// knowledgeLearningCount.setNumber(1); -// knowledgeLearningCountService.save(knowledgeLearningCount); -// }else { -// //该用户学习知识点数+1 -// boolean is = knowledgeLearningCountService.update() -// .setSql("number = "+set.size()) -// .eq("user_id", userId).update(); -// System.out.println(is); -// } - } -}