文件上传
This commit is contained in:
1
pom.xml
1
pom.xml
@@ -330,6 +330,7 @@
|
||||
<module>vetti-generator</module>
|
||||
<module>vetti-common</module>
|
||||
<module>vetti-ai</module>
|
||||
<module>vetti-hotake</module>
|
||||
</modules>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
|
||||
@@ -84,6 +84,12 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.vetti</groupId>
|
||||
<artifactId>vetti-hotake</artifactId>
|
||||
<version>3.9.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
package com.vetti.web.controller.hotake;
|
||||
|
||||
|
||||
import com.vetti.common.annotation.Log;
|
||||
import com.vetti.common.core.controller.BaseController;
|
||||
import com.vetti.common.core.domain.AjaxResult;
|
||||
import com.vetti.common.core.page.TableDataInfo;
|
||||
import com.vetti.common.enums.BusinessType;
|
||||
import com.vetti.common.utils.poi.ExcelUtil;
|
||||
import com.vetti.hotake.domain.HotakeSysFile;
|
||||
import com.vetti.hotake.domain.dto.HotakeSysFileDto;
|
||||
import com.vetti.hotake.service.IHotakeSysFileService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文件管理Controller
|
||||
*
|
||||
* @author ID
|
||||
* @date 2025-09-06
|
||||
*/
|
||||
@Api(tags = "文件管理")
|
||||
@RestController
|
||||
@RequestMapping("/hotake/sysFile")
|
||||
public class HotakeSysFileController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IHotakeSysFileService hotakeSysFileService;
|
||||
|
||||
/**
|
||||
* 查询文件管理列表
|
||||
*/
|
||||
@ApiOperation("查询文件管理列表")
|
||||
@PreAuthorize("@ss.hasPermi('command:sysFile:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(HotakeSysFile HotakeSysFile) {
|
||||
startPage();
|
||||
List<HotakeSysFileDto> list = hotakeSysFileService.selectHotakeSysFileList(HotakeSysFile);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出文件管理列表
|
||||
*/
|
||||
@ApiOperation("导出文件管理列表")
|
||||
@PreAuthorize("@ss.hasPermi('command:sysFile:export')")
|
||||
@Log(title = "文件管理", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public AjaxResult export(HotakeSysFile HotakeSysFile) {
|
||||
List<HotakeSysFileDto> list = hotakeSysFileService.selectHotakeSysFileList(HotakeSysFile);
|
||||
ExcelUtil<HotakeSysFileDto> util = new ExcelUtil<HotakeSysFileDto>(HotakeSysFileDto.class);
|
||||
return util.exportExcel(list, "文件管理数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件管理详细信息
|
||||
*/
|
||||
@ApiOperation("获取文件管理详细信息")
|
||||
@PreAuthorize("@ss.hasPermi('command:sysFile:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||
return AjaxResult.success(hotakeSysFileService.selectHotakeSysFileById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增文件管理
|
||||
*/
|
||||
@ApiOperation("新增文件管理")
|
||||
@PreAuthorize("@ss.hasPermi('command:sysFile:add')")
|
||||
@Log(title = "文件管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestPart("file") MultipartFile file, HotakeSysFile HotakeSysFile) {
|
||||
hotakeSysFileService.insertHotakeSysFile(file, HotakeSysFile);
|
||||
return toAjax(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改文件管理
|
||||
*/
|
||||
@ApiOperation("修改文件管理")
|
||||
@PreAuthorize("@ss.hasPermi('command:sysFile:edit')")
|
||||
@Log(title = "文件管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestPart(name = "file", required = false) MultipartFile file, HotakeSysFile HotakeSysFile) {
|
||||
return toAjax(hotakeSysFileService.updateHotakeSysFile(file, HotakeSysFile));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文件管理
|
||||
*/
|
||||
@ApiOperation("删除文件管理")
|
||||
@PreAuthorize("@ss.hasPermi('command:sysFile:remove')")
|
||||
@Log(title = "文件管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||
return toAjax(hotakeSysFileService.deleteHotakeSysFileByIds(ids));
|
||||
}
|
||||
|
||||
@ApiOperation("禁用文件管理")
|
||||
@PreAuthorize("@ss.hasPermi('command:sysFile:edit')")
|
||||
@Log(title = "文件管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/available/{id}")
|
||||
public AjaxResult availableSysFile(@PathVariable Long id) {
|
||||
return toAjax(hotakeSysFileService.availableSysFile(id));
|
||||
}
|
||||
}
|
||||
38
vetti-hotake/pom.xml
Normal file
38
vetti-hotake/pom.xml
Normal file
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.vetti</groupId>
|
||||
<artifactId>vetti-service</artifactId>
|
||||
<version>3.9.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>vetti-hotake</artifactId>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- 防止进入swagger页面报类型转换错误,排除3.0.0中的引用,手动增加1.6.2版本 -->
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-models</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 通用工具-->
|
||||
<dependency>
|
||||
<groupId>com.vetti</groupId>
|
||||
<artifactId>vetti-common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.vetti</groupId>
|
||||
<artifactId>vetti-system</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.vetti.hotake.domain;
|
||||
|
||||
|
||||
import com.vetti.common.annotation.Excel;
|
||||
import com.vetti.common.core.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 文件管理对象 command_sys_file
|
||||
*
|
||||
* @author ID
|
||||
* @date 2025-09-06
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class HotakeSysFile extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** ID */
|
||||
@ApiModelProperty("ID")
|
||||
private Long id;
|
||||
|
||||
/** 存储minio中桶名字 */
|
||||
@ApiModelProperty("存储minio中桶名字")
|
||||
@Excel(name = "存储minio中桶名字")
|
||||
private String minioBucketName;
|
||||
|
||||
/** CODE */
|
||||
@ApiModelProperty("CODE")
|
||||
@Excel(name = "CODE")
|
||||
private String code;
|
||||
|
||||
/** 文件名称 */
|
||||
@ApiModelProperty("文件名称")
|
||||
@Excel(name = "文件名称")
|
||||
private String fileName;
|
||||
|
||||
/** 文件类型(如:image/jpeg, application/pdf等) */
|
||||
@ApiModelProperty("文件类型(如:image/jpeg, application/pdf等)")
|
||||
@Excel(name = "文件类型", readConverterExp = "如=:image/jpeg,,a=pplication/pdf等")
|
||||
private String fileType;
|
||||
|
||||
/** 文件大小,单位字节 */
|
||||
@ApiModelProperty("文件大小,单位字节")
|
||||
@Excel(name = "文件大小,单位字节")
|
||||
private Long fileSize;
|
||||
|
||||
/** 文件存储路径(物理路径或云存储URL) */
|
||||
@ApiModelProperty("文件存储路径(物理路径或云存储URL)")
|
||||
@Excel(name = "文件存储路径", readConverterExp = "物理路径或云存储URL")
|
||||
private String storagePath;
|
||||
|
||||
/** 文件MD5值,用于校验文件完整性和去重 */
|
||||
@ApiModelProperty("文件MD5值,用于校验文件完整性和去重")
|
||||
@Excel(name = "文件MD5值,用于校验文件完整性和去重")
|
||||
private String fileMd5;
|
||||
|
||||
/** 上传平台:1-PC管理平台,2-APP端 */
|
||||
@ApiModelProperty("上传平台:1-PC管理平台,2-APP端")
|
||||
@Excel(name = "上传平台:1-PC管理平台,2-APP端")
|
||||
private Integer uploadPlatform;
|
||||
|
||||
/** 是否可用(1可用,2不可用) */
|
||||
@ApiModelProperty("是否可用(1可用,2不可用)")
|
||||
@Excel(name = "是否可用", readConverterExp = "1=可用,2不可用")
|
||||
private Integer available;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.vetti.hotake.domain.dto;
|
||||
|
||||
import com.vetti.common.utils.bean.BeanUtils;
|
||||
import com.vetti.hotake.domain.HotakeSysFile;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author ID
|
||||
* @date 2025/9/7 16:10
|
||||
*/
|
||||
@Data
|
||||
public class HotakeSysFileDto extends HotakeSysFile {
|
||||
|
||||
private String downloadLink;
|
||||
|
||||
public static HotakeSysFileDto build(String link, HotakeSysFile data) {
|
||||
HotakeSysFileDto dto = new HotakeSysFileDto();
|
||||
BeanUtils.copyBeanProp(dto, data);
|
||||
dto.setDownloadLink(link);
|
||||
return dto;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.vetti.hotake.mapper;
|
||||
|
||||
|
||||
import com.vetti.hotake.domain.HotakeSysFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文件管理Mapper接口
|
||||
*
|
||||
* @author ID
|
||||
* @date 2025-09-06
|
||||
*/
|
||||
public interface HotakeSysFileMapper
|
||||
{
|
||||
/**
|
||||
* 查询文件管理
|
||||
*
|
||||
* @param id 文件管理主键
|
||||
* @return 文件管理
|
||||
*/
|
||||
public HotakeSysFile selectHotakeSysFileById(Long id);
|
||||
|
||||
/**
|
||||
* 查询文件管理列表
|
||||
*
|
||||
* @param HotakeSysFile 文件管理
|
||||
* @return 文件管理集合
|
||||
*/
|
||||
public List<HotakeSysFile> selectHotakeSysFileList(HotakeSysFile HotakeSysFile);
|
||||
|
||||
/**
|
||||
* 新增文件管理
|
||||
*
|
||||
* @param HotakeSysFile 文件管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertHotakeSysFile(HotakeSysFile HotakeSysFile);
|
||||
|
||||
/**
|
||||
* 修改文件管理
|
||||
*
|
||||
* @param HotakeSysFile 文件管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateHotakeSysFile(HotakeSysFile HotakeSysFile);
|
||||
|
||||
/**
|
||||
* 删除文件管理
|
||||
*
|
||||
* @param id 文件管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteHotakeSysFileById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除文件管理
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteHotakeSysFileByIds(Long[] ids);
|
||||
/**
|
||||
* 批量新增文件管理
|
||||
*
|
||||
* @param HotakeSysFileList 文件管理列表
|
||||
* @return 结果
|
||||
*/
|
||||
public int batchInsertHotakeSysFile(List<HotakeSysFile> HotakeSysFileList);
|
||||
|
||||
|
||||
public List<HotakeSysFile> selectHotakeSysFileByIds(Long[] ids);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package com.vetti.hotake.service;
|
||||
|
||||
import com.vetti.hotake.domain.HotakeSysFile;
|
||||
import com.vetti.hotake.domain.dto.HotakeSysFileDto;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 文件管理Service接口
|
||||
*
|
||||
* @author ID
|
||||
* @date 2025-09-06
|
||||
*/
|
||||
public interface IHotakeSysFileService {
|
||||
/**
|
||||
* 查询文件管理
|
||||
*
|
||||
* @param id 文件管理主键
|
||||
* @return 文件管理
|
||||
*/
|
||||
public HotakeSysFile selectHotakeSysFileById(Long id);
|
||||
|
||||
/**
|
||||
* 查询文件管理列表
|
||||
*
|
||||
* @param hotakeSysFile 文件管理
|
||||
* @return 文件管理集合
|
||||
*/
|
||||
public List<HotakeSysFileDto> selectHotakeSysFileList(HotakeSysFile hotakeSysFile);
|
||||
|
||||
/**
|
||||
* 新增文件管理
|
||||
*
|
||||
* @param hotakeSysFile 文件管理
|
||||
* @return 结果
|
||||
*/
|
||||
public HotakeSysFile insertHotakeSysFile(MultipartFile file, HotakeSysFile hotakeSysFile);
|
||||
|
||||
/**
|
||||
* 修改文件管理
|
||||
*
|
||||
* @param hotakeSysFile 文件管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateHotakeSysFile(MultipartFile file, HotakeSysFile hotakeSysFile);
|
||||
|
||||
/**
|
||||
* 批量删除文件管理
|
||||
*
|
||||
* @param ids 需要删除的文件管理主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteHotakeSysFileByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除文件管理信息
|
||||
*
|
||||
* @param id 文件管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteHotakeSysFileById(Long id);
|
||||
|
||||
/**
|
||||
* 批量新增文件管理
|
||||
*
|
||||
* @param hotakeSysFileList 文件管理列表
|
||||
* @return 结果
|
||||
*/
|
||||
public int batchInsertHotakeSysFile(List<HotakeSysFile> hotakeSysFileList);
|
||||
|
||||
int availableSysFile(Long id);
|
||||
|
||||
/**
|
||||
* 获取文件url
|
||||
*
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
String url(HotakeSysFile data);
|
||||
|
||||
/**
|
||||
* 获取文件url
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
String url(Long id);
|
||||
|
||||
/**
|
||||
* 获取文件url
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
Map<Long, String> url(Long[] ids);
|
||||
|
||||
public void updateData(MultipartFile file, HotakeSysFile hotakeSysFile);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
package com.vetti.hotake.service.impl;
|
||||
|
||||
|
||||
import com.vetti.common.config.MinioConfig;
|
||||
import com.vetti.common.core.service.BaseServiceImpl;
|
||||
import com.vetti.common.enums.FillTypeEnum;
|
||||
import com.vetti.common.utils.file.FileTypeUtils;
|
||||
import com.vetti.common.utils.file.FileUtils;
|
||||
import com.vetti.common.utils.file.MinioUtil;
|
||||
import com.vetti.common.utils.sign.Md5Utils;
|
||||
import com.vetti.hotake.domain.HotakeSysFile;
|
||||
import com.vetti.hotake.domain.dto.HotakeSysFileDto;
|
||||
import com.vetti.hotake.mapper.HotakeSysFileMapper;
|
||||
import com.vetti.hotake.service.IHotakeSysFileService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.vetti.common.utils.SecurityUtils.getLoginUser;
|
||||
|
||||
/**
|
||||
* 文件管理Service业务层处理
|
||||
*
|
||||
* @author ID
|
||||
* @date 2025-09-06
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
@Service
|
||||
public class HotakeSysFileServiceImpl extends BaseServiceImpl implements IHotakeSysFileService {
|
||||
@Resource
|
||||
private HotakeSysFileMapper hotakeSysFileMapper;
|
||||
|
||||
@Resource
|
||||
MinioUtil minioUtil;
|
||||
|
||||
@Resource
|
||||
MinioConfig minioConfig;
|
||||
|
||||
/**
|
||||
* 查询文件管理
|
||||
*
|
||||
* @param id 文件管理主键
|
||||
* @return 文件管理
|
||||
*/
|
||||
@Transactional(readOnly = true)
|
||||
@Override
|
||||
public HotakeSysFile selectHotakeSysFileById(Long id) {
|
||||
return hotakeSysFileMapper.selectHotakeSysFileById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询文件管理列表
|
||||
*
|
||||
* @param HotakeSysFile 文件管理
|
||||
* @return 文件管理
|
||||
*/
|
||||
@Transactional(readOnly = true)
|
||||
@Override
|
||||
public List<HotakeSysFileDto> selectHotakeSysFileList(HotakeSysFile HotakeSysFile) {
|
||||
List<HotakeSysFileDto> l = new ArrayList<>();
|
||||
List<HotakeSysFile> dataL = hotakeSysFileMapper.selectHotakeSysFileList(HotakeSysFile);
|
||||
if (CollectionUtils.isNotEmpty(dataL)) {
|
||||
dataL.forEach(e -> {
|
||||
l.add(HotakeSysFileDto.build(url(e), e));
|
||||
});
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增文件管理
|
||||
*
|
||||
* @param HotakeSysFile 文件管理
|
||||
* @return 结果
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public HotakeSysFile insertHotakeSysFile(MultipartFile file, HotakeSysFile HotakeSysFile) {
|
||||
if (file == null) {
|
||||
throw new IllegalArgumentException("文件不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(HotakeSysFile.getCode())) {
|
||||
throw new IllegalArgumentException("CODE不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(HotakeSysFile.getMinioBucketName())) {
|
||||
throw new IllegalArgumentException("桶不能为空");
|
||||
}
|
||||
if (checkCode(HotakeSysFile)) {
|
||||
throw new IllegalArgumentException("CODE不能重复");
|
||||
}
|
||||
HotakeSysFile.setUploadPlatform(1);//PC
|
||||
updateData(file, HotakeSysFile);
|
||||
fill(FillTypeEnum.INSERT.getCode(), HotakeSysFile);
|
||||
hotakeSysFileMapper.insertHotakeSysFile(HotakeSysFile);
|
||||
return HotakeSysFile;
|
||||
}
|
||||
|
||||
private boolean checkCode(HotakeSysFile HotakeSysFile) {
|
||||
HotakeSysFile query = new HotakeSysFile();
|
||||
query.setCode(HotakeSysFile.getCode());
|
||||
query.setMinioBucketName(HotakeSysFile.getMinioBucketName());
|
||||
List<HotakeSysFile> HotakeSysFiles = hotakeSysFileMapper.selectHotakeSysFileList(HotakeSysFile);
|
||||
if (HotakeSysFiles.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateData(MultipartFile file, HotakeSysFile HotakeSysFile) {
|
||||
try {
|
||||
String fileUrl = minioUtil.uploadFile(file, minioUtil.objectName(getLoginUser().getUserId()), HotakeSysFile.getMinioBucketName());
|
||||
HotakeSysFile.setStoragePath(fileUrl);
|
||||
HotakeSysFile.setAvailable(1);//可用
|
||||
// HotakeSysFile.setUploadPlatform(1);//PC
|
||||
HotakeSysFile.setFileName(FileUtils.cleanFileName(file.getOriginalFilename()));
|
||||
HotakeSysFile.setFileType(FileTypeUtils.getFileType(file.getOriginalFilename()));
|
||||
HotakeSysFile.setFileSize(file.getSize());
|
||||
HotakeSysFile.setFileMd5(Md5Utils.getFileMd5(FileUtils.convert(file)));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改文件管理
|
||||
*
|
||||
* @param HotakeSysFile 文件管理
|
||||
* @return 结果
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public int updateHotakeSysFile(MultipartFile file, HotakeSysFile HotakeSysFile) {
|
||||
HotakeSysFile old = hotakeSysFileMapper.selectHotakeSysFileById(HotakeSysFile.getId());
|
||||
if (file == null) {
|
||||
old.setRemark(HotakeSysFile.getRemark());
|
||||
fill(FillTypeEnum.UPDATE.getCode(), old);
|
||||
return hotakeSysFileMapper.updateHotakeSysFile(old);
|
||||
}
|
||||
HotakeSysFile.setUploadPlatform(1);//PC
|
||||
updateData(file, HotakeSysFile);
|
||||
fill(FillTypeEnum.UPDATE.getCode(), HotakeSysFile);
|
||||
return hotakeSysFileMapper.updateHotakeSysFile(HotakeSysFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除文件管理
|
||||
*
|
||||
* @param ids 需要删除的文件管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public int deleteHotakeSysFileByIds(Long[] ids) {
|
||||
return hotakeSysFileMapper.deleteHotakeSysFileByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文件管理信息
|
||||
*
|
||||
* @param id 文件管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public int deleteHotakeSysFileById(Long id) {
|
||||
return hotakeSysFileMapper.deleteHotakeSysFileById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量新增文件管理
|
||||
*
|
||||
* @param HotakeSysFileList 文件管理列表
|
||||
* @return 结果
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public int batchInsertHotakeSysFile(List<HotakeSysFile> HotakeSysFileList) {
|
||||
return hotakeSysFileMapper.batchInsertHotakeSysFile(HotakeSysFileList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int availableSysFile(Long id) {
|
||||
HotakeSysFile HotakeSysFile = hotakeSysFileMapper.selectHotakeSysFileById(id);
|
||||
HotakeSysFile.setAvailable(2);
|
||||
fill(FillTypeEnum.UPDATE.getCode(), HotakeSysFile);
|
||||
return hotakeSysFileMapper.updateHotakeSysFile(HotakeSysFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String url(HotakeSysFile data) {
|
||||
return minioConfig.getEndpoint() + "/" + data.getMinioBucketName() + "/" + data.getStoragePath();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String url(Long id) {
|
||||
return url(hotakeSysFileMapper.selectHotakeSysFileById(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, String> url(Long[] ids) {
|
||||
List<HotakeSysFile> l = hotakeSysFileMapper.selectHotakeSysFileByIds(ids);
|
||||
if (CollectionUtils.isEmpty(l)) {
|
||||
return null;
|
||||
}
|
||||
Map<Long, String> map = new HashMap<>();
|
||||
l.forEach(e -> {
|
||||
map.put(e.getId(), url(e));
|
||||
});
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
<?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.vetti.hotake.mapper.HotakeSysFileMapper">
|
||||
|
||||
<resultMap type="HotakeSysFile" id="HotakeSysFileResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="minioBucketName" column="minio_bucket_name" />
|
||||
<result property="code" column="code" />
|
||||
<result property="fileName" column="file_name" />
|
||||
<result property="fileType" column="file_type" />
|
||||
<result property="fileSize" column="file_size" />
|
||||
<result property="storagePath" column="storage_path" />
|
||||
<result property="fileMd5" column="file_md5" />
|
||||
<result property="uploadPlatform" column="upload_platform" />
|
||||
<result property="available" column="available" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectHotakeSysFileVo">
|
||||
select id, minio_bucket_name, code, file_name, file_type, file_size, storage_path, file_md5, upload_platform, available, create_by, create_time, update_by, update_time, remark from hotake_sys_file
|
||||
</sql>
|
||||
|
||||
<select id="selectHotakeSysFileList" parameterType="HotakeSysFile" resultMap="HotakeSysFileResult">
|
||||
<include refid="selectHotakeSysFileVo"/>
|
||||
<where>
|
||||
<if test="minioBucketName != null and minioBucketName != ''"> and minio_bucket_name = #{minioBucketName}</if>
|
||||
<if test="code != null and code != ''"> and code = #{code}</if>
|
||||
<if test="fileName != null and fileName != ''"> and file_name like concat('%', #{fileName}, '%')</if>
|
||||
<if test="fileType != null and fileType != ''"> and file_type = #{fileType}</if>
|
||||
<if test="fileSize != null "> and file_size = #{fileSize}</if>
|
||||
<if test="storagePath != null and storagePath != ''"> and storage_path = #{storagePath}</if>
|
||||
<if test="fileMd5 != null and fileMd5 != ''"> and file_md5 = #{fileMd5}</if>
|
||||
<if test="uploadPlatform != null "> and upload_platform = #{uploadPlatform}</if>
|
||||
<if test="available != null "> and available = #{available}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectHotakeSysFileById" parameterType="Long" resultMap="HotakeSysFileResult">
|
||||
<include refid="selectHotakeSysFileVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertHotakeSysFile" parameterType="HotakeSysFile" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into Hotake_sys_file
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="minioBucketName != null and minioBucketName != ''">minio_bucket_name,</if>
|
||||
<if test="code != null and code != ''">code,</if>
|
||||
<if test="fileName != null and fileName != ''">file_name,</if>
|
||||
<if test="fileType != null and fileType != ''">file_type,</if>
|
||||
<if test="fileSize != null">file_size,</if>
|
||||
<if test="storagePath != null and storagePath != ''">storage_path,</if>
|
||||
<if test="fileMd5 != null">file_md5,</if>
|
||||
<if test="uploadPlatform != null">upload_platform,</if>
|
||||
<if test="available != null">available,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="minioBucketName != null and minioBucketName != ''">#{minioBucketName},</if>
|
||||
<if test="code != null and code != ''">#{code},</if>
|
||||
<if test="fileName != null and fileName != ''">#{fileName},</if>
|
||||
<if test="fileType != null and fileType != ''">#{fileType},</if>
|
||||
<if test="fileSize != null">#{fileSize},</if>
|
||||
<if test="storagePath != null and storagePath != ''">#{storagePath},</if>
|
||||
<if test="fileMd5 != null">#{fileMd5},</if>
|
||||
<if test="uploadPlatform != null">#{uploadPlatform},</if>
|
||||
<if test="available != null">#{available},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateHotakeSysFile" parameterType="HotakeSysFile">
|
||||
update Hotake_sys_file
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="minioBucketName != null and minioBucketName != ''">minio_bucket_name = #{minioBucketName},</if>
|
||||
<if test="code != null and code != ''">code = #{code},</if>
|
||||
<if test="fileName != null and fileName != ''">file_name = #{fileName},</if>
|
||||
<if test="fileType != null and fileType != ''">file_type = #{fileType},</if>
|
||||
<if test="fileSize != null">file_size = #{fileSize},</if>
|
||||
<if test="storagePath != null and storagePath != ''">storage_path = #{storagePath},</if>
|
||||
<if test="fileMd5 != null">file_md5 = #{fileMd5},</if>
|
||||
<if test="uploadPlatform != null">upload_platform = #{uploadPlatform},</if>
|
||||
<if test="available != null">available = #{available},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteHotakeSysFileById" parameterType="Long">
|
||||
delete from Hotake_sys_file where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteHotakeSysFileByIds" parameterType="String">
|
||||
delete from Hotake_sys_file where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<insert id="batchInsertHotakeSysFile">
|
||||
insert into Hotake_sys_file( id, minio_bucket_name, code, file_name, file_type, file_size, storage_path, file_md5, upload_platform, available, create_by, create_time, update_by, update_time, remark,) values
|
||||
<foreach item="item" index="index" collection="list" separator=",">
|
||||
( #{item.id}, #{item.minioBucketName}, #{item.code}, #{item.fileName}, #{item.fileType}, #{item.fileSize}, #{item.storagePath}, #{item.fileMd5}, #{item.uploadPlatform}, #{item.available}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime}, #{item.remark},)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="selectHotakeSysFileByIds" parameterType="String" resultMap="HotakeSysFileResult">
|
||||
<include refid="selectHotakeSysFileVo"/> where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user