refactor(缺陷管理): 优化缺陷功能关联附件逻辑
This commit is contained in:
parent
030259d11e
commit
fe0cf474fc
|
@ -13,35 +13,31 @@ import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class BugAttachment implements Serializable {
|
public class BugLocalAttachment implements Serializable {
|
||||||
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@NotBlank(message = "{bug_attachment.id.not_blank}", groups = {Updated.class})
|
@NotBlank(message = "{bug_local_attachment.id.not_blank}", groups = {Updated.class})
|
||||||
@Size(min = 1, max = 255, message = "{bug_attachment.id.length_range}", groups = {Created.class, Updated.class})
|
@Size(min = 1, max = 255, message = "{bug_local_attachment.id.length_range}", groups = {Created.class, Updated.class})
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
@Schema(description = "缺陷ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "缺陷ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@NotBlank(message = "{bug_attachment.bug_id.not_blank}", groups = {Created.class})
|
@NotBlank(message = "{bug_local_attachment.bug_id.not_blank}", groups = {Created.class})
|
||||||
@Size(min = 1, max = 50, message = "{bug_attachment.bug_id.length_range}", groups = {Created.class, Updated.class})
|
@Size(min = 1, max = 50, message = "{bug_local_attachment.bug_id.length_range}", groups = {Created.class, Updated.class})
|
||||||
private String bugId;
|
private String bugId;
|
||||||
|
|
||||||
@Schema(description = "文件ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "文件ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@NotBlank(message = "{bug_attachment.file_id.not_blank}", groups = {Created.class})
|
@NotBlank(message = "{bug_local_attachment.file_id.not_blank}", groups = {Created.class})
|
||||||
@Size(min = 1, max = 50, message = "{bug_attachment.file_id.length_range}", groups = {Created.class, Updated.class})
|
@Size(min = 1, max = 50, message = "{bug_local_attachment.file_id.length_range}", groups = {Created.class, Updated.class})
|
||||||
private String fileId;
|
private String fileId;
|
||||||
|
|
||||||
@Schema(description = "文件名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "文件名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@NotBlank(message = "{bug_attachment.file_name.not_blank}", groups = {Created.class})
|
@NotBlank(message = "{bug_local_attachment.file_name.not_blank}", groups = {Created.class})
|
||||||
@Size(min = 1, max = 255, message = "{bug_attachment.file_name.length_range}", groups = {Created.class, Updated.class})
|
@Size(min = 1, max = 255, message = "{bug_local_attachment.file_name.length_range}", groups = {Created.class, Updated.class})
|
||||||
private String fileName;
|
private String fileName;
|
||||||
|
|
||||||
@Schema(description = "文件大小", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "文件大小", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@NotNull(message = "{bug_attachment.size.not_blank}", groups = {Created.class})
|
@NotNull(message = "{bug_local_attachment.size.not_blank}", groups = {Created.class})
|
||||||
private Long size;
|
private Long size;
|
||||||
|
|
||||||
@Schema(description = "是否本地", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
||||||
@NotNull(message = "{bug_attachment.local.not_blank}", groups = {Created.class})
|
|
||||||
private Boolean local;
|
|
||||||
|
|
||||||
@Schema(description = "创建人")
|
@Schema(description = "创建人")
|
||||||
private String createUser;
|
private String createUser;
|
||||||
|
|
||||||
|
@ -56,7 +52,6 @@ public class BugAttachment implements Serializable {
|
||||||
fileId("file_id", "fileId", "VARCHAR", false),
|
fileId("file_id", "fileId", "VARCHAR", false),
|
||||||
fileName("file_name", "fileName", "VARCHAR", false),
|
fileName("file_name", "fileName", "VARCHAR", false),
|
||||||
size("size", "size", "BIGINT", true),
|
size("size", "size", "BIGINT", true),
|
||||||
local("local", "local", "BIT", true),
|
|
||||||
createUser("create_user", "createUser", "VARCHAR", false),
|
createUser("create_user", "createUser", "VARCHAR", false),
|
||||||
createTime("create_time", "createTime", "BIGINT", false);
|
createTime("create_time", "createTime", "BIGINT", false);
|
||||||
|
|
|
@ -3,14 +3,14 @@ package io.metersphere.bug.domain;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class BugAttachmentExample {
|
public class BugLocalAttachmentExample {
|
||||||
protected String orderByClause;
|
protected String orderByClause;
|
||||||
|
|
||||||
protected boolean distinct;
|
protected boolean distinct;
|
||||||
|
|
||||||
protected List<Criteria> oredCriteria;
|
protected List<Criteria> oredCriteria;
|
||||||
|
|
||||||
public BugAttachmentExample() {
|
public BugLocalAttachmentExample() {
|
||||||
oredCriteria = new ArrayList<Criteria>();
|
oredCriteria = new ArrayList<Criteria>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -444,66 +444,6 @@ public class BugAttachmentExample {
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Criteria andLocalIsNull() {
|
|
||||||
addCriterion("`local` is null");
|
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andLocalIsNotNull() {
|
|
||||||
addCriterion("`local` is not null");
|
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andLocalEqualTo(Boolean value) {
|
|
||||||
addCriterion("`local` =", value, "local");
|
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andLocalNotEqualTo(Boolean value) {
|
|
||||||
addCriterion("`local` <>", value, "local");
|
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andLocalGreaterThan(Boolean value) {
|
|
||||||
addCriterion("`local` >", value, "local");
|
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andLocalGreaterThanOrEqualTo(Boolean value) {
|
|
||||||
addCriterion("`local` >=", value, "local");
|
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andLocalLessThan(Boolean value) {
|
|
||||||
addCriterion("`local` <", value, "local");
|
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andLocalLessThanOrEqualTo(Boolean value) {
|
|
||||||
addCriterion("`local` <=", value, "local");
|
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andLocalIn(List<Boolean> values) {
|
|
||||||
addCriterion("`local` in", values, "local");
|
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andLocalNotIn(List<Boolean> values) {
|
|
||||||
addCriterion("`local` not in", values, "local");
|
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andLocalBetween(Boolean value1, Boolean value2) {
|
|
||||||
addCriterion("`local` between", value1, value2, "local");
|
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andLocalNotBetween(Boolean value1, Boolean value2) {
|
|
||||||
addCriterion("`local` not between", value1, value2, "local");
|
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andCreateUserIsNull() {
|
public Criteria andCreateUserIsNull() {
|
||||||
addCriterion("create_user is null");
|
addCriterion("create_user is null");
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
|
@ -1,35 +0,0 @@
|
||||||
package io.metersphere.bug.mapper;
|
|
||||||
|
|
||||||
import io.metersphere.bug.domain.BugAttachment;
|
|
||||||
import io.metersphere.bug.domain.BugAttachmentExample;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface BugAttachmentMapper {
|
|
||||||
long countByExample(BugAttachmentExample example);
|
|
||||||
|
|
||||||
int deleteByExample(BugAttachmentExample example);
|
|
||||||
|
|
||||||
int deleteByPrimaryKey(String id);
|
|
||||||
|
|
||||||
int insert(BugAttachment record);
|
|
||||||
|
|
||||||
int insertSelective(BugAttachment record);
|
|
||||||
|
|
||||||
List<BugAttachment> selectByExample(BugAttachmentExample example);
|
|
||||||
|
|
||||||
BugAttachment selectByPrimaryKey(String id);
|
|
||||||
|
|
||||||
int updateByExampleSelective(@Param("record") BugAttachment record, @Param("example") BugAttachmentExample example);
|
|
||||||
|
|
||||||
int updateByExample(@Param("record") BugAttachment record, @Param("example") BugAttachmentExample example);
|
|
||||||
|
|
||||||
int updateByPrimaryKeySelective(BugAttachment record);
|
|
||||||
|
|
||||||
int updateByPrimaryKey(BugAttachment record);
|
|
||||||
|
|
||||||
int batchInsert(@Param("list") List<BugAttachment> list);
|
|
||||||
|
|
||||||
int batchInsertSelective(@Param("list") List<BugAttachment> list, @Param("selective") BugAttachment.Column ... selective);
|
|
||||||
}
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
package io.metersphere.bug.mapper;
|
||||||
|
|
||||||
|
import io.metersphere.bug.domain.BugLocalAttachment;
|
||||||
|
import io.metersphere.bug.domain.BugLocalAttachmentExample;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface BugLocalAttachmentMapper {
|
||||||
|
long countByExample(BugLocalAttachmentExample example);
|
||||||
|
|
||||||
|
int deleteByExample(BugLocalAttachmentExample example);
|
||||||
|
|
||||||
|
int deleteByPrimaryKey(String id);
|
||||||
|
|
||||||
|
int insert(BugLocalAttachment record);
|
||||||
|
|
||||||
|
int insertSelective(BugLocalAttachment record);
|
||||||
|
|
||||||
|
List<BugLocalAttachment> selectByExample(BugLocalAttachmentExample example);
|
||||||
|
|
||||||
|
BugLocalAttachment selectByPrimaryKey(String id);
|
||||||
|
|
||||||
|
int updateByExampleSelective(@Param("record") BugLocalAttachment record, @Param("example") BugLocalAttachmentExample example);
|
||||||
|
|
||||||
|
int updateByExample(@Param("record") BugLocalAttachment record, @Param("example") BugLocalAttachmentExample example);
|
||||||
|
|
||||||
|
int updateByPrimaryKeySelective(BugLocalAttachment record);
|
||||||
|
|
||||||
|
int updateByPrimaryKey(BugLocalAttachment record);
|
||||||
|
|
||||||
|
int batchInsert(@Param("list") List<BugLocalAttachment> list);
|
||||||
|
|
||||||
|
int batchInsertSelective(@Param("list") List<BugLocalAttachment> list, @Param("selective") BugLocalAttachment.Column ... selective);
|
||||||
|
}
|
|
@ -1,13 +1,12 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="io.metersphere.bug.mapper.BugAttachmentMapper">
|
<mapper namespace="io.metersphere.bug.mapper.BugLocalAttachmentMapper">
|
||||||
<resultMap id="BaseResultMap" type="io.metersphere.bug.domain.BugAttachment">
|
<resultMap id="BaseResultMap" type="io.metersphere.bug.domain.BugLocalAttachment">
|
||||||
<id column="id" jdbcType="VARCHAR" property="id" />
|
<id column="id" jdbcType="VARCHAR" property="id" />
|
||||||
<result column="bug_id" jdbcType="VARCHAR" property="bugId" />
|
<result column="bug_id" jdbcType="VARCHAR" property="bugId" />
|
||||||
<result column="file_id" jdbcType="VARCHAR" property="fileId" />
|
<result column="file_id" jdbcType="VARCHAR" property="fileId" />
|
||||||
<result column="file_name" jdbcType="VARCHAR" property="fileName" />
|
<result column="file_name" jdbcType="VARCHAR" property="fileName" />
|
||||||
<result column="size" jdbcType="BIGINT" property="size" />
|
<result column="size" jdbcType="BIGINT" property="size" />
|
||||||
<result column="local" jdbcType="BIT" property="local" />
|
|
||||||
<result column="create_user" jdbcType="VARCHAR" property="createUser" />
|
<result column="create_user" jdbcType="VARCHAR" property="createUser" />
|
||||||
<result column="create_time" jdbcType="BIGINT" property="createTime" />
|
<result column="create_time" jdbcType="BIGINT" property="createTime" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
@ -70,15 +69,15 @@
|
||||||
</where>
|
</where>
|
||||||
</sql>
|
</sql>
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
id, bug_id, file_id, file_name, `size`, `local`, create_user, create_time
|
id, bug_id, file_id, file_name, `size`, create_user, create_time
|
||||||
</sql>
|
</sql>
|
||||||
<select id="selectByExample" parameterType="io.metersphere.bug.domain.BugAttachmentExample" resultMap="BaseResultMap">
|
<select id="selectByExample" parameterType="io.metersphere.bug.domain.BugLocalAttachmentExample" resultMap="BaseResultMap">
|
||||||
select
|
select
|
||||||
<if test="distinct">
|
<if test="distinct">
|
||||||
distinct
|
distinct
|
||||||
</if>
|
</if>
|
||||||
<include refid="Base_Column_List" />
|
<include refid="Base_Column_List" />
|
||||||
from bug_attachment
|
from bug_local_attachment
|
||||||
<if test="_parameter != null">
|
<if test="_parameter != null">
|
||||||
<include refid="Example_Where_Clause" />
|
<include refid="Example_Where_Clause" />
|
||||||
</if>
|
</if>
|
||||||
|
@ -89,29 +88,29 @@
|
||||||
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
|
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
|
||||||
select
|
select
|
||||||
<include refid="Base_Column_List" />
|
<include refid="Base_Column_List" />
|
||||||
from bug_attachment
|
from bug_local_attachment
|
||||||
where id = #{id,jdbcType=VARCHAR}
|
where id = #{id,jdbcType=VARCHAR}
|
||||||
</select>
|
</select>
|
||||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
|
||||||
delete from bug_attachment
|
delete from bug_local_attachment
|
||||||
where id = #{id,jdbcType=VARCHAR}
|
where id = #{id,jdbcType=VARCHAR}
|
||||||
</delete>
|
</delete>
|
||||||
<delete id="deleteByExample" parameterType="io.metersphere.bug.domain.BugAttachmentExample">
|
<delete id="deleteByExample" parameterType="io.metersphere.bug.domain.BugLocalAttachmentExample">
|
||||||
delete from bug_attachment
|
delete from bug_local_attachment
|
||||||
<if test="_parameter != null">
|
<if test="_parameter != null">
|
||||||
<include refid="Example_Where_Clause" />
|
<include refid="Example_Where_Clause" />
|
||||||
</if>
|
</if>
|
||||||
</delete>
|
</delete>
|
||||||
<insert id="insert" parameterType="io.metersphere.bug.domain.BugAttachment">
|
<insert id="insert" parameterType="io.metersphere.bug.domain.BugLocalAttachment">
|
||||||
insert into bug_attachment (id, bug_id, file_id,
|
insert into bug_local_attachment (id, bug_id, file_id,
|
||||||
file_name, `size`, `local`, create_user,
|
file_name, `size`, create_user,
|
||||||
create_time)
|
create_time)
|
||||||
values (#{id,jdbcType=VARCHAR}, #{bugId,jdbcType=VARCHAR}, #{fileId,jdbcType=VARCHAR},
|
values (#{id,jdbcType=VARCHAR}, #{bugId,jdbcType=VARCHAR}, #{fileId,jdbcType=VARCHAR},
|
||||||
#{fileName,jdbcType=VARCHAR}, #{size,jdbcType=BIGINT}, #{local,jdbcType=BIT}, #{createUser,jdbcType=VARCHAR},
|
#{fileName,jdbcType=VARCHAR}, #{size,jdbcType=BIGINT}, #{createUser,jdbcType=VARCHAR},
|
||||||
#{createTime,jdbcType=BIGINT})
|
#{createTime,jdbcType=BIGINT})
|
||||||
</insert>
|
</insert>
|
||||||
<insert id="insertSelective" parameterType="io.metersphere.bug.domain.BugAttachment">
|
<insert id="insertSelective" parameterType="io.metersphere.bug.domain.BugLocalAttachment">
|
||||||
insert into bug_attachment
|
insert into bug_local_attachment
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
<if test="id != null">
|
<if test="id != null">
|
||||||
id,
|
id,
|
||||||
|
@ -128,9 +127,6 @@
|
||||||
<if test="size != null">
|
<if test="size != null">
|
||||||
`size`,
|
`size`,
|
||||||
</if>
|
</if>
|
||||||
<if test="local != null">
|
|
||||||
`local`,
|
|
||||||
</if>
|
|
||||||
<if test="createUser != null">
|
<if test="createUser != null">
|
||||||
create_user,
|
create_user,
|
||||||
</if>
|
</if>
|
||||||
|
@ -154,9 +150,6 @@
|
||||||
<if test="size != null">
|
<if test="size != null">
|
||||||
#{size,jdbcType=BIGINT},
|
#{size,jdbcType=BIGINT},
|
||||||
</if>
|
</if>
|
||||||
<if test="local != null">
|
|
||||||
#{local,jdbcType=BIT},
|
|
||||||
</if>
|
|
||||||
<if test="createUser != null">
|
<if test="createUser != null">
|
||||||
#{createUser,jdbcType=VARCHAR},
|
#{createUser,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
|
@ -165,14 +158,14 @@
|
||||||
</if>
|
</if>
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
<select id="countByExample" parameterType="io.metersphere.bug.domain.BugAttachmentExample" resultType="java.lang.Long">
|
<select id="countByExample" parameterType="io.metersphere.bug.domain.BugLocalAttachmentExample" resultType="java.lang.Long">
|
||||||
select count(*) from bug_attachment
|
select count(*) from bug_local_attachment
|
||||||
<if test="_parameter != null">
|
<if test="_parameter != null">
|
||||||
<include refid="Example_Where_Clause" />
|
<include refid="Example_Where_Clause" />
|
||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
<update id="updateByExampleSelective" parameterType="map">
|
<update id="updateByExampleSelective" parameterType="map">
|
||||||
update bug_attachment
|
update bug_local_attachment
|
||||||
<set>
|
<set>
|
||||||
<if test="record.id != null">
|
<if test="record.id != null">
|
||||||
id = #{record.id,jdbcType=VARCHAR},
|
id = #{record.id,jdbcType=VARCHAR},
|
||||||
|
@ -189,9 +182,6 @@
|
||||||
<if test="record.size != null">
|
<if test="record.size != null">
|
||||||
`size` = #{record.size,jdbcType=BIGINT},
|
`size` = #{record.size,jdbcType=BIGINT},
|
||||||
</if>
|
</if>
|
||||||
<if test="record.local != null">
|
|
||||||
`local` = #{record.local,jdbcType=BIT},
|
|
||||||
</if>
|
|
||||||
<if test="record.createUser != null">
|
<if test="record.createUser != null">
|
||||||
create_user = #{record.createUser,jdbcType=VARCHAR},
|
create_user = #{record.createUser,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
|
@ -204,21 +194,20 @@
|
||||||
</if>
|
</if>
|
||||||
</update>
|
</update>
|
||||||
<update id="updateByExample" parameterType="map">
|
<update id="updateByExample" parameterType="map">
|
||||||
update bug_attachment
|
update bug_local_attachment
|
||||||
set id = #{record.id,jdbcType=VARCHAR},
|
set id = #{record.id,jdbcType=VARCHAR},
|
||||||
bug_id = #{record.bugId,jdbcType=VARCHAR},
|
bug_id = #{record.bugId,jdbcType=VARCHAR},
|
||||||
file_id = #{record.fileId,jdbcType=VARCHAR},
|
file_id = #{record.fileId,jdbcType=VARCHAR},
|
||||||
file_name = #{record.fileName,jdbcType=VARCHAR},
|
file_name = #{record.fileName,jdbcType=VARCHAR},
|
||||||
`size` = #{record.size,jdbcType=BIGINT},
|
`size` = #{record.size,jdbcType=BIGINT},
|
||||||
`local` = #{record.local,jdbcType=BIT},
|
|
||||||
create_user = #{record.createUser,jdbcType=VARCHAR},
|
create_user = #{record.createUser,jdbcType=VARCHAR},
|
||||||
create_time = #{record.createTime,jdbcType=BIGINT}
|
create_time = #{record.createTime,jdbcType=BIGINT}
|
||||||
<if test="_parameter != null">
|
<if test="_parameter != null">
|
||||||
<include refid="Update_By_Example_Where_Clause" />
|
<include refid="Update_By_Example_Where_Clause" />
|
||||||
</if>
|
</if>
|
||||||
</update>
|
</update>
|
||||||
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.bug.domain.BugAttachment">
|
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.bug.domain.BugLocalAttachment">
|
||||||
update bug_attachment
|
update bug_local_attachment
|
||||||
<set>
|
<set>
|
||||||
<if test="bugId != null">
|
<if test="bugId != null">
|
||||||
bug_id = #{bugId,jdbcType=VARCHAR},
|
bug_id = #{bugId,jdbcType=VARCHAR},
|
||||||
|
@ -232,9 +221,6 @@
|
||||||
<if test="size != null">
|
<if test="size != null">
|
||||||
`size` = #{size,jdbcType=BIGINT},
|
`size` = #{size,jdbcType=BIGINT},
|
||||||
</if>
|
</if>
|
||||||
<if test="local != null">
|
|
||||||
`local` = #{local,jdbcType=BIT},
|
|
||||||
</if>
|
|
||||||
<if test="createUser != null">
|
<if test="createUser != null">
|
||||||
create_user = #{createUser,jdbcType=VARCHAR},
|
create_user = #{createUser,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
|
@ -244,29 +230,28 @@
|
||||||
</set>
|
</set>
|
||||||
where id = #{id,jdbcType=VARCHAR}
|
where id = #{id,jdbcType=VARCHAR}
|
||||||
</update>
|
</update>
|
||||||
<update id="updateByPrimaryKey" parameterType="io.metersphere.bug.domain.BugAttachment">
|
<update id="updateByPrimaryKey" parameterType="io.metersphere.bug.domain.BugLocalAttachment">
|
||||||
update bug_attachment
|
update bug_local_attachment
|
||||||
set bug_id = #{bugId,jdbcType=VARCHAR},
|
set bug_id = #{bugId,jdbcType=VARCHAR},
|
||||||
file_id = #{fileId,jdbcType=VARCHAR},
|
file_id = #{fileId,jdbcType=VARCHAR},
|
||||||
file_name = #{fileName,jdbcType=VARCHAR},
|
file_name = #{fileName,jdbcType=VARCHAR},
|
||||||
`size` = #{size,jdbcType=BIGINT},
|
`size` = #{size,jdbcType=BIGINT},
|
||||||
`local` = #{local,jdbcType=BIT},
|
|
||||||
create_user = #{createUser,jdbcType=VARCHAR},
|
create_user = #{createUser,jdbcType=VARCHAR},
|
||||||
create_time = #{createTime,jdbcType=BIGINT}
|
create_time = #{createTime,jdbcType=BIGINT}
|
||||||
where id = #{id,jdbcType=VARCHAR}
|
where id = #{id,jdbcType=VARCHAR}
|
||||||
</update>
|
</update>
|
||||||
<insert id="batchInsert" parameterType="map">
|
<insert id="batchInsert" parameterType="map">
|
||||||
insert into bug_attachment
|
insert into bug_local_attachment
|
||||||
(id, bug_id, file_id, file_name, `size`, `local`, create_user, create_time)
|
(id, bug_id, file_id, file_name, `size`, create_user, create_time)
|
||||||
values
|
values
|
||||||
<foreach collection="list" item="item" separator=",">
|
<foreach collection="list" item="item" separator=",">
|
||||||
(#{item.id,jdbcType=VARCHAR}, #{item.bugId,jdbcType=VARCHAR}, #{item.fileId,jdbcType=VARCHAR},
|
(#{item.id,jdbcType=VARCHAR}, #{item.bugId,jdbcType=VARCHAR}, #{item.fileId,jdbcType=VARCHAR},
|
||||||
#{item.fileName,jdbcType=VARCHAR}, #{item.size,jdbcType=BIGINT}, #{item.local,jdbcType=BIT},
|
#{item.fileName,jdbcType=VARCHAR}, #{item.size,jdbcType=BIGINT}, #{item.createUser,jdbcType=VARCHAR},
|
||||||
#{item.createUser,jdbcType=VARCHAR}, #{item.createTime,jdbcType=BIGINT})
|
#{item.createTime,jdbcType=BIGINT})
|
||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
<insert id="batchInsertSelective" parameterType="map">
|
<insert id="batchInsertSelective" parameterType="map">
|
||||||
insert into bug_attachment (
|
insert into bug_local_attachment (
|
||||||
<foreach collection="selective" item="column" separator=",">
|
<foreach collection="selective" item="column" separator=",">
|
||||||
${column.escapedColumnName}
|
${column.escapedColumnName}
|
||||||
</foreach>
|
</foreach>
|
||||||
|
@ -290,9 +275,6 @@
|
||||||
<if test="'size'.toString() == column.value">
|
<if test="'size'.toString() == column.value">
|
||||||
#{item.size,jdbcType=BIGINT}
|
#{item.size,jdbcType=BIGINT}
|
||||||
</if>
|
</if>
|
||||||
<if test="'local'.toString() == column.value">
|
|
||||||
#{item.local,jdbcType=BIT}
|
|
||||||
</if>
|
|
||||||
<if test="'create_user'.toString() == column.value">
|
<if test="'create_user'.toString() == column.value">
|
||||||
#{item.createUser,jdbcType=VARCHAR}
|
#{item.createUser,jdbcType=VARCHAR}
|
||||||
</if>
|
</if>
|
|
@ -53,17 +53,16 @@ CREATE TABLE IF NOT EXISTS bug_follower(
|
||||||
|
|
||||||
CREATE INDEX idx_follow_id ON bug_follower(user_id);
|
CREATE INDEX idx_follow_id ON bug_follower(user_id);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS bug_attachment(
|
CREATE TABLE IF NOT EXISTS bug_local_attachment(
|
||||||
`id` VARCHAR(255) NOT NULL COMMENT 'ID' ,
|
`id` VARCHAR(255) NOT NULL COMMENT 'ID' ,
|
||||||
`bug_id` VARCHAR(50) NOT NULL COMMENT '缺陷ID' ,
|
`bug_id` VARCHAR(50) NOT NULL COMMENT '缺陷ID' ,
|
||||||
`file_id` VARCHAR(50) NOT NULL COMMENT '文件ID' ,
|
`file_id` VARCHAR(50) NOT NULL COMMENT '文件ID' ,
|
||||||
`file_name` VARCHAR(255) NOT NULL COMMENT '文件名称' ,
|
`file_name` VARCHAR(255) NOT NULL COMMENT '文件名称' ,
|
||||||
`size` BIGINT NOT NULL COMMENT '文件大小' ,
|
`size` BIGINT NOT NULL COMMENT '文件大小' ,
|
||||||
`local` BIT(1) NOT NULL COMMENT '是否本地' ,
|
|
||||||
`create_user` VARCHAR(50) NOT NULL COMMENT '创建人' ,
|
`create_user` VARCHAR(50) NOT NULL COMMENT '创建人' ,
|
||||||
`create_time` BIGINT NOT NULL COMMENT '创建时间' ,
|
`create_time` BIGINT NOT NULL COMMENT '创建时间' ,
|
||||||
PRIMARY KEY (id)
|
PRIMARY KEY (id)
|
||||||
) COMMENT = '缺陷附件';
|
) COMMENT = '缺陷本地附件';
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS bug_comment(
|
CREATE TABLE IF NOT EXISTS bug_comment(
|
||||||
`id` VARCHAR(50) NOT NULL COMMENT 'ID' ,
|
`id` VARCHAR(50) NOT NULL COMMENT 'ID' ,
|
||||||
|
|
|
@ -42,19 +42,17 @@ bug_comment.create_user.length_range=评论人长度必须在1-50之间
|
||||||
bug_comment.update_user.not_blank=更新人不能为空
|
bug_comment.update_user.not_blank=更新人不能为空
|
||||||
bug_comment.update_user.length_range=更新人长度必须在1-50之间
|
bug_comment.update_user.length_range=更新人长度必须在1-50之间
|
||||||
|
|
||||||
# bugAttachment
|
# bugLocalAttachment
|
||||||
bug_attachment.id.not_blank=ID不能为空
|
bug_local_attachment.id.not_blank=ID不能为空
|
||||||
bug_attachment.id.length_range=ID长度必须在1-50之间
|
bug_local_attachment.id.length_range=ID长度必须在1-50之间
|
||||||
bug_attachment.bug_id.not_blank=缺陷ID不能为空
|
bug_local_attachment.bug_id.not_blank=缺陷ID不能为空
|
||||||
bug_attachment.bug_id.length_range=缺陷ID长度必须在1-50之间
|
bug_local_attachment.bug_id.length_range=缺陷ID长度必须在1-50之间
|
||||||
bug_attachment.file_id.not_blank=文件ID不能为空
|
bug_local_attachment.file_id.not_blank=文件ID不能为空
|
||||||
bug_attachment.file_id.length_range=文件ID长度必须在1-50之间
|
bug_local_attachment.file_id.length_range=文件ID长度必须在1-50之间
|
||||||
bug_attachment.file_name.not_blank=文件名称不能为空
|
bug_local_attachment.file_name.not_blank=文件名称不能为空
|
||||||
bug_attachment.file_name.length_range=文件名称长度必须在1-50之间
|
bug_local_attachment.file_name.length_range=文件名称长度必须在1-50之间
|
||||||
bug_attachment.local.not_blank=是否本地上传不能为空
|
bug_local_attachment.create_user.not_blank=创建人不能为空
|
||||||
bug_attachment.local.length_range=是否本地上传长度必须在1-50之间
|
bug_local_attachment.create_user.length_range=创建人长度必须在1-50之间
|
||||||
bug_attachment.create_user.not_blank=创建人不能为空
|
|
||||||
bug_attachment.create_user.length_range=创建人长度必须在1-50之间
|
|
||||||
|
|
||||||
# bugCustomField
|
# bugCustomField
|
||||||
bug_custom_field.bug_id.not_blank=缺陷ID不能为空
|
bug_custom_field.bug_id.not_blank=缺陷ID不能为空
|
||||||
|
|
|
@ -42,19 +42,17 @@ bug_comment.create_user.length_range=createUser length must be between 1-50
|
||||||
bug_comment.update_user.not_blank=updateUser cannot be empty
|
bug_comment.update_user.not_blank=updateUser cannot be empty
|
||||||
bug_comment.update_user.length_range=updateUser length must be between 1-50
|
bug_comment.update_user.length_range=updateUser length must be between 1-50
|
||||||
|
|
||||||
# bugAttachment
|
# bugLocalAttachment
|
||||||
bug_attachment.id.not_blank=id cannot be empty
|
bug_local_attachment.id.not_blank=id cannot be empty
|
||||||
bug_attachment.id.length_range=id length must be between 1-50
|
bug_local_attachment.id.length_range=id length must be between 1-50
|
||||||
bug_attachment.bug_id.not_blank=bugId cannot be empty
|
bug_local_attachment.bug_id.not_blank=bugId cannot be empty
|
||||||
bug_attachment.bug_id.length_range=bugId length must be between 1-50
|
bug_local_attachment.bug_id.length_range=bugId length must be between 1-50
|
||||||
bug_attachment.file_id.not_blank=fileId cannot be empty
|
bug_local_attachment.file_id.not_blank=fileId cannot be empty
|
||||||
bug_attachment.file_id.length_range=fileId length must be between 1-50
|
bug_local_attachment.file_id.length_range=fileId length must be between 1-50
|
||||||
bug_attachment.file_name.not_blank=fileName cannot be empty
|
bug_local_attachment.file_name.not_blank=fileName cannot be empty
|
||||||
bug_attachment.file_name.length_range=fileName length must be between 1-50
|
bug_local_attachment.file_name.length_range=fileName length must be between 1-50
|
||||||
bug_attachment.local.not_blank=local cannot be empty
|
bug_local_attachment.create_user.not_blank=createUser cannot be empty
|
||||||
bug_attachment.local.length_range=local length must be between 1-50
|
bug_local_attachment.create_user.length_range=createUser length must be between 1-50
|
||||||
bug_attachment.create_user.not_blank=createUser cannot be empty
|
|
||||||
bug_attachment.create_user.length_range=createUser length must be between 1-50
|
|
||||||
|
|
||||||
# bugCustomField
|
# bugCustomField
|
||||||
bug_custom_field.bug_id.not_blank=bugId cannot be empty
|
bug_custom_field.bug_id.not_blank=bugId cannot be empty
|
||||||
|
|
|
@ -42,19 +42,17 @@ bug_comment.create_user.length_range=评论人长度必须在1-50之间
|
||||||
bug_comment.update_user.not_blank=更新人不能为空
|
bug_comment.update_user.not_blank=更新人不能为空
|
||||||
bug_comment.update_user.length_range=更新人长度必须在1-50之间
|
bug_comment.update_user.length_range=更新人长度必须在1-50之间
|
||||||
|
|
||||||
# bugAttachment
|
# bugLocalAttachment
|
||||||
bug_attachment.id.not_blank=ID不能为空
|
bug_local_attachment.id.not_blank=ID不能为空
|
||||||
bug_attachment.id.length_range=ID长度必须在1-50之间
|
bug_local_attachment.id.length_range=ID长度必须在1-50之间
|
||||||
bug_attachment.bug_id.not_blank=缺陷ID不能为空
|
bug_local_attachment.bug_id.not_blank=缺陷ID不能为空
|
||||||
bug_attachment.bug_id.length_range=缺陷ID长度必须在1-50之间
|
bug_local_attachment.bug_id.length_range=缺陷ID长度必须在1-50之间
|
||||||
bug_attachment.file_id.not_blank=文件ID不能为空
|
bug_local_attachment.file_id.not_blank=文件ID不能为空
|
||||||
bug_attachment.file_id.length_range=文件ID长度必须在1-50之间
|
bug_local_attachment.file_id.length_range=文件ID长度必须在1-50之间
|
||||||
bug_attachment.file_name.not_blank=文件名称不能为空
|
bug_local_attachment.file_name.not_blank=文件名称不能为空
|
||||||
bug_attachment.file_name.length_range=文件名称长度必须在1-50之间
|
bug_local_attachment.file_name.length_range=文件名称长度必须在1-50之间
|
||||||
bug_attachment.local.not_blank=是否本地上传不能为空
|
bug_local_attachment.create_user.not_blank=创建人不能为空
|
||||||
bug_attachment.local.length_range=是否本地上传长度必须在1-50之间
|
bug_local_attachment.create_user.length_range=创建人长度必须在1-50之间
|
||||||
bug_attachment.create_user.not_blank=创建人不能为空
|
|
||||||
bug_attachment.create_user.length_range=创建人长度必须在1-50之间
|
|
||||||
|
|
||||||
# bugCustomField
|
# bugCustomField
|
||||||
bug_custom_field.bug_id.not_blank=缺陷ID不能为空
|
bug_custom_field.bug_id.not_blank=缺陷ID不能为空
|
||||||
|
|
|
@ -42,19 +42,17 @@ bug_comment.create_user.length_range=评论人長度必須在1-50之間
|
||||||
bug_comment.update_user.not_blank=更新人不能為空
|
bug_comment.update_user.not_blank=更新人不能為空
|
||||||
bug_comment.update_user.length_range=更新人長度必須在1-50之間
|
bug_comment.update_user.length_range=更新人長度必須在1-50之間
|
||||||
|
|
||||||
# bugAttachment
|
# bugLocalAttachment
|
||||||
bug_attachment.id.not_blank=ID不能為空
|
bug_local_attachment.id.not_blank=ID不能為空
|
||||||
bug_attachment.id.length_range=ID長度必須在1-50之間
|
bug_local_attachment.id.length_range=ID長度必須在1-50之間
|
||||||
bug_attachment.bug_id.not_blank=缺陷ID不能為空
|
bug_local_attachment.bug_id.not_blank=缺陷ID不能為空
|
||||||
bug_attachment.bug_id.length_range=缺陷ID長度必須在1-50之間
|
bug_local_attachment.bug_id.length_range=缺陷ID長度必須在1-50之間
|
||||||
bug_attachment.file_id.not_blank=文件ID不能為空
|
bug_local_attachment.file_id.not_blank=文件ID不能為空
|
||||||
bug_attachment.file_id.length_range=文件ID長度必須在1-50之間
|
bug_local_attachment.file_id.length_range=文件ID長度必須在1-50之間
|
||||||
bug_attachment.file_name.not_blank=文件名称不能為空
|
bug_local_attachment.file_name.not_blank=文件名称不能為空
|
||||||
bug_attachment.file_name.length_range=文件名称長度必須在1-50之間
|
bug_local_attachment.file_name.length_range=文件名称長度必須在1-50之間
|
||||||
bug_attachment.local.not_blank=是否本地上傳不能為空
|
bug_local_attachment.create_user.not_blank=创建人不能為空
|
||||||
bug_attachment.local.length_range=是否本地上傳必須在1-50之間
|
bug_local_attachment.create_user.length_range=创建人長度必須在1-50之間
|
||||||
bug_attachment.create_user.not_blank=创建人不能為空
|
|
||||||
bug_attachment.create_user.length_range=创建人長度必須在1-50之間
|
|
||||||
|
|
||||||
# bugCustomField
|
# bugCustomField
|
||||||
bug_custom_field.bug_id.not_blank=缺陷ID不能為空
|
bug_custom_field.bug_id.not_blank=缺陷ID不能為空
|
||||||
|
|
|
@ -60,8 +60,8 @@ public class BugEditRequest {
|
||||||
@Schema(description = "删除的本地附件集合")
|
@Schema(description = "删除的本地附件集合")
|
||||||
private List<String> deleteLocalFileIds;
|
private List<String> deleteLocalFileIds;
|
||||||
|
|
||||||
@Schema(description = "取消关联附件集合")
|
@Schema(description = "取消关联附件关系ID集合")
|
||||||
private List<String> unLinkFileIds;
|
private List<String> unLinkRefIds;
|
||||||
|
|
||||||
@Schema(description = "关联附件集合")
|
@Schema(description = "关联附件集合")
|
||||||
private List<String> linkFileIds;
|
private List<String> linkFileIds;
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
package io.metersphere.bug.dto.request;
|
|
||||||
|
|
||||||
import io.metersphere.system.dto.sdk.BasePageRequest;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
public class BugRelateCasePageRequest extends BasePageRequest {
|
|
||||||
|
|
||||||
@Schema(description = "所属项目ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
||||||
private String projectId;
|
|
||||||
|
|
||||||
@Schema(description = "版本ID")
|
|
||||||
private String versionId;
|
|
||||||
|
|
||||||
@Schema(description = "选中模块ID")
|
|
||||||
private String selectModuleId;
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
package io.metersphere.bug.dto.request;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
public class BugRelateCaseRequest extends BugRelateCasePageRequest{
|
|
||||||
|
|
||||||
@Schema(description = "是否全选", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
||||||
private boolean selectAll;
|
|
||||||
|
|
||||||
@Schema(description = "用例ID勾选列表")
|
|
||||||
private List<String> includeCaseIds;
|
|
||||||
}
|
|
|
@ -1,15 +1,15 @@
|
||||||
package io.metersphere.bug.mapper;
|
package io.metersphere.bug.mapper;
|
||||||
|
|
||||||
import io.metersphere.bug.domain.BugAttachment;
|
import io.metersphere.bug.domain.BugLocalAttachment;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface ExtBugAttachmentMapper {
|
public interface ExtBugLocalAttachmentMapper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量插入缺陷附件关系
|
* 批量插入缺陷附件关系
|
||||||
* @param attachments 缺陷附件集合
|
* @param attachments 缺陷附件集合
|
||||||
*/
|
*/
|
||||||
void batchInsert(@Param("list") List<BugAttachment> attachments);
|
void batchInsert(@Param("list") List<BugLocalAttachment> attachments);
|
||||||
}
|
}
|
|
@ -1,11 +1,11 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="io.metersphere.bug.mapper.ExtBugAttachmentMapper">
|
<mapper namespace="io.metersphere.bug.mapper.ExtBugLocalAttachmentMapper">
|
||||||
<insert id="batchInsert" parameterType="io.metersphere.bug.domain.BugAttachment">
|
<insert id="batchInsert" parameterType="io.metersphere.bug.domain.BugLocalAttachment">
|
||||||
insert into bug_attachment values
|
insert into bug_local_attachment values
|
||||||
<foreach collection="list" item="attachment" separator=",">
|
<foreach collection="list" item="attachment" separator=",">
|
||||||
(#{attachment.id}, #{attachment.bugId}, #{attachment.fileId}, #{attachment.fileName},
|
(#{attachment.id}, #{attachment.bugId}, #{attachment.fileId}, #{attachment.fileName},
|
||||||
#{attachment.size}, #{attachment.local}, #{attachment.createUser}, #{attachment.createTime})
|
#{attachment.size}, #{attachment.createUser}, #{attachment.createTime})
|
||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
</mapper>
|
</mapper>
|
|
@ -12,22 +12,23 @@ import io.metersphere.bug.dto.request.BugPageRequest;
|
||||||
import io.metersphere.bug.enums.BugPlatform;
|
import io.metersphere.bug.enums.BugPlatform;
|
||||||
import io.metersphere.bug.mapper.*;
|
import io.metersphere.bug.mapper.*;
|
||||||
import io.metersphere.bug.utils.CustomFieldUtils;
|
import io.metersphere.bug.utils.CustomFieldUtils;
|
||||||
import io.metersphere.project.domain.FileMetadata;
|
import io.metersphere.project.dto.filemanagement.FileLogRecord;
|
||||||
import io.metersphere.project.domain.FileMetadataExample;
|
import io.metersphere.project.service.FileAssociationService;
|
||||||
import io.metersphere.project.mapper.FileMetadataMapper;
|
|
||||||
import io.metersphere.project.service.FileService;
|
import io.metersphere.project.service.FileService;
|
||||||
import io.metersphere.project.service.ProjectTemplateService;
|
import io.metersphere.project.service.ProjectTemplateService;
|
||||||
import io.metersphere.sdk.constants.ApplicationNumScope;
|
import io.metersphere.sdk.constants.ApplicationNumScope;
|
||||||
|
import io.metersphere.sdk.constants.HttpMethodConstants;
|
||||||
import io.metersphere.sdk.constants.StorageType;
|
import io.metersphere.sdk.constants.StorageType;
|
||||||
import io.metersphere.sdk.constants.TemplateScene;
|
import io.metersphere.sdk.constants.TemplateScene;
|
||||||
import io.metersphere.sdk.exception.MSException;
|
import io.metersphere.sdk.exception.MSException;
|
||||||
import io.metersphere.sdk.util.BeanUtils;
|
import io.metersphere.sdk.util.BeanUtils;
|
||||||
import io.metersphere.sdk.util.MsFileUtils;
|
import io.metersphere.sdk.util.FileAssociationSourceUtil;
|
||||||
import io.metersphere.sdk.util.Translator;
|
import io.metersphere.sdk.util.Translator;
|
||||||
import io.metersphere.system.domain.Template;
|
import io.metersphere.system.domain.Template;
|
||||||
import io.metersphere.system.dto.sdk.OptionDTO;
|
import io.metersphere.system.dto.sdk.OptionDTO;
|
||||||
import io.metersphere.system.dto.sdk.TemplateDTO;
|
import io.metersphere.system.dto.sdk.TemplateDTO;
|
||||||
import io.metersphere.system.file.FileRequest;
|
import io.metersphere.system.file.FileRequest;
|
||||||
|
import io.metersphere.system.log.constants.OperationLogModule;
|
||||||
import io.metersphere.system.mapper.BaseUserMapper;
|
import io.metersphere.system.mapper.BaseUserMapper;
|
||||||
import io.metersphere.system.mapper.TemplateMapper;
|
import io.metersphere.system.mapper.TemplateMapper;
|
||||||
import io.metersphere.system.service.BaseTemplateService;
|
import io.metersphere.system.service.BaseTemplateService;
|
||||||
|
@ -78,11 +79,11 @@ public class BugService {
|
||||||
@Resource
|
@Resource
|
||||||
private ExtBugRelateCaseMapper extBugRelateCaseMapper;
|
private ExtBugRelateCaseMapper extBugRelateCaseMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private FileMetadataMapper fileMetadataMapper;
|
private FileAssociationService fileAssociationService;
|
||||||
@Resource
|
@Resource
|
||||||
private BugAttachmentMapper bugAttachmentMapper;
|
private BugLocalAttachmentMapper bugLocalAttachmentMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private ExtBugAttachmentMapper extBugAttachmentMapper;
|
private ExtBugLocalAttachmentMapper extBugLocalAttachmentMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private FileService fileService;
|
private FileService fileService;
|
||||||
@Resource
|
@Resource
|
||||||
|
@ -90,6 +91,11 @@ public class BugService {
|
||||||
@Resource
|
@Resource
|
||||||
private BugFollowerMapper bugFollowerMapper;
|
private BugFollowerMapper bugFollowerMapper;
|
||||||
|
|
||||||
|
public static final String ADD_BUG_FILE_LOG_URL = "/bug/add";
|
||||||
|
public static final String UPDATE_BUG_FILE_LOG_URL = "/bug/update";
|
||||||
|
public static final String UPLOAD_SOURCE_DIR = "/project";
|
||||||
|
public static final String UPLOAD_APP_DIR = "/bug";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 缺陷列表查询
|
* 缺陷列表查询
|
||||||
*
|
*
|
||||||
|
@ -144,7 +150,7 @@ public class BugService {
|
||||||
// 自定义字段
|
// 自定义字段
|
||||||
handleAndSaveCustomFields(request, false, false);
|
handleAndSaveCustomFields(request, false, false);
|
||||||
// 附件
|
// 附件
|
||||||
handleAndSaveAttachments(request, files, currentUser);
|
handleAndSaveAttachments(request, files, currentUser, ADD_BUG_FILE_LOG_URL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -166,7 +172,7 @@ public class BugService {
|
||||||
// 自定义字段
|
// 自定义字段
|
||||||
handleAndSaveCustomFields(request, true, false);
|
handleAndSaveCustomFields(request, true, false);
|
||||||
// 附件
|
// 附件
|
||||||
handleAndSaveAttachments(request, files, currentUser);
|
handleAndSaveAttachments(request, files, currentUser, UPDATE_BUG_FILE_LOG_URL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -360,7 +366,6 @@ public class BugService {
|
||||||
// }
|
// }
|
||||||
if (StringUtils.isEmpty(bug.getId())) {
|
if (StringUtils.isEmpty(bug.getId())) {
|
||||||
bug.setId(IDGenerator.nextStr());
|
bug.setId(IDGenerator.nextStr());
|
||||||
// TODO: 业务ID生成规则, 暂保留, 后续补充
|
|
||||||
bug.setNum(Long.valueOf(NumGenerator.nextNum(request.getProjectId(), ApplicationNumScope.BUG_MANAGEMENT)).intValue());
|
bug.setNum(Long.valueOf(NumGenerator.nextNum(request.getProjectId(), ApplicationNumScope.BUG_MANAGEMENT)).intValue());
|
||||||
bug.setHandleUsers(request.getHandleUser());
|
bug.setHandleUsers(request.getHandleUser());
|
||||||
bug.setCreateUser(currentUser);
|
bug.setCreateUser(currentUser);
|
||||||
|
@ -473,83 +478,50 @@ public class BugService {
|
||||||
* @param request 请求参数
|
* @param request 请求参数
|
||||||
* @param files 上传附件集合
|
* @param files 上传附件集合
|
||||||
*/
|
*/
|
||||||
private void handleAndSaveAttachments(BugEditRequest request, List<MultipartFile> files, String currentUser) {
|
private void handleAndSaveAttachments(BugEditRequest request, List<MultipartFile> files, String currentUser, String fileLogUrl) {
|
||||||
Map<String, MultipartFile> uploadMinioFiles = new HashMap<>(16);
|
/*
|
||||||
List<BugAttachment> addFiles = new ArrayList<>();
|
* 附件处理逻辑
|
||||||
// 处理删除的本地上传附件及取消关联的附件
|
* 1. 先处理删除, 及取消关联的附件
|
||||||
List<String> deleteIds = new ArrayList<>();
|
* 2. 再处理新上传的, 新关联的附件
|
||||||
|
*/
|
||||||
if (CollectionUtils.isNotEmpty(request.getDeleteLocalFileIds())) {
|
if (CollectionUtils.isNotEmpty(request.getDeleteLocalFileIds())) {
|
||||||
deleteIds.addAll(request.getDeleteLocalFileIds());
|
// 删除本地上传的附件, BUG_LOCAL_ATTACHMENT表
|
||||||
request.getDeleteLocalFileIds().forEach(deleteFileId -> {
|
request.getDeleteLocalFileIds().forEach(deleteFileId -> {
|
||||||
FileRequest fileRequest = new FileRequest();
|
FileRequest fileRequest = buildBugFileRequest(request.getProjectId(), deleteFileId, null);
|
||||||
fileRequest.setProjectId(request.getProjectId());
|
|
||||||
fileRequest.setFileName(deleteFileId);
|
|
||||||
fileRequest.setStorage(StorageType.MINIO.name());
|
|
||||||
try {
|
try {
|
||||||
fileService.deleteFile(fileRequest);
|
fileService.deleteFile(fileRequest);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new MSException(Translator.get("bug_attachment_delete_error"));
|
throw new MSException(Translator.get("bug_attachment_delete_error"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
BugLocalAttachmentExample example = new BugLocalAttachmentExample();
|
||||||
|
example.createCriteria().andBugIdEqualTo(request.getId()).andFileIdIn(request.getDeleteLocalFileIds());
|
||||||
|
bugLocalAttachmentMapper.deleteByExample(example);
|
||||||
}
|
}
|
||||||
if (CollectionUtils.isNotEmpty(request.getUnLinkFileIds())) {
|
if (CollectionUtils.isNotEmpty(request.getUnLinkRefIds())) {
|
||||||
deleteIds.addAll(request.getUnLinkFileIds());
|
// 取消关联的附件, FILE_ASSOCIATION表
|
||||||
}
|
fileAssociationService.deleteBySourceId(request.getUnLinkRefIds(), createFileLogRecord(fileLogUrl, currentUser, request.getProjectId()));
|
||||||
if (CollectionUtils.isNotEmpty(deleteIds)) {
|
|
||||||
BugAttachmentExample example = new BugAttachmentExample();
|
|
||||||
example.createCriteria().andBugIdEqualTo(request.getId()).andFileIdIn(deleteIds);
|
|
||||||
bugAttachmentMapper.deleteByExample(example);
|
|
||||||
// TODO: 如果是第三方平台, 需调用平台插件同步删除附件
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 新本地上传的附件
|
// 新本地上传的附件
|
||||||
|
List<BugLocalAttachment> addFiles = new ArrayList<>();
|
||||||
|
Map<String, MultipartFile> uploadMinioFiles = new HashMap<>(16);
|
||||||
if (CollectionUtils.isNotEmpty(files)) {
|
if (CollectionUtils.isNotEmpty(files)) {
|
||||||
files.forEach(file -> {
|
files.forEach(file -> {
|
||||||
BugAttachment bugAttachment = new BugAttachment();
|
BugLocalAttachment bugAttachment = new BugLocalAttachment();
|
||||||
bugAttachment.setId(IDGenerator.nextStr());
|
bugAttachment.setId(IDGenerator.nextStr());
|
||||||
bugAttachment.setBugId(request.getId());
|
bugAttachment.setBugId(request.getId());
|
||||||
bugAttachment.setFileId(IDGenerator.nextStr());
|
bugAttachment.setFileId(IDGenerator.nextStr());
|
||||||
bugAttachment.setFileName(file.getOriginalFilename());
|
bugAttachment.setFileName(file.getOriginalFilename());
|
||||||
bugAttachment.setSize(file.getSize());
|
bugAttachment.setSize(file.getSize());
|
||||||
bugAttachment.setLocal(true);
|
|
||||||
bugAttachment.setCreateTime(System.currentTimeMillis());
|
bugAttachment.setCreateTime(System.currentTimeMillis());
|
||||||
bugAttachment.setCreateUser(currentUser);
|
bugAttachment.setCreateUser(currentUser);
|
||||||
addFiles.add(bugAttachment);
|
addFiles.add(bugAttachment);
|
||||||
uploadMinioFiles.put(bugAttachment.getFileId(), file);
|
uploadMinioFiles.put(bugAttachment.getFileId(), file);
|
||||||
});
|
});
|
||||||
}
|
extBugLocalAttachmentMapper.batchInsert(addFiles);
|
||||||
// 新关联的附件
|
|
||||||
List<String> linkIds = request.getLinkFileIds();
|
|
||||||
if (CollectionUtils.isNotEmpty(linkIds)) {
|
|
||||||
FileMetadataExample example = new FileMetadataExample();
|
|
||||||
example.createCriteria().andIdIn(linkIds);
|
|
||||||
List<FileMetadata> linkFiles = fileMetadataMapper.selectByExample(example);
|
|
||||||
Map<String, FileMetadata> linkFileMap = linkFiles.stream().collect(Collectors.toMap(FileMetadata::getId, v -> v));
|
|
||||||
linkIds.forEach(fileId -> {
|
|
||||||
FileMetadata fileMetadata = linkFileMap.get(fileId);
|
|
||||||
if (fileMetadata == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
BugAttachment bugAttachment = new BugAttachment();
|
|
||||||
bugAttachment.setId(IDGenerator.nextStr());
|
|
||||||
bugAttachment.setBugId(request.getId());
|
|
||||||
bugAttachment.setFileId(fileId);
|
|
||||||
bugAttachment.setFileName(fileMetadata.getName());
|
|
||||||
bugAttachment.setSize(fileMetadata.getSize());
|
|
||||||
bugAttachment.setLocal(false);
|
|
||||||
bugAttachment.setCreateTime(System.currentTimeMillis());
|
|
||||||
bugAttachment.setCreateUser(currentUser);
|
|
||||||
addFiles.add(bugAttachment);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (CollectionUtils.isNotEmpty(addFiles)) {
|
|
||||||
extBugAttachmentMapper.batchInsert(addFiles);
|
|
||||||
}
|
|
||||||
// TODO: 如果是第三方平台, 需调用平台插件同步上传附件
|
|
||||||
uploadMinioFiles.forEach((fileId, file) -> {
|
uploadMinioFiles.forEach((fileId, file) -> {
|
||||||
FileRequest fileRequest = new FileRequest();
|
FileRequest fileRequest = buildBugFileRequest(request.getProjectId(), fileId, file.getOriginalFilename());
|
||||||
fileRequest.setFileName(file.getOriginalFilename());
|
|
||||||
fileRequest.setResourceId("/" + MsFileUtils.BUG_MANAGEMENT_DIR + "/" + request.getProjectId() + "/" + fileId);
|
|
||||||
fileRequest.setStorage(StorageType.MINIO.name());
|
|
||||||
try {
|
try {
|
||||||
fileService.upload(file, fileRequest);
|
fileService.upload(file, fileRequest);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -557,6 +529,12 @@ public class BugService {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// 新关联的附件
|
||||||
|
if (CollectionUtils.isNotEmpty(request.getLinkFileIds())) {
|
||||||
|
fileAssociationService.association(request.getId(), FileAssociationSourceUtil.SOURCE_TYPE_BUG, request.getLinkFileIds(), false,
|
||||||
|
createFileLogRecord(fileLogUrl, currentUser, request.getProjectId()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * 封装缺陷平台请求参数
|
// * 封装缺陷平台请求参数
|
||||||
|
@ -653,4 +631,24 @@ public class BugService {
|
||||||
// }
|
// }
|
||||||
// return template;
|
// return template;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
private FileLogRecord createFileLogRecord(String logUrl, String operator, String projectId){
|
||||||
|
return FileLogRecord.builder()
|
||||||
|
.logModule(OperationLogModule.BUG_MANAGEMENT)
|
||||||
|
.requestMethod(HttpMethodConstants.POST.name())
|
||||||
|
.requestUrl(logUrl)
|
||||||
|
.operator(operator)
|
||||||
|
.projectId(projectId)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private FileRequest buildBugFileRequest(String projectId, String resourceId, String fileName) {
|
||||||
|
FileRequest fileRequest = new FileRequest();
|
||||||
|
fileRequest.setFolder(UPLOAD_SOURCE_DIR + "/" + projectId + UPLOAD_APP_DIR + "/" + resourceId);
|
||||||
|
fileRequest.setProjectId(projectId);
|
||||||
|
fileRequest.setResourceId(resourceId);
|
||||||
|
fileRequest.setFileName(StringUtils.isEmpty(fileName) ? null : fileName);
|
||||||
|
fileRequest.setStorage(StorageType.MINIO.name());
|
||||||
|
return fileRequest;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@
|
||||||
<!-- <table tableName="bug_content" />-->
|
<!-- <table tableName="bug_content" />-->
|
||||||
<!-- <table tableName="bug_follower" />-->
|
<!-- <table tableName="bug_follower" />-->
|
||||||
<!-- <table tableName="bug_comment" />-->
|
<!-- <table tableName="bug_comment" />-->
|
||||||
<!-- <table tableName="bug_attachment" />-->
|
<table tableName="bug_local_attachment" />
|
||||||
<!-- <table tableName="bug_custom_field" />-->
|
<!-- <table tableName="bug_custom_field" />-->
|
||||||
<!-- <table tableName="bug_relation_case" />-->
|
<!-- <table tableName="bug_relation_case" />-->
|
||||||
<!-- <table tableName="bug_history" />-->
|
<!-- <table tableName="bug_history" />-->
|
||||||
|
|
|
@ -440,13 +440,13 @@ public class BugControllerTests extends BaseTest {
|
||||||
request.setHandleUser("admin");
|
request.setHandleUser("admin");
|
||||||
request.setTemplateId("default-bug-template");
|
request.setTemplateId("default-bug-template");
|
||||||
request.setStatus("prepare");
|
request.setStatus("prepare");
|
||||||
request.setLinkFileIds(List.of("default-bug-file-id-1", "default-bug-file-id-3"));
|
request.setLinkFileIds(List.of("default-bug-file-id-1"));
|
||||||
Map<String, String> customFieldMap = new HashMap<>();
|
Map<String, String> customFieldMap = new HashMap<>();
|
||||||
customFieldMap.put("custom-field", "oasis");
|
customFieldMap.put("custom-field", "oasis");
|
||||||
customFieldMap.put("test_field", JSON.toJSONString(List.of("test")));
|
customFieldMap.put("test_field", JSON.toJSONString(List.of("test")));
|
||||||
if (isUpdate) {
|
if (isUpdate) {
|
||||||
request.setId("default-bug-id");
|
request.setId("default-bug-id");
|
||||||
request.setUnLinkFileIds(List.of("default-bug-file-id-1"));
|
request.setUnLinkRefIds(List.of("default-bug-file-id-1"));
|
||||||
request.setDeleteLocalFileIds(List.of("default-bug-file-id"));
|
request.setDeleteLocalFileIds(List.of("default-bug-file-id"));
|
||||||
request.setLinkFileIds(List.of("default-bug-file-id-2"));
|
request.setLinkFileIds(List.of("default-bug-file-id-2"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,4 +102,6 @@ public class OperationLogModule {
|
||||||
public static final String API_DEBUG = "API_DEBUG";
|
public static final String API_DEBUG = "API_DEBUG";
|
||||||
//接口管理-环境
|
//接口管理-环境
|
||||||
public static final String API_DEFINITION_ENVIRONMENT = "API_DEFINITION_ENVIRONMENT";
|
public static final String API_DEFINITION_ENVIRONMENT = "API_DEFINITION_ENVIRONMENT";
|
||||||
|
// 缺陷管理
|
||||||
|
public static final String BUG_MANAGEMENT = "BUG_MANAGEMENT";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue