!143 代码合并

Merge pull request !143 from MAC/develop
This commit is contained in:
MAC 2023-05-01 15:01:10 +00:00 committed by Gitee
commit 8338ef32de
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 24 additions and 15 deletions

View File

@ -54,17 +54,18 @@ public class ShareController {
@PostMapping(value = "/sharefile")
@MyLog(operation = "分享文件", module = CURRENT_MODULE)
@ResponseBody
public RestResult<ShareFileVO> shareFile( @RequestBody ShareFileDTO shareSecretDTO) {
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();
BeanUtil.copyProperties(shareSecretDTO, share);
share.setShareId(IdUtil.getSnowflakeNextIdStr());
BeanUtil.copyProperties(shareFileDTO, share);
share.setShareTime(DateUtil.getCurrentTime());
share.setUserId(sessionUserBean.getUserId());
share.setShareStatus(0);
if (shareSecretDTO.getShareType() == 1) {
if (shareFileDTO.getShareType() == 1) {
String extractionCode = RandomUtil.randomNumbers(6);
share.setExtractionCode(extractionCode);
shareSecretVO.setExtractionCode(share.getExtractionCode());
@ -73,10 +74,11 @@ public class ShareController {
share.setShareBatchNum(uuid);
shareService.save(share);
List<ShareFile> fileList = JSON.parseArray(shareSecretDTO.getFiles(), ShareFile.class);
List<ShareFile> saveFileList = new ArrayList<>();
for (ShareFile shareFile : fileList) {
UserFile userFile = userFileService.getById(shareFile.getUserFileId());
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("您只能分享自己的文件");
}
@ -85,12 +87,16 @@ public class ShareController {
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);

View File

@ -14,9 +14,9 @@ import java.util.UUID;
@TableName("share")
public class Share {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@GeneratedValue(strategy = GenerationType.AUTO)
@TableId(type = IdType.AUTO)
private Long shareId;
private String shareId;
@Column(columnDefinition="varchar(20) comment '用户id'")
private String userId;
@Column(columnDefinition="varchar(30) comment '分享时间'")

View File

@ -13,9 +13,9 @@ import javax.persistence.*;
@TableName("sharefile")
public class ShareFile {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@GeneratedValue(strategy = GenerationType.AUTO)
@TableId(type = IdType.AUTO)
private Long shareFileId;
private String shareFileId;
@Column(columnDefinition="varchar(50) comment '分享批次号'")
private String shareBatchNum;

View File

@ -3,11 +3,14 @@ package com.qiwenshare.file.dto.sharefile;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
@Data
@Schema(name = "分享文件DTO",required = true)
public class ShareFileDTO {
@Schema(description="文件集合")
private String files;
@Schema(description="文件Id集合", required = true)
@NotEmpty
private String userFileIds;
@Schema(description = "过期日期", example="2020-05-23 22:10:33")
private String endTime;
@Schema(description = "分享类型", example="0公共分享1私密分享2好友分享")

View File

@ -8,15 +8,15 @@ import javax.persistence.Column;
@Schema(description="分享列表VO")
@Data
public class ShareListVO {
private Long shareId;
private Long userId;
private String shareId;
private String userId;
private String shareTime;
private String endTime;
private String extractionCode;
private String shareBatchNum;
private Integer shareType;//0公共1私密2好友
private Integer shareStatus;//0正常1已失效2已撤销
private Long shareFileId;
private String shareFileId;
private String userFileId;
private String shareFilePath;
private String fileId;