diff --git a/pom.xml b/pom.xml
index 19e0375..4e9e452 100644
--- a/pom.xml
+++ b/pom.xml
@@ -227,6 +227,25 @@
commons-lang
2.6
+
+
+
+
+ commons-fileupload
+ commons-fileupload
+ 1.3.1
+
+
+ org.apache.httpcomponents
+ httpcore
+ 4.4.10
+
+
+ org.apache.httpcomponents
+ httpclient
+ 4.5.6
+
+
diff --git a/src/main/java/com/teaching/backend/common/ErrorCode.java b/src/main/java/com/teaching/backend/common/ErrorCode.java
index 4b2a66e..95830fb 100644
--- a/src/main/java/com/teaching/backend/common/ErrorCode.java
+++ b/src/main/java/com/teaching/backend/common/ErrorCode.java
@@ -18,7 +18,7 @@ public enum ErrorCode {
STUDENT_NOT_EXIT(40006, "缺少学生信息"),
COURSES_NOT_EXIT(40007, "缺少课程信息"),
CONTENT_NOT_EXIT(40008, "内容id不存在"),
- KNOWS_EXIT(40009, "该项下面存在关联的知识点"),
+ KNOWS_EXIT(40009, "该项下面存在关联的知识点,请在删除关联的知识点后再来操作!"),
INVALID_ROLE(400010, "角色不存在"),
NOT_LOGIN_ERROR(40100, "未登录"),
diff --git a/src/main/java/com/teaching/backend/config/NonStaticResourceHttpRequestHandler.java b/src/main/java/com/teaching/backend/config/NonStaticResourceHttpRequestHandler.java
new file mode 100644
index 0000000..69b9ac9
--- /dev/null
+++ b/src/main/java/com/teaching/backend/config/NonStaticResourceHttpRequestHandler.java
@@ -0,0 +1,23 @@
+package com.teaching.backend.config;
+
+import org.springframework.core.io.FileSystemResource;
+import org.springframework.core.io.Resource;
+import org.springframework.stereotype.Component;
+import org.springframework.web.servlet.resource.ResourceHttpRequestHandler;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * @author longge93
+ */
+@Component
+public class NonStaticResourceHttpRequestHandler extends ResourceHttpRequestHandler {
+
+ public final static String ATTR_FILE = "NON-STATIC-FILE";
+
+ @Override
+ protected Resource getResource(HttpServletRequest request) {
+ String filePath = (String) request.getAttribute(ATTR_FILE);
+ return new FileSystemResource(filePath);
+ }
+}
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 07fb7f2..7e14395 100644
--- a/src/main/java/com/teaching/backend/controller/courses/CoursesController.java
+++ b/src/main/java/com/teaching/backend/controller/courses/CoursesController.java
@@ -3,19 +3,15 @@ package com.teaching.backend.controller.courses;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.common.CommonResult;
-import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.common.ResultUtils;
-import com.teaching.backend.exception.BusinessException;
-
import com.teaching.backend.filter.ValidateParams;
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.query.CourseQuery;
import com.teaching.backend.model.vo.courses.CoursesVO;
-import com.teaching.backend.model.vo.umsAdmin.UmsStudentVO;
+import com.teaching.backend.model.vo.courses.PersonalCenterStudentListVO;
import com.teaching.backend.service.courses.ICoursesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -24,7 +20,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
-import java.util.*;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.Map;
/**
*
@@ -87,7 +85,6 @@ public class CoursesController {
@ApiOperation("查询课程列表")
@ValidateParams({"userId"})
@GetMapping("/page")
-// @PostMapping("/page")
public BaseResponse> getCourses(CourseQuery courseQuery){
PageDTO coursesList = coursesService.queryCourses(courseQuery);
return ResultUtils.success(coursesList);
@@ -97,9 +94,6 @@ public class CoursesController {
@ValidateParams({"id"})
@GetMapping("/{id}")
public BaseResponse getByIdCourse(@PathVariable String id){
- if(id==null){
- throw new BusinessException(ErrorCode.PARAMS_ERROR,"课程id为空");
- }
Courses course = coursesService.getById(id);
CoursesDTO coursesDTO = new CoursesDTO();
BeanUtils.copyProperties(course,coursesDTO);
@@ -114,16 +108,12 @@ public class CoursesController {
return ResultUtils.success("编辑成功");
}
- //TODO:删除功能暂未完善,数据缺失
- // 暂时发现有个漏洞 就是目标关联的有知识点的时候还是可以直接删除
- // (当有内容的时候本来就是得先删除内容--关联也有知识点 所以内容下面的不用校验 )
@ApiOperation("根据id删除课程")
@ValidateParams({"id"})
@DeleteMapping("/{id}")
public BaseResponse deleteCourses(@PathVariable String id){
coursesService.deleteBatchByIds(id);
-// coursesService.removeBatchByIds(ids);
return ResultUtils.success("删除成功");
}
@@ -142,8 +132,8 @@ public class CoursesController {
@ApiOperation("查询学生列表")
@PostMapping("/studentList")
- public CommonResult> getStudentList(CourseQuery courseQuery){
- LinkedHashSet umsStudentList = coursesService.queryStudentList(courseQuery);
+ public CommonResult> getStudentList(@RequestParam String userId){
+ LinkedHashSet umsStudentList = coursesService.queryStudentList(userId);
return CommonResult.success(umsStudentList);
}
diff --git a/src/main/java/com/teaching/backend/controller/courses/ObjectiveContentsController.java b/src/main/java/com/teaching/backend/controller/courses/ObjectiveContentsController.java
index 17a9462..cbe1c5e 100644
--- a/src/main/java/com/teaching/backend/controller/courses/ObjectiveContentsController.java
+++ b/src/main/java/com/teaching/backend/controller/courses/ObjectiveContentsController.java
@@ -39,7 +39,6 @@ public class ObjectiveContentsController {
@ValidateParams({"id"})
@DeleteMapping("/{id}")
public BaseResponse deleteContent(@PathVariable String id){
-// objectiveContentsService.removeById(id);
String data = objectiveContentsService.deleteById(id);
return ResultUtils.success(data);
}
diff --git a/src/main/java/com/teaching/backend/controller/favour/SeCourseFavourController.java b/src/main/java/com/teaching/backend/controller/favour/SeCourseFavourController.java
index 5a61c49..fe2548b 100644
--- a/src/main/java/com/teaching/backend/controller/favour/SeCourseFavourController.java
+++ b/src/main/java/com/teaching/backend/controller/favour/SeCourseFavourController.java
@@ -99,8 +99,8 @@ public class SeCourseFavourController {
*/
@ApiOperation("查询最新收藏")
@PostMapping("/newCollect")
- public CommonResult newCollect(@RequestParam String userId) {
- CoursesVO newCoursesVO = seCourseFavourService.queryNewCollect(userId);
+ public CommonResult> newCollect(@RequestParam String userId) {
+ List newCoursesVO = seCourseFavourService.queryNewCollect(userId);
if (newCoursesVO == null){
CommonResult.failed("用户或角色错误");
}
diff --git a/src/main/java/com/teaching/backend/controller/records/BaseSourceApiController.java b/src/main/java/com/teaching/backend/controller/records/BaseSourceApiController.java
new file mode 100644
index 0000000..5253649
--- /dev/null
+++ b/src/main/java/com/teaching/backend/controller/records/BaseSourceApiController.java
@@ -0,0 +1,46 @@
+package com.teaching.backend.controller.records;
+
+import com.teaching.backend.config.NonStaticResourceHttpRequestHandler;
+import org.mybatis.logging.Logger;
+import org.mybatis.logging.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.nio.charset.StandardCharsets;
+
+@RestController
+@RequestMapping(value = "/api/baseResource")
+public class BaseSourceApiController {
+
+
+ @Autowired
+ private NonStaticResourceHttpRequestHandler nonStaticResourceHttpRequestHandler;
+
+
+ private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+ @RequestMapping(value = "/video", method = RequestMethod.GET)
+ public void video(
+ HttpServletRequest request,
+ HttpServletResponse response
+ ) {
+ try {
+ String path = "D:/Users/Desktop/image/剪映/7.18/7月20.mp4";
+ File file = new File(path);
+ if (file.exists()) {
+ request.setAttribute(NonStaticResourceHttpRequestHandler.ATTR_FILE, path);
+ nonStaticResourceHttpRequestHandler.handleRequest(request, response);
+ } else {
+ response.setStatus(HttpServletResponse.SC_NOT_FOUND);
+ response.setCharacterEncoding(StandardCharsets.UTF_8.toString());
+ }
+ } catch (Exception e) {
+
+ }
+ }
+}
diff --git a/src/main/java/com/teaching/backend/controller/records/Bf.java b/src/main/java/com/teaching/backend/controller/records/Bf.java
new file mode 100644
index 0000000..f0a8d95
--- /dev/null
+++ b/src/main/java/com/teaching/backend/controller/records/Bf.java
@@ -0,0 +1,56 @@
+package com.teaching.backend.controller.records;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.FileInputStream;
+import java.io.OutputStream;
+
+@RestController
+@RequestMapping("/api/bf")
+public class Bf {
+ /**
+ * 根据本地图片全路径,响应给浏览器1个图片流
+ */
+ @RequestMapping("/showImage")
+ public void showImage(HttpServletResponse response, @RequestParam("fileName")String fileName) {
+ System.out.println(fileName);
+ show(response,fileName,"image");
+ }
+
+ /**
+ * 根据本地视频全路径,响应给浏览器1个视频
+ */
+ @RequestMapping("/showVideo")
+ public void showVideo(HttpServletResponse response, @RequestParam("fileName")String fileName) {
+ show(response,fileName,"video");
+ }
+
+ /**
+ * 响应文件
+ * @param response
+ * @param fileName 文件全路径
+ * @param type 响应流类型
+ */
+ public void show(HttpServletResponse response, String fileName,String type){
+ try{
+ FileInputStream fis = new FileInputStream(fileName); // 以byte流的方式打开文件
+ int i=fis.available(); //得到文件大小
+ System.out.println(i);
+ byte data[]=new byte[i];
+ fis.read(data); //读数据
+ response.setContentType(type+"/*"); //设置返回的文件类型
+ OutputStream toClient=response.getOutputStream(); //得到向客户端输出二进制数据的对象
+ toClient.write(data); //输出数据
+ toClient.flush();
+ toClient.close();
+ fis.close();
+ }catch(Exception e){
+ e.printStackTrace();
+ System.out.println("文件不存在");
+ }
+ }
+}
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 808cb8e..ed7b1b3 100644
--- a/src/main/java/com/teaching/backend/controller/records/CourseLearningRecordController.java
+++ b/src/main/java/com/teaching/backend/controller/records/CourseLearningRecordController.java
@@ -61,7 +61,7 @@ public class CourseLearningRecordController {
* 个人中心课程列表
* @return
*/
- @ApiOperation("查询前4的课程")
+ @ApiOperation("按新旧排序查询的课程列表")
@PostMapping("/courseList")
public CommonResult> courseList(@RequestParam String userId) {
List coursesVOList = courseLearningRecordService.queryCourseList(userId);
diff --git a/src/main/java/com/teaching/backend/controller/records/KnowledgeLearningRecordController.java b/src/main/java/com/teaching/backend/controller/records/KnowledgeLearningRecordController.java
index da94b8d..f723a2d 100644
--- a/src/main/java/com/teaching/backend/controller/records/KnowledgeLearningRecordController.java
+++ b/src/main/java/com/teaching/backend/controller/records/KnowledgeLearningRecordController.java
@@ -1,24 +1,28 @@
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.CommonResult;
import com.teaching.backend.common.ResultUtils;
import com.teaching.backend.filter.ValidateParams;
+import com.teaching.backend.mapper.records.KnowledgeLearningRecordMapper;
import com.teaching.backend.model.entity.records.CourseLearningRecord;
import com.teaching.backend.model.entity.records.KnowledgeLearningRecord;
+import com.teaching.backend.model.vo.knowGraph.KnowVO;
import com.teaching.backend.service.impl.records.KnowledgeLearningRecordServiceImpl;
import io.swagger.annotations.ApiOperation;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
+import java.util.List;
@RestController
@RequestMapping("/api/knowledgelearning")
public class KnowledgeLearningRecordController {
@Resource
private KnowledgeLearningRecordServiceImpl knowledgeLearningRecordService;
+ @Resource
+ private KnowledgeLearningRecordMapper knowledgeLearningRecordMapper;
@ApiOperation("添加知识点学习记录")
// @ValidateParams({"userId","type","coursesId"})
@@ -27,4 +31,58 @@ public class KnowledgeLearningRecordController {
return knowledgeLearningRecordService.saveCoursesRecords(knowledgeLearningRecord);
}
+ /**
+ * 获取当前登录用户的学习知识点记录
+ * @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){
+ return knowledgeLearningRecordService.getPage(pagenum, pagesize, userId, courseId);
+ }
+
+ /**
+ * 根据ids删除
+ * @param ids
+ * @return
+ */
+ @ApiOperation("学习记录删除")
+ @DeleteMapping("/delete")
+ public BaseResponse deleteRecords(@RequestParam List ids){
+ return knowledgeLearningRecordService.removeKnowledgeRecord(ids);
+ }
+
+ /**
+ * 统计单个学生学习知识点数量
+ * @param userId
+ * @return
+ */
+ @ApiOperation("统计单个学生学习知识点数量")
+ @GetMapping("/countknowledgenumber")
+ public BaseResponse countKnowledgeNumber(@RequestParam String userId) {
+ return ResultUtils.success(knowledgeLearningRecordMapper.selectDistinctKnowledgeIdsByUser(userId).size());
+ }
+
+ /**
+ * 获取学习最多的知识点
+ *
+ * @return
+ */
+ @ApiOperation("查询学习最多的知识点")
+ @PostMapping("/studyMaxKnowledge")
+ public CommonResult> studyMaxKnowledge(@RequestParam String userId) {
+ List knowVO = knowledgeLearningRecordService.queryMaxKnowledge(userId);
+ if (knowVO == null){
+ CommonResult.failed("用户或角色错误");
+ }
+ return CommonResult.success(knowVO);
+ }
+
+
}
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 77adf9d..e025d4d 100644
--- a/src/main/java/com/teaching/backend/controller/records/ResourceLearningRecordController.java
+++ b/src/main/java/com/teaching/backend/controller/records/ResourceLearningRecordController.java
@@ -1,29 +1,102 @@
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.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+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);
+ };
-// @ApiOperation("添加资源学习记录")
-//// @ValidateParams({"userId","type","coursesId"})
-// @PostMapping("/saverecords")
-// public BaseResponse saveResourceRecords(@RequestBody ResourceLearningRecord resourceLearningRecord) {
-// return resourceLearningRecordService.saveCoursesRecords(resourceLearningRecord);
-// }
}
diff --git a/src/main/java/com/teaching/backend/controller/umsAdmin/ReportController.java b/src/main/java/com/teaching/backend/controller/umsAdmin/ReportController.java
index 15b86c9..439ea74 100644
--- a/src/main/java/com/teaching/backend/controller/umsAdmin/ReportController.java
+++ b/src/main/java/com/teaching/backend/controller/umsAdmin/ReportController.java
@@ -33,11 +33,11 @@ public class ReportController {
* 接收每日浏览量
* @return
*/
- @PostMapping("/receptionBrowse")
+ @GetMapping("/receptionBrowse")
@ApiOperation("接收每日浏览量")
- public CommonResult receptionBrowse(@RequestBody ReportDTO reportDTO){
+ public CommonResult receptionBrowse(){
- boolean receptionBrowse = reportService.getReceptionBrowse(reportDTO);
+ boolean receptionBrowse = reportService.getReceptionBrowse();
if (receptionBrowse == false){
return CommonResult.failed();
}
diff --git a/src/main/java/com/teaching/backend/mapper/favour/SeCourseFavourMapper.java b/src/main/java/com/teaching/backend/mapper/favour/SeCourseFavourMapper.java
index 3c9c766..55adb81 100644
--- a/src/main/java/com/teaching/backend/mapper/favour/SeCourseFavourMapper.java
+++ b/src/main/java/com/teaching/backend/mapper/favour/SeCourseFavourMapper.java
@@ -4,15 +4,17 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.teaching.backend.model.entity.courses.Courses;
import com.teaching.backend.model.entity.favour.SeCourseFavour;
+import java.util.List;
+
/**
* 课程点赞数据库操作
*/
public interface SeCourseFavourMapper extends BaseMapper {
- String queryAllNewCollectCourse();
+ List queryAllNewCollectCourse();
- String queryStudentNewCollectCourse(String userId);
+ List queryStudentNewCollectCourse(String userId);
}
diff --git a/src/main/java/com/teaching/backend/mapper/records/KnowledgeLearningRecordMapper.java b/src/main/java/com/teaching/backend/mapper/records/KnowledgeLearningRecordMapper.java
index d9dbbe5..2ddda90 100644
--- a/src/main/java/com/teaching/backend/mapper/records/KnowledgeLearningRecordMapper.java
+++ b/src/main/java/com/teaching/backend/mapper/records/KnowledgeLearningRecordMapper.java
@@ -3,6 +3,12 @@ package com.teaching.backend.mapper.records;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.teaching.backend.model.entity.records.KnowledgeLearningRecord;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.List;
+
+import java.util.List;
/**
*
@@ -14,4 +20,9 @@ import com.teaching.backend.model.entity.records.KnowledgeLearningRecord;
*/
public interface KnowledgeLearningRecordMapper extends BaseMapper {
+ @Select("SELECT knowledge_id FROM knowledge_learning_record WHERE user_id = #{userId} GROUP BY knowledge_id")
+ List selectDistinctKnowledgeIdsByUser(@Param("userId") String userId);
+ List queryStudyKnowledgeMaxNumber();
+
+ List queryStudyMaxKnowledgeId(String userId);
}
diff --git a/src/main/java/com/teaching/backend/mapper/records/ResourceLearningRecordMapper.java b/src/main/java/com/teaching/backend/mapper/records/ResourceLearningRecordMapper.java
index c1235c1..4f7151f 100644
--- a/src/main/java/com/teaching/backend/mapper/records/ResourceLearningRecordMapper.java
+++ b/src/main/java/com/teaching/backend/mapper/records/ResourceLearningRecordMapper.java
@@ -3,6 +3,10 @@ package com.teaching.backend.mapper.records;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.teaching.backend.model.entity.records.ResourceLearningRecord;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.List;
/**
*
@@ -13,5 +17,7 @@ import com.teaching.backend.model.entity.records.ResourceLearningRecord;
* @since 2024-07-24
*/
public interface ResourceLearningRecordMapper extends BaseMapper {
+ @Select("SELECT resource_id FROM resource_learning_record WHERE user_id = #{userId} GROUP BY resource_id")
+ List selectDistinctResourceIdsByUser(@Param("userId") String userId);
}
diff --git a/src/main/java/com/teaching/backend/model/dto/upload/UploadFileParamsDto.java b/src/main/java/com/teaching/backend/model/dto/upload/UploadFileParamsDto.java
new file mode 100644
index 0000000..c5a84bf
--- /dev/null
+++ b/src/main/java/com/teaching/backend/model/dto/upload/UploadFileParamsDto.java
@@ -0,0 +1,32 @@
+package com.teaching.backend.model.dto.upload;
+
+import lombok.Data;
+
+@Data
+public class UploadFileParamsDto {
+ /**
+ * 文件名称
+ */
+ private String filename;
+
+ /**
+ * 文件类型(文档,音频,视频)
+ */
+ private String fileType;
+ /**
+ * 文件大小
+ */
+ private Long fileSize;
+ /**
+ * 标签
+ */
+ private String tags;
+ /**
+ * 上传人
+ */
+ private String username;
+ /**
+ * 备注
+ */
+ private String remark;
+}
diff --git a/src/main/java/com/teaching/backend/model/entity/records/KnowledgeLearningRecord.java b/src/main/java/com/teaching/backend/model/entity/records/KnowledgeLearningRecord.java
index 7d1f11c..37b4cab 100644
--- a/src/main/java/com/teaching/backend/model/entity/records/KnowledgeLearningRecord.java
+++ b/src/main/java/com/teaching/backend/model/entity/records/KnowledgeLearningRecord.java
@@ -37,8 +37,8 @@ public class KnowledgeLearningRecord implements Serializable {
@TableField("knowledge_id")
private String knowledgeId;
- @ApiModelProperty(value = "知识点id")
- @TableField("knowledge_id")
+ @ApiModelProperty(value = "知识点名称")
+ @TableField("knowledge_name")
private String knowledgeName;
@ApiModelProperty(value = "课程id")
diff --git a/src/main/java/com/teaching/backend/model/entity/records/ResourceLearningRecord.java b/src/main/java/com/teaching/backend/model/entity/records/ResourceLearningRecord.java
index c33d691..d7dd115 100644
--- a/src/main/java/com/teaching/backend/model/entity/records/ResourceLearningRecord.java
+++ b/src/main/java/com/teaching/backend/model/entity/records/ResourceLearningRecord.java
@@ -37,6 +37,10 @@ public class ResourceLearningRecord implements Serializable {
@TableField("resource_id")
private String resourceId;
+ @ApiModelProperty(value = "资源名称")
+ @TableField("resource_name")
+ private String resourceName;
+
@ApiModelProperty(value = "知识点id")
@TableField("knowledge_id")
private String knowledgeId;
diff --git a/src/main/java/com/teaching/backend/model/vo/courses/PersonalCenterStudentListVO.java b/src/main/java/com/teaching/backend/model/vo/courses/PersonalCenterStudentListVO.java
new file mode 100644
index 0000000..e0fe434
--- /dev/null
+++ b/src/main/java/com/teaching/backend/model/vo/courses/PersonalCenterStudentListVO.java
@@ -0,0 +1,44 @@
+package com.teaching.backend.model.vo.courses;
+
+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;
+import java.util.List;
+
+/**
+ *
+ *
+ *
+ *
+ * @author zjh
+ * @since 2024-06-12
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class PersonalCenterStudentListVO implements Serializable {
+
+
+ /**
+ * 头像
+ */
+ private String icon;
+
+ /**
+ * 姓名
+ */
+ private String name;
+
+ /**
+ * 学号
+ */
+ private String number;
+
+}
diff --git a/src/main/java/com/teaching/backend/model/vo/knowGraph/KnowVO.java b/src/main/java/com/teaching/backend/model/vo/knowGraph/KnowVO.java
index d6a60a2..beaa1a2 100644
--- a/src/main/java/com/teaching/backend/model/vo/knowGraph/KnowVO.java
+++ b/src/main/java/com/teaching/backend/model/vo/knowGraph/KnowVO.java
@@ -3,7 +3,6 @@ package com.teaching.backend.model.vo.knowGraph;
import lombok.Data;
import java.io.Serializable;
-import java.util.List;
@Data
diff --git a/src/main/java/com/teaching/backend/model/vo/records/CourseLearningRecordsVo.java b/src/main/java/com/teaching/backend/model/vo/records/CourseLearningRecordsVo.java
index 1260a73..acd047f 100644
--- a/src/main/java/com/teaching/backend/model/vo/records/CourseLearningRecordsVo.java
+++ b/src/main/java/com/teaching/backend/model/vo/records/CourseLearningRecordsVo.java
@@ -17,6 +17,10 @@ public class CourseLearningRecordsVo {
* 课程学习id
*/
private String id;
+ /**
+ * 课程id
+ */
+ private String courseId;
/**
* 课程名称
*/
diff --git a/src/main/java/com/teaching/backend/model/vo/records/KnowledgeLearningRecordVo.java b/src/main/java/com/teaching/backend/model/vo/records/KnowledgeLearningRecordVo.java
new file mode 100644
index 0000000..c550f19
--- /dev/null
+++ b/src/main/java/com/teaching/backend/model/vo/records/KnowledgeLearningRecordVo.java
@@ -0,0 +1,37 @@
+package com.teaching.backend.model.vo.records;
+
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+
+@Data
+@ApiModel(description = "知识点学习记录")
+public class KnowledgeLearningRecordVo {
+ /**
+ * 知识点学习id
+ */
+ private String id;
+ /**
+ * 课程id
+ */
+ private String coursesId;
+ /**
+ * 知识点id
+ */
+ private String knowledgeId;
+ /**
+ * 知识点名称
+ */
+ private String knowledgeName;
+ /**
+ * 用户id
+ */
+ private String userId;
+ /**
+ * 学习人数
+ */
+ private Integer number;
+ /**
+ * 学习时间
+ */
+ private String time;
+}
diff --git a/src/main/java/com/teaching/backend/model/vo/records/ResourceLearingRecordVo.java b/src/main/java/com/teaching/backend/model/vo/records/ResourceLearingRecordVo.java
new file mode 100644
index 0000000..09a738e
--- /dev/null
+++ b/src/main/java/com/teaching/backend/model/vo/records/ResourceLearingRecordVo.java
@@ -0,0 +1,29 @@
+package com.teaching.backend.model.vo.records;
+
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+
+@Data
+@ApiModel(description = "资源学习记录")
+public class ResourceLearingRecordVo {
+ /**
+ * 资源学习id
+ */
+ private String id;
+ /**
+ * 资源名称
+ */
+ private String resourceName;
+ /**
+ * 用户id
+ */
+ private String userId;
+ /**
+ * 学习人数
+ */
+ private Integer number;
+ /**
+ * 学习时间
+ */
+ private String time;
+}
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 9a06641..dcd643c 100644
--- a/src/main/java/com/teaching/backend/service/courses/ICoursesService.java
+++ b/src/main/java/com/teaching/backend/service/courses/ICoursesService.java
@@ -8,6 +8,7 @@ import com.teaching.backend.model.entity.courses.Courses;
import com.teaching.backend.model.entity.umsAdmin.UmsStudent;
import com.teaching.backend.model.query.CourseQuery;
import com.teaching.backend.model.vo.courses.CoursesVO;
+import com.teaching.backend.model.vo.courses.PersonalCenterStudentListVO;
import com.teaching.backend.model.vo.umsAdmin.UmsStudentVO;
import javax.servlet.http.HttpServletResponse;
@@ -46,5 +47,5 @@ public interface ICoursesService extends IService {
Map getPagePageSize2(int page, int pageSize);
- LinkedHashSet queryStudentList(CourseQuery courseQuery);
+ LinkedHashSet queryStudentList(String userId);
}
diff --git a/src/main/java/com/teaching/backend/service/favour/SeCourseFavourService.java b/src/main/java/com/teaching/backend/service/favour/SeCourseFavourService.java
index 9723cbf..a8d1076 100644
--- a/src/main/java/com/teaching/backend/service/favour/SeCourseFavourService.java
+++ b/src/main/java/com/teaching/backend/service/favour/SeCourseFavourService.java
@@ -61,5 +61,5 @@ public interface SeCourseFavourService extends IService {
* @param userId
* @return
*/
- CoursesVO queryNewCollect(String userId);
+ List queryNewCollect(String userId);
}
diff --git a/src/main/java/com/teaching/backend/service/impl/courses/CourseObjectivesServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/courses/CourseObjectivesServiceImpl.java
index f5682e6..435f710 100644
--- a/src/main/java/com/teaching/backend/service/impl/courses/CourseObjectivesServiceImpl.java
+++ b/src/main/java/com/teaching/backend/service/impl/courses/CourseObjectivesServiceImpl.java
@@ -25,6 +25,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import static com.teaching.backend.utils.CourseCode.TOTAL_OBJECTIVE_HAS_NO_CHILD;
+
/**
*
* 服务实现类
@@ -54,33 +56,33 @@ public class CourseObjectivesServiceImpl extends ServiceImpl()
.eq(CourseObjectives::getPid, pid)
.eq(CourseObjectives::getType, type));
+
if (count==CourseCode.OBJECTIVE_EXIT.getValue()){
throw new BusinessException(ErrorCode.CONTENT_EXISTS,"该类型的目标已存在,禁止重复添加!");
}
- if (type!=CourseCode.SI_ZHENG_TYPE.getValue()){
+
+ if (!type.equals(CourseCode.SI_ZHENG_TYPE.getValue())){
Long sz = SZ_EXIT(courseObjectivesDTO);
if (sz!=CourseCode.SI_ZHENG_EXIT.getValue()){
throw new BusinessException(ErrorCode.PARAMS_ILLEGAL,"请在添加完思政目标以后再添加此类型目标!");
}
}
- courseObjectivesMapper.insert(courseObjectivesNew);
+ //插入新的课程目标
+ int insert = courseObjectivesMapper.insert(courseObjectivesNew);
+ //插入数据以后要把总体目标那边的haschild改成1
+ if (insert>0){
+ CourseObjectives courseObjectivesOld = courseObjectivesMapper.selectById(pid);
+ if (courseObjectivesOld.getHasChild() == TOTAL_OBJECTIVE_HAS_NO_CHILD.getValue()) {
+ courseObjectivesOld.setHasChild(1);
+ courseObjectivesMapper.updateById(courseObjectivesOld);
+ }
+ }
return "添加成功";
-
- //往表里面写分项目标
-// courseObjectivesMapper.insert(courseObjectivesNew);
-// //插入数据以后要把总体目标那边的haschild改成1
-// CourseObjectives courseObjectivesOld = courseObjectivesMapper.selectById(pid);
-// courseObjectivesOld.setHasChild(1);
-// courseObjectivesMapper.updateById(courseObjectivesOld);
}
private Long SZ_EXIT(CourseObjectivesDTO courseObjectivesDTO) {
@@ -110,7 +112,7 @@ public class CourseObjectivesServiceImpl extends ServiceImpl()
.eq(ObjectiveContentKnow::getObjectiveOrContent, id));
if(count > CourseCode.KNOWS_EXIT.getValue()){
@@ -121,9 +123,9 @@ public class CourseObjectivesServiceImpl extends ServiceImpl queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CourseObjectives::getPid, pid);
Long countSZ = courseObjectivesMapper.selectCount(queryWrapper);
- if (countSZ==CourseCode.SI_ZHENG_EXIT.getValue()){
+ if (countSZ.equals(CourseCode.SI_ZHENG_EXIT.getValue())){
Long countContentsSZ = getCount(id);
- if (countContentsSZ<(CourseCode.CONTENT_EXIT.getValue()))
+ if (countContentsSZ == (CourseCode.CONTENT_EXIT.getValue()))
{
// 删除操作和更新父目标状态
deleteObjectiveAndUpdateParent(id, pid);
@@ -140,7 +142,7 @@ public class CourseObjectivesServiceImpl extends ServiceImpl impl
@Override
@Transactional
public String saveCourseWithObjective(CoursesDTO coursesDTO) {
-// String teacher = coursesDTO.getTeacher();
-// if (teacher == null || teacher.equals("")) {
-// throw new BusinessException(ErrorCode.USERNAME_NOT_EXIT);
-// }
+ // 初始化并生成新的课程ID
Courses courses = new Courses();
String courseId = UUID.randomUUID().toString().replace("-", "");
- CourseObjectives courseObjectives = new CourseObjectives();
+ // 拷贝属性并设置创建时间和ID
BeanUtils.copyProperties(coursesDTO, courses);
courses.setCreateTime(LocalDateTime.now());
courses.setId(courseId);
+
+ // 检查课程代码是否已存在
String code = coursesDTO.getCode();
- QueryWrapper queryWrapper = new QueryWrapper<>();
- queryWrapper.eq("code", code);
- Long count = coursesMapper.selectCount(queryWrapper);
- if (count == 0) {
- int insert = coursesMapper.insert(courses);
- if (insert > 0) {
- Courses coursesNew = coursesMapper.selectById(courseId);
- courseObjectives.setCourseId(courseId);
- courseObjectives.setType(CourseCode.TOTAL_OBJECTIVE_TYPE.getValue());
-// courseObjectives.setName(coursesNew.getName() + "课程总体目标");
- int insertTotal = courseObjectivesMapper.insert(courseObjectives);
- if (insertTotal>0){
- CourseObjectives courseTotalObjectives = courseObjectivesMapper.selectOne
- (new LambdaQueryWrapper().eq(CourseObjectives::getCourseId, courseId));
- String courseTotalObjectivesId = courseTotalObjectives.getId();
- List objectivesTypes = objectivesTypeMapper.selectList(new LambdaQueryWrapper());
- ArrayList courseObjectivesFList = new ArrayList<>();
- CourseObjectives courseObjectivesF = null;
- for (ObjectivesType objectivesType : objectivesTypes) {
- Integer typeId = objectivesType.getId();
- if (!typeId.equals(CourseCode.TOTAL_OBJECTIVE_TYPE.getValue())){
-// String typeName = objectivesType.getTypeName();
- courseObjectivesF = new CourseObjectives();
- courseObjectivesF.setType(typeId);
-// courseObjectivesF.setName(typeName);
- courseObjectivesF.setPid(courseTotalObjectivesId);
- courseObjectivesFList.add(courseObjectivesF);
- }
- }
- courseObjectivesMapper.insertBatch(courseObjectivesFList);
- courseTotalObjectives.setHasChild(1);
- courseObjectivesMapper.updateById(courseTotalObjectives);
- }
- }
- return "添加成功";
- } else {
+ Long count = query().eq("code", code).count();
+ if (count > 0) {
throw new BusinessException(ErrorCode.OPERATION_ERROR, "这个课程已经存在了!请联系系统相关人员为您导入课程数据!");
}
+ // 插入课程信息
+ int insert = coursesMapper.insert(courses);
+ if (insert <= 0) {
+ throw new BusinessException(ErrorCode.OPERATION_ERROR, "课程插入失败!");
+ }
+
+ // 插入课程目标信息
+ CourseObjectives courseObjectives = new CourseObjectives();
+ courseObjectives.setCourseId(courseId);
+ courseObjectives.setType(CourseCode.TOTAL_OBJECTIVE_TYPE.getValue());
+ int insertTotal = courseObjectivesMapper.insert(courseObjectives);
+ if (insertTotal <= 0) {
+ throw new BusinessException(ErrorCode.OPERATION_ERROR, "课程目标插入失败!");
+ }
+
+ // 获取插入后的课程目标信息
+ CourseObjectives courseTotalObjectives = courseObjectivesMapper.selectOne(
+ new LambdaQueryWrapper().eq(CourseObjectives::getCourseId, courseId)
+ );
+ String courseTotalObjectivesId = courseTotalObjectives.getId();
+
+ // 获取所有目标类型并插入子目标
+ List objectivesTypes = objectivesTypeMapper.selectList(new LambdaQueryWrapper<>());
+ ArrayList courseObjectivesFList = new ArrayList<>();
+ for (ObjectivesType objectivesType : objectivesTypes) {
+ if (!objectivesType.getId().equals(CourseCode.TOTAL_OBJECTIVE_TYPE.getValue())) {
+ CourseObjectives courseObjectivesF = new CourseObjectives();
+ courseObjectivesF.setType(objectivesType.getId());
+ courseObjectivesF.setPid(courseTotalObjectivesId);
+ courseObjectivesFList.add(courseObjectivesF);
+ }
+ }
+
+ // 批量插入子目标并更新父目标的hasChild字段
+ if (!courseObjectivesFList.isEmpty()) {
+ courseObjectivesMapper.insertBatch(courseObjectivesFList);
+ courseTotalObjectives.setHasChild(1);
+ courseObjectivesMapper.updateById(courseTotalObjectives);
+ }
+
+ return "添加成功";
}
+
@Override
public PageDTO queryCourses(CourseQuery courseQuery) {
-// int roleId = Integer.parseInt(umsUserMapper.selectOne(new LambdaQueryWrapper()
-// .eq(UmsUser::getUsername, courseQuery.getUsername())).getRoleId());
UmsUser umsUser = umsUserMapper.selectById(courseQuery.getUserId());
if (umsUser == null){
throw new BusinessException(ErrorCode.PARAMS_USER_NOTEXISTS);
@@ -184,9 +191,11 @@ public class CoursesServiceImpl extends ServiceImpl impl
Page p = lambdaQuery()
.like(courseQuery.getName() != null, Courses::getName, courseQuery.getName())
.apply("FIND_IN_SET({0}, teacher)", courseQuery.getUserId())
- .eq(courseQuery.getCategory() != null && !courseQuery.getCategory().isEmpty(), Courses::getCategory, courseQuery.getCategory())
+ .eq(StringUtils.hasText(courseQuery.getCategory()), Courses::getCategory, courseQuery.getCategory())
+// .eq(courseQuery.getCategory() != null && !courseQuery.getCategory().isEmpty(), Courses::getCategory, courseQuery.getCategory())
.eq(courseQuery.getNature() != null && !courseQuery.getNature().isEmpty(), Courses::getNature, courseQuery.getNature())
.eq(courseQuery.getAssessmenttype() != null &&!courseQuery.getAssessmenttype().isEmpty(), Courses::getAssessmenttype, courseQuery.getAssessmenttype())
+ .select(Courses::getId,Courses::getTeacher,Courses::getImg,Courses::getName,Courses::getCredit,Courses::getClasshours)
.page(page);
return PageDTO.of(p,CoursesVO.class);
}
@@ -201,6 +210,7 @@ public class CoursesServiceImpl extends ServiceImpl impl
Page p = lambdaQuery()
.like(courseQuery.getName() != null, Courses::getName, courseQuery.getName())
.in(Courses::getId, coursesList)
+ .select(Courses::getId,Courses::getTeacher,Courses::getImg,Courses::getName,Courses::getCredit,Courses::getClasshours)
.page(page);
return PageDTO.of(p, CoursesVO.class);
}
@@ -212,6 +222,7 @@ public class CoursesServiceImpl extends ServiceImpl impl
.eq(courseQuery.getNature() != null && !courseQuery.getNature().isEmpty(), Courses::getNature, courseQuery.getNature())
.eq(courseQuery.getAssessmenttype() != null &&!courseQuery.getAssessmenttype().isEmpty(), Courses::getAssessmenttype, courseQuery.getAssessmenttype())
.apply(courseQuery.getTeacher() != null && !courseQuery.getTeacher().isEmpty(), "FIND_IN_SET({0}, teacher)", courseQuery.getTeacher())
+ .select(Courses::getId,Courses::getTeacher,Courses::getImg,Courses::getName,Courses::getCredit,Courses::getClasshours)
.page(page);
return PageDTO.of(p, CoursesVO.class);
}
@@ -339,13 +350,15 @@ public class CoursesServiceImpl extends ServiceImpl impl
}
@Override
- public LinkedHashSet queryStudentList(CourseQuery courseQuery) {
- String roleId = umsUserMapper.getbyIdRoleId(courseQuery.getUserId());
+ public LinkedHashSet queryStudentList(String userId) {
+ String roleId = umsUserMapper.getbyIdRoleId(userId);
+ CourseQuery courseQuery = new CourseQuery();
+ courseQuery.setUserId(userId);
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<>();
+ LinkedHashSet studentNameList = new LinkedHashSet<>();
for (String courseId : courseIds) {
List studentUsernames = studentCoursesMapper.selectBatchSomeStudent(courseId);
List courseLearningRecordList = new ArrayList<>();
@@ -356,7 +369,12 @@ 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()));
- studentNameList.add(umsStudent);
+ 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);
}
}
return studentNameList;
diff --git a/src/main/java/com/teaching/backend/service/impl/courses/ObjectiveContentKnowServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/courses/ObjectiveContentKnowServiceImpl.java
index f62b99a..13720df 100644
--- a/src/main/java/com/teaching/backend/service/impl/courses/ObjectiveContentKnowServiceImpl.java
+++ b/src/main/java/com/teaching/backend/service/impl/courses/ObjectiveContentKnowServiceImpl.java
@@ -18,6 +18,7 @@ import com.teaching.backend.service.courses.IObjectiveContentKnowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.math.RoundingMode;
@@ -71,7 +72,6 @@ public class ObjectiveContentKnowServiceImpl extends ServiceImpl objectiveContentKnows = objectiveContentKnowMapper.selectList(
new LambdaQueryWrapper()
.eq(ObjectiveContentKnow::getObjectiveOrContent, objectiveOrContentId));
@@ -105,16 +100,16 @@ public class ObjectiveContentKnowServiceImpl extends ServiceImpl objectiveContents = objectiveContentsMapper.selectList(
- new LambdaQueryWrapper()
+ List objectiveContents = objectiveContentsMapper.selectList(new LambdaQueryWrapper()
.eq(ObjectiveContents::getObjectiveId, objectiveOrContentId));
// 如果存在分项目标内容,处理并计算每个内容的相关数据
- if (objectiveContents != null && !objectiveContents.isEmpty()) {
+ if (!CollectionUtils.isEmpty(objectiveContents)) {
List contentKnowVOs = objectiveContents.stream()
.map(content -> createObjectiveContentKnowVO(content.getId(), objectiveContentKnowMapper.selectList(
new LambdaQueryWrapper()
@@ -123,10 +118,10 @@ public class ObjectiveContentKnowServiceImpl extends ServiceImpl {
- BigDecimal contentPercentage = calculatePercentage(contentKnowVO.getKnowsTime(), classhours);
- contentKnowVO.setPersent(contentPercentage + "%");
- });
+// contentKnowVOs.forEach(contentKnowVO -> {
+// BigDecimal contentPercentage = calculatePercentage(contentKnowVO.getKnowsTime(), classhours);
+// contentKnowVO.setPersent(contentPercentage + "%");
+// });
// 设置内容的知识点数据
objectiveContentKnowVO.setContentKnowsData(contentKnowVOs);
@@ -168,6 +163,4 @@ public class ObjectiveContentKnowServiceImpl extends ServiceImpl0 ? "删除成功!" : "删除失败!";
+ return delete > 0 ? "删除成功!" : "删除失败!";
}
}
diff --git a/src/main/java/com/teaching/backend/service/impl/favour/SeCourseFavourServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/favour/SeCourseFavourServiceImpl.java
index bebe162..a260644 100644
--- a/src/main/java/com/teaching/backend/service/impl/favour/SeCourseFavourServiceImpl.java
+++ b/src/main/java/com/teaching/backend/service/impl/favour/SeCourseFavourServiceImpl.java
@@ -156,21 +156,27 @@ public class SeCourseFavourServiceImpl extends ServiceImpl queryNewCollect(String userId) {
String roleId = umsUserMapper.getbyIdRoleId(userId);
- CoursesVO coursesVO = new CoursesVO();
+ List coursesList = new ArrayList<>();
if (roleId.equals("1")){
//老师
- String courseId = seCourseFavourMapper.queryAllNewCollectCourse();
- Courses courses = coursesMapper.selectById(courseId);
- BeanUtil.copyProperties(courses,coursesVO);
- return coursesVO;
+ List courseIdList = seCourseFavourMapper.queryAllNewCollectCourse();
+ for (String courseId : courseIdList) {
+ Courses courses = coursesMapper.selectById(courseId);
+ coursesList.add(courses);
+ }
+ List coursesVOList = BeanUtil.copyToList(coursesList, CoursesVO.class);
+ return coursesVOList;
}else if (roleId.equals("2")){
//学生
- String courseId = seCourseFavourMapper.queryStudentNewCollectCourse(userId);
- Courses courses = coursesMapper.selectById(courseId);
- BeanUtil.copyProperties(courses,coursesVO);
- return coursesVO;
+ List courseIdList = seCourseFavourMapper.queryStudentNewCollectCourse(userId);
+ for (String courseId : courseIdList) {
+ Courses courses = coursesMapper.selectById(courseId);
+ coursesList.add(courses);
+ }
+ List coursesVOList = BeanUtil.copyToList(coursesList,CoursesVO.class);
+ return coursesVOList;
}else {
return null;
}
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 b8e4809..2ce1a62 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
@@ -61,19 +61,21 @@ public class CourseLearningRecordServiceImpl extends ServiceImpl 0){
//自己没学过,人数加1
if (count1 == 0){
courseLearningNumberService.update().setSql("number = number + 1").eq("course_id",courseId).update();
-// System.out.println("用户:"+userId+"第一次学这门课");
+ //System.out.println("用户:"+userId+"第一次学这门课");
}
+ //System.out.println("重复学习");
}else {
//该课程第一次被学,人数设置为1
CourseLearningNumber courseLearningNumber = new CourseLearningNumber();
courseLearningNumber.setNumber(1);
courseLearningNumber.setCourseId(courseId);
courseLearningNumberService.save(courseLearningNumber);
+ //System.out.println("该课程第一次被学习");
}
//设置人数
String numberId = courseLearningNumberService.query().eq("course_id", courseId).one().getId();
diff --git a/src/main/java/com/teaching/backend/service/impl/records/KnowledgeLearningRecordServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/records/KnowledgeLearningRecordServiceImpl.java
index fe3d252..0c10b1f 100644
--- a/src/main/java/com/teaching/backend/service/impl/records/KnowledgeLearningRecordServiceImpl.java
+++ b/src/main/java/com/teaching/backend/service/impl/records/KnowledgeLearningRecordServiceImpl.java
@@ -2,20 +2,38 @@ 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.KnowledgeLearningRecordMapper;
+import com.teaching.backend.mapper.umsAdmin.UmsUserMapper;
+import com.teaching.backend.model.entity.KnowGraph.Know;
import com.teaching.backend.model.entity.KnowGraph.KnowledgeLearningNumber;
+import com.teaching.backend.model.entity.Knowtemp.Knowtemp;
import com.teaching.backend.model.entity.courses.CourseLearningNumber;
+
+import com.teaching.backend.model.entity.courses.Courses;
import com.teaching.backend.model.entity.records.KnowledgeLearningRecord;
+
+import com.teaching.backend.model.vo.courses.CoursesVO;
+import com.teaching.backend.model.vo.knowGraph.KnowVO;
+import com.teaching.backend.model.vo.records.KnowledgeLearningRecordVo;
+import com.teaching.backend.service.KnowGraph.KnowService;
import com.teaching.backend.service.impl.courses.CourseLearningNumberServiceImpl;
import com.teaching.backend.service.impl.knowledge.KnowledgeLearningNumberServiceImpl;
import com.teaching.backend.service.records.IKnowledgeLearningRecordService;
+import org.springframework.beans.factory.annotation.Autowired;
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;
/**
*
@@ -29,6 +47,12 @@ import java.time.LocalDateTime;
public class KnowledgeLearningRecordServiceImpl extends ServiceImpl implements IKnowledgeLearningRecordService {
@Resource
private KnowledgeLearningNumberServiceImpl knowledgeLearningNumberService;
+ @Autowired
+ private UmsUserMapper umsUserMapper;
+ @Autowired
+ private KnowledgeLearningRecordMapper knowledgeLearningRecordMapper;
+ @Resource
+ private KnowService knowService;
@Override
public BaseResponse saveCoursesRecords(KnowledgeLearningRecord knowledgeLearningRecord) {
@@ -44,14 +68,22 @@ public class KnowledgeLearningRecordServiceImpl extends ServiceImpl 0){
+ Long count1 = query()
+ .eq("user_id", userId)
+ .eq("courses_id", courseId)
+ .eq("knowledge_id",knowledgeId).count();
+ if (count > 0){//有人学过
//自己没学过,人数加1
if (count1 == 0){
- knowledgeLearningNumberService.update().setSql("number = number + 1").eq("course_id", courseId).eq("knowledge_id",knowledgeId).update();
-// System.out.println("用户:"+userId+"第一次学这门课");
+ //该知识点学习人数
+ knowledgeLearningNumberService.update()
+ .setSql("number = number + 1")
+ .eq("course_id", courseId)
+ .eq("knowledge_id",knowledgeId).update();
+ System.out.println("用户:"+userId+":第一次学这门课");
+
}
- }else {
+ }else {//没人学过(自己肯定也没学)
//该课程第一次被学,人数设置为1
KnowledgeLearningNumber knowledgeLearningNumber = new KnowledgeLearningNumber();
knowledgeLearningNumber.setNumber(1);
@@ -68,4 +100,78 @@ public class KnowledgeLearningRecordServiceImpl extends ServiceImpl getPage(int pagenum, int pagesize, String userId, 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("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(knowledgeLearningRecord -> {
+ KnowledgeLearningRecordVo knowledgeLearningRecordVo = new KnowledgeLearningRecordVo();
+ BeanUtil.copyProperties(knowledgeLearningRecord,knowledgeLearningRecordVo);
+ Date date = Date.from(knowledgeLearningRecord.getTimes().atZone(ZoneId.systemDefault()).toInstant());
+ knowledgeLearningRecordVo.setTime(sdf.format(date));
+// //填充学习人数
+ knowledgeLearningRecordVo.setNumber(knowledgeLearningNumberService.getById(knowledgeLearningRecord.getNumber()).getNumber());
+ recordsVos.add(knowledgeLearningRecordVo);
+ });
+ page1.setRecords(recordsVos);
+ return ResultUtils.success(page1);
+ }
+
+ @Override
+ public BaseResponse removeKnowledgeRecord(List ids) {
+ removeByIds(ids);
+ return ResultUtils.success("删除成功!");
+ }
+
+ @Override
+ public List queryMaxKnowledge(String userId) {
+ String roleId = umsUserMapper.getbyIdRoleId(userId);
+ List coursesList = new ArrayList<>();
+ KnowVO knowVO = null;
+ if (roleId.equals("1")){
+ //老师
+ List knowledgeIdList = knowledgeLearningRecordMapper.queryStudyKnowledgeMaxNumber();
+ for (String knowledgeId : knowledgeIdList) {
+ BaseResponse knowledge = knowService.query(Long.valueOf(knowledgeId));
+ if (knowledge.getData() != null){
+ knowVO = new KnowVO();
+ knowVO.setId(knowledge.getData().getId());
+ knowVO.setLabel(knowledge.getData().getName());
+ knowVO.setColor(knowledge.getData().getInfo());
+ coursesList.add(knowVO);
+ }
+ }
+ return coursesList;
+ }else if (roleId.equals("2")){
+ //学生
+ List knowledgeIdList = knowledgeLearningRecordMapper.queryStudyMaxKnowledgeId(userId);
+ for (String knowledgeId : knowledgeIdList) {
+ BaseResponse knowledge = knowService.query(Long.valueOf(knowledgeId));
+ if (knowledge.getData() != null) {
+ knowVO = new KnowVO();
+ knowVO.setId(knowledge.getData().getId());
+ knowVO.setLabel(knowledge.getData().getName());
+ knowVO.setColor(knowledge.getData().getInfo());
+ coursesList.add(knowVO);
+ }
+ }
+ return coursesList;
+ }else {
+ return null;
+ }
+ }
+
}
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 c69e71d..14270e6 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,16 +1,28 @@
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;
/**
*
@@ -23,52 +35,93 @@ import java.time.LocalDateTime;
@Service
public class ResourceLearningRecordServiceImpl extends ServiceImpl implements IResourceLearningRecordService {
-// @Resource
-// private ResourceLearningNumberServiceImpl resourceLearningNumberService;
+ @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("删除成功!");
+ }
+
-// @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).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("添加成功");
-// }
}
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 3cabf56..dd42ddc 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
@@ -11,6 +11,7 @@ import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
@@ -24,7 +25,7 @@ public class ReportServiceImpl extends ServiceImpl impleme
@Override
public BrowseReportVO getBrowseStatistics() {
//存放访问的前一天至前七天的每天对应的日期
- List dateList = new ArrayList<>();
+ List dateList = new ArrayList<>();
//存放这个月访问的前一天至前七天的每天对应的浏览量
List ThisMonthBrowseList = new ArrayList<>();
//存放上个月访问的前一天至前七天的每天对应的浏览量
@@ -36,7 +37,9 @@ public class ReportServiceImpl extends ServiceImpl impleme
// 获取前七天的日期
for (int i = 1; i <= 7; i++) {
LocalDate day = end.minusDays(i);
- dateList.add(day);
+ // 定义一个仅包含月日的格式化器
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM-dd");
+ dateList.add(day.format(formatter));
//查询今天对应的浏览量
String browse = reportMapper.getBrowseByTime(day);
@@ -47,6 +50,8 @@ public class ReportServiceImpl extends ServiceImpl impleme
LocalDate lastMonth = lastMonthToday.minusDays(i);
//查询上个月的今天对应的浏览量
String lastMonthBrowse = reportMapper.getBrowseByTime(lastMonth);
+
+
LastMonthBrowseList.add(lastMonthBrowse);
}
@@ -59,13 +64,19 @@ public class ReportServiceImpl extends ServiceImpl impleme
}
@Override
- public boolean getReceptionBrowse(ReportDTO reportDTO) {
- if (reportDTO.getCreateTime() == null || reportDTO.getPageView() == null){
- return false;
- }
- boolean todayBrowse = reportMapper.addTodayBrowse(reportDTO);
- if (todayBrowse == false){
- return false;
+ public boolean getReceptionBrowse() {
+ //查询今日有无记录
+ List list = lambdaQuery().eq(Report::getCreateTime, LocalDate.now()).list();
+
+ if (list.size() > 0){
+ //有,给记录加一
+ update().setSql("page_view = page_view + 1").eq("create_time",LocalDate.now()).update();
+ }else {
+ //无,创建一个记录
+ Report report = new Report();
+ report.setCreateTime(LocalDate.now());
+ report.setPageView("1");
+ save(report);
}
return true;
}
diff --git a/src/main/java/com/teaching/backend/service/records/IKnowledgeLearningRecordService.java b/src/main/java/com/teaching/backend/service/records/IKnowledgeLearningRecordService.java
index ac279a5..4e320e0 100644
--- a/src/main/java/com/teaching/backend/service/records/IKnowledgeLearningRecordService.java
+++ b/src/main/java/com/teaching/backend/service/records/IKnowledgeLearningRecordService.java
@@ -1,9 +1,14 @@
package com.teaching.backend.service.records;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.model.entity.records.KnowledgeLearningRecord;
+import io.swagger.models.auth.In;
+import com.teaching.backend.model.vo.knowGraph.KnowVO;
+
+import java.util.List;
/**
*
@@ -16,4 +21,12 @@ import com.teaching.backend.model.entity.records.KnowledgeLearningRecord;
public interface IKnowledgeLearningRecordService extends IService {
BaseResponse saveCoursesRecords(KnowledgeLearningRecord knowledgeLearningRecord);
+
+ BaseResponse getPage(int pagenum, int pagesize, String userId, String courseId);
+
+ BaseResponse removeKnowledgeRecord(List ids);
+
+
+ List queryMaxKnowledge(String userId);
}
+
diff --git a/src/main/java/com/teaching/backend/service/records/IResourceLearningRecordService.java b/src/main/java/com/teaching/backend/service/records/IResourceLearningRecordService.java
index 9ea73bc..1282e23 100644
--- a/src/main/java/com/teaching/backend/service/records/IResourceLearningRecordService.java
+++ b/src/main/java/com/teaching/backend/service/records/IResourceLearningRecordService.java
@@ -1,10 +1,13 @@
package com.teaching.backend.service.records;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.model.entity.records.ResourceLearningRecord;
+import java.util.List;
+
/**
*
* 服务类
@@ -15,5 +18,9 @@ import com.teaching.backend.model.entity.records.ResourceLearningRecord;
*/
public interface IResourceLearningRecordService extends IService {
-// BaseResponse saveCoursesRecords(ResourceLearningRecord resourceLearningRecord);
+ BaseResponse saveCoursesRecords(ResourceLearningRecord resourceLearningRecord);
+
+ BaseResponse getPage(int pagenum, int pagesize, String userId, String knowledgeId, String courseId);
+
+ BaseResponse removeResourceRecord(List ids);
}
diff --git a/src/main/java/com/teaching/backend/service/report/ReportService.java b/src/main/java/com/teaching/backend/service/report/ReportService.java
index 5fbe678..74c1fcc 100644
--- a/src/main/java/com/teaching/backend/service/report/ReportService.java
+++ b/src/main/java/com/teaching/backend/service/report/ReportService.java
@@ -17,5 +17,5 @@ public interface ReportService extends IService {
* 接收每日浏览量
* @return
*/
- boolean getReceptionBrowse(ReportDTO reportDTO);
+ boolean getReceptionBrowse();
}
diff --git a/src/main/java/com/teaching/backend/utils/Constants.java b/src/main/java/com/teaching/backend/utils/Constants.java
new file mode 100644
index 0000000..821d3f2
--- /dev/null
+++ b/src/main/java/com/teaching/backend/utils/Constants.java
@@ -0,0 +1,5 @@
+package com.teaching.backend.utils;
+
+public class Constants {
+ public static final String UPLOAD_URL = "E:\\workspace\\file\\";
+}
diff --git a/src/main/java/com/teaching/backend/utils/CourseCode.java b/src/main/java/com/teaching/backend/utils/CourseCode.java
index d736cd4..b7b2465 100644
--- a/src/main/java/com/teaching/backend/utils/CourseCode.java
+++ b/src/main/java/com/teaching/backend/utils/CourseCode.java
@@ -4,14 +4,14 @@ public enum CourseCode {
HAS_CHILD(1, "存在子节点"),
OBJECTIVE_EXIT(1,"目标存在"),
- CONTENT_EXIT(1, "存在内容"),
+ CONTENT_EXIT(0, "不存在内容"),
SI_ZHENG_TYPE(1, "思政目标类型"),
SI_ZHENG_EXIT(1, "思政目标存在"),
KNOWS_EXIT(0, "存在关联的知识点"),
TEACHER_ROLE_ID(1, "教师的角色id是1"),
TOTAL_OBJECTIVE_TYPE(0, "课程总目标"),
-
+ TOTAL_OBJECTIVE_HAS_NO_CHILD(0, "课程总目标下面没有分项目标"),
Total_EXIT(0, "课程总目标"),
COURSE_UPDATING(1, "课程正在修改中");
diff --git a/src/main/java/com/teaching/backend/utils/UploadUtils.java b/src/main/java/com/teaching/backend/utils/UploadUtils.java
new file mode 100644
index 0000000..bd844af
--- /dev/null
+++ b/src/main/java/com/teaching/backend/utils/UploadUtils.java
@@ -0,0 +1,115 @@
+package com.teaching.backend.utils;
+
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.io.FileUtils;
+import org.springframework.util.DigestUtils;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.util.*;
+
+import static com.teaching.backend.utils.Constants.UPLOAD_URL;
+
+@Slf4j
+//文件上传工具类
+public class UploadUtils {
+
+ public static String saveFileByDirectory (MultipartFile file) {
+ String url = "";
+ try {
+ // 将文件保存在服务器目录中
+ // 文件名称
+ String uuid = UUID.randomUUID().toString();
+ // 得到上传文件后缀
+ String originalName = file.getOriginalFilename();
+ String ext = "." + FilenameUtils.getExtension(originalName);
+ // 新生成的文件名称
+ String fileName = uuid + ext;
+ // 复制文件
+ File targetFile = new File(UPLOAD_URL, fileName);
+ url = UPLOAD_URL + fileName;
+ FileUtils.writeByteArrayToFile(targetFile, file.getBytes());
+ System.out.println("保存成功");
+ } catch (IOException e) {
+ log.error("保存文件到服务器(本地)失败",e);
+ }
+ return url;
+ }
+
+ public static void Chunk(File sourseFile) throws IOException {
+// //源文件
+// File sourseFile = new File("D:/Users/Desktop/image/剪映/7.18/7月20.mp4");
+ //分块文件存储路径
+ String chunkFilePath = "E:\\workspace\\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();
+ }
+
+ public static void Merge(File sourseFile) throws IOException {
+ //块文件目录
+ File chunkFolder = new File("E:\\workspace\\chunk");
+// //源文件
+// File sourseFile = new File("D:/Users/Desktop/image/剪映/7.18/7月20.mp4");
+ //合并后的文件
+ File mergeFile = new File("E:\\workspace\\file\\"+sourseFile.getName());
+
+ //取出所有分块文件
+ 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("文件合并成功!");
+ }
+ }
+}
diff --git a/src/main/resources/mapper/CourseLearningRecordMapper.xml b/src/main/resources/mapper/CourseLearningRecordMapper.xml
index 65d9f52..d117fc7 100644
--- a/src/main/resources/mapper/CourseLearningRecordMapper.xml
+++ b/src/main/resources/mapper/CourseLearningRecordMapper.xml
@@ -19,14 +19,13 @@
course_learning_number cln
ORDER BY
number
- DESC LIMIT 4;
+ DESC;
diff --git a/src/main/resources/mapper/KnowledgeLearningRecordMapper.xml b/src/main/resources/mapper/KnowledgeLearningRecordMapper.xml
new file mode 100644
index 0000000..3ea0405
--- /dev/null
+++ b/src/main/resources/mapper/KnowledgeLearningRecordMapper.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
diff --git a/src/main/resources/mapper/SeCourseFavourMapper.xml b/src/main/resources/mapper/SeCourseFavourMapper.xml
index 26ae03d..f310d5d 100644
--- a/src/main/resources/mapper/SeCourseFavourMapper.xml
+++ b/src/main/resources/mapper/SeCourseFavourMapper.xml
@@ -10,7 +10,7 @@
se_course_favour scf
ORDER BY
createtime
- DESC LIMIT 1;
+ DESC;
diff --git a/src/test/java/com/teaching/MinioTest.java b/src/test/java/com/teaching/MinioTest.java
new file mode 100644
index 0000000..cbdb77d
--- /dev/null
+++ b/src/test/java/com/teaching/MinioTest.java
@@ -0,0 +1,101 @@
+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
new file mode 100644
index 0000000..6d75620
--- /dev/null
+++ b/src/test/java/com/teaching/test.java
@@ -0,0 +1,36 @@
+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);
+// }
+ }
+}