commit
8338ef32de
@ -54,17 +54,18 @@ public class ShareController {
|
|||||||
@PostMapping(value = "/sharefile")
|
@PostMapping(value = "/sharefile")
|
||||||
@MyLog(operation = "分享文件", module = CURRENT_MODULE)
|
@MyLog(operation = "分享文件", module = CURRENT_MODULE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public RestResult<ShareFileVO> shareFile( @RequestBody ShareFileDTO shareSecretDTO) {
|
public RestResult<ShareFileVO> shareFile( @RequestBody ShareFileDTO shareFileDTO) {
|
||||||
ShareFileVO shareSecretVO = new ShareFileVO();
|
ShareFileVO shareSecretVO = new ShareFileVO();
|
||||||
JwtUser sessionUserBean = SessionUtil.getSession();
|
JwtUser sessionUserBean = SessionUtil.getSession();
|
||||||
|
|
||||||
String uuid = UUID.randomUUID().toString().replace("-", "");
|
String uuid = UUID.randomUUID().toString().replace("-", "");
|
||||||
Share share = new Share();
|
Share share = new Share();
|
||||||
BeanUtil.copyProperties(shareSecretDTO, share);
|
share.setShareId(IdUtil.getSnowflakeNextIdStr());
|
||||||
|
BeanUtil.copyProperties(shareFileDTO, share);
|
||||||
share.setShareTime(DateUtil.getCurrentTime());
|
share.setShareTime(DateUtil.getCurrentTime());
|
||||||
share.setUserId(sessionUserBean.getUserId());
|
share.setUserId(sessionUserBean.getUserId());
|
||||||
share.setShareStatus(0);
|
share.setShareStatus(0);
|
||||||
if (shareSecretDTO.getShareType() == 1) {
|
if (shareFileDTO.getShareType() == 1) {
|
||||||
String extractionCode = RandomUtil.randomNumbers(6);
|
String extractionCode = RandomUtil.randomNumbers(6);
|
||||||
share.setExtractionCode(extractionCode);
|
share.setExtractionCode(extractionCode);
|
||||||
shareSecretVO.setExtractionCode(share.getExtractionCode());
|
shareSecretVO.setExtractionCode(share.getExtractionCode());
|
||||||
@ -73,10 +74,11 @@ public class ShareController {
|
|||||||
share.setShareBatchNum(uuid);
|
share.setShareBatchNum(uuid);
|
||||||
shareService.save(share);
|
shareService.save(share);
|
||||||
|
|
||||||
List<ShareFile> fileList = JSON.parseArray(shareSecretDTO.getFiles(), ShareFile.class);
|
|
||||||
List<ShareFile> saveFileList = new ArrayList<>();
|
List<ShareFile> saveFileList = new ArrayList<>();
|
||||||
for (ShareFile shareFile : fileList) {
|
String userFileIds = shareFileDTO.getUserFileIds();
|
||||||
UserFile userFile = userFileService.getById(shareFile.getUserFileId());
|
String[] userFileIdList = userFileIds.split(",");
|
||||||
|
for (String userFileId : userFileIdList) {
|
||||||
|
UserFile userFile = userFileService.getById(userFileId);
|
||||||
if (userFile.getUserId().compareTo(sessionUserBean.getUserId()) != 0) {
|
if (userFile.getUserId().compareTo(sessionUserBean.getUserId()) != 0) {
|
||||||
return RestResult.fail().message("您只能分享自己的文件");
|
return RestResult.fail().message("您只能分享自己的文件");
|
||||||
}
|
}
|
||||||
@ -85,12 +87,16 @@ public class ShareController {
|
|||||||
List<UserFile> userfileList = userFileService.selectUserFileByLikeRightFilePath(qiwenFile.getPath(), sessionUserBean.getUserId());
|
List<UserFile> userfileList = userFileService.selectUserFileByLikeRightFilePath(qiwenFile.getPath(), sessionUserBean.getUserId());
|
||||||
for (UserFile userFile1 : userfileList) {
|
for (UserFile userFile1 : userfileList) {
|
||||||
ShareFile shareFile1 = new ShareFile();
|
ShareFile shareFile1 = new ShareFile();
|
||||||
|
shareFile1.setShareFileId(IdUtil.getSnowflakeNextIdStr());
|
||||||
shareFile1.setUserFileId(userFile1.getUserFileId());
|
shareFile1.setUserFileId(userFile1.getUserFileId());
|
||||||
shareFile1.setShareBatchNum(uuid);
|
shareFile1.setShareBatchNum(uuid);
|
||||||
shareFile1.setShareFilePath(userFile1.getFilePath().replaceFirst(userFile.getFilePath().equals("/") ? "" : userFile.getFilePath(), ""));
|
shareFile1.setShareFilePath(userFile1.getFilePath().replaceFirst(userFile.getFilePath().equals("/") ? "" : userFile.getFilePath(), ""));
|
||||||
saveFileList.add(shareFile1);
|
saveFileList.add(shareFile1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ShareFile shareFile = new ShareFile();
|
||||||
|
shareFile.setShareFileId(IdUtil.getSnowflakeNextIdStr());
|
||||||
|
shareFile.setUserFileId(userFileId);
|
||||||
shareFile.setShareFilePath("/");
|
shareFile.setShareFilePath("/");
|
||||||
shareFile.setShareBatchNum(uuid);
|
shareFile.setShareBatchNum(uuid);
|
||||||
saveFileList.add(shareFile);
|
saveFileList.add(shareFile);
|
||||||
|
@ -14,9 +14,9 @@ import java.util.UUID;
|
|||||||
@TableName("share")
|
@TableName("share")
|
||||||
public class Share {
|
public class Share {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
@TableId(type = IdType.AUTO)
|
@TableId(type = IdType.AUTO)
|
||||||
private Long shareId;
|
private String shareId;
|
||||||
@Column(columnDefinition="varchar(20) comment '用户id'")
|
@Column(columnDefinition="varchar(20) comment '用户id'")
|
||||||
private String userId;
|
private String userId;
|
||||||
@Column(columnDefinition="varchar(30) comment '分享时间'")
|
@Column(columnDefinition="varchar(30) comment '分享时间'")
|
||||||
|
@ -13,9 +13,9 @@ import javax.persistence.*;
|
|||||||
@TableName("sharefile")
|
@TableName("sharefile")
|
||||||
public class ShareFile {
|
public class ShareFile {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
@TableId(type = IdType.AUTO)
|
@TableId(type = IdType.AUTO)
|
||||||
private Long shareFileId;
|
private String shareFileId;
|
||||||
|
|
||||||
@Column(columnDefinition="varchar(50) comment '分享批次号'")
|
@Column(columnDefinition="varchar(50) comment '分享批次号'")
|
||||||
private String shareBatchNum;
|
private String shareBatchNum;
|
||||||
|
@ -3,11 +3,14 @@ package com.qiwenshare.file.dto.sharefile;
|
|||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Schema(name = "分享文件DTO",required = true)
|
@Schema(name = "分享文件DTO",required = true)
|
||||||
public class ShareFileDTO {
|
public class ShareFileDTO {
|
||||||
@Schema(description="文件集合")
|
@Schema(description="文件Id集合", required = true)
|
||||||
private String files;
|
@NotEmpty
|
||||||
|
private String userFileIds;
|
||||||
@Schema(description = "过期日期", example="2020-05-23 22:10:33")
|
@Schema(description = "过期日期", example="2020-05-23 22:10:33")
|
||||||
private String endTime;
|
private String endTime;
|
||||||
@Schema(description = "分享类型", example="0公共分享,1私密分享,2好友分享")
|
@Schema(description = "分享类型", example="0公共分享,1私密分享,2好友分享")
|
||||||
|
@ -8,15 +8,15 @@ import javax.persistence.Column;
|
|||||||
@Schema(description="分享列表VO")
|
@Schema(description="分享列表VO")
|
||||||
@Data
|
@Data
|
||||||
public class ShareListVO {
|
public class ShareListVO {
|
||||||
private Long shareId;
|
private String shareId;
|
||||||
private Long userId;
|
private String userId;
|
||||||
private String shareTime;
|
private String shareTime;
|
||||||
private String endTime;
|
private String endTime;
|
||||||
private String extractionCode;
|
private String extractionCode;
|
||||||
private String shareBatchNum;
|
private String shareBatchNum;
|
||||||
private Integer shareType;//0公共,1私密,2好友
|
private Integer shareType;//0公共,1私密,2好友
|
||||||
private Integer shareStatus;//0正常,1已失效,2已撤销
|
private Integer shareStatus;//0正常,1已失效,2已撤销
|
||||||
private Long shareFileId;
|
private String shareFileId;
|
||||||
private String userFileId;
|
private String userFileId;
|
||||||
private String shareFilePath;
|
private String shareFilePath;
|
||||||
private String fileId;
|
private String fileId;
|
||||||
|
Loading…
Reference in New Issue
Block a user