上传的文件保存到数据库
This commit is contained in:
parent
1862341e94
commit
54ad67d899
|
@ -17,7 +17,7 @@ public class FileStore implements Serializable {
|
|||
|
||||
private Long updateTime;
|
||||
|
||||
private byte[] file;
|
||||
private String file;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
@ -77,11 +77,11 @@ public class FileStore implements Serializable {
|
|||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public byte[] getFile() {
|
||||
public String getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
public void setFile(byte[] file) {
|
||||
this.file = file;
|
||||
public void setFile(String file) {
|
||||
this.file = file == null ? null : file.trim();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package io.metersphere.base.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class FileStoreResource implements Serializable {
|
||||
private String testId;
|
||||
|
||||
private String fileId;
|
||||
|
||||
private String fileType;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public String getTestId() {
|
||||
return testId;
|
||||
}
|
||||
|
||||
public void setTestId(String testId) {
|
||||
this.testId = testId == null ? null : testId.trim();
|
||||
}
|
||||
|
||||
public String getFileId() {
|
||||
return fileId;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,410 @@
|
|||
package io.metersphere.base.domain;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class FileStoreResourceExample {
|
||||
protected String orderByClause;
|
||||
|
||||
protected boolean distinct;
|
||||
|
||||
protected List<Criteria> oredCriteria;
|
||||
|
||||
public FileStoreResourceExample() {
|
||||
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 andTestIdIsNull() {
|
||||
addCriterion("test_id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTestIdIsNotNull() {
|
||||
addCriterion("test_id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTestIdEqualTo(String value) {
|
||||
addCriterion("test_id =", value, "testId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTestIdNotEqualTo(String value) {
|
||||
addCriterion("test_id <>", value, "testId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTestIdGreaterThan(String value) {
|
||||
addCriterion("test_id >", value, "testId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTestIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("test_id >=", value, "testId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTestIdLessThan(String value) {
|
||||
addCriterion("test_id <", value, "testId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTestIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("test_id <=", value, "testId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTestIdLike(String value) {
|
||||
addCriterion("test_id like", value, "testId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTestIdNotLike(String value) {
|
||||
addCriterion("test_id not like", value, "testId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTestIdIn(List<String> values) {
|
||||
addCriterion("test_id in", values, "testId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTestIdNotIn(List<String> values) {
|
||||
addCriterion("test_id not in", values, "testId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTestIdBetween(String value1, String value2) {
|
||||
addCriterion("test_id between", value1, value2, "testId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTestIdNotBetween(String value1, String value2) {
|
||||
addCriterion("test_id not between", value1, value2, "testId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFileIdIsNull() {
|
||||
addCriterion("file_id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFileIdIsNotNull() {
|
||||
addCriterion("file_id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFileIdEqualTo(String value) {
|
||||
addCriterion("file_id =", value, "fileId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFileIdNotEqualTo(String value) {
|
||||
addCriterion("file_id <>", value, "fileId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFileIdGreaterThan(String value) {
|
||||
addCriterion("file_id >", value, "fileId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFileIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("file_id >=", value, "fileId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFileIdLessThan(String value) {
|
||||
addCriterion("file_id <", value, "fileId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFileIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("file_id <=", value, "fileId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFileIdLike(String value) {
|
||||
addCriterion("file_id like", value, "fileId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFileIdNotLike(String value) {
|
||||
addCriterion("file_id not like", value, "fileId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFileIdIn(List<String> values) {
|
||||
addCriterion("file_id in", values, "fileId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFileIdNotIn(List<String> values) {
|
||||
addCriterion("file_id not in", values, "fileId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFileIdBetween(String value1, String value2) {
|
||||
addCriterion("file_id between", value1, value2, "fileId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFileIdNotBetween(String value1, String value2) {
|
||||
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 {
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,9 +2,8 @@ package io.metersphere.base.mapper;
|
|||
|
||||
import io.metersphere.base.domain.FileStore;
|
||||
import io.metersphere.base.domain.FileStoreExample;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface FileStoreMapper {
|
||||
long countByExample(FileStoreExample example);
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
|
||||
</resultMap>
|
||||
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.FileStore">
|
||||
<result column="file" jdbcType="LONGVARBINARY" property="file" />
|
||||
<result column="file" jdbcType="LONGVARCHAR" property="file" />
|
||||
</resultMap>
|
||||
<sql id="Example_Where_Clause">
|
||||
<where>
|
||||
|
@ -131,7 +131,7 @@
|
|||
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=LONGVARBINARY})
|
||||
#{updateTime,jdbcType=BIGINT}, #{file,jdbcType=LONGVARCHAR})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="io.metersphere.base.domain.FileStore">
|
||||
insert into file_store
|
||||
|
@ -184,7 +184,7 @@
|
|||
#{updateTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="file != null">
|
||||
#{file,jdbcType=LONGVARBINARY},
|
||||
#{file,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
@ -219,7 +219,7 @@
|
|||
update_time = #{record.updateTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="record.file != null">
|
||||
file = #{record.file,jdbcType=LONGVARBINARY},
|
||||
file = #{record.file,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
<if test="_parameter != null">
|
||||
|
@ -235,7 +235,7 @@
|
|||
size = #{record.size,jdbcType=BIGINT},
|
||||
create_time = #{record.createTime,jdbcType=BIGINT},
|
||||
update_time = #{record.updateTime,jdbcType=BIGINT},
|
||||
file = #{record.file,jdbcType=LONGVARBINARY}
|
||||
file = #{record.file,jdbcType=LONGVARCHAR}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
|
@ -275,7 +275,7 @@
|
|||
update_time = #{updateTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="file != null">
|
||||
file = #{file,jdbcType=LONGVARBINARY},
|
||||
file = #{file,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
|
@ -288,7 +288,7 @@
|
|||
size = #{size,jdbcType=BIGINT},
|
||||
create_time = #{createTime,jdbcType=BIGINT},
|
||||
update_time = #{updateTime,jdbcType=BIGINT},
|
||||
file = #{file,jdbcType=LONGVARBINARY}
|
||||
file = #{file,jdbcType=LONGVARCHAR}
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.FileStore">
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
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);
|
||||
}
|
|
@ -0,0 +1,153 @@
|
|||
<?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">
|
||||
<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>
|
||||
<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">
|
||||
test_id, file_id, file_type
|
||||
</sql>
|
||||
<select id="selectByExample" parameterType="io.metersphere.base.domain.FileStoreResourceExample" resultMap="BaseResultMap">
|
||||
select
|
||||
<if test="distinct">
|
||||
distinct
|
||||
</if>
|
||||
<include refid="Base_Column_List" />
|
||||
from file_store_resource
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
<if test="orderByClause != null">
|
||||
order by ${orderByClause}
|
||||
</if>
|
||||
</select>
|
||||
<delete id="deleteByExample" parameterType="io.metersphere.base.domain.FileStoreResourceExample">
|
||||
delete from file_store_resource
|
||||
<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>
|
||||
<insert id="insertSelective" parameterType="io.metersphere.base.domain.FileStoreResource">
|
||||
insert into file_store_resource
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="testId != null">
|
||||
test_id,
|
||||
</if>
|
||||
<if test="fileId != null">
|
||||
file_id,
|
||||
</if>
|
||||
<if test="fileType != null">
|
||||
file_type,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="testId != null">
|
||||
#{testId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<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
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</select>
|
||||
<update id="updateByExampleSelective" parameterType="map">
|
||||
update file_store_resource
|
||||
<set>
|
||||
<if test="record.testId != null">
|
||||
test_id = #{record.testId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<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
|
||||
set test_id = #{record.testId,jdbcType=VARCHAR},
|
||||
file_id = #{record.fileId,jdbcType=VARCHAR},
|
||||
file_type = #{record.fileType,jdbcType=VARCHAR}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
</mapper>
|
|
@ -3,9 +3,8 @@ package io.metersphere.base.mapper;
|
|||
import io.metersphere.base.domain.LoadTest;
|
||||
import io.metersphere.base.domain.LoadTestExample;
|
||||
import io.metersphere.base.domain.LoadTestWithBLOBs;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface LoadTestMapper {
|
||||
long countByExample(LoadTestExample example);
|
||||
|
|
|
@ -2,9 +2,8 @@ package io.metersphere.base.mapper;
|
|||
|
||||
import io.metersphere.base.domain.LoadTestReport;
|
||||
import io.metersphere.base.domain.LoadTestReportExample;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface LoadTestReportMapper {
|
||||
long countByExample(LoadTestReportExample example);
|
||||
|
|
|
@ -2,9 +2,8 @@ package io.metersphere.base.mapper;
|
|||
|
||||
import io.metersphere.base.domain.Organization;
|
||||
import io.metersphere.base.domain.OrganizationExample;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface OrganizationMapper {
|
||||
long countByExample(OrganizationExample example);
|
||||
|
|
|
@ -2,9 +2,8 @@ package io.metersphere.base.mapper;
|
|||
|
||||
import io.metersphere.base.domain.Project;
|
||||
import io.metersphere.base.domain.ProjectExample;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface ProjectMapper {
|
||||
long countByExample(ProjectExample example);
|
||||
|
|
|
@ -2,9 +2,8 @@ package io.metersphere.base.mapper;
|
|||
|
||||
import io.metersphere.base.domain.Role;
|
||||
import io.metersphere.base.domain.RoleExample;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface RoleMapper {
|
||||
long countByExample(RoleExample example);
|
||||
|
|
|
@ -2,9 +2,8 @@ package io.metersphere.base.mapper;
|
|||
|
||||
import io.metersphere.base.domain.SystemParameter;
|
||||
import io.metersphere.base.domain.SystemParameterExample;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface SystemParameterMapper {
|
||||
long countByExample(SystemParameterExample example);
|
||||
|
|
|
@ -2,9 +2,8 @@ package io.metersphere.base.mapper;
|
|||
|
||||
import io.metersphere.base.domain.TestResource;
|
||||
import io.metersphere.base.domain.TestResourceExample;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface TestResourceMapper {
|
||||
long countByExample(TestResourceExample example);
|
||||
|
|
|
@ -2,9 +2,8 @@ package io.metersphere.base.mapper;
|
|||
|
||||
import io.metersphere.base.domain.TestResourcePool;
|
||||
import io.metersphere.base.domain.TestResourcePoolExample;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface TestResourcePoolMapper {
|
||||
long countByExample(TestResourcePoolExample example);
|
||||
|
|
|
@ -2,9 +2,8 @@ package io.metersphere.base.mapper;
|
|||
|
||||
import io.metersphere.base.domain.Workspace;
|
||||
import io.metersphere.base.domain.WorkspaceExample;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface WorkspaceMapper {
|
||||
long countByExample(WorkspaceExample example);
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package io.metersphere.commons.constants;
|
||||
|
||||
public enum LoadTestFileType {
|
||||
JMX
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package io.metersphere.commons.utils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
public class IOUtils {
|
||||
public static String toString(InputStream inputStream, Charset charset) throws IOException {
|
||||
final int bufferSize = 1024;
|
||||
final char[] buffer = new char[bufferSize];
|
||||
final StringBuilder out = new StringBuilder();
|
||||
Reader in = new InputStreamReader(inputStream, charset);
|
||||
|
||||
int charsRead;
|
||||
while ((charsRead = in.read(buffer, 0, buffer.length)) > 0) {
|
||||
out.append(buffer, 0, charsRead);
|
||||
}
|
||||
|
||||
return out.toString();
|
||||
}
|
||||
}
|
|
@ -36,9 +36,12 @@ public class LoadTestController {
|
|||
return PageUtils.setPageInfo(page, loadTestService.list(request));
|
||||
}
|
||||
|
||||
@PostMapping("/save")
|
||||
public void save(@RequestBody SaveTestPlanRequest request) {
|
||||
loadTestService.save(request);
|
||||
@PostMapping(value = "/save", consumes = {"multipart/form-data"})
|
||||
public void save(
|
||||
@RequestPart("request") SaveTestPlanRequest request,
|
||||
@RequestPart("file") MultipartFile file
|
||||
) {
|
||||
loadTestService.save(request, file);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
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.OrganizationMapper;
|
||||
import io.metersphere.base.mapper.ProjectMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtLoadTestMapper;
|
||||
import io.metersphere.commons.constants.LoadTestFileType;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.IOUtils;
|
||||
import io.metersphere.controller.request.testplan.DeleteTestPlanRequest;
|
||||
import io.metersphere.controller.request.testplan.QueryTestPlanRequest;
|
||||
import io.metersphere.controller.request.testplan.SaveTestPlanRequest;
|
||||
|
@ -13,11 +17,13 @@ import org.apache.commons.lang3.RandomUtils;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
@Service
|
||||
|
@ -29,6 +35,10 @@ public class LoadTestService {
|
|||
private ExtLoadTestMapper extLoadTestMapper;
|
||||
@Resource
|
||||
private ProjectMapper projectMapper;
|
||||
@Resource
|
||||
private FileStoreMapper fileStoreMapper;
|
||||
@Resource
|
||||
private FileStoreResourceMapper fileStoreResourceMapper;
|
||||
|
||||
// 测试,模拟数据
|
||||
@PostConstruct
|
||||
|
@ -63,7 +73,23 @@ public class LoadTestService {
|
|||
loadTestMapper.deleteByExample(loadTestExample);
|
||||
}
|
||||
|
||||
public void save(SaveTestPlanRequest request) {
|
||||
public void save(SaveTestPlanRequest request, MultipartFile file) {
|
||||
if (file == null) {
|
||||
throw new IllegalArgumentException("文件不能为空!");
|
||||
}
|
||||
|
||||
final FileStore fileStore = saveFileStore(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);
|
||||
}
|
||||
|
||||
private LoadTestWithBLOBs saveLoadTest(SaveTestPlanRequest request) {
|
||||
final LoadTestWithBLOBs loadTest = new LoadTestWithBLOBs();
|
||||
loadTest.setId(UUID.randomUUID().toString());
|
||||
loadTest.setName(request.getName());
|
||||
|
@ -73,5 +99,23 @@ public class LoadTestService {
|
|||
loadTest.setScenarioDefinition("todo");
|
||||
loadTest.setDescription("todo");
|
||||
loadTestMapper.insert(loadTest);
|
||||
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());
|
||||
try {
|
||||
fileStore.setFile(IOUtils.toString(file.getInputStream(), StandardCharsets.UTF_8));
|
||||
} catch (IOException e) {
|
||||
MSException.throwException(e);
|
||||
}
|
||||
fileStoreMapper.insert(fileStore);
|
||||
return fileStore;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,5 +57,6 @@
|
|||
<table tableName="load_test_report"/>
|
||||
<table tableName="load_test"/>
|
||||
<table tableName="file_store"/>
|
||||
<table tableName="file_store_resource"/>
|
||||
</context>
|
||||
</generatorConfiguration>
|
|
@ -74,6 +74,27 @@ export default {
|
|||
}
|
||||
};
|
||||
|
||||
Vue.prototype.$request = function (axiosRequestConfig, success) {
|
||||
if (!success) {
|
||||
return axios.request(axiosRequestConfig);
|
||||
} else {
|
||||
axios.request(axiosRequestConfig).then(response => {
|
||||
if (!response.data) {
|
||||
return success(response);
|
||||
}
|
||||
if (response.data.success) {
|
||||
return success(response.data);
|
||||
} else {
|
||||
window.console.warn(response.data);
|
||||
Message.warning(response.data.message);
|
||||
}
|
||||
}).catch(error => {
|
||||
window.console.error(error.response || error.message);
|
||||
Message.error({message: error.message, showClose: true});
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
Vue.prototype.$all = function (array, callback) {
|
||||
if (array.length < 1) return;
|
||||
axios.all(array).then(axios.spread(callback));
|
||||
|
|
|
@ -86,15 +86,31 @@
|
|||
return;
|
||||
}
|
||||
|
||||
this.$post(this.savePath, this.testPlan).then(response => {
|
||||
let formData = new FormData();
|
||||
|
||||
formData.append("file", this.testPlan.file);
|
||||
// file属性不需要json化
|
||||
let requestJson = JSON.stringify(this.testPlan, function (key, value) {return key === "file" ? undefined : value});
|
||||
formData.append('request', new Blob([requestJson], {
|
||||
type: "application/json"
|
||||
}));
|
||||
|
||||
let options = {
|
||||
method: 'POST',
|
||||
url: this.savePath,
|
||||
data: formData,
|
||||
headers: {
|
||||
'Content-Type': undefined
|
||||
}
|
||||
};
|
||||
|
||||
this.$request(options).then(response => {
|
||||
if (response) {
|
||||
this.$message({
|
||||
message: '保存成功!',
|
||||
type: 'success'
|
||||
});
|
||||
}
|
||||
}).catch((response) => {
|
||||
this.$message.error(response.message);
|
||||
});
|
||||
},
|
||||
saveAndRun() {
|
||||
|
@ -134,7 +150,7 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!this.testPlan.fileId) {
|
||||
if (!this.testPlan.file) {
|
||||
this.$message({
|
||||
message: 'jmx文件不能为空!',
|
||||
type: 'error'
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
:show-file-list="false"
|
||||
:action="jmxUploadPath"
|
||||
:before-upload="beforeUpload"
|
||||
:http-request="handleUpload"
|
||||
:file-list="fileList">
|
||||
<i class="el-icon-upload"/>
|
||||
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
||||
|
@ -64,13 +65,6 @@
|
|||
},
|
||||
methods: {
|
||||
beforeUpload(file) {
|
||||
window.console.log(file);
|
||||
|
||||
/// todo: 上传的文件需要绑定到当前testPlan,这里暂时使用文件名
|
||||
this._changeTestPlan(function (testPlan) {
|
||||
testPlan.fileId = file.name;
|
||||
});
|
||||
|
||||
if (!this.fileValidator(file)) {
|
||||
/// todo: 显示错误信息
|
||||
return false;
|
||||
|
@ -86,6 +80,13 @@
|
|||
|
||||
return true;
|
||||
},
|
||||
handleUpload(uploadResources) {
|
||||
window.console.log(uploadResources);
|
||||
|
||||
this._changeTestPlan(function (testPlan) {
|
||||
testPlan.file = uploadResources.file;
|
||||
});
|
||||
},
|
||||
handleDownload(file) {
|
||||
let data = {
|
||||
name: file.name
|
||||
|
|
Loading…
Reference in New Issue