7-31 岗位查用户

This commit is contained in:
ybb 2025-08-05 09:27:10 +08:00
parent 141c95f63e
commit 50c343402b
5 changed files with 32 additions and 30 deletions

View File

@ -11,7 +11,7 @@ import java.util.List;
@ApiOperation("商务资料文件对象")
public interface BusinessDataFileMapper {
public List<BusinessDataFileEntity> List( @Param("folderId") Long folderId,String fileName);
public List<BusinessDataFileEntity> List(@Param("folderId") Long folderId, @Param("fileName") String fileName);
void delete(@Param("fileId") Long fileId,@Param("folderId") Long folderId);
void add(BusinessDataFileEntity businessDataFileEntity);

View File

@ -10,7 +10,7 @@ import org.springframework.web.bind.annotation.RequestParam;
public interface BusinessDataFileService {
PageBean pageSelect(Integer page, Integer pageSize, Long folderId);
PageBean pageSelect(Integer page, Integer pageSize, Long folderId, String fileName);
Result delete(@RequestParam(value = "fileId", required = false) Long fileId,@RequestParam(value = "foldelId", required = false) Long folderId);

View File

@ -30,11 +30,12 @@ public class BusinessDataFileServiceImpl implements BusinessDataFileService {
@ApiOperation("分页查询文件")
public PageBean pageSelect(Integer page, Integer pageSize, Long folderId) {
@Override
public PageBean pageSelect(Integer page, Integer pageSize, Long folderId, String fileName) {
PageHelper.startPage(page, pageSize);
List<BusinessDataFileEntity> list = businessDataFileMapper.List(folderId ,"");
Page<BusinessDataFileEntity> p= (Page<BusinessDataFileEntity>) list;
PageBean pageBean = new PageBean(p.getTotal(),p.getResult());
List<BusinessDataFileEntity> list = businessDataFileMapper.List(folderId, fileName);
Page<BusinessDataFileEntity> p = (Page<BusinessDataFileEntity>) list;
PageBean pageBean = new PageBean(p.getTotal(), p.getResult());
return pageBean;
}
@ApiOperation("删除文件")

View File

@ -2,15 +2,15 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.dite.znpt.mapper.BusinessDataFileMapper">
<select id="List" resultType="com.dite.znpt.domain.entity.BusinessDataFileEntity">
select * from business_data_part_file
<where>
<if test="param1 != null">
and folder_id = #{param1}
</if>
<if test="param2 != null and param2 != ''">
and file_name = #{param2}
</if>
</where>
select * from business_data_part_file
<where>
<if test="folderId != null">
and folder_id = #{folderId}
</if>
<if test="fileName != null and fileName != ''">
and file_name like concat('%', #{fileName}, '%')
</if>
</where>
</select>
<delete id="delete" parameterType="com.dite.znpt.domain.entity.BusinessDataFileEntity" >
delete from business_data_part_file

View File

@ -44,43 +44,44 @@ public class BusinessDataFileController {
@ApiOperation(value = "分页查询文件", httpMethod = "GET")
@GetMapping("/list")
public Result pageSelect(@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer pageSize,
@RequestParam(defaultValue = "0") Long folderId) {
PageBean pageBean = businessDataFileService.pageSelect(page, pageSize, folderId);
@RequestParam(defaultValue = "10") Integer pageSize,
@RequestParam(defaultValue = "0") Long folderId,
@RequestParam(required = false) String fileName) {
PageBean pageBean = businessDataFileService.pageSelect(page, pageSize, folderId, fileName);
return Result.ok(pageBean);
}
@ApiOperation(value = "增加文件")
@PostMapping("/add")
public Result add(@RequestParam("file") MultipartFile file,
@RequestParam Long folderId) {
System.out.println(file+" 77777777777777777777777777"+folderId);
@RequestParam Long folderId) {
System.out.println(file + " 77777777777777777777777777" + folderId);
if (file.isEmpty()) {
return Result.error("上传文件为空");
}
//TODO 以后可以优化就算文件名一样加个12这种
// TODO 以后可以优化就算文件名一样加个12这种
try {
byte[] bytes = file.getBytes();
String uploadDir = businessDataService.getPath(folderId);
File uploadedFile = new File(uploadDir + "\\" + file.getOriginalFilename());
if(uploadedFile.exists()){
if (uploadedFile.exists()) {
return Result.error("文件已存在");
}
}
file.transferTo(uploadedFile);
//保存文件信息到数据
// 保存文件信息到数据
BusinessDataFileEntity fileEntity = new BusinessDataFileEntity();
fileEntity.setFolderId(folderId);
fileEntity.setFileName(file.getOriginalFilename());
fileEntity.setFilePath(uploadDir+"\\"+file.getOriginalFilename());
fileEntity.setFilePath(uploadDir + "\\" + file.getOriginalFilename());
fileEntity.setFileType(file.getContentType());
fileEntity.setFileSize(file.getSize());
fileEntity.setUploadTime(new Date() );
fileEntity.setUploadTime(new Date());
fileEntity.setUploaderId(0L);
System.out.println(uploadDir+"\\"+file.getOriginalFilename());
System.out.println(uploadDir + "\\" + file.getOriginalFilename());
businessDataFileService.add(fileEntity);
return Result.okM("上传成功");
@ -93,12 +94,13 @@ public class BusinessDataFileController {
@ApiOperation(value = "删除文件")
@DeleteMapping("/delete")
public Result delete(@RequestParam Long fileId) {
businessDataFileService.delete(fileId,null);
businessDataFileService.delete(fileId, null);
return Result.okM("删除成功");
}
@ApiOperation(value = "下载文件")
@GetMapping("/download")
public void download(@RequestParam("fileId") Long fileId , HttpServletResponse response) {
public void download(@RequestParam("fileId") Long fileId, HttpServletResponse response) {
String path = businessDataFileService.getPath(fileId);
try {
// path是指想要下载的文件的路径
@ -133,5 +135,4 @@ public class BusinessDataFileController {
}
}
}