将文件信息和文件内容分成两个表

This commit is contained in:
haifeng414 2020-02-17 17:32:47 +08:00
parent a5de8cebbb
commit e7bbfe074d
16 changed files with 656 additions and 392 deletions

View File

@ -0,0 +1,27 @@
package io.metersphere.base.domain;
import java.io.Serializable;
public class FileContent implements Serializable {
private String id;
private String file;
private static final long serialVersionUID = 1L;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id == null ? null : id.trim();
}
public String getFile() {
return file;
}
public void setFile(String file) {
this.file = file == null ? null : file.trim();
}
}

View File

@ -0,0 +1,270 @@
package io.metersphere.base.domain;
import java.util.ArrayList;
import java.util.List;
public class FileContentExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public FileContentExample() {
oredCriteria = new ArrayList<Criteria>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(String value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(String value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(String value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(String value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(String value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(String value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdLike(String value) {
addCriterion("id like", value, "id");
return (Criteria) this;
}
public Criteria andIdNotLike(String value) {
addCriterion("id not like", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<String> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<String> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(String value1, String value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(String value1, String value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}

View File

@ -2,13 +2,11 @@ package io.metersphere.base.domain;
import java.io.Serializable;
public class FileStore implements Serializable {
public class FileMetadata implements Serializable {
private String id;
private String name;
private String description;
private String type;
private Long size;
@ -17,8 +15,6 @@ public class FileStore implements Serializable {
private Long updateTime;
private String file;
private static final long serialVersionUID = 1L;
public String getId() {
@ -37,14 +33,6 @@ public class FileStore implements Serializable {
this.name = name == null ? null : name.trim();
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description == null ? null : description.trim();
}
public String getType() {
return type;
}
@ -76,12 +64,4 @@ public class FileStore implements Serializable {
public void setUpdateTime(Long updateTime) {
this.updateTime = updateTime;
}
public String getFile() {
return file;
}
public void setFile(String file) {
this.file = file == null ? null : file.trim();
}
}

View File

@ -3,14 +3,14 @@ package io.metersphere.base.domain;
import java.util.ArrayList;
import java.util.List;
public class FileStoreExample {
public class FileMetadataExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public FileStoreExample() {
public FileMetadataExample() {
oredCriteria = new ArrayList<Criteria>();
}
@ -244,76 +244,6 @@ public class FileStoreExample {
return (Criteria) this;
}
public Criteria andDescriptionIsNull() {
addCriterion("description is null");
return (Criteria) this;
}
public Criteria andDescriptionIsNotNull() {
addCriterion("description is not null");
return (Criteria) this;
}
public Criteria andDescriptionEqualTo(String value) {
addCriterion("description =", value, "description");
return (Criteria) this;
}
public Criteria andDescriptionNotEqualTo(String value) {
addCriterion("description <>", value, "description");
return (Criteria) this;
}
public Criteria andDescriptionGreaterThan(String value) {
addCriterion("description >", value, "description");
return (Criteria) this;
}
public Criteria andDescriptionGreaterThanOrEqualTo(String value) {
addCriterion("description >=", value, "description");
return (Criteria) this;
}
public Criteria andDescriptionLessThan(String value) {
addCriterion("description <", value, "description");
return (Criteria) this;
}
public Criteria andDescriptionLessThanOrEqualTo(String value) {
addCriterion("description <=", value, "description");
return (Criteria) this;
}
public Criteria andDescriptionLike(String value) {
addCriterion("description like", value, "description");
return (Criteria) this;
}
public Criteria andDescriptionNotLike(String value) {
addCriterion("description not like", value, "description");
return (Criteria) this;
}
public Criteria andDescriptionIn(List<String> values) {
addCriterion("description in", values, "description");
return (Criteria) this;
}
public Criteria andDescriptionNotIn(List<String> values) {
addCriterion("description not in", values, "description");
return (Criteria) this;
}
public Criteria andDescriptionBetween(String value1, String value2) {
addCriterion("description between", value1, value2, "description");
return (Criteria) this;
}
public Criteria andDescriptionNotBetween(String value1, String value2) {
addCriterion("description not between", value1, value2, "description");
return (Criteria) this;
}
public Criteria andTypeIsNull() {
addCriterion("type is null");
return (Criteria) this;

View File

@ -2,13 +2,11 @@ package io.metersphere.base.domain;
import java.io.Serializable;
public class FileStoreResource implements Serializable {
public class LoadTestFile implements Serializable {
private String testId;
private String fileId;
private String fileType;
private static final long serialVersionUID = 1L;
public String getTestId() {
@ -26,12 +24,4 @@ public class FileStoreResource implements Serializable {
public void setFileId(String fileId) {
this.fileId = fileId == null ? null : fileId.trim();
}
public String getFileType() {
return fileType;
}
public void setFileType(String fileType) {
this.fileType = fileType == null ? null : fileType.trim();
}
}

View File

@ -3,14 +3,14 @@ package io.metersphere.base.domain;
import java.util.ArrayList;
import java.util.List;
public class FileStoreResourceExample {
public class LoadTestFileExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public FileStoreResourceExample() {
public LoadTestFileExample() {
oredCriteria = new ArrayList<Criteria>();
}
@ -243,76 +243,6 @@ public class FileStoreResourceExample {
addCriterion("file_id not between", value1, value2, "fileId");
return (Criteria) this;
}
public Criteria andFileTypeIsNull() {
addCriterion("file_type is null");
return (Criteria) this;
}
public Criteria andFileTypeIsNotNull() {
addCriterion("file_type is not null");
return (Criteria) this;
}
public Criteria andFileTypeEqualTo(String value) {
addCriterion("file_type =", value, "fileType");
return (Criteria) this;
}
public Criteria andFileTypeNotEqualTo(String value) {
addCriterion("file_type <>", value, "fileType");
return (Criteria) this;
}
public Criteria andFileTypeGreaterThan(String value) {
addCriterion("file_type >", value, "fileType");
return (Criteria) this;
}
public Criteria andFileTypeGreaterThanOrEqualTo(String value) {
addCriterion("file_type >=", value, "fileType");
return (Criteria) this;
}
public Criteria andFileTypeLessThan(String value) {
addCriterion("file_type <", value, "fileType");
return (Criteria) this;
}
public Criteria andFileTypeLessThanOrEqualTo(String value) {
addCriterion("file_type <=", value, "fileType");
return (Criteria) this;
}
public Criteria andFileTypeLike(String value) {
addCriterion("file_type like", value, "fileType");
return (Criteria) this;
}
public Criteria andFileTypeNotLike(String value) {
addCriterion("file_type not like", value, "fileType");
return (Criteria) this;
}
public Criteria andFileTypeIn(List<String> values) {
addCriterion("file_type in", values, "fileType");
return (Criteria) this;
}
public Criteria andFileTypeNotIn(List<String> values) {
addCriterion("file_type not in", values, "fileType");
return (Criteria) this;
}
public Criteria andFileTypeBetween(String value1, String value2) {
addCriterion("file_type between", value1, value2, "fileType");
return (Criteria) this;
}
public Criteria andFileTypeNotBetween(String value1, String value2) {
addCriterion("file_type not between", value1, value2, "fileType");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {

View File

@ -0,0 +1,34 @@
package io.metersphere.base.mapper;
import io.metersphere.base.domain.FileContent;
import io.metersphere.base.domain.FileContentExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface FileContentMapper {
long countByExample(FileContentExample example);
int deleteByExample(FileContentExample example);
int deleteByPrimaryKey(String id);
int insert(FileContent record);
int insertSelective(FileContent record);
List<FileContent> selectByExampleWithBLOBs(FileContentExample example);
List<FileContent> selectByExample(FileContentExample example);
FileContent selectByPrimaryKey(String id);
int updateByExampleSelective(@Param("record") FileContent record, @Param("example") FileContentExample example);
int updateByExampleWithBLOBs(@Param("record") FileContent record, @Param("example") FileContentExample example);
int updateByExample(@Param("record") FileContent record, @Param("example") FileContentExample example);
int updateByPrimaryKeySelective(FileContent record);
int updateByPrimaryKeyWithBLOBs(FileContent record);
}

View File

@ -0,0 +1,194 @@
<?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="io.metersphere.base.mapper.FileContentMapper">
<resultMap id="BaseResultMap" type="io.metersphere.base.domain.FileContent">
<id column="id" jdbcType="VARCHAR" property="id" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.FileContent">
<result column="file" jdbcType="LONGVARCHAR" property="file" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id
</sql>
<sql id="Blob_Column_List">
file
</sql>
<select id="selectByExampleWithBLOBs" parameterType="io.metersphere.base.domain.FileContentExample" resultMap="ResultMapWithBLOBs">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from file_content
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByExample" parameterType="io.metersphere.base.domain.FileContentExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from file_content
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="ResultMapWithBLOBs">
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from file_content
where id = #{id,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from file_content
where id = #{id,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="io.metersphere.base.domain.FileContentExample">
delete from file_content
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="io.metersphere.base.domain.FileContent">
insert into file_content (id, file)
values (#{id,jdbcType=VARCHAR}, #{file,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.FileContent">
insert into file_content
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="file != null">
file,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=VARCHAR},
</if>
<if test="file != null">
#{file,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.FileContentExample" resultType="java.lang.Long">
select count(*) from file_content
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update file_content
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=VARCHAR},
</if>
<if test="record.file != null">
file = #{record.file,jdbcType=LONGVARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExampleWithBLOBs" parameterType="map">
update file_content
set id = #{record.id,jdbcType=VARCHAR},
file = #{record.file,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update file_content
set id = #{record.id,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.base.domain.FileContent">
update file_content
<set>
<if test="file != null">
file = #{file,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="io.metersphere.base.domain.FileContent">
update file_content
set file = #{file,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>

View File

@ -0,0 +1,30 @@
package io.metersphere.base.mapper;
import io.metersphere.base.domain.FileMetadata;
import io.metersphere.base.domain.FileMetadataExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface FileMetadataMapper {
long countByExample(FileMetadataExample example);
int deleteByExample(FileMetadataExample example);
int deleteByPrimaryKey(String id);
int insert(FileMetadata record);
int insertSelective(FileMetadata record);
List<FileMetadata> selectByExample(FileMetadataExample example);
FileMetadata selectByPrimaryKey(String id);
int updateByExampleSelective(@Param("record") FileMetadata record, @Param("example") FileMetadataExample example);
int updateByExample(@Param("record") FileMetadata record, @Param("example") FileMetadataExample example);
int updateByPrimaryKeySelective(FileMetadata record);
int updateByPrimaryKey(FileMetadata record);
}

View File

@ -1,18 +1,14 @@
<?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="io.metersphere.base.mapper.FileStoreMapper">
<resultMap id="BaseResultMap" type="io.metersphere.base.domain.FileStore">
<mapper namespace="io.metersphere.base.mapper.FileMetadataMapper">
<resultMap id="BaseResultMap" type="io.metersphere.base.domain.FileMetadata">
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="description" jdbcType="VARCHAR" property="description" />
<result column="type" jdbcType="VARCHAR" property="type" />
<result column="size" jdbcType="BIGINT" property="size" />
<result column="create_time" jdbcType="BIGINT" property="createTime" />
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.FileStore">
<result column="file" jdbcType="LONGVARCHAR" property="file" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
@ -72,20 +68,15 @@
</where>
</sql>
<sql id="Base_Column_List">
id, name, description, type, size, create_time, update_time
id, name, type, size, create_time, update_time
</sql>
<sql id="Blob_Column_List">
file
</sql>
<select id="selectByExampleWithBLOBs" parameterType="io.metersphere.base.domain.FileStoreExample" resultMap="ResultMapWithBLOBs">
<select id="selectByExample" parameterType="io.metersphere.base.domain.FileMetadataExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from file_store
from file_metadata
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
@ -93,48 +84,32 @@
order by ${orderByClause}
</if>
</select>
<select id="selectByExample" parameterType="io.metersphere.base.domain.FileStoreExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from file_store
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="ResultMapWithBLOBs">
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from file_store
from file_metadata
where id = #{id,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from file_store
delete from file_metadata
where id = #{id,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="io.metersphere.base.domain.FileStoreExample">
delete from file_store
<delete id="deleteByExample" parameterType="io.metersphere.base.domain.FileMetadataExample">
delete from file_metadata
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="io.metersphere.base.domain.FileStore">
insert into file_store (id, name, description,
type, size, create_time,
update_time, file)
values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR},
#{type,jdbcType=VARCHAR}, #{size,jdbcType=BIGINT}, #{createTime,jdbcType=BIGINT},
#{updateTime,jdbcType=BIGINT}, #{file,jdbcType=LONGVARCHAR})
<insert id="insert" parameterType="io.metersphere.base.domain.FileMetadata">
insert into file_metadata (id, name, type,
size, create_time, update_time
)
values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR},
#{size,jdbcType=BIGINT}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}
)
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.FileStore">
insert into file_store
<insert id="insertSelective" parameterType="io.metersphere.base.domain.FileMetadata">
insert into file_metadata
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
@ -142,9 +117,6 @@
<if test="name != null">
name,
</if>
<if test="description != null">
description,
</if>
<if test="type != null">
type,
</if>
@ -157,9 +129,6 @@
<if test="updateTime != null">
update_time,
</if>
<if test="file != null">
file,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
@ -168,9 +137,6 @@
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="description != null">
#{description,jdbcType=VARCHAR},
</if>
<if test="type != null">
#{type,jdbcType=VARCHAR},
</if>
@ -183,19 +149,16 @@
<if test="updateTime != null">
#{updateTime,jdbcType=BIGINT},
</if>
<if test="file != null">
#{file,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.FileStoreExample" resultType="java.lang.Long">
select count(*) from file_store
<select id="countByExample" parameterType="io.metersphere.base.domain.FileMetadataExample" resultType="java.lang.Long">
select count(*) from file_metadata
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update file_store
update file_metadata
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=VARCHAR},
@ -203,9 +166,6 @@
<if test="record.name != null">
name = #{record.name,jdbcType=VARCHAR},
</if>
<if test="record.description != null">
description = #{record.description,jdbcType=VARCHAR},
</if>
<if test="record.type != null">
type = #{record.type,jdbcType=VARCHAR},
</if>
@ -218,33 +178,15 @@
<if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=BIGINT},
</if>
<if test="record.file != null">
file = #{record.file,jdbcType=LONGVARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExampleWithBLOBs" parameterType="map">
update file_store
set id = #{record.id,jdbcType=VARCHAR},
name = #{record.name,jdbcType=VARCHAR},
description = #{record.description,jdbcType=VARCHAR},
type = #{record.type,jdbcType=VARCHAR},
size = #{record.size,jdbcType=BIGINT},
create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT},
file = #{record.file,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update file_store
update file_metadata
set id = #{record.id,jdbcType=VARCHAR},
name = #{record.name,jdbcType=VARCHAR},
description = #{record.description,jdbcType=VARCHAR},
type = #{record.type,jdbcType=VARCHAR},
size = #{record.size,jdbcType=BIGINT},
create_time = #{record.createTime,jdbcType=BIGINT},
@ -253,15 +195,12 @@
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.base.domain.FileStore">
update file_store
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.base.domain.FileMetadata">
update file_metadata
<set>
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="description != null">
description = #{description,jdbcType=VARCHAR},
</if>
<if test="type != null">
type = #{type,jdbcType=VARCHAR},
</if>
@ -274,27 +213,12 @@
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=BIGINT},
</if>
<if test="file != null">
file = #{file,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="io.metersphere.base.domain.FileStore">
update file_store
<update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.FileMetadata">
update file_metadata
set name = #{name,jdbcType=VARCHAR},
description = #{description,jdbcType=VARCHAR},
type = #{type,jdbcType=VARCHAR},
size = #{size,jdbcType=BIGINT},
create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT},
file = #{file,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.FileStore">
update file_store
set name = #{name,jdbcType=VARCHAR},
description = #{description,jdbcType=VARCHAR},
type = #{type,jdbcType=VARCHAR},
size = #{size,jdbcType=BIGINT},
create_time = #{createTime,jdbcType=BIGINT},

View File

@ -1,36 +0,0 @@
package io.metersphere.base.mapper;
import io.metersphere.base.domain.FileStore;
import io.metersphere.base.domain.FileStoreExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface FileStoreMapper {
long countByExample(FileStoreExample example);
int deleteByExample(FileStoreExample example);
int deleteByPrimaryKey(String id);
int insert(FileStore record);
int insertSelective(FileStore record);
List<FileStore> selectByExampleWithBLOBs(FileStoreExample example);
List<FileStore> selectByExample(FileStoreExample example);
FileStore selectByPrimaryKey(String id);
int updateByExampleSelective(@Param("record") FileStore record, @Param("example") FileStoreExample example);
int updateByExampleWithBLOBs(@Param("record") FileStore record, @Param("example") FileStoreExample example);
int updateByExample(@Param("record") FileStore record, @Param("example") FileStoreExample example);
int updateByPrimaryKeySelective(FileStore record);
int updateByPrimaryKeyWithBLOBs(FileStore record);
int updateByPrimaryKey(FileStore record);
}

View File

@ -1,22 +0,0 @@
package io.metersphere.base.mapper;
import io.metersphere.base.domain.FileStoreResource;
import io.metersphere.base.domain.FileStoreResourceExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface FileStoreResourceMapper {
long countByExample(FileStoreResourceExample example);
int deleteByExample(FileStoreResourceExample example);
int insert(FileStoreResource record);
int insertSelective(FileStoreResource record);
List<FileStoreResource> selectByExample(FileStoreResourceExample example);
int updateByExampleSelective(@Param("record") FileStoreResource record, @Param("example") FileStoreResourceExample example);
int updateByExample(@Param("record") FileStoreResource record, @Param("example") FileStoreResourceExample example);
}

View File

@ -0,0 +1,22 @@
package io.metersphere.base.mapper;
import io.metersphere.base.domain.LoadTestFile;
import io.metersphere.base.domain.LoadTestFileExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface LoadTestFileMapper {
long countByExample(LoadTestFileExample example);
int deleteByExample(LoadTestFileExample example);
int insert(LoadTestFile record);
int insertSelective(LoadTestFile record);
List<LoadTestFile> selectByExample(LoadTestFileExample example);
int updateByExampleSelective(@Param("record") LoadTestFile record, @Param("example") LoadTestFileExample example);
int updateByExample(@Param("record") LoadTestFile record, @Param("example") LoadTestFileExample example);
}

View File

@ -1,10 +1,9 @@
<?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="io.metersphere.base.mapper.FileStoreResourceMapper">
<resultMap id="BaseResultMap" type="io.metersphere.base.domain.FileStoreResource">
<mapper namespace="io.metersphere.base.mapper.LoadTestFileMapper">
<resultMap id="BaseResultMap" type="io.metersphere.base.domain.LoadTestFile">
<result column="test_id" jdbcType="VARCHAR" property="testId" />
<result column="file_id" jdbcType="VARCHAR" property="fileId" />
<result column="file_type" jdbcType="VARCHAR" property="fileType" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
@ -65,15 +64,15 @@
</where>
</sql>
<sql id="Base_Column_List">
test_id, file_id, file_type
test_id, file_id
</sql>
<select id="selectByExample" parameterType="io.metersphere.base.domain.FileStoreResourceExample" resultMap="BaseResultMap">
<select id="selectByExample" parameterType="io.metersphere.base.domain.LoadTestFileExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from file_store_resource
from load_test_file
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
@ -81,20 +80,18 @@
order by ${orderByClause}
</if>
</select>
<delete id="deleteByExample" parameterType="io.metersphere.base.domain.FileStoreResourceExample">
delete from file_store_resource
<delete id="deleteByExample" parameterType="io.metersphere.base.domain.LoadTestFileExample">
delete from load_test_file
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="io.metersphere.base.domain.FileStoreResource">
insert into file_store_resource (test_id, file_id, file_type
)
values (#{testId,jdbcType=VARCHAR}, #{fileId,jdbcType=VARCHAR}, #{fileType,jdbcType=VARCHAR}
)
<insert id="insert" parameterType="io.metersphere.base.domain.LoadTestFile">
insert into load_test_file (test_id, file_id)
values (#{testId,jdbcType=VARCHAR}, #{fileId,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.FileStoreResource">
insert into file_store_resource
<insert id="insertSelective" parameterType="io.metersphere.base.domain.LoadTestFile">
insert into load_test_file
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="testId != null">
test_id,
@ -102,9 +99,6 @@
<if test="fileId != null">
file_id,
</if>
<if test="fileType != null">
file_type,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="testId != null">
@ -113,19 +107,16 @@
<if test="fileId != null">
#{fileId,jdbcType=VARCHAR},
</if>
<if test="fileType != null">
#{fileType,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.FileStoreResourceExample" resultType="java.lang.Long">
select count(*) from file_store_resource
<select id="countByExample" parameterType="io.metersphere.base.domain.LoadTestFileExample" resultType="java.lang.Long">
select count(*) from load_test_file
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update file_store_resource
update load_test_file
<set>
<if test="record.testId != null">
test_id = #{record.testId,jdbcType=VARCHAR},
@ -133,19 +124,15 @@
<if test="record.fileId != null">
file_id = #{record.fileId,jdbcType=VARCHAR},
</if>
<if test="record.fileType != null">
file_type = #{record.fileType,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update file_store_resource
update load_test_file
set test_id = #{record.testId,jdbcType=VARCHAR},
file_id = #{record.fileId,jdbcType=VARCHAR},
file_type = #{record.fileType,jdbcType=VARCHAR}
file_id = #{record.fileId,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>

View File

@ -1,10 +1,7 @@
package io.metersphere.service;
import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.FileStoreMapper;
import io.metersphere.base.mapper.FileStoreResourceMapper;
import io.metersphere.base.mapper.LoadTestMapper;
import io.metersphere.base.mapper.ProjectMapper;
import io.metersphere.base.mapper.*;
import io.metersphere.base.mapper.ext.ExtLoadTestMapper;
import io.metersphere.commons.constants.LoadTestFileType;
import io.metersphere.commons.exception.MSException;
@ -36,9 +33,11 @@ public class LoadTestService {
@Resource
private ProjectMapper projectMapper;
@Resource
private FileStoreMapper fileStoreMapper;
private FileMetadataMapper fileMetadataMapper;
@Resource
private FileStoreResourceMapper fileStoreResourceMapper;
private FileContentMapper fileContentMapper;
@Resource
private LoadTestFileMapper loadTestFileMapper;
// 测试模拟数据
@PostConstruct
@ -78,15 +77,14 @@ public class LoadTestService {
throw new IllegalArgumentException("文件不能为空!");
}
final FileStore fileStore = saveFileStore(file);
final FileMetadata fileMetadata = saveFile(file);
final LoadTestWithBLOBs loadTest = saveLoadTest(request);
FileStoreResource fileStoreResource = new FileStoreResource();
fileStoreResource.setTestId(loadTest.getId());
fileStoreResource.setFileId(fileStore.getId());
fileStoreResource.setFileType(fileStore.getType());
fileStoreResourceMapper.insert(fileStoreResource);
LoadTestFile loadTestFile = new LoadTestFile();
loadTestFile.setTestId(loadTest.getId());
loadTestFile.setFileId(fileMetadata.getId());
loadTestFileMapper.insert(loadTestFile);
}
private LoadTestWithBLOBs saveLoadTest(SaveTestPlanRequest request) {
@ -102,20 +100,25 @@ public class LoadTestService {
return loadTest;
}
private FileStore saveFileStore(MultipartFile file) {
final FileStore fileStore = new FileStore();
fileStore.setId(UUID.randomUUID().toString());
fileStore.setName(file.getOriginalFilename());
fileStore.setSize(file.getSize());
fileStore.setCreateTime(System.currentTimeMillis());
fileStore.setUpdateTime(System.currentTimeMillis());
fileStore.setType(LoadTestFileType.JMX.name());
private FileMetadata saveFile(MultipartFile file) {
final FileMetadata fileMetadata = new FileMetadata();
fileMetadata.setId(UUID.randomUUID().toString());
fileMetadata.setName(file.getOriginalFilename());
fileMetadata.setSize(file.getSize());
fileMetadata.setCreateTime(System.currentTimeMillis());
fileMetadata.setUpdateTime(System.currentTimeMillis());
fileMetadata.setType(LoadTestFileType.JMX.name());
fileMetadataMapper.insert(fileMetadata);
FileContent fileContent = new FileContent();
fileContent.setId(fileMetadata.getId());
try {
fileStore.setFile(IOUtils.toString(file.getInputStream(), StandardCharsets.UTF_8));
fileContent.setFile(IOUtils.toString(file.getInputStream(), StandardCharsets.UTF_8));
} catch (IOException e) {
MSException.throwException(e);
}
fileStoreMapper.insert(fileStore);
return fileStore;
fileContentMapper.insert(fileContent);
return fileMetadata;
}
}

View File

@ -56,7 +56,8 @@
<table tableName="organization"/>
<table tableName="load_test_report"/>
<table tableName="load_test"/>
<table tableName="file_store"/>
<table tableName="file_store_resource"/>
<table tableName="file_content"/>
<table tableName="file_metadata"/>
<table tableName="load_test_file"/>
</context>
</generatorConfiguration>