完善分享功能,缺陷修复
This commit is contained in:
parent
1857c5132f
commit
50c1ba4125
@ -3,7 +3,11 @@ package com.qiwenshare.file.api;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.qiwenshare.file.domain.Share;
|
||||
import com.qiwenshare.file.domain.ShareFile;
|
||||
import com.qiwenshare.file.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);
|
||||
}
|
||||
|
@ -4,11 +4,14 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.qiwenshare.file.domain.RecoveryFile;
|
||||
import com.qiwenshare.file.domain.Share;
|
||||
import com.qiwenshare.file.domain.ShareFile;
|
||||
import com.qiwenshare.file.dto.sharefile.ShareListDTO;
|
||||
import com.qiwenshare.file.vo.share.ShareFileListVO;
|
||||
import com.qiwenshare.file.vo.share.ShareListVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IShareService extends IService<Share> {
|
||||
void batchInsertShareFile(List<ShareFile> shareFiles);
|
||||
List<ShareFileListVO> selectShareFileList(String shareBatchNum, String filePath);
|
||||
List<ShareListVO> selectShareList(ShareListDTO shareListDTO, Long userId);
|
||||
int selectShareListTotalCount(ShareListDTO shareListDTO, Long userId);
|
||||
}
|
||||
|
@ -22,5 +22,6 @@ public interface IUserFileService extends IService<UserFile> {
|
||||
List<UserFile> selectFileListLikeRightFilePath(String filePath, long userId);
|
||||
List<UserFile> selectFilePathTreeByUserId(Long userId);
|
||||
void deleteUserFile(Long userFileId, Long sessionUserId);
|
||||
UserFile repeatUserFileDeal(UserFile userFile);
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.qiwenshare.common.exception.NotLoginException;
|
||||
import com.qiwenshare.common.util.DateUtil;
|
||||
import com.qiwenshare.common.result.RestResult;
|
||||
import com.qiwenshare.file.anno.MyLog;
|
||||
@ -15,18 +16,17 @@ import com.qiwenshare.file.domain.UserFile;
|
||||
import com.qiwenshare.file.dto.sharefile.*;
|
||||
import com.qiwenshare.file.vo.share.ShareFileListVO;
|
||||
import com.qiwenshare.file.vo.share.ShareFileVO;
|
||||
import com.qiwenshare.file.vo.share.ShareListVO;
|
||||
import com.qiwenshare.file.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;
|
||||
import java.util.*;
|
||||
|
||||
@Tag(name = "share", description = "该接口为文件分享接口")
|
||||
@RestController
|
||||
@ -38,6 +38,8 @@ public class ShareController {
|
||||
@Resource
|
||||
IUserService userService;
|
||||
@Resource
|
||||
IShareFileService shareFileService;
|
||||
@Resource
|
||||
IShareService shareService;
|
||||
@Resource
|
||||
IFileService fileService;
|
||||
@ -51,6 +53,9 @@ public class ShareController {
|
||||
public RestResult<ShareFileVO> shareFile( @RequestBody ShareFileDTO shareSecretDTO, @RequestHeader("token") String token) {
|
||||
ShareFileVO shareSecretVO = new ShareFileVO();
|
||||
UserBean sessionUserBean = userService.getUserBeanByToken(token);
|
||||
if (sessionUserBean == null) {
|
||||
throw new NotLoginException();
|
||||
}
|
||||
|
||||
String uuid = UUID.randomUUID().toString().replace("-", "");
|
||||
Share share = new Share();
|
||||
@ -71,7 +76,7 @@ public class ShareController {
|
||||
List<ShareFile> saveFileList = new ArrayList<>();
|
||||
for (ShareFile shareFile : fileList) {
|
||||
UserFile userFile = userFileService.getById(shareFile.getUserFileId());
|
||||
if (userFile.getUserId() != sessionUserBean.getUserId()) {
|
||||
if (userFile.getUserId().compareTo(sessionUserBean.getUserId()) != 0) {
|
||||
return RestResult.fail().message("您只能分享自己的文件");
|
||||
}
|
||||
if (userFile.getIsDir() == 1) {
|
||||
@ -90,7 +95,7 @@ public class ShareController {
|
||||
|
||||
|
||||
}
|
||||
shareService.batchInsertShareFile(saveFileList);
|
||||
shareFileService.batchInsertShareFile(saveFileList);
|
||||
shareSecretVO.setShareBatchNum(uuid);
|
||||
|
||||
return RestResult.success().data(shareSecretVO);
|
||||
@ -99,12 +104,14 @@ public class ShareController {
|
||||
@Operation(summary = "保存分享文件", description = "用来将别人分享的文件保存到自己的网盘中", tags = {"share"})
|
||||
@PostMapping(value = "/savesharefile")
|
||||
@MyLog(operation = "保存分享文件", module = CURRENT_MODULE)
|
||||
@Transactional(rollbackFor=Exception.class)
|
||||
@ResponseBody
|
||||
public RestResult saveShareFile(@RequestBody SaveShareFileDTO saveShareFileDTO, @RequestHeader("token") String token) {
|
||||
|
||||
//{"filePath":"/mac/","files":"[{\"userFileId\":555},{\"userFileId\":266}]"}
|
||||
UserBean sessionUserBean = userService.getUserBeanByToken(token);
|
||||
List<ShareFile> fileList = JSON.parseArray(saveShareFileDTO.getFiles(), ShareFile.class);
|
||||
String savefilePath = saveShareFileDTO.getFilePath();
|
||||
Long userId = sessionUserBean.getUserId();
|
||||
|
||||
List<UserFile> saveUserFileList = new ArrayList<>();
|
||||
for (ShareFile shareFile : fileList) {
|
||||
@ -112,27 +119,27 @@ public class ShareController {
|
||||
if (userFile.getIsDir() == 1) {
|
||||
List<UserFile> userfileList = userFileService.selectFileListLikeRightFilePath(userFile.getFilePath() + userFile.getFileName(), userFile.getUserId());
|
||||
log.info("查询文件列表:" + JSON.toJSONString(userfileList));
|
||||
for (UserFile userFile1 : userfileList) {
|
||||
userFile.setUserFileId(null);
|
||||
userFile1.setUserId(sessionUserBean.getUserId());
|
||||
userFile1.setFilePath(userFile1.getFilePath().replaceFirst(userFile.getFilePath(), saveShareFileDTO.getFilePath()));
|
||||
saveUserFileList.add(userFile1);
|
||||
log.info("当前文件:" + JSON.toJSONString(userFile1));
|
||||
if (userFile1.getIsDir() == 0) {
|
||||
fileService.increaseFilePointCount(userFile1.getFileId());
|
||||
String filePath = userFile.getFilePath();
|
||||
userfileList.forEach(p->{
|
||||
p.setUserFileId(null);
|
||||
p.setUserId(userId);
|
||||
p.setFilePath(p.getFilePath().replaceFirst(filePath, savefilePath));
|
||||
p = userFileService.repeatUserFileDeal(p);
|
||||
saveUserFileList.add(p);
|
||||
log.info("当前文件:" + JSON.toJSONString(p));
|
||||
if (p.getIsDir() == 0) {
|
||||
fileService.increaseFilePointCount(p.getFileId());
|
||||
}
|
||||
}
|
||||
userFile.setUserFileId(null);
|
||||
userFile.setUserId(sessionUserBean.getUserId());
|
||||
userFile.setFilePath(saveShareFileDTO.getFilePath());
|
||||
saveUserFileList.add(userFile);
|
||||
});
|
||||
} else {
|
||||
userFile.setUserFileId(null);
|
||||
userFile.setUserId(sessionUserBean.getUserId());
|
||||
userFile.setFilePath(saveShareFileDTO.getFilePath());
|
||||
saveUserFileList.add(userFile);
|
||||
fileService.increaseFilePointCount(userFile.getFileId());
|
||||
}
|
||||
|
||||
userFile.setUserFileId(null);
|
||||
userFile.setUserId(userId);
|
||||
userFile.setFilePath(savefilePath);
|
||||
userFile = userFileService.repeatUserFileDeal(userFile);
|
||||
saveUserFileList.add(userFile);
|
||||
}
|
||||
log.info("----------" + JSON.toJSONString(saveUserFileList));
|
||||
userFileService.saveBatch(saveUserFileList);
|
||||
@ -140,13 +147,33 @@ public class ShareController {
|
||||
return RestResult.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "分享列表", description = "分享列表", tags = {"share"})
|
||||
@Operation(summary = "查看已分享列表", description = "查看已分享列表", tags = {"share"})
|
||||
@GetMapping(value = "/shareList")
|
||||
@ResponseBody
|
||||
public RestResult shareList(ShareListDTO shareListDTO, @RequestHeader("token") String token) {
|
||||
UserBean sessionUserBean = userService.getUserBeanByToken(token);
|
||||
if (sessionUserBean == null) {
|
||||
throw new NotLoginException();
|
||||
}
|
||||
List<ShareListVO> shareList = shareService.selectShareList(shareListDTO, sessionUserBean.getUserId());
|
||||
LambdaQueryWrapper<ShareFile> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
int total = shareService.selectShareListTotalCount(shareListDTO, sessionUserBean.getUserId());
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("total", total);
|
||||
map.put("list", shareList);
|
||||
return RestResult.success().data(map);
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "分享文件列表", description = "分享列表", tags = {"share"})
|
||||
@GetMapping(value = "/sharefileList")
|
||||
@ResponseBody
|
||||
public RestResult<List<ShareFileListVO>> shareFileListBySecret(ShareFileListBySecretDTO shareFileListBySecretDTO) {
|
||||
public RestResult<List<ShareFileListVO>> shareFileList(ShareFileListDTO shareFileListBySecretDTO) {
|
||||
String shareBatchNum = shareFileListBySecretDTO.getShareBatchNum();
|
||||
String shareFilePath = shareFileListBySecretDTO.getShareFilePath();
|
||||
List<ShareFileListVO> list = shareService.selectShareFileList(shareBatchNum, shareFilePath);
|
||||
List<ShareFileListVO> list = shareFileService.selectShareFileList(shareBatchNum, shareFilePath);
|
||||
for (ShareFileListVO shareFileListVO : list) {
|
||||
shareFileListVO.setShareFilePath(shareFilePath);
|
||||
}
|
||||
@ -163,7 +190,6 @@ public class ShareController {
|
||||
ShareTypeVO shareTypeVO = new ShareTypeVO();
|
||||
shareTypeVO.setShareType(share.getShareType());
|
||||
return RestResult.success().data(shareTypeVO);
|
||||
|
||||
}
|
||||
|
||||
@Operation(summary = "校验提取码", description = "校验提取码", tags = {"share"})
|
||||
|
@ -4,8 +4,8 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Schema(name = "分享列表DTO",required = true)
|
||||
public class ShareFileListBySecretDTO {
|
||||
@Schema(name = "分享文件列表DTO",required = true)
|
||||
public class ShareFileListDTO {
|
||||
|
||||
@Schema(description="批次号")
|
||||
private String shareBatchNum;
|
@ -0,0 +1,17 @@
|
||||
package com.qiwenshare.file.dto.sharefile;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Schema(name = "分享列表DTO",required = true)
|
||||
public class ShareListDTO {
|
||||
@Schema(description="分享文件路径")
|
||||
private String shareFilePath;
|
||||
@Schema(description="批次号")
|
||||
private String shareBatchNum;
|
||||
@Schema(description = "当前页码")
|
||||
private Long currentPage;
|
||||
@Schema(description = "一页显示数量")
|
||||
private Long pageCount;
|
||||
}
|
@ -3,6 +3,12 @@ package com.qiwenshare.file.mapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.qiwenshare.file.domain.Share;
|
||||
import com.qiwenshare.file.domain.ShareFile;
|
||||
import com.qiwenshare.file.vo.share.ShareFileListVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ShareFileMapper extends BaseMapper<ShareFile> {
|
||||
void batchInsertShareFile(List<ShareFile> shareFiles);
|
||||
List<ShareFileListVO> selectShareFileList(@Param("shareBatchNum") String shareBatchNum, @Param("shareFilePath") String filePath);
|
||||
}
|
||||
|
@ -5,11 +5,13 @@ import com.qiwenshare.file.domain.FileBean;
|
||||
import com.qiwenshare.file.domain.Share;
|
||||
import com.qiwenshare.file.domain.ShareFile;
|
||||
import com.qiwenshare.file.vo.share.ShareFileListVO;
|
||||
import com.qiwenshare.file.vo.share.ShareListVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ShareMapper extends BaseMapper<Share> {
|
||||
void batchInsertShareFile(List<ShareFile> shareFiles);
|
||||
List<ShareFileListVO> selectShareFileList(@Param("shareBatchNum") String shareBatchNum, @Param("shareFilePath") String filePath);
|
||||
|
||||
List<ShareListVO> selectShareList(String shareFilePath,String shareBatchNum, Long beginCount, Long pageCount, Long userId);
|
||||
int selectShareListTotalCount(String shareFilePath,String shareBatchNum, Long userId);
|
||||
}
|
||||
|
@ -6,11 +6,13 @@ import com.qiwenshare.file.domain.FileBean;
|
||||
import com.qiwenshare.file.mapper.FileMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@Transactional(rollbackFor=Exception.class)
|
||||
public class FileService extends ServiceImpl<FileMapper, FileBean> implements IFileService {
|
||||
|
||||
@Resource
|
||||
|
@ -33,9 +33,11 @@ import com.qiwenshare.file.mapper.StorageMapper;
|
||||
import com.qiwenshare.file.mapper.UserFileMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@Transactional(rollbackFor=Exception.class)
|
||||
public class FiletransferService implements IFiletransferService {
|
||||
|
||||
@Resource
|
||||
|
@ -8,12 +8,14 @@ import com.qiwenshare.file.api.IOperationLogService;
|
||||
import com.qiwenshare.file.domain.OperationLogBean;
|
||||
import com.qiwenshare.file.mapper.OperationLogMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor=Exception.class)
|
||||
public class OperationLogService extends ServiceImpl<OperationLogMapper, OperationLogBean> implements IOperationLogService {
|
||||
|
||||
@Resource
|
||||
|
@ -16,6 +16,7 @@ import com.qiwenshare.file.mapper.UserFileMapper;
|
||||
import com.qiwenshare.file.vo.file.RecoveryFileListVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
@ -24,6 +25,7 @@ import java.util.concurrent.Executors;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@Transactional(rollbackFor=Exception.class)
|
||||
public class RecoveryFileService extends ServiceImpl<RecoveryFileMapper, RecoveryFile> implements IRecoveryFileService {
|
||||
@Resource
|
||||
UserFileMapper userFileMapper;
|
||||
|
@ -1,17 +1,41 @@
|
||||
package com.qiwenshare.file.service;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.qiwenshare.file.api.IShareFileService;
|
||||
import com.qiwenshare.file.api.IShareService;
|
||||
import com.qiwenshare.file.domain.Share;
|
||||
import com.qiwenshare.file.domain.ShareFile;
|
||||
import com.qiwenshare.file.domain.UserFile;
|
||||
import com.qiwenshare.file.mapper.ShareFileMapper;
|
||||
import com.qiwenshare.file.mapper.ShareMapper;
|
||||
import com.qiwenshare.file.mapper.UserFileMapper;
|
||||
import com.qiwenshare.file.vo.share.ShareFileListVO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@Transactional(rollbackFor=Exception.class)
|
||||
public class ShareFileService extends ServiceImpl<ShareFileMapper, ShareFile> implements IShareFileService {
|
||||
@Resource
|
||||
ShareFileMapper shareFileMapper;
|
||||
@Resource
|
||||
UserFileMapper userFileMapper;
|
||||
@Override
|
||||
public void batchInsertShareFile(List<ShareFile> shareFiles) {
|
||||
shareFileMapper.batchInsertShareFile(shareFiles);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ShareFileListVO> selectShareFileList(String shareBatchNum, String filePath) {
|
||||
return shareFileMapper.selectShareFileList(shareBatchNum, filePath);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,27 +5,35 @@ import com.qiwenshare.file.api.IShareService;
|
||||
import com.qiwenshare.file.domain.RecoveryFile;
|
||||
import com.qiwenshare.file.domain.Share;
|
||||
import com.qiwenshare.file.domain.ShareFile;
|
||||
import com.qiwenshare.file.dto.sharefile.ShareListDTO;
|
||||
import com.qiwenshare.file.mapper.RecoveryFileMapper;
|
||||
import com.qiwenshare.file.mapper.ShareMapper;
|
||||
import com.qiwenshare.file.vo.share.ShareFileListVO;
|
||||
import com.qiwenshare.file.vo.share.ShareListVO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
@Slf4j
|
||||
@Service
|
||||
@Transactional(rollbackFor=Exception.class)
|
||||
public class ShareService extends ServiceImpl<ShareMapper, Share> implements IShareService {
|
||||
|
||||
@Resource
|
||||
ShareMapper shareMapper;
|
||||
|
||||
@Override
|
||||
public void batchInsertShareFile(List<ShareFile> shareFiles) {
|
||||
shareMapper.batchInsertShareFile(shareFiles);
|
||||
public List<ShareListVO> selectShareList(ShareListDTO shareListDTO, Long userId) {
|
||||
Long beginCount = (shareListDTO.getCurrentPage() - 1) * shareListDTO.getPageCount();
|
||||
return shareMapper.selectShareList(shareListDTO.getShareFilePath(),
|
||||
shareListDTO.getShareBatchNum(),
|
||||
beginCount, shareListDTO.getPageCount(), userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ShareFileListVO> selectShareFileList(String shareBatchNum, String filePath) {
|
||||
return shareMapper.selectShareFileList(shareBatchNum, filePath);
|
||||
public int selectShareListTotalCount(ShareListDTO shareListDTO, Long userId) {
|
||||
return shareMapper.selectShareListTotalCount(shareListDTO.getShareFilePath(), shareListDTO.getShareBatchNum(), userId);
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import com.qiwenshare.file.mapper.UserFileMapper;
|
||||
import com.qiwenshare.file.vo.file.FileListVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
@ -24,6 +25,7 @@ import java.util.concurrent.Executors;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@Transactional(rollbackFor=Exception.class)
|
||||
public class UserFileService extends ServiceImpl<UserFileMapper, UserFile> implements IUserFileService {
|
||||
@Resource
|
||||
UserFileMapper userFileMapper;
|
||||
@ -214,6 +216,42 @@ public class UserFileService extends ServiceImpl<UserFileMapper, UserFile> impl
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserFile repeatUserFileDeal(UserFile userFile) {
|
||||
String fileName = userFile.getFileName();
|
||||
String filePath = userFile.getFilePath();
|
||||
String extendName = userFile.getExtendName();
|
||||
Integer deleteFlag = userFile.getDeleteFlag();
|
||||
Long userId = userFile.getUserId();
|
||||
LambdaQueryWrapper<UserFile> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(UserFile::getFilePath, filePath)
|
||||
.eq(UserFile::getExtendName, extendName)
|
||||
.eq(UserFile::getDeleteFlag, deleteFlag)
|
||||
.eq(UserFile::getUserId, userId)
|
||||
.eq(UserFile::getFileName, fileName);
|
||||
List<UserFile> list = userFileMapper.selectList(lambdaQueryWrapper);
|
||||
if (list == null) {
|
||||
return userFile;
|
||||
}
|
||||
if (list.isEmpty()) {
|
||||
return userFile;
|
||||
}
|
||||
int i = 0;
|
||||
|
||||
while (list != null && !list.isEmpty()) {
|
||||
i++;
|
||||
lambdaQueryWrapper.eq(UserFile::getFilePath, filePath)
|
||||
.eq(UserFile::getExtendName, extendName)
|
||||
.eq(UserFile::getDeleteFlag, deleteFlag)
|
||||
.eq(UserFile::getUserId, userId)
|
||||
.eq(UserFile::getFileName, fileName + "(" + i + ")");
|
||||
list = userFileMapper.selectList(lambdaQueryWrapper);
|
||||
}
|
||||
userFile.setFileName(fileName + "(" + i + ")");
|
||||
return userFile;
|
||||
|
||||
}
|
||||
|
||||
private void updateFileDeleteStateByFilePath(String filePath, String deleteBatchNum, Long userId) {
|
||||
new Thread(()->{
|
||||
List<UserFile> fileList = selectFileListLikeRightFilePath(filePath, userId);
|
||||
|
@ -16,6 +16,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.crypto.hash.SimpleHash;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
@ -23,6 +24,7 @@ import java.util.regex.Pattern;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@Transactional(rollbackFor=Exception.class)
|
||||
public class UserService extends ServiceImpl<UserMapper, UserBean> implements IUserService {
|
||||
|
||||
@Resource
|
||||
|
@ -0,0 +1,35 @@
|
||||
package com.qiwenshare.file.vo.share;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
|
||||
@Schema(description="分享列表VO")
|
||||
@Data
|
||||
public class ShareListVO {
|
||||
private Long shareId;
|
||||
private Long 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 Long userFileId;
|
||||
private String shareFilePath;
|
||||
private Long fileId;
|
||||
private String fileName;
|
||||
private String filePath;
|
||||
private String extendName;
|
||||
private Integer isDir;
|
||||
private String uploadTime;
|
||||
private Integer deleteFlag;
|
||||
private String deleteTime;
|
||||
private String deleteBatchNum;
|
||||
private String timeStampName;
|
||||
private String fileUrl;
|
||||
private Long fileSize;
|
||||
private Integer storageType;
|
||||
}
|
@ -54,8 +54,6 @@ qiwen-file.share-mode=false
|
||||
qiwen-file.storage-type=0
|
||||
qiwen-file.cache-mode=0
|
||||
|
||||
#是否启用阿里云oss
|
||||
#qiwen-file.aliyun.oss.enabled=false
|
||||
#阿里云oss基本配置
|
||||
qiwen-file.aliyun.oss.endpoint=
|
||||
qiwen-file.aliyun.oss.access-key-id=
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
<mapper namespace="com.qiwenshare.file.mapper.FileMapper">
|
||||
|
||||
|
||||
<insert id="batchInsertFile" parameterType="java.util.List">
|
||||
INSERT ignore INTO file (userId, fileName,timeStampName, fileUrl,
|
||||
filePath, extendName, uploadTime, fileSize, isDir)
|
||||
@ -18,40 +17,4 @@
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
|
||||
|
||||
<!-- <update id="updateFile" parameterType="java">-->
|
||||
<!-- <choose>-->
|
||||
<!-- <when test="isDir == 1">-->
|
||||
<!-- UPDATE file SET filename=#{fileName}, uploadTime = #{uploadTime}-->
|
||||
<!-- where fileId = #{fileId};-->
|
||||
<!-- UPDATE file SET filepath=REPLACE(filepath, #{oldFilePath}, #{filePath}) WHERE filepath LIKE N'${oldFilePath}%';-->
|
||||
<!-- </when>-->
|
||||
<!-- <otherwise>-->
|
||||
<!-- update file-->
|
||||
<!-- <set>-->
|
||||
<!-- <if test="fileName != null">-->
|
||||
<!-- fileName = #{fileName},-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="uploadTime != null">-->
|
||||
<!-- uploadTime = #{uploadTime},-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="fileUrl != null">-->
|
||||
<!-- fileUrl = #{fileUrl},-->
|
||||
<!-- </if>-->
|
||||
<!-- </set>-->
|
||||
<!-- where fileId = #{fileId}-->
|
||||
<!-- </otherwise>-->
|
||||
<!-- </choose>-->
|
||||
|
||||
<!-- </update>-->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</mapper>
|
@ -0,0 +1,61 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.qiwenshare.file.mapper.ShareFileMapper">
|
||||
|
||||
|
||||
<insert id="batchInsertShareFile" parameterType="java.util.List">
|
||||
INSERT ignore INTO sharefile (shareBatchNum, userFileId, shareFilePath)
|
||||
VALUES
|
||||
<foreach collection="list" item="file" index="index" separator=",">
|
||||
(#{file.shareBatchNum}, #{file.userFileId}, #{file.shareFilePath})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="selectShareFileList" resultType="com.qiwenshare.file.vo.share.ShareFileListVO">
|
||||
select * from sharefile a
|
||||
left join userfile b on b.userFileId = a.userFileId
|
||||
left join file c on c.fileId = b.fileId
|
||||
where a.shareBatchNum = #{shareBatchNum}
|
||||
and a.shareFilePath = #{shareFilePath}
|
||||
</select>
|
||||
|
||||
|
||||
<!-- <update id="updateFile" parameterType="java">-->
|
||||
<!-- <choose>-->
|
||||
<!-- <when test="isDir == 1">-->
|
||||
<!-- UPDATE file SET filename=#{fileName}, uploadTime = #{uploadTime}-->
|
||||
<!-- where fileId = #{fileId};-->
|
||||
<!-- UPDATE file SET filepath=REPLACE(filepath, #{oldFilePath}, #{filePath}) WHERE filepath LIKE N'${oldFilePath}%';-->
|
||||
<!-- </when>-->
|
||||
<!-- <otherwise>-->
|
||||
<!-- update file-->
|
||||
<!-- <set>-->
|
||||
<!-- <if test="fileName != null">-->
|
||||
<!-- fileName = #{fileName},-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="uploadTime != null">-->
|
||||
<!-- uploadTime = #{uploadTime},-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="fileUrl != null">-->
|
||||
<!-- fileUrl = #{fileUrl},-->
|
||||
<!-- </if>-->
|
||||
<!-- </set>-->
|
||||
<!-- where fileId = #{fileId}-->
|
||||
<!-- </otherwise>-->
|
||||
<!-- </choose>-->
|
||||
|
||||
<!-- </update>-->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</mapper>
|
@ -6,23 +6,34 @@
|
||||
|
||||
<mapper namespace="com.qiwenshare.file.mapper.ShareMapper">
|
||||
|
||||
|
||||
<insert id="batchInsertShareFile" parameterType="java.util.List">
|
||||
INSERT ignore INTO sharefile (shareBatchNum, userFileId, shareFilePath)
|
||||
VALUES
|
||||
<foreach collection="list" item="file" index="index" separator=",">
|
||||
(#{file.shareBatchNum}, #{file.userFileId}, #{file.shareFilePath})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="selectShareFileList" resultType="com.qiwenshare.file.vo.share.ShareFileListVO">
|
||||
select * from sharefile a
|
||||
left join userfile b on b.userFileId = a.userFileId
|
||||
left join file c on c.fileId = b.fileId
|
||||
where a.shareBatchNum = #{shareBatchNum}
|
||||
and a.shareFilePath = #{shareFilePath}
|
||||
<select id="selectShareList" resultType="com.qiwenshare.file.vo.share.ShareListVO">
|
||||
SELECT * FROM share a
|
||||
LEFT JOIN sharefile b ON b.shareBatchNum = a.shareBatchNum
|
||||
LEFT JOIN userfile c ON c.userFileId = b.userFileId
|
||||
LEFT JOIN file d ON d.fileId = c.fileId
|
||||
WHERE shareFilePath = #{shareFilePath}
|
||||
<if test="shareBatchNum != null">
|
||||
AND a.shareBatchNum = #{shareBatchNum}
|
||||
</if>
|
||||
AND c.userId = #{userId}
|
||||
order BY shareTime desc
|
||||
limit #{beginCount}, #{pageCount}
|
||||
</select>
|
||||
|
||||
<select id="selectShareListTotalCount" resultType="java.lang.Integer">
|
||||
SELECT count(*) FROM share a
|
||||
LEFT JOIN sharefile b ON b.shareBatchNum = a.shareBatchNum
|
||||
LEFT JOIN userfile c ON c.userFileId = b.userFileId
|
||||
LEFT JOIN file d ON d.fileId = c.fileId
|
||||
WHERE shareFilePath = #{shareFilePath}
|
||||
<if test="shareBatchNum != null">
|
||||
AND a.shareBatchNum = #{shareBatchNum}
|
||||
</if>
|
||||
AND c.userId = #{userId}
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- <update id="updateFile" parameterType="java">-->
|
||||
|
@ -28,8 +28,8 @@
|
||||
</where>
|
||||
ORDER BY isDir desc
|
||||
limit #{beginCount}, #{pageCount}
|
||||
|
||||
</select>
|
||||
|
||||
<sql id="selectByExtendName" >
|
||||
left join file on file.fileId = userfile.fileId
|
||||
where extendName in
|
||||
|
Loading…
Reference in New Issue
Block a user