Merge remote-tracking branch 'origin/master'

master
小萌新 5 months ago
commit 896ba81d60
  1. 36
      docs/文档说明.md
  2. 2
      pom.xml
  3. 27
      src/main/java/com/teaching/backend/controller/Know/KnowController.java
  4. 2
      src/main/java/com/teaching/backend/controller/Knowtmp/KnowtmpController.java
  5. 5
      src/main/java/com/teaching/backend/controller/courses/CoursesController.java
  6. 2
      src/main/java/com/teaching/backend/controller/records/Bf.java
  7. 15
      src/main/java/com/teaching/backend/controller/records/CourseLearningRecordController.java
  8. 205
      src/main/java/com/teaching/backend/controller/records/ResourceLearningRecordController.java
  9. 8
      src/main/java/com/teaching/backend/controller/resource/ResourceController.java
  10. 72
      src/main/java/com/teaching/backend/controller/umsAdmin/UmsStudentManageController.java
  11. 13
      src/main/java/com/teaching/backend/controller/umsStudent/UmsStudentController.java
  12. 30
      src/main/java/com/teaching/backend/mapper/know/KnowRepository.java
  13. 17
      src/main/java/com/teaching/backend/mapper/records/ResourceLearningNumberMapper.java
  14. 2
      src/main/java/com/teaching/backend/mapper/resource/ResourcesRepository.java
  15. 22
      src/main/java/com/teaching/backend/mapper/umsAdmin/UmsStudentManageMapper.java
  16. 1
      src/main/java/com/teaching/backend/mapper/umsAdmin/UmsStudentMapper.java
  17. 6
      src/main/java/com/teaching/backend/model/dto/Know/KnowChapterCreateRequest.java
  18. 3
      src/main/java/com/teaching/backend/model/dto/Know/KnowCourseCreateRequest.java
  19. 1
      src/main/java/com/teaching/backend/model/dto/Knowtmp/KnowtempAdd.java
  20. 1
      src/main/java/com/teaching/backend/model/dto/Knowtmp/KnowtempUpdate.java
  21. 2
      src/main/java/com/teaching/backend/model/dto/chapter/ChapterDTO.java
  22. 25
      src/main/java/com/teaching/backend/model/dto/umsAdmin/UmsStudentPageQueryDTO.java
  23. 2
      src/main/java/com/teaching/backend/model/entity/chapter/Chapter.java
  24. 6
      src/main/java/com/teaching/backend/model/entity/know/Know.java
  25. 15
      src/main/java/com/teaching/backend/model/entity/know/KnowChapter.java
  26. 9
      src/main/java/com/teaching/backend/model/entity/know/KnowCourse.java
  27. 4
      src/main/java/com/teaching/backend/model/entity/knowtmp/Knowtmp.java
  28. 47
      src/main/java/com/teaching/backend/model/entity/records/ResourceLearningNumber.java
  29. 84
      src/main/java/com/teaching/backend/model/entity/umsAdmin/UmsStudentManage.java
  30. 21
      src/main/java/com/teaching/backend/model/entity/umsAdmin/UmsStudentPageQuery.java
  31. 3
      src/main/java/com/teaching/backend/model/entity/umsAdmin/UmsUser.java
  32. 15
      src/main/java/com/teaching/backend/service/Know/KnowService.java
  33. 5
      src/main/java/com/teaching/backend/service/courses/ICoursesService.java
  34. 8
      src/main/java/com/teaching/backend/service/impl/chapter/ChapterServiceImpl.java
  35. 38
      src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java
  36. 130
      src/main/java/com/teaching/backend/service/impl/know/knowServiceImpl.java
  37. 14
      src/main/java/com/teaching/backend/service/impl/knowtmp/KnowtmpServiceImpl.java
  38. 17
      src/main/java/com/teaching/backend/service/impl/records/CourseLearningRecordServiceImpl.java
  39. 22
      src/main/java/com/teaching/backend/service/impl/records/ResourceLearningNumberServiceImpl.java
  40. 252
      src/main/java/com/teaching/backend/service/impl/records/ResourceLearningRecordServiceImpl.java
  41. 2
      src/main/java/com/teaching/backend/service/impl/report/ReportServiceImpl.java
  42. 16
      src/main/java/com/teaching/backend/service/impl/resource/ResourceServiceImpl.java
  43. 94
      src/main/java/com/teaching/backend/service/impl/umsAdmin/UmsStudentManageServiceImpl.java
  44. 4
      src/main/java/com/teaching/backend/service/impl/umsAdmin/UmsUserServiceImpl.java
  45. 5
      src/main/java/com/teaching/backend/service/knowtmp/KnowtmpService.java
  46. 2
      src/main/java/com/teaching/backend/service/records/ICourseLearningRecordService.java
  47. 17
      src/main/java/com/teaching/backend/service/records/IResourceLearningNumberService.java
  48. 8
      src/main/java/com/teaching/backend/service/resource/ResourceService.java
  49. 21
      src/main/java/com/teaching/backend/service/umsAdmin/UmsStudentManageService.java
  50. 2
      src/main/java/com/teaching/backend/utils/MinioUtils.java
  51. 5
      src/main/resources/mapper/UmsPermissionMapper.xml
  52. 46
      src/main/resources/mapper/UmsStudentManageService.xml
  53. 20
      src/main/resources/mapper/UmsStudentMapper.xml
  54. 14
      src/main/resources/mapper/UmsUserMapper.xml
  55. 101
      src/test/java/com/teaching/MinioTest.java
  56. 36
      src/test/java/com/teaching/test.java

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

@ -227,8 +227,6 @@
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<!-- 文件下载-->
<dependency>
<groupId>commons-fileupload</groupId>

@ -28,6 +28,20 @@ public class KnowController {
@Autowired
private KnowService knowService;
// 添加全部知识点
@PostMapping("/addAllKnow")
BaseResponse<String> addAllKnow(@RequestParam String courseId){
return knowService.addAllKnow(courseId);
}
// 添加知识点与资源的关系
@PostMapping("/addRelationship/Withresources")
BaseResponse<String> addRelationshipWithresources(@RequestParam Long id,@RequestParam Long resourceId){
return knowService.addRelationshipWithresources(id,resourceId);
}
//===================
// 添加知识点
@PostMapping("/addKnow")
BaseResponse<String> addKnow(@RequestBody KnowRequest knowRequest){
@ -110,20 +124,9 @@ public class KnowController {
//获取课程下的所有知识点
@GetMapping("/getAllKnowByCourseId")
BaseKnowReturn getAllKnowByCourseId(@RequestParam String id){
BaseResponse<BaseKnowReturn> getAllKnowByCourseId(@RequestParam String id){
return knowService.getAllKnowByCourseId(id);
}
//获取课程下的所有资源
@GetMapping("/getAllResourcesByCourseId")
BaseResponse<Set<KnowVO1>> getAllResourcesByCourseId(@RequestParam String id){
return knowService.getAllResourcesByCourseId(id);
}
//获取知识点下二级的所有资源
@GetMapping("/getSecondResources")
Set<Resources> getSecondResources(@RequestParam Long id){
return knowService.getSecondResources(id);
}
}

@ -50,7 +50,7 @@ public class KnowtmpController {
}
//查询通过chapterId List
@GetMapping("/queryKnow")
BaseResponse<List<Knowtmp>> queryByChapterId(Long chapterId){
List<Knowtmp> queryByChapterId(Long chapterId){
return knowtmpService.queryByChapterId(chapterId);
}
}

@ -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<LinkedHashSet<PersonalCenterStudentListVO>> getStudentList(@RequestParam String userId){
LinkedHashSet<PersonalCenterStudentListVO> umsStudentList = coursesService.queryStudentList(userId);
public CommonResult<List<PersonalCenterStudentListVO>> getStudentList(@RequestParam String userId){
List<PersonalCenterStudentListVO> umsStudentList = coursesService.queryStudentList(userId);
return CommonResult.success(umsStudentList);
}

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

@ -70,4 +70,19 @@ public class CourseLearningRecordController {
}
return CommonResult.success(coursesVOList);
}
/**
* 推荐课程
* @return
*/
@ApiOperation("推荐课程")
@PostMapping("/recommendCourses")
public CommonResult<List<CoursesVO>> recommendCourses(@RequestParam String userId) {
List<CoursesVO> coursesVOList = courseLearningRecordService.queryrecommendCourses(userId);
if (coursesVOList == null){
CommonResult.failed("用户或角色错误");
}
return CommonResult.success(coursesVOList);
}
}

@ -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<String> saveResourceRecords(@RequestBody ResourceLearningRecord resourceLearningRecord) {
// return resourceLearningRecordService.saveCoursesRecords(resourceLearningRecord);
// }
//
// /**
// * 获取当前登录用户的学习资源记录
// * @param pagenum
// * @param pagesize
// * @return
// */
// @ApiOperation("根据用户id查询学习记录")
// @ValidateParams({"userId"})
// @GetMapping("/page")
// public BaseResponse<Page> 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<String> deleteRecords(@RequestParam List<Long> ids){
// return resourceLearningRecordService.removeResourceRecord(ids);
// }
//
// /**
// * 统计单个学生学习资源数量
// * @param userId
// * @return
// */
// @ApiOperation("统计单个学生学习资源数量")
// @GetMapping("/countresourcenumber")
// public BaseResponse<Integer> countResourceNumber(@RequestParam String userId) {
// return ResultUtils.success(resourceLearningRecordMapper.selectDistinctResourceIdsByUser(userId).size());
// }
//
//
// @ApiOperation("上传图片")
// @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
// public BaseResponse<String> 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<String> 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<String> saveResourceRecords(@RequestBody ResourceLearningRecord resourceLearningRecord) {
return resourceLearningRecordService.saveCoursesRecords(resourceLearningRecord);
}
/**
* 获取当前登录用户的学习资源记录
* @param pagenum
* @param pagesize
* @return
*/
@ApiOperation("根据用户id查询学习记录")
@ValidateParams({"userId"})
@GetMapping("/page")
public BaseResponse<Page> 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<String> deleteRecords(@RequestParam List<Long> ids){
return resourceLearningRecordService.removeResourceRecord(ids);
}
/**
* 统计单个学生学习资源数量
* @param userId
* @return
*/
@ApiOperation("统计单个学生学习资源数量")
@GetMapping("/countresourcenumber")
public BaseResponse<Integer> countResourceNumber(@RequestParam String userId) {
return ResultUtils.success(resourceLearningRecordMapper.selectDistinctResourceIdsByUser(userId).size());
}
@ApiOperation("上传图片")
@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public BaseResponse<String> 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<String> bf(@RequestParam String path, File file,HttpServletRequest request, HttpServletResponse response){
File sourseFile = new File(path);
return ResultUtils.success(path);
};
}

@ -32,7 +32,7 @@ public class ResourceController {
//添加知识点
@PostMapping("/upload")
@ResponseBody
public BaseResponse<ResourceUploadDto> uploadFile(@RequestPart("file") MultipartFile file) {
public BaseResponse<Resources> uploadFile(@RequestPart("file") MultipartFile file) {
return resourceService.upload(file);
}
@ -62,19 +62,19 @@ public class ResourceController {
//查询课程下资源
@GetMapping("/queryByCourseId")
Set<Resources> queryResourcesByCourseId(String courseId){
BaseResponse<Set<Resources>> queryResourcesByCourseId(@RequestParam String courseId){
return resourceService.queryResourcesByCourseId(courseId);
}
//查询章节下资源
@GetMapping("/queryByChapterId")
Set<Resources> queryResourcesByChapterId(Long chapterId){
BaseResponse<Set<Resources>> queryResourcesByChapterId(@RequestParam Long chapterId){
return resourceService.queryResourcesByChapterId(chapterId);
}
//查询二级节点下资源
@GetMapping("/queryBesidesKnow")
Set<Resources> queryBesidesKnowToResources(Long KnowId){
BaseResponse<Set<Resources>> queryBesidesKnowToResources(@RequestParam Long KnowId){
return resourceService.queryBesidesKnowToResources(KnowId);
}

@ -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<Map<String, Object>> page(UmsStudentPageQueryDTO umsStudentPageQueryDTO){
Map<String, Object> 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<UmsStudentManage> 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("修改成功");
}
}

@ -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 {
}

@ -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<Know, Long> {
@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<Know, Long> {
//=============================
@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<Know, Long> {
//====================
@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<Know, Long> {
@Query("MATCH (p:Know)-[:FatherAndSon]->(n:Know)-[:resources]->(m:Resources) WHERE ID(p) = $id RETURN m")
Set<Resources> 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);
}

@ -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;
/**
* <p>
* Mapper 接口
* </p>
*
* @author author
* @since 2024-07-29
*/
public interface ResourceLearningNumberMapper extends BaseMapper<ResourceLearningNumber> {
}

@ -38,7 +38,7 @@ public interface ResourcesRepository extends Neo4jRepository<Resources, Long> {
Set<Resources> queryResourcesByCourseId(String courseId);
//查询章节下资源
@Query("MATCH p = (a:Know)-[rels*]-(b:Resources) WHERE a.chapterId = chapterId and ANY(rel IN rels WHERE TYPE(rel) = 'resources') RETURN b")
@Query("MATCH p = (a:Know)-[rels*]-(b:Resources) WHERE a.chapterId = $chapterId and ANY(rel IN rels WHERE TYPE(rel) = 'resources') RETURN b")
Set<Resources> queryResourcesByChapterId(Long chapterId);
//查询二级节点下资源

@ -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> {
UmsStudentManage queryStudent(String userId);
List<UmsStudentManage> pageQueryStudent(UmsStudentPageQuery umsStudentPageQuery);
int pageQueryStudentCount(UmsStudentPageQueryDTO umsStudentPageQueryDTO);
UmsStudentManage getByIdStudentAndUser(Long id);
}

@ -15,4 +15,5 @@ public interface UmsStudentMapper extends BaseMapper<UmsStudent> {
boolean updateStudentInfo(UmsStudent umsStudent);
UmsStudent selectByUserId(Integer userId);
}

@ -23,6 +23,12 @@ public class KnowChapterCreateRequest implements Serializable {
private String info;
/**
* 学时
*/
private double hour;
}

@ -23,6 +23,9 @@ public class KnowCourseCreateRequest implements Serializable {
private String info;
private double hour;

@ -23,6 +23,7 @@ public class KnowtempAdd implements Serializable {
private Integer ordernum;
private double hour;
}

@ -24,6 +24,7 @@ public class KnowtempUpdate implements Serializable {
private Long chapterid;
private Integer ordernum;
private double hour;
}

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

@ -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;
}

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

@ -31,5 +31,11 @@ public class Know implements Serializable {
@Property
private String info;
/**
* 学时
*/
@Property
private double hour;
}

@ -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;
}

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

@ -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;
}

@ -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;
/**
* <p>
*
* </p>
*
* @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;
}

@ -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;
/**
* <p>
*
* </p>
*
* @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;
}

@ -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;
}

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

@ -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<String> addAllKnow(String courseId);
BaseResponse<String> addRelationshipWithresources(Long id, Long resourceId);
//=====================
// 添加知识点
BaseResponse<String> addKnow(KnowRequest knowRequest);
@ -62,13 +72,12 @@ public interface KnowService {
//=====================
//获取课程下的所有知识点
BaseKnowReturn getAllKnowByCourseId(String id);
BaseResponse<BaseKnowReturn> getAllKnowByCourseId(String id);
//获取课程下的所有资源
BaseResponse<Set<KnowVO1>> getAllResourcesByCourseId(String id);
//获取知识点下二级的所有资源
Set<Resources> getSecondResources(Long id);
}

@ -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<Courses> {
Map<String, Object> getPagePageSize2(int page, int pageSize);
LinkedHashSet<PersonalCenterStudentListVO> queryStudentList(String userId);
List<PersonalCenterStudentListVO> queryStudentList(String userId);
LinkedHashSet<UmsStudentManage> queryTeacherByStudentList(String userId);
}

@ -445,17 +445,17 @@ public class ChapterServiceImpl extends ServiceImpl<ChapterMapper, Chapter> impl
List<Chapter> 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());
}

@ -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<CoursesMapper, Courses> impl
private LearningRecordsMapper learningRecordsMapper;
@Autowired
CourseLearningRecordMapper courseLearningRecordMapper;
@Autowired
private UmsStudentManageMapper umsStudentManageMapper;
@Override
@ -350,15 +354,30 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
}
@Override
public LinkedHashSet<PersonalCenterStudentListVO> queryStudentList(String userId) {
public List<PersonalCenterStudentListVO> queryStudentList(String userId) {
LinkedHashSet<UmsStudentManage> umsStudentManageList = queryTeacherByStudentList(userId);
List<PersonalCenterStudentListVO> 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<UmsStudentManage> queryTeacherByStudentList(String userId) {
String roleId = umsUserMapper.getbyIdRoleId(userId);
CourseQuery courseQuery = new CourseQuery();
courseQuery.setUserId(userId);
LinkedHashSet<UmsStudentManage> umsStudentManageList = new LinkedHashSet<>();
if (roleId.equals("1")){
PageDTO<CoursesVO> queryCourses = queryCourses(courseQuery);
List<CoursesVO> coursesList = queryCourses.getList();
List<String> courseIds = coursesList.stream().map(CoursesVO::getId).collect(Collectors.toList());
LinkedHashSet<PersonalCenterStudentListVO> studentNameList = new LinkedHashSet<>();
for (String courseId : courseIds) {
List<StudentCourses> studentUsernames = studentCoursesMapper.selectBatchSomeStudent(courseId);
List<CourseLearningRecord> courseLearningRecordList = new ArrayList<>();
@ -368,16 +387,11 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> 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<CoursesMapper, Courses> impl
List<Chapter> 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;

@ -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<String> addRelationshipWithresources(Long id, Long resourceId){
int f = knowRepository.addResourceResourcesKnow(id,resourceId);
if(f <= 0){
throw new RuntimeException("添加关系失败");
}
return ResultUtils.success("添加关系成功");
}
@Override
public BaseResponse<String> 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<Chapter> 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<Long> idList = chapterList.stream()
.map(menu -> menu.getId())
.collect(Collectors.toList());
//获取chapterId 查询知识点 返回知识点集合
List<Knowtmp> knowlist = knowtmpService.queryByChapterIdList(idList);
for (int i = 0; i < idList.size(); i++) {
List<Knowtmp> 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<String> 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<String> 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<String> 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<BaseKnowReturn> getAllKnowByCourseId(String id) {
Collection<Map<String, Object>> 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<Resources> getSecondResources(Long id) {
Set<Resources>resourcesSet ;
resourcesSet = knowRepository.queryBesidesKnowToResources(id);
return resourcesSet;
}
}

@ -69,11 +69,19 @@ public class KnowtmpServiceImpl implements KnowtmpService {
}
@Override
public BaseResponse<List<Knowtmp>> queryByChapterId(Long chapterId) {
public List<Knowtmp> queryByChapterId(Long chapterId) {
Knowtmp knowtmp = new Knowtmp();
final QueryWrapper<Knowtmp> knowtmpQueryWrapper = new QueryWrapper<>();
QueryWrapper<Knowtmp> knowtmpQueryWrapper = new QueryWrapper<>();
knowtmpQueryWrapper.eq("chapterId",chapterId);
List<Knowtmp> knowtmps = knowtmpMapper.selectList(knowtmpQueryWrapper);
return ResultUtils.success(knowtmps);
return knowtmps;
}
@Override
public List<Knowtmp> queryByChapterIdList(List<Long> chapterIdList) {
QueryWrapper<Knowtmp> knowtmpQueryWrapper = new QueryWrapper<>();
knowtmpQueryWrapper.in("chapterId",chapterIdList);
List<Knowtmp> knowtmps = knowtmpMapper.selectList(knowtmpQueryWrapper);
return knowtmps;
}
}

@ -145,4 +145,21 @@ public class CourseLearningRecordServiceImpl extends ServiceImpl<CourseLearningR
return null;
}
}
@Override
public List<CoursesVO> queryrecommendCourses(String userId) {
String roleId = umsUserMapper.getbyIdRoleId(userId);
if (roleId.equals("1")) {
return null;
} else if (roleId.equals("2")) {
return null;
}else {
return null;
}
}
}

@ -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;
/**
* <p>
* 服务实现类
* </p>
*
* @author author
* @since 2024-07-29
*/
@Service
public class ResourceLearningNumberServiceImpl extends ServiceImpl<ResourceLearningNumberMapper, ResourceLearningNumber> implements IResourceLearningNumberService {
}

@ -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;
//
///**
// * <p>
// * 服务实现类
// * </p>
// *
// * @author author
// * @since 2024-07-24
// */
//@Service
//public class ResourceLearningRecordServiceImpl extends ServiceImpl<ResourceLearningRecordMapper, ResourceLearningRecord> implements IResourceLearningRecordService {
//
// @Resource
// private ResourceLearningNumberServiceImpl resourceLearningNumberService;
//
// @Override
// public BaseResponse<String> 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<Page> 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<ResourceLearningRecord> page = query()
// .orderByDesc("times")
// .eq("user_id", userId)
// .eq("knowledge_id",knowledgeId)
// .eq("courses_id",courseId).page(new Page<>(pagenum, pagesize));
// Page<ResourceLearingRecordVo> page1 = new Page<>();
// List<ResourceLearningRecord> records = page.getRecords();
// BeanUtil.copyProperties(page, page1);
// List<ResourceLearingRecordVo> 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<String> removeResourceRecord(List<Long> 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;
/**
* <p>
* 服务实现类
* </p>
*
* @author author
* @since 2024-07-24
*/
@Service
public class ResourceLearningRecordServiceImpl extends ServiceImpl<ResourceLearningRecordMapper, ResourceLearningRecord> implements IResourceLearningRecordService {
@Resource
private ResourceLearningNumberServiceImpl resourceLearningNumberService;
@Override
public BaseResponse<String> 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<Page> 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<ResourceLearningRecord> page = query()
.orderByDesc("times")
.eq("user_id", userId)
.eq("knowledge_id",knowledgeId)
.eq("courses_id",courseId).page(new Page<>(pagenum, pagesize));
Page<ResourceLearingRecordVo> page1 = new Page<>();
List<ResourceLearningRecord> records = page.getRecords();
BeanUtil.copyProperties(page, page1);
List<ResourceLearingRecordVo> 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<String> removeResourceRecord(List<Long> ids) {
removeByIds(ids);
return ResultUtils.success("删除成功!");
}
}

@ -30,7 +30,6 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
List<String> ThisMonthBrowseList = new ArrayList<>();
//存放上个月访问的前一天至前七天的每天对应的浏览量
List<String> LastMonthBrowseList = new ArrayList<>();
//获取今天的日期
LocalDate end = LocalDate.now();
@ -51,7 +50,6 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
//查询上个月的今天对应的浏览量
String lastMonthBrowse = reportMapper.getBrowseByTime(lastMonth);
LastMonthBrowseList.add(lastMonthBrowse);
}

@ -67,7 +67,7 @@ public class ResourceServiceImpl implements ResourceService {
private Neo4jClient neo4jClient;
@Override
public BaseResponse<ResourceUploadDto> upload(MultipartFile file) {
public BaseResponse<Resources> 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<Resources> queryResourcesByCourseId(String courseId){
public BaseResponse<Set<Resources>> queryResourcesByCourseId(String courseId){
// todo 判空,查询
Set<Resources>resourcesSet;
resourcesSet = resourcesRepository.queryResourcesByCourseId(courseId);
return resourcesSet;
return ResultUtils.success(resourcesSet);
}
@Override
//查询章节下资源
public Set<Resources> queryResourcesByChapterId(Long chapterId){
public BaseResponse<Set<Resources>> queryResourcesByChapterId(Long chapterId){
// todo 判空,查询
Set<Resources>resourcesSet ;
resourcesSet = resourcesRepository.queryResourcesByChapterId(chapterId);
return resourcesSet;
return ResultUtils.success(resourcesSet);
}
@Override
//查询二级节点下资源
public Set<Resources> queryBesidesKnowToResources(Long KnowId){
public BaseResponse<Set<Resources>> queryBesidesKnowToResources(Long KnowId){
// todo 判空,查询
Set<Resources>resourcesSet ;
resourcesSet = resourcesRepository.queryBesidesKnowToResources(KnowId);
return resourcesSet;
return ResultUtils.success(resourcesSet);
}

@ -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<UmsStudentManageMapper, UmsStudentManage> implements UmsStudentManageService {
@Autowired
private UmsStudentManageMapper umsStudentManageMapper;
@Autowired
private UmsStudentMapper umsStudentMapper;
@Autowired
private UmsUserMapper umsUserMapper;
@Autowired
private CoursesServiceImpl coursesService;
@Override
public Map<String, Object> pageQuery(UmsStudentPageQueryDTO umsStudentPageQueryDTO) {
LinkedHashSet<UmsStudentManage> umsStudentManages = coursesService.queryTeacherByStudentList(umsStudentPageQueryDTO.getUserId());
//总记录数
int totalCount = umsStudentManages.size();
//总页数
int totalPages = (int) Math.ceil((double) totalCount / umsStudentPageQueryDTO.getPageSize());
List<UmsStudentManage> umsStudentManageList = umsStudentManages.stream()
.skip((umsStudentPageQueryDTO.getPage() - 1) * umsStudentPageQueryDTO.getPageSize())
.limit(umsStudentPageQueryDTO.getPageSize())
.collect(Collectors.toList());
Map<String, Object> 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,"账号状态修改失败");
}
}
}

@ -70,7 +70,7 @@ public class UmsUserServiceImpl extends ServiceImpl<UmsUserMapper, UmsUser> impl
UmsUser umsUser = new UmsUser();
BeanUtils.copyProperties(umsAdminParam, umsUser);
umsUser.setCreateTime(LocalDateTime.now());
umsUser.setStatus(1);
umsUser.setStatus("1");
//查询是否有相同用户名的用户
List<UmsUser> umsAdminList = lambdaQuery()
.eq(UmsUser::getUsername, umsUser.getUsername())
@ -291,7 +291,7 @@ public class UmsUserServiceImpl extends ServiceImpl<UmsUserMapper, UmsUser> impl
UmsUser umsUser = new UmsUser();
BeanUtils.copyProperties(umsUserParam, umsUser);
umsUser.setCreateTime(LocalDateTime.now());
umsUser.setStatus(1);
umsUser.setStatus("1");
//查询是否有相同手机号的用户
List<UmsUser> umsUserList = lambdaQuery()
.eq(UmsUser::getPhone,umsUserParam.getPhone())

@ -26,6 +26,9 @@ public interface KnowtmpService {
BaseResponse<Knowtmp> query(Long id);
//查询通过chapterId List
BaseResponse<List<Knowtmp>> queryByChapterId(Long chapterId);
List<Knowtmp> queryByChapterId(Long chapterId);
//查询通过chapterId List
List<Knowtmp> queryByChapterIdList(List<Long> chapterIdList);
}

@ -28,4 +28,6 @@ public interface ICourseLearningRecordService extends IService<CourseLearningRec
BaseResponse<String> removeCoursesRecords(List<Long> ids);
List<CoursesVO> queryCourseList(String userId);
List<CoursesVO> queryrecommendCourses(String userId);
}

@ -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;
/**
* <p>
* 服务类
* </p>
*
* @author author
* @since 2024-07-29
*/
public interface IResourceLearningNumberService extends IService<ResourceLearningNumber> {
}

@ -20,7 +20,7 @@ import java.util.Set;
public interface ResourceService {
BaseResponse<ResourceUploadDto> upload(MultipartFile file) ;
BaseResponse<Resources> upload(MultipartFile file) ;
BaseResponse<String> delete(String filename) ;
@ -32,13 +32,13 @@ public interface ResourceService {
BaseResponse<String> addResourcesAndKnowById(Long id, List<Long> resourcesIds);
//查询课程下资源
Set<Resources> queryResourcesByCourseId(String courseId);
BaseResponse<Set<Resources>> queryResourcesByCourseId(String courseId);
//查询章节下资源
Set<Resources> queryResourcesByChapterId(Long chapterId);
BaseResponse<Set<Resources>> queryResourcesByChapterId(Long chapterId);
//查询二级节点下资源
Set<Resources> queryBesidesKnowToResources(Long KnowId);
BaseResponse<Set<Resources>> queryBesidesKnowToResources(Long KnowId);
}

@ -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<UmsStudentManage> {
Map<String, Object> pageQuery(UmsStudentPageQueryDTO umsStudentPageQueryDTO);
UmsStudentManage getByIdStudentAndUser(Long id);
void updateStudentAndUser(UmsStudentManage umsStudentManage);
void startOrStop(String status, Long id);
}

@ -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();
}

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.teaching.backend.mapper.umsAdmin.UmsPermissionMapper">
</mapper>

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.teaching.backend.mapper.umsAdmin.UmsStudentManageMapper">
<select id="queryStudent" resultType="com.teaching.backend.model.entity.umsAdmin.UmsStudentManage">
select *
from ums_student us
INNER JOIN ums_user uu ON us.user_id = uu.id
WHERE us.user_id = #{userId}
</select>
<select id="pageQueryStudent" resultType="com.teaching.backend.model.entity.umsAdmin.UmsStudentManage">
select *
from ums_student us
INNER JOIN ums_user uu ON us.user_id = uu.id
<where>
<if test="name != null and name != ''">
and name like concat('%',#{name},'%')
</if>
<if test="number != null and number != ''">
and number like concat('%',#{number},'%')
</if>
</where>
LIMIT #{pageSize} OFFSET #{offset};
</select>
<select id="pageQueryStudentCount" resultType="java.lang.Integer">
SELECT COUNT(*)
FROM ums_student us
INNER JOIN ums_user uu ON us.user_id = uu.id
<where>
<if test="name != null and name != ''">
AND us.name LIKE CONCAT('%', #{name}, '%')
</if>
<if test="number != null and number != ''">
AND us.number LIKE CONCAT('%', #{number}, '%')
</if>
</where>
</select>
<select id="getByIdStudentAndUser" resultType="com.teaching.backend.model.entity.umsAdmin.UmsStudentManage"
parameterType="java.lang.Long">
select *
from ums_student us
INNER JOIN ums_user uu ON us.user_id = uu.id
WHERE us.id = #{id}
</select>
</mapper>

@ -5,34 +5,34 @@
<update id="updateStudentInfo" parameterType="com.teaching.backend.model.entity.umsAdmin.UmsStudent">
update ums_student
<set>
<if test="name != null">
<if test="name != null and name != ''">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="sex != null">
<if test="sex != null and sex != ''">
sex = #{sex},
</if>
<if test="nationality != null">
<if test="nationality != null and nationality != ''">
nationality = #{nationality,jdbcType=VARCHAR},
</if>
<if test="number != null">
<if test="number != null and number != ''">
number = #{number,jdbcType=VARCHAR},
</if>
<if test="birthday != null">
<if test="birthday != null and birthday != ''">
birthday = #{birthday,jdbcType=VARCHAR},
</if>
<if test="phone != null">
<if test="phone != null and phone != ''">
phone = #{phone,jdbcType=TIMESTAMP},
</if>
<if test="faculty != null">
<if test="faculty != null and faculty != ''">
faculty = #{faculty,jdbcType=INTEGER},
</if>
<if test="major != null">
<if test="major != null and major != ''">
major = #{major,jdbcType=INTEGER},
</if>
<if test="yearAge != null">
<if test="yearAge != null and yearAge != ''">
year_age = #{yearAge,jdbcType=INTEGER},
</if>
<if test="className != null">
<if test="className != null and className != ''">
class_name = #{className,jdbcType=INTEGER},
</if>
</set>

@ -5,25 +5,25 @@
<update id="updateUserInformation">
update ums_user
<set>
<if test="username != null">
<if test="username != null and username != ''">
username = #{username,jdbcType=VARCHAR},
</if>
<if test="password != null">
<if test="password != null and password != ''">
password = #{password},
</if>
<if test="phone != null">
<if test="phone != null and phone != ''">
phone = #{phone,jdbcType=VARCHAR},
</if>
<if test="nickName != null">
<if test="nickName != null and nickName != ''">
nick_name = #{nickName,jdbcType=VARCHAR},
</if>
<if test="icon != null">
<if test="icon != null and icon != ''">
icon = #{icon,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
<if test="createTime != null and createTime != ''">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="status != null">
<if test="status != null and status != ''">
status = #{status,jdbcType=INTEGER},
</if>
</set>

@ -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<File> fileList = Arrays.asList(files);
//对分块文件排序
Collections.sort(fileList, new Comparator<File>() {
@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接口合并分块
//批量清理分块文件
}

@ -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<KnowledgeLearningCount> list = knowledgeLearningCountService.query().eq("user_id", userId).list();
// HashSet<KnowledgeLearningCount> 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);
// }
}
}
Loading…
Cancel
Save