【MINIO上传的文件信息保存】

This commit is contained in:
weizhihong 2022-09-30 14:57:34 +08:00
parent aadd300cb8
commit 1dd77a87b9
9 changed files with 53 additions and 144 deletions

View File

@ -1,12 +1,12 @@
create TABLE `minio_file_info` (
`id` bigint NOT NULL AUTO_INCREMENT comment '主键',
`title` varchar(255) DEFAULT NULL comment '文件展示名称',
`type` varchar(255) DEFAULT NULL comment '文件类型',
`file_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL comment '存放路径',
`directory` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL comment '文件',
`file_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL comment '存放文件名',
`create_time` datetime DEFAULT NULL comment '创建时间',
`creator` bigint DEFAULT NULL comment '创建者',
`status` int DEFAULT NULL comment '状态',
PRIMARY KEY (`id`),
KEY `type` (`type`),
KEY `type` (`directory`),
KEY `status` (`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

View File

@ -1,11 +1,10 @@
package club.joylink.rtss.controller;
import club.joylink.rtss.entity.minio.MinioDirectory;
import club.joylink.rtss.entity.minio.MinioFileInfo;
import club.joylink.rtss.services.MinioService;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.client.PageQueryVO;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.minio.MinioFilePageVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -18,28 +17,16 @@ public class MinioController {
@Autowired
private MinioService minioService;
@PostMapping("/file/case/save")
public void saveTestcaseFile(@RequestAttribute AccountVO user, @RequestBody MinioFileInfo fileInfo) {
fileInfo.setType(MinioDirectory.CASE.name());
@PostMapping("/file/save")
public void saveFile(@RequestAttribute AccountVO user, @RequestBody MinioFileInfo fileInfo) {
minioService.saveFileInfo(user, fileInfo);
}
@GetMapping("/file/case/list")
public PageVO<MinioFileInfo> queryCaseFileInfo(PageQueryVO pageVO) {
return minioService.queryFileInfoList(pageVO, MinioDirectory.CASE);
@GetMapping("/file/list")
public PageVO<MinioFileInfo> queryFileInfo(MinioFilePageVO pageVO) {
return minioService.queryFileInfoList(pageVO);
}
@PostMapping("/file/logo/save")
public void saveLogoFile(@RequestAttribute AccountVO user, @RequestBody MinioFileInfo fileInfo) {
fileInfo.setType(MinioDirectory.LOGO.name());
minioService.saveFileInfo(user, fileInfo);
}
@GetMapping("/file/logo/list")
public PageVO<MinioFileInfo> queryLogoFileInfo(PageQueryVO pageVO) {
return minioService.queryFileInfoList(pageVO, MinioDirectory.LOGO);
}
@PutMapping("/file/update")
public void update(@RequestBody MinioFileInfo fileInfo) {
minioService.update(fileInfo);

View File

@ -1,27 +0,0 @@
package club.joylink.rtss.entity.minio;
import lombok.Getter;
/**
* minio文件夹配置
*/
@Getter
public enum MinioDirectory {
CASE("案例展示", "case"),
LOGO("网站logo图片", "logo");
MinioDirectory(String name, String directory) {
this.name = name;
this.directory = directory;
}
/**
* 名称描述
*/
private String name;
/**
* 文件存储MINIO文件夹
*/
private String directory;
}

View File

@ -21,7 +21,7 @@ public class MinioFileInfo {
/**
* 文件所属类型
*/
private String type;
private String directory;
/**
* 文件名称

View File

@ -235,76 +235,6 @@ public class MinioFileInfoExample {
return (Criteria) this;
}
public Criteria andTypeIsNull() {
addCriterion("type is null");
return (Criteria) this;
}
public Criteria andTypeIsNotNull() {
addCriterion("type is not null");
return (Criteria) this;
}
public Criteria andTypeEqualTo(String value) {
addCriterion("type =", value, "type");
return (Criteria) this;
}
public Criteria andTypeNotEqualTo(String value) {
addCriterion("type <>", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThan(String value) {
addCriterion("type >", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThanOrEqualTo(String value) {
addCriterion("type >=", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThan(String value) {
addCriterion("type <", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThanOrEqualTo(String value) {
addCriterion("type <=", value, "type");
return (Criteria) this;
}
public Criteria andTypeLike(String value) {
addCriterion("type like", value, "type");
return (Criteria) this;
}
public Criteria andTypeNotLike(String value) {
addCriterion("type not like", value, "type");
return (Criteria) this;
}
public Criteria andTypeIn(List<String> values) {
addCriterion("type in", values, "type");
return (Criteria) this;
}
public Criteria andTypeNotIn(List<String> values) {
addCriterion("type not in", values, "type");
return (Criteria) this;
}
public Criteria andTypeBetween(String value1, String value2) {
addCriterion("type between", value1, value2, "type");
return (Criteria) this;
}
public Criteria andTypeNotBetween(String value1, String value2) {
addCriterion("type not between", value1, value2, "type");
return (Criteria) this;
}
public Criteria andDirectoryIsNull() {
addCriterion("directory is null");
return (Criteria) this;

View File

@ -1,11 +1,10 @@
package club.joylink.rtss.services;
import club.joylink.rtss.entity.minio.MinioDirectory;
import club.joylink.rtss.entity.minio.MinioFileInfo;
import club.joylink.rtss.util.MinioClientUtil;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.client.PageQueryVO;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.minio.MinioFilePageVO;
public interface MinioService {
/**
@ -21,7 +20,7 @@ public interface MinioService {
/**
* 获取对应的文件列表
*/
PageVO<MinioFileInfo> queryFileInfoList(PageQueryVO pageQueryVO, MinioDirectory directory);
PageVO<MinioFileInfo> queryFileInfoList(MinioFilePageVO pageQueryVO);
/**
* 删除文档

View File

@ -2,17 +2,17 @@ package club.joylink.rtss.services;
import club.joylink.rtss.configuration.MinioClientConfig;
import club.joylink.rtss.dao.minio.MinioFileInfoDao;
import club.joylink.rtss.entity.minio.MinioDirectory;
import club.joylink.rtss.entity.minio.MinioFileInfo;
import club.joylink.rtss.entity.minio.MinioFileInfoExample;
import club.joylink.rtss.util.MinioClientUtil;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.client.PageQueryVO;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.minio.MinioFilePageVO;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.time.LocalDateTime;
import java.util.Map;
@ -47,17 +47,20 @@ public class MinioServiceImpl implements MinioService {
}
@Override
public PageVO<MinioFileInfo> queryFileInfoList(PageQueryVO queryVO, MinioDirectory directory) {
public PageVO<MinioFileInfo> queryFileInfoList(MinioFilePageVO queryVO) {
MinioFileInfoExample example = new MinioFileInfoExample();
MinioFileInfoExample.Criteria criteria = example.createCriteria().andStatusEqualTo(1);
if (directory != null) {
criteria.andTypeEqualTo(directory.name());
if (!StringUtils.isEmpty(queryVO.getDirectory())) {
criteria.andDirectoryEqualTo(queryVO.getDirectory());
}
if (!StringUtils.isEmpty(queryVO.getTitle())) {
criteria.andTitleLike(queryVO.getTitle());
}
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
Page<MinioFileInfo> minioFileInfoPage = (Page<MinioFileInfo>) this.minioFileInfoDao.selectByExample(example);
return PageVO.convert(minioFileInfoPage, minioFileInfoPage.getResult());
}
@Override
public void delete(Long id) {
MinioFileInfo minioFileInfo = new MinioFileInfo();

View File

@ -0,0 +1,17 @@
package club.joylink.rtss.vo.minio;
import club.joylink.rtss.vo.client.PageQueryVO;
import lombok.Data;
@Data
public class MinioFilePageVO extends PageQueryVO {
/**
* 文件文件夹
*/
private String directory;
/**
* 项目title
*/
private String title;
}

View File

@ -4,7 +4,7 @@
<resultMap id="BaseResultMap" type="club.joylink.rtss.entity.minio.MinioFileInfo">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="title" property="title" jdbcType="VARCHAR"/>
<result column="type" property="type" jdbcType="VARCHAR"/>
<result column="directory" property="directory" jdbcType="VARCHAR"/>
<result column="file_name" property="fileName" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="creator" property="creator" jdbcType="BIGINT"/>
@ -71,7 +71,7 @@
</where>
</sql>
<sql id="Base_Column_List">
id, title, type, file_name, create_time, creator, status
id, title, `directory`, file_name, create_time, creator, status
</sql>
<select id="selectByExample" resultMap="BaseResultMap"
parameterType="club.joylink.rtss.entity.minio.MinioFileInfoExample">
@ -101,8 +101,8 @@
</delete>
<insert id="insert" parameterType="club.joylink.rtss.entity.minio.MinioFileInfo" keyColumn="id"
useGeneratedKeys="true" keyProperty="id">
insert into minio_file_info (title, type, file_name, create_time, creator, status)
values (#{title,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{fileName,jdbcType=VARCHAR},
insert into minio_file_info (title, directory, file_name, create_time, creator, status)
values (#{title,jdbcType=VARCHAR}, #{directory,jdbcType=VARCHAR}, #{fileName,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP}, #{creator,jdbcType=BIGINT}, #{status,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="club.joylink.rtss.entity.minio.MinioFileInfo">
@ -114,8 +114,8 @@
<if test="title != null">
title,
</if>
<if test="type != null">
type,
<if test="directory != null">
`directory`,
</if>
<if test="fileName != null">
file_name,
@ -137,8 +137,8 @@
<if test="title != null">
#{title,jdbcType=VARCHAR},
</if>
<if test="type != null">
#{type,jdbcType=VARCHAR},
<if test="directory != null">
#{directory,jdbcType=VARCHAR},
</if>
<if test="fileName != null">
#{fileName,jdbcType=VARCHAR},
@ -163,8 +163,8 @@
<if test="record.title != null">
title = #{record.title,jdbcType=VARCHAR},
</if>
<if test="record.type != null">
type = #{record.type,jdbcType=VARCHAR},
<if test="record.directory != null">
type = #{record.directory,jdbcType=VARCHAR},
</if>
<if test="record.fileName != null">
file_name = #{record.fileName,jdbcType=VARCHAR},
@ -187,7 +187,7 @@
update minio_file_info
set id = #{record.id,jdbcType=BIGINT},
title = #{record.title,jdbcType=VARCHAR},
type = #{record.type,jdbcType=VARCHAR},
`directory` = #{record.directory,jdbcType=VARCHAR},
file_name = #{record.fileName,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
creator = #{record.creator,jdbcType=BIGINT},
@ -202,8 +202,8 @@
<if test="title != null">
title = #{title,jdbcType=VARCHAR},
</if>
<if test="type != null">
type = #{type,jdbcType=VARCHAR},
<if test="directory != null">
`directory` = #{directory,jdbcType=VARCHAR},
</if>
<if test="fileName != null">
file_name = #{fileName,jdbcType=VARCHAR},
@ -223,7 +223,7 @@
<update id="updateByPrimaryKey" parameterType="club.joylink.rtss.entity.minio.MinioFileInfo">
update minio_file_info
set title = #{title,jdbcType=VARCHAR},
type = #{type,jdbcType=VARCHAR},
`directory` = #{directory,jdbcType=VARCHAR},
file_name = #{fileName,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
creator = #{creator,jdbcType=BIGINT},