feat(新增): 文件管理文件生成,修改模板生成器部分缺陷
This commit is contained in:
parent
73f8f42dd7
commit
e493f282fa
|
@ -3,11 +3,11 @@ package cn.bunny.common.generator.generator;
|
|||
import cn.bunny.common.generator.entity.BaseField;
|
||||
import cn.bunny.common.generator.entity.BaseResultMap;
|
||||
import cn.bunny.common.generator.utils.GeneratorCodeUtils;
|
||||
import cn.bunny.dao.dto.system.dept.DeptAddDto;
|
||||
import cn.bunny.dao.dto.system.dept.DeptDto;
|
||||
import cn.bunny.dao.dto.system.dept.DeptUpdateDto;
|
||||
import cn.bunny.dao.entity.system.Dept;
|
||||
import cn.bunny.dao.vo.system.dept.DeptVo;
|
||||
import cn.bunny.dao.dto.system.files.FilesAddDto;
|
||||
import cn.bunny.dao.dto.system.files.FilesDto;
|
||||
import cn.bunny.dao.dto.system.files.FilesUpdateDto;
|
||||
import cn.bunny.dao.entity.system.Files;
|
||||
import cn.bunny.dao.vo.system.files.FilesVo;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.google.common.base.CaseFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
@ -36,7 +36,7 @@ import java.util.stream.Stream;
|
|||
@Service
|
||||
public class WebGeneratorCode {
|
||||
// 公共路径
|
||||
public static String commonPath = "D:\\Project\\web\\PC\\auth\\auth-web\\src";
|
||||
public static String commonPath = "D:\\MyFolder\\auth-admin\\auth-web\\src";
|
||||
// 生成API请求路径
|
||||
public static String apiPath = commonPath + "\\api\\v1\\";
|
||||
// 生成vue路径
|
||||
|
@ -44,18 +44,18 @@ public class WebGeneratorCode {
|
|||
// 生成仓库路径
|
||||
public static String storePath = commonPath + "\\store\\system\\";
|
||||
// 后端controller
|
||||
public static String controllerPath = "D:\\Project\\web\\PC\\auth\\auth-server-java\\service\\src\\main\\java\\cn\\bunny\\services\\controller\\";
|
||||
public static String servicePath = "D:\\Project\\web\\PC\\auth\\auth-server-java\\service\\src\\main\\java\\cn\\bunny\\services\\service\\";
|
||||
public static String serviceImplPath = "D:\\Project\\web\\PC\\auth\\auth-server-java\\service\\src\\main\\java\\cn\\bunny\\services\\service\\impl\\";
|
||||
public static String mapperPath = "D:\\Project\\web\\PC\\auth\\auth-server-java\\service\\src\\main\\java\\cn\\bunny\\services\\mapper\\";
|
||||
public static String resourceMapperPath = "D:\\Project\\web\\PC\\auth\\auth-server-java\\service\\src\\main\\resources\\mapper\\";
|
||||
public static String controllerPath = "D:\\MyFolder\\auth-admin\\auth-server-java\\service\\src\\main\\java\\cn\\bunny\\services\\controller\\";
|
||||
public static String servicePath = "D:\\MyFolder\\auth-admin\\auth-server-java\\service\\src\\main\\java\\cn\\bunny\\services\\service\\";
|
||||
public static String serviceImplPath = "D:\\MyFolder\\auth-admin\\auth-server-java\\service\\src\\main\\java\\cn\\bunny\\services\\service\\impl\\";
|
||||
public static String mapperPath = "D:\\MyFolder\\auth-admin\\auth-server-java\\service\\src\\main\\java\\cn\\bunny\\services\\mapper\\";
|
||||
public static String resourceMapperPath = "D:\\MyFolder\\auth-admin\\auth-server-java\\service\\src\\main\\resources\\mapper\\";
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Class<?> originalClass = Dept.class;
|
||||
Class<?> dtoClass = DeptDto.class;
|
||||
Class<?> addDtoClass = DeptAddDto.class;
|
||||
Class<?> updateDtoClass = DeptUpdateDto.class;
|
||||
Class<?> voClass = DeptVo.class;
|
||||
Class<?> originalClass = Files.class;
|
||||
Class<?> dtoClass = FilesDto.class;
|
||||
Class<?> addDtoClass = FilesAddDto.class;
|
||||
Class<?> updateDtoClass = FilesUpdateDto.class;
|
||||
Class<?> voClass = FilesVo.class;
|
||||
|
||||
// 设置velocity资源加载器
|
||||
Properties prop = new Properties();
|
||||
|
|
|
@ -37,7 +37,7 @@ public class ${originalName}ServiceImpl extends ServiceImpl<${originalName}Mappe
|
|||
|
||||
List<${originalName}Vo> voList = page.getRecords().stream().map(${lowercaseName} -> {
|
||||
${originalName}Vo ${lowercaseName}Vo = new ${originalName}Vo();
|
||||
BeanUtils.copyProperties(${originalName}, ${originalName}Vo);
|
||||
BeanUtils.copyProperties(${lowercaseName}, ${lowercaseName}Vo);
|
||||
return ${lowercaseName}Vo;
|
||||
}).toList();
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
|
||||
<PureTableBar :columns="columns" title="${classDescription}" @fullscreen="tableRef.setAdaptive()" @refresh="onSearch">
|
||||
<template #buttons>
|
||||
<el-button :icon="useRenderIcon(AddFill)" type="primary" @click="onAdd"> 添加${classTitle}</el-button>
|
||||
<el-button :icon="useRenderIcon(AddFill)" type="primary" @click="onAdd"> {{ $t('add_new') }} </el-button>
|
||||
</template>
|
||||
|
||||
<template v-slot="{ size, dynamicColumns }">
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
package cn.bunny.dao.dto.system.files;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@Schema(name = "FilesAddDto对象", title = "文件", description = "文件管理")
|
||||
public class FilesAddDto {
|
||||
|
||||
@Schema(name = "filename", title = "文件的名称")
|
||||
@NotBlank(message = "文件的名称不能为空")
|
||||
private String filename;
|
||||
|
||||
@Schema(name = "filepath", title = "文件在服务器上的存储路径")
|
||||
@NotBlank(message = "存储路径不能为空")
|
||||
private String filepath;
|
||||
|
||||
@Schema(name = "fileType", title = "文件的MIME类型")
|
||||
@NotBlank(message = "文件类型不能为空")
|
||||
private String fileType;
|
||||
|
||||
@Schema(name = "downloadCount", title = "下载数量")
|
||||
private Integer downloadCount = 0;
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package cn.bunny.dao.dto.system.files;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@Schema(name = "FilesDto对象", title = "文件", description = "文件管理")
|
||||
public class FilesDto {
|
||||
|
||||
@Schema(name = "filename", title = "文件的名称")
|
||||
private String filename;
|
||||
|
||||
@Schema(name = "filepath", title = "文件在服务器上的存储路径")
|
||||
private String filepath;
|
||||
|
||||
@Schema(name = "fileType", title = "文件的MIME类型")
|
||||
private String fileType;
|
||||
|
||||
@Schema(name = "downloadCount", title = "下载数量")
|
||||
private Integer downloadCount;
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package cn.bunny.dao.dto.system.files;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@Schema(name = "FilesUpdateDto对象", title = "文件", description = "文件管理")
|
||||
public class FilesUpdateDto {
|
||||
|
||||
@Schema(name = "id", title = "主键")
|
||||
@NotNull(message = "id不能为空")
|
||||
private Long id;
|
||||
|
||||
@Schema(name = "filename", title = "文件的名称")
|
||||
@NotBlank(message = "文件的名称不能为空")
|
||||
private String filename;
|
||||
|
||||
@Schema(name = "filepath", title = "文件在服务器上的存储路径")
|
||||
@NotBlank(message = "存储路径不能为空")
|
||||
private String filepath;
|
||||
|
||||
@Schema(name = "fileType", title = "文件的MIME类型")
|
||||
@NotBlank(message = "文件类型不能为空")
|
||||
private String fileType;
|
||||
|
||||
@Schema(name = "downloadCount", title = "下载数量")
|
||||
private Integer downloadCount;
|
||||
|
||||
}
|
|
@ -2,7 +2,6 @@ package cn.bunny.dao.entity.system;
|
|||
|
||||
import cn.bunny.dao.entity.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
@ -20,7 +19,7 @@ import lombok.experimental.Accessors;
|
|||
@Setter
|
||||
@Accessors(chain = true)
|
||||
@TableName("sys_files")
|
||||
@ApiModel(value = "Files对象", description = "系统文件表")
|
||||
@Schema(name = "Files对象", title = "系统文件表", description = "系统文件管理")
|
||||
public class Files extends BaseEntity {
|
||||
|
||||
@Schema(name = "filename", title = "文件的名称")
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.dao.vo.system.dept;
|
||||
package cn.bunny.dao.vo.system;
|
||||
|
||||
import cn.bunny.dao.vo.BaseVo;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.dao.vo.system.email;
|
||||
package cn.bunny.dao.vo.system;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.dao.vo.system.menuIcon;
|
||||
package cn.bunny.dao.vo.system;
|
||||
|
||||
import cn.bunny.dao.vo.BaseVo;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
@ -0,0 +1,30 @@
|
|||
package cn.bunny.dao.vo.system.files;
|
||||
|
||||
import cn.bunny.dao.vo.BaseVo;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@Schema(name = "FilesVo对象", title = "系统文件", description = "管理端系统文件返回信息")
|
||||
public class FilesVo extends BaseVo {
|
||||
|
||||
@Schema(name = "filename", title = "文件的名称")
|
||||
private String filename;
|
||||
|
||||
@Schema(name = "filepath", title = "文件在服务器上的存储路径")
|
||||
private String filepath;
|
||||
|
||||
@Schema(name = "fileSize", title = "文件的大小,以字节为单位")
|
||||
private Long fileSize;
|
||||
|
||||
@Schema(name = "fileType", title = "文件的MIME类型")
|
||||
private String fileType;
|
||||
|
||||
@Schema(name = "downloadCount", title = "下载数量")
|
||||
private Integer downloadCount;
|
||||
|
||||
}
|
|
@ -7,7 +7,7 @@ import cn.bunny.dao.entity.system.Dept;
|
|||
import cn.bunny.dao.pojo.result.PageResult;
|
||||
import cn.bunny.dao.pojo.result.Result;
|
||||
import cn.bunny.dao.pojo.result.ResultCodeEnum;
|
||||
import cn.bunny.dao.vo.system.dept.DeptVo;
|
||||
import cn.bunny.dao.vo.system.DeptVo;
|
||||
import cn.bunny.services.service.DeptService;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
|
|
@ -1,24 +1,36 @@
|
|||
package cn.bunny.services.controller;
|
||||
|
||||
import cn.bunny.dao.dto.system.files.FileUploadDto;
|
||||
import cn.bunny.dao.dto.system.files.FilesAddDto;
|
||||
import cn.bunny.dao.dto.system.files.FilesDto;
|
||||
import cn.bunny.dao.dto.system.files.FilesUpdateDto;
|
||||
import cn.bunny.dao.entity.system.Files;
|
||||
import cn.bunny.dao.pojo.result.PageResult;
|
||||
import cn.bunny.dao.pojo.result.Result;
|
||||
import cn.bunny.dao.pojo.result.ResultCodeEnum;
|
||||
import cn.bunny.dao.vo.system.files.FileInfoVo;
|
||||
import cn.bunny.dao.vo.system.files.FilesVo;
|
||||
import cn.bunny.services.service.FilesService;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统文件表 前端控制器
|
||||
* 系统文件表表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2024-10-04
|
||||
* @since 2024-10-09 16:28:01
|
||||
*/
|
||||
@Tag(name = "系统文件表", description = "系统文件表相关接口")
|
||||
@RestController
|
||||
@RequestMapping("admin/files")
|
||||
public class FilesController {
|
||||
|
@ -26,10 +38,44 @@ public class FilesController {
|
|||
@Autowired
|
||||
private FilesService filesService;
|
||||
|
||||
@Operation(summary = "分页查询系统文件表", description = "分页查询系统文件表")
|
||||
@GetMapping("getFilesList/{page}/{limit}")
|
||||
public Mono<Result<PageResult<FilesVo>>> getFilesList(
|
||||
@Parameter(name = "page", description = "当前页", required = true)
|
||||
@PathVariable("page") Integer page,
|
||||
@Parameter(name = "limit", description = "每页记录数", required = true)
|
||||
@PathVariable("limit") Integer limit,
|
||||
FilesDto dto) {
|
||||
Page<Files> pageParams = new Page<>(page, limit);
|
||||
PageResult<FilesVo> pageResult = filesService.getFilesList(pageParams, dto);
|
||||
return Mono.just(Result.success(pageResult));
|
||||
}
|
||||
|
||||
@Operation(summary = "添加系统文件表", description = "添加系统文件表")
|
||||
@PostMapping("addFiles")
|
||||
public Mono<Result<String>> addFiles(@Valid @RequestBody FilesAddDto dto) {
|
||||
filesService.addFiles(dto);
|
||||
return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS));
|
||||
}
|
||||
|
||||
@Operation(summary = "更新系统文件表", description = "更新系统文件表")
|
||||
@PutMapping("updateFiles")
|
||||
public Mono<Result<String>> updateFiles(@Valid @RequestBody FilesUpdateDto dto) {
|
||||
filesService.updateFiles(dto);
|
||||
return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS));
|
||||
}
|
||||
|
||||
@Operation(summary = "上传文件", description = "上传文件")
|
||||
@PostMapping("upload")
|
||||
public Result<FileInfoVo> upload(FileUploadDto dto) {
|
||||
FileInfoVo vo = filesService.upload(dto);
|
||||
return Result.success(vo, ResultCodeEnum.SUCCESS_UPLOAD);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除系统文件表", description = "删除系统文件表")
|
||||
@DeleteMapping("deleteFiles")
|
||||
public Mono<Result<String>> deleteFiles(@RequestBody List<Long> ids) {
|
||||
filesService.deleteFiles(ids);
|
||||
return Mono.just(Result.success(ResultCodeEnum.DELETE_SUCCESS));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import cn.bunny.dao.entity.system.MenuIcon;
|
|||
import cn.bunny.dao.pojo.result.PageResult;
|
||||
import cn.bunny.dao.pojo.result.Result;
|
||||
import cn.bunny.dao.pojo.result.ResultCodeEnum;
|
||||
import cn.bunny.dao.vo.system.menuIcon.MenuIconVo;
|
||||
import cn.bunny.dao.vo.system.MenuIconVo;
|
||||
import cn.bunny.services.service.MenuIconService;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
package cn.bunny.services.mapper;
|
||||
|
||||
import cn.bunny.dao.dto.system.files.FilesDto;
|
||||
import cn.bunny.dao.entity.system.Files;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
@ -10,9 +16,24 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2024-10-04
|
||||
* @since 2024-10-09 16:28:01
|
||||
*/
|
||||
@Mapper
|
||||
public interface FilesMapper extends BaseMapper<Files> {
|
||||
|
||||
/**
|
||||
* * 分页查询系统文件表内容
|
||||
*
|
||||
* @param pageParams 系统文件表分页参数
|
||||
* @param dto 系统文件表查询表单
|
||||
* @return 系统文件表分页结果
|
||||
*/
|
||||
IPage<Files> selectListByPage(@Param("page") Page<Files> pageParams, @Param("dto") FilesDto dto);
|
||||
|
||||
/**
|
||||
* 物理删除系统文件表
|
||||
*
|
||||
* @param ids 删除 id 列表
|
||||
*/
|
||||
void deleteBatchIdsWithPhysics(List<Long> ids);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import cn.bunny.dao.dto.system.dept.DeptDto;
|
|||
import cn.bunny.dao.dto.system.dept.DeptUpdateDto;
|
||||
import cn.bunny.dao.entity.system.Dept;
|
||||
import cn.bunny.dao.pojo.result.PageResult;
|
||||
import cn.bunny.dao.vo.system.dept.DeptVo;
|
||||
import cn.bunny.dao.vo.system.DeptVo;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import jakarta.validation.Valid;
|
||||
|
|
|
@ -1,9 +1,18 @@
|
|||
package cn.bunny.services.service;
|
||||
|
||||
import cn.bunny.dao.dto.system.files.FileUploadDto;
|
||||
import cn.bunny.dao.dto.system.files.FilesAddDto;
|
||||
import cn.bunny.dao.dto.system.files.FilesDto;
|
||||
import cn.bunny.dao.dto.system.files.FilesUpdateDto;
|
||||
import cn.bunny.dao.entity.system.Files;
|
||||
import cn.bunny.dao.pojo.result.PageResult;
|
||||
import cn.bunny.dao.vo.system.files.FileInfoVo;
|
||||
import cn.bunny.dao.vo.system.files.FilesVo;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
@ -11,10 +20,31 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2024-10-04
|
||||
* @since 2024-10-09 16:28:01
|
||||
*/
|
||||
public interface FilesService extends IService<Files> {
|
||||
|
||||
/**
|
||||
* * 获取系统文件表列表
|
||||
*
|
||||
* @return 系统文件表返回列表
|
||||
*/
|
||||
PageResult<FilesVo> getFilesList(Page<Files> pageParams, FilesDto dto);
|
||||
|
||||
/**
|
||||
* * 添加系统文件表
|
||||
*
|
||||
* @param dto 添加表单
|
||||
*/
|
||||
void addFiles(@Valid FilesAddDto dto);
|
||||
|
||||
/**
|
||||
* * 更新系统文件表
|
||||
*
|
||||
* @param dto 更新表单
|
||||
*/
|
||||
void updateFiles(@Valid FilesUpdateDto dto);
|
||||
|
||||
/**
|
||||
* * 上传文件
|
||||
*
|
||||
|
@ -22,4 +52,11 @@ public interface FilesService extends IService<Files> {
|
|||
* @return 管理端返回文件信息
|
||||
*/
|
||||
FileInfoVo upload(FileUploadDto dto);
|
||||
|
||||
/**
|
||||
* * 删除|批量删除系统文件表类型
|
||||
*
|
||||
* @param ids 删除id列表
|
||||
*/
|
||||
void deleteFiles(List<Long> ids);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import cn.bunny.dao.dto.system.menuIcon.MenuIconDto;
|
|||
import cn.bunny.dao.dto.system.menuIcon.MenuIconUpdateDto;
|
||||
import cn.bunny.dao.entity.system.MenuIcon;
|
||||
import cn.bunny.dao.pojo.result.PageResult;
|
||||
import cn.bunny.dao.vo.system.menuIcon.MenuIconVo;
|
||||
import cn.bunny.dao.vo.system.MenuIconVo;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import jakarta.validation.Valid;
|
||||
|
|
|
@ -7,7 +7,7 @@ import cn.bunny.dao.dto.system.dept.DeptUpdateDto;
|
|||
import cn.bunny.dao.entity.system.Dept;
|
||||
import cn.bunny.dao.pojo.result.PageResult;
|
||||
import cn.bunny.dao.pojo.result.ResultCodeEnum;
|
||||
import cn.bunny.dao.vo.system.dept.DeptVo;
|
||||
import cn.bunny.dao.vo.system.DeptVo;
|
||||
import cn.bunny.services.mapper.DeptMapper;
|
||||
import cn.bunny.services.mapper.UserDeptMapper;
|
||||
import cn.bunny.services.service.DeptService;
|
||||
|
|
|
@ -1,30 +1,93 @@
|
|||
package cn.bunny.services.service.impl;
|
||||
|
||||
import cn.bunny.dao.dto.system.files.FileUploadDto;
|
||||
import cn.bunny.dao.dto.system.files.FilesAddDto;
|
||||
import cn.bunny.dao.dto.system.files.FilesDto;
|
||||
import cn.bunny.dao.dto.system.files.FilesUpdateDto;
|
||||
import cn.bunny.dao.entity.system.Files;
|
||||
import cn.bunny.dao.pojo.result.PageResult;
|
||||
import cn.bunny.dao.vo.system.files.FileInfoVo;
|
||||
import cn.bunny.dao.vo.system.files.FilesVo;
|
||||
import cn.bunny.services.factory.FileFactory;
|
||||
import cn.bunny.services.mapper.FilesMapper;
|
||||
import cn.bunny.services.service.FilesService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统文件表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2024-10-04
|
||||
* @since 2024-10-09 16:28:01
|
||||
*/
|
||||
@Service
|
||||
public class FilesServiceImpl extends ServiceImpl<FilesMapper, Files> implements FilesService {
|
||||
|
||||
@Autowired
|
||||
private FileFactory fileFactory;
|
||||
private final FileFactory fileFactory;
|
||||
|
||||
public FilesServiceImpl(FileFactory fileFactory) {this.fileFactory = fileFactory;}
|
||||
|
||||
/**
|
||||
* * 系统文件表 服务实现类
|
||||
*
|
||||
* @param pageParams 系统文件表分页查询page对象
|
||||
* @param dto 系统文件表分页查询对象
|
||||
* @return 查询分页系统文件表返回对象
|
||||
*/
|
||||
@Override
|
||||
public PageResult<FilesVo> getFilesList(Page<Files> pageParams, FilesDto dto) {
|
||||
// 分页查询菜单图标
|
||||
IPage<Files> page = baseMapper.selectListByPage(pageParams, dto);
|
||||
|
||||
List<FilesVo> voList = page.getRecords().stream().map(files -> {
|
||||
FilesVo filesVo = new FilesVo();
|
||||
BeanUtils.copyProperties(files, filesVo);
|
||||
return filesVo;
|
||||
}).toList();
|
||||
|
||||
return PageResult.<FilesVo>builder()
|
||||
.list(voList)
|
||||
.pageNo(page.getCurrent())
|
||||
.pageSize(page.getSize())
|
||||
.total(page.getTotal())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加系统文件表
|
||||
*
|
||||
* @param dto 系统文件表添加
|
||||
*/
|
||||
@Override
|
||||
public void addFiles(@Valid FilesAddDto dto) {
|
||||
// 保存数据
|
||||
Files files = new Files();
|
||||
BeanUtils.copyProperties(dto, files);
|
||||
save(files);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新系统文件表
|
||||
*
|
||||
* @param dto 系统文件表更新
|
||||
*/
|
||||
@Override
|
||||
public void updateFiles(@Valid FilesUpdateDto dto) {
|
||||
// 更新内容
|
||||
Files files = new Files();
|
||||
BeanUtils.copyProperties(dto, files);
|
||||
updateById(files);
|
||||
}
|
||||
|
||||
/**
|
||||
* * 上传文件
|
||||
|
@ -40,4 +103,14 @@ public class FilesServiceImpl extends ServiceImpl<FilesMapper, Files> implements
|
|||
|
||||
return fileFactory.uploadFile(file, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除|批量删除系统文件表
|
||||
*
|
||||
* @param ids 删除id列表
|
||||
*/
|
||||
@Override
|
||||
public void deleteFiles(List<Long> ids) {
|
||||
baseMapper.deleteBatchIdsWithPhysics(ids);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import cn.bunny.dao.dto.system.menuIcon.MenuIconDto;
|
|||
import cn.bunny.dao.dto.system.menuIcon.MenuIconUpdateDto;
|
||||
import cn.bunny.dao.entity.system.MenuIcon;
|
||||
import cn.bunny.dao.pojo.result.PageResult;
|
||||
import cn.bunny.dao.vo.system.menuIcon.MenuIconVo;
|
||||
import cn.bunny.dao.vo.system.MenuIconVo;
|
||||
import cn.bunny.services.mapper.MenuIconMapper;
|
||||
import cn.bunny.services.service.MenuIconService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
|
|
|
@ -5,21 +5,52 @@
|
|||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="cn.bunny.dao.entity.system.Files">
|
||||
<id column="id" property="id"/>
|
||||
<result column="filename" property="filename"/>
|
||||
<result column="filepath" property="filepath"/>
|
||||
<result column="file_size" property="fileSize"/>
|
||||
<result column="file_type" property="fileType"/>
|
||||
<result column="download_count" property="downloadCount"/>
|
||||
<result column="create_user" property="createUser"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
<result column="update_user" property="updateUser"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="is_deleted" property="isDeleted"/>
|
||||
<id column="create_time" property="createTime"/>
|
||||
<id column="update_time" property="updateTime"/>
|
||||
<id column="create_user" property="createUser"/>
|
||||
<id column="update_user" property="updateUser"/>
|
||||
<id column="is_deleted" property="isDeleted"/>
|
||||
<id column="filename" property="filename"/>
|
||||
<id column="filepath" property="filepath"/>
|
||||
<id column="file_size" property="fileSize"/>
|
||||
<id column="file_type" property="fileType"/>
|
||||
<id column="download_count" property="downloadCount"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, filename, filepath, file_size, file_type, download_count, create_user, update_time, update_user, create_time, is_deleted
|
||||
id, create_time, update_time, create_user, update_user, is_deleted, filename, filepath, file_size, file_type, download_count
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询系统文件表内容 -->
|
||||
<select id="selectListByPage" resultType="cn.bunny.dao.entity.system.Files">
|
||||
select <include refid="Base_Column_List"/>
|
||||
from sys_files
|
||||
<where>
|
||||
<if test="dto.filename != null and dto.filename != ''">
|
||||
filename like CONCAT('%',#{dto.filename},'%')
|
||||
</if>
|
||||
<if test="dto.filepath != null and dto.filepath != ''">
|
||||
filepath like CONCAT('%',#{dto.filepath},'%')
|
||||
</if>
|
||||
<if test="dto.fileType != null and dto.fileType != ''">
|
||||
file_type like CONCAT('%',#{dto.fileType},'%')
|
||||
</if>
|
||||
<if test="dto.downloadCount != null and dto.downloadCount != ''">
|
||||
download_count like CONCAT('%',#{dto.downloadCount},'%')
|
||||
</if>
|
||||
</where>
|
||||
order by update_time
|
||||
</select>
|
||||
|
||||
<!-- 物理删除系统文件表 -->
|
||||
<delete id="deleteBatchIdsWithPhysics">
|
||||
delete
|
||||
from sys_files
|
||||
where id in
|
||||
<foreach collection="ids" item="id" open="(" close=")" separator=",">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue