# Conflicts: # src/main/java/com/teaching/backend/controller/records/ResourceLearningRecordController.java # src/main/java/com/teaching/backend/service/impl/records/ResourceLearningRecordServiceImpl.java # src/main/java/com/teaching/backend/service/records/IResourceLearningRecordService.javamaster
commit
205de3c972
45 changed files with 1133 additions and 213 deletions
@ -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); |
||||
} |
||||
} |
@ -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) { |
||||
|
||||
} |
||||
} |
||||
} |
@ -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("文件不存在"); |
||||
} |
||||
} |
||||
} |
@ -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<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); |
||||
}; |
||||
|
||||
// @ApiOperation("添加资源学习记录")
|
||||
//// @ValidateParams({"userId","type","coursesId"})
|
||||
// @PostMapping("/saverecords")
|
||||
// public BaseResponse<String> saveResourceRecords(@RequestBody ResourceLearningRecord resourceLearningRecord) {
|
||||
// return resourceLearningRecordService.saveCoursesRecords(resourceLearningRecord);
|
||||
// }
|
||||
} |
||||
|
@ -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; |
||||
} |
@ -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; |
||||
|
||||
/** |
||||
* <p> |
||||
* |
||||
* </p> |
||||
* |
||||
* @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; |
||||
|
||||
} |
@ -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; |
||||
} |
@ -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; |
||||
} |
@ -0,0 +1,5 @@ |
||||
package com.teaching.backend.utils; |
||||
|
||||
public class Constants { |
||||
public static final String UPLOAD_URL = "E:\\workspace\\file\\"; |
||||
} |
@ -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<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("文件合并成功!"); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,20 @@ |
||||
<?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.records.KnowledgeLearningRecordMapper"> |
||||
|
||||
<select id="queryStudyKnowledgeMaxNumber" resultType="java.lang.String"> |
||||
SELECT |
||||
kln.knowledge_id knowledgeId |
||||
FROM |
||||
knowledge_learning_number kln |
||||
ORDER BY |
||||
number |
||||
DESC; |
||||
</select> |
||||
<select id="queryStudyMaxKnowledgeId" resultType="java.lang.String"> |
||||
SELECT knowledge_id,knowledge_name |
||||
FROM knowledge_learning_record |
||||
WHERE user_id = #{userId} |
||||
ORDER BY times DESC; |
||||
</select> |
||||
</mapper> |
@ -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<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接口合并分块
|
||||
|
||||
|
||||
//批量清理分块文件
|
||||
|
||||
|
||||
} |
@ -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<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…
Reference in new issue