feat(用例管理): 用例评审新增未评审数量以及脑图保存调整

This commit is contained in:
guoyuqi 2024-06-04 15:54:13 +08:00 committed by Craftsman
parent 13b683d671
commit d4f37273fb
15 changed files with 1706 additions and 59 deletions

View File

@ -0,0 +1,129 @@
package io.metersphere.functional.domain;
import io.metersphere.validation.groups.*;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import lombok.Data;
@Data
public class MindAdditionalNode implements Serializable {
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{mind_additional_node.id.not_blank}", groups = {Updated.class})
@Size(min = 1, max = 50, message = "{mind_additional_node.id.length_range}", groups = {Created.class, Updated.class})
private String id;
@Schema(description = "项目ID", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{mind_additional_node.project_id.not_blank}", groups = {Created.class})
@Size(min = 1, max = 50, message = "{mind_additional_node.project_id.length_range}", groups = {Created.class, Updated.class})
private String projectId;
@Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{mind_additional_node.name.not_blank}", groups = {Created.class})
@Size(min = 1, max = 255, message = "{mind_additional_node.name.length_range}", groups = {Created.class, Updated.class})
private String name;
@Schema(description = "父节点ID", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{mind_additional_node.parent_id.not_blank}", groups = {Created.class})
@Size(min = 1, max = 50, message = "{mind_additional_node.parent_id.length_range}", groups = {Created.class, Updated.class})
private String parentId;
@Schema(description = "同一节点下的顺序", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "{mind_additional_node.pos.not_blank}", groups = {Created.class})
private Long pos;
@Schema(description = "创建时间")
private Long createTime;
@Schema(description = "更新时间")
private Long updateTime;
@Schema(description = "创建人")
private String createUser;
@Schema(description = "更新人")
private String updateUser;
private static final long serialVersionUID = 1L;
public enum Column {
id("id", "id", "VARCHAR", false),
projectId("project_id", "projectId", "VARCHAR", false),
name("name", "name", "VARCHAR", true),
parentId("parent_id", "parentId", "VARCHAR", false),
pos("pos", "pos", "BIGINT", false),
createTime("create_time", "createTime", "BIGINT", false),
updateTime("update_time", "updateTime", "BIGINT", false),
createUser("create_user", "createUser", "VARCHAR", false),
updateUser("update_user", "updateUser", "VARCHAR", false);
private static final String BEGINNING_DELIMITER = "`";
private static final String ENDING_DELIMITER = "`";
private final String column;
private final boolean isColumnNameDelimited;
private final String javaProperty;
private final String jdbcType;
public String value() {
return this.column;
}
public String getValue() {
return this.column;
}
public String getJavaProperty() {
return this.javaProperty;
}
public String getJdbcType() {
return this.jdbcType;
}
Column(String column, String javaProperty, String jdbcType, boolean isColumnNameDelimited) {
this.column = column;
this.javaProperty = javaProperty;
this.jdbcType = jdbcType;
this.isColumnNameDelimited = isColumnNameDelimited;
}
public String desc() {
return this.getEscapedColumnName() + " DESC";
}
public String asc() {
return this.getEscapedColumnName() + " ASC";
}
public static Column[] excludes(Column ... excludes) {
ArrayList<Column> columns = new ArrayList<>(Arrays.asList(Column.values()));
if (excludes != null && excludes.length > 0) {
columns.removeAll(new ArrayList<>(Arrays.asList(excludes)));
}
return columns.toArray(new Column[]{});
}
public static Column[] all() {
return Column.values();
}
public String getEscapedColumnName() {
if (this.isColumnNameDelimited) {
return new StringBuilder().append(BEGINNING_DELIMITER).append(this.column).append(ENDING_DELIMITER).toString();
} else {
return this.column;
}
}
public String getAliasedEscapedColumnName() {
return this.getEscapedColumnName();
}
}
}

View File

@ -0,0 +1,800 @@
package io.metersphere.functional.domain;
import java.util.ArrayList;
import java.util.List;
public class MindAdditionalNodeExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public MindAdditionalNodeExample() {
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 Criteria andProjectIdIsNull() {
addCriterion("project_id is null");
return (Criteria) this;
}
public Criteria andProjectIdIsNotNull() {
addCriterion("project_id is not null");
return (Criteria) this;
}
public Criteria andProjectIdEqualTo(String value) {
addCriterion("project_id =", value, "projectId");
return (Criteria) this;
}
public Criteria andProjectIdNotEqualTo(String value) {
addCriterion("project_id <>", value, "projectId");
return (Criteria) this;
}
public Criteria andProjectIdGreaterThan(String value) {
addCriterion("project_id >", value, "projectId");
return (Criteria) this;
}
public Criteria andProjectIdGreaterThanOrEqualTo(String value) {
addCriterion("project_id >=", value, "projectId");
return (Criteria) this;
}
public Criteria andProjectIdLessThan(String value) {
addCriterion("project_id <", value, "projectId");
return (Criteria) this;
}
public Criteria andProjectIdLessThanOrEqualTo(String value) {
addCriterion("project_id <=", value, "projectId");
return (Criteria) this;
}
public Criteria andProjectIdLike(String value) {
addCriterion("project_id like", value, "projectId");
return (Criteria) this;
}
public Criteria andProjectIdNotLike(String value) {
addCriterion("project_id not like", value, "projectId");
return (Criteria) this;
}
public Criteria andProjectIdIn(List<String> values) {
addCriterion("project_id in", values, "projectId");
return (Criteria) this;
}
public Criteria andProjectIdNotIn(List<String> values) {
addCriterion("project_id not in", values, "projectId");
return (Criteria) this;
}
public Criteria andProjectIdBetween(String value1, String value2) {
addCriterion("project_id between", value1, value2, "projectId");
return (Criteria) this;
}
public Criteria andProjectIdNotBetween(String value1, String value2) {
addCriterion("project_id not between", value1, value2, "projectId");
return (Criteria) this;
}
public Criteria andNameIsNull() {
addCriterion("`name` is null");
return (Criteria) this;
}
public Criteria andNameIsNotNull() {
addCriterion("`name` is not null");
return (Criteria) this;
}
public Criteria andNameEqualTo(String value) {
addCriterion("`name` =", value, "name");
return (Criteria) this;
}
public Criteria andNameNotEqualTo(String value) {
addCriterion("`name` <>", value, "name");
return (Criteria) this;
}
public Criteria andNameGreaterThan(String value) {
addCriterion("`name` >", value, "name");
return (Criteria) this;
}
public Criteria andNameGreaterThanOrEqualTo(String value) {
addCriterion("`name` >=", value, "name");
return (Criteria) this;
}
public Criteria andNameLessThan(String value) {
addCriterion("`name` <", value, "name");
return (Criteria) this;
}
public Criteria andNameLessThanOrEqualTo(String value) {
addCriterion("`name` <=", value, "name");
return (Criteria) this;
}
public Criteria andNameLike(String value) {
addCriterion("`name` like", value, "name");
return (Criteria) this;
}
public Criteria andNameNotLike(String value) {
addCriterion("`name` not like", value, "name");
return (Criteria) this;
}
public Criteria andNameIn(List<String> values) {
addCriterion("`name` in", values, "name");
return (Criteria) this;
}
public Criteria andNameNotIn(List<String> values) {
addCriterion("`name` not in", values, "name");
return (Criteria) this;
}
public Criteria andNameBetween(String value1, String value2) {
addCriterion("`name` between", value1, value2, "name");
return (Criteria) this;
}
public Criteria andNameNotBetween(String value1, String value2) {
addCriterion("`name` not between", value1, value2, "name");
return (Criteria) this;
}
public Criteria andParentIdIsNull() {
addCriterion("parent_id is null");
return (Criteria) this;
}
public Criteria andParentIdIsNotNull() {
addCriterion("parent_id is not null");
return (Criteria) this;
}
public Criteria andParentIdEqualTo(String value) {
addCriterion("parent_id =", value, "parentId");
return (Criteria) this;
}
public Criteria andParentIdNotEqualTo(String value) {
addCriterion("parent_id <>", value, "parentId");
return (Criteria) this;
}
public Criteria andParentIdGreaterThan(String value) {
addCriterion("parent_id >", value, "parentId");
return (Criteria) this;
}
public Criteria andParentIdGreaterThanOrEqualTo(String value) {
addCriterion("parent_id >=", value, "parentId");
return (Criteria) this;
}
public Criteria andParentIdLessThan(String value) {
addCriterion("parent_id <", value, "parentId");
return (Criteria) this;
}
public Criteria andParentIdLessThanOrEqualTo(String value) {
addCriterion("parent_id <=", value, "parentId");
return (Criteria) this;
}
public Criteria andParentIdLike(String value) {
addCriterion("parent_id like", value, "parentId");
return (Criteria) this;
}
public Criteria andParentIdNotLike(String value) {
addCriterion("parent_id not like", value, "parentId");
return (Criteria) this;
}
public Criteria andParentIdIn(List<String> values) {
addCriterion("parent_id in", values, "parentId");
return (Criteria) this;
}
public Criteria andParentIdNotIn(List<String> values) {
addCriterion("parent_id not in", values, "parentId");
return (Criteria) this;
}
public Criteria andParentIdBetween(String value1, String value2) {
addCriterion("parent_id between", value1, value2, "parentId");
return (Criteria) this;
}
public Criteria andParentIdNotBetween(String value1, String value2) {
addCriterion("parent_id not between", value1, value2, "parentId");
return (Criteria) this;
}
public Criteria andPosIsNull() {
addCriterion("pos is null");
return (Criteria) this;
}
public Criteria andPosIsNotNull() {
addCriterion("pos is not null");
return (Criteria) this;
}
public Criteria andPosEqualTo(Long value) {
addCriterion("pos =", value, "pos");
return (Criteria) this;
}
public Criteria andPosNotEqualTo(Long value) {
addCriterion("pos <>", value, "pos");
return (Criteria) this;
}
public Criteria andPosGreaterThan(Long value) {
addCriterion("pos >", value, "pos");
return (Criteria) this;
}
public Criteria andPosGreaterThanOrEqualTo(Long value) {
addCriterion("pos >=", value, "pos");
return (Criteria) this;
}
public Criteria andPosLessThan(Long value) {
addCriterion("pos <", value, "pos");
return (Criteria) this;
}
public Criteria andPosLessThanOrEqualTo(Long value) {
addCriterion("pos <=", value, "pos");
return (Criteria) this;
}
public Criteria andPosIn(List<Long> values) {
addCriterion("pos in", values, "pos");
return (Criteria) this;
}
public Criteria andPosNotIn(List<Long> values) {
addCriterion("pos not in", values, "pos");
return (Criteria) this;
}
public Criteria andPosBetween(Long value1, Long value2) {
addCriterion("pos between", value1, value2, "pos");
return (Criteria) this;
}
public Criteria andPosNotBetween(Long value1, Long value2) {
addCriterion("pos not between", value1, value2, "pos");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null");
return (Criteria) this;
}
public Criteria andCreateTimeIsNotNull() {
addCriterion("create_time is not null");
return (Criteria) this;
}
public Criteria andCreateTimeEqualTo(Long value) {
addCriterion("create_time =", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotEqualTo(Long value) {
addCriterion("create_time <>", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThan(Long value) {
addCriterion("create_time >", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThanOrEqualTo(Long value) {
addCriterion("create_time >=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThan(Long value) {
addCriterion("create_time <", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThanOrEqualTo(Long value) {
addCriterion("create_time <=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeIn(List<Long> values) {
addCriterion("create_time in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotIn(List<Long> values) {
addCriterion("create_time not in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeBetween(Long value1, Long value2) {
addCriterion("create_time between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotBetween(Long value1, Long value2) {
addCriterion("create_time not between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNull() {
addCriterion("update_time is null");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNotNull() {
addCriterion("update_time is not null");
return (Criteria) this;
}
public Criteria andUpdateTimeEqualTo(Long value) {
addCriterion("update_time =", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotEqualTo(Long value) {
addCriterion("update_time <>", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThan(Long value) {
addCriterion("update_time >", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThanOrEqualTo(Long value) {
addCriterion("update_time >=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThan(Long value) {
addCriterion("update_time <", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThanOrEqualTo(Long value) {
addCriterion("update_time <=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIn(List<Long> values) {
addCriterion("update_time in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotIn(List<Long> values) {
addCriterion("update_time not in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeBetween(Long value1, Long value2) {
addCriterion("update_time between", value1, value2, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotBetween(Long value1, Long value2) {
addCriterion("update_time not between", value1, value2, "updateTime");
return (Criteria) this;
}
public Criteria andCreateUserIsNull() {
addCriterion("create_user is null");
return (Criteria) this;
}
public Criteria andCreateUserIsNotNull() {
addCriterion("create_user is not null");
return (Criteria) this;
}
public Criteria andCreateUserEqualTo(String value) {
addCriterion("create_user =", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserNotEqualTo(String value) {
addCriterion("create_user <>", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserGreaterThan(String value) {
addCriterion("create_user >", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserGreaterThanOrEqualTo(String value) {
addCriterion("create_user >=", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserLessThan(String value) {
addCriterion("create_user <", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserLessThanOrEqualTo(String value) {
addCriterion("create_user <=", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserLike(String value) {
addCriterion("create_user like", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserNotLike(String value) {
addCriterion("create_user not like", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserIn(List<String> values) {
addCriterion("create_user in", values, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserNotIn(List<String> values) {
addCriterion("create_user not in", values, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserBetween(String value1, String value2) {
addCriterion("create_user between", value1, value2, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserNotBetween(String value1, String value2) {
addCriterion("create_user not between", value1, value2, "createUser");
return (Criteria) this;
}
public Criteria andUpdateUserIsNull() {
addCriterion("update_user is null");
return (Criteria) this;
}
public Criteria andUpdateUserIsNotNull() {
addCriterion("update_user is not null");
return (Criteria) this;
}
public Criteria andUpdateUserEqualTo(String value) {
addCriterion("update_user =", value, "updateUser");
return (Criteria) this;
}
public Criteria andUpdateUserNotEqualTo(String value) {
addCriterion("update_user <>", value, "updateUser");
return (Criteria) this;
}
public Criteria andUpdateUserGreaterThan(String value) {
addCriterion("update_user >", value, "updateUser");
return (Criteria) this;
}
public Criteria andUpdateUserGreaterThanOrEqualTo(String value) {
addCriterion("update_user >=", value, "updateUser");
return (Criteria) this;
}
public Criteria andUpdateUserLessThan(String value) {
addCriterion("update_user <", value, "updateUser");
return (Criteria) this;
}
public Criteria andUpdateUserLessThanOrEqualTo(String value) {
addCriterion("update_user <=", value, "updateUser");
return (Criteria) this;
}
public Criteria andUpdateUserLike(String value) {
addCriterion("update_user like", value, "updateUser");
return (Criteria) this;
}
public Criteria andUpdateUserNotLike(String value) {
addCriterion("update_user not like", value, "updateUser");
return (Criteria) this;
}
public Criteria andUpdateUserIn(List<String> values) {
addCriterion("update_user in", values, "updateUser");
return (Criteria) this;
}
public Criteria andUpdateUserNotIn(List<String> values) {
addCriterion("update_user not in", values, "updateUser");
return (Criteria) this;
}
public Criteria andUpdateUserBetween(String value1, String value2) {
addCriterion("update_user between", value1, value2, "updateUser");
return (Criteria) this;
}
public Criteria andUpdateUserNotBetween(String value1, String value2) {
addCriterion("update_user not between", value1, value2, "updateUser");
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

@ -0,0 +1,34 @@
package io.metersphere.functional.mapper;
import io.metersphere.functional.domain.MindAdditionalNode;
import io.metersphere.functional.domain.MindAdditionalNodeExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface MindAdditionalNodeMapper {
long countByExample(MindAdditionalNodeExample example);
int deleteByExample(MindAdditionalNodeExample example);
int deleteByPrimaryKey(String id);
int insert(MindAdditionalNode record);
int insertSelective(MindAdditionalNode record);
List<MindAdditionalNode> selectByExample(MindAdditionalNodeExample example);
MindAdditionalNode selectByPrimaryKey(String id);
int updateByExampleSelective(@Param("record") MindAdditionalNode record, @Param("example") MindAdditionalNodeExample example);
int updateByExample(@Param("record") MindAdditionalNode record, @Param("example") MindAdditionalNodeExample example);
int updateByPrimaryKeySelective(MindAdditionalNode record);
int updateByPrimaryKey(MindAdditionalNode record);
int batchInsert(@Param("list") List<MindAdditionalNode> list);
int batchInsertSelective(@Param("list") List<MindAdditionalNode> list, @Param("selective") MindAdditionalNode.Column ... selective);
}

View File

@ -0,0 +1,328 @@
<?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.functional.mapper.MindAdditionalNodeMapper">
<resultMap id="BaseResultMap" type="io.metersphere.functional.domain.MindAdditionalNode">
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="project_id" jdbcType="VARCHAR" property="projectId" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="parent_id" jdbcType="VARCHAR" property="parentId" />
<result column="pos" jdbcType="BIGINT" property="pos" />
<result column="create_time" jdbcType="BIGINT" property="createTime" />
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
<result column="create_user" jdbcType="VARCHAR" property="createUser" />
<result column="update_user" jdbcType="VARCHAR" property="updateUser" />
</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, project_id, `name`, parent_id, pos, create_time, update_time, create_user, update_user
</sql>
<select id="selectByExample" parameterType="io.metersphere.functional.domain.MindAdditionalNodeExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from mind_additional_node
<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="BaseResultMap">
select
<include refid="Base_Column_List" />
from mind_additional_node
where id = #{id,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from mind_additional_node
where id = #{id,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="io.metersphere.functional.domain.MindAdditionalNodeExample">
delete from mind_additional_node
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="io.metersphere.functional.domain.MindAdditionalNode">
insert into mind_additional_node (id, project_id, `name`,
parent_id, pos, create_time,
update_time, create_user, update_user
)
values (#{id,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
#{parentId,jdbcType=VARCHAR}, #{pos,jdbcType=BIGINT}, #{createTime,jdbcType=BIGINT},
#{updateTime,jdbcType=BIGINT}, #{createUser,jdbcType=VARCHAR}, #{updateUser,jdbcType=VARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="io.metersphere.functional.domain.MindAdditionalNode">
insert into mind_additional_node
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="projectId != null">
project_id,
</if>
<if test="name != null">
`name`,
</if>
<if test="parentId != null">
parent_id,
</if>
<if test="pos != null">
pos,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="createUser != null">
create_user,
</if>
<if test="updateUser != null">
update_user,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=VARCHAR},
</if>
<if test="projectId != null">
#{projectId,jdbcType=VARCHAR},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="parentId != null">
#{parentId,jdbcType=VARCHAR},
</if>
<if test="pos != null">
#{pos,jdbcType=BIGINT},
</if>
<if test="createTime != null">
#{createTime,jdbcType=BIGINT},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=BIGINT},
</if>
<if test="createUser != null">
#{createUser,jdbcType=VARCHAR},
</if>
<if test="updateUser != null">
#{updateUser,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.functional.domain.MindAdditionalNodeExample" resultType="java.lang.Long">
select count(*) from mind_additional_node
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update mind_additional_node
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=VARCHAR},
</if>
<if test="record.projectId != null">
project_id = #{record.projectId,jdbcType=VARCHAR},
</if>
<if test="record.name != null">
`name` = #{record.name,jdbcType=VARCHAR},
</if>
<if test="record.parentId != null">
parent_id = #{record.parentId,jdbcType=VARCHAR},
</if>
<if test="record.pos != null">
pos = #{record.pos,jdbcType=BIGINT},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=BIGINT},
</if>
<if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=BIGINT},
</if>
<if test="record.createUser != null">
create_user = #{record.createUser,jdbcType=VARCHAR},
</if>
<if test="record.updateUser != null">
update_user = #{record.updateUser,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update mind_additional_node
set id = #{record.id,jdbcType=VARCHAR},
project_id = #{record.projectId,jdbcType=VARCHAR},
`name` = #{record.name,jdbcType=VARCHAR},
parent_id = #{record.parentId,jdbcType=VARCHAR},
pos = #{record.pos,jdbcType=BIGINT},
create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT},
create_user = #{record.createUser,jdbcType=VARCHAR},
update_user = #{record.updateUser,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.functional.domain.MindAdditionalNode">
update mind_additional_node
<set>
<if test="projectId != null">
project_id = #{projectId,jdbcType=VARCHAR},
</if>
<if test="name != null">
`name` = #{name,jdbcType=VARCHAR},
</if>
<if test="parentId != null">
parent_id = #{parentId,jdbcType=VARCHAR},
</if>
<if test="pos != null">
pos = #{pos,jdbcType=BIGINT},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=BIGINT},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=BIGINT},
</if>
<if test="createUser != null">
create_user = #{createUser,jdbcType=VARCHAR},
</if>
<if test="updateUser != null">
update_user = #{updateUser,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="io.metersphere.functional.domain.MindAdditionalNode">
update mind_additional_node
set project_id = #{projectId,jdbcType=VARCHAR},
`name` = #{name,jdbcType=VARCHAR},
parent_id = #{parentId,jdbcType=VARCHAR},
pos = #{pos,jdbcType=BIGINT},
create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT},
create_user = #{createUser,jdbcType=VARCHAR},
update_user = #{updateUser,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
<insert id="batchInsert" parameterType="map">
insert into mind_additional_node
(id, project_id, `name`, parent_id, pos, create_time, update_time, create_user, update_user
)
values
<foreach collection="list" item="item" separator=",">
(#{item.id,jdbcType=VARCHAR}, #{item.projectId,jdbcType=VARCHAR}, #{item.name,jdbcType=VARCHAR},
#{item.parentId,jdbcType=VARCHAR}, #{item.pos,jdbcType=BIGINT}, #{item.createTime,jdbcType=BIGINT},
#{item.updateTime,jdbcType=BIGINT}, #{item.createUser,jdbcType=VARCHAR}, #{item.updateUser,jdbcType=VARCHAR}
)
</foreach>
</insert>
<insert id="batchInsertSelective" parameterType="map">
insert into mind_additional_node (
<foreach collection="selective" item="column" separator=",">
${column.escapedColumnName}
</foreach>
)
values
<foreach collection="list" item="item" separator=",">
(
<foreach collection="selective" item="column" separator=",">
<if test="'id'.toString() == column.value">
#{item.id,jdbcType=VARCHAR}
</if>
<if test="'project_id'.toString() == column.value">
#{item.projectId,jdbcType=VARCHAR}
</if>
<if test="'name'.toString() == column.value">
#{item.name,jdbcType=VARCHAR}
</if>
<if test="'parent_id'.toString() == column.value">
#{item.parentId,jdbcType=VARCHAR}
</if>
<if test="'pos'.toString() == column.value">
#{item.pos,jdbcType=BIGINT}
</if>
<if test="'create_time'.toString() == column.value">
#{item.createTime,jdbcType=BIGINT}
</if>
<if test="'update_time'.toString() == column.value">
#{item.updateTime,jdbcType=BIGINT}
</if>
<if test="'create_user'.toString() == column.value">
#{item.createUser,jdbcType=VARCHAR}
</if>
<if test="'update_user'.toString() == column.value">
#{item.updateUser,jdbcType=VARCHAR}
</if>
</foreach>
)
</foreach>
</insert>
</mapper>

View File

@ -11,6 +11,32 @@ CREATE TABLE IF NOT EXISTS platform_source(
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_general_ci COMMENT = '平台对接保存参数';
CREATE TABLE IF NOT EXISTS mind_additional_node(
`id` VARCHAR(50) NOT NULL COMMENT 'ID' ,
`project_id` VARCHAR(50) NOT NULL COMMENT '项目ID' ,
`name` VARCHAR(255) NOT NULL COMMENT '名称' ,
`parent_id` VARCHAR(50) NOT NULL DEFAULT 'NONE' COMMENT '父节点ID' ,
`pos` BIGINT NOT NULL DEFAULT 0 COMMENT '同一节点下的顺序' ,
`create_time` BIGINT NOT NULL COMMENT '创建时间' ,
`update_time` BIGINT NOT NULL COMMENT '更新时间' ,
`create_user` VARCHAR(50) NOT NULL COMMENT '创建人' ,
`update_user` VARCHAR(50) NOT NULL COMMENT '更新人' ,
PRIMARY KEY (id)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_general_ci COMMENT = '平台对接保存参数';
CREATE INDEX idx_project_id ON mind_additional_node(project_id);
CREATE INDEX idx_name ON mind_additional_node(name);
CREATE INDEX idx_pos ON mind_additional_node(pos);
CREATE INDEX idx_parent_id ON mind_additional_node(parent_id);
CREATE INDEX idx_create_user ON mind_additional_node(create_user);
CREATE INDEX idx_update_user ON mind_additional_node(update_user);
CREATE INDEX idx_create_time ON mind_additional_node(create_time);
CREATE INDEX idx_update_time ON mind_additional_node(update_time);
CREATE UNIQUE INDEX uq_name_project_parent ON mind_additional_node(project_id,name,parent_id);
-- 测试计划增加排序字段
alter table test_plan
ADD COLUMN `pos` BIGINT NOT NULL DEFAULT 0 COMMENT '自定义排序';

View File

@ -27,6 +27,9 @@ public class CaseReviewDTO extends CaseReview {
@Schema(description = "已评审过得用例数")
private int reviewedCount;
@Schema(description = "未评审得用例数")
private int unReviewCount;
@Schema(description = "关注标识")
private Boolean followFlag;

View File

@ -1,5 +1,6 @@
package io.metersphere.functional.dto;
import io.metersphere.sdk.constants.ModuleConstants;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import lombok.AllArgsConstructor;
@ -20,6 +21,6 @@ public class MinderOptionDTO {
@Schema(description = "节点类型")
@NotBlank(message = "{functional_case_test.test_type.not_blank}")
private String type;
private String type = ModuleConstants.ROOT_NODE_PARENT_ID;
}

View File

@ -809,6 +809,7 @@
cf.name = 'functional_priority'
AND cf.scene = 'FUNCTIONAL'
AND cf.internal= true
order by fc.pos
</select>
<select id="getMinderCaseReviewList" resultType="io.metersphere.functional.dto.FunctionalCaseMindDTO">

View File

@ -31,6 +31,9 @@ public class FunctionalCaseMinderEditRequest implements Serializable {
@Schema(description = "新增/修改的模块集合(只记录操作的节点,节点下的子节点不需要记录)", requiredMode = Schema.RequiredMode.REQUIRED)
private List<FunctionalCaseModuleEditRequest> updateModuleList;
@Schema(description = "新增/修改的空白节点集合(只记录操作的节点,节点下的子节点不需要记录)", requiredMode = Schema.RequiredMode.REQUIRED)
private List<MindAdditionalNodeRequest> additionalNodeList;
@Schema(description = "删除的模块/用例的集合", requiredMode = Schema.RequiredMode.REQUIRED)
private List<MinderOptionDTO> deleteResourceList;

View File

@ -0,0 +1,43 @@
package io.metersphere.functional.request;
import io.metersphere.validation.groups.Created;
import io.metersphere.validation.groups.Updated;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
/**
* @author guoyuqi
*/
@Data
public class MindAdditionalNodeRequest implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{mind_additional_node.id.not_blank}", groups = {Updated.class})
private String id;
@Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{mind_additional_node.name.not_blank}", groups = {Created.class})
private String name;
@Schema(description = "父节点ID()", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{mind_additional_node.parent_id.not_blank}", groups = {Created.class})
private String parentId;
@Schema(description = "操作类型(新增(ADD)/更新(UPDATE)", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{fake_error.relation.not_blank}")
private String type;
@Schema(description = "移动方式(节点移动或新增时需要)", requiredMode = Schema.RequiredMode.REQUIRED)
private String moveMode;
@Schema(description = "移动目标(节点移动或新增时需要)", requiredMode = Schema.RequiredMode.REQUIRED)
private String targetId;
}

View File

@ -133,6 +133,7 @@ public class CaseReviewService {
caseReviewDTO.setReReviewedCount(0);
caseReviewDTO.setUnderReviewedCount(0);
caseReviewDTO.setReviewedCount(0);
caseReviewDTO.setUnReviewCount(0);
} else {
buildAboutCaseCount(caseReviewDTO, caseReviewFunctionalCaseList);
}
@ -174,6 +175,13 @@ public class CaseReviewService {
caseReviewDTO.setUnderReviewedCount(underReviewedList.size());
caseReviewDTO.setReviewedCount(caseReviewDTO.getPassCount() + caseReviewDTO.getUnPassCount());
List<CaseReviewFunctionalCase> unReviewList = statusCaseMap.get(FunctionalCaseReviewStatus.UN_REVIEWED.toString());
if (unReviewList == null) {
unReviewList = new ArrayList<>();
}
caseReviewDTO.setUnReviewCount(unReviewList.size());
}
/**

View File

@ -9,9 +9,12 @@ import io.metersphere.functional.request.*;
import io.metersphere.project.domain.Project;
import io.metersphere.project.mapper.ExtBaseProjectVersionMapper;
import io.metersphere.project.mapper.ProjectMapper;
import io.metersphere.project.service.ProjectTemplateService;
import io.metersphere.project.utils.NodeSortUtils;
import io.metersphere.sdk.constants.ExecStatus;
import io.metersphere.sdk.constants.HttpMethodConstants;
import io.metersphere.sdk.constants.ModuleConstants;
import io.metersphere.sdk.constants.TemplateScene;
import io.metersphere.sdk.exception.MSException;
import io.metersphere.sdk.util.BeanUtils;
import io.metersphere.sdk.util.JSON;
@ -20,6 +23,8 @@ import io.metersphere.system.domain.CustomField;
import io.metersphere.system.domain.CustomFieldExample;
import io.metersphere.system.domain.User;
import io.metersphere.system.dto.sdk.OptionDTO;
import io.metersphere.system.dto.sdk.TemplateCustomFieldDTO;
import io.metersphere.system.dto.sdk.TemplateDTO;
import io.metersphere.system.dto.sdk.enums.MoveTypeEnum;
import io.metersphere.system.log.constants.OperationLogModule;
import io.metersphere.system.log.constants.OperationLogType;
@ -58,7 +63,6 @@ public class FunctionalCaseMinderService {
protected static final long LIMIT_POS = NodeSortUtils.DEFAULT_NODE_INTERVAL_POS;
@Resource
private FunctionalCaseMapper functionalCaseMapper;
@ -113,6 +117,13 @@ public class FunctionalCaseMinderService {
@Resource
private FunctionalCaseNoticeService functionalCaseNoticeService;
@Resource
private MindAdditionalNodeMapper mindAdditionalNodeMapper;
@Resource
private ProjectTemplateService projectTemplateService;
private static final String FUNCTIONAL_CASE = "functional_case";
private static final String FUNCTIONAL_CASE_MODULE = "functional_case_module";
private static final String CHECK_OWNER_CASE = "check_owner_case";
@ -130,11 +141,39 @@ public class FunctionalCaseMinderService {
return new ArrayList<>();
}
List<FunctionalCaseMindDTO> functionalCaseMindDTOList = extFunctionalCaseMapper.getMinderCaseList(request, deleted);
List<FunctionalMinderTreeDTO> functionalMinderTreeDTOS = buildAdditionalData(request.getModuleId());
if (CollectionUtils.isNotEmpty(functionalMinderTreeDTOS)) {
list.addAll(functionalMinderTreeDTOS);
}
//构造父子级数据
buildList(functionalCaseMindDTOList, list);
return list;
}
private List<FunctionalMinderTreeDTO> buildAdditionalData(String moduleId) {
List<FunctionalMinderTreeDTO> list = new ArrayList<>();
MindAdditionalNodeExample mindAdditionalNodeExample = new MindAdditionalNodeExample();
mindAdditionalNodeExample.createCriteria().andParentIdEqualTo(moduleId);
mindAdditionalNodeExample.setOrderByClause("pos asc");
List<MindAdditionalNode> mindAdditionalNodes = mindAdditionalNodeMapper.selectByExample(mindAdditionalNodeExample);
if (CollectionUtils.isEmpty(mindAdditionalNodes)) {
return new ArrayList<>();
}
for (MindAdditionalNode mindAdditionalNode : mindAdditionalNodes) {
FunctionalMinderTreeDTO root = new FunctionalMinderTreeDTO();
FunctionalMinderTreeNodeDTO rootData = new FunctionalMinderTreeNodeDTO();
rootData.setId(mindAdditionalNode.getId());
rootData.setPos(mindAdditionalNode.getPos());
rootData.setText(mindAdditionalNode.getName());
rootData.setResource(new ArrayList<>());
root.setChildren(buildAdditionalData(mindAdditionalNode.getId()));
root.setData(rootData);
list.add(root);
}
return list;
}
private void buildList(List<FunctionalCaseMindDTO> functionalCaseMindDTOList, List<FunctionalMinderTreeDTO> list) {
//构造父子级数据
for (FunctionalCaseMindDTO functionalCaseMindDTO : functionalCaseMindDTOList) {
@ -183,7 +222,7 @@ public class FunctionalCaseMinderService {
int i = 1;
if (StringUtils.equalsIgnoreCase(functionalCaseMindDTO.getCaseEditType(), FunctionalCaseTypeConstants.CaseEditType.STEP.name()) && functionalCaseMindDTO.getSteps() != null) {
String stepText = new String(functionalCaseMindDTO.getSteps(), StandardCharsets.UTF_8);
if(StringUtils.isNotBlank(stepText)){
if (StringUtils.isNotBlank(stepText)) {
List<FunctionalCaseStepDTO> functionalCaseStepDTOS = JSON.parseArray(stepText, FunctionalCaseStepDTO.class);
for (FunctionalCaseStepDTO functionalCaseStepDTO : functionalCaseStepDTOS) {
i = i + 1;
@ -245,11 +284,16 @@ public class FunctionalCaseMinderService {
FunctionalCaseBlobMapper caseBlobMapper = sqlSession.getMapper(FunctionalCaseBlobMapper.class);
FunctionalCaseCustomFieldMapper caseCustomFieldMapper = sqlSession.getMapper(FunctionalCaseCustomFieldMapper.class);
FunctionalCaseModuleMapper moduleMapper = sqlSession.getMapper(FunctionalCaseModuleMapper.class);
MindAdditionalNodeMapper additionalNodeMapper = sqlSession.getMapper(MindAdditionalNodeMapper.class);
List<LogDTO> addLogDTOS = new ArrayList<>();
List<FunctionalCaseDTO> noticeList = new ArrayList<>();
List<FunctionalCaseDTO> updateNoticeList = new ArrayList<>();
List<LogDTO> updateLogDTOS = new ArrayList<>();
Map<String, String> newModuleMap = new HashMap<>();
//处理模块
dealModule(request, userId, moduleMapper, newModuleMap);
//处理用例
if (CollectionUtils.isNotEmpty(request.getUpdateCaseList())) {
Map<String, List<FunctionalCaseChangeRequest>> resourceMap = request.getUpdateCaseList().stream().collect(Collectors.groupingBy(FunctionalCaseChangeRequest::getType));
@ -257,15 +301,24 @@ public class FunctionalCaseMinderService {
Map<String, String> customFieldNameMap = getCustomFieldNameMap(request);
List<FunctionalCaseChangeRequest> addList = resourceMap.get(OperationLogType.ADD.toString());
List<FunctionalCase> updatePosList = new ArrayList<>();
CustomFieldExample customFieldExample = new CustomFieldExample();
customFieldExample.createCriteria().andNameEqualTo("functional_priority").andSceneEqualTo(TemplateScene.FUNCTIONAL.toString()).andInternalEqualTo(true);
List<CustomField> defaultCustomFields = customFieldMapper.selectByExample(customFieldExample);
CustomField customField = defaultCustomFields.get(0);
TemplateDTO defaultTemplateDTO = projectTemplateService.getDefaultTemplateDTO(request.getProjectId(), TemplateScene.FUNCTIONAL.toString());
List<TemplateCustomFieldDTO> customFields = defaultTemplateDTO.getCustomFields();
Map<String, Object> defaultValueMap = customFields.stream().filter(t -> t.getDefaultValue() != null).collect(Collectors.toMap(TemplateCustomFieldDTO::getFieldId, TemplateCustomFieldDTO::getDefaultValue));
defaultValueMap.putIfAbsent(customField.getId(), "P0");
if (CollectionUtils.isNotEmpty(addList)) {
Map<String, List<FunctionalCase>> moduleCaseMap = getModuleCaseMap(addList);
for (FunctionalCaseChangeRequest functionalCaseChangeRequest : addList) {
FunctionalCase functionalCase = addCase(request, userId, functionalCaseChangeRequest, caseMapper);
FunctionalCase functionalCase = addCase(request, userId, functionalCaseChangeRequest, caseMapper, newModuleMap);
String caseId = functionalCase.getId();
//附属表
FunctionalCaseBlob functionalCaseBlob = addCaseBlob(functionalCaseChangeRequest, caseId, caseBlobMapper);
//保存自定义字段
List<FunctionalCaseCustomField> functionalCaseCustomFields = addCustomFields(functionalCaseChangeRequest, caseId, caseCustomFieldMapper);
List<FunctionalCaseCustomField> functionalCaseCustomFields = addCustomFields(functionalCaseChangeRequest, caseId, caseCustomFieldMapper, defaultValueMap);
//排序
reSetMap(functionalCaseChangeRequest, moduleCaseMap, functionalCase);
FunctionalCaseHistoryLogDTO historyLogDTO = new FunctionalCaseHistoryLogDTO(functionalCase, functionalCaseBlob, functionalCaseCustomFields, new ArrayList<>(), new ArrayList<>());
@ -322,40 +375,8 @@ public class FunctionalCaseMinderService {
}
//处理模块
if (CollectionUtils.isNotEmpty(request.getUpdateModuleList())) {
List<FunctionalCaseModule> updatePosList = new ArrayList<>();
//处理新增
Map<String, List<FunctionalCaseModuleEditRequest>> resourceMap = request.getUpdateModuleList().stream().collect(Collectors.groupingBy(FunctionalCaseModuleEditRequest::getType));
List<FunctionalCaseModuleEditRequest> addList = resourceMap.get(OperationLogType.ADD.toString());
if (CollectionUtils.isNotEmpty(addList)) {
Map<String, List<FunctionalCaseModule>> parentModuleMap = getParentModuleMap(addList);
for (FunctionalCaseModuleEditRequest functionalCaseModuleEditRequest : addList) {
checkModules(functionalCaseModuleEditRequest, parentModuleMap);
FunctionalCaseModule functionalCaseModule = addModule(request, userId, functionalCaseModuleEditRequest, moduleMapper);
reSetModuleMap(functionalCaseModuleEditRequest, parentModuleMap, functionalCaseModule);
}
parentModuleMap.forEach((k, v) -> {
updatePosList.addAll(v);
});
}
//处理更新
List<FunctionalCaseModuleEditRequest> updateList = resourceMap.get(OperationLogType.UPDATE.toString());
if (CollectionUtils.isNotEmpty(updateList)) {
Map<String, List<FunctionalCaseModule>> parentModuleMap = getParentModuleMap(addList);
for (FunctionalCaseModuleEditRequest functionalCaseModuleEditRequest : updateList) {
checkModules(functionalCaseModuleEditRequest, parentModuleMap);
FunctionalCaseModule updateModule = updateModule(userId, functionalCaseModuleEditRequest);
reSetModuleMap(functionalCaseModuleEditRequest, parentModuleMap, updateModule);
}
parentModuleMap.forEach((k, v) -> {
updatePosList.addAll(v);
});
}
//批量排序
batchSortModule(updatePosList, moduleMapper);
}
//处理空白节点
dealAdditionalNode(request, userId, additionalNodeMapper, newModuleMap);
sqlSession.flushStatements();
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
@ -378,6 +399,196 @@ public class FunctionalCaseMinderService {
commonNoticeSendService.sendNotice(NoticeConstants.TaskType.FUNCTIONAL_CASE_TASK, NoticeConstants.Event.UPDATE, resources, user, request.getProjectId());
}
private void dealAdditionalNode(FunctionalCaseMinderEditRequest request, String userId, MindAdditionalNodeMapper additionalNodeMapper, Map<String, String> newModuleMap) {
if (CollectionUtils.isNotEmpty(request.getAdditionalNodeList())) {
List<MindAdditionalNode> updatePosList = new ArrayList<>();
Map<String, List<MindAdditionalNodeRequest>> resourceMap = request.getAdditionalNodeList().stream().collect(Collectors.groupingBy(MindAdditionalNodeRequest::getType));
List<MindAdditionalNodeRequest> addList = resourceMap.get(OperationLogType.ADD.toString());
Map<String, String> newNodeMap = new HashMap<>();
//空白节点的父节点不一定是空白节点有可能是模块
if (CollectionUtils.isNotEmpty(addList)) {
List<MindAdditionalNode> nodes = new ArrayList<>();
Map<String, List<MindAdditionalNode>> parentModuleMap = getParentNodeMap(addList);
for (MindAdditionalNodeRequest mindAdditionalNodeRequest : addList) {
MindAdditionalNode mindAdditionalNode = buildNode(request, userId, mindAdditionalNodeRequest, additionalNodeMapper);
nodes.add(mindAdditionalNode);
newNodeMap.put(mindAdditionalNodeRequest.getId(), mindAdditionalNode.getId());
reSetNodeMap(mindAdditionalNodeRequest, parentModuleMap, mindAdditionalNode);
}
for (MindAdditionalNode node : nodes) {
if (StringUtils.isNotBlank(newNodeMap.get(node.getParentId()))) {
node.setParentId(newNodeMap.get(node.getParentId()));
}
if (StringUtils.isNotBlank(newModuleMap.get(node.getParentId()))) {
node.setParentId(newModuleMap.get(node.getParentId()));
}
additionalNodeMapper.insert(node);
}
parentModuleMap.forEach((k, v) -> {
updatePosList.addAll(v);
});
}
//处理更新
List<MindAdditionalNodeRequest> updateList = resourceMap.get(OperationLogType.UPDATE.toString());
if (CollectionUtils.isNotEmpty(updateList)) {
List<MindAdditionalNode> nodes = new ArrayList<>();
Map<String, List<MindAdditionalNode>> parentModuleMap = getParentNodeMap(addList);
for (MindAdditionalNodeRequest mindAdditionalNodeRequest : updateList) {
MindAdditionalNode updateModule = updateNode(userId, mindAdditionalNodeRequest, additionalNodeMapper);
nodes.add(updateModule);
reSetNodeMap(mindAdditionalNodeRequest, parentModuleMap, updateModule);
}
for (MindAdditionalNode node : nodes) {
if (StringUtils.isNotBlank(newNodeMap.get(node.getParentId()))) {
node.setParentId(newNodeMap.get(node.getParentId()));
}
if (StringUtils.isNotBlank(newModuleMap.get(node.getParentId()))) {
node.setParentId(newModuleMap.get(node.getParentId()));
}
additionalNodeMapper.updateByPrimaryKeySelective(node);
}
parentModuleMap.forEach((k, v) -> {
updatePosList.addAll(v);
});
}
//批量排序
batchSortNode(updatePosList, additionalNodeMapper);
}
}
private void batchSortNode(List<MindAdditionalNode> updatePosList, MindAdditionalNodeMapper mindAdditionalNodeMapper) {
for (MindAdditionalNode mindAdditionalNode : updatePosList) {
MindAdditionalNode additionalNode = new MindAdditionalNode();
additionalNode.setId(mindAdditionalNode.getId());
additionalNode.setPos(mindAdditionalNode.getPos());
mindAdditionalNodeMapper.updateByPrimaryKeySelective(additionalNode);
}
}
private MindAdditionalNode updateNode(String userId, MindAdditionalNodeRequest mindAdditionalNodeRequest, MindAdditionalNodeMapper mindAdditionalNodeMapper) {
MindAdditionalNode mindAdditionalNode = new MindAdditionalNode();
mindAdditionalNode.setId(mindAdditionalNodeRequest.getId());
mindAdditionalNode.setName(mindAdditionalNodeRequest.getName());
mindAdditionalNode.setParentId(mindAdditionalNodeRequest.getParentId());
mindAdditionalNode.setUpdateTime(System.currentTimeMillis());
mindAdditionalNode.setUpdateUser(userId);
mindAdditionalNode.setCreateUser(null);
mindAdditionalNode.setCreateTime(null);
return mindAdditionalNode;
}
private void reSetNodeMap(MindAdditionalNodeRequest mindAdditionalNodeRequest, Map<String, List<MindAdditionalNode>> parentModuleMap, MindAdditionalNode mindAdditionalNode) {
List<MindAdditionalNode> mindAdditionalNodes = parentModuleMap.get(mindAdditionalNode.getParentId());
if (CollectionUtils.isEmpty(mindAdditionalNodes)) {
return;
}
List<MindAdditionalNode> sortList = mindAdditionalNodes.stream().sorted(Comparator.comparing(MindAdditionalNode::getPos)).toList();
int j = getNodeIndex(mindAdditionalNodeRequest, sortList);
List<MindAdditionalNode> additionalNodeList = getAdditionalNodes(mindAdditionalNodeRequest, mindAdditionalNode, sortList, j);
for (int i = 0; i < additionalNodeList.size(); i++) {
additionalNodeList.get(i).setPos(5000L * i);
}
parentModuleMap.put(mindAdditionalNode.getParentId(), additionalNodeList);
}
private int getNodeIndex(MindAdditionalNodeRequest mindAdditionalNodeRequest, List<MindAdditionalNode> sortList) {
int j = 0;
for (int i = 0; i < sortList.size(); i++) {
if (StringUtils.equalsIgnoreCase(sortList.get(i).getId(), mindAdditionalNodeRequest.getTargetId())) {
j = i;
break;
}
}
return j;
}
private MindAdditionalNode buildNode(FunctionalCaseMinderEditRequest request, String userId, MindAdditionalNodeRequest mindAdditionalNodeRequest, MindAdditionalNodeMapper additionalNodeMapper) {
MindAdditionalNode mindAdditionalNode = new MindAdditionalNode();
mindAdditionalNode.setId(IDGenerator.nextStr());
mindAdditionalNode.setName(mindAdditionalNodeRequest.getName());
mindAdditionalNode.setParentId(mindAdditionalNodeRequest.getParentId());
mindAdditionalNode.setProjectId(request.getProjectId());
mindAdditionalNode.setCreateTime(System.currentTimeMillis());
mindAdditionalNode.setUpdateTime(mindAdditionalNode.getCreateTime());
mindAdditionalNode.setPos(this.countPos(mindAdditionalNode.getParentId()));
mindAdditionalNode.setCreateUser(userId);
mindAdditionalNode.setUpdateUser(userId);
return mindAdditionalNode;
}
private Map<String, List<MindAdditionalNode>> getParentNodeMap(List<MindAdditionalNodeRequest> addList) {
List<String> targetIds = addList.stream().filter(t -> !StringUtils.equalsIgnoreCase(t.getMoveMode(), MoveTypeEnum.APPEND.name())).map(MindAdditionalNodeRequest::getTargetId).distinct().toList();
List<String> parentIds = new ArrayList<>();
if (CollectionUtils.isNotEmpty(targetIds)) {
MindAdditionalNodeExample mindAdditionalNodeExample = new MindAdditionalNodeExample();
mindAdditionalNodeExample.createCriteria().andIdIn(targetIds);
List<MindAdditionalNode> mindAdditionalNodes = mindAdditionalNodeMapper.selectByExample(mindAdditionalNodeExample);
parentIds = mindAdditionalNodes.stream().map(MindAdditionalNode::getParentId).distinct().toList();
}
if (CollectionUtils.isEmpty(parentIds)) {
parentIds = addList.stream().map(MindAdditionalNodeRequest::getParentId).distinct().toList();
}
MindAdditionalNodeExample mindAdditionalNodeExample = new MindAdditionalNodeExample();
mindAdditionalNodeExample.createCriteria().andParentIdIn(parentIds);
List<MindAdditionalNode> mindAdditionalNodes = mindAdditionalNodeMapper.selectByExample(mindAdditionalNodeExample);
return mindAdditionalNodes.stream().collect(Collectors.groupingBy(MindAdditionalNode::getParentId));
}
private void dealModule(FunctionalCaseMinderEditRequest request, String userId, FunctionalCaseModuleMapper moduleMapper, Map<String, String> newModuleMap) {
if (CollectionUtils.isNotEmpty(request.getUpdateModuleList())) {
List<FunctionalCaseModule> updatePosList = new ArrayList<>();
//处理新增
Map<String, List<FunctionalCaseModuleEditRequest>> resourceMap = request.getUpdateModuleList().stream().collect(Collectors.groupingBy(FunctionalCaseModuleEditRequest::getType));
List<FunctionalCaseModuleEditRequest> addList = resourceMap.get(OperationLogType.ADD.toString());
if (CollectionUtils.isNotEmpty(addList)) {
List<FunctionalCaseModule> modules = new ArrayList<>();
Map<String, List<FunctionalCaseModule>> parentModuleMap = getParentModuleMap(addList);
for (FunctionalCaseModuleEditRequest functionalCaseModuleEditRequest : addList) {
checkModules(functionalCaseModuleEditRequest, parentModuleMap);
FunctionalCaseModule functionalCaseModule = buildModule(request, userId, functionalCaseModuleEditRequest, moduleMapper);
modules.add(functionalCaseModule);
newModuleMap.put(functionalCaseModuleEditRequest.getId(), functionalCaseModule.getId());
reSetModuleMap(functionalCaseModuleEditRequest, parentModuleMap, functionalCaseModule);
}
for (FunctionalCaseModule module : modules) {
if (StringUtils.isNotBlank(newModuleMap.get(module.getParentId()))) {
module.setParentId(newModuleMap.get(module.getParentId()));
}
moduleMapper.insert(module);
}
parentModuleMap.forEach((k, v) -> {
updatePosList.addAll(v);
});
}
//处理更新
List<FunctionalCaseModuleEditRequest> updateList = resourceMap.get(OperationLogType.UPDATE.toString());
if (CollectionUtils.isNotEmpty(updateList)) {
List<FunctionalCaseModule> modules = new ArrayList<>();
Map<String, List<FunctionalCaseModule>> parentModuleMap = getParentModuleMap(addList);
for (FunctionalCaseModuleEditRequest functionalCaseModuleEditRequest : updateList) {
checkModules(functionalCaseModuleEditRequest, parentModuleMap);
FunctionalCaseModule updateModule = updateModule(userId, functionalCaseModuleEditRequest, moduleMapper);
modules.add(updateModule);
reSetModuleMap(functionalCaseModuleEditRequest, parentModuleMap, updateModule);
}
for (FunctionalCaseModule module : modules) {
if (StringUtils.isNotBlank(newModuleMap.get(module.getParentId()))) {
module.setParentId(newModuleMap.get(module.getParentId()));
}
moduleMapper.updateByPrimaryKeySelective(module);
}
parentModuleMap.forEach((k, v) -> {
updatePosList.addAll(v);
});
}
//批量排序
batchSortModule(updatePosList, moduleMapper);
}
}
private static void batchSortModule(List<FunctionalCaseModule> updatePosList, FunctionalCaseModuleMapper moduleMapper) {
for (FunctionalCaseModule functionalCaseModule : updatePosList) {
FunctionalCaseModule functionalCaseModuleUpdatePos = new FunctionalCaseModule();
@ -417,11 +628,11 @@ public class FunctionalCaseMinderService {
private Map<String, String> getCustomFieldNameMap(FunctionalCaseMinderEditRequest request) {
List<CaseCustomFieldDTO> caseCustomFieldDTOS = new ArrayList<>();
for (FunctionalCaseChangeRequest caseChangeRequest : request.getUpdateCaseList()) {
if (CollectionUtils.isNotEmpty(caseChangeRequest.getCustomFields())){
if (CollectionUtils.isNotEmpty(caseChangeRequest.getCustomFields())) {
caseCustomFieldDTOS.addAll(caseChangeRequest.getCustomFields());
}
}
if (CollectionUtils.isEmpty(caseCustomFieldDTOS)){
if (CollectionUtils.isEmpty(caseCustomFieldDTOS)) {
return new HashMap<>();
}
List<String> caseCustomFields = caseCustomFieldDTOS.stream().map(CaseCustomFieldDTO::getFieldId).toList();
@ -472,7 +683,7 @@ public class FunctionalCaseMinderService {
}
@NotNull
private FunctionalCaseModule addModule(FunctionalCaseMinderEditRequest request, String userId, FunctionalCaseModuleEditRequest functionalCaseModuleEditRequest, FunctionalCaseModuleMapper moduleMapper) {
private FunctionalCaseModule buildModule(FunctionalCaseMinderEditRequest request, String userId, FunctionalCaseModuleEditRequest functionalCaseModuleEditRequest, FunctionalCaseModuleMapper moduleMapper) {
FunctionalCaseModule functionalCaseModule = new FunctionalCaseModule();
functionalCaseModule.setId(IDGenerator.nextStr());
functionalCaseModule.setName(functionalCaseModuleEditRequest.getName());
@ -483,26 +694,25 @@ public class FunctionalCaseMinderService {
functionalCaseModule.setPos(this.countPos(functionalCaseModule.getParentId()));
functionalCaseModule.setCreateUser(userId);
functionalCaseModule.setUpdateUser(userId);
moduleMapper.insert(functionalCaseModule);
return functionalCaseModule;
}
@NotNull
private FunctionalCaseModule updateModule(String userId, FunctionalCaseModuleEditRequest functionalCaseModuleEditRequest) {
private FunctionalCaseModule updateModule(String userId, FunctionalCaseModuleEditRequest functionalCaseModuleEditRequest, FunctionalCaseModuleMapper moduleMapper) {
FunctionalCaseModule updateModule = new FunctionalCaseModule();
updateModule.setId(functionalCaseModuleEditRequest.getId());
updateModule.setName(functionalCaseModuleEditRequest.getName());
updateModule.setParentId(functionalCaseModuleEditRequest.getParentId());
updateModule.setUpdateTime(System.currentTimeMillis());
updateModule.setUpdateUser(userId);
updateModule.setCreateUser(null);
updateModule.setCreateTime(null);
functionalCaseModuleMapper.updateByPrimaryKeySelective(updateModule);
return updateModule;
}
@NotNull
private Map<String, List<FunctionalCaseModule>> getParentModuleMap(List<FunctionalCaseModuleEditRequest> addList) {
List<String> targetIds = addList.stream().filter(t->!StringUtils.equalsIgnoreCase(t.getMoveMode(), MoveTypeEnum.APPEND.name())).map(FunctionalCaseModuleEditRequest::getTargetId).distinct().toList();
List<String> targetIds = addList.stream().filter(t -> !StringUtils.equalsIgnoreCase(t.getMoveMode(), MoveTypeEnum.APPEND.name())).map(FunctionalCaseModuleEditRequest::getTargetId).distinct().toList();
List<String> parentIds = new ArrayList<>();
if (CollectionUtils.isNotEmpty(targetIds)) {
FunctionalCaseModuleExample functionalCaseModuleExample = new FunctionalCaseModuleExample();
@ -560,6 +770,23 @@ public class FunctionalCaseMinderService {
return finallyModules;
}
private static List<MindAdditionalNode> getAdditionalNodes(MindAdditionalNodeRequest mindAdditionalNodeRequest, MindAdditionalNode mindAdditionalNode, List<MindAdditionalNode> sortList, int j) {
List<MindAdditionalNode> finallyModules = new ArrayList<>();
List<MindAdditionalNode> beforeModules;
List<MindAdditionalNode> afterModules;
if (StringUtils.equals(mindAdditionalNodeRequest.getMoveMode(), MoveTypeEnum.AFTER.name())) {
beforeModules = sortList.subList(0, j + 1);
afterModules = sortList.subList(j + 1, sortList.size());
} else {
beforeModules = sortList.subList(0, j);
afterModules = sortList.subList(j, sortList.size());
}
finallyModules.addAll(beforeModules);
finallyModules.add(mindAdditionalNode);
finallyModules.addAll(afterModules);
return finallyModules;
}
private static int getModuleIndex(FunctionalCaseModuleEditRequest functionalCaseModuleEditRequest, List<FunctionalCaseModule> sortList) {
int j = 0;
for (int i = 0; i < sortList.size(); i++) {
@ -701,12 +928,21 @@ public class FunctionalCaseMinderService {
return caseCustomFields;
}
private List<FunctionalCaseCustomField> addCustomFields(FunctionalCaseChangeRequest functionalCaseChangeRequest, String caseId, FunctionalCaseCustomFieldMapper caseCustomFieldMapper) {
private List<FunctionalCaseCustomField> addCustomFields(FunctionalCaseChangeRequest functionalCaseChangeRequest, String caseId, FunctionalCaseCustomFieldMapper caseCustomFieldMapper, Map<String, Object> defaultValueMap) {
List<CaseCustomFieldDTO> customFields = functionalCaseChangeRequest.getCustomFields();
List<FunctionalCaseCustomField> caseCustomFields = new ArrayList<>();
List<FunctionalCaseCustomField> caseCustomFields;
if (CollectionUtils.isNotEmpty(customFields)) {
customFields = customFields.stream().distinct().collect(Collectors.toList());
caseCustomFields = saveCustomField(caseId, caseCustomFieldMapper, customFields);
} else {
List<CaseCustomFieldDTO> customFieldDTOs = new ArrayList<>();
defaultValueMap.forEach((k,v)->{
CaseCustomFieldDTO customFieldDTO = new CaseCustomFieldDTO();
customFieldDTO.setFieldId(k);
customFieldDTO.setValue(v.toString());
customFieldDTOs.add(customFieldDTO);
});
caseCustomFields = saveCustomField(caseId, caseCustomFieldMapper, customFieldDTOs);
}
return caseCustomFields;
}
@ -737,11 +973,14 @@ public class FunctionalCaseMinderService {
}
@NotNull
private FunctionalCase addCase(FunctionalCaseMinderEditRequest request, String userId, FunctionalCaseChangeRequest functionalCaseChangeRequest, FunctionalCaseMapper caseMapper) {
private FunctionalCase addCase(FunctionalCaseMinderEditRequest request, String userId, FunctionalCaseChangeRequest functionalCaseChangeRequest, FunctionalCaseMapper caseMapper, Map<String, String> newModuleMap) {
FunctionalCase functionalCase = new FunctionalCase();
BeanUtils.copyBean(functionalCase, functionalCaseChangeRequest);
String caseId = IDGenerator.nextStr();
functionalCase.setId(caseId);
if (StringUtils.isNotBlank(newModuleMap.get(functionalCaseChangeRequest.getModuleId()))) {
functionalCase.setModuleId(newModuleMap.get(functionalCaseChangeRequest.getModuleId()));
}
functionalCase.setProjectId(request.getProjectId());
functionalCase.setVersionId(request.getVersionId());
functionalCase.setNum(functionalCaseService.getNextNum(request.getProjectId()));
@ -780,7 +1019,13 @@ public class FunctionalCaseMinderService {
List<FunctionalCase> functionalCases = functionalCaseModuleService.deleteModuleByIds(moduleIds, new ArrayList<>(), userId);
functionalCaseModuleService.batchDelLog(functionalCases, request.getProjectId());
functionalCaseNoticeService.batchSendNotice(request.getProjectId(), functionalCases.stream().map(FunctionalCase::getId).toList(), user, NoticeConstants.Event.DELETE);
}
List<MinderOptionDTO> additionalOptionDTOS = resourceMap.get(ModuleConstants.ROOT_NODE_PARENT_ID);
if (CollectionUtils.isNotEmpty(additionalOptionDTOS)) {
List<String> mindAdditionalNodeIds = caseModuleOptionDTOS.stream().map(MinderOptionDTO::getId).toList();
MindAdditionalNodeExample mindAdditionalNodeExample = new MindAdditionalNodeExample();
mindAdditionalNodeExample.createCriteria().andIdIn(mindAdditionalNodeIds);
mindAdditionalNodeMapper.deleteByExample(mindAdditionalNodeExample);
}
}
}

View File

@ -9,6 +9,6 @@ import org.springframework.stereotype.Service;
* @date : 2023-5-17
*/
@Service
public class MinderExtraNodeService {
public class MindAdditionalNodeService {
}

View File

@ -8,6 +8,7 @@ import io.metersphere.functional.dto.MinderOptionDTO;
import io.metersphere.functional.mapper.FunctionalCaseBlobMapper;
import io.metersphere.functional.mapper.FunctionalCaseMapper;
import io.metersphere.functional.mapper.FunctionalCaseModuleMapper;
import io.metersphere.functional.mapper.MindAdditionalNodeMapper;
import io.metersphere.functional.request.*;
import io.metersphere.sdk.util.JSON;
import io.metersphere.sdk.util.Translator;
@ -45,13 +46,14 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
public static final String FUNCTIONAL_CASE_PLAN_LIST_URL = "/functional/mind/case/plan/list";
@Resource
private FunctionalCaseBlobMapper functionalCaseBlobMapper;
@Resource
private FunctionalCaseMapper functionalCaseMapper;
@Resource
private FunctionalCaseModuleMapper functionalCaseModuleMapper;
@Resource
private MindAdditionalNodeMapper mindAdditionalNodeMapper;
@Test
@Order(1)
@ -144,8 +146,7 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
resultHolder = JSON.parseObject(contentAsString, ResultHolder.class);
List<FunctionalMinderTreeDTO> baseTreeNodes = JSON.parseArray(JSON.toJSONString(resultHolder.getData()), FunctionalMinderTreeDTO.class);
Assertions.assertNotNull(baseTreeNodes);
Assertions.assertEquals(2, baseTreeNodes.size());
Assertions.assertEquals(3, baseTreeNodes.size());
}
@Test
@ -208,6 +209,20 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
functionalCaseModuleEditRequest.setParentId("TEST_MINDER_MODULE_ID_GYQ");
functionalCaseModuleEditRequests.add(functionalCaseModuleEditRequest);
request.setUpdateModuleList(functionalCaseModuleEditRequests);
List<MindAdditionalNodeRequest> additionalNodeList = new ArrayList<>();
MindAdditionalNodeRequest mindAdditionalNodeRequest = new MindAdditionalNodeRequest();
mindAdditionalNodeRequest.setId("weyyg");
mindAdditionalNodeRequest.setType("ADD");
mindAdditionalNodeRequest.setName("新增空白");
mindAdditionalNodeRequest.setParentId("TEST_MINDER_MODULE_ID_GYQ");
additionalNodeList.add(mindAdditionalNodeRequest);
mindAdditionalNodeRequest = new MindAdditionalNodeRequest();
mindAdditionalNodeRequest.setId("additional2");
mindAdditionalNodeRequest.setType("UPDATE");
mindAdditionalNodeRequest.setName("additional2");
mindAdditionalNodeRequest.setParentId("TEST_MINDER_MODULE_ID_GYQ");
additionalNodeList.add(mindAdditionalNodeRequest);
request.setAdditionalNodeList(additionalNodeList);
List<MinderOptionDTO> deleteResourceList = new ArrayList<>();
MinderOptionDTO minderOptionDTO = new MinderOptionDTO();
minderOptionDTO.setId("TEST_FUNCTIONAL_MINDER_CASE_ID_9");
@ -217,18 +232,24 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
minderOptionDTO.setId("TEST_MINDER_MODULE_ID_GYQ9");
minderOptionDTO.setType(Translator.get("minder_extra_node.module"));
deleteResourceList.add(minderOptionDTO);
minderOptionDTO = new MinderOptionDTO();
minderOptionDTO.setId("additional1");
minderOptionDTO.setType("NONE");
deleteResourceList.add(minderOptionDTO);
request.setDeleteResourceList(deleteResourceList);
this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_EDIT_URL, request);
MindAdditionalNode mindAdditionalNode = mindAdditionalNodeMapper.selectByPrimaryKey("additional2");
Assertions.assertTrue(StringUtils.equalsIgnoreCase(mindAdditionalNode.getParentId(),"TEST_MINDER_MODULE_ID_GYQ"));
FunctionalCaseExample functionalCaseExample = new FunctionalCaseExample();
functionalCaseExample.createCriteria().andNameEqualTo("新增用例");
List<FunctionalCase> functionalCases = functionalCaseMapper.selectByExample(functionalCaseExample);
Assertions.assertTrue(CollectionUtils.isNotEmpty(functionalCases));
Assertions.assertTrue(functionalCases.get(0).getPos()>0L);
Assertions.assertTrue(functionalCases.get(0).getPos() > 0L);
FunctionalCaseModuleExample functionalCaseModuleExample = new FunctionalCaseModuleExample();
functionalCaseModuleExample.createCriteria().andNameEqualTo("新增9");
List<FunctionalCaseModule> functionalCaseModules = functionalCaseModuleMapper.selectByExample(functionalCaseModuleExample);
Assertions.assertTrue(CollectionUtils.isNotEmpty(functionalCaseModules));
Assertions.assertTrue(functionalCaseModules.get(0).getPos()>0L);
Assertions.assertTrue(functionalCaseModules.get(0).getPos() > 0L);
request = new FunctionalCaseMinderEditRequest();
request.setProjectId("project-case-minder-test");
request.setVersionId("ffff");

View File

@ -93,4 +93,9 @@ VALUES ('TEST_FUNCTIONAL_MINDER_CASE_ID_1', 'TEST_MINDER_REVIEW_ID_GYQ', 'admin'
('TEST_FUNCTIONAL_MINDER_CASE_ID_5', 'TEST_MINDER_REVIEW_ID_GYQ2', 'admin'),
('TEST_FUNCTIONAL_MINDER_CASE_ID_6', 'TEST_MINDER_REVIEW_ID_GYQ2', 'admin');
INSERT INTO mind_additional_node(id, project_id, name, parent_id, pos, create_time, update_time, create_user, update_user)
VALUES ('additional1', 'project-case-minder-test', 'additional1', 'TEST_MINDER_MODULE_ID_GYQ', 0, UNIX_TIMESTAMP() * 1000,UNIX_TIMESTAMP() * 1000, 'admin','admin'),
('additional2', 'project-case-minder-test', 'additional2', 'additional1', 500, UNIX_TIMESTAMP() * 1000,UNIX_TIMESTAMP() * 1000, 'admin','admin');
INSERT INTO template(id,name,remark,internal,update_time,create_time,create_user,scope_type,scope_id,enable_third_part, scene, ref_id)
VALUES ('100001', 'functional_default', '', 1, UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, 'admin', 'PROJECT', 'project-case-minder-test', 0, 'FUNCTIONAL', '100001');