网盘代码集成(未完成)

This commit is contained in:
pengjie 2023-05-10 18:25:17 +08:00
parent aafa3a049a
commit 2856687a60
180 changed files with 11444 additions and 114 deletions

16
pom.xml
View File

@ -282,6 +282,18 @@
<version>3.2.34</version>
</dependency>
<dependency>
<groupId>com.qiwenshare</groupId>
<artifactId>ufop-spring-boot-starter</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>org</groupId>
<artifactId>jaudiotagger</artifactId>
<version>2.0.1</version>
</dependency>
<!-- opencv -->
<dependency>
<groupId>org.bytedeco</groupId>
@ -420,12 +432,12 @@
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.7.4</version>
<version>5.8.4</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-core</artifactId>
<version>5.7.4</version>
<version>5.8.4</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>

4287
replay_pid19100.log Normal file

File diff suppressed because one or more lines are too long

View File

@ -7,7 +7,6 @@ import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@ -17,7 +16,6 @@ import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.security.web.firewall.HttpFirewall;
import org.springframework.security.web.firewall.StrictHttpFirewall;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* @program: itbgpproject
@ -25,7 +23,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
* @author: Mr.Peng
* @create: 2020-08-03 14:50
**/
@MapperScan({"com.zhgd.*.*.*.mapper","com.zhwl.*.*.*.mapper"})
@MapperScan({"com.zhgd.*.*.*.mapper","com.zhwl.*.*.*.mapper","com.zhgd.*.*.*.*.mapper"})
@EnableAsync //开启异步调用
@EnableScheduling
@EnableFileStorage

View File

@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -58,4 +59,20 @@ public class MonitorApi {
}
return jsonObject.getJSONObject("data").get("url").toString();
}
/**
* 云台操作
* @return
*/
public JSONObject controlling(Map<String, Object> map) {
String path = "/api/video/v1/ptzs/controlling";
JSONObject jsonBody = JSONObject.parseObject(JSON.toJSONString(map));
Map<String, String> headMap = new HashMap<>();
map.put("userId", "admin");
JSONObject jsonObject = cameraPreview.GetCameraPreviewURL(path, jsonBody.toJSONString(), headMap);
if (jsonObject == null) {
return null;
}
return jsonObject;
}
}

View File

@ -123,7 +123,7 @@ public class HardWareCallbackController {
environmentAlarm.setProjectSn(environmentDev.getProjectSn());
environmentAlarm.setEngineeringSn(environmentDev.getEngineeringSn());
environmentAlarm.setState(0);
environmentAlarm.setOffsetValue(environmentAlarm.getAlarmValue() - environmentAlarm.getThresholdValue());
environmentAlarm.setOffsetValue(CommonUtil.offset(environmentAlarm.getAlarmValue(), environmentAlarm.getThresholdValue()));
environmentAlarmService.save(environmentAlarm);
long num = redisRepository.leftPush(CacheConstants.ENVIRONMENT_ALARM_LIST + environmentDev.getCode(), environmentAlarm);
if (num > 10) {

View File

@ -68,6 +68,7 @@ public class NoticeController {
wrapper.like(Notice::getContent, content);
}
wrapper.eq(Notice::getCreateBy, SecurityUtil.getUser().getSn());
wrapper.orderByDesc(Notice::getCreateTime);
IPage<Notice> pageList = noticeService.page(page, wrapper);
return Result.success(pageList);
}

View File

@ -12,6 +12,8 @@ import com.zhgd.xmgl.modules.basicdata.entity.Policy;
import com.zhgd.xmgl.modules.basicdata.service.IPolicyService;
import com.zhgd.xmgl.modules.basicdata.vo.PolicyVo;
import com.zhgd.xmgl.security.SecurityUtil;
import com.zhgd.xmgl.valid.AddGroup;
import com.zhgd.xmgl.valid.EditGroup;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
@ -20,6 +22,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@ -66,6 +69,7 @@ public class PolicyController {
wrapper.like("p.content", content);
}
wrapper.eq("p.create_by", SecurityUtil.getUser().getSn());
wrapper.orderByDesc("p.create_time");
IPage<PolicyDto> pageList = policyService.fromMePageList(page, wrapper);
return Result.success(pageList);
}
@ -110,7 +114,7 @@ public class PolicyController {
@OperLog(operModul = "政策法规管理", operType = "新增", operDesc = "添加政策法规信息")
@ApiOperation(value = " 添加政策法规信息", notes = "添加政策法规信息", httpMethod = "POST")
@PostMapping(value = "/add")
public Result<Object> add(@RequestBody PolicyVo policyVo) {
public Result<Object> add(@RequestBody @Validated(AddGroup.class) PolicyVo policyVo) {
return Result.success(policyService.saveInfo(policyVo));
}
@ -122,7 +126,7 @@ public class PolicyController {
@OperLog(operModul = "政策法规管理", operType = "修改", operDesc = "编辑政策法规信息")
@ApiOperation(value = "编辑政策法规信息", notes = "编辑政策法规信息", httpMethod = "POST")
@PostMapping(value = "/edit")
public Result<Policy> edit(@RequestBody PolicyVo policyVo) {
public Result<Policy> edit(@RequestBody @Validated(EditGroup.class) PolicyVo policyVo) {
Result<Policy> result = new Result<Policy>();
Policy policyEntity = policyService.getById(policyVo.getPolicyId());
if (policyEntity == null) {

View File

@ -91,7 +91,7 @@ public class VideoOpController {
/**
* 海康监控图片抓拍
*/
@OperLog(operModul = "文件管理", operType = "文件上传", operDesc = "海康监控图片抓拍")
@OperLog(operModul = "视频操作管理", operType = "文件上传", operDesc = "海康监控图片抓拍")
@ApiOperation(value = "海康监控图片抓拍", notes = "海康监控图片抓拍", httpMethod="POST")
@ApiImplicitParam(name = "monitorCode", value = "监控点编码", paramType = "query", dataType = "String")
@PostMapping("/manualCapture")
@ -106,4 +106,20 @@ public class VideoOpController {
.setPlatform("minio-1") //使用指定的存储平台
.upload());
}
/**
* 云台操作
*/
@OperLog(operModul = "视频操作管理", operType = "控制", operDesc = "云台操作")
@ApiOperation(value = "云台操作", notes = "云台操作", httpMethod="POST")
@ApiImplicitParams({
@ApiImplicitParam(name = "cameraIndexCode", value = "监控点编码", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "action", value = "0-开始; 1停止", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "command", value = "操作方式(参考海康文档)", paramType = "query", dataType = "String")
})
@PostMapping("/controlling")
public Result<Object> controlling(@RequestBody Map<String, Object> map) {
JSONObject jsonObject = monitorApi.controlling(map);
return Result.success(jsonObject);
}
}

View File

@ -1,13 +1,9 @@
package com.zhgd.xmgl.modules.basicdata.controller.enterprise;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zhgd.annotation.OperLog;
import com.zhgd.jeecg.common.api.vo.Result;
import com.zhgd.jeecg.common.system.query.QueryGenerator;
import com.zhgd.xmgl.modules.basicdata.entity.SystemDept;
import com.zhgd.xmgl.modules.basicdata.service.ISystemDeptService;
import com.zhgd.xmgl.security.SecurityUser;
import com.zhgd.xmgl.security.SecurityUtil;
import com.zhgd.xmgl.valid.AddGroup;
import com.zhgd.xmgl.valid.EditGroup;
import io.swagger.annotations.Api;
@ -49,10 +45,7 @@ public class EntSystemDeptController {
@PostMapping(value = "/list")
public Result<List<SystemDept>> queryList(@RequestBody SystemDept systemDept) {
Result<List<SystemDept>> result = new Result<List<SystemDept>>();
SecurityUser user = SecurityUtil.getUser();
systemDept.setSn(user.getSn());
QueryWrapper<SystemDept> queryWrapper = QueryGenerator.initQueryWrapper(systemDept);
List<SystemDept> list = systemDeptService.list(queryWrapper);
List<SystemDept> list = systemDeptService.getList(systemDept);
result.setSuccess(true);
result.setResult(list);
return result;

View File

@ -65,6 +65,7 @@ public class GovMonitorQuestionController {
@ApiOperation(value = " 添加视频抓拍记录信息", notes = "添加视频抓拍记录信息" , httpMethod="POST")
@PostMapping(value = "/add")
public Result<Object> add(@RequestBody MonitorQuestion monitorQuestion) {
monitorQuestion.setState(0);
monitorQuestionService.saveInfo(monitorQuestion);
return Result.ok("添加成功!");
}

View File

@ -1,13 +1,9 @@
package com.zhgd.xmgl.modules.basicdata.controller.government;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zhgd.annotation.OperLog;
import com.zhgd.jeecg.common.api.vo.Result;
import com.zhgd.xmgl.modules.basicdata.entity.SystemDept;
import com.zhgd.xmgl.modules.basicdata.service.ISystemDeptService;
import com.zhgd.xmgl.security.SecurityUser;
import com.zhgd.xmgl.security.SecurityUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
@ -46,13 +42,7 @@ public class GovSystemDeptController {
@PostMapping(value = "/list")
public Result<List<SystemDept>> queryList(@RequestBody SystemDept systemDept) {
Result<List<SystemDept>> result = new Result<List<SystemDept>>();
SecurityUser user = SecurityUtil.getUser();
LambdaQueryWrapper<SystemDept> queryWrapper = Wrappers.<SystemDept>lambdaQuery();
queryWrapper.eq(SystemDept::getSn, user.getSn());
if (systemDept.getDeptId() != null) {
queryWrapper.ne(SystemDept::getDeptId, systemDept.getDeptId());
}
List<SystemDept> list = systemDeptService.list(queryWrapper);
List<SystemDept> list = systemDeptService.getList(systemDept);
result.setSuccess(true);
result.setResult(list);
return result;

View File

@ -1,13 +1,9 @@
package com.zhgd.xmgl.modules.basicdata.controller.project;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zhgd.annotation.OperLog;
import com.zhgd.jeecg.common.api.vo.Result;
import com.zhgd.jeecg.common.system.query.QueryGenerator;
import com.zhgd.xmgl.modules.basicdata.entity.SystemDept;
import com.zhgd.xmgl.modules.basicdata.service.ISystemDeptService;
import com.zhgd.xmgl.security.SecurityUser;
import com.zhgd.xmgl.security.SecurityUtil;
import com.zhgd.xmgl.valid.AddGroup;
import com.zhgd.xmgl.valid.EditGroup;
import io.swagger.annotations.Api;
@ -49,10 +45,7 @@ public class SystemDeptController {
@PostMapping(value = "/list")
public Result<List<SystemDept>> queryList(@RequestBody SystemDept systemDept) {
Result<List<SystemDept>> result = new Result<List<SystemDept>>();
SecurityUser user = SecurityUtil.getUser();
systemDept.setSn(user.getSn());
QueryWrapper<SystemDept> queryWrapper = QueryGenerator.initQueryWrapper(systemDept);
List<SystemDept> list = systemDeptService.list(queryWrapper);
List<SystemDept> list = systemDeptService.getList(systemDept);
result.setSuccess(true);
result.setResult(list);
return result;

View File

@ -13,17 +13,17 @@ import lombok.Data;
public class AppIndexTopStatDto {
@ApiModelProperty(value = "在建工程")
private Integer building;
private Integer building = 0;
@ApiModelProperty(value = "今年新建")
private Integer newBuild;
private Integer newBuild = 0;
@ApiModelProperty(value = "今年竣工")
private Integer finish;
private Integer finish = 0;
@ApiModelProperty(value = "企业总数")
private Integer enterpriseNum;
private Integer enterpriseNum = 0;
@ApiModelProperty(value = "实名制人员总数")
private Integer workerNum;
private Integer workerNum = 0;
}

View File

@ -40,4 +40,7 @@ public class EngineeringDeviceDto {
@ApiModelProperty(value = "项目AI预警信息统计")
private String aiAlarmStat;
@ApiModelProperty(value = "AI预警状态(true预警;false正常)")
private Boolean aiAlarmFlag;
}

View File

@ -31,4 +31,7 @@ public class ProjectDeviceDto {
@ApiModelProperty(value = "项目AI预警信息统计")
private String aiAlarmStat;
@ApiModelProperty(value = "AI预警状态(true预警;false正常)")
private Boolean aiAlarmFlag;
}

View File

@ -3,11 +3,14 @@ package com.zhgd.xmgl.modules.basicdata.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.zhgd.xmgl.valid.AddGroup;
import com.zhgd.xmgl.valid.EditGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.Date;
@ -39,6 +42,7 @@ public class AnnexFile implements Serializable {
* 文件名
*/
@Excel(name = "文件名", width = 15)
@NotBlank(message = "文件不能为空", groups = {AddGroup.class, EditGroup.class})
@ApiModelProperty(value = "文件名")
private String fileName;
/**
@ -51,6 +55,7 @@ public class AnnexFile implements Serializable {
* 文件url
*/
@Excel(name = "文件url", width = 15)
@NotBlank(message = "文件不能为空", groups = {AddGroup.class, EditGroup.class})
@ApiModelProperty(value = "文件url")
private String fileUrl;
/**

View File

@ -98,7 +98,12 @@ public class MonitorQuestion implements Serializable {
@Excel(name = "工程sn", width = 20)
@ApiModelProperty(value = "工程sn")
private String engineeringSn;
/**
* 整改情况
*/
@Excel(name = "整改情况", width = 15)
@ApiModelProperty(value = "整改情况")
private String solveDesc;
/**
* 视频名称
*/

View File

@ -77,10 +77,10 @@ public class SystemDept implements Serializable {
@ApiModelProperty(value = "邮箱")
private String email;
/**
* 部门状态0正常 1停用
* 部门状态1正常 0停用
*/
@Excel(name = "部门状态(0正常 1停用)", width = 15)
@ApiModelProperty(value = "部门状态(0正常 1停用)")
@Excel(name = "部门状态(1正常 0停用)", width = 15)
@ApiModelProperty(value = "部门状态(1正常 0停用)")
private Integer status;
/**

View File

@ -0,0 +1,13 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.api;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zhgd.xmgl.modules.basicdata.qiwen.domain.CommonFile;
import com.zhgd.xmgl.modules.basicdata.qiwen.vo.commonfile.CommonFileListVo;
import com.zhgd.xmgl.modules.basicdata.qiwen.vo.commonfile.CommonFileUser;
import java.util.List;
public interface ICommonFileService extends IService<CommonFile> {
List<CommonFileUser> selectCommonFileUser(String userId);
List<CommonFileListVo> selectCommonFileByUser(String userId, String sessionUserId);
}

View File

@ -0,0 +1,13 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.api;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zhgd.xmgl.modules.basicdata.qiwen.domain.FileNotice;
import com.zhgd.xmgl.modules.basicdata.qiwen.dto.notice.NoticeListDTO;
public interface IFileNoticeService extends IService<FileNotice> {
IPage<FileNotice> selectUserPage(NoticeListDTO noticeListDTO);
}

View File

@ -0,0 +1,8 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.api;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zhgd.xmgl.modules.basicdata.qiwen.domain.FilePermission;
public interface IFilePermissionService extends IService<FilePermission> {
}

View File

@ -0,0 +1,16 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.api;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zhgd.xmgl.modules.basicdata.qiwen.domain.FileBean;
import com.zhgd.xmgl.modules.basicdata.qiwen.vo.file.FileDetailVO;
public interface IFileService extends IService<FileBean> {
Long getFilePointCount(String fileId);
void unzipFile(String userFileId, int unzipMode, String filePath);
void updateFileDetail(String userFileId, String identifier, long fileSize);
FileDetailVO getFileDetail(String userFileId);
}

View File

@ -0,0 +1,27 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.api;
import com.zhgd.xmgl.modules.basicdata.qiwen.domain.FileBean;
import com.zhgd.xmgl.modules.basicdata.qiwen.dto.file.DownloadFileDTO;
import com.zhgd.xmgl.modules.basicdata.qiwen.dto.file.PreviewDTO;
import com.zhgd.xmgl.modules.basicdata.qiwen.dto.file.UploadFileDTO;
import com.zhgd.xmgl.modules.basicdata.qiwen.vo.file.UploadFileVo;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
public interface IFiletransferService {
UploadFileVo uploadFileSpeed(UploadFileDTO uploadFileDTO);
void uploadFile(HttpServletRequest request, UploadFileDTO UploadFileDto, String userId);
void downloadFile(HttpServletResponse httpServletResponse, DownloadFileDTO downloadFileDTO);
void downloadUserFileList(HttpServletResponse httpServletResponse, String filePath, String fileName, List<String> userFileIds);
void previewFile(HttpServletResponse httpServletResponse, PreviewDTO previewDTO);
void previewPictureFile(HttpServletResponse httpServletResponse, PreviewDTO previewDTO);
void deleteFile(FileBean fileBean);
Long selectStorageSizeByUserId(String userId);
}

View File

@ -0,0 +1,13 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.api;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zhgd.xmgl.modules.basicdata.qiwen.domain.RecoveryFile;
import com.zhgd.xmgl.modules.basicdata.qiwen.vo.file.RecoveryFileListVo;
import java.util.List;
public interface IRecoveryFileService extends IService<RecoveryFile> {
void deleteUserFileByDeleteBatchNum(String deleteBatchNum);
void restorefile(String deleteBatchNum, String filePath, String sessionUserId);
List<RecoveryFileListVo> selectRecoveryFileList(String userId);
}

View File

@ -0,0 +1,12 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.api;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zhgd.xmgl.modules.basicdata.qiwen.domain.ShareFile;
import com.zhgd.xmgl.modules.basicdata.qiwen.vo.share.ShareFileListVO;
import java.util.List;
public interface IShareFileService extends IService<ShareFile> {
void batchInsertShareFile(List<ShareFile> shareFiles);
List<ShareFileListVO> selectShareFileList(String shareBatchNum, String filePath);
}

View File

@ -0,0 +1,13 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.api;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zhgd.xmgl.modules.basicdata.qiwen.domain.Share;
import com.zhgd.xmgl.modules.basicdata.qiwen.dto.sharefile.ShareListDTO;
import com.zhgd.xmgl.modules.basicdata.qiwen.vo.share.ShareListVO;
import java.util.List;
public interface IShareService extends IService<Share> {
List<ShareListVO> selectShareList(ShareListDTO shareListDTO, String userId);
int selectShareListTotalCount(ShareListDTO shareListDTO, String userId);
}

View File

@ -0,0 +1,9 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.api;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zhgd.xmgl.modules.basicdata.qiwen.domain.StorageBean;
public interface IStorageService extends IService<StorageBean> {
Long getTotalStorageSize(String userId);
boolean checkStorage(String userId, Long fileSize);
}

View File

@ -0,0 +1,14 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.api;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zhgd.xmgl.modules.basicdata.qiwen.domain.SysParam;
/**
* @author MAC
* @version 1.0
* @description: TODO
* @date 2021/12/30 14:54
*/
public interface ISysParamService extends IService<SysParam> {
String getValue(String key);
}

View File

@ -0,0 +1,10 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.api;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zhgd.xmgl.modules.basicdata.qiwen.domain.UploadTaskDetail;
import java.util.List;
public interface IUploadTaskDetailService extends IService<UploadTaskDetail> {
List<Integer> getUploadedChunkNumList(String identifier);
}

View File

@ -0,0 +1,8 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.api;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zhgd.xmgl.modules.basicdata.qiwen.domain.UploadTask;
public interface IUploadTaskService extends IService<UploadTask> {
}

View File

@ -0,0 +1,26 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.api;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zhgd.xmgl.modules.basicdata.qiwen.domain.UserFile;
import com.zhgd.xmgl.modules.basicdata.qiwen.vo.file.FileListVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface IUserFileService extends IService<UserFile> {
List<UserFile> selectUserFileByNameAndPath(String fileName, String filePath, String userId);
List<UserFile> selectSameUserFile(String fileName, String filePath, String extendName, String userId);
IPage<FileListVO> userFileList(String userId, String filePath, Long beginCount, Long pageCount);
void updateFilepathByUserFileId(String userFileId, String newfilePath, String userId);
void userFileCopy(String userId, String userFileId, String newfilePath);
IPage<FileListVO> getFileByFileType(Integer fileTypeId, Long currentPage, Long pageCount, String userId);
List<UserFile> selectUserFileListByPath(String filePath, String userId);
List<UserFile> selectFilePathTreeByUserId(String userId);
void deleteUserFile(String userFileId, String sessionUserId);
List<UserFile> selectUserFileByLikeRightFilePath(@Param("filePath") String filePath, @Param("userId") String userId);
}

View File

@ -0,0 +1,192 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.component;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.qiwenshare.ufop.factory.UFOPFactory;
import com.qiwenshare.ufop.operation.copy.domain.CopyFile;
import com.qiwenshare.ufop.util.UFOPUtils;
import com.zhgd.xmgl.modules.basicdata.qiwen.api.IFiletransferService;
import com.zhgd.xmgl.modules.basicdata.qiwen.api.IRecoveryFileService;
import com.zhgd.xmgl.modules.basicdata.qiwen.domain.FileBean;
import com.zhgd.xmgl.modules.basicdata.qiwen.domain.UserFile;
import com.zhgd.xmgl.modules.basicdata.qiwen.io.QiwenFile;
import com.zhgd.xmgl.modules.basicdata.qiwen.mapper.FileMapper;
import com.zhgd.xmgl.modules.basicdata.qiwen.mapper.UserFileMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.Future;
/**
* 功能描述异步任务业务类@Async也可添加在方法上
*/
@Slf4j
@Component
@Async("asyncTaskExecutor")
public class AsyncTaskComp {
@Resource
IRecoveryFileService recoveryFileService;
@Resource
IFiletransferService filetransferService;
@Resource
UFOPFactory ufopFactory;
@Resource
UserFileMapper userFileMapper;
@Resource
FileMapper fileMapper;
@Resource
FileDealComp fileDealComp;
@Value("${ufop.storage-type}")
private Integer storageType;
public Integer getFilePointCount(String fileId) {
LambdaQueryWrapper<UserFile> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(UserFile::getFileId, fileId);
return userFileMapper.selectCount(lambdaQueryWrapper);
}
public Future<String> deleteUserFile(String userFileId) {
UserFile userFile = userFileMapper.selectById(userFileId);
if (userFile.getIsDir() == 1) {
LambdaQueryWrapper<UserFile> userFileLambdaQueryWrapper = new LambdaQueryWrapper<>();
userFileLambdaQueryWrapper.eq(UserFile::getDeleteBatchNum, userFile.getDeleteBatchNum());
List<UserFile> list = userFileMapper.selectList(userFileLambdaQueryWrapper);
recoveryFileService.deleteUserFileByDeleteBatchNum(userFile.getDeleteBatchNum());
for (UserFile userFileItem : list) {
Integer filePointCount = getFilePointCount(userFileItem.getFileId());
if (filePointCount != null && filePointCount == 0 && userFileItem.getIsDir() == 0) {
FileBean fileBean = fileMapper.selectById(userFileItem.getFileId());
try {
filetransferService.deleteFile(fileBean);
fileMapper.deleteById(fileBean.getFileId());
} catch (Exception e) {
log.error("删除本地文件失败:" + JSON.toJSONString(fileBean));
}
}
}
} else {
recoveryFileService.deleteUserFileByDeleteBatchNum(userFile.getDeleteBatchNum());
Integer filePointCount = getFilePointCount(userFile.getFileId());
if (filePointCount != null && filePointCount == 0 && userFile.getIsDir() == 0) {
FileBean fileBean = fileMapper.selectById(userFile.getFileId());
try {
filetransferService.deleteFile(fileBean);
fileMapper.deleteById(fileBean.getFileId());
} catch (Exception e) {
log.error("删除本地文件失败:" + JSON.toJSONString(fileBean));
}
}
}
return new AsyncResult<>("deleteUserFile");
}
// public Future<String> checkESUserFileId(String userFileId) {
// UserFile userFile = userFileMapper.selectById(userFileId);
// if (userFile == null) {
// fileDealComp.deleteESByUserFileId(userFileId);
// }
// return new AsyncResult<>("checkUserFileId");
// }
public Future<String> saveUnzipFile(UserFile userFile, FileBean fileBean, int unzipMode, String entryName, String filePath) {
String unzipUrl = UFOPUtils.getTempFile(fileBean.getFileUrl()).getAbsolutePath().replace("." + userFile.getExtendName(), "");
String totalFileUrl = unzipUrl + entryName;
File currentFile = new File(totalFileUrl);
String fileId = null;
if (!currentFile.isDirectory()) {
FileInputStream fis = null;
String md5Str = UUID.randomUUID().toString();
try {
fis = new FileInputStream(currentFile);
md5Str = DigestUtils.md5Hex(fis);
} catch (IOException e) {
e.printStackTrace();
} finally {
IOUtils.closeQuietly(fis);
}
FileInputStream fileInputStream = null;
try {
Map<String, Object> param = new HashMap<>();
param.put("identifier", md5Str);
List<FileBean> list = fileMapper.selectByMap(param);
if (list != null && !list.isEmpty()) { //文件已存在
fileId = list.get(0).getFileId();
} else { //文件不存在
fileInputStream = new FileInputStream(currentFile);
CopyFile createFile = new CopyFile();
createFile.setExtendName(FilenameUtils.getExtension(totalFileUrl));
String saveFileUrl = ufopFactory.getCopier().copy(fileInputStream, createFile);
FileBean tempFileBean = new FileBean(saveFileUrl, currentFile.length(), storageType, md5Str, userFile.getUserId());
;
fileMapper.insert(tempFileBean);
fileId = tempFileBean.getFileId();
}
} catch (IOException e) {
e.printStackTrace();
} finally {
IOUtils.closeQuietly(fileInputStream);
System.gc();
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
currentFile.delete();
}
}
QiwenFile qiwenFile = null;
if (unzipMode == 0) {
qiwenFile = new QiwenFile(userFile.getFilePath(), entryName, currentFile.isDirectory());
} else if (unzipMode == 1) {
qiwenFile = new QiwenFile(userFile.getFilePath() + "/" + userFile.getFileName(), entryName, currentFile.isDirectory());
} else if (unzipMode == 2) {
qiwenFile = new QiwenFile(filePath, entryName, currentFile.isDirectory());
}
UserFile saveUserFile = new UserFile(qiwenFile, userFile.getUserId(), fileId);
String fileName = fileDealComp.getRepeatFileName(saveUserFile, saveUserFile.getFilePath());
if (saveUserFile.getIsDir() == 1 && !fileName.equals(saveUserFile.getFileName())) {
//如果是目录而且重复什么也不做
} else {
saveUserFile.setFileName(fileName);
userFileMapper.insert(saveUserFile);
}
fileDealComp.restoreParentFilePath(qiwenFile, userFile.getUserId());
return new AsyncResult<>("saveUnzipFile");
}
}

View File

@ -0,0 +1,555 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.component;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.qiwenshare.common.util.DateUtil;
import com.qiwenshare.common.util.MusicUtils;
import com.qiwenshare.common.util.security.SessionUtil;
import com.qiwenshare.ufop.factory.UFOPFactory;
import com.qiwenshare.ufop.operation.copy.Copier;
import com.qiwenshare.ufop.operation.copy.domain.CopyFile;
import com.qiwenshare.ufop.operation.download.Downloader;
import com.qiwenshare.ufop.operation.download.domain.DownloadFile;
import com.qiwenshare.ufop.operation.write.Writer;
import com.qiwenshare.ufop.operation.write.domain.WriteFile;
import com.qiwenshare.ufop.util.UFOPUtils;
import com.zhgd.xmgl.modules.basicdata.qiwen.api.IShareFileService;
import com.zhgd.xmgl.modules.basicdata.qiwen.api.IShareService;
import com.zhgd.xmgl.modules.basicdata.qiwen.config.es.FileSearch;
import com.zhgd.xmgl.modules.basicdata.qiwen.domain.*;
import com.zhgd.xmgl.modules.basicdata.qiwen.io.QiwenFile;
import com.zhgd.xmgl.modules.basicdata.qiwen.mapper.FileMapper;
import com.zhgd.xmgl.modules.basicdata.qiwen.mapper.MusicMapper;
import com.zhgd.xmgl.modules.basicdata.qiwen.mapper.UserFileMapper;
import com.zhgd.xmgl.modules.basicdata.qiwen.util.QiwenFileUtil;
import com.zhgd.xmgl.modules.basicdata.qiwen.util.TreeNode;
import com.zhgd.xmgl.security.SecurityUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.jaudiotagger.audio.AudioFile;
import org.jaudiotagger.audio.AudioFileIO;
import org.jaudiotagger.audio.AudioHeader;
import org.jaudiotagger.audio.flac.FlacFileReader;
import org.jaudiotagger.audio.mp3.MP3File;
import org.jaudiotagger.tag.FieldKey;
import org.jaudiotagger.tag.Tag;
import org.jaudiotagger.tag.datatype.Artwork;
import org.jaudiotagger.tag.id3.AbstractID3v2Frame;
import org.jaudiotagger.tag.id3.AbstractID3v2Tag;
import org.jaudiotagger.tag.id3.framebody.FrameBodyAPIC;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
/**
* 文件逻辑处理组件
*/
@Slf4j
@Component
public class FileDealComp {
@Resource
private UserFileMapper userFileMapper;
@Resource
private FileMapper fileMapper;
@Resource
private IShareService shareService;
@Resource
private IShareFileService shareFileService;
@Resource
private UFOPFactory ufopFactory;
@Resource
private MusicMapper musicMapper;
public static Executor exec = Executors.newFixedThreadPool(10);
/**
* 获取重复文件名
* <p>
* 场景1: 文件还原时 savefilePath 路径下保存 测试.txt 文件重名则会生成 测试(1).txt
* 场景2 上传文件时 savefilePath 路径下保存 测试.txt 文件重名则会生成 测试(1).txt
*
* @param userFile
* @param savefilePath
* @return
*/
public String getRepeatFileName(UserFile userFile, String savefilePath) {
String fileName = userFile.getFileName();
String extendName = userFile.getExtendName();
String userId = userFile.getUserId();
int isDir = userFile.getIsDir();
LambdaQueryWrapper<UserFile> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(UserFile::getFilePath, savefilePath)
.eq(UserFile::getDeleteFlag, 0)
.eq(UserFile::getUserId, userId)
.eq(UserFile::getFileName, fileName)
.eq(UserFile::getIsDir, isDir);
if (userFile.isFile()) {
lambdaQueryWrapper.eq(UserFile::getExtendName, extendName);
}
List<UserFile> list = userFileMapper.selectList(lambdaQueryWrapper);
if (CollectionUtils.isEmpty(list)) {
return fileName;
}
int i = 0;
while (!CollectionUtils.isEmpty(list)) {
i++;
LambdaQueryWrapper<UserFile> lambdaQueryWrapper1 = new LambdaQueryWrapper<>();
lambdaQueryWrapper1.eq(UserFile::getFilePath, savefilePath)
.eq(UserFile::getDeleteFlag, 0)
.eq(UserFile::getUserId, userId)
.eq(UserFile::getFileName, fileName + "(" + i + ")")
.eq(UserFile::getIsDir, isDir);
if (userFile.isFile()) {
lambdaQueryWrapper1.eq(UserFile::getExtendName, extendName);
}
list = userFileMapper.selectList(lambdaQueryWrapper1);
}
return fileName + "(" + i + ")";
}
/**
* 还原父文件路径
* <p>
* 1回收站文件还原操作会将文件恢复到原来的路径下,当还原文件的时候如果父目录已经不存在了则需要把父母录给还原
* 2上传目录
*
* @param sessionUserId
*/
public void restoreParentFilePath(QiwenFile qiwenFile, String sessionUserId) {
if (qiwenFile.isFile()) {
qiwenFile = qiwenFile.getParentFile();
}
while (qiwenFile.getParent() != null) {
String fileName = qiwenFile.getName();
String parentFilePath = qiwenFile.getParent();
LambdaQueryWrapper<UserFile> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(UserFile::getFilePath, parentFilePath)
.eq(UserFile::getFileName, fileName)
.eq(UserFile::getDeleteFlag, 0)
.eq(UserFile::getIsDir, 1)
.eq(UserFile::getUserId, sessionUserId);
List<UserFile> userFileList = userFileMapper.selectList(lambdaQueryWrapper);
if (userFileList.size() == 0) {
UserFile userFile = QiwenFileUtil.getQiwenDir(sessionUserId, parentFilePath, fileName);
try {
userFileMapper.insert(userFile);
} catch (Exception e) {
if (e.getMessage().contains("Duplicate entry")) {
//ignore
} else {
log.error(e.getMessage());
}
}
}
qiwenFile = new QiwenFile(parentFilePath, true);
}
}
/**
* 删除重复的子目录文件
* <p>
* 当还原目录的时候如果其子目录在文件系统中已存在则还原之后进行去重操作
*
* @param filePath
* @param sessionUserId
*/
public void deleteRepeatSubDirFile(String filePath, String sessionUserId) {
log.debug("删除子目录:" + filePath);
LambdaQueryWrapper<UserFile> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.select(UserFile::getFileName, UserFile::getFilePath)
.likeRight(UserFile::getFilePath, QiwenFileUtil.formatLikePath(filePath))
.eq(UserFile::getIsDir, 1)
.eq(UserFile::getDeleteFlag, 0)
.eq(UserFile::getUserId, sessionUserId)
.groupBy(UserFile::getFilePath, UserFile::getFileName)
.having("count(fileName) >= 2");
List<UserFile> repeatList = userFileMapper.selectList(lambdaQueryWrapper);
for (UserFile userFile : repeatList) {
LambdaQueryWrapper<UserFile> lambdaQueryWrapper1 = new LambdaQueryWrapper<>();
lambdaQueryWrapper1.eq(UserFile::getFilePath, userFile.getFilePath())
.eq(UserFile::getFileName, userFile.getFileName())
.eq(UserFile::getDeleteFlag, "0");
List<UserFile> userFiles = userFileMapper.selectList(lambdaQueryWrapper1);
for (int i = 0; i < userFiles.size() - 1; i++) {
userFileMapper.deleteById(userFiles.get(i).getUserFileId());
}
}
}
/**
* 组织一个树目录节点文件移动的时候使用
*
* @param treeNode
* @param id
* @param filePath
* @param nodeNameQueue
* @return
*/
public TreeNode insertTreeNode(TreeNode treeNode, long id, String filePath, Queue<String> nodeNameQueue) {
List<TreeNode> childrenTreeNodes = treeNode.getChildren();
String currentNodeName = nodeNameQueue.peek();
if (currentNodeName == null) {
return treeNode;
}
QiwenFile qiwenFile = new QiwenFile(filePath, currentNodeName, true);
filePath = qiwenFile.getPath();
if (!isExistPath(childrenTreeNodes, currentNodeName)) { //1判断有没有该子节点如果没有则插入
//插入
TreeNode resultTreeNode = new TreeNode();
resultTreeNode.setFilePath(filePath);
resultTreeNode.setLabel(nodeNameQueue.poll());
resultTreeNode.setId(++id);
childrenTreeNodes.add(resultTreeNode);
} else { //2如果有则跳过
nodeNameQueue.poll();
}
if (nodeNameQueue.size() != 0) {
for (int i = 0; i < childrenTreeNodes.size(); i++) {
TreeNode childrenTreeNode = childrenTreeNodes.get(i);
if (currentNodeName.equals(childrenTreeNode.getLabel())) {
childrenTreeNode = insertTreeNode(childrenTreeNode, id * 10, filePath, nodeNameQueue);
childrenTreeNodes.remove(i);
childrenTreeNodes.add(childrenTreeNode);
treeNode.setChildren(childrenTreeNodes);
}
}
} else {
treeNode.setChildren(childrenTreeNodes);
}
return treeNode;
}
/**
* 判断该路径在树节点中是否已经存在
*
* @param childrenTreeNodes
* @param path
* @return
*/
public boolean isExistPath(List<TreeNode> childrenTreeNodes, String path) {
boolean isExistPath = false;
try {
for (TreeNode childrenTreeNode : childrenTreeNodes) {
if (path.equals(childrenTreeNode.getLabel())) {
isExistPath = true;
}
}
} catch (Exception e) {
e.printStackTrace();
}
return isExistPath;
}
public void uploadESByUserFileId(String userFileId) {
try {
Map<String, Object> param = new HashMap<>();
param.put("userFileId", userFileId);
List<UserFile> userfileResult = userFileMapper.selectByMap(param);
if (userfileResult != null && userfileResult.size() > 0) {
FileSearch fileSearch = new FileSearch();
BeanUtil.copyProperties(userfileResult.get(0), fileSearch);
/*if (fileSearch.getIsDir() == 0) {
Reader reader = ufopFactory.getReader(fileSearch.getStorageType());
ReadFile readFile = new ReadFile();
readFile.setFileUrl(fileSearch.getFileUrl());
String content = reader.read(readFile);
//全文搜索
fileSearch.setContent(content);
}*/
// elasticsearchClient.index(i -> i.index("filesearch").id(fileSearch.getUserFileId()).document(fileSearch));
}
} catch (Exception e) {
log.debug("ES更新操作失败请检查配置");
}
}
// public void deleteESByUserFileId(String userFileId) {
// exec.execute(() -> {
// try {
// elasticsearchClient.delete(d -> d
// .index("filesearch")
// .id(userFileId));
// } catch (Exception e) {
// log.debug("ES删除操作失败请检查配置");
// }
// });
//
//
// }
/**
* 根据用户传入的参数判断是否有下载或者预览权限
*
* @return
*/
public boolean checkAuthDownloadAndPreview(String shareBatchNum,
String extractionCode,
String token,
String userFileIds,
Integer platform) {
log.debug("权限检查开始shareBatchNum:{}, extractionCode:{}, token:{}, userFileIds{}", shareBatchNum, extractionCode, token, userFileIds);
if (platform != null && platform == 2) {
return true;
}
String[] userFileIdArr = userFileIds.split(",");
for (String userFileId : userFileIdArr) {
UserFile userFile = userFileMapper.selectById(userFileId);
log.debug(JSON.toJSONString(userFile));
if ("undefined".equals(shareBatchNum) || StringUtils.isEmpty(shareBatchNum)) {
String userId = SecurityUtil.getUser().getUserId();
log.debug(JSON.toJSONString("当前登录session用户id" + userId));
if (userId == null) {
return false;
}
log.debug("文件所属用户id" + userFile.getUserId());
log.debug("登录用户id:" + userId);
if (!userFile.getUserId().equals(userId)) {
log.info("用户id不一致权限校验失败");
return false;
}
} else {
Map<String, Object> param = new HashMap<>();
param.put("shareBatchNum", shareBatchNum);
List<Share> shareList = shareService.listByMap(param);
//判断批次号
if (shareList.size() <= 0) {
log.info("分享批次号不存在,权限校验失败");
return false;
}
Integer shareType = shareList.get(0).getShareType();
if (1 == shareType) {
//判断提取码
if (!shareList.get(0).getExtractionCode().equals(extractionCode)) {
log.info("提取码错误,权限校验失败");
return false;
}
}
param.put("userFileId", userFileId);
List<ShareFile> shareFileList = shareFileService.listByMap(param);
if (shareFileList.size() <= 0) {
log.info("用户id和分享批次号不匹配权限校验失败");
return false;
}
}
}
return true;
}
/**
* 拷贝文件
* 场景修改的文件被多处引用时需要重新拷贝一份然后在新的基础上修改
*
* @param fileBean
* @param userFile
* @return
*/
public String copyFile(FileBean fileBean, UserFile userFile) {
Copier copier = ufopFactory.getCopier();
Downloader downloader = ufopFactory.getDownloader(fileBean.getStorageType());
DownloadFile downloadFile = new DownloadFile();
downloadFile.setFileUrl(fileBean.getFileUrl());
CopyFile copyFile = new CopyFile();
copyFile.setExtendName(userFile.getExtendName());
String fileUrl = copier.copy(downloader.getInputStream(downloadFile), copyFile);
if (downloadFile.getOssClient() != null) {
downloadFile.getOssClient().shutdown();
}
fileBean.setFileUrl(fileUrl);
fileBean.setFileId(IdUtil.getSnowflakeNextIdStr());
fileMapper.insert(fileBean);
userFile.setFileId(fileBean.getFileId());
userFile.setUploadTime(DateUtil.getCurrentTime());
userFile.setModifyTime(DateUtil.getCurrentTime());
userFile.setModifyUserId(SessionUtil.getUserId());
userFileMapper.updateById(userFile);
return fileUrl;
}
public String getIdentifierByFile(String fileUrl, int storageType) throws IOException {
DownloadFile downloadFile = new DownloadFile();
downloadFile.setFileUrl(fileUrl);
InputStream inputStream = ufopFactory.getDownloader(storageType).getInputStream(downloadFile);
return DigestUtils.md5Hex(inputStream);
}
public void saveFileInputStream(int storageType, String fileUrl, InputStream inputStream) throws IOException {
Writer writer1 = ufopFactory.getWriter(storageType);
WriteFile writeFile = new WriteFile();
writeFile.setFileUrl(fileUrl);
int fileSize = inputStream.available();
writeFile.setFileSize(fileSize);
writer1.write(inputStream, writeFile);
}
public boolean isDirExist(String fileName, String filePath, String userId) {
LambdaQueryWrapper<UserFile> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(UserFile::getFileName, fileName)
.eq(UserFile::getFilePath, QiwenFile.formatPath(filePath))
.eq(UserFile::getUserId, userId)
.eq(UserFile::getDeleteFlag, 0)
.eq(UserFile::getIsDir, 1);
List<UserFile> list = userFileMapper.selectList(lambdaQueryWrapper);
if (list != null && !list.isEmpty()) {
return true;
}
return false;
}
public void parseMusicFile(String extendName, int storageType, String fileUrl, String fileId) {
File outFile = null;
InputStream inputStream = null;
FileOutputStream fileOutputStream = null;
try {
if ("mp3".equalsIgnoreCase(extendName) || "flac".equalsIgnoreCase(extendName)) {
Downloader downloader = ufopFactory.getDownloader(storageType);
DownloadFile downloadFile = new DownloadFile();
downloadFile.setFileUrl(fileUrl);
inputStream = downloader.getInputStream(downloadFile);
outFile = UFOPUtils.getTempFile(fileUrl);
if (!outFile.exists()) {
outFile.createNewFile();
}
fileOutputStream = new FileOutputStream(outFile);
IOUtils.copy(inputStream, fileOutputStream);
Music music = new Music();
music.setMusicId(IdUtil.getSnowflakeNextIdStr());
music.setFileId(fileId);
Tag tag = null;
AudioHeader audioHeader = null;
if ("mp3".equalsIgnoreCase(extendName)) {
MP3File f = (MP3File) AudioFileIO.read(outFile);
tag = f.getTag();
audioHeader = f.getAudioHeader();
MP3File mp3file = new MP3File(outFile);
if (mp3file.hasID3v2Tag()) {
AbstractID3v2Tag id3v2Tag = mp3file.getID3v2TagAsv24();
AbstractID3v2Frame frame = (AbstractID3v2Frame) id3v2Tag.getFrame("APIC");
FrameBodyAPIC body;
if (frame != null && !frame.isEmpty()) {
body = (FrameBodyAPIC) frame.getBody();
byte[] imageData = body.getImageData();
music.setAlbumImage(Base64.getEncoder().encodeToString(imageData));
}
if (tag != null) {
music.setArtist(tag.getFirst(FieldKey.ARTIST));
music.setTitle(tag.getFirst(FieldKey.TITLE));
music.setAlbum(tag.getFirst(FieldKey.ALBUM));
music.setYear(tag.getFirst(FieldKey.YEAR));
try {
music.setTrack(tag.getFirst(FieldKey.TRACK));
} catch (Exception e) {
// ignore
}
music.setGenre(tag.getFirst(FieldKey.GENRE));
music.setComment(tag.getFirst(FieldKey.COMMENT));
music.setLyrics(tag.getFirst(FieldKey.LYRICS));
music.setComposer(tag.getFirst(FieldKey.COMPOSER));
music.setAlbumArtist(tag.getFirst(FieldKey.ALBUM_ARTIST));
music.setEncoder(tag.getFirst(FieldKey.ENCODER));
}
}
} else if ("flac".equalsIgnoreCase(extendName)) {
AudioFile f = new FlacFileReader().read(outFile);
tag = f.getTag();
audioHeader = f.getAudioHeader();
if (tag != null) {
music.setArtist(StringUtils.join(tag.getFields(FieldKey.ARTIST), ","));
music.setTitle(StringUtils.join(tag.getFields(FieldKey.TITLE), ","));
music.setAlbum(StringUtils.join(tag.getFields(FieldKey.ALBUM), ","));
music.setYear(StringUtils.join(tag.getFields(FieldKey.YEAR), ","));
music.setTrack(StringUtils.join(tag.getFields(FieldKey.TRACK), ","));
music.setGenre(StringUtils.join(tag.getFields(FieldKey.GENRE), ","));
music.setComment(StringUtils.join(tag.getFields(FieldKey.COMMENT), ","));
music.setLyrics(StringUtils.join(tag.getFields(FieldKey.LYRICS), ","));
music.setComposer(StringUtils.join(tag.getFields(FieldKey.COMPOSER), ","));
music.setAlbumArtist(StringUtils.join(tag.getFields(FieldKey.ALBUM_ARTIST), ","));
music.setEncoder(StringUtils.join(tag.getFields(FieldKey.ENCODER), ","));
List<Artwork> artworkList = tag.getArtworkList();
if (artworkList != null && !artworkList.isEmpty()) {
Artwork artwork = artworkList.get(0);
byte[] binaryData = artwork.getBinaryData();
music.setAlbumImage(Base64.getEncoder().encodeToString(binaryData));
}
}
}
if (audioHeader != null) {
music.setTrackLength(Float.parseFloat(audioHeader.getTrackLength() + ""));
}
if (StringUtils.isEmpty(music.getLyrics())) {
try {
String lyc = MusicUtils.getLyc(music.getArtist(), music.getTitle(), music.getAlbum());
music.setLyrics(lyc);
} catch (Exception e) {
log.info(e.getMessage());
}
}
musicMapper.insert(music);
}
} catch (Exception e) {
log.error("解析音乐信息失败!", e);
} finally {
IOUtils.closeQuietly(inputStream);
IOUtils.closeQuietly(fileOutputStream);
if (outFile != null) {
if (outFile.exists()) {
outFile.delete();
}
}
}
}
}

View File

@ -0,0 +1,69 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.component;
import com.alibaba.fastjson2.JSON;
import com.qiwenshare.common.util.math.CalculatorUtils;
import com.zhgd.xmgl.modules.basicdata.qiwen.config.jwt.JwtProperties;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.JwtBuilder;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import io.jsonwebtoken.impl.DefaultClaims;
import org.apache.commons.codec.binary.Base64;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
import java.util.Date;
import java.util.Map;
@Component
public class JwtComp {
@Resource
JwtProperties jwtProperties;
// 由字符串生成加密key
private SecretKey generalKey() {
// 本地的密码解码
byte[] encodedKey = Base64.decodeBase64(jwtProperties.getSecret());
// 根据给定的字节数组使用AES加密算法构造一个密钥
return new SecretKeySpec(encodedKey, 0, encodedKey.length, "AES");
}
// 创建jwt
public String createJWT(Map<String, Object> param) {
String subject = JSON.toJSONString(param);
// 生成JWT的时间
long nowTime = System.currentTimeMillis();
Date nowDate = new Date(nowTime);
// 生成签名的时候使用的秘钥secret切记这个秘钥不能外露是你服务端的私钥在任何场景都不应该流露出去一旦客户端得知这个secret那就意味着客户端是可以自我签发jwt的
SecretKey key = generalKey();
Double expireTime = CalculatorUtils.conversion(jwtProperties.getPayload().getRegisterdClaims().getExp());
// 为payload添加各种标准声明和私有声明
DefaultClaims defaultClaims = new DefaultClaims();
defaultClaims.setIssuer(jwtProperties.getPayload().getRegisterdClaims().getIss());
defaultClaims.setExpiration(new Date(System.currentTimeMillis() + expireTime.longValue()));
defaultClaims.setSubject(subject);
defaultClaims.setAudience(jwtProperties.getPayload().getRegisterdClaims().getAud());
JwtBuilder builder = Jwts.builder() // 表示new一个JwtBuilder设置jwt的body
.setClaims(defaultClaims)
.setIssuedAt(nowDate) // iat(issuedAt)jwt的签发时间
.signWith(SignatureAlgorithm.forName(jwtProperties.getHeader().getAlg()), key); // 设置签名使用的是签名算法和签名使用的秘钥
return builder.compact();
}
// 解密jwt
public Claims parseJWT(String jwt) throws Exception {
SecretKey key = generalKey(); // 签名秘钥和生成的签名的秘钥一模一样
return Jwts.parser() // 得到DefaultJwtParser
.setSigningKey(key) // 设置签名的秘钥
.parseClaimsJws(jwt).getBody();
}
}

View File

@ -0,0 +1,58 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.component;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.qiwenshare.common.constant.RegexConstant;
import com.zhgd.xmgl.modules.basicdata.entity.SystemUser;
import com.zhgd.xmgl.modules.basicdata.mapper.SystemUserMapper;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
import java.util.regex.Pattern;
@Component
public class UserDealComp {
@Resource
SystemUserMapper systemUserMapper;
/**
* 检测用户名是否存在
*
* @param systemUser
*/
public Boolean isUserNameExit(SystemUser systemUser) {
LambdaQueryWrapper<SystemUser> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(SystemUser::getAccount, systemUser.getAccount());
List<SystemUser> list = systemUserMapper.selectList(lambdaQueryWrapper);
if (list != null && !list.isEmpty()) {
return true;
} else {
return false;
}
}
/**
* 检测手机号是否存在
*
* @param systemUser
* @return
*/
public Boolean isPhoneExit(SystemUser systemUser) {
LambdaQueryWrapper<SystemUser> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(SystemUser::getUserTel, systemUser.getUserTel());
List<SystemUser> list = systemUserMapper.selectList(lambdaQueryWrapper);
if (list != null && !list.isEmpty()) {
return true;
} else {
return false;
}
}
public Boolean isPhoneFormatRight(String phone){
boolean isRight = Pattern.matches(RegexConstant.PASSWORD_REGEX, phone);
return isRight;
}
}

View File

@ -0,0 +1,26 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.config.es;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class FileSearch {
private String indexName;
private String userFileId;
private String fileId;
private String fileName;
private String content;
private String fileUrl;
private Long fileSize;
private Integer storageType;
private String identifier;
private Long userId;
private String filePath;
private String extendName;
private Integer isDir;
private String uploadTime;
private Integer deleteFlag;
private String deleteTime;
private String deleteBatchNum;
}

View File

@ -0,0 +1,9 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.config.jwt;
import lombok.Data;
@Data
public class JwtHeader {
private String alg;
private String typ;
}

View File

@ -0,0 +1,10 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.config.jwt;
import lombok.Data;
@Data
public class JwtPayload {
private RegisterdClaims registerdClaims;
}

View File

@ -0,0 +1,15 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.config.jwt;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Data
@Component
@ConfigurationProperties(prefix = "jwt")
public class JwtProperties {
private String secret;
private JwtHeader header;
private JwtPayload payload;
}

View File

@ -0,0 +1,11 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.config.jwt;
import lombok.Data;
@Data
public class RegisterdClaims {
private String iss;
private String exp;
private String sub;
private String aud;
}

View File

@ -0,0 +1,85 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.config.threadpool;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Component;
import java.util.Objects;
import java.util.concurrent.Executor;
import java.util.concurrent.ThreadPoolExecutor;
/**
* 异步线程池配置 AsyncConfigurer在applicationContext早期初始化如果需要依赖于其它的bean尽可能的将它们声明为lazy
*/
@Slf4j
@EnableAsync
@Component
@EnableConfigurationProperties(AsyncThreadPoolProperties.class)
public class AsyncThreadPoolAutoConfiguration implements AsyncConfigurer {
@Autowired
private AsyncThreadPoolProperties asyncThreadPoolProperties;
/**
* 定义线程池
* 使用{@link java.util.concurrent.LinkedBlockingQueue}(FIFO队列是一个用于并发环境下的阻塞队列集合类
* ThreadPoolTaskExecutor不是完全被IOC容器管理的bean,可以在方法上加上@Bean注解交给容器管理,这样可以将taskExecutor.initialize()方法调用去掉容器会自动调用
*
* @return
*/
@Bean("asyncTaskExecutor")
@Override
public Executor getAsyncExecutor() {
//Java虚拟机可用的处理器数
int processors = Runtime.getRuntime().availableProcessors();
//定义线程池
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
//核心线程数
taskExecutor.setCorePoolSize(Objects.nonNull(asyncThreadPoolProperties.getCorePoolSize()) ? asyncThreadPoolProperties.getCorePoolSize() : processors);
//线程池最大线程数,默认40000
taskExecutor.setMaxPoolSize(Objects.nonNull(asyncThreadPoolProperties.getMaxPoolSize()) ? asyncThreadPoolProperties.getMaxPoolSize() : 40000);
//线程队列最大线程数,默认80000
taskExecutor.setQueueCapacity(Objects.nonNull(asyncThreadPoolProperties.getMaxPoolSize()) ? asyncThreadPoolProperties.getMaxPoolSize() : 80000);
//线程名称前缀
taskExecutor.setThreadNamePrefix(StringUtils.isNotEmpty(asyncThreadPoolProperties.getThreadNamePrefix()) ? asyncThreadPoolProperties.getThreadNamePrefix() : "Async-ThreadPool-");
//线程池中线程最大空闲时间默认60单位
taskExecutor.setKeepAliveSeconds(asyncThreadPoolProperties.getKeepAliveSeconds());
//核心线程是否允许超时默认:false
taskExecutor.setAllowCoreThreadTimeOut(asyncThreadPoolProperties.isAllowCoreThreadTimeOut());
//IOC容器关闭时是否阻塞等待剩余的任务执行完成默认:false必须设置setAwaitTerminationSeconds
taskExecutor.setWaitForTasksToCompleteOnShutdown(asyncThreadPoolProperties.isWaitForTasksToCompleteOnShutdown());
//阻塞IOC容器关闭的时间默认10秒必须设置setWaitForTasksToCompleteOnShutdown
taskExecutor.setAwaitTerminationSeconds(asyncThreadPoolProperties.getAwaitTerminationSeconds());
/**
* 拒绝策略默认是AbortPolicy
* AbortPolicy丢弃任务并抛出RejectedExecutionException异常
* DiscardPolicy丢弃任务但不抛出异常
* DiscardOldestPolicy丢弃最旧的处理程序然后重试如果执行器关闭这时丢弃任务
* CallerRunsPolicy执行器执行任务失败则在策略回调方法中执行任务如果执行器关闭这时丢弃任务
*/
taskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy());
//初始化
//taskExecutor.initialize();
return taskExecutor;
}
/**
* 异步方法执行的过程中抛出的异常捕获
*
* @return AsyncUncaughtExceptionHandler
*/
@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
return new BaseAsyncUncaughtExceptionHandler();
}
}

View File

@ -0,0 +1,51 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.config.threadpool;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* 异步线程池配置文件
*/
@Data
@ConfigurationProperties(prefix = "spring.async-thread-pool")
public class AsyncThreadPoolProperties {
/**
* 是否启动异步线程池默认 false
*/
private boolean enable;
/**
* 核心线程数,默认Java虚拟机可用线程数
*/
private Integer corePoolSize=8;
/**
* 线程池最大线程数,默认40000
*/
private Integer maxPoolSize=500;
/**
* 线程队列最大线程数,默认80000
*/
private Integer queueCapacity = 5;
/**
* 线程池中线程最大空闲时间默认60单位
*/
private Integer keepAliveSeconds = 600;
/**
* 自定义线程名前缀默认Async-ThreadPool-
*/
private String threadNamePrefix = "async-threadpool-";
/**
* 核心线程是否允许超时默认false
*/
private boolean allowCoreThreadTimeOut;
/**
* IOC容器关闭时是否阻塞等待剩余的任务执行完成默认:false必须设置setAwaitTerminationSeconds
*/
private boolean waitForTasksToCompleteOnShutdown;
/**
* 阻塞IOC容器关闭的时间默认10秒必须设置setWaitForTasksToCompleteOnShutdown
*/
private int awaitTerminationSeconds = 10;
}

View File

@ -0,0 +1,16 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.config.threadpool;
import lombok.extern.slf4j.Slf4j;
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
import java.lang.reflect.Method;
import java.util.Arrays;
@Slf4j
public class BaseAsyncUncaughtExceptionHandler implements AsyncUncaughtExceptionHandler {
@Override
public void handleUncaughtException(Throwable throwable, Method method, Object... objects) {
log.error("捕获线程异常method[{}] params{}", method, Arrays.toString(objects));
log.error("线程异常");
}
}

View File

@ -0,0 +1,110 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.controller;
import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qiwenshare.common.anno.MyLog;
import com.qiwenshare.common.result.RestResult;
import com.qiwenshare.common.util.security.JwtUser;
import com.qiwenshare.common.util.security.SessionUtil;
import com.zhgd.xmgl.modules.basicdata.qiwen.api.ICommonFileService;
import com.zhgd.xmgl.modules.basicdata.qiwen.api.IFilePermissionService;
import com.zhgd.xmgl.modules.basicdata.qiwen.api.IUserFileService;
import com.zhgd.xmgl.modules.basicdata.qiwen.domain.CommonFile;
import com.zhgd.xmgl.modules.basicdata.qiwen.domain.FilePermission;
import com.zhgd.xmgl.modules.basicdata.qiwen.domain.UserFile;
import com.zhgd.xmgl.modules.basicdata.qiwen.dto.commonfile.CommonFileDTO;
import com.zhgd.xmgl.modules.basicdata.qiwen.io.QiwenFile;
import com.zhgd.xmgl.modules.basicdata.qiwen.vo.commonfile.CommonFileListVo;
import com.zhgd.xmgl.modules.basicdata.qiwen.vo.commonfile.CommonFileUser;
import com.zhgd.xmgl.modules.basicdata.qiwen.vo.file.FileListVO;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
@Api(description = "该接口为文件共享接口")
@RestController
@Slf4j
@RequestMapping("/common")
public class CommonFileController {
public static final String CURRENT_MODULE = "文件共享";
@Resource
ICommonFileService commonFileService;
@Resource
IFilePermissionService filePermissionService;
@Resource
IUserFileService userFileService;
@Operation(summary = "将文件共享给他人", description = "共享文件统一接口", tags = {"common"})
@PostMapping(value = "/commonfile")
@ResponseBody
public RestResult<String> commonFile(@RequestBody CommonFileDTO commonFileDTO) {
CommonFile commonFile = new CommonFile();
commonFile.setUserFileId(commonFileDTO.getUserFileId());
commonFile.setCommonFileId(IdUtil.getSnowflakeNextIdStr());
commonFileService.save(commonFile);
List<FilePermission> list = JSON.parseArray(commonFileDTO.getCommonUserList(), FilePermission.class);
List<FilePermission> filePermissionList = new ArrayList<>();
for (FilePermission filePermission : list) {
filePermission.setFilePermissionId(IdUtil.getSnowflakeNextId());
filePermission.setCommonFileId(commonFile.getCommonFileId());
filePermissionList.add(filePermission);
}
filePermissionService.saveBatch(filePermissionList);
return RestResult.success();
}
@Operation(summary = "获取共享空间的全量用户列表", description = "共享文件用户接口", tags = {"common"})
@GetMapping(value = "/commonfileuser")
@MyLog(operation = "共享文件用户", module = CURRENT_MODULE)
@ResponseBody
public RestResult<List<CommonFileUser>> commonFileUserList() {
JwtUser sessionUserBean = SessionUtil.getSession();
List<CommonFileUser> list = commonFileService.selectCommonFileUser(sessionUserBean.getUserId());
return RestResult.success().data(list);
}
@Operation(summary = "获取共享用户文件列表", description = "用来做前台列表展示", tags = {"file"})
@RequestMapping(value = "/getCommonFileByUser", method = RequestMethod.GET)
@ResponseBody
public RestResult<CommonFileListVo> getCommonFileByUser(
@Parameter(description = "用户id", required = true) String userId){
JwtUser sessionUserBean = SessionUtil.getSession();
List<CommonFileListVo> commonFileVo = commonFileService.selectCommonFileByUser(userId, sessionUserBean.getUserId());
return RestResult.success().data(commonFileVo);
}
@Operation(summary = "获取共享空间中某个用户的文件列表", description = "用来做前台列表展示", tags = {"file"})
@RequestMapping(value = "/commonFileList", method = RequestMethod.GET)
@ResponseBody
public RestResult<FileListVO> commonFileList(
@Parameter(description = "用户id", required = true) Long commonFileId,
@Parameter(description = "文件路径", required = true) String filePath,
@Parameter(description = "当前页", required = true) long currentPage,
@Parameter(description = "页面数量", required = true) long pageCount){
CommonFile commonFile = commonFileService.getById(commonFileId);
UserFile userFile = userFileService.getById(commonFile.getUserFileId());
QiwenFile qiwenFile = new QiwenFile(userFile.getFilePath(), filePath, true);
IPage<FileListVO> fileList = userFileService.userFileList(userFile.getUserId(), qiwenFile.getPath(), currentPage, pageCount);
return RestResult.success().data(fileList);
}
}

View File

@ -0,0 +1,65 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qiwenshare.common.result.RestResult;
import com.zhgd.xmgl.modules.basicdata.entity.Notice;
import com.zhgd.xmgl.modules.basicdata.qiwen.api.IFileNoticeService;
import com.zhgd.xmgl.modules.basicdata.qiwen.domain.FileNotice;
import com.zhgd.xmgl.modules.basicdata.qiwen.dto.notice.NoticeListDTO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@Tag(name = "公告管理")
@RestController
@RequestMapping("/fileNotice")
public class FileNoticeController {
public static final String CURRENT_MODULE = "公告管理";
@Resource
IFileNoticeService noticeService;
/**
* 得到所有的公告
*
* @return
*/
@Operation(summary = "得到所有的公告列表", tags = {"公告管理"})
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
public RestResult<NoticeListDTO> selectUserList(@Parameter(description = "当前页从1开始") @RequestParam(defaultValue = "1") int page,
@Parameter(description = "页大小") @RequestParam(defaultValue = "10") int pageSize,
@Parameter(description = "标题") @RequestParam(required = false) String title,
@Parameter(description = "发布者") @RequestParam(required = false) Long publisher,
@Parameter(description = "开始发布时间") @RequestParam(required = false) String beginTime,
@Parameter(description = "开始发布时间") @RequestParam(required = false) String endTime) {
NoticeListDTO noticeListDTO = new NoticeListDTO();
noticeListDTO.setPage(page);
noticeListDTO.setPageSize(pageSize);
noticeListDTO.setTitle(title);
noticeListDTO.setPlatform(3);
noticeListDTO.setPublisher(publisher);
noticeListDTO.setBeginTime(beginTime);
noticeListDTO.setEndTime(endTime);
IPage<FileNotice> noticeIPage = noticeService.selectUserPage(noticeListDTO);
return RestResult.success().dataList(noticeIPage.getRecords(), noticeIPage.getTotal());
}
@Operation(summary = "查询公告详情", tags = {"公告管理"})
@RequestMapping(value = "/detail", method = RequestMethod.GET)
@ResponseBody
public RestResult<Notice> getNoticeDetail(@Parameter(description = "公告id", required = true) long noticeId) {
RestResult<Notice> result = new RestResult<Notice>();
FileNotice notice = noticeService.getById(noticeId);
return RestResult.success().data(notice);
}
}

View File

@ -0,0 +1,490 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.controller;
import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qiwenshare.common.anno.MyLog;
import com.qiwenshare.common.exception.QiwenException;
import com.qiwenshare.common.result.RestResult;
import com.qiwenshare.common.util.DateUtil;
import com.qiwenshare.common.util.security.JwtUser;
import com.qiwenshare.common.util.security.SessionUtil;
import com.qiwenshare.ufop.factory.UFOPFactory;
import com.qiwenshare.ufop.operation.copy.Copier;
import com.qiwenshare.ufop.operation.copy.domain.CopyFile;
import com.zhgd.xmgl.modules.basicdata.qiwen.api.IFileService;
import com.zhgd.xmgl.modules.basicdata.qiwen.api.IUserFileService;
import com.zhgd.xmgl.modules.basicdata.qiwen.component.AsyncTaskComp;
import com.zhgd.xmgl.modules.basicdata.qiwen.component.FileDealComp;
import com.zhgd.xmgl.modules.basicdata.qiwen.domain.FileBean;
import com.zhgd.xmgl.modules.basicdata.qiwen.domain.UserFile;
import com.zhgd.xmgl.modules.basicdata.qiwen.dto.file.*;
import com.zhgd.xmgl.modules.basicdata.qiwen.io.QiwenFile;
import com.zhgd.xmgl.modules.basicdata.qiwen.util.QiwenFileUtil;
import com.zhgd.xmgl.modules.basicdata.qiwen.util.TreeNode;
import com.zhgd.xmgl.modules.basicdata.qiwen.vo.file.FileDetailVO;
import com.zhgd.xmgl.modules.basicdata.qiwen.vo.file.FileListVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.ClassUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URLDecoder;
import java.util.*;
@RestController
@Slf4j
@RequestMapping("files")
public class FilesController {
@Resource
IFileService fileService;
@Resource
IUserFileService userFileService;
@Resource
UFOPFactory ufopFactory;
@Resource
FileDealComp fileDealComp;
@Resource
AsyncTaskComp asyncTaskComp;
@Value("${ufop.storage-type}")
private Integer storageType;
public static final String CURRENT_MODULE = "文件接口";
@Operation(summary = "创建文件", description = "创建文件", tags = {"file"})
@ResponseBody
@RequestMapping(value = "/createFile", method = RequestMethod.POST)
public RestResult<Object> createFile(@Valid @RequestBody CreateFileDTO createFileDTO) {
try {
String userId = SessionUtil.getUserId();
String filePath = createFileDTO.getFilePath();
String fileName = createFileDTO.getFileName();
String extendName = createFileDTO.getExtendName();
List<UserFile> userFiles = userFileService.selectSameUserFile(fileName, filePath, extendName, userId);
if (userFiles != null && !userFiles.isEmpty()) {
return RestResult.fail().message("同名文件已存在");
}
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
String templateFilePath = "";
if ("docx".equals(extendName)) {
templateFilePath = "template/Word.docx";
} else if ("xlsx".equals(extendName)) {
templateFilePath = "template/Excel.xlsx";
} else if ("pptx".equals(extendName)) {
templateFilePath = "template/PowerPoint.pptx";
} else if ("txt".equals(extendName)) {
templateFilePath = "template/Text.txt";
} else if ("drawio".equals(extendName)) {
templateFilePath = "template/Drawio.drawio";
}
String url2 = ClassUtils.getDefaultClassLoader().getResource("static/" + templateFilePath).getPath();
url2 = URLDecoder.decode(url2, "UTF-8");
FileInputStream fileInputStream = new FileInputStream(url2);
Copier copier = ufopFactory.getCopier();
CopyFile copyFile = new CopyFile();
copyFile.setExtendName(extendName);
String fileUrl = copier.copy(fileInputStream, copyFile);
FileBean fileBean = new FileBean();
fileBean.setFileId(IdUtil.getSnowflakeNextIdStr());
fileBean.setFileSize(0L);
fileBean.setFileUrl(fileUrl);
fileBean.setStorageType(storageType);
fileBean.setIdentifier(uuid);
fileBean.setCreateTime(DateUtil.getCurrentTime());
fileBean.setCreateUserId(SessionUtil.getSession().getUserId());
fileBean.setFileStatus(1);
boolean saveFlag = fileService.save(fileBean);
UserFile userFile = new UserFile();
if (saveFlag) {
userFile.setUserFileId(IdUtil.getSnowflakeNextIdStr());
userFile.setUserId(userId);
userFile.setFileName(fileName);
userFile.setFilePath(filePath);
userFile.setDeleteFlag(0);
userFile.setIsDir(0);
userFile.setExtendName(extendName);
userFile.setUploadTime(DateUtil.getCurrentTime());
userFile.setFileId(fileBean.getFileId());
userFile.setCreateTime(DateUtil.getCurrentTime());
userFile.setCreateUserId(SessionUtil.getUserId());
userFileService.save(userFile);
}
return RestResult.success().message("文件创建成功");
} catch (Exception e) {
log.error(e.getMessage());
return RestResult.fail().message(e.getMessage());
}
}
@Operation(summary = "创建文件夹", description = "目录(文件夹)的创建", tags = {"file"})
@RequestMapping(value = "/createFold", method = RequestMethod.POST)
@MyLog(operation = "创建文件夹", module = CURRENT_MODULE)
@ResponseBody
public RestResult<String> createFold(@Valid @RequestBody CreateFoldDTO createFoldDto) {
String userId = SessionUtil.getSession().getUserId();
String filePath = createFoldDto.getFilePath();
boolean isDirExist = fileDealComp.isDirExist(createFoldDto.getFileName(), createFoldDto.getFilePath(), userId);
if (isDirExist) {
return RestResult.fail().message("同名文件夹已存在");
}
UserFile userFile = QiwenFileUtil.getQiwenDir(userId, filePath, createFoldDto.getFileName());
userFileService.save(userFile);
fileDealComp.uploadESByUserFileId(userFile.getUserFileId());
return RestResult.success();
}
// @Operation(summary = "文件搜索", description = "文件搜索", tags = {"file"})
// @GetMapping(value = "/search")
// @MyLog(operation = "文件搜索", module = CURRENT_MODULE)
// @ResponseBody
// public RestResult<SearchFileVO> searchFile(SearchFileDTO searchFileDTO) {
// JwtUser sessionUserBean = SessionUtil.getSession();
//
// int currentPage = (int)searchFileDTO.getCurrentPage() - 1;
// int pageCount = (int)(searchFileDTO.getPageCount() == 0 ? 10 : searchFileDTO.getPageCount());
//
// SearchResponse<FileSearch> search = null;
// try {
// search = elasticsearchClient.search(s -> s
// .index("filesearch")
// .query(_1 -> _1
// .bool(_2 -> _2
// .must(_3 -> _3
// .bool(_4 -> _4
// .should(_5 -> _5
// .match(_6 -> _6
// .field("fileName")
// .query(searchFileDTO.getFileName())))
// .should(_5 -> _5
// .wildcard(_6 -> _6
// .field("fileName")
// .wildcard("*" + searchFileDTO.getFileName() + "*")))
// .should(_5 -> _5
// .match(_6 -> _6
// .field("content")
// .query(searchFileDTO.getFileName())))
// .should(_5 -> _5
// .wildcard(_6 -> _6
// .field("content")
// .wildcard("*" + searchFileDTO.getFileName() + "*")))
// ))
// .must(_3 -> _3
// .term(_4 -> _4
// .field("userId")
// .value(sessionUserBean.getUserId())))
// ))
// .from(currentPage)
// .size(pageCount)
// .highlight(h -> h
// .fields("fileName", f -> f.type("plain")
// .preTags("<span class='keyword'>").postTags("</span>"))
// .encoder(HighlighterEncoder.Html))
// ,
// FileSearch.class);
// } catch (IOException e) {
// e.printStackTrace();
// }
//
// List<SearchFileVO> searchFileVOList = new ArrayList<>();
// for (Hit<FileSearch> hit : search.hits().hits()) {
// SearchFileVO searchFileVO = new SearchFileVO();
// BeanUtil.copyProperties(hit.source(), searchFileVO);
// searchFileVO.setHighLight(hit.highlight());
// searchFileVOList.add(searchFileVO);
// asyncTaskComp.checkESUserFileId(searchFileVO.getUserFileId());
// }
// return RestResult.success().dataList(searchFileVOList, searchFileVOList.size());
// }
@Operation(summary = "文件重命名", description = "文件重命名", tags = {"file"})
@RequestMapping(value = "/renamefile", method = RequestMethod.POST)
@MyLog(operation = "文件重命名", module = CURRENT_MODULE)
@ResponseBody
public RestResult<String> renameFile(@RequestBody RenameFileDTO renameFileDto) {
JwtUser sessionUserBean = SessionUtil.getSession();
UserFile userFile = userFileService.getById(renameFileDto.getUserFileId());
List<UserFile> userFiles = userFileService.selectUserFileByNameAndPath(renameFileDto.getFileName(), userFile.getFilePath(), sessionUserBean.getUserId());
if (userFiles != null && !userFiles.isEmpty()) {
return RestResult.fail().message("同名文件已存在");
}
LambdaUpdateWrapper<UserFile> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
lambdaUpdateWrapper.set(UserFile::getFileName, renameFileDto.getFileName())
.set(UserFile::getUploadTime, DateUtil.getCurrentTime())
.eq(UserFile::getUserFileId, renameFileDto.getUserFileId());
userFileService.update(lambdaUpdateWrapper);
if (1 == userFile.getIsDir()) {
List<UserFile> list = userFileService.selectUserFileByLikeRightFilePath(new QiwenFile(userFile.getFilePath(), userFile.getFileName(), true).getPath(), sessionUserBean.getUserId());
for (UserFile newUserFile : list) {
newUserFile.setFilePath(newUserFile.getFilePath().replaceFirst(new QiwenFile(userFile.getFilePath(), userFile.getFileName(), userFile.getIsDir() == 1).getPath(),
new QiwenFile(userFile.getFilePath(), renameFileDto.getFileName(), userFile.getIsDir() == 1).getPath()));
userFileService.updateById(newUserFile);
}
}
fileDealComp.uploadESByUserFileId(renameFileDto.getUserFileId());
return RestResult.success();
}
@Operation(summary = "获取文件列表", description = "用来做前台列表展示", tags = {"file"})
@RequestMapping(value = "/getfilelist", method = RequestMethod.GET)
@ResponseBody
public RestResult<FileListVO> getFileList(
@Parameter(description = "文件类型", required = true) String fileType,
@Parameter(description = "文件路径", required = true) String filePath,
@Parameter(description = "当前页", required = true) long currentPage,
@Parameter(description = "页面数量", required = true) long pageCount){
if ("0".equals(fileType)) {
IPage<FileListVO> fileList = userFileService.userFileList(null, filePath, currentPage, pageCount);
return RestResult.success().dataList(fileList.getRecords(), fileList.getTotal());
} else {
IPage<FileListVO> fileList = userFileService.getFileByFileType(Integer.valueOf(fileType), currentPage, pageCount, SessionUtil.getSession().getUserId());
return RestResult.success().dataList(fileList.getRecords(), fileList.getTotal());
}
}
@Operation(summary = "批量删除文件", description = "批量删除文件", tags = {"file"})
@RequestMapping(value = "/batchdeletefile", method = RequestMethod.POST)
@MyLog(operation = "批量删除文件", module = CURRENT_MODULE)
@ResponseBody
public RestResult<String> deleteImageByIds(@RequestBody BatchDeleteFileDTO batchDeleteFileDto) {
String userFileIds = batchDeleteFileDto.getUserFileIds();
String[] userFileIdList = userFileIds.split(",");
for (String userFileId : userFileIdList) {
userFileService.deleteUserFile(userFileId, SessionUtil.getUserId());
// fileDealComp.deleteESByUserFileId(userFileId);
}
return RestResult.success().message("批量删除文件成功");
}
@Operation(summary = "删除文件", description = "可以删除文件或者目录", tags = {"file"})
@RequestMapping(value = "/deletefile", method = RequestMethod.POST)
@MyLog(operation = "删除文件", module = CURRENT_MODULE)
@ResponseBody
public RestResult deleteFile(@RequestBody DeleteFileDTO deleteFileDto) {
JwtUser sessionUserBean = SessionUtil.getSession();
userFileService.deleteUserFile(deleteFileDto.getUserFileId(), sessionUserBean.getUserId());
// fileDealComp.deleteESByUserFileId(deleteFileDto.getUserFileId());
return RestResult.success();
}
@Operation(summary = "解压文件", description = "解压文件。", tags = {"file"})
@RequestMapping(value = "/unzipfile", method = RequestMethod.POST)
@MyLog(operation = "解压文件", module = CURRENT_MODULE)
@ResponseBody
public RestResult<String> unzipFile(@RequestBody UnzipFileDTO unzipFileDto) {
try {
fileService.unzipFile(unzipFileDto.getUserFileId(), unzipFileDto.getUnzipMode(), unzipFileDto.getFilePath());
} catch (QiwenException e) {
return RestResult.fail().message(e.getMessage());
}
return RestResult.success();
}
@Operation(summary = "文件复制", description = "可以复制文件或者目录", tags = {"file"})
@RequestMapping(value = "/copyfile", method = RequestMethod.POST)
@MyLog(operation = "文件复制", module = CURRENT_MODULE)
@ResponseBody
public RestResult<String> copyFile(@RequestBody CopyFileDTO copyFileDTO) {
String userId = SessionUtil.getUserId();
String filePath = copyFileDTO.getFilePath();
String userFileIds = copyFileDTO.getUserFileIds();
String[] userFileIdArr = userFileIds.split(",");
for (String userFileId : userFileIdArr) {
UserFile userFile = userFileService.getById(userFileId);
String oldfilePath = userFile.getFilePath();
String fileName = userFile.getFileName();
if (userFile.isDirectory()) {
QiwenFile qiwenFile = new QiwenFile(oldfilePath, fileName, true);
if (filePath.startsWith(qiwenFile.getPath() + QiwenFile.separator) || filePath.equals(qiwenFile.getPath())) {
return RestResult.fail().message("原路径与目标路径冲突,不能复制");
}
}
userFileService.userFileCopy(SessionUtil.getUserId(), userFileId, filePath);
fileDealComp.deleteRepeatSubDirFile(filePath, userId);
}
return RestResult.success();
}
@Operation(summary = "文件移动", description = "可以移动文件或者目录", tags = {"file"})
@RequestMapping(value = "/movefile", method = RequestMethod.POST)
@MyLog(operation = "文件移动", module = CURRENT_MODULE)
@ResponseBody
public RestResult<String> moveFile(@RequestBody MoveFileDTO moveFileDto) {
JwtUser sessionUserBean = SessionUtil.getSession();
UserFile userFile = userFileService.getById(moveFileDto.getUserFileId());
String oldfilePath = userFile.getFilePath();
String newfilePath = moveFileDto.getFilePath();
String fileName = userFile.getFileName();
String extendName = userFile.getExtendName();
if (StringUtils.isEmpty(extendName)) {
QiwenFile qiwenFile = new QiwenFile(oldfilePath, fileName, true);
if (newfilePath.startsWith(qiwenFile.getPath() + QiwenFile.separator) || newfilePath.equals(qiwenFile.getPath())) {
return RestResult.fail().message("原路径与目标路径冲突,不能移动");
}
}
userFileService.updateFilepathByUserFileId(moveFileDto.getUserFileId(), newfilePath, sessionUserBean.getUserId());
fileDealComp.deleteRepeatSubDirFile(newfilePath, sessionUserBean.getUserId());
return RestResult.success();
}
@Operation(summary = "批量移动文件", description = "可以同时选择移动多个文件或者目录", tags = {"file"})
@RequestMapping(value = "/batchmovefile", method = RequestMethod.POST)
@MyLog(operation = "批量移动文件", module = CURRENT_MODULE)
@ResponseBody
public RestResult<String> batchMoveFile(@RequestBody BatchMoveFileDTO batchMoveFileDto) {
JwtUser sessionUserBean = SessionUtil.getSession();
String newfilePath = batchMoveFileDto.getFilePath();
String userFileIds = batchMoveFileDto.getUserFileIds();
String[] userFileIdArr = userFileIds.split(",");
for (String userFileId : userFileIdArr) {
UserFile userFile = userFileService.getById(userFileId);
if (StringUtils.isEmpty(userFile.getExtendName())) {
QiwenFile qiwenFile = new QiwenFile(userFile.getFilePath(), userFile.getFileName(), true);
if (newfilePath.startsWith(qiwenFile.getPath() + QiwenFile.separator) || newfilePath.equals(qiwenFile.getPath())) {
return RestResult.fail().message("原路径与目标路径冲突,不能移动");
}
}
userFileService.updateFilepathByUserFileId(userFile.getUserFileId(), newfilePath, sessionUserBean.getUserId());
}
return RestResult.success().data("批量移动文件成功");
}
@Operation(summary = "获取文件树", description = "文件移动的时候需要用到该接口,用来展示目录树", tags = {"file"})
@RequestMapping(value = "/getfiletree", method = RequestMethod.GET)
@ResponseBody
public RestResult<TreeNode> getFileTree() {
RestResult<TreeNode> result = new RestResult<TreeNode>();
JwtUser sessionUserBean = SessionUtil.getSession();
List<UserFile> userFileList = userFileService.selectFilePathTreeByUserId(sessionUserBean.getUserId());
TreeNode resultTreeNode = new TreeNode();
resultTreeNode.setLabel(QiwenFile.separator);
resultTreeNode.setId(0L);
long id = 1;
for (int i = 0; i < userFileList.size(); i++){
UserFile userFile = userFileList.get(i);
QiwenFile qiwenFile = new QiwenFile(userFile.getFilePath(), userFile.getFileName(), false);
String filePath = qiwenFile.getPath();
Queue<String> queue = new LinkedList<>();
String[] strArr = filePath.split(QiwenFile.separator);
for (int j = 0; j < strArr.length; j++){
if (!"".equals(strArr[j]) && strArr[j] != null){
queue.add(strArr[j]);
}
}
if (queue.size() == 0){
continue;
}
resultTreeNode = fileDealComp.insertTreeNode(resultTreeNode, id++, QiwenFile.separator, queue);
}
List<TreeNode> treeNodeList = resultTreeNode.getChildren();
Collections.sort(treeNodeList, (o1, o2) -> {
long i = o1.getId() - o2.getId();
return (int) i;
});
result.setSuccess(true);
result.setData(resultTreeNode);
return result;
}
@Operation(summary = "修改文件", description = "支持普通文本类文件的修改", tags = {"file"})
@RequestMapping(value = "/update", method = RequestMethod.POST)
@ResponseBody
public RestResult<String> updateFile(@RequestBody UpdateFileDTO updateFileDTO) {
JwtUser sessionUserBean = SessionUtil.getSession();
UserFile userFile = userFileService.getById(updateFileDTO.getUserFileId());
FileBean fileBean = fileService.getById(userFile.getFileId());
Long pointCount = fileService.getFilePointCount(userFile.getFileId());
String fileUrl = fileBean.getFileUrl();
if (pointCount > 1) {
fileUrl = fileDealComp.copyFile(fileBean, userFile);
}
String content = updateFileDTO.getFileContent();
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(content.getBytes());
try {
int fileSize = byteArrayInputStream.available();
fileDealComp.saveFileInputStream(fileBean.getStorageType(), fileUrl, byteArrayInputStream);
String md5Str = fileDealComp.getIdentifierByFile(fileUrl, fileBean.getStorageType());
fileService.updateFileDetail(userFile.getUserFileId(), md5Str, fileSize);
} catch (Exception e) {
throw new QiwenException(999999, "修改文件异常");
} finally {
try {
byteArrayInputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return RestResult.success().message("修改文件成功");
}
@Operation(summary = "查询文件详情", description = "查询文件详情", tags = {"file"})
@RequestMapping(value = "/detail", method = RequestMethod.GET)
@ResponseBody
public RestResult<FileDetailVO> queryFileDetail(
@Parameter(description = "用户文件Id", required = true) String userFileId){
FileDetailVO vo = fileService.getFileDetail(userFileId);
return RestResult.success().data(vo);
}
}

View File

@ -0,0 +1,312 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.controller;
import com.qiwenshare.common.anno.MyLog;
import com.qiwenshare.common.result.RestResult;
import com.qiwenshare.common.util.MimeUtils;
import com.qiwenshare.common.util.security.JwtUser;
import com.qiwenshare.common.util.security.SessionUtil;
import com.zhgd.xmgl.modules.basicdata.qiwen.api.IFileService;
import com.zhgd.xmgl.modules.basicdata.qiwen.api.IFiletransferService;
import com.zhgd.xmgl.modules.basicdata.qiwen.api.IUserFileService;
import com.zhgd.xmgl.modules.basicdata.qiwen.component.FileDealComp;
import com.zhgd.xmgl.modules.basicdata.qiwen.domain.FileBean;
import com.zhgd.xmgl.modules.basicdata.qiwen.domain.StorageBean;
import com.zhgd.xmgl.modules.basicdata.qiwen.domain.UserFile;
import com.zhgd.xmgl.modules.basicdata.qiwen.dto.file.BatchDownloadFileDTO;
import com.zhgd.xmgl.modules.basicdata.qiwen.dto.file.DownloadFileDTO;
import com.zhgd.xmgl.modules.basicdata.qiwen.dto.file.PreviewDTO;
import com.zhgd.xmgl.modules.basicdata.qiwen.dto.file.UploadFileDTO;
import com.zhgd.xmgl.modules.basicdata.qiwen.io.QiwenFile;
import com.zhgd.xmgl.modules.basicdata.qiwen.service.StorageService;
import com.zhgd.xmgl.modules.basicdata.qiwen.vo.file.UploadFileVo;
import com.qiwenshare.ufop.factory.UFOPFactory;
import com.qiwenshare.ufop.operation.download.Downloader;
import com.qiwenshare.ufop.operation.download.domain.DownloadFile;
import com.qiwenshare.ufop.operation.download.domain.Range;
import com.qiwenshare.ufop.util.UFOPUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@Slf4j
@Tag(name = "filetransfer", description = "该接口为文件传输接口,主要用来做文件的上传、下载和预览")
@RestController
@RequestMapping("/filetransfer")
public class FiletransferController {
@Resource
IFiletransferService filetransferService;
@Resource
IFileService fileService;
@Resource
IUserFileService userFileService;
@Resource
FileDealComp fileDealComp;
@Resource
StorageService storageService;
@Resource
UFOPFactory ufopFactory;
public static final String CURRENT_MODULE = "文件传输接口";
@Operation(summary = "极速上传", description = "校验文件MD5判断文件是否存在如果存在直接上传成功并返回skipUpload=true如果不存在返回skipUpload=false需要再次调用该接口的POST方法", tags = {"filetransfer"})
@RequestMapping(value = "/uploadfile", method = RequestMethod.GET)
@MyLog(operation = "极速上传", module = CURRENT_MODULE)
@ResponseBody
public RestResult<UploadFileVo> uploadFileSpeed(UploadFileDTO uploadFileDto) {
JwtUser sessionUserBean = SessionUtil.getSession();
boolean isCheckSuccess = storageService.checkStorage(SessionUtil.getUserId(), uploadFileDto.getTotalSize());
if (!isCheckSuccess) {
return RestResult.fail().message("存储空间不足");
}
UploadFileVo uploadFileVo = filetransferService.uploadFileSpeed(uploadFileDto);
return RestResult.success().data(uploadFileVo);
}
@Operation(summary = "上传文件", description = "真正的上传文件接口", tags = {"filetransfer"})
@RequestMapping(value = "/uploadfile", method = RequestMethod.POST)
@MyLog(operation = "上传文件", module = CURRENT_MODULE)
@ResponseBody
public RestResult<UploadFileVo> uploadFile(HttpServletRequest request, UploadFileDTO uploadFileDto) {
JwtUser sessionUserBean = SessionUtil.getSession();
filetransferService.uploadFile(request, uploadFileDto, sessionUserBean.getUserId());
UploadFileVo uploadFileVo = new UploadFileVo();
return RestResult.success().data(uploadFileVo);
}
@Operation(summary = "下载文件", description = "下载文件接口", tags = {"filetransfer"})
@MyLog(operation = "下载文件", module = CURRENT_MODULE)
@RequestMapping(value = "/downloadfile", method = RequestMethod.GET)
public void downloadFile(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, DownloadFileDTO downloadFileDTO) {
Cookie[] cookieArr = httpServletRequest.getCookies();
String token = "";
if (cookieArr != null) {
for (Cookie cookie : cookieArr) {
if ("token".equals(cookie.getName())) {
token = cookie.getValue();
}
}
}
boolean authResult = fileDealComp.checkAuthDownloadAndPreview(downloadFileDTO.getShareBatchNum(),
downloadFileDTO.getExtractionCode(),
token,
downloadFileDTO.getUserFileId(), null);
if (!authResult) {
log.error("没有权限下载!!!");
return;
}
httpServletResponse.setContentType("application/force-download");// 设置强制下载不打开
UserFile userFile = userFileService.getById(downloadFileDTO.getUserFileId());
String fileName = "";
if (userFile.getIsDir() == 1) {
fileName = userFile.getFileName() + ".zip";
} else {
fileName = userFile.getFileName() + "." + userFile.getExtendName();
}
try {
fileName = new String(fileName.getBytes("utf-8"), "ISO-8859-1");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
httpServletResponse.addHeader("Content-Disposition", "attachment;fileName=" + fileName);// 设置文件名
filetransferService.downloadFile(httpServletResponse, downloadFileDTO);
}
@Operation(summary = "批量下载文件", description = "批量下载文件", tags = {"filetransfer"})
@RequestMapping(value = "/batchDownloadFile", method = RequestMethod.GET)
@MyLog(operation = "批量下载文件", module = CURRENT_MODULE)
@ResponseBody
public void batchDownloadFile(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, BatchDownloadFileDTO batchDownloadFileDTO) {
Cookie[] cookieArr = httpServletRequest.getCookies();
String token = "";
if (cookieArr != null) {
for (Cookie cookie : cookieArr) {
if ("token".equals(cookie.getName())) {
token = cookie.getValue();
}
}
}
boolean authResult = fileDealComp.checkAuthDownloadAndPreview(batchDownloadFileDTO.getShareBatchNum(),
batchDownloadFileDTO.getExtractionCode(),
token,
batchDownloadFileDTO.getUserFileIds(), null);
if (!authResult) {
log.error("没有权限下载!!!");
return;
}
String files = batchDownloadFileDTO.getUserFileIds();
String[] userFileIdStrs = files.split(",");
List<String> userFileIds = new ArrayList<>();
for(String userFileId : userFileIdStrs) {
UserFile userFile = userFileService.getById(userFileId);
if (userFile.getIsDir() == 0) {
userFileIds.add(userFileId);
} else {
QiwenFile qiwenFile = new QiwenFile(userFile.getFilePath(), userFile.getFileName(), true);
List<UserFile> userFileList = userFileService.selectUserFileByLikeRightFilePath(qiwenFile.getPath(), userFile.getUserId());
List<String> userFileIds1 = userFileList.stream().map(UserFile::getUserFileId).collect(Collectors.toList());
userFileIds.add(userFile.getUserFileId());
userFileIds.addAll(userFileIds1);
}
}
UserFile userFile = userFileService.getById(userFileIdStrs[0]);
httpServletResponse.setContentType("application/force-download");// 设置强制下载不打开
Date date = new Date();
String fileName = String.valueOf(date.getTime());
httpServletResponse.addHeader("Content-Disposition", "attachment;fileName=" + fileName + ".zip");// 设置文件名
filetransferService.downloadUserFileList(httpServletResponse, userFile.getFilePath(), fileName, userFileIds);
}
@Operation(summary="预览文件", description="用于文件预览", tags = {"filetransfer"})
@GetMapping("/preview")
public void preview(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, PreviewDTO previewDTO) throws IOException {
if (previewDTO.getPlatform() != null && previewDTO.getPlatform() == 2) {
filetransferService.previewPictureFile(httpServletResponse, previewDTO);
return ;
}
String token = "";
if (StringUtils.isNotEmpty(previewDTO.getToken())) {
token = previewDTO.getToken();
} else {
Cookie[] cookieArr = httpServletRequest.getCookies();
if (cookieArr != null) {
for (Cookie cookie : cookieArr) {
if ("token".equals(cookie.getName())) {
token = cookie.getValue();
}
}
}
}
UserFile userFile = userFileService.getById(previewDTO.getUserFileId());
boolean authResult = fileDealComp.checkAuthDownloadAndPreview(previewDTO.getShareBatchNum(),
previewDTO.getExtractionCode(),
token,
previewDTO.getUserFileId(),
previewDTO.getPlatform());
if (!authResult) {
log.error("没有权限预览!!!");
return;
}
String fileName = userFile.getFileName() + "." + userFile.getExtendName();
try {
fileName = new String(fileName.getBytes("utf-8"), "ISO-8859-1");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
httpServletResponse.addHeader("Content-Disposition", "fileName=" + fileName);// 设置文件名
String mime = MimeUtils.getMime(userFile.getExtendName());
httpServletResponse.setHeader("Content-Type", mime);
if (UFOPUtils.isImageFile(userFile.getExtendName())) {
httpServletResponse.setHeader("cache-control", "public");
}
FileBean fileBean = fileService.getById(userFile.getFileId());
if (UFOPUtils.isVideoFile(userFile.getExtendName()) || "mp3".equalsIgnoreCase(userFile.getExtendName()) || "flac".equalsIgnoreCase(userFile.getExtendName())) {
//获取从那个字节开始读取文件
String rangeString = httpServletRequest.getHeader("Range");
int start = 0;
if (StringUtils.isNotBlank(rangeString)) {
start = Integer.parseInt(rangeString.substring(rangeString.indexOf("=") + 1, rangeString.indexOf("-")));
}
Downloader downloader = ufopFactory.getDownloader(fileBean.getStorageType());
DownloadFile downloadFile = new DownloadFile();
downloadFile.setFileUrl(fileBean.getFileUrl());
Range range = new Range();
range.setStart(start);
if (start + 1024 * 1024 * 1 >= fileBean.getFileSize().intValue()) {
range.setLength(fileBean.getFileSize().intValue() - start);
} else {
range.setLength(1024 * 1024 * 1);
}
downloadFile.setRange(range);
InputStream inputStream = downloader.getInputStream(downloadFile);
OutputStream outputStream = httpServletResponse.getOutputStream();
try {
//返回码需要为206代表只处理了部分请求响应了部分数据
httpServletResponse.setStatus(HttpServletResponse.SC_PARTIAL_CONTENT);
// 每次请求只返回1MB的视频流
httpServletResponse.setHeader("Accept-Ranges", "bytes");
//设置此次相应返回的数据范围
httpServletResponse.setHeader("Content-Range", "bytes " + start + "-" + (fileBean.getFileSize() - 1) + "/" + fileBean.getFileSize());
IOUtils.copy(inputStream, outputStream);
} finally {
IOUtils.closeQuietly(inputStream);
IOUtils.closeQuietly(outputStream);
if (downloadFile.getOssClient() != null) {
downloadFile.getOssClient().shutdown();
}
}
} else {
filetransferService.previewFile(httpServletResponse, previewDTO);
}
}
@Operation(summary = "获取存储信息", description = "获取存储信息", tags = {"filetransfer"})
@RequestMapping(value = "/getstorage", method = RequestMethod.GET)
@ResponseBody
public RestResult<StorageBean> getStorage() {
JwtUser sessionUserBean = SessionUtil.getSession();
StorageBean storageBean = new StorageBean();
storageBean.setUserId(sessionUserBean.getUserId());
Long storageSize = filetransferService.selectStorageSizeByUserId(sessionUserBean.getUserId());
StorageBean storage = new StorageBean();
storage.setUserId(sessionUserBean.getUserId());
storage.setStorageSize(storageSize);
Long totalStorageSize = storageService.getTotalStorageSize(sessionUserBean.getUserId());
storage.setTotalStorageSize(totalStorageSize);
return RestResult.success().data(storage);
}
}

View File

@ -0,0 +1,106 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qiwenshare.common.anno.MyLog;
import com.qiwenshare.common.result.RestResult;
import com.qiwenshare.common.util.security.JwtUser;
import com.qiwenshare.common.util.security.SessionUtil;
import com.zhgd.xmgl.modules.basicdata.qiwen.api.*;
import com.zhgd.xmgl.modules.basicdata.qiwen.component.AsyncTaskComp;
import com.zhgd.xmgl.modules.basicdata.qiwen.domain.RecoveryFile;
import com.zhgd.xmgl.modules.basicdata.qiwen.dto.file.DeleteRecoveryFileDTO;
import com.zhgd.xmgl.modules.basicdata.qiwen.dto.recoveryfile.BatchDeleteRecoveryFileDTO;
import com.zhgd.xmgl.modules.basicdata.qiwen.dto.recoveryfile.RestoreFileDTO;
import com.zhgd.xmgl.modules.basicdata.qiwen.vo.file.RecoveryFileListVo;
import com.zhgd.xmgl.modules.basicdata.service.ISystemUserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
@Tag(name = "recoveryfile", description = "文件删除后会进入回收站,该接口主要是对回收站文件进行管理")
@RestController
@Slf4j
@RequestMapping("/recoveryfile")
public class RecoveryFileController {
@Resource
IRecoveryFileService recoveryFileService;
@Resource
IUserFileService userFileService;
@Resource
ISystemUserService systemUserService;
@Resource
IFileService fileService;
@Resource
IFiletransferService filetransferService;
@Resource
AsyncTaskComp asyncTaskComp;
public static final String CURRENT_MODULE = "回收站文件接口";
@Operation(summary = "删除回收文件", description = "删除回收文件", tags = {"recoveryfile"})
@MyLog(operation = "删除回收文件", module = CURRENT_MODULE)
@RequestMapping(value = "/deleterecoveryfile", method = RequestMethod.POST)
@ResponseBody
public RestResult<String> deleteRecoveryFile(@RequestBody DeleteRecoveryFileDTO deleteRecoveryFileDTO) {
RecoveryFile recoveryFile = recoveryFileService.getOne(new QueryWrapper<RecoveryFile>().lambda().eq(RecoveryFile::getUserFileId, deleteRecoveryFileDTO.getUserFileId()));
asyncTaskComp.deleteUserFile(recoveryFile.getUserFileId());
recoveryFileService.removeById(recoveryFile.getRecoveryFileId());
return RestResult.success().data("删除成功");
}
@Operation(summary = "批量删除回收文件", description = "批量删除回收文件", tags = {"recoveryfile"})
@RequestMapping(value = "/batchdelete", method = RequestMethod.POST)
@MyLog(operation = "批量删除回收文件", module = CURRENT_MODULE)
@ResponseBody
public RestResult<String> batchDeleteRecoveryFile(@RequestBody BatchDeleteRecoveryFileDTO batchDeleteRecoveryFileDTO) {
String userFileIds = batchDeleteRecoveryFileDTO.getUserFileIds();
String[] userFileIdList = userFileIds.split(",");
for (String userFileId : userFileIdList) {
RecoveryFile recoveryFile = recoveryFileService.getOne(new QueryWrapper<RecoveryFile>().lambda().eq(RecoveryFile::getUserFileId, userFileId));
if (recoveryFile != null) {
asyncTaskComp.deleteUserFile(recoveryFile.getUserFileId());
recoveryFileService.removeById(recoveryFile.getRecoveryFileId());
}
}
return RestResult.success().data("批量删除成功");
}
@Operation(summary = "回收文件列表", description = "回收文件列表", tags = {"recoveryfile"})
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
public RestResult<RecoveryFileListVo> getRecoveryFileList() {
JwtUser sessionUserBean = SessionUtil.getSession();
List<RecoveryFileListVo> recoveryFileList = recoveryFileService.selectRecoveryFileList(sessionUserBean.getUserId());
return RestResult.success().dataList(recoveryFileList, recoveryFileList.size());
}
@Operation(summary = "还原文件", description = "还原文件", tags = {"recoveryfile"})
@RequestMapping(value = "/restorefile", method = RequestMethod.POST)
@MyLog(operation = "还原文件", module = CURRENT_MODULE)
@ResponseBody
public RestResult restoreFile(@RequestBody RestoreFileDTO restoreFileDto) {
JwtUser sessionUserBean = SessionUtil.getSession();
recoveryFileService.restorefile(restoreFileDto.getDeleteBatchNum(), restoreFileDto.getFilePath(), sessionUserBean.getUserId());
return RestResult.success().message("还原成功!");
}
}

View File

@ -0,0 +1,235 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.controller;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.RandomUtil;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.qiwenshare.common.anno.MyLog;
import com.qiwenshare.common.result.RestResult;
import com.qiwenshare.common.util.DateUtil;
import com.qiwenshare.common.util.security.JwtUser;
import com.qiwenshare.common.util.security.SessionUtil;
import com.zhgd.xmgl.modules.basicdata.qiwen.api.IShareFileService;
import com.zhgd.xmgl.modules.basicdata.qiwen.api.IShareService;
import com.zhgd.xmgl.modules.basicdata.qiwen.api.IUserFileService;
import com.zhgd.xmgl.modules.basicdata.qiwen.component.FileDealComp;
import com.zhgd.xmgl.modules.basicdata.qiwen.domain.Share;
import com.zhgd.xmgl.modules.basicdata.qiwen.domain.ShareFile;
import com.zhgd.xmgl.modules.basicdata.qiwen.domain.UserFile;
import com.zhgd.xmgl.modules.basicdata.qiwen.dto.sharefile.*;
import com.zhgd.xmgl.modules.basicdata.qiwen.io.QiwenFile;
import com.zhgd.xmgl.modules.basicdata.qiwen.vo.share.ShareFileListVO;
import com.zhgd.xmgl.modules.basicdata.qiwen.vo.share.ShareFileVO;
import com.zhgd.xmgl.modules.basicdata.qiwen.vo.share.ShareListVO;
import com.zhgd.xmgl.modules.basicdata.qiwen.vo.share.ShareTypeVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
@Tag(name = "share", description = "该接口为文件分享接口")
@RestController
@Slf4j
@RequestMapping("/share")
public class ShareController {
public static final String CURRENT_MODULE = "文件分享";
@Resource
IShareFileService shareFileService;
@Resource
IShareService shareService;
@Resource
IUserFileService userFileService;
@Resource
FileDealComp fileDealComp;
@Operation(summary = "分享文件", description = "分享文件统一接口", tags = {"share"})
@PostMapping(value = "/sharefile")
@MyLog(operation = "分享文件", module = CURRENT_MODULE)
@ResponseBody
public RestResult<ShareFileVO> shareFile( @RequestBody ShareFileDTO shareFileDTO) {
ShareFileVO shareSecretVO = new ShareFileVO();
JwtUser sessionUserBean = SessionUtil.getSession();
String uuid = UUID.randomUUID().toString().replace("-", "");
Share share = new Share();
share.setShareId(IdUtil.getSnowflakeNextIdStr());
BeanUtil.copyProperties(shareFileDTO, share);
share.setShareTime(DateUtil.getCurrentTime());
share.setUserId(sessionUserBean.getUserId());
share.setShareStatus(0);
if (shareFileDTO.getShareType() == 1) {
String extractionCode = RandomUtil.randomNumbers(6);
share.setExtractionCode(extractionCode);
shareSecretVO.setExtractionCode(share.getExtractionCode());
}
share.setShareBatchNum(uuid);
shareService.save(share);
List<ShareFile> saveFileList = new ArrayList<>();
String userFileIds = shareFileDTO.getUserFileIds();
String[] userFileIdList = userFileIds.split(",");
for (String userFileId : userFileIdList) {
UserFile userFile = userFileService.getById(userFileId);
if (userFile.getUserId().compareTo(sessionUserBean.getUserId()) != 0) {
return RestResult.fail().message("您只能分享自己的文件");
}
if (userFile.getIsDir() == 1) {
QiwenFile qiwenFile = new QiwenFile(userFile.getFilePath(), userFile.getFileName(), true);
List<UserFile> userfileList = userFileService.selectUserFileByLikeRightFilePath(qiwenFile.getPath(), sessionUserBean.getUserId());
for (UserFile userFile1 : userfileList) {
ShareFile shareFile1 = new ShareFile();
shareFile1.setShareFileId(IdUtil.getSnowflakeNextIdStr());
shareFile1.setUserFileId(userFile1.getUserFileId());
shareFile1.setShareBatchNum(uuid);
shareFile1.setShareFilePath(userFile1.getFilePath().replaceFirst(userFile.getFilePath().equals("/") ? "" : userFile.getFilePath(), ""));
saveFileList.add(shareFile1);
}
}
ShareFile shareFile = new ShareFile();
shareFile.setShareFileId(IdUtil.getSnowflakeNextIdStr());
shareFile.setUserFileId(userFileId);
shareFile.setShareFilePath("/");
shareFile.setShareBatchNum(uuid);
saveFileList.add(shareFile);
}
shareFileService.batchInsertShareFile(saveFileList);
shareSecretVO.setShareBatchNum(uuid);
return RestResult.success().data(shareSecretVO);
}
@Operation(summary = "保存分享文件", description = "用来将别人分享的文件保存到自己的网盘中", tags = {"share"})
@PostMapping(value = "/savesharefile")
@MyLog(operation = "保存分享文件", module = CURRENT_MODULE)
@Transactional(rollbackFor=Exception.class)
@ResponseBody
public RestResult saveShareFile(@RequestBody SaveShareFileDTO saveShareFileDTO) {
JwtUser sessionUserBean = SessionUtil.getSession();
List<ShareFile> fileList = JSON.parseArray(saveShareFileDTO.getFiles(), ShareFile.class);
String savefilePath = saveShareFileDTO.getFilePath();
String userId = sessionUserBean.getUserId();
List<UserFile> saveUserFileList = new ArrayList<>();
for (ShareFile shareFile : fileList) {
UserFile userFile = userFileService.getById(shareFile.getUserFileId());
String fileName = userFile.getFileName();
String savefileName = fileDealComp.getRepeatFileName(userFile, savefilePath);
if (userFile.getIsDir() == 1) {
List<UserFile> userfileList = userFileService.selectUserFileByLikeRightFilePath(new QiwenFile(userFile.getFilePath(), userFile.getFileName(), true).getPath(), userFile.getUserId());
log.info("查询文件列表:" + JSON.toJSONString(userfileList));
String filePath = userFile.getFilePath();
userfileList.forEach(p->{
p.setUserFileId(IdUtil.getSnowflakeNextIdStr());
p.setUserId(userId);
p.setFilePath(p.getFilePath().replaceFirst(filePath + "/" + fileName, savefilePath + "/" + savefileName));
saveUserFileList.add(p);
log.info("当前文件:" + JSON.toJSONString(p));
});
}
userFile.setUserFileId(IdUtil.getSnowflakeNextIdStr());
userFile.setUserId(userId);
userFile.setFilePath(savefilePath);
userFile.setFileName(savefileName);
saveUserFileList.add(userFile);
}
log.info("----------" + JSON.toJSONString(saveUserFileList));
userFileService.saveBatch(saveUserFileList);
return RestResult.success();
}
@Operation(summary = "查看已分享列表", description = "查看已分享列表", tags = {"share"})
@GetMapping(value = "/shareList")
@ResponseBody
public RestResult<ShareListVO> shareList(ShareListDTO shareListDTO) {
JwtUser sessionUserBean = SessionUtil.getSession();
List<ShareListVO> shareList = shareService.selectShareList(shareListDTO, sessionUserBean.getUserId());
int total = shareService.selectShareListTotalCount(shareListDTO, sessionUserBean.getUserId());
return RestResult.success().dataList(shareList, total);
}
@Operation(summary = "分享文件列表", description = "分享列表", tags = {"share"})
@GetMapping(value = "/sharefileList")
@ResponseBody
public RestResult<ShareFileListVO> shareFileList(ShareFileListDTO shareFileListBySecretDTO) {
String shareBatchNum = shareFileListBySecretDTO.getShareBatchNum();
String shareFilePath = shareFileListBySecretDTO.getShareFilePath();
List<ShareFileListVO> list = shareFileService.selectShareFileList(shareBatchNum, shareFilePath);
for (ShareFileListVO shareFileListVO : list) {
shareFileListVO.setShareFilePath(shareFilePath);
}
return RestResult.success().dataList(list, list.size());
}
@Operation(summary = "分享类型", description = "可用此接口判断是否需要提取码", tags = {"share"})
@GetMapping(value = "/sharetype")
@ResponseBody
public RestResult<ShareTypeVO> shareType(ShareTypeDTO shareTypeDTO) {
LambdaQueryWrapper<Share> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(Share::getShareBatchNum, shareTypeDTO.getShareBatchNum());
Share share = shareService.getOne(lambdaQueryWrapper);
ShareTypeVO shareTypeVO = new ShareTypeVO();
shareTypeVO.setShareType(share.getShareType());
return RestResult.success().data(shareTypeVO);
}
@Operation(summary = "校验提取码", description = "校验提取码", tags = {"share"})
@GetMapping(value = "/checkextractioncode")
@ResponseBody
public RestResult<String> checkExtractionCode(CheckExtractionCodeDTO checkExtractionCodeDTO) {
LambdaQueryWrapper<Share> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(Share::getShareBatchNum, checkExtractionCodeDTO.getShareBatchNum())
.eq(Share::getExtractionCode, checkExtractionCodeDTO.getExtractionCode());
List<Share> list = shareService.list(lambdaQueryWrapper);
if (list.isEmpty()) {
return RestResult.fail().message("校验失败");
} else {
return RestResult.success();
}
}
@Operation(summary = "校验过期时间", description = "校验过期时间", tags = {"share"})
@GetMapping(value = "/checkendtime")
@ResponseBody
public RestResult<String> checkEndTime(CheckEndTimeDTO checkEndTimeDTO) {
LambdaQueryWrapper<Share> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(Share::getShareBatchNum, checkEndTimeDTO.getShareBatchNum());
Share share = shareService.getOne(lambdaQueryWrapper);
if (share == null) {
return RestResult.fail().message("文件不存在!");
}
String endTime = share.getEndTime();
Date endTimeDate = null;
try {
endTimeDate = DateUtil.getDateByFormatString(endTime, "yyyy-MM-dd HH:mm:ss");
} catch (ParseException e) {
log.error("日期解析失败:{}" , e);
}
if (new Date().after(endTimeDate)) {
return RestResult.fail().message("分享已过期");
} else {
return RestResult.success();
}
}
}

View File

@ -0,0 +1,47 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qiwenshare.common.result.RestResult;
import com.zhgd.xmgl.modules.basicdata.qiwen.api.ISysParamService;
import com.zhgd.xmgl.modules.basicdata.qiwen.domain.SysParam;
import com.zhgd.xmgl.modules.basicdata.qiwen.dto.param.QueryGroupParamDTO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Tag(name = "系统参数管理")
@RestController
@RequestMapping("/param")
public class SysParamController {
@Resource
ISysParamService sysParamService;
@Operation(summary = "查询系统参数组", tags = {"系统参数管理"})
@RequestMapping(value = "/grouplist", method = RequestMethod.GET)
@ResponseBody
public RestResult<Map> groupList(
@Parameter(description = "查询参数dto", required = false)
QueryGroupParamDTO queryGroupParamDTO
) {
List<SysParam> list = sysParamService.list(new QueryWrapper<SysParam>().lambda().eq(SysParam::getGroupName, queryGroupParamDTO.getGroupName()));
Map<String, Object> result = new HashMap<>();
for (SysParam sysParam : list) {
result.put(sysParam.getSysParamKey(), sysParam.getSysParamValue());
}
return RestResult.success().data(result);
}
}

View File

@ -0,0 +1,81 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zhgd.xmgl.modules.basicdata.qiwen.api.IShareFileService;
import com.zhgd.xmgl.modules.basicdata.qiwen.component.FileDealComp;
import com.zhgd.xmgl.modules.basicdata.qiwen.domain.ShareFile;
import com.zhgd.xmgl.modules.basicdata.qiwen.domain.UserFile;
import com.zhgd.xmgl.modules.basicdata.qiwen.io.QiwenFile;
import com.zhgd.xmgl.modules.basicdata.qiwen.service.UserFileService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Controller;
import javax.annotation.Resource;
import java.util.List;
@Slf4j
@Controller
public class TaskController {
@Resource
UserFileService userFileService;
@Resource
FileDealComp fileDealComp;
@Resource
IShareFileService shareFileService;
@Scheduled(fixedRate = 1000 * 60 * 60 * 24)
public void updateElasticSearch() {
List<UserFile> userfileList = userFileService.list(new QueryWrapper<UserFile>().eq("delete_flag", 0));
for (int i = 0; i < userfileList.size(); i++) {
try {
QiwenFile ufopFile = new QiwenFile(userfileList.get(i).getFilePath(), userfileList.get(i).getFileName(), userfileList.get(i).getIsDir() == 1);
fileDealComp.restoreParentFilePath(ufopFile, userfileList.get(i).getUserId());
if (i % 1000 == 0 || i == userfileList.size() - 1) {
log.info("目录健康检查进度:" + (i + 1) + "/" + userfileList.size());
}
} catch (Exception e) {
log.error(e.getMessage());
}
}
userfileList = userFileService.list(new QueryWrapper<UserFile>().eq("delete_flag", 0));
for (UserFile userFile : userfileList) {
fileDealComp.uploadESByUserFileId(userFile.getUserFileId());
}
}
@Scheduled(fixedRate = Long.MAX_VALUE)
public void updateFilePath() {
List<UserFile> list = userFileService.list();
for (UserFile userFile : list) {
try {
String path = QiwenFile.formatPath(userFile.getFilePath());
if (!userFile.getFilePath().equals(path)) {
userFile.setFilePath(path);
userFileService.updateById(userFile);
}
} catch (Exception e) {
// ignore
}
}
}
@Scheduled(fixedRate = Long.MAX_VALUE)
public void updateShareFilePath() {
List<ShareFile> list = shareFileService.list();
for (ShareFile shareFile : list) {
try {
String path = QiwenFile.formatPath(shareFile.getShareFilePath());
shareFile.setShareFilePath(path);
shareFileService.updateById(shareFile);
} catch (Exception e) {
//ignore
}
}
}
}

View File

@ -0,0 +1,37 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import java.io.Serializable;
/**
* @Description: 文件
* @author pengj
* @date 2023-05-10
* @version V1.0
*/
@Data
@TableName("commonfile")
@ApiModel(value = "CommonFile实体类", description = "CommonFile")
public class CommonFile implements Serializable {
private static final long serialVersionUID = 1L;
/**
* commonfileid
*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "commonfileid")
private String commonFileId;
/**
* 用户文件id
*/
@Excel(name = "用户文件id", width = 15)
@ApiModelProperty(value = "用户文件id")
private String userFileId;
}

View File

@ -0,0 +1,115 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.domain;
import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.qiwenshare.common.util.DateUtil;
import com.qiwenshare.ufop.operation.upload.domain.UploadFileResult;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import java.io.Serializable;
/**
* @Description: 文件实体类
* @author pengj
* @date 2023-05-10
* @version V1.0
*/
@Data
@TableName("file")
@ApiModel(value = "FileBean实体类", description = "FileBean")
public class FileBean implements Serializable {
private static final long serialVersionUID = 1L;
/**
* fileid
*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "fileid")
private String fileId;
/**
* 创建时间
*/
@Excel(name = "创建时间", width = 15)
@ApiModelProperty(value = "创建时间")
private String createTime;
/**
* 创建用户id
*/
@Excel(name = "创建用户id", width = 15)
@ApiModelProperty(value = "创建用户id")
private String createUserId;
/**
* 文件大小
*/
@Excel(name = "文件大小", width = 15)
@ApiModelProperty(value = "文件大小")
private Long fileSize;
/**
* 文件状态(0-失效1-生效)
*/
@Excel(name = "文件状态(0-失效1-生效)", width = 15)
@ApiModelProperty(value = "文件状态(0-失效1-生效)")
private Integer fileStatus;
/**
* 文件url
*/
@Excel(name = "文件url", width = 15)
@ApiModelProperty(value = "文件url")
private String fileUrl;
/**
* md5唯一标识
*/
@Excel(name = "md5唯一标识", width = 15)
@ApiModelProperty(value = "md5唯一标识")
private String identifier;
/**
* 修改时间
*/
@Excel(name = "修改时间", width = 15)
@ApiModelProperty(value = "修改时间")
private String modifyTime;
/**
* 修改用户id
*/
@Excel(name = "修改用户id", width = 15)
@ApiModelProperty(value = "修改用户id")
private String modifyUserId;
/**
* 存储类型
*/
@Excel(name = "存储类型", width = 15)
@ApiModelProperty(value = "存储类型")
private Integer storageType;
public FileBean(){
}
public FileBean(UploadFileResult uploadFileResult) {
this.fileId = IdUtil.getSnowflakeNextIdStr();
this.fileUrl = uploadFileResult.getFileUrl();
this.fileSize = uploadFileResult.getFileSize();
this.fileStatus = 1;
this.storageType = uploadFileResult.getStorageType().getCode();
this.identifier = uploadFileResult.getIdentifier();
this.createTime = DateUtil.getCurrentTime();
}
public FileBean(String fileUrl, Long fileSize, Integer storageType, String identifier, String userId) {
this.fileId = IdUtil.getSnowflakeNextIdStr();
this.fileUrl = fileUrl;
this.fileSize = fileSize;
this.fileStatus = 1;
this.storageType = storageType;
this.identifier = identifier;
this.createTime = DateUtil.getCurrentTime();
this.createUserId = userId;
}
}

View File

@ -0,0 +1,43 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import java.io.Serializable;
/**
* @Description: 文件
* @author pengj
* @date 2023-05-10
* @version V1.0
*/
@Data
@TableName("fileclassification")
@ApiModel(value = "FileClassification实体类", description = "FileClassification")
public class FileClassification implements Serializable {
private static final long serialVersionUID = 1L;
/**
* fileclassificationid
*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "fileclassificationid")
private Integer fileclassificationid;
/**
* 文件扩展名
*/
@Excel(name = "文件扩展名", width = 15)
@ApiModelProperty(value = "文件扩展名")
private String fileextendname;
/**
* 文件类型id
*/
@Excel(name = "文件类型id", width = 15)
@ApiModelProperty(value = "文件类型id")
private Integer filetypeid;
}

View File

@ -0,0 +1,43 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import java.io.Serializable;
/**
* @Description: 文件
* @author pengj
* @date 2023-05-10
* @version V1.0
*/
@Data
@TableName("fileextend")
@ApiModel(value = "FileExtend实体类", description = "FileExtend")
public class FileExtend implements Serializable {
private static final long serialVersionUID = 1L;
/**
* fileextendname
*/
@TableId(type = IdType.INPUT)
@ApiModelProperty(value = "fileextendname")
private String fileextendname;
/**
* 文件扩展名描述
*/
@Excel(name = "文件扩展名描述", width = 15)
@ApiModelProperty(value = "文件扩展名描述")
private String fileextenddesc;
/**
* 文件扩展名预览图
*/
@Excel(name = "文件扩展名预览图", width = 15)
@ApiModelProperty(value = "文件扩展名预览图")
private String fileextendimgurl;
}

View File

@ -0,0 +1,91 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import java.io.Serializable;
/**
* @Description: 文件
* @author pengj
* @date 2023-05-10
* @version V1.0
*/
@Data
@TableName("file_notice")
@ApiModel(value = "FileNotice实体类", description = "FileNotice")
public class FileNotice implements Serializable {
private static final long serialVersionUID = 1L;
/**
* noticeid
*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "noticeid")
private Integer noticeid;
/**
* html内容
*/
@Excel(name = "html内容", width = 15)
@ApiModelProperty(value = "html内容")
private Object content;
/**
* 创建时间
*/
@Excel(name = "创建时间", width = 15)
@ApiModelProperty(value = "创建时间")
private String createtime;
/**
* 创建用户id
*/
@Excel(name = "创建用户id", width = 15)
@ApiModelProperty(value = "创建用户id")
private Integer createuserid;
/**
* 是否长期有效(0-,1-)
*/
@Excel(name = "是否长期有效(0-否,1-是)", width = 15)
@ApiModelProperty(value = "是否长期有效(0-否,1-是)")
private Integer islongvaliddata;
/**
* markdown原文
*/
@Excel(name = "markdown原文", width = 15)
@ApiModelProperty(value = "markdown原文")
private Object markdowncontent;
/**
* 修改时间
*/
@Excel(name = "修改时间", width = 15)
@ApiModelProperty(value = "修改时间")
private String modifytime;
/**
* 修改用户id
*/
@Excel(name = "修改用户id", width = 15)
@ApiModelProperty(value = "修改用户id")
private Integer modifyuserid;
/**
* 平台(1-社区,2-管理端,3-网盘,4-股票)
*/
@Excel(name = "平台(1-社区,2-管理端,3-网盘,4-股票)", width = 15)
@ApiModelProperty(value = "平台(1-社区,2-管理端,3-网盘,4-股票)")
private Integer platform;
/**
* 标题
*/
@Excel(name = "标题", width = 15)
@ApiModelProperty(value = "标题")
private String title;
/**
* 有效时间
*/
@Excel(name = "有效时间", width = 15)
@ApiModelProperty(value = "有效时间")
private String validdatetime;
}

View File

@ -0,0 +1,49 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import java.io.Serializable;
/**
* @Description: 文件
* @author pengj
* @date 2023-05-10
* @version V1.0
*/
@Data
@TableName("filepermission")
@ApiModel(value = "FilePermission实体类", description = "FilePermission")
public class FilePermission implements Serializable {
private static final long serialVersionUID = 1L;
/**
* filepermissionid
*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "filepermissionid")
private Long filePermissionId;
/**
* 共享文件id
*/
@Excel(name = "共享文件id", width = 15)
@ApiModelProperty(value = "共享文件id")
private String commonFileId;
/**
* 用户对文件的权限码
*/
@Excel(name = "用户对文件的权限码", width = 15)
@ApiModelProperty(value = "用户对文件的权限码")
private Integer filepermissioncode;
/**
* 用户id
*/
@Excel(name = "用户id", width = 15)
@ApiModelProperty(value = "用户id")
private Integer userid;
}

View File

@ -0,0 +1,43 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import java.io.Serializable;
/**
* @Description: 文件
* @author pengj
* @date 2023-05-10
* @version V1.0
*/
@Data
@TableName("filetype")
@ApiModel(value = "FileType实体类", description = "FileType")
public class FileType implements Serializable {
private static final long serialVersionUID = 1L;
/**
* filetypeid
*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "filetypeid")
private Integer filetypeid;
/**
* 文件类型名
*/
@Excel(name = "文件类型名", width = 15)
@ApiModelProperty(value = "文件类型名")
private String filetypename;
/**
* 次序
*/
@Excel(name = "次序", width = 15)
@ApiModelProperty(value = "次序")
private Integer ordernum;
}

View File

@ -0,0 +1,49 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import java.io.Serializable;
/**
* @Description: 文件
* @author pengj
* @date 2023-05-10
* @version V1.0
*/
@Data
@TableName("image")
@ApiModel(value = "Image实体类", description = "Image")
public class Image implements Serializable {
private static final long serialVersionUID = 1L;
/**
* imageid
*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "imageid")
private Integer imageId;
/**
* 文件id
*/
@Excel(name = "文件id", width = 15)
@ApiModelProperty(value = "文件id")
private String fileId;
/**
* 图像的高
*/
@Excel(name = "图像的高", width = 15)
@ApiModelProperty(value = "图像的高")
private Integer imageHeight;
/**
* 图像的宽
*/
@Excel(name = "图像的宽", width = 15)
@ApiModelProperty(value = "图像的宽")
private Integer imageWidth;
}

View File

@ -0,0 +1,139 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import java.io.Serializable;
/**
* @Description: 文件
* @author pengj
* @date 2023-05-10
* @version V1.0
*/
@Data
@TableName("music")
@ApiModel(value = "Music实体类", description = "Music")
public class Music implements Serializable {
private static final long serialVersionUID = 1L;
/**
* musicid
*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "musicid")
private String musicId;
/**
* album
*/
@Excel(name = "album", width = 15)
@ApiModelProperty(value = "album")
private String album;
/**
* albumartist
*/
@Excel(name = "albumartist", width = 15)
@ApiModelProperty(value = "albumartist")
private String albumArtist;
/**
* albumimage
*/
@Excel(name = "albumimage", width = 15)
@ApiModelProperty(value = "albumimage")
private String albumImage;
/**
* artist
*/
@Excel(name = "artist", width = 15)
@ApiModelProperty(value = "artist")
private String artist;
/**
* comment
*/
@Excel(name = "comment", width = 15)
@ApiModelProperty(value = "comment")
private String comment;
/**
* composer
*/
@Excel(name = "composer", width = 15)
@ApiModelProperty(value = "composer")
private String composer;
/**
* copyright
*/
@Excel(name = "copyright", width = 15)
@ApiModelProperty(value = "copyright")
private String copyright;
/**
* encoder
*/
@Excel(name = "encoder", width = 15)
@ApiModelProperty(value = "encoder")
private String encoder;
/**
* 文件id
*/
@Excel(name = "文件id", width = 15)
@ApiModelProperty(value = "文件id")
private String fileId;
/**
* genre
*/
@Excel(name = "genre", width = 15)
@ApiModelProperty(value = "genre")
private String genre;
/**
* 歌词
*/
@Excel(name = "歌词", width = 15)
@ApiModelProperty(value = "歌词")
private String lyrics;
/**
* originalartist
*/
@Excel(name = "originalartist", width = 15)
@ApiModelProperty(value = "originalartist")
private String originalartist;
/**
* publicer
*/
@Excel(name = "publicer", width = 15)
@ApiModelProperty(value = "publicer")
private String publicer;
/**
* title
*/
@Excel(name = "title", width = 15)
@ApiModelProperty(value = "title")
private String title;
/**
* track
*/
@Excel(name = "track", width = 15)
@ApiModelProperty(value = "track")
private String track;
/**
* tracklength
*/
@Excel(name = "tracklength", width = 15)
@ApiModelProperty(value = "tracklength")
private Float trackLength;
/**
* url
*/
@Excel(name = "url", width = 15)
@ApiModelProperty(value = "url")
private String url;
/**
* year
*/
@Excel(name = "year", width = 15)
@ApiModelProperty(value = "year")
private String year;
}

View File

@ -0,0 +1,91 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import java.io.Serializable;
/**
* @Description: 文件
* @author pengj
* @date 2023-05-10
* @version V1.0
*/
@Data
@TableName("picturefile")
@ApiModel(value = "PictureFile实体类", description = "PictureFile")
public class PictureFile implements Serializable {
private static final long serialVersionUID = 1L;
/**
* picturefileid
*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "picturefileid")
private Integer picturefileid;
/**
* 创建时间
*/
@Excel(name = "创建时间", width = 15)
@ApiModelProperty(value = "创建时间")
private String createtime;
/**
* 创建用户id
*/
@Excel(name = "创建用户id", width = 15)
@ApiModelProperty(value = "创建用户id")
private Integer createuserid;
/**
* 扩展名
*/
@Excel(name = "扩展名", width = 15)
@ApiModelProperty(value = "扩展名")
private String extendName;
/**
* 文件名
*/
@Excel(name = "文件名", width = 15)
@ApiModelProperty(value = "文件名")
private String fileName;
/**
* 文件大小
*/
@Excel(name = "文件大小", width = 15)
@ApiModelProperty(value = "文件大小")
private Integer filesize;
/**
* 文件url
*/
@Excel(name = "文件url", width = 15)
@ApiModelProperty(value = "文件url")
private String fileUrl;
/**
* 修改时间
*/
@Excel(name = "修改时间", width = 15)
@ApiModelProperty(value = "修改时间")
private String modifyTime;
/**
* 修改用户id
*/
@Excel(name = "修改用户id", width = 15)
@ApiModelProperty(value = "修改用户id")
private Integer modifyuserid;
/**
* 存储类型
*/
@Excel(name = "存储类型", width = 15)
@ApiModelProperty(value = "存储类型")
private Integer storageType;
/**
* 用户id
*/
@Excel(name = "用户id", width = 15)
@ApiModelProperty(value = "用户id")
private Integer userid;
}

View File

@ -0,0 +1,49 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import java.io.Serializable;
/**
* @Description: 文件
* @author pengj
* @date 2023-05-10
* @version V1.0
*/
@Data
@TableName("recoveryfile")
@ApiModel(value = "RecoveryFile实体类", description = "RecoveryFile")
public class RecoveryFile implements Serializable {
private static final long serialVersionUID = 1L;
/**
* recoveryfileid
*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "recoveryfileid")
private Integer recoveryFileId;
/**
* 删除批次号
*/
@Excel(name = "删除批次号", width = 15)
@ApiModelProperty(value = "删除批次号")
private String deleteBatchNum;
/**
* 删除时间
*/
@Excel(name = "删除时间", width = 15)
@ApiModelProperty(value = "删除时间")
private String deleteTime;
/**
* 用户文件id
*/
@Excel(name = "用户文件id", width = 15)
@ApiModelProperty(value = "用户文件id")
private String userFileId;
}

View File

@ -0,0 +1,73 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import java.io.Serializable;
/**
* @Description: 文件
* @author pengj
* @date 2023-05-10
* @version V1.0
*/
@Data
@TableName("share")
@ApiModel(value = "Share实体类", description = "Share")
public class Share implements Serializable {
private static final long serialVersionUID = 1L;
/**
* shareid
*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "shareid")
private String shareId;
/**
* 失效时间
*/
@Excel(name = "失效时间", width = 15)
@ApiModelProperty(value = "失效时间")
private String endTime;
/**
* 提取码
*/
@Excel(name = "提取码", width = 15)
@ApiModelProperty(value = "提取码")
private String extractionCode;
/**
* 分享批次号
*/
@Excel(name = "分享批次号", width = 15)
@ApiModelProperty(value = "分享批次号")
private String shareBatchNum;
/**
* 分享状态(0正常,1已失效,2已撤销)
*/
@Excel(name = "分享状态(0正常,1已失效,2已撤销)", width = 15)
@ApiModelProperty(value = "分享状态(0正常,1已失效,2已撤销)")
private Integer shareStatus;
/**
* 分享时间
*/
@Excel(name = "分享时间", width = 15)
@ApiModelProperty(value = "分享时间")
private String shareTime;
/**
* 分享类型(0公共,1私密,2好友)
*/
@Excel(name = "分享类型(0公共,1私密,2好友)", width = 15)
@ApiModelProperty(value = "分享类型(0公共,1私密,2好友)")
private Integer shareType;
/**
* 用户id
*/
@Excel(name = "用户id", width = 15)
@ApiModelProperty(value = "用户id")
private String userId;
}

View File

@ -0,0 +1,49 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import java.io.Serializable;
/**
* @Description: 文件
* @author pengj
* @date 2023-05-10
* @version V1.0
*/
@Data
@TableName("share_file")
@ApiModel(value = "ShareFile实体类", description = "ShareFile")
public class ShareFile implements Serializable {
private static final long serialVersionUID = 1L;
/**
* sharefileid
*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "sharefileid")
private String shareFileId;
/**
* 分享批次号
*/
@Excel(name = "分享批次号", width = 15)
@ApiModelProperty(value = "分享批次号")
private String shareBatchNum;
/**
* 分享文件路径
*/
@Excel(name = "分享文件路径", width = 15)
@ApiModelProperty(value = "分享文件路径")
private String shareFilePath;
/**
* 用户文件id
*/
@Excel(name = "用户文件id", width = 15)
@ApiModelProperty(value = "用户文件id")
private String userFileId;
}

View File

@ -0,0 +1,61 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import java.io.Serializable;
/**
* @Description: 文件
* @author pengj
* @date 2023-05-10
* @version V1.0
*/
@Data
@TableName("storage")
@ApiModel(value = "StorageBean实体类", description = "StorageBean")
public class StorageBean implements Serializable {
private static final long serialVersionUID = 1L;
/**
* storageid
*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "storageid")
private Integer storageId;
/**
* 修改时间
*/
@Excel(name = "修改时间", width = 15)
@ApiModelProperty(value = "修改时间")
private String modifytime;
/**
* 修改用户id
*/
@Excel(name = "修改用户id", width = 15)
@ApiModelProperty(value = "修改用户id")
private Integer modifyuserid;
/**
* 占用存储大小
*/
@Excel(name = "占用存储大小", width = 15)
@ApiModelProperty(value = "占用存储大小")
private Long storageSize;
/**
* 总存储大小
*/
@Excel(name = "总存储大小", width = 15)
@ApiModelProperty(value = "总存储大小")
private Long totalStorageSize;
/**
* userid
*/
@Excel(name = "userid", width = 15)
@ApiModelProperty(value = "userid")
private String userId;
}

View File

@ -0,0 +1,55 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import java.io.Serializable;
/**
* @Description: 文件
* @author pengj
* @date 2023-05-10
* @version V1.0
*/
@Data
@TableName("sysparam")
@ApiModel(value = "SysParam实体类", description = "SysParam")
public class SysParam implements Serializable {
private static final long serialVersionUID = 1L;
/**
* sysparamid
*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "sysparamid")
private Integer sysParamId;
/**
* groupname
*/
@Excel(name = "groupname", width = 15)
@ApiModelProperty(value = "groupname")
private String groupName;
/**
* sysparamdesc
*/
@Excel(name = "sysparamdesc", width = 15)
@ApiModelProperty(value = "sysparamdesc")
private String sysParamDesc;
/**
* sysparamkey
*/
@Excel(name = "sysparamkey", width = 15)
@ApiModelProperty(value = "sysparamkey")
private String sysParamKey;
/**
* sysparamvalue
*/
@Excel(name = "sysparamvalue", width = 15)
@ApiModelProperty(value = "sysparamvalue")
private String sysParamValue;
}

View File

@ -0,0 +1,73 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import java.io.Serializable;
/**
* @Description: 文件
* @author pengj
* @date 2023-05-10
* @version V1.0
*/
@Data
@TableName("uploadtask")
@ApiModel(value = "UploadTask实体类", description = "UploadTask")
public class UploadTask implements Serializable {
private static final long serialVersionUID = 1L;
/**
* uploadtaskid
*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "uploadtaskid")
private Integer uploadTaskId;
/**
* 扩展名
*/
@Excel(name = "扩展名", width = 15)
@ApiModelProperty(value = "扩展名")
private String extendName;
/**
* 文件名称
*/
@Excel(name = "文件名称", width = 15)
@ApiModelProperty(value = "文件名称")
private String fileName;
/**
* 文件路径
*/
@Excel(name = "文件路径", width = 15)
@ApiModelProperty(value = "文件路径")
private String filePath;
/**
* md5唯一标识
*/
@Excel(name = "md5唯一标识", width = 15)
@ApiModelProperty(value = "md5唯一标识")
private String identifier;
/**
* 上传状态(1-成功,0-失败或未完成)
*/
@Excel(name = "上传状态(1-成功,0-失败或未完成)", width = 15)
@ApiModelProperty(value = "上传状态(1-成功,0-失败或未完成)")
private Integer uploadStatus;
/**
* 上传时间
*/
@Excel(name = "上传时间", width = 15)
@ApiModelProperty(value = "上传时间")
private String uploadTime;
/**
* 用户id
*/
@Excel(name = "用户id", width = 15)
@ApiModelProperty(value = "用户id")
private String userId;
}

View File

@ -0,0 +1,79 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import java.io.Serializable;
/**
* @Description: 文件
* @author pengj
* @date 2023-05-10
* @version V1.0
*/
@Data
@TableName("uploadtaskdetail")
@ApiModel(value = "UploadTaskDetail实体类", description = "UploadTaskDetail")
public class UploadTaskDetail implements Serializable {
private static final long serialVersionUID = 1L;
/**
* uploadtaskdetailid
*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "uploadtaskdetailid")
private Integer uploadtaskdetailid;
/**
* 当前分片数
*/
@Excel(name = "当前分片数", width = 15)
@ApiModelProperty(value = "当前分片数")
private Integer chunkNumber;
/**
* 当前分片大小
*/
@Excel(name = "当前分片大小", width = 15)
@ApiModelProperty(value = "当前分片大小")
private Integer chunkSize;
/**
* 文件路径
*/
@Excel(name = "文件路径", width = 15)
@ApiModelProperty(value = "文件路径")
private String filePath;
/**
* 文件名称
*/
@Excel(name = "文件名称", width = 15)
@ApiModelProperty(value = "文件名称")
private String filename;
/**
* 文件md5唯一标识
*/
@Excel(name = "文件md5唯一标识", width = 15)
@ApiModelProperty(value = "文件md5唯一标识")
private String identifier;
/**
* 文件相对路径
*/
@Excel(name = "文件相对路径", width = 15)
@ApiModelProperty(value = "文件相对路径")
private String relativePath;
/**
* 文件总分片数
*/
@Excel(name = "文件总分片数", width = 15)
@ApiModelProperty(value = "文件总分片数")
private Integer totalChunks;
/**
* 文件总大小
*/
@Excel(name = "文件总大小", width = 15)
@ApiModelProperty(value = "文件总大小")
private Integer totalSize;
}

View File

@ -0,0 +1,145 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.domain;
import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.qiwenshare.common.util.DateUtil;
import com.zhgd.xmgl.modules.basicdata.qiwen.io.QiwenFile;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import java.io.Serializable;
/**
* @Description: 文件
* @author pengj
* @date 2023-05-10
* @version V1.0
*/
@Data
@TableName("user_file")
@ApiModel(value = "UserFile实体类", description = "UserFile")
public class UserFile implements Serializable {
private static final long serialVersionUID = 1L;
/**
* userfileid
*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "userfileid")
private String userFileId;
/**
* 创建时间
*/
@Excel(name = "创建时间", width = 15)
@ApiModelProperty(value = "创建时间")
private String createTime;
/**
* 创建用户id
*/
@Excel(name = "创建用户id", width = 15)
@ApiModelProperty(value = "创建用户id")
private String createUserId;
/**
* 删除批次号
*/
@Excel(name = "删除批次号", width = 15)
@ApiModelProperty(value = "删除批次号")
private String deleteBatchNum;
/**
* 删除标识(0-未删除1-已删除)
*/
@Excel(name = "删除标识(0-未删除1-已删除)", width = 15)
@ApiModelProperty(value = "删除标识(0-未删除1-已删除)")
private Integer deleteFlag;
/**
* 删除时间
*/
@Excel(name = "删除时间", width = 15)
@ApiModelProperty(value = "删除时间")
private String deleteTime;
/**
* 扩展名
*/
@Excel(name = "扩展名", width = 15)
@ApiModelProperty(value = "扩展名")
private String extendName;
/**
* 文件id
*/
@Excel(name = "文件id", width = 15)
@ApiModelProperty(value = "文件id")
private String fileId;
/**
* 文件名
*/
@Excel(name = "文件名", width = 15)
@ApiModelProperty(value = "文件名")
private String fileName;
/**
* 文件路径
*/
@Excel(name = "文件路径", width = 15)
@ApiModelProperty(value = "文件路径")
private String filePath;
/**
* 是否是目录(0-,1-)
*/
@Excel(name = "是否是目录(0-否,1-是)", width = 15)
@ApiModelProperty(value = "是否是目录(0-否,1-是)")
private Integer isDir;
/**
* 修改时间
*/
@Excel(name = "修改时间", width = 15)
@ApiModelProperty(value = "修改时间")
private String modifyTime;
/**
* 修改用户id
*/
@Excel(name = "修改用户id", width = 15)
@ApiModelProperty(value = "修改用户id")
private String modifyUserId;
/**
* 修改时间
*/
@Excel(name = "修改时间", width = 15)
@ApiModelProperty(value = "修改时间")
private String uploadTime;
/**
* 用户id
*/
@Excel(name = "用户id", width = 15)
@ApiModelProperty(value = "用户id")
private String userId;
public UserFile() {
}
public UserFile(QiwenFile qiwenFile, String userId, String fileId) {
this.userFileId = IdUtil.getSnowflakeNextIdStr();
this.userId = userId;
this.fileId = fileId;
this.filePath = qiwenFile.getParent();
this.fileName = qiwenFile.getNameNotExtend();
this.extendName = qiwenFile.getExtendName();
this.isDir = qiwenFile.isDirectory() ? 1 : 0;
String currentTime = DateUtil.getCurrentTime();
this.setUploadTime(currentTime);
this.setCreateUserId(userId);
this.setCreateTime(currentTime);
this.deleteFlag = 0;
}
public boolean isFile() {
return this.isDir == 0;
}
public boolean isDirectory() {
return this.isDir == 1;
}
}

View File

@ -0,0 +1,20 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.dto.commonfile;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author MAC
* @version 1.0
* @description: TODO
* @date 2022/1/12 15:03
*/
@Data
@ApiModel(description = "共享文件DTO")
public class CommonFileDTO {
@ApiModelProperty(name = "用户文件id")
private String userFileId;
@ApiModelProperty(name = "共享用户id集合")
private String commonUserList;
}

View File

@ -0,0 +1,16 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.dto.file;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
@Data
@ApiModel(description = "批量删除文件DTO")
public class BatchDeleteFileDTO {
@ApiModelProperty(value="文件Id集合", required = true)
@NotEmpty
private String userFileIds;
}

View File

@ -0,0 +1,16 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.dto.file;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(name = "批量下载文件DTO",required = true)
public class BatchDownloadFileDTO {
@Schema(description="文件集合", required = true)
private String userFileIds;
@Schema(description="批次号")
private String shareBatchNum;
@Schema(description="提取码")
private String extractionCode;
}

View File

@ -0,0 +1,15 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.dto.file;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(name = "批量移动文件DTO",required = true)
public class BatchMoveFileDTO {
@Schema(description="用户文件Id集合", required = true)
private String userFileIds;
@Schema(description="目的文件路径", required = true)
private String filePath;
}

View File

@ -0,0 +1,15 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.dto.file;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(name = "复制文件DTO",required = true)
public class CopyFileDTO {
@Schema(description = "用户文件id集合", required = true)
private String userFileIds;
@Schema(description = "文件路径", required = true)
private String filePath;
}

View File

@ -0,0 +1,24 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.dto.file;
import com.qiwenshare.common.constant.RegexConstant;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
@Data
public class CreateFileDTO {
@Schema(description = "文件路径", required = true)
private String filePath;
@Schema(description = "文件名", required = true)
@NotBlank(message = "文件名不能为空")
@Pattern(regexp = RegexConstant.FILE_NAME_REGEX, message = "文件名不合法!", flags = {Pattern.Flag.CASE_INSENSITIVE})
private String fileName;
@Schema(description = "扩展名", required = true)
private String extendName;
}

View File

@ -0,0 +1,20 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.dto.file;
import com.qiwenshare.common.constant.RegexConstant;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
@Data
@Schema(name = "创建文件DTO",required = true)
public class CreateFoldDTO {
@Schema(description="文件名", required=true)
@NotBlank(message = "文件名不能为空")
@Pattern(regexp = RegexConstant.FILE_NAME_REGEX, message = "文件名不合法!")
private String fileName;
@Schema(description="文件路径", required=true)
private String filePath;
}

View File

@ -0,0 +1,10 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.dto.file;
import lombok.Data;
@Data
public class CreateOfficeFileDTO {
private String filePath;
private String fileName;
private String extendName;
}

View File

@ -0,0 +1,13 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.dto.file;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(name = "删除文件DTO",required = true)
public class DeleteFileDTO {
@Schema(description = "用户文件id", required = true)
private String userFileId;
}

View File

@ -0,0 +1,12 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.dto.file;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(name = "删除回收文件DTO",required = true)
public class DeleteRecoveryFileDTO {
@Schema(description = "用户文件id", required = true)
private String userFileId;
}

View File

@ -0,0 +1,14 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.dto.file;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(name = "下载文件DTO",required = true)
public class DownloadFileDTO {
private String userFileId;
@Schema(description="批次号")
private String shareBatchNum;
@Schema(description="提取码")
private String extractionCode;
}

View File

@ -0,0 +1,12 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.dto.file;
import lombok.Data;
@Data
public class EditOfficeFileDTO {
private String userFileId;
// private String previewUrl;
// private String filePath;
// private String fileName;
// private String extendName;
}

View File

@ -0,0 +1,15 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.dto.file;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(name = "文件列表DTO",required = true)
public class FileListDTO {
@Schema(description = "文件路径", required = true)
private String filePath;
@Schema(description = "当前页码", required = true)
private Long currentPage;
@Schema(description = "一页显示数量", required = true)
private Long pageCount;
}

View File

@ -0,0 +1,22 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.dto.file;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(name = "移动文件DTO",required = true)
public class MoveFileDTO {
@Schema(description = "用户文件id", required = true)
private String userFileId;
@Schema(description = "文件路径", required = true)
private String filePath;
//
// @Schema(description = "文件名", required = true)
// private String fileName;
//
// @Schema(description = "旧文件名", required = true)
// private String oldFilePath;
// @Schema(description = "扩展名", required = true)
// private String extendName;
}

View File

@ -0,0 +1,14 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.dto.file;
import lombok.Data;
@Data
public class OnlyofficeDTO {
private String fileId;
private String fileName;
private String fileUrl;
private String extendName;
}

View File

@ -0,0 +1,18 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.dto.file;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(name = "预览文件DTO",required = true)
public class PreviewDTO {
private String userFileId;
@Schema(description="批次号")
private String shareBatchNum;
@Schema(description="提取码")
private String extractionCode;
private String isMin;
private Integer platform;
private String url;
private String token;
}

View File

@ -0,0 +1,12 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.dto.file;
import lombok.Data;
@Data
public class PreviewOfficeFileDTO {
private String userFileId;
private String previewUrl;
// private String filePath;
// private String fileName;
// private String extendName;
}

View File

@ -0,0 +1,14 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.dto.file;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(name = "重命名文件DTO",required = true)
public class RenameFileDTO {
@Schema(description = "用户文件id", required = true)
private String userFileId;
@Schema(description = "文件名", required = true)
private String fileName;
}

View File

@ -0,0 +1,14 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.dto.file;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
public class SearchFileDTO {
@Schema(description="文件名", required=true)
private String fileName;
@Schema(description="当前页", required=true)
private long currentPage;
@Schema(description="每页数量", required=true)
private long pageCount;
}

View File

@ -0,0 +1,17 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.dto.file;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(name = "解压缩文件DTO",required = true)
public class UnzipFileDTO {
@Schema(description = "文件url", required = true)
private String userFileId;
@Schema(description = "解压模式 0-解压到当前文件夹, 1-自动创建该文件名目录,并解压到目录里, 2-手动选择解压目录", required = true)
private int unzipMode;
@Schema(description = "解压目的文件目录,仅当 unzipMode 为 2 时必传")
private String filePath;
}

View File

@ -0,0 +1,19 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.dto.file;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
* @author 马超
* @version 1.0
* @description: TODO
* @date 2021/12/8 19:23
*/
@Data
@Schema(name = "修改文件DTO",required = true)
public class UpdateFileDTO {
@Schema(description = "用户文件id")
private String userFileId;
@Schema(description = "文件内容")
private String fileContent;
}

View File

@ -0,0 +1,33 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.dto.file;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(name = "上传文件DTO",required = true)
public class UploadFileDTO {
@Schema(description = "文件路径")
private String filePath;
@Schema(description = "文件名")
private String filename;
@Schema(description = "切片数量")
private int chunkNumber;
@Schema(description = "切片大小")
private long chunkSize;
@Schema(description = "相对路径")
private String relativePath;
@Schema(description = "所有切片")
private int totalChunks;
@Schema(description = "总大小")
private long totalSize;
@Schema(description = "当前切片大小")
private long currentChunkSize;
@Schema(description = "md5码")
private String identifier;
}

View File

@ -0,0 +1,28 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.dto.notice;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(name = "公告列表DTO")
public class NoticeListDTO {
@Schema(description = "当前页从1开始", required = true, example = "1")
private int page;
@Schema(description = "页大小", required = true, example = "10")
private int pageSize;
@Schema(description = "标题")
private String title;
@Schema(description = "平台")
private Integer platform;
@Schema(description = "发布者")
private Long publisher;
@Schema(description = "开始发布时间")
private String beginTime;
@Schema(description = "开始发布时间")
private String endTime;
}

View File

@ -0,0 +1,13 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.dto.param;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(name = "获取组参数列表DTO")
public class QueryGroupParamDTO {
@Schema(description = "组名")
private String groupName;
}

View File

@ -0,0 +1,11 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.dto.recoveryfile;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(name = "批量删除回收文件DTO",required = true)
public class BatchDeleteRecoveryFileDTO {
@Schema(description="用户文件Id集合", required = true)
private String userFileIds;
}

View File

@ -0,0 +1,13 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.dto.recoveryfile;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(name = "回收文件列表DTO",required = true)
public class RecoveryFileListDTO {
@Schema(description = "当前页码")
private Long currentPage;
@Schema(description = "一页显示数量")
private Long pageCount;
}

View File

@ -0,0 +1,13 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.dto.recoveryfile;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(name = "回收文件DTO",required = true)
public class RestoreFileDTO {
@Schema(description="删除批次号")
private String deleteBatchNum;
@Schema(description="文件路径")
private String filePath;
}

View File

@ -0,0 +1,12 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.dto.sharefile;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(name = "校验过期时间DTO",required = true)
public class CheckEndTimeDTO {
@Schema(description="批次号")
private String shareBatchNum;
}

View File

@ -0,0 +1,17 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.dto.sharefile;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(name = "校验提取码DTO",required = true)
public class CheckExtractionCodeDTO {
@Schema(description="批次号")
private String shareBatchNum;
@Schema(description="提取码")
private String extractionCode;
}

View File

@ -0,0 +1,13 @@
package com.zhgd.xmgl.modules.basicdata.qiwen.dto.sharefile;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(name = "保存分享文件DTO",required = true)
public class SaveShareFileDTO {
@Schema(description="文件集合", example = "[{\"userFileId\":12},{\"userFileId\":13}]")
private String files;
@Schema(description = "文件路径")
private String filePath;
}

Some files were not shown because too many files have changed in this diff Show More