添加文件-文件夹
This commit is contained in:
parent
b87190d135
commit
817f662cb7
@ -0,0 +1,18 @@
|
||||
CREATE TABLE `li_file_directory` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '创建者',
|
||||
`update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '更新者',
|
||||
`delete_flag` tinyint(1) NULL DEFAULT 0 COMMENT '删除标志 true/false 删除/未删除',
|
||||
`directory_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '文件目录类型',
|
||||
`directory_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '拥有者名称',
|
||||
`owner_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '拥有者id',
|
||||
`parent_id` bigint NULL DEFAULT NULL COMMENT '父分类ID',
|
||||
`level` int NULL DEFAULT NULL COMMENT '层级',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 1698937596963311619 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '文件夹' ROW_FORMAT = DYNAMIC;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
||||
ALTER TABLE li_file ADD file_directory_id varchar(255) COMMENT '文件夹ID';
|
@ -7,9 +7,7 @@ import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.security.AuthUser;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.security.enums.UserEnums;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.common.vo.SearchVO;
|
||||
import cn.lili.modules.file.entity.File;
|
||||
import cn.lili.modules.file.entity.dto.FileOwnerDTO;
|
||||
import cn.lili.modules.file.service.FileService;
|
||||
@ -43,10 +41,9 @@ public class FileController {
|
||||
@ApiOperation(value = "获取自己的图片资源")
|
||||
@GetMapping
|
||||
@ApiImplicitParam(name = "title", value = "名称模糊匹配")
|
||||
public ResultMessage<IPage<File>> getFileList(@RequestHeader String accessToken, File file, SearchVO searchVO, PageVO pageVo) {
|
||||
public ResultMessage<IPage<File>> getFileList(@RequestHeader String accessToken, FileOwnerDTO fileOwnerDTO) {
|
||||
|
||||
AuthUser authUser = UserContext.getAuthUser(cache, accessToken);
|
||||
FileOwnerDTO fileOwnerDTO = new FileOwnerDTO();
|
||||
//只有买家才写入自己id
|
||||
if (authUser.getRole().equals(UserEnums.MEMBER)) {
|
||||
fileOwnerDTO.setOwnerId(authUser.getId());
|
||||
@ -55,7 +52,7 @@ public class FileController {
|
||||
fileOwnerDTO.setOwnerId(authUser.getStoreId());
|
||||
}
|
||||
fileOwnerDTO.setUserEnums(authUser.getRole().name());
|
||||
return ResultUtil.data(fileService.customerPageOwner(fileOwnerDTO, file, searchVO, pageVo));
|
||||
return ResultUtil.data(fileService.customerPageOwner(fileOwnerDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "文件重命名")
|
||||
|
@ -0,0 +1,64 @@
|
||||
package cn.lili.controller.common;
|
||||
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.file.entity.FileDirectory;
|
||||
import cn.lili.modules.file.entity.dto.FileDirectoryDTO;
|
||||
import cn.lili.modules.file.service.FileDirectoryService;
|
||||
import cn.lili.modules.file.service.FileService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文件目录管理接口
|
||||
*
|
||||
* @author Chopper
|
||||
* @since 2020/11/26 15:41
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "文件目录管理接口")
|
||||
@RequestMapping("/common/resource/fileDirectory")
|
||||
@RequiredArgsConstructor
|
||||
public class FileDirectoryController {
|
||||
|
||||
private final FileDirectoryService fileDirectoryService;
|
||||
private final FileService fileService;
|
||||
|
||||
@ApiOperation(value = "获取文件目录列表")
|
||||
@GetMapping
|
||||
public ResultMessage<List<FileDirectoryDTO>> getSceneFileList() {
|
||||
return ResultUtil.data(fileDirectoryService.getFileDirectoryList(UserContext.getCurrentUser().getId()));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "添加文件目录")
|
||||
@PostMapping
|
||||
public ResultMessage<FileDirectory> addSceneFileList(@RequestBody FileDirectory fileDirectory) {
|
||||
fileDirectory.setDirectoryType(UserContext.getCurrentUser().getRole().name());
|
||||
fileDirectoryService.save(fileDirectory);
|
||||
return ResultUtil.data(fileDirectory);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改文件目录")
|
||||
@PutMapping
|
||||
public ResultMessage<FileDirectory> editSceneFileList(@RequestBody FileDirectory fileDirectory) {
|
||||
fileDirectory.setDirectoryType(UserContext.getCurrentUser().getRole().name());
|
||||
fileDirectoryService.updateById(fileDirectory);
|
||||
return ResultUtil.data(fileDirectory);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除文件目录")
|
||||
@DeleteMapping("/{id}")
|
||||
public ResultMessage<Object> deleteSceneFileList(@PathVariable String id) {
|
||||
//删除文件夹下面的图片
|
||||
fileService.batchDeleteByDirectory(id);
|
||||
//删除目录
|
||||
fileDirectoryService.removeById(id);
|
||||
return ResultUtil.success();
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package cn.lili.controller.common;
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.lili.cache.Cache;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
@ -21,10 +22,7 @@ import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.InputStream;
|
||||
@ -55,7 +53,7 @@ public class UploadController {
|
||||
@PostMapping(value = "/file")
|
||||
public ResultMessage<Object> upload(MultipartFile file,
|
||||
String base64,
|
||||
@RequestHeader String accessToken) {
|
||||
@RequestHeader String accessToken, @RequestParam String directoryPath) {
|
||||
|
||||
|
||||
AuthUser authUser = UserContext.getAuthUser(cache, accessToken);
|
||||
@ -89,6 +87,12 @@ public class UploadController {
|
||||
try {
|
||||
InputStream inputStream = file.getInputStream();
|
||||
//上传至第三方云服务或服务器
|
||||
String scene = UserContext.getCurrentUser().getRole().name();
|
||||
if (StrUtil.equalsAny(UserContext.getCurrentUser().getRole().name(), UserEnums.MEMBER.name(), UserEnums.STORE.name(), UserEnums.SEAT.name())) {
|
||||
scene = scene + "/" + authUser.getId();
|
||||
}
|
||||
fileKey = scene + "/" + directoryPath + "/" + fileKey;
|
||||
//上传至第三方云服务或服务器
|
||||
result = filePluginFactory.filePlugin().inputStreamUpload(inputStream, fileKey);
|
||||
//保存数据信息至数据库
|
||||
newFile.setName(file.getOriginalFilename());
|
||||
@ -104,6 +108,15 @@ public class UploadController {
|
||||
} else {
|
||||
newFile.setOwnerId(authUser.getId());
|
||||
}
|
||||
|
||||
//存储文件目录
|
||||
if (StrUtil.isNotEmpty(directoryPath)) {
|
||||
if (directoryPath.indexOf("/") > 0) {
|
||||
newFile.setFileDirectoryId(directoryPath.substring(directoryPath.lastIndexOf("/") + 1));
|
||||
} else {
|
||||
newFile.setFileDirectoryId(directoryPath);
|
||||
}
|
||||
}
|
||||
fileService.save(newFile);
|
||||
} catch (Exception e) {
|
||||
log.error("文件上传失败", e);
|
||||
|
@ -43,4 +43,7 @@ public class File extends BaseEntity {
|
||||
|
||||
@ApiModelProperty(value = "用户类型")
|
||||
private String userEnums;
|
||||
|
||||
@ApiModelProperty(value = "文件夹ID")
|
||||
private String fileDirectoryId;
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package cn.lili.modules.file.entity;
|
||||
|
||||
import cn.lili.common.security.enums.UserEnums;
|
||||
import cn.lili.mybatis.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
|
||||
@Data
|
||||
@TableName("li_file_directory")
|
||||
@ApiModel(value = "文件目录")
|
||||
public class FileDirectory extends BaseEntity {
|
||||
|
||||
/**
|
||||
* @see UserEnums
|
||||
*/
|
||||
@ApiModelProperty(value = "文件目录类型")
|
||||
private String directoryType;
|
||||
@ApiModelProperty(value = "拥有者名称")
|
||||
private String directoryName;
|
||||
@ApiModelProperty(value = "拥有者id")
|
||||
private String ownerId;
|
||||
@ApiModelProperty(value = "父分类ID")
|
||||
private String parentId;
|
||||
@ApiModelProperty(value = "层级")
|
||||
@Min(value = 0, message = "层级最小为0")
|
||||
@Max(value = 2, message = "层级最大为2")
|
||||
private Integer level;
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package cn.lili.modules.file.entity.dto;
|
||||
|
||||
import cn.lili.common.utils.BeanUtil;
|
||||
import cn.lili.modules.file.entity.FileDirectory;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class FileDirectoryDTO extends FileDirectory{
|
||||
|
||||
@ApiModelProperty(value = "文件目录列表")
|
||||
private List<FileDirectory> children= new ArrayList<>();
|
||||
|
||||
public FileDirectoryDTO(FileDirectory fileDirectory){
|
||||
BeanUtil.copyProperties(fileDirectory, this);
|
||||
}
|
||||
}
|
@ -1,10 +1,16 @@
|
||||
package cn.lili.modules.file.entity.dto;
|
||||
|
||||
import cn.lili.common.utils.DateUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import com.alipay.api.internal.util.StringUtils;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 文件查询所属者参数对象
|
||||
*
|
||||
@ -14,7 +20,7 @@ import lombok.NoArgsConstructor;
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class FileOwnerDTO {
|
||||
public class FileOwnerDTO extends PageVO {
|
||||
|
||||
@ApiModelProperty(value = "拥有者id")
|
||||
private String ownerId;
|
||||
@ -22,4 +28,42 @@ public class FileOwnerDTO {
|
||||
@ApiModelProperty(value = "用户类型")
|
||||
private String userEnums;
|
||||
|
||||
@ApiModelProperty(value = "原文件名")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "存储文件名")
|
||||
private String fileKey;
|
||||
|
||||
@ApiModelProperty(value = "文件类型")
|
||||
private String fileType;
|
||||
|
||||
@ApiModelProperty(value = "文件夹ID")
|
||||
private String fileDirectoryId;
|
||||
|
||||
@ApiModelProperty(value = "起始日期")
|
||||
private String startDate;
|
||||
|
||||
@ApiModelProperty(value = "结束日期")
|
||||
private String endDate;
|
||||
|
||||
public Date getConvertStartDate() {
|
||||
if (StringUtils.isEmpty(startDate)) {
|
||||
return null;
|
||||
}
|
||||
return DateUtil.toDate(startDate, DateUtil.STANDARD_DATE_FORMAT);
|
||||
}
|
||||
|
||||
public Date getConvertEndDate() {
|
||||
if (StringUtils.isEmpty(endDate)) {
|
||||
return null;
|
||||
}
|
||||
//结束时间等于结束日期+1天 -1秒,
|
||||
Date date = DateUtil.toDate(endDate, DateUtil.STANDARD_DATE_FORMAT);
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.set(Calendar.DAY_OF_MONTH, calendar.get(Calendar.DAY_OF_MONTH) + 1);
|
||||
calendar.set(Calendar.SECOND, -1);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,18 @@
|
||||
package cn.lili.modules.file.entity.dto;
|
||||
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.SearchVO;
|
||||
import cn.lili.modules.file.entity.File;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class FileSearchParams extends PageVO {
|
||||
|
||||
@ApiModelProperty(value = "文件")
|
||||
private File file;
|
||||
@ApiModelProperty(value = "搜索VO")
|
||||
private SearchVO searchVO;
|
||||
@ApiModelProperty(value = "文件夹ID")
|
||||
private String fileDirectoryId;
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package cn.lili.modules.file.mapper;
|
||||
|
||||
import cn.lili.modules.file.entity.FileDirectory;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* 文件管理数据处理层
|
||||
*
|
||||
* @author Chopper
|
||||
* @since 2021-02-22 17:20
|
||||
*/
|
||||
public interface FileDirectoryMapper extends BaseMapper<FileDirectory> {
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package cn.lili.modules.file.service;
|
||||
|
||||
import cn.lili.common.security.enums.UserEnums;
|
||||
import cn.lili.modules.file.entity.FileDirectory;
|
||||
import cn.lili.modules.file.entity.dto.FileDirectoryDTO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文件管理业务层
|
||||
*
|
||||
* @author Chopper
|
||||
*/
|
||||
public interface FileDirectoryService extends IService<FileDirectory> {
|
||||
|
||||
/**
|
||||
* 添加目录
|
||||
*
|
||||
* @param userEnum
|
||||
* @param id
|
||||
* @param ownerName
|
||||
*/
|
||||
void addFileDirectory(UserEnums userEnum, String id, String ownerName);
|
||||
|
||||
/**
|
||||
* 获取文件目录
|
||||
*
|
||||
* @param ownerId 拥有者
|
||||
* @return
|
||||
*/
|
||||
List<FileDirectoryDTO> getFileDirectoryList(String ownerId);
|
||||
}
|
@ -24,6 +24,12 @@ public interface FileService extends IService<File> {
|
||||
* @param ids
|
||||
*/
|
||||
void batchDelete(List<String> ids);
|
||||
/**
|
||||
* 根据文件夹ID批量删除
|
||||
*
|
||||
* @param directoryId 文件夹ID
|
||||
*/
|
||||
void batchDeleteByDirectory(String directoryId);
|
||||
|
||||
/**
|
||||
* 所有者批量删除
|
||||
@ -37,22 +43,19 @@ public interface FileService extends IService<File> {
|
||||
/**
|
||||
* 自定义搜索分页
|
||||
*
|
||||
* @param file
|
||||
* @param searchVO
|
||||
* @param pageVo
|
||||
|
||||
* @param fileOwnerDTO 文件查询
|
||||
|
||||
* @return
|
||||
*/
|
||||
IPage<File> customerPage(File file, SearchVO searchVO, PageVO pageVo);
|
||||
IPage<File> customerPage(FileOwnerDTO fileOwnerDTO);
|
||||
|
||||
/**
|
||||
* 所属文件数据查询
|
||||
*
|
||||
* @param file
|
||||
* @param searchVO
|
||||
* @param pageVo
|
||||
* @param ownerDTO
|
||||
* @param ownerDTO 文件查询
|
||||
* @return
|
||||
*/
|
||||
IPage<File> customerPageOwner(FileOwnerDTO ownerDTO, File file, SearchVO searchVO, PageVO pageVo);
|
||||
IPage<File> customerPageOwner(FileOwnerDTO ownerDTO);
|
||||
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package cn.lili.modules.file.serviceimpl;
|
||||
|
||||
import cn.lili.common.security.enums.UserEnums;
|
||||
import cn.lili.modules.file.entity.FileDirectory;
|
||||
import cn.lili.modules.file.entity.dto.FileDirectoryDTO;
|
||||
import cn.lili.modules.file.mapper.FileDirectoryMapper;
|
||||
import cn.lili.modules.file.service.FileDirectoryService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文件管理业务层实现
|
||||
*
|
||||
* @author Chopper
|
||||
* @since 2020/11/26 17:50
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class FileDirectoryServiceImpl extends ServiceImpl<FileDirectoryMapper, FileDirectory> implements FileDirectoryService {
|
||||
|
||||
|
||||
@Override
|
||||
public void addFileDirectory(UserEnums userEnum, String id, String ownerName) {
|
||||
FileDirectory fileDirectory = new FileDirectory();
|
||||
fileDirectory.setOwnerId(id);
|
||||
fileDirectory.setDirectoryName(ownerName);
|
||||
fileDirectory.setDirectoryType(userEnum.name());
|
||||
this.save(fileDirectory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FileDirectoryDTO> getFileDirectoryList(String scene) {
|
||||
|
||||
List<FileDirectory> fileDirectoryList = this.list();
|
||||
List<FileDirectoryDTO> fileDirectoryDTOList = new ArrayList<>();
|
||||
|
||||
fileDirectoryList.forEach(item -> {
|
||||
if (item.getLevel() == 0) {
|
||||
FileDirectoryDTO fileDirectoryDTO = new FileDirectoryDTO(item);
|
||||
initChild(fileDirectoryDTO, fileDirectoryList);
|
||||
fileDirectoryDTOList.add(fileDirectoryDTO);
|
||||
}
|
||||
});
|
||||
|
||||
return fileDirectoryDTOList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 递归初始化子树
|
||||
*/
|
||||
private void initChild(FileDirectoryDTO fileDirectoryDTO, List<FileDirectory> fileDirectoryList) {
|
||||
if (fileDirectoryList == null) {
|
||||
return;
|
||||
}
|
||||
fileDirectoryList.stream()
|
||||
.filter(item -> (item.getParentId().equals(fileDirectoryDTO.getId())))
|
||||
.forEach(child -> {
|
||||
FileDirectoryDTO childTree = new FileDirectoryDTO(child);
|
||||
initChild(childTree, fileDirectoryList);
|
||||
fileDirectoryDTO.getChildren().add(childTree);
|
||||
});
|
||||
}
|
||||
}
|
@ -4,15 +4,14 @@ import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.security.AuthUser;
|
||||
import cn.lili.mybatis.util.PageUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.SearchVO;
|
||||
import cn.lili.modules.file.entity.File;
|
||||
import cn.lili.modules.file.entity.dto.FileOwnerDTO;
|
||||
import cn.lili.modules.file.mapper.FileMapper;
|
||||
import cn.lili.modules.file.plugin.FilePlugin;
|
||||
import cn.lili.modules.file.plugin.FilePluginFactory;
|
||||
import cn.lili.modules.file.service.FileService;
|
||||
import cn.lili.mybatis.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@ -47,6 +46,18 @@ public class FileServiceImpl extends ServiceImpl<FileMapper, File> implements Fi
|
||||
this.remove(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void batchDeleteByDirectory(String directoryId) {
|
||||
LambdaQueryWrapper<File> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(File::getFileDirectoryId, directoryId);
|
||||
|
||||
List<File> files = this.list(queryWrapper);
|
||||
List<String> keys = new ArrayList<>();
|
||||
files.forEach(item -> keys.add(item.getFileKey()));
|
||||
filePluginFactory.filePlugin().deleteFile(keys);
|
||||
this.remove(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void batchDelete(List<String> ids, AuthUser authUser) {
|
||||
LambdaQueryWrapper<File> queryWrapper = new LambdaQueryWrapper<>();
|
||||
@ -74,26 +85,28 @@ public class FileServiceImpl extends ServiceImpl<FileMapper, File> implements Fi
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<File> customerPage(File file, SearchVO searchVO, PageVO pageVo) {
|
||||
public IPage<File> customerPage(FileOwnerDTO fileOwnerDTO) {
|
||||
LambdaQueryWrapper<File> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.like(CharSequenceUtil.isNotEmpty(file.getName()), File::getName, file.getName())
|
||||
.like(CharSequenceUtil.isNotEmpty(file.getFileKey()), File::getFileKey, file.getFileKey())
|
||||
.like(CharSequenceUtil.isNotEmpty(file.getFileType()), File::getFileType, file.getFileType())
|
||||
.between(CharSequenceUtil.isNotEmpty(searchVO.getStartDate()) && CharSequenceUtil.isNotEmpty(searchVO.getEndDate()),
|
||||
File::getCreateTime, searchVO.getStartDate(), searchVO.getEndDate());
|
||||
return this.page(PageUtil.initPage(pageVo), queryWrapper);
|
||||
queryWrapper.like(CharSequenceUtil.isNotEmpty(fileOwnerDTO.getName()), File::getName, fileOwnerDTO.getName())
|
||||
.eq(CharSequenceUtil.isNotEmpty(fileOwnerDTO.getFileDirectoryId()),File::getFileDirectoryId, fileOwnerDTO.getFileDirectoryId())
|
||||
.like(CharSequenceUtil.isNotEmpty(fileOwnerDTO.getFileKey()), File::getFileKey, fileOwnerDTO.getFileKey())
|
||||
.like(CharSequenceUtil.isNotEmpty(fileOwnerDTO.getFileType()), File::getFileType, fileOwnerDTO.getFileType())
|
||||
.between(CharSequenceUtil.isNotEmpty(fileOwnerDTO.getStartDate()) && CharSequenceUtil.isNotEmpty(fileOwnerDTO.getEndDate()),
|
||||
File::getCreateTime, fileOwnerDTO.getStartDate(), fileOwnerDTO.getEndDate());
|
||||
return this.page(PageUtil.initPage(fileOwnerDTO), queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<File> customerPageOwner(FileOwnerDTO ownerDTO, File file, SearchVO searchVO, PageVO pageVo) {
|
||||
public IPage<File> customerPageOwner(FileOwnerDTO fileOwnerDTO) {
|
||||
LambdaQueryWrapper<File> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(CharSequenceUtil.isNotEmpty(ownerDTO.getOwnerId()), File::getOwnerId, ownerDTO.getOwnerId())
|
||||
.eq(File::getUserEnums, ownerDTO.getUserEnums())
|
||||
.like(CharSequenceUtil.isNotEmpty(file.getName()), File::getName, file.getName())
|
||||
.like(CharSequenceUtil.isNotEmpty(file.getFileKey()), File::getFileKey, file.getFileKey())
|
||||
.like(CharSequenceUtil.isNotEmpty(file.getFileType()), File::getFileType, file.getFileType())
|
||||
.between(CharSequenceUtil.isNotEmpty(searchVO.getStartDate()) && CharSequenceUtil.isNotEmpty(searchVO.getEndDate()),
|
||||
File::getCreateTime, searchVO.getStartDate(), searchVO.getEndDate());
|
||||
return this.page(PageUtil.initPage(pageVo), queryWrapper);
|
||||
queryWrapper.eq(CharSequenceUtil.isNotEmpty(fileOwnerDTO.getOwnerId()), File::getOwnerId, fileOwnerDTO.getOwnerId())
|
||||
.eq(File::getUserEnums, fileOwnerDTO.getUserEnums())
|
||||
.eq(CharSequenceUtil.isNotEmpty(fileOwnerDTO.getFileDirectoryId()),File::getFileDirectoryId, fileOwnerDTO.getFileDirectoryId())
|
||||
.like(CharSequenceUtil.isNotEmpty(fileOwnerDTO.getName()), File::getName, fileOwnerDTO.getName())
|
||||
.like(CharSequenceUtil.isNotEmpty(fileOwnerDTO.getFileKey()), File::getFileKey, fileOwnerDTO.getFileKey())
|
||||
.like(CharSequenceUtil.isNotEmpty(fileOwnerDTO.getFileType()), File::getFileType, fileOwnerDTO.getFileType())
|
||||
.between(CharSequenceUtil.isNotEmpty(fileOwnerDTO.getStartDate()) && CharSequenceUtil.isNotEmpty(fileOwnerDTO.getEndDate()),
|
||||
File::getCreateTime, fileOwnerDTO.getStartDate(), fileOwnerDTO.getEndDate());
|
||||
return this.page(PageUtil.initPage(fileOwnerDTO), queryWrapper);
|
||||
}
|
||||
}
|
@ -1,10 +1,9 @@
|
||||
package cn.lili.controller.file;
|
||||
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.common.vo.SearchVO;
|
||||
import cn.lili.modules.file.entity.File;
|
||||
import cn.lili.modules.file.entity.dto.FileOwnerDTO;
|
||||
import cn.lili.modules.file.service.FileService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
@ -34,9 +33,9 @@ public class FileManagerController {
|
||||
@ApiOperation(value = "管理端管理所有图片")
|
||||
@GetMapping
|
||||
@ApiImplicitParam(name = "title", value = "名称模糊匹配")
|
||||
public ResultMessage<IPage<File>> adminFiles(File file, SearchVO searchVO, PageVO pageVo) {
|
||||
public ResultMessage<IPage<File>> adminFiles(FileOwnerDTO fileOwnerDTO) {
|
||||
|
||||
return ResultUtil.data(fileService.customerPage(file, searchVO, pageVo));
|
||||
return ResultUtil.data(fileService.customerPage(fileOwnerDTO));
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user