新功能:实现文件管理功能以支持文件查询
实现文件管理的新功能,允许通过用户ID查询相关文件。在系统模块中,创建了FileController来处理文件查询请求,并且定义了FileService接口及其实现FileServiceImpl来具体执行文件相关操作。同时,引入了FileRespVO来作为文件响应的VO类。 - 新增FileController类,提供文件查询的REST API。 - 定义FileRespVO类,用作文件信息的响应对象。- 在FileService接口中定义getFileList方法,用于获取文件列表。- 实现FileServiceImpl类,使用LaborContractMapper进行文件数据的检索。
This commit is contained in:
parent
fa52566ce8
commit
288b934149
@ -0,0 +1,48 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.file;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.file.vo.FileRespVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
||||
import cn.iocoder.yudao.module.system.service.file.FileService;
|
||||
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
||||
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.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - 文件管理")
|
||||
@RestController
|
||||
@RequestMapping("/system/file")
|
||||
@Validated
|
||||
public class FileController {
|
||||
|
||||
@Resource
|
||||
private FileService fileService;
|
||||
|
||||
@Resource
|
||||
private AdminUserService userService;
|
||||
|
||||
@GetMapping("/getFileByUserId")
|
||||
@Operation(summary = "获得指定用户的文件")
|
||||
@Parameter(name = "userId", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('system:labor-contract:query')")
|
||||
public CommonResult<List<FileRespVO>> getFileList(@RequestParam("userId") Long userId) {
|
||||
|
||||
AdminUserDO userDO = userService.getUser(userId);
|
||||
List<FileRespVO> fileRespVOS = fileService.getFileList(userDO.getMobile());
|
||||
fileRespVOS = fileRespVOS.stream().filter(item -> item.getFileType().contains("pdf") || item.getFileType().contains("doc")).collect(Collectors.toList());
|
||||
|
||||
return success(fileRespVOS);
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.file.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 文件管理 Response VO")
|
||||
@Data
|
||||
public class FileRespVO {
|
||||
|
||||
@Schema(description = "文件编号")
|
||||
private String fileId;
|
||||
|
||||
@Schema(description = "文件 URL")
|
||||
private String url;
|
||||
|
||||
@Schema(description = "文件名")
|
||||
private String fileName;
|
||||
|
||||
@Schema(description = "文件类型")
|
||||
private String fileType;
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package cn.iocoder.yudao.module.system.service.file;
|
||||
|
||||
import cn.iocoder.yudao.module.system.controller.admin.file.vo.FileRespVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文件管理 Service 接口
|
||||
*
|
||||
* @author 符溶馨
|
||||
*/
|
||||
public interface FileService {
|
||||
List<FileRespVO> getFileList(String mobile);
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package cn.iocoder.yudao.module.system.service.file;
|
||||
|
||||
import cn.iocoder.yudao.module.system.controller.admin.file.vo.FileRespVO;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.laborcontract.LaborContractMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文件管理 Service 实现类
|
||||
*
|
||||
* @author 符溶馨
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class FileServiceImpl implements FileService {
|
||||
|
||||
@Resource
|
||||
private LaborContractMapper laborContractMapper;
|
||||
|
||||
@Override
|
||||
public List<FileRespVO> getFileList(String mobile) {
|
||||
|
||||
return laborContractMapper.selectFileByUserId(mobile);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user