commit
896ba81d60
56 changed files with 1081 additions and 501 deletions
@ -0,0 +1,36 @@ |
|||||||
|
## 文档说明 |
||||||
|
|
||||||
|
##### 资源接口 |
||||||
|
|
||||||
|
resourcesController 资源上传 uploadFile / 下载 deleteResource / 预览 readFile |
||||||
|
|
||||||
|
用minio 作为资源管理 |
||||||
|
|
||||||
|
minio 网址:http://39.106.16.162:9001/ |
||||||
|
用户名:minioadmin |
||||||
|
密码:minioadmin |
||||||
|
|
||||||
|
以日期分类 文件类型 文件名前10个(超出10)+yyyymmddhhmmss |
||||||
|
|
||||||
|
yml 配置 |
||||||
|
|
||||||
|
```java |
||||||
|
minio: |
||||||
|
endpoint: http://39.106.16.162:9090 #MinIO服务所在地址 |
||||||
|
bucketName: teaching # 存储桶名称 |
||||||
|
accessKey: minioadmin # 访问的key |
||||||
|
secretKey: minioadmin # 访问的秘钥 |
||||||
|
``` |
||||||
|
|
||||||
|
minioutils 工具类 |
||||||
|
|
||||||
|
> 逻辑就是,文件上传之后,存入图数据库,返回节点信息 , 删除文件 也得删除文件在图数据库的节点 |
||||||
|
|
||||||
|
##### 图数据库 |
||||||
|
|
||||||
|
http://39.106.16.162:7474/ |
||||||
|
|
||||||
|
用户名 neo4j |
||||||
|
|
||||||
|
密码123456 |
||||||
|
|
@ -1,102 +1,103 @@ |
|||||||
//package com.teaching.backend.controller.records;
|
package com.teaching.backend.controller.records; |
||||||
//
|
|
||||||
//import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||||
//import com.teaching.backend.common.BaseResponse;
|
import com.teaching.backend.common.BaseResponse; |
||||||
//import com.teaching.backend.common.ResultUtils;
|
import com.teaching.backend.common.ResultUtils; |
||||||
//import com.teaching.backend.filter.ValidateParams;
|
import com.teaching.backend.filter.ValidateParams; |
||||||
//import com.teaching.backend.mapper.records.ResourceLearningRecordMapper;
|
import com.teaching.backend.mapper.records.ResourceLearningRecordMapper; |
||||||
//import com.teaching.backend.model.entity.records.KnowledgeLearningRecord;
|
import com.teaching.backend.model.entity.records.KnowledgeLearningRecord; |
||||||
//import com.teaching.backend.model.entity.records.ResourceLearningRecord;
|
import com.teaching.backend.model.entity.records.ResourceLearningRecord; |
||||||
//import com.teaching.backend.service.impl.records.KnowledgeLearningRecordServiceImpl;
|
import com.teaching.backend.service.impl.records.KnowledgeLearningRecordServiceImpl; |
||||||
//import com.teaching.backend.service.impl.records.ResourceLearningRecordServiceImpl;
|
import com.teaching.backend.service.impl.records.ResourceLearningRecordServiceImpl; |
||||||
//import com.teaching.backend.utils.UploadUtils;
|
import com.teaching.backend.utils.UploadUtils; |
||||||
//import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation; |
||||||
//import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType; |
||||||
//import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*; |
||||||
//import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile; |
||||||
//
|
|
||||||
//import javax.annotation.Resource;
|
import javax.annotation.Resource; |
||||||
//import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest; |
||||||
//import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse; |
||||||
//import java.io.File;
|
import java.io.File; |
||||||
//import java.io.IOException;
|
import java.io.IOException; |
||||||
//import java.util.List;
|
import java.util.List; |
||||||
//
|
|
||||||
//@RestController
|
@RestController |
||||||
//@RequestMapping("/api/resourcelearningrecords")
|
@RequestMapping("/api/resourcelearningrecords") |
||||||
//public class ResourceLearningRecordController {
|
public class ResourceLearningRecordController { |
||||||
// @Resource
|
|
||||||
// private ResourceLearningRecordServiceImpl resourceLearningRecordService;
|
@Resource |
||||||
// @Resource
|
private ResourceLearningRecordServiceImpl resourceLearningRecordService; |
||||||
// private ResourceLearningRecordMapper resourceLearningRecordMapper;
|
@Resource |
||||||
//
|
private ResourceLearningRecordMapper resourceLearningRecordMapper; |
||||||
//
|
|
||||||
//
|
|
||||||
// @ApiOperation("添加资源学习记录")
|
|
||||||
//// @ValidateParams({"userId","type","coursesId"})
|
@ApiOperation("添加资源学习记录") |
||||||
// @PostMapping("/saverecords")
|
// @ValidateParams({"userId","type","coursesId"})
|
||||||
// public BaseResponse<String> saveResourceRecords(@RequestBody ResourceLearningRecord resourceLearningRecord) {
|
@PostMapping("/saverecords") |
||||||
// return resourceLearningRecordService.saveCoursesRecords(resourceLearningRecord);
|
public BaseResponse<String> saveResourceRecords(@RequestBody ResourceLearningRecord resourceLearningRecord) { |
||||||
// }
|
return resourceLearningRecordService.saveCoursesRecords(resourceLearningRecord); |
||||||
//
|
} |
||||||
// /**
|
|
||||||
// * 获取当前登录用户的学习资源记录
|
/** |
||||||
// * @param pagenum
|
* 获取当前登录用户的学习资源记录 |
||||||
// * @param pagesize
|
* @param pagenum |
||||||
// * @return
|
* @param pagesize |
||||||
// */
|
* @return |
||||||
// @ApiOperation("根据用户id查询学习记录")
|
*/ |
||||||
// @ValidateParams({"userId"})
|
@ApiOperation("根据用户id查询学习记录") |
||||||
// @GetMapping("/page")
|
@ValidateParams({"userId"}) |
||||||
// public BaseResponse<Page> getAll(@RequestParam(value = "pagenum", defaultValue = "1") int pagenum,
|
@GetMapping("/page") |
||||||
// @RequestParam(value = "pagesize", defaultValue = "10") int pagesize,
|
public BaseResponse<Page> getAll(@RequestParam(value = "pagenum", defaultValue = "1") int pagenum, |
||||||
// @RequestParam String userId,
|
@RequestParam(value = "pagesize", defaultValue = "10") int pagesize, |
||||||
// @RequestParam String courseId,
|
@RequestParam String userId, |
||||||
// @RequestParam String knowledgeId){
|
@RequestParam String courseId, |
||||||
// return resourceLearningRecordService.getPage(pagenum, pagesize, userId, knowledgeId,courseId);
|
@RequestParam String knowledgeId){ |
||||||
//
|
return resourceLearningRecordService.getPage(pagenum, pagesize, userId, knowledgeId,courseId); |
||||||
// }
|
|
||||||
// /**
|
} |
||||||
// * 根据ids删除
|
/** |
||||||
// * @param ids
|
* 根据ids删除 |
||||||
// * @return
|
* @param ids |
||||||
// */
|
* @return |
||||||
// @ApiOperation("学习记录删除")
|
*/ |
||||||
// @DeleteMapping("/delete")
|
@ApiOperation("学习记录删除") |
||||||
// public BaseResponse<String> deleteRecords(@RequestParam List<Long> ids){
|
@DeleteMapping("/delete") |
||||||
// return resourceLearningRecordService.removeResourceRecord(ids);
|
public BaseResponse<String> deleteRecords(@RequestParam List<Long> ids){ |
||||||
// }
|
return resourceLearningRecordService.removeResourceRecord(ids); |
||||||
//
|
} |
||||||
// /**
|
|
||||||
// * 统计单个学生学习资源数量
|
/** |
||||||
// * @param userId
|
* 统计单个学生学习资源数量 |
||||||
// * @return
|
* @param userId |
||||||
// */
|
* @return |
||||||
// @ApiOperation("统计单个学生学习资源数量")
|
*/ |
||||||
// @GetMapping("/countresourcenumber")
|
@ApiOperation("统计单个学生学习资源数量") |
||||||
// public BaseResponse<Integer> countResourceNumber(@RequestParam String userId) {
|
@GetMapping("/countresourcenumber") |
||||||
// return ResultUtils.success(resourceLearningRecordMapper.selectDistinctResourceIdsByUser(userId).size());
|
public BaseResponse<Integer> countResourceNumber(@RequestParam String userId) { |
||||||
// }
|
return ResultUtils.success(resourceLearningRecordMapper.selectDistinctResourceIdsByUser(userId).size()); |
||||||
//
|
} |
||||||
//
|
|
||||||
// @ApiOperation("上传图片")
|
|
||||||
// @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
@ApiOperation("上传图片") |
||||||
// public BaseResponse<String> upload(@RequestPart("filedata") MultipartFile filedata) throws IOException {
|
@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) |
||||||
// //调用ser
|
public BaseResponse<String> upload(@RequestPart("filedata") MultipartFile filedata) throws IOException { |
||||||
// System.out.println(filedata.getResource());
|
//调用ser
|
||||||
// System.out.println(UploadUtils.saveFileByDirectory(filedata));
|
System.out.println(filedata.getResource()); |
||||||
//// File file = filedata.getResource().getFile();
|
System.out.println(UploadUtils.saveFileByDirectory(filedata)); |
||||||
//// UploadUtils.Chunk(file);
|
// File file = filedata.getResource().getFile();
|
||||||
//// UploadUtils.Merge(file);
|
// UploadUtils.Chunk(file);
|
||||||
// //源文件
|
// UploadUtils.Merge(file);
|
||||||
//// File sourseFile = (File) file;
|
//源文件
|
||||||
// return ResultUtils.success("hello");
|
// File sourseFile = (File) file;
|
||||||
// };
|
return ResultUtils.success("hello"); |
||||||
//
|
}; |
||||||
// @GetMapping("/bf")
|
|
||||||
// public BaseResponse<String> bf(@RequestParam String path, File file,HttpServletRequest request, HttpServletResponse response){
|
@GetMapping("/bf") |
||||||
// File sourseFile = new File(path);
|
public BaseResponse<String> bf(@RequestParam String path, File file,HttpServletRequest request, HttpServletResponse response){ |
||||||
// return ResultUtils.success(path);
|
File sourseFile = new File(path); |
||||||
// };
|
return ResultUtils.success(path); |
||||||
//
|
}; |
||||||
//}
|
|
||||||
|
} |
||||||
|
@ -0,0 +1,72 @@ |
|||||||
|
package com.teaching.backend.controller.umsAdmin; |
||||||
|
|
||||||
|
import com.teaching.backend.common.CommonResult; |
||||||
|
import com.teaching.backend.model.dto.umsAdmin.UmsStudentPageQueryDTO; |
||||||
|
import com.teaching.backend.model.entity.umsAdmin.UmsStudentManage; |
||||||
|
import com.teaching.backend.service.umsAdmin.UmsStudentManageService; |
||||||
|
import io.swagger.annotations.Api; |
||||||
|
import io.swagger.annotations.ApiOperation; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.web.bind.annotation.*; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
@RestController |
||||||
|
@Api(tags = "学生管理") |
||||||
|
@RequestMapping("/api/studentManage") |
||||||
|
@Slf4j |
||||||
|
public class UmsStudentManageController { |
||||||
|
|
||||||
|
@Autowired |
||||||
|
private UmsStudentManageService umsStudentManageService; |
||||||
|
|
||||||
|
/** |
||||||
|
* 学生管理分页查询 |
||||||
|
* @param umsStudentPageQueryDTO |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
@GetMapping("/page") |
||||||
|
@ApiOperation("学生管理分页查询") |
||||||
|
public CommonResult<Map<String, Object>> page(UmsStudentPageQueryDTO umsStudentPageQueryDTO){ |
||||||
|
Map<String, Object> pageResult = umsStudentManageService.pageQuery(umsStudentPageQueryDTO); |
||||||
|
return CommonResult.success(pageResult); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 启用禁用学生账号 |
||||||
|
* @param status |
||||||
|
* @param id |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
@PostMapping("/status/{status}") |
||||||
|
@ApiOperation("启用禁用员工账号") |
||||||
|
public CommonResult startOrStop(@PathVariable String status, Long id){ |
||||||
|
umsStudentManageService.startOrStop(status,id); |
||||||
|
return CommonResult.success("修改成功"); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 根据id查询学生信息 |
||||||
|
* @param id |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
@GetMapping("/{id}") |
||||||
|
@ApiOperation("根据id查询学生信息") |
||||||
|
public CommonResult<UmsStudentManage> getById(@PathVariable Long id){ |
||||||
|
UmsStudentManage umsStudentManage = umsStudentManageService.getByIdStudentAndUser(id); |
||||||
|
return CommonResult.success(umsStudentManage); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 编辑学生信息 |
||||||
|
* @param umsStudentManage |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
@PutMapping |
||||||
|
@ApiOperation("编辑学生信息") |
||||||
|
public CommonResult update(@RequestBody UmsStudentManage umsStudentManage){ |
||||||
|
log.info("编辑学生信息: {}",umsStudentManage); |
||||||
|
umsStudentManageService.updateStudentAndUser(umsStudentManage); |
||||||
|
return CommonResult.success("修改成功"); |
||||||
|
} |
||||||
|
} |
@ -1,13 +0,0 @@ |
|||||||
package com.teaching.backend.controller.umsStudent; |
|
||||||
|
|
||||||
import io.swagger.annotations.Api; |
|
||||||
import lombok.extern.slf4j.Slf4j; |
|
||||||
import org.springframework.web.bind.annotation.RequestMapping; |
|
||||||
import org.springframework.web.bind.annotation.RestController; |
|
||||||
|
|
||||||
@RestController |
|
||||||
@Api(tags = "UmsStudentController") |
|
||||||
@RequestMapping("/api/student") |
|
||||||
@Slf4j |
|
||||||
public class UmsStudentController { |
|
||||||
} |
|
@ -0,0 +1,17 @@ |
|||||||
|
package com.teaching.backend.mapper.records; |
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import com.teaching.backend.model.entity.records.ResourceLearningNumber; |
||||||
|
|
||||||
|
/** |
||||||
|
* <p> |
||||||
|
* Mapper 接口 |
||||||
|
* </p> |
||||||
|
* |
||||||
|
* @author author |
||||||
|
* @since 2024-07-29 |
||||||
|
*/ |
||||||
|
public interface ResourceLearningNumberMapper extends BaseMapper<ResourceLearningNumber> { |
||||||
|
|
||||||
|
} |
@ -0,0 +1,22 @@ |
|||||||
|
package com.teaching.backend.mapper.umsAdmin; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||||
|
import com.teaching.backend.model.dto.umsAdmin.UmsStudentPageQueryDTO; |
||||||
|
import com.teaching.backend.model.entity.umsAdmin.*; |
||||||
|
import org.apache.ibatis.annotations.Mapper; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
@Mapper |
||||||
|
public interface UmsStudentManageMapper extends BaseMapper<UmsStudentManage> { |
||||||
|
|
||||||
|
UmsStudentManage queryStudent(String userId); |
||||||
|
|
||||||
|
List<UmsStudentManage> pageQueryStudent(UmsStudentPageQuery umsStudentPageQuery); |
||||||
|
|
||||||
|
int pageQueryStudentCount(UmsStudentPageQueryDTO umsStudentPageQueryDTO); |
||||||
|
|
||||||
|
UmsStudentManage getByIdStudentAndUser(Long id); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,25 @@ |
|||||||
|
package com.teaching.backend.model.dto.umsAdmin; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
|
||||||
|
@Data |
||||||
|
public class UmsStudentPageQueryDTO implements Serializable { |
||||||
|
|
||||||
|
//学生姓名
|
||||||
|
private String name; |
||||||
|
|
||||||
|
//学号
|
||||||
|
private String number; |
||||||
|
|
||||||
|
//页码
|
||||||
|
private int page; |
||||||
|
|
||||||
|
//每页显示记录数
|
||||||
|
private int pageSize; |
||||||
|
|
||||||
|
//学号
|
||||||
|
private String userId; |
||||||
|
|
||||||
|
} |
@ -0,0 +1,47 @@ |
|||||||
|
package com.teaching.backend.model.entity.records; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||||
|
import java.io.Serializable; |
||||||
|
import io.swagger.annotations.ApiModel; |
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.EqualsAndHashCode; |
||||||
|
import lombok.experimental.Accessors; |
||||||
|
|
||||||
|
/** |
||||||
|
* <p> |
||||||
|
* |
||||||
|
* </p> |
||||||
|
* |
||||||
|
* @author author |
||||||
|
* @since 2024-07-29 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@EqualsAndHashCode(callSuper = false) |
||||||
|
@Accessors(chain = true) |
||||||
|
@TableName("resource_learning_number") |
||||||
|
@ApiModel(value="ResourceLearningNumber对象", description="") |
||||||
|
public class ResourceLearningNumber implements Serializable { |
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "资源学习记录id") |
||||||
|
@TableId(value = "id", type = IdType.ASSIGN_ID) |
||||||
|
private String id; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "课程id") |
||||||
|
private String courseId; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "知识点id") |
||||||
|
private String knowledgeId; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "资源id") |
||||||
|
private String resourceId; |
||||||
|
|
||||||
|
@ApiModelProperty(value = "学习人数") |
||||||
|
private Integer number; |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,84 @@ |
|||||||
|
package com.teaching.backend.model.entity.umsAdmin; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.EqualsAndHashCode; |
||||||
|
import lombok.experimental.Accessors; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.time.LocalDate; |
||||||
|
import java.time.LocalDateTime; |
||||||
|
|
||||||
|
/** |
||||||
|
* <p> |
||||||
|
* |
||||||
|
* </p> |
||||||
|
* |
||||||
|
* @author zjh |
||||||
|
* @since 2024-06-12 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@EqualsAndHashCode(callSuper = false) |
||||||
|
@Accessors(chain = true) |
||||||
|
public class UmsStudentManage implements Serializable { |
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L; |
||||||
|
|
||||||
|
@TableId(value = "id", type = IdType.AUTO) |
||||||
|
private Integer id; |
||||||
|
|
||||||
|
//用户名
|
||||||
|
private String username; |
||||||
|
|
||||||
|
//密码
|
||||||
|
private String password; |
||||||
|
|
||||||
|
//昵称
|
||||||
|
private String nickName; |
||||||
|
|
||||||
|
//头像
|
||||||
|
private String icon; |
||||||
|
|
||||||
|
//注册时间
|
||||||
|
private LocalDateTime createTime; |
||||||
|
|
||||||
|
//账号状态
|
||||||
|
private Integer status; |
||||||
|
|
||||||
|
//姓名
|
||||||
|
private String name; |
||||||
|
|
||||||
|
//性别
|
||||||
|
private String sex; |
||||||
|
|
||||||
|
//民族
|
||||||
|
private String nationality; |
||||||
|
|
||||||
|
//学号
|
||||||
|
private String number; |
||||||
|
|
||||||
|
//生日
|
||||||
|
private LocalDateTime birthday; |
||||||
|
|
||||||
|
//手机号
|
||||||
|
private String phone; |
||||||
|
|
||||||
|
//院系
|
||||||
|
private String faculty; |
||||||
|
|
||||||
|
//专业
|
||||||
|
private String major; |
||||||
|
|
||||||
|
//入学年份
|
||||||
|
private LocalDate yearAge; |
||||||
|
|
||||||
|
//班级
|
||||||
|
private String className; |
||||||
|
|
||||||
|
//user_id
|
||||||
|
private Integer userId; |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,21 @@ |
|||||||
|
package com.teaching.backend.model.entity.umsAdmin; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
|
||||||
|
@Data |
||||||
|
public class UmsStudentPageQuery implements Serializable { |
||||||
|
|
||||||
|
//学生姓名
|
||||||
|
private String name; |
||||||
|
|
||||||
|
//学号
|
||||||
|
private String number; |
||||||
|
|
||||||
|
//每页显示记录数
|
||||||
|
private int pageSize; |
||||||
|
|
||||||
|
//偏移量
|
||||||
|
private int offset; |
||||||
|
} |
@ -0,0 +1,22 @@ |
|||||||
|
package com.teaching.backend.service.impl.records; |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||||
|
import com.teaching.backend.mapper.records.ResourceLearningNumberMapper; |
||||||
|
import com.teaching.backend.model.entity.records.ResourceLearningNumber; |
||||||
|
import com.teaching.backend.service.records.IResourceLearningNumberService; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
/** |
||||||
|
* <p> |
||||||
|
* 服务实现类 |
||||||
|
* </p> |
||||||
|
* |
||||||
|
* @author author |
||||||
|
* @since 2024-07-29 |
||||||
|
*/ |
||||||
|
@Service |
||||||
|
public class ResourceLearningNumberServiceImpl extends ServiceImpl<ResourceLearningNumberMapper, ResourceLearningNumber> implements IResourceLearningNumberService { |
||||||
|
|
||||||
|
} |
@ -1,127 +1,125 @@ |
|||||||
//package com.teaching.backend.service.impl.records;
|
package com.teaching.backend.service.impl.records; |
||||||
//
|
|
||||||
//
|
|
||||||
//import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil; |
||||||
//import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||||
//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||||
//import com.teaching.backend.common.BaseResponse;
|
import com.teaching.backend.common.BaseResponse; |
||||||
//import com.teaching.backend.common.ResultUtils;
|
import com.teaching.backend.common.ResultUtils; |
||||||
//import com.teaching.backend.mapper.records.ResourceLearningRecordMapper;
|
import com.teaching.backend.mapper.records.ResourceLearningRecordMapper; |
||||||
//import com.teaching.backend.model.entity.records.KnowledgeLearningRecord;
|
import com.teaching.backend.model.entity.records.ResourceLearningNumber; |
||||||
//import com.teaching.backend.model.entity.records.ResourceLearningRecord;
|
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.model.vo.records.ResourceLearingRecordVo;
|
import com.teaching.backend.service.records.IResourceLearningRecordService; |
||||||
//import com.teaching.backend.service.impl.resource.ResourceLearningNumberServiceImpl;
|
import org.springframework.stereotype.Service; |
||||||
//import com.teaching.backend.service.records.IResourceLearningRecordService;
|
|
||||||
//import org.springframework.stereotype.Service;
|
import javax.annotation.Resource; |
||||||
//
|
import java.text.SimpleDateFormat; |
||||||
//import javax.annotation.Resource;
|
import java.time.LocalDateTime; |
||||||
//import java.text.SimpleDateFormat;
|
import java.time.ZoneId; |
||||||
//import java.time.LocalDateTime;
|
import java.util.ArrayList; |
||||||
//import java.time.ZoneId;
|
import java.util.Date; |
||||||
//import java.util.ArrayList;
|
import java.util.List; |
||||||
//import java.util.Date;
|
|
||||||
//import java.util.List;
|
/** |
||||||
//
|
* <p> |
||||||
///**
|
* 服务实现类 |
||||||
// * <p>
|
* </p> |
||||||
// * 服务实现类
|
* |
||||||
// * </p>
|
* @author author |
||||||
// *
|
* @since 2024-07-24 |
||||||
// * @author author
|
*/ |
||||||
// * @since 2024-07-24
|
@Service |
||||||
// */
|
public class ResourceLearningRecordServiceImpl extends ServiceImpl<ResourceLearningRecordMapper, ResourceLearningRecord> implements IResourceLearningRecordService { |
||||||
//@Service
|
|
||||||
//public class ResourceLearningRecordServiceImpl extends ServiceImpl<ResourceLearningRecordMapper, ResourceLearningRecord> implements IResourceLearningRecordService {
|
@Resource |
||||||
//
|
private ResourceLearningNumberServiceImpl resourceLearningNumberService; |
||||||
// @Resource
|
|
||||||
// private ResourceLearningNumberServiceImpl resourceLearningNumberService;
|
@Override |
||||||
//
|
public BaseResponse<String> saveCoursesRecords(ResourceLearningRecord resourceLearningRecord) { |
||||||
// @Override
|
//课程id
|
||||||
// public BaseResponse<String> saveCoursesRecords(ResourceLearningRecord resourceLearningRecord) {
|
String courseId = resourceLearningRecord.getCoursesId(); |
||||||
// //课程id
|
String knowledgeId = resourceLearningRecord.getKnowledgeId(); |
||||||
// String courseId = resourceLearningRecord.getCoursesId();
|
String resourceId = resourceLearningRecord.getResourceId(); |
||||||
// String knowledgeId = resourceLearningRecord.getKnowledgeId();
|
String userId = resourceLearningRecord.getUserId(); |
||||||
// String resourceId = resourceLearningRecord.getResourceId();
|
//1.生成学习时间
|
||||||
// String userId = resourceLearningRecord.getUserId();
|
resourceLearningRecord.setTimes(LocalDateTime.now()); |
||||||
// //1.生成学习时间
|
//2.设置人数
|
||||||
// resourceLearningRecord.setTimes(LocalDateTime.now());
|
//2.1查人数
|
||||||
// //2.设置人数
|
Long count = resourceLearningNumberService.query() |
||||||
// //2.1查人数
|
.eq("course_id", courseId) |
||||||
// Long count = resourceLearningNumberService.query()
|
.eq("knowledge_id",knowledgeId) |
||||||
// .eq("course_id", courseId)
|
.eq("resource_id",resourceId).count(); |
||||||
// .eq("knowledge_id",knowledgeId)
|
//2.2判断自己是否学习过
|
||||||
// .eq("resource_id",resourceId).count();
|
Long count1 = query() |
||||||
// //2.2判断自己是否学习过
|
.eq("user_id", userId) |
||||||
// Long count1 = query()
|
.eq("courses_id", courseId) |
||||||
// .eq("user_id", userId)
|
.eq("knowledge_id",knowledgeId) |
||||||
// .eq("courses_id", courseId)
|
.eq("resource_id",resourceId).count(); |
||||||
// .eq("knowledge_id",knowledgeId)
|
if (count > 0){ |
||||||
// .eq("resource_id",resourceId).count();
|
//自己没学过,人数加1
|
||||||
// if (count > 0){
|
if (count1 == 0){ |
||||||
// //自己没学过,人数加1
|
resourceLearningNumberService.update().setSql("number = number + 1") |
||||||
// if (count1 == 0){
|
.eq("course_id",courseId) |
||||||
// resourceLearningNumberService.update().setSql("number = number + 1")
|
.eq("knowledge_id",knowledgeId) |
||||||
// .eq("course_id",courseId)
|
.eq("resource_id",resourceId).update(); |
||||||
// .eq("knowledge_id",knowledgeId)
|
// System.out.println("用户:"+userId+"第一次学这门课");
|
||||||
// .eq("resource_id",resourceId).update();
|
} |
||||||
//// System.out.println("用户:"+userId+"第一次学这门课");
|
}else { |
||||||
// }
|
//该课程第一次被学,人数设置为1
|
||||||
// }else {
|
ResourceLearningNumber resourceLearningNumber = new ResourceLearningNumber(); |
||||||
// //该课程第一次被学,人数设置为1
|
resourceLearningNumber.setNumber(1); |
||||||
// ResourceLearningNumber resourceLearningNumber = new ResourceLearningNumber();
|
resourceLearningNumber.setCourseId(courseId); |
||||||
// resourceLearningNumber.setNumber(1);
|
resourceLearningNumber.setKnowledgeId(knowledgeId); |
||||||
// resourceLearningNumber.setCourseId(courseId);
|
resourceLearningNumber.setResourceId(resourceId); |
||||||
// resourceLearningNumber.setKnowledgeId(knowledgeId);
|
resourceLearningNumberService.save(resourceLearningNumber); |
||||||
// resourceLearningNumber.setResourceId(resourceId);
|
} |
||||||
// resourceLearningNumberService.save(resourceLearningNumber);
|
//设置人数
|
||||||
// }
|
String numberId = resourceLearningNumberService.query() |
||||||
// //设置人数
|
.eq("course_id", courseId) |
||||||
// String numberId = resourceLearningNumberService.query()
|
.eq("knowledge_id",knowledgeId) |
||||||
// .eq("course_id", courseId)
|
.eq("resource_id",resourceId).one().getId(); |
||||||
// .eq("knowledge_id",knowledgeId)
|
resourceLearningRecord.setNumber(numberId); |
||||||
// .eq("resource_id",resourceId).one().getId();
|
//保存记录
|
||||||
// resourceLearningRecord.setNumber(numberId);
|
save(resourceLearningRecord); |
||||||
// //保存记录
|
return ResultUtils.success("添加成功"); |
||||||
// save(resourceLearningRecord);
|
} |
||||||
// return ResultUtils.success("添加成功");
|
|
||||||
// }
|
@Override |
||||||
//
|
public BaseResponse<Page> getPage(int pagenum, int pagesize, String userId, String knowledgeId, String courseId) { |
||||||
// @Override
|
//格式化时间
|
||||||
// public BaseResponse<Page> getPage(int pagenum, int pagesize, String userId, String knowledgeId, String courseId) {
|
String strDateFormat = "yyyy-MM-dd HH:mm:ss"; |
||||||
////格式化时间
|
SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat); |
||||||
// String strDateFormat = "yyyy-MM-dd HH:mm:ss";
|
//分页查询
|
||||||
// SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat);
|
Page<ResourceLearningRecord> page = query() |
||||||
// //分页查询
|
.orderByDesc("times") |
||||||
// Page<ResourceLearningRecord> page = query()
|
.eq("user_id", userId) |
||||||
// .orderByDesc("times")
|
.eq("knowledge_id",knowledgeId) |
||||||
// .eq("user_id", userId)
|
.eq("courses_id",courseId).page(new Page<>(pagenum, pagesize)); |
||||||
// .eq("knowledge_id",knowledgeId)
|
Page<ResourceLearingRecordVo> page1 = new Page<>(); |
||||||
// .eq("courses_id",courseId).page(new Page<>(pagenum, pagesize));
|
List<ResourceLearningRecord> records = page.getRecords(); |
||||||
// Page<ResourceLearingRecordVo> page1 = new Page<>();
|
BeanUtil.copyProperties(page, page1); |
||||||
// List<ResourceLearningRecord> records = page.getRecords();
|
List<ResourceLearingRecordVo> recordsVos = new ArrayList<>(); |
||||||
// BeanUtil.copyProperties(page, page1);
|
//copy集合
|
||||||
// List<ResourceLearingRecordVo> recordsVos = new ArrayList<>();
|
records.forEach(resourceLearningRecord -> { |
||||||
// //copy集合
|
ResourceLearingRecordVo resourceLearingRecordVo = new ResourceLearingRecordVo(); |
||||||
// records.forEach(resourceLearningRecord -> {
|
BeanUtil.copyProperties(resourceLearningRecord,resourceLearingRecordVo); |
||||||
// ResourceLearingRecordVo resourceLearingRecordVo = new ResourceLearingRecordVo();
|
Date date = Date.from(resourceLearningRecord.getTimes().atZone(ZoneId.systemDefault()).toInstant()); |
||||||
// BeanUtil.copyProperties(resourceLearningRecord,resourceLearingRecordVo);
|
resourceLearingRecordVo.setTime(sdf.format(date)); |
||||||
// 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); |
||||||
// resourceLearingRecordVo.setNumber(resourceLearningNumberService.getById(resourceLearningRecord.getNumber()).getNumber());
|
}); |
||||||
// recordsVos.add(resourceLearingRecordVo);
|
page1.setRecords(recordsVos); |
||||||
// });
|
return ResultUtils.success(page1); |
||||||
// page1.setRecords(recordsVos);
|
} |
||||||
// return ResultUtils.success(page1);
|
|
||||||
// }
|
@Override |
||||||
//
|
public BaseResponse<String> removeResourceRecord(List<Long> ids) { |
||||||
// @Override
|
removeByIds(ids); |
||||||
// public BaseResponse<String> removeResourceRecord(List<Long> ids) {
|
return ResultUtils.success("删除成功!"); |
||||||
// removeByIds(ids);
|
} |
||||||
// return ResultUtils.success("删除成功!");
|
|
||||||
// }
|
|
||||||
//
|
} |
||||||
//
|
|
||||||
//}
|
|
||||||
|
@ -0,0 +1,94 @@ |
|||||||
|
package com.teaching.backend.service.impl.umsAdmin; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||||
|
import com.teaching.backend.exception.BusinessException; |
||||||
|
import com.teaching.backend.mapper.umsAdmin.*; |
||||||
|
import com.teaching.backend.model.dto.umsAdmin.UmsStudentPageQueryDTO; |
||||||
|
import com.teaching.backend.model.entity.umsAdmin.*; |
||||||
|
import com.teaching.backend.service.impl.courses.CoursesServiceImpl; |
||||||
|
import com.teaching.backend.service.umsAdmin.UmsStudentManageService; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
import org.springframework.beans.BeanUtils; |
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.LinkedHashSet; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
import java.util.stream.Collectors; |
||||||
|
|
||||||
|
|
||||||
|
@Service |
||||||
|
@Slf4j |
||||||
|
public class UmsStudentManageServiceImpl extends ServiceImpl<UmsStudentManageMapper, UmsStudentManage> implements UmsStudentManageService { |
||||||
|
|
||||||
|
@Autowired |
||||||
|
private UmsStudentManageMapper umsStudentManageMapper; |
||||||
|
@Autowired |
||||||
|
private UmsStudentMapper umsStudentMapper; |
||||||
|
@Autowired |
||||||
|
private UmsUserMapper umsUserMapper; |
||||||
|
@Autowired |
||||||
|
private CoursesServiceImpl coursesService; |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
public Map<String, Object> pageQuery(UmsStudentPageQueryDTO umsStudentPageQueryDTO) { |
||||||
|
|
||||||
|
LinkedHashSet<UmsStudentManage> umsStudentManages = coursesService.queryTeacherByStudentList(umsStudentPageQueryDTO.getUserId()); |
||||||
|
|
||||||
|
//总记录数
|
||||||
|
int totalCount = umsStudentManages.size(); |
||||||
|
|
||||||
|
//总页数
|
||||||
|
int totalPages = (int) Math.ceil((double) totalCount / umsStudentPageQueryDTO.getPageSize()); |
||||||
|
|
||||||
|
List<UmsStudentManage> umsStudentManageList = umsStudentManages.stream() |
||||||
|
.skip((umsStudentPageQueryDTO.getPage() - 1) * umsStudentPageQueryDTO.getPageSize()) |
||||||
|
.limit(umsStudentPageQueryDTO.getPageSize()) |
||||||
|
.collect(Collectors.toList()); |
||||||
|
|
||||||
|
Map<String, Object> result = new HashMap<>(); |
||||||
|
result.put("Records", umsStudentManageList); |
||||||
|
result.put("totalCount", totalCount); |
||||||
|
result.put("totalPages", totalPages); |
||||||
|
result.put("currentPage", umsStudentPageQueryDTO.getPage()); |
||||||
|
|
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public UmsStudentManage getByIdStudentAndUser(Long id) { |
||||||
|
UmsStudentManage studentAndUser = umsStudentManageMapper.getByIdStudentAndUser(id); |
||||||
|
return studentAndUser; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void updateStudentAndUser(UmsStudentManage umsStudentManage) { |
||||||
|
UmsStudent umsStudent = new UmsStudent(); |
||||||
|
BeanUtils.copyProperties(umsStudentManage,umsStudent); |
||||||
|
boolean studentInfo = umsStudentMapper.updateStudentInfo(umsStudent); |
||||||
|
if (studentInfo == false){ |
||||||
|
throw new BusinessException(400,"修改失败"); |
||||||
|
} |
||||||
|
UmsUser umsUser = new UmsUser(); |
||||||
|
BeanUtils.copyProperties(umsStudentManage, umsUser); |
||||||
|
umsUser.setId(Long.valueOf(umsStudentManage.getUserId())); |
||||||
|
boolean userInformation = umsUserMapper.updateUserInformation(umsUser); |
||||||
|
if (userInformation == false){ |
||||||
|
throw new BusinessException(400,"修改失败"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void startOrStop(String status, Long id) { |
||||||
|
UmsUser umsUser = new UmsUser(); |
||||||
|
umsUser.setStatus(status); |
||||||
|
umsUser.setId(id); |
||||||
|
boolean updateUserInformation = umsUserMapper.updateUserInformation(umsUser); |
||||||
|
if (updateUserInformation == false){ |
||||||
|
throw new BusinessException(400,"账号状态修改失败"); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,17 @@ |
|||||||
|
package com.teaching.backend.service.records; |
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||||
|
import com.teaching.backend.model.entity.records.ResourceLearningNumber; |
||||||
|
|
||||||
|
/** |
||||||
|
* <p> |
||||||
|
* 服务类 |
||||||
|
* </p> |
||||||
|
* |
||||||
|
* @author author |
||||||
|
* @since 2024-07-29 |
||||||
|
*/ |
||||||
|
public interface IResourceLearningNumberService extends IService<ResourceLearningNumber> { |
||||||
|
|
||||||
|
} |
@ -0,0 +1,21 @@ |
|||||||
|
package com.teaching.backend.service.umsAdmin; |
||||||
|
|
||||||
|
|
||||||
|
import cn.hutool.db.PageResult; |
||||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||||
|
import com.teaching.backend.model.dto.umsAdmin.UmsStudentPageQueryDTO; |
||||||
|
import com.teaching.backend.model.entity.umsAdmin.UmsStudentManage; |
||||||
|
|
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
public interface UmsStudentManageService extends IService<UmsStudentManage> { |
||||||
|
|
||||||
|
|
||||||
|
Map<String, Object> pageQuery(UmsStudentPageQueryDTO umsStudentPageQueryDTO); |
||||||
|
|
||||||
|
UmsStudentManage getByIdStudentAndUser(Long id); |
||||||
|
|
||||||
|
void updateStudentAndUser(UmsStudentManage umsStudentManage); |
||||||
|
|
||||||
|
void startOrStop(String status, Long id); |
||||||
|
} |
@ -1,5 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|
||||||
<mapper namespace="com.teaching.backend.mapper.umsAdmin.UmsPermissionMapper"> |
|
||||||
|
|
||||||
</mapper> |
|
@ -0,0 +1,46 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||||
|
<mapper namespace="com.teaching.backend.mapper.umsAdmin.UmsStudentManageMapper"> |
||||||
|
|
||||||
|
<select id="queryStudent" resultType="com.teaching.backend.model.entity.umsAdmin.UmsStudentManage"> |
||||||
|
select * |
||||||
|
from ums_student us |
||||||
|
INNER JOIN ums_user uu ON us.user_id = uu.id |
||||||
|
WHERE us.user_id = #{userId} |
||||||
|
</select> |
||||||
|
<select id="pageQueryStudent" resultType="com.teaching.backend.model.entity.umsAdmin.UmsStudentManage"> |
||||||
|
select * |
||||||
|
from ums_student us |
||||||
|
INNER JOIN ums_user uu ON us.user_id = uu.id |
||||||
|
<where> |
||||||
|
<if test="name != null and name != ''"> |
||||||
|
and name like concat('%',#{name},'%') |
||||||
|
</if> |
||||||
|
<if test="number != null and number != ''"> |
||||||
|
and number like concat('%',#{number},'%') |
||||||
|
</if> |
||||||
|
</where> |
||||||
|
LIMIT #{pageSize} OFFSET #{offset}; |
||||||
|
</select> |
||||||
|
<select id="pageQueryStudentCount" resultType="java.lang.Integer"> |
||||||
|
SELECT COUNT(*) |
||||||
|
FROM ums_student us |
||||||
|
INNER JOIN ums_user uu ON us.user_id = uu.id |
||||||
|
<where> |
||||||
|
<if test="name != null and name != ''"> |
||||||
|
AND us.name LIKE CONCAT('%', #{name}, '%') |
||||||
|
</if> |
||||||
|
<if test="number != null and number != ''"> |
||||||
|
AND us.number LIKE CONCAT('%', #{number}, '%') |
||||||
|
</if> |
||||||
|
</where> |
||||||
|
</select> |
||||||
|
<select id="getByIdStudentAndUser" resultType="com.teaching.backend.model.entity.umsAdmin.UmsStudentManage" |
||||||
|
parameterType="java.lang.Long"> |
||||||
|
select * |
||||||
|
from ums_student us |
||||||
|
INNER JOIN ums_user uu ON us.user_id = uu.id |
||||||
|
WHERE us.id = #{id} |
||||||
|
</select> |
||||||
|
|
||||||
|
</mapper> |
@ -1,101 +0,0 @@ |
|||||||
package com.teaching; |
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test; |
|
||||||
import org.springframework.util.DigestUtils; |
|
||||||
|
|
||||||
import java.io.*; |
|
||||||
import java.util.Arrays; |
|
||||||
import java.util.Collections; |
|
||||||
import java.util.Comparator; |
|
||||||
import java.util.List; |
|
||||||
|
|
||||||
public class MinioTest { |
|
||||||
//分块测试
|
|
||||||
@Test |
|
||||||
public void testChunk() throws IOException { |
|
||||||
//源文件
|
|
||||||
File sourseFile = new File("D:/Users/Desktop/image/剪映/7.18/7月20.mp4"); |
|
||||||
//分块文件存储路径
|
|
||||||
String chunkFilePath = "D:/Users/Desktop/image/剪映/7.18/chunk/"; |
|
||||||
//分块文件大小
|
|
||||||
int chunkSize = 1024 * 1024 * 1; |
|
||||||
//分块文件个数
|
|
||||||
int chunkNum = (int) Math.ceil(sourseFile.length() * 1.0 / chunkSize); |
|
||||||
//使用流从源文件读数据,向分块文件中写数据
|
|
||||||
RandomAccessFile raf_r = new RandomAccessFile(sourseFile, "r"); |
|
||||||
//缓存区
|
|
||||||
byte[] bytes = new byte[1024]; |
|
||||||
for (int i = 0; i < chunkNum; i++) { |
|
||||||
File chunkFile = new File(chunkFilePath + i); |
|
||||||
//分块文件写入流
|
|
||||||
RandomAccessFile raf_rw = new RandomAccessFile(chunkFile, "rw"); |
|
||||||
int len = -1; |
|
||||||
while((len=raf_r.read(bytes)) != -1){ |
|
||||||
raf_rw.write(bytes, 0, len); |
|
||||||
if (chunkFile.length() >= chunkSize){ |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
raf_rw.close(); |
|
||||||
} |
|
||||||
raf_r.close(); |
|
||||||
} |
|
||||||
|
|
||||||
//将分块进行合并
|
|
||||||
@Test |
|
||||||
public void testMerge() throws IOException { |
|
||||||
//块文件目录
|
|
||||||
File chunkFolder = new File("D:\\Users\\Desktop\\image\\剪映\\7.18\\chunk"); |
|
||||||
//源文件
|
|
||||||
File sourseFile = new File("D:/Users/Desktop/image/剪映/7.18/7月20.mp4"); |
|
||||||
//合并后的文件
|
|
||||||
File mergeFile = new File("D:/Users/Desktop/image/剪映/7.18/7月20_merge.mp4"); |
|
||||||
|
|
||||||
//取出所有分块文件
|
|
||||||
File[] files = chunkFolder.listFiles(); |
|
||||||
//将数组转成list
|
|
||||||
List<File> fileList = Arrays.asList(files); |
|
||||||
//对分块文件排序
|
|
||||||
Collections.sort(fileList, new Comparator<File>() { |
|
||||||
@Override |
|
||||||
public int compare(File o1, File o2) { |
|
||||||
return Integer.parseInt(o1.getName()) - Integer.parseInt(o2.getName()); //升序
|
|
||||||
} |
|
||||||
}); |
|
||||||
//向合并文件写的流
|
|
||||||
RandomAccessFile raf_rw = new RandomAccessFile(mergeFile, "rw"); |
|
||||||
//缓存区
|
|
||||||
byte[] bytes = new byte[1024]; |
|
||||||
//遍历分块文件,向合并的文件写
|
|
||||||
for (File file : fileList) { |
|
||||||
//读分块的流
|
|
||||||
RandomAccessFile raf_r = new RandomAccessFile(file, "r"); |
|
||||||
int len = -1; |
|
||||||
while((len = raf_r.read(bytes)) != -1){ |
|
||||||
raf_rw.write(bytes, 0, len); |
|
||||||
} |
|
||||||
raf_r.close(); |
|
||||||
} |
|
||||||
raf_rw.close(); |
|
||||||
//合并文件完成后对合并的文件校验
|
|
||||||
FileInputStream fileInputStream_merge = new FileInputStream(mergeFile); |
|
||||||
FileInputStream fileInputStream_source = new FileInputStream(sourseFile); |
|
||||||
String md5_merge = DigestUtils.md5DigestAsHex(fileInputStream_merge); |
|
||||||
String md5_source = DigestUtils.md5DigestAsHex(fileInputStream_source); |
|
||||||
if (md5_merge.equals(md5_source)){ |
|
||||||
System.out.println("文件合并成功!"); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
//将分块文件上传到minio
|
|
||||||
public void uploadChunk(){ |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
//调用minio接口合并分块
|
|
||||||
|
|
||||||
|
|
||||||
//批量清理分块文件
|
|
||||||
|
|
||||||
|
|
||||||
} |
|
@ -1,36 +0,0 @@ |
|||||||
package com.teaching; |
|
||||||
|
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j; |
|
||||||
import org.junit.jupiter.api.Test; |
|
||||||
import org.springframework.boot.test.context.SpringBootTest; |
|
||||||
|
|
||||||
import javax.annotation.Resource; |
|
||||||
|
|
||||||
@Slf4j |
|
||||||
@SpringBootTest |
|
||||||
public class test { |
|
||||||
|
|
||||||
|
|
||||||
@Test |
|
||||||
public void countknowledge(){ |
|
||||||
String userId = "2"; |
|
||||||
// System.out.println(knowledgeLearningCountService.list());
|
|
||||||
// List<KnowledgeLearningCount> list = knowledgeLearningCountService.query().eq("user_id", userId).list();
|
|
||||||
// HashSet<KnowledgeLearningCount> set = new HashSet<>(list);
|
|
||||||
// System.out.println(set.size());
|
|
||||||
// Long count = knowledgeLearningCountService.query().eq("user_id", userId).count();
|
|
||||||
// if (count == 0){
|
|
||||||
// KnowledgeLearningCount knowledgeLearningCount = new KnowledgeLearningCount();
|
|
||||||
// knowledgeLearningCount.setUserId(userId);
|
|
||||||
// knowledgeLearningCount.setNumber(1);
|
|
||||||
// knowledgeLearningCountService.save(knowledgeLearningCount);
|
|
||||||
// }else {
|
|
||||||
// //该用户学习知识点数+1
|
|
||||||
// boolean is = knowledgeLearningCountService.update()
|
|
||||||
// .setSql("number = "+set.size())
|
|
||||||
// .eq("user_id", userId).update();
|
|
||||||
// System.out.println(is);
|
|
||||||
// }
|
|
||||||
} |
|
||||||
} |
|
Loading…
Reference in new issue