refactor(系统设置): 项目增加资源池
This commit is contained in:
parent
72eebe62e0
commit
be376a4847
|
@ -0,0 +1,99 @@
|
|||
package io.metersphere.project.domain;
|
||||
|
||||
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 jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
@Data
|
||||
public class ProjectTestResourcePool implements Serializable {
|
||||
@Schema(description = "项目ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "{project_test_resource_pool.project_id.not_blank}", groups = {Created.class})
|
||||
@Size(min = 1, max = 50, message = "{project_test_resource_pool.project_id.length_range}", groups = {Created.class, Updated.class})
|
||||
private String projectId;
|
||||
|
||||
@Schema(description = "资源池ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "{project_test_resource_pool.test_resource_pool_id.not_blank}", groups = {Created.class})
|
||||
@Size(min = 1, max = 50, message = "{project_test_resource_pool.test_resource_pool_id.length_range}", groups = {Created.class, Updated.class})
|
||||
private String testResourcePoolId;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public enum Column {
|
||||
projectId("project_id", "projectId", "VARCHAR", false),
|
||||
testResourcePoolId("test_resource_pool_id", "testResourcePoolId", "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();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,340 @@
|
|||
package io.metersphere.project.domain;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ProjectTestResourcePoolExample {
|
||||
protected String orderByClause;
|
||||
|
||||
protected boolean distinct;
|
||||
|
||||
protected List<Criteria> oredCriteria;
|
||||
|
||||
public ProjectTestResourcePoolExample() {
|
||||
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 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 andTestResourcePoolIdIsNull() {
|
||||
addCriterion("test_resource_pool_id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTestResourcePoolIdIsNotNull() {
|
||||
addCriterion("test_resource_pool_id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTestResourcePoolIdEqualTo(String value) {
|
||||
addCriterion("test_resource_pool_id =", value, "testResourcePoolId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTestResourcePoolIdNotEqualTo(String value) {
|
||||
addCriterion("test_resource_pool_id <>", value, "testResourcePoolId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTestResourcePoolIdGreaterThan(String value) {
|
||||
addCriterion("test_resource_pool_id >", value, "testResourcePoolId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTestResourcePoolIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("test_resource_pool_id >=", value, "testResourcePoolId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTestResourcePoolIdLessThan(String value) {
|
||||
addCriterion("test_resource_pool_id <", value, "testResourcePoolId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTestResourcePoolIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("test_resource_pool_id <=", value, "testResourcePoolId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTestResourcePoolIdLike(String value) {
|
||||
addCriterion("test_resource_pool_id like", value, "testResourcePoolId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTestResourcePoolIdNotLike(String value) {
|
||||
addCriterion("test_resource_pool_id not like", value, "testResourcePoolId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTestResourcePoolIdIn(List<String> values) {
|
||||
addCriterion("test_resource_pool_id in", values, "testResourcePoolId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTestResourcePoolIdNotIn(List<String> values) {
|
||||
addCriterion("test_resource_pool_id not in", values, "testResourcePoolId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTestResourcePoolIdBetween(String value1, String value2) {
|
||||
addCriterion("test_resource_pool_id between", value1, value2, "testResourcePoolId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTestResourcePoolIdNotBetween(String value1, String value2) {
|
||||
addCriterion("test_resource_pool_id not between", value1, value2, "testResourcePoolId");
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package io.metersphere.project.mapper;
|
||||
|
||||
import io.metersphere.project.domain.ProjectTestResourcePool;
|
||||
import io.metersphere.project.domain.ProjectTestResourcePoolExample;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface ProjectTestResourcePoolMapper {
|
||||
long countByExample(ProjectTestResourcePoolExample example);
|
||||
|
||||
int deleteByExample(ProjectTestResourcePoolExample example);
|
||||
|
||||
int deleteByPrimaryKey(@Param("projectId") String projectId, @Param("testResourcePoolId") String testResourcePoolId);
|
||||
|
||||
int insert(ProjectTestResourcePool record);
|
||||
|
||||
int insertSelective(ProjectTestResourcePool record);
|
||||
|
||||
List<ProjectTestResourcePool> selectByExample(ProjectTestResourcePoolExample example);
|
||||
|
||||
int updateByExampleSelective(@Param("record") ProjectTestResourcePool record, @Param("example") ProjectTestResourcePoolExample example);
|
||||
|
||||
int updateByExample(@Param("record") ProjectTestResourcePool record, @Param("example") ProjectTestResourcePoolExample example);
|
||||
|
||||
int batchInsert(@Param("list") List<ProjectTestResourcePool> list);
|
||||
|
||||
int batchInsertSelective(@Param("list") List<ProjectTestResourcePool> list, @Param("selective") ProjectTestResourcePool.Column ... selective);
|
||||
}
|
|
@ -0,0 +1,173 @@
|
|||
<?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.project.mapper.ProjectTestResourcePoolMapper">
|
||||
<resultMap id="BaseResultMap" type="io.metersphere.project.domain.ProjectTestResourcePool">
|
||||
<id column="project_id" jdbcType="VARCHAR" property="projectId" />
|
||||
<id column="test_resource_pool_id" jdbcType="VARCHAR" property="testResourcePoolId" />
|
||||
</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">
|
||||
project_id, test_resource_pool_id
|
||||
</sql>
|
||||
<select id="selectByExample" parameterType="io.metersphere.project.domain.ProjectTestResourcePoolExample" resultMap="BaseResultMap">
|
||||
select
|
||||
<if test="distinct">
|
||||
distinct
|
||||
</if>
|
||||
<include refid="Base_Column_List" />
|
||||
from project_test_resource_pool
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
<if test="orderByClause != null">
|
||||
order by ${orderByClause}
|
||||
</if>
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="map">
|
||||
delete from project_test_resource_pool
|
||||
where project_id = #{projectId,jdbcType=VARCHAR}
|
||||
and test_resource_pool_id = #{testResourcePoolId,jdbcType=VARCHAR}
|
||||
</delete>
|
||||
<delete id="deleteByExample" parameterType="io.metersphere.project.domain.ProjectTestResourcePoolExample">
|
||||
delete from project_test_resource_pool
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</delete>
|
||||
<insert id="insert" parameterType="io.metersphere.project.domain.ProjectTestResourcePool">
|
||||
insert into project_test_resource_pool (project_id, test_resource_pool_id)
|
||||
values (#{projectId,jdbcType=VARCHAR}, #{testResourcePoolId,jdbcType=VARCHAR})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="io.metersphere.project.domain.ProjectTestResourcePool">
|
||||
insert into project_test_resource_pool
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="projectId != null">
|
||||
project_id,
|
||||
</if>
|
||||
<if test="testResourcePoolId != null">
|
||||
test_resource_pool_id,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="projectId != null">
|
||||
#{projectId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="testResourcePoolId != null">
|
||||
#{testResourcePoolId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<select id="countByExample" parameterType="io.metersphere.project.domain.ProjectTestResourcePoolExample" resultType="java.lang.Long">
|
||||
select count(*) from project_test_resource_pool
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</select>
|
||||
<update id="updateByExampleSelective" parameterType="map">
|
||||
update project_test_resource_pool
|
||||
<set>
|
||||
<if test="record.projectId != null">
|
||||
project_id = #{record.projectId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.testResourcePoolId != null">
|
||||
test_resource_pool_id = #{record.testResourcePoolId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByExample" parameterType="map">
|
||||
update project_test_resource_pool
|
||||
set project_id = #{record.projectId,jdbcType=VARCHAR},
|
||||
test_resource_pool_id = #{record.testResourcePoolId,jdbcType=VARCHAR}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
<insert id="batchInsert" parameterType="map">
|
||||
insert into project_test_resource_pool
|
||||
(project_id, test_resource_pool_id)
|
||||
values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.projectId,jdbcType=VARCHAR}, #{item.testResourcePoolId,jdbcType=VARCHAR})
|
||||
</foreach>
|
||||
</insert>
|
||||
<insert id="batchInsertSelective" parameterType="map">
|
||||
insert into project_test_resource_pool (
|
||||
<foreach collection="selective" item="column" separator=",">
|
||||
${column.escapedColumnName}
|
||||
</foreach>
|
||||
)
|
||||
values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
<foreach collection="selective" item="column" separator=",">
|
||||
<if test="'project_id'.toString() == column.value">
|
||||
#{item.projectId,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="'test_resource_pool_id'.toString() == column.value">
|
||||
#{item.testResourcePoolId,jdbcType=VARCHAR}
|
||||
</if>
|
||||
</foreach>
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
</mapper>
|
|
@ -318,5 +318,15 @@ CREATE INDEX idx_platform ON project_robot(platform);
|
|||
CREATE INDEX idx_webhook ON project_robot(webhook);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS project_test_resource_pool(
|
||||
`project_id` VARCHAR(50) NOT NULL COMMENT '项目ID' ,
|
||||
`test_resource_pool_id` VARCHAR(50) NOT NULL COMMENT '资源池ID' ,
|
||||
PRIMARY KEY (project_id,test_resource_pool_id)
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4
|
||||
COLLATE = utf8mb4_general_ci
|
||||
COMMENT = '项目与资源池关系表';
|
||||
|
||||
|
||||
-- set innodb lock wait timeout to default
|
||||
SET SESSION innodb_lock_wait_timeout = DEFAULT;
|
|
@ -0,0 +1,8 @@
|
|||
package io.metersphere.sdk.constants;
|
||||
|
||||
public class ModuleType {
|
||||
public static final String API_TEST = "api_test";
|
||||
public static final String UI_TEST = "ui_test";
|
||||
public static final String LOAD_TEST = "load_test";
|
||||
|
||||
}
|
|
@ -32,4 +32,10 @@ public class ProjectBaseRequest {
|
|||
|
||||
@Schema(description = "模块设置")
|
||||
private List<String> moduleIds;
|
||||
|
||||
@Schema(description = "成员数", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
private List<String> userIds;
|
||||
|
||||
@Schema(description = "资源池", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
private List<String> resourcePoolIds;
|
||||
}
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
package io.metersphere.sdk.dto;
|
||||
|
||||
import io.metersphere.project.domain.Project;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class ProjectExtendDTO extends ProjectDTO implements Serializable {
|
||||
private List<String> moduleIds;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
|
@ -148,6 +148,8 @@ environment_datasource.dbUrl.not_blank=Db Url is required
|
|||
environment_name_is_null=Environment name is required
|
||||
environment_config_is_null=Environment config is required
|
||||
|
||||
resource_pool_not_exist=Resource pool does not exist
|
||||
|
||||
#file management
|
||||
file_module.not.exist=File module does not exist
|
||||
upload.file.error=Upload file error
|
||||
|
|
|
@ -147,6 +147,7 @@ environment_datasource.driverId.not_blank=驱动ID不能为空
|
|||
environment_datasource.dbUrl.not_blank=数据库连接不能为空
|
||||
environment_name_is_null=环境名称不能为空
|
||||
environment_config_is_null=环境配置不能为空
|
||||
resource_pool_not_exist=资源池不存在
|
||||
|
||||
#file management
|
||||
file_module.not.exist=文件模块不存在
|
||||
|
|
|
@ -147,6 +147,8 @@ environment_datasource.driverId.not_blank=驅動ID不能為空
|
|||
environment_datasource.dbUrl.not_blank=數據庫地址不能為空
|
||||
environment_name_is_null=環境名稱不能為空
|
||||
environment_config_is_null=環境配置不能為空
|
||||
|
||||
resource_pool_not_exist=資源池不存在
|
||||
#file management
|
||||
file_module.not.exist=文件模塊不存在
|
||||
upload.file.error=上傳文件失敗
|
||||
|
|
|
@ -5,16 +5,15 @@ import io.metersphere.project.request.ProjectSwitchRequest;
|
|||
import io.metersphere.project.service.ProjectLogService;
|
||||
import io.metersphere.project.service.ProjectService;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.sdk.dto.ProjectExtendDTO;
|
||||
import io.metersphere.sdk.dto.UpdateProjectRequest;
|
||||
import io.metersphere.system.dto.ProjectDTO;
|
||||
import io.metersphere.system.dto.UpdateProjectRequest;
|
||||
import io.metersphere.sdk.dto.UserDTO;
|
||||
import io.metersphere.system.utils.SessionUtils;
|
||||
import io.metersphere.system.domain.TestResourcePool;
|
||||
import io.metersphere.system.log.annotation.Log;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.system.utils.SessionUtils;
|
||||
import io.metersphere.validation.groups.Updated;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
|
@ -33,7 +32,7 @@ public class ProjectController {
|
|||
@GetMapping("/get/{id}")
|
||||
@Operation(summary = "项目管理-基本信息")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_BASE_INFO_READ)
|
||||
public ProjectExtendDTO getProject(@PathVariable String id) {
|
||||
public ProjectDTO getProject(@PathVariable String id) {
|
||||
return projectService.getProjectById(id);
|
||||
}
|
||||
|
||||
|
@ -55,44 +54,15 @@ public class ProjectController {
|
|||
@Operation(summary = "项目管理-更新项目")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_BASE_INFO_READ_UPDATE)
|
||||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateLog(#request)", msClass = ProjectLogService.class)
|
||||
public ProjectExtendDTO updateProject(@RequestBody @Validated({Updated.class}) UpdateProjectRequest request) {
|
||||
public ProjectDTO updateProject(@RequestBody @Validated({Updated.class}) UpdateProjectRequest request) {
|
||||
return projectService.update(request, SessionUtils.getUserId());
|
||||
}
|
||||
|
||||
@GetMapping("/delete/{id}")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_BASE_INFO_READ_DELETE)
|
||||
@Operation(summary = "项目管理-删除")
|
||||
@Parameter(name = "id", description = "项目", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED))
|
||||
@Log(type = OperationLogType.DELETE, expression = "#msClass.deleteLog(#id)", msClass = ProjectLogService.class)
|
||||
public int deleteProject(@PathVariable String id) {
|
||||
return projectService.delete(id, SessionUtils.getUserId());
|
||||
}
|
||||
|
||||
@GetMapping("/revoke/{id}")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_BASE_INFO_READ_RECOVER)
|
||||
@Operation(summary = "项目管理-撤销删除")
|
||||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.recoverLog(#id)", msClass = ProjectLogService.class)
|
||||
@Parameter(name = "id", description = "项目", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED))
|
||||
public int revokeProject(@PathVariable String id) {
|
||||
return projectService.revoke(id, SessionUtils.getUserId());
|
||||
}
|
||||
|
||||
@GetMapping("/enable/{id}")
|
||||
@Operation(summary = "项目管理-启用")
|
||||
@Parameter(name = "id", description = "项目ID", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED))
|
||||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateLog(#id)", msClass = ProjectLogService.class)
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_BASE_INFO_READ_UPDATE)
|
||||
public void enable(@PathVariable String id) {
|
||||
projectService.enable(id, SessionUtils.getUserId());
|
||||
}
|
||||
|
||||
@GetMapping("/disable/{id}")
|
||||
@Operation(summary = "项目管理-禁用")
|
||||
@Parameter(name = "id", description = "项目ID", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED))
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_BASE_INFO_READ_UPDATE)
|
||||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateLog(#id)", msClass = ProjectLogService.class)
|
||||
public void disable(@PathVariable String id) {
|
||||
projectService.disable(id, SessionUtils.getUserId());
|
||||
@GetMapping("/pool-options/{type}/{projectId}")
|
||||
@Operation(summary = "项目管理-获取项目下的资源池")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_BASE_INFO_READ)
|
||||
public List<TestResourcePool> getPoolOptions(@PathVariable String type ,@PathVariable String projectId) {
|
||||
return projectService.getPoolOptions(projectId, type);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,9 +2,8 @@ package io.metersphere.project.service;
|
|||
|
||||
import io.metersphere.project.domain.Project;
|
||||
import io.metersphere.project.mapper.ProjectMapper;
|
||||
import io.metersphere.sdk.constants.HttpMethodConstants;
|
||||
import io.metersphere.sdk.dto.LogDTO;
|
||||
import io.metersphere.sdk.dto.UpdateProjectRequest;
|
||||
import io.metersphere.system.dto.UpdateProjectRequest;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.system.log.constants.OperationLogModule;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
|
@ -40,69 +39,4 @@ public class ProjectLogService {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public LogDTO updateLog(String id) {
|
||||
Project project = projectMapper.selectByPrimaryKey(id);
|
||||
if (project != null) {
|
||||
LogDTO dto = new LogDTO(
|
||||
project.getId(),
|
||||
project.getOrganizationId(),
|
||||
project.getId(),
|
||||
project.getCreateUser(),
|
||||
OperationLogType.UPDATE.name(),
|
||||
OperationLogModule.PROJECT_MANAGEMENT,
|
||||
project.getName());
|
||||
dto.setMethod(HttpMethodConstants.GET.name());
|
||||
|
||||
dto.setOriginalValue(JSON.toJSONBytes(project));
|
||||
return dto;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除接口日志
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public LogDTO deleteLog(String id) {
|
||||
Project project = projectMapper.selectByPrimaryKey(id);
|
||||
if (project != null) {
|
||||
LogDTO dto = new LogDTO(
|
||||
project.getId(),
|
||||
project.getOrganizationId(),
|
||||
id,
|
||||
project.getCreateUser(),
|
||||
OperationLogType.DELETE.name(),
|
||||
OperationLogModule.PROJECT_MANAGEMENT,
|
||||
project.getName());
|
||||
|
||||
dto.setOriginalValue(JSON.toJSONBytes(project));
|
||||
return dto;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 恢复项目
|
||||
* @param id 接口请求参数
|
||||
* @return 日志详情
|
||||
*/
|
||||
public LogDTO recoverLog(String id) {
|
||||
Project project = projectMapper.selectByPrimaryKey(id);
|
||||
if (project != null) {
|
||||
LogDTO dto = new LogDTO(
|
||||
project.getId(),
|
||||
project.getOrganizationId(),
|
||||
id,
|
||||
null,
|
||||
OperationLogType.RECOVER.name(),
|
||||
OperationLogModule.PROJECT_MANAGEMENT,
|
||||
project.getName());
|
||||
dto.setOriginalValue(JSON.toJSONBytes(project));
|
||||
return dto;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,34 +2,37 @@ package io.metersphere.project.service;
|
|||
|
||||
import io.metersphere.project.domain.Project;
|
||||
import io.metersphere.project.domain.ProjectExample;
|
||||
import io.metersphere.project.domain.ProjectTestResourcePool;
|
||||
import io.metersphere.project.domain.ProjectTestResourcePoolExample;
|
||||
import io.metersphere.project.mapper.ExtProjectMapper;
|
||||
import io.metersphere.project.mapper.ProjectMapper;
|
||||
import io.metersphere.project.mapper.ProjectTestResourcePoolMapper;
|
||||
import io.metersphere.project.request.ProjectSwitchRequest;
|
||||
import io.metersphere.sdk.constants.InternalUserRole;
|
||||
import io.metersphere.sdk.dto.ProjectExtendDTO;
|
||||
import io.metersphere.sdk.constants.ModuleType;
|
||||
import io.metersphere.sdk.dto.SessionUser;
|
||||
import io.metersphere.sdk.dto.UpdateProjectRequest;
|
||||
import io.metersphere.sdk.dto.UserDTO;
|
||||
import io.metersphere.sdk.exception.MSException;
|
||||
import io.metersphere.system.domain.Organization;
|
||||
import io.metersphere.system.service.BaseUserService;
|
||||
import io.metersphere.sdk.util.BeanUtils;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.system.utils.SessionUtils;
|
||||
import io.metersphere.sdk.util.Translator;
|
||||
import io.metersphere.system.domain.User;
|
||||
import io.metersphere.system.domain.UserRoleRelation;
|
||||
import io.metersphere.system.domain.UserRoleRelationExample;
|
||||
import io.metersphere.system.domain.*;
|
||||
import io.metersphere.system.dto.ProjectDTO;
|
||||
import io.metersphere.system.dto.UpdateProjectRequest;
|
||||
import io.metersphere.system.mapper.OrganizationMapper;
|
||||
import io.metersphere.system.mapper.TestResourcePoolMapper;
|
||||
import io.metersphere.system.mapper.TestResourcePoolOrganizationMapper;
|
||||
import io.metersphere.system.mapper.UserRoleRelationMapper;
|
||||
import io.metersphere.system.service.BaseUserService;
|
||||
import io.metersphere.system.service.CommonProjectService;
|
||||
import io.metersphere.system.utils.SessionUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
|
@ -47,6 +50,12 @@ public class ProjectService {
|
|||
private OrganizationMapper organizationMapper;
|
||||
@Resource
|
||||
private CommonProjectService commonProjectService;
|
||||
@Resource
|
||||
private TestResourcePoolMapper testResourcePoolMapper;
|
||||
@Resource
|
||||
private ProjectTestResourcePoolMapper projectTestResourcePoolMapper;
|
||||
@Resource
|
||||
private TestResourcePoolOrganizationMapper testResourcePoolOrganizationMapper;
|
||||
|
||||
|
||||
public List<Project> getUserProject(String organizationId, String userId) {
|
||||
|
@ -83,25 +92,13 @@ public class ProjectService {
|
|||
return sessionUser;
|
||||
}
|
||||
|
||||
public ProjectExtendDTO getProjectById(String id) {
|
||||
Project project = projectMapper.selectByPrimaryKey(id);
|
||||
ProjectExtendDTO projectExtendDTO = new ProjectExtendDTO();
|
||||
if (ObjectUtils.isNotEmpty(project)) {
|
||||
BeanUtils.copyBean(projectExtendDTO, project);
|
||||
Organization organization = organizationMapper.selectByPrimaryKey(project.getOrganizationId());
|
||||
projectExtendDTO.setOrganizationName(organization.getName());
|
||||
if (StringUtils.isNotEmpty(project.getModuleSetting())) {
|
||||
projectExtendDTO.setModuleIds(JSON.parseArray(project.getModuleSetting(), String.class));
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return projectExtendDTO;
|
||||
public ProjectDTO getProjectById(String id) {
|
||||
return commonProjectService.get(id);
|
||||
}
|
||||
|
||||
public ProjectExtendDTO update(UpdateProjectRequest updateProjectDto, String updateUser) {
|
||||
public ProjectDTO update(UpdateProjectRequest updateProjectDto, String updateUser) {
|
||||
Project project = new Project();
|
||||
ProjectExtendDTO projectExtendDTO = new ProjectExtendDTO();
|
||||
ProjectDTO projectDTO = new ProjectDTO();
|
||||
project.setId(updateProjectDto.getId());
|
||||
project.setName(updateProjectDto.getName());
|
||||
project.setDescription(updateProjectDto.getDescription());
|
||||
|
@ -113,16 +110,16 @@ public class ProjectService {
|
|||
project.setUpdateTime(System.currentTimeMillis());
|
||||
checkProjectExistByName(project);
|
||||
checkProjectNotExist(project.getId());
|
||||
projectExtendDTO.setOrganizationName(organizationMapper.selectByPrimaryKey(updateProjectDto.getOrganizationId()).getName());
|
||||
BeanUtils.copyBean(projectExtendDTO, project);
|
||||
projectDTO.setOrganizationName(organizationMapper.selectByPrimaryKey(updateProjectDto.getOrganizationId()).getName());
|
||||
BeanUtils.copyBean(projectDTO, project);
|
||||
//判断是否有模块设置
|
||||
if (CollectionUtils.isNotEmpty(updateProjectDto.getModuleIds())) {
|
||||
project.setModuleSetting(JSON.toJSONString(updateProjectDto.getModuleIds()));
|
||||
projectExtendDTO.setModuleIds(updateProjectDto.getModuleIds());
|
||||
projectDTO.setModuleIds(updateProjectDto.getModuleIds());
|
||||
}
|
||||
|
||||
projectMapper.updateByPrimaryKeySelective(project);
|
||||
return projectExtendDTO;
|
||||
return projectDTO;
|
||||
}
|
||||
|
||||
private void checkProjectExistByName(Project project) {
|
||||
|
@ -139,19 +136,52 @@ public class ProjectService {
|
|||
}
|
||||
}
|
||||
|
||||
public int delete(String id, String deleteUser) {
|
||||
return commonProjectService.delete(id,deleteUser);
|
||||
private List<String> getPoolIds(String projectId) {
|
||||
List<String> poolIds = new ArrayList<>();
|
||||
ProjectTestResourcePoolExample example = new ProjectTestResourcePoolExample();
|
||||
example.createCriteria().andProjectIdEqualTo(projectId);
|
||||
List<ProjectTestResourcePool> projectPools = projectTestResourcePoolMapper.selectByExample(example);
|
||||
if (CollectionUtils.isNotEmpty(projectPools)) {
|
||||
return projectPools.stream().map(ProjectTestResourcePool::getTestResourcePoolId).toList();
|
||||
}
|
||||
//判断项目所属组织是否关联了资源池
|
||||
Project project = projectMapper.selectByPrimaryKey(projectId);
|
||||
TestResourcePoolOrganizationExample orgExample = new TestResourcePoolOrganizationExample();
|
||||
orgExample.createCriteria().andOrgIdEqualTo(project.getOrganizationId());
|
||||
List<TestResourcePoolOrganization> orgPools = testResourcePoolOrganizationMapper.selectByExample(orgExample);
|
||||
if (CollectionUtils.isNotEmpty(orgPools)) {
|
||||
poolIds.addAll(orgPools.stream().map(TestResourcePoolOrganization::getTestResourcePoolId).toList());
|
||||
}
|
||||
//获取应用全部组织的资源池
|
||||
TestResourcePoolExample poolExample = new TestResourcePoolExample();
|
||||
poolExample.createCriteria().andAllOrgEqualTo(true).andEnableEqualTo(true).andDeletedEqualTo(false);
|
||||
List<TestResourcePool> testResourcePools = testResourcePoolMapper.selectByExample(poolExample);
|
||||
poolIds.addAll(testResourcePools.stream().map(TestResourcePool::getId).toList());
|
||||
poolIds = poolIds.stream().distinct().filter(StringUtils::isNotBlank).toList();
|
||||
return poolIds;
|
||||
}
|
||||
|
||||
public int revoke(String id, String updateUser) {
|
||||
return commonProjectService.revoke(id, updateUser);
|
||||
public List<TestResourcePool> getPoolOptions(String projectId, String type) {
|
||||
//判断项目是否关联了资源池
|
||||
checkProjectNotExist(projectId);
|
||||
List<String> poolIds = getPoolIds(projectId);
|
||||
TestResourcePoolExample example = new TestResourcePoolExample();
|
||||
TestResourcePoolExample.Criteria criteria = example.createCriteria();
|
||||
criteria.andIdIn(poolIds).andEnableEqualTo(true).andDeletedEqualTo(false);
|
||||
return switch (type) {
|
||||
case ModuleType.API_TEST-> {
|
||||
criteria.andApiTestEqualTo(true);
|
||||
yield testResourcePoolMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public void enable(String id, String updateUser) {
|
||||
commonProjectService.enable(id, updateUser);
|
||||
case ModuleType.UI_TEST -> {
|
||||
criteria.andUiTestEqualTo(true);
|
||||
yield testResourcePoolMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public void disable(String id, String updateUser) {
|
||||
commonProjectService.disable(id, updateUser);
|
||||
case ModuleType.LOAD_TEST -> {
|
||||
criteria.andLoadTestEqualTo(true);
|
||||
yield testResourcePoolMapper.selectByExample(example);
|
||||
}
|
||||
default -> new ArrayList<>();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,6 +85,7 @@
|
|||
<table tableName="message_task"/>
|
||||
<table tableName="message_task_blob"/>
|
||||
<table tableName="notification"/>
|
||||
<table tableName="project_test_resource_pool"/>
|
||||
<!-- 要忽略的字段-->
|
||||
<!-- <table tableName="test_case">
|
||||
<ignoreColumn column="follow_people"/>
|
||||
|
|
|
@ -5,14 +5,16 @@ import io.metersphere.project.domain.Project;
|
|||
import io.metersphere.project.domain.ProjectExample;
|
||||
import io.metersphere.project.mapper.ProjectMapper;
|
||||
import io.metersphere.project.request.ProjectSwitchRequest;
|
||||
import io.metersphere.sdk.constants.ModuleType;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.sdk.constants.SessionConstants;
|
||||
import io.metersphere.sdk.dto.ProjectExtendDTO;
|
||||
import io.metersphere.sdk.dto.UpdateProjectRequest;
|
||||
import io.metersphere.system.dto.ProjectDTO;
|
||||
import io.metersphere.system.dto.UpdateProjectRequest;
|
||||
import io.metersphere.sdk.dto.UserDTO;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.system.base.BaseTest;
|
||||
import io.metersphere.system.controller.handler.ResultHolder;
|
||||
import io.metersphere.system.domain.TestResourcePool;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
|
@ -45,10 +47,8 @@ public class ProjectControllerTests extends BaseTest {
|
|||
private static final String prefix = "/project";
|
||||
private static final String getOptions = prefix + "/list/options/";
|
||||
private final static String updateProject = prefix + "/update";
|
||||
private final static String deleteProject = prefix + "/delete/";
|
||||
private final static String revokeProject = prefix + "/revoke/";
|
||||
private final static String disableProject = prefix + "/disable/";
|
||||
private final static String enableProject = prefix + "/enable/";
|
||||
|
||||
private static final String getPoolOptions = prefix + "/pool-options/";
|
||||
|
||||
private static final ResultMatcher BAD_REQUEST_MATCHER = status().isBadRequest();
|
||||
private static final ResultMatcher ERROR_REQUEST_MATCHER = status().is5xxServerError();
|
||||
|
@ -76,15 +76,6 @@ public class ProjectControllerTests extends BaseTest {
|
|||
.andExpect(content().contentType(MediaType.APPLICATION_JSON)).andReturn();
|
||||
}
|
||||
|
||||
private void responseGet(String url, ResultMatcher resultMatcher) throws Exception {
|
||||
mockMvc.perform(MockMvcRequestBuilders.get(url)
|
||||
.header(SessionConstants.HEADER_TOKEN, sessionId)
|
||||
.header(SessionConstants.CSRF_TOKEN, csrfToken)
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(resultMatcher)
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON)).andReturn();
|
||||
}
|
||||
|
||||
public UpdateProjectRequest generatorUpdate(String organizationId,
|
||||
String projectId,
|
||||
String name,
|
||||
|
@ -135,7 +126,7 @@ public class ProjectControllerTests extends BaseTest {
|
|||
executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
|
||||
public void testGetProject() throws Exception {
|
||||
MvcResult mvcResult = responseGet(prefix + "/get/projectId");
|
||||
ProjectExtendDTO getProjects = parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||
ProjectDTO getProjects = parseObjectFromMvcResult(mvcResult, ProjectDTO.class);
|
||||
Assertions.assertNotNull(getProjects);
|
||||
//权限校验
|
||||
requestGetPermissionTest(PermissionConstants.PROJECT_BASE_INFO_READ, prefix + "/get/projectId");
|
||||
|
@ -147,7 +138,7 @@ public class ProjectControllerTests extends BaseTest {
|
|||
public void testGetProjectError() throws Exception {
|
||||
//项目不存在
|
||||
MvcResult mvcResult = this.responseGet(prefix + "/get/111111");
|
||||
ProjectExtendDTO project = parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||
ProjectDTO project = parseObjectFromMvcResult(mvcResult, ProjectDTO.class);
|
||||
Assertions.assertNull(project);
|
||||
}
|
||||
|
||||
|
@ -273,7 +264,7 @@ public class ProjectControllerTests extends BaseTest {
|
|||
}
|
||||
project.setModuleIds(moduleIds);
|
||||
MvcResult mvcResult = this.responsePost(updateProject, project);
|
||||
ProjectExtendDTO result = parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||
ProjectDTO result = parseObjectFromMvcResult(mvcResult, ProjectDTO.class);
|
||||
Project currentProject = projectMapper.selectByPrimaryKey(project.getId());
|
||||
compareProjectDTO(currentProject, result);
|
||||
//断言模块设置
|
||||
|
@ -289,7 +280,7 @@ public class ProjectControllerTests extends BaseTest {
|
|||
moduleIds.add("uiTest");
|
||||
project.setModuleIds(moduleIds);
|
||||
mvcResult = this.responsePost(updateProject, project);
|
||||
result = parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||
result = parseObjectFromMvcResult(mvcResult, ProjectDTO.class);
|
||||
currentProject = projectMapper.selectByPrimaryKey(project.getId());
|
||||
compareProjectDTO(currentProject, result);
|
||||
//断言模块设置
|
||||
|
@ -327,84 +318,17 @@ public class ProjectControllerTests extends BaseTest {
|
|||
|
||||
@Test
|
||||
@Order(9)
|
||||
public void testDeleteProject() throws Exception {
|
||||
MvcResult mvcResult = this.responseGet(deleteProject + "projectId4");
|
||||
int count = parseObjectFromMvcResult(mvcResult, Integer.class);
|
||||
Project currentProject = projectMapper.selectByPrimaryKey("projectId4");
|
||||
Assertions.assertEquals(currentProject.getDeleted(), true);
|
||||
Assertions.assertEquals(currentProject.getId(), "projectId4");
|
||||
Assertions.assertEquals(1, count);
|
||||
// 校验日志
|
||||
checkLog("projectId4", OperationLogType.DELETE);
|
||||
// @@校验权限
|
||||
requestGetPermissionTest(PermissionConstants.PROJECT_BASE_INFO_READ_DELETE, deleteProject + DEFAULT_PROJECT_ID);
|
||||
public void testGetPoolOptions() throws Exception {
|
||||
MvcResult mvcResult = this.responseGet(getPoolOptions + ModuleType.API_TEST + "/"+DEFAULT_PROJECT_ID);
|
||||
mvcResult = this.responseGet(getPoolOptions + ModuleType.UI_TEST + "/"+DEFAULT_PROJECT_ID);
|
||||
mvcResult = this.responseGet(getPoolOptions + ModuleType.LOAD_TEST + "/"+DEFAULT_PROJECT_ID);
|
||||
mvcResult = this.responseGet(getPoolOptions + "test" + "/"+DEFAULT_PROJECT_ID);
|
||||
List<TestResourcePool> list = parseObjectFromMvcResult(mvcResult, List.class);
|
||||
//断言为空的list
|
||||
Assertions.assertEquals(0, list.size());
|
||||
//权限校验
|
||||
requestGetPermissionTest(PermissionConstants.PROJECT_BASE_INFO_READ, getPoolOptions + "api_test" + "/"+DEFAULT_PROJECT_ID);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(10)
|
||||
public void testDeleteProjectError() throws Exception {
|
||||
String id = "1111";
|
||||
this.responseGet(deleteProject + id, ERROR_REQUEST_MATCHER);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(11)
|
||||
public void revokeSuccess() throws Exception {
|
||||
MvcResult mvcResult = this.responseGet(revokeProject + "projectId4");
|
||||
int count = parseObjectFromMvcResult(mvcResult, Integer.class);
|
||||
Project currentProject = projectMapper.selectByPrimaryKey("projectId4");
|
||||
Assertions.assertEquals(currentProject.getDeleted(), false);
|
||||
Assertions.assertEquals(currentProject.getId(), "projectId4");
|
||||
Assertions.assertEquals(1, count);
|
||||
// 校验日志
|
||||
checkLog("projectId4", OperationLogType.RECOVER);
|
||||
// @@校验权限
|
||||
requestGetPermissionTest(PermissionConstants.PROJECT_BASE_INFO_READ_RECOVER, revokeProject + DEFAULT_PROJECT_ID);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(12)
|
||||
public void testRevokeProjectError() throws Exception {
|
||||
String id = "1111";
|
||||
this.responseGet(revokeProject + id, ERROR_REQUEST_MATCHER);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(19)
|
||||
public void disableSuccess() throws Exception {
|
||||
String id = "projectId4";
|
||||
this.responseGet(disableProject + id,status().isOk());
|
||||
Project currentProject = projectMapper.selectByPrimaryKey(id);
|
||||
Assertions.assertEquals(currentProject.getEnable(), false);
|
||||
checkLog(id, OperationLogType.UPDATE);
|
||||
// @@校验权限
|
||||
requestGetPermissionTest(PermissionConstants.PROJECT_BASE_INFO_READ_UPDATE, disableProject + DEFAULT_PROJECT_ID);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(20)
|
||||
public void disableError() throws Exception {
|
||||
String id = "1111";
|
||||
this.responseGet(disableProject + id, ERROR_REQUEST_MATCHER);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(19)
|
||||
public void enableSuccess() throws Exception {
|
||||
String id = "projectId4";
|
||||
this.responseGet(enableProject + id,status().isOk());
|
||||
Project currentProject = projectMapper.selectByPrimaryKey(id);
|
||||
Assertions.assertEquals(currentProject.getEnable(), true);
|
||||
checkLog(id, OperationLogType.UPDATE);
|
||||
// @@校验权限
|
||||
requestGetPermissionTest(PermissionConstants.PROJECT_BASE_INFO_READ_UPDATE, enableProject + DEFAULT_PROJECT_ID);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(20)
|
||||
public void enableError() throws Exception {
|
||||
String id = "1111";
|
||||
this.responseGet(enableProject + id, ERROR_REQUEST_MATCHER);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,3 +33,15 @@ replace INTO user_role_permission(id, role_id, permission_id) VALUES ('user_role
|
|||
|
||||
#插入测试数据 环境
|
||||
replace INTO environment (id, name, project_id, create_user, update_user, create_time, update_time) VALUES ('environmentId1', '环境1', 'projectId1', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000);
|
||||
|
||||
replace into test_resource_pool(id, name, type, description, enable, create_time, update_time, create_user, api_test,
|
||||
load_test, ui_test, server_url, all_org, deleted)
|
||||
values ('resourcePoolId', 'resourcePoolName', 'node', 'resourcePoolDescription', 1, unix_timestamp() * 1000,
|
||||
unix_timestamp() * 1000, 'admin', 1, 1, 1, 'http://localhost:8080', 1, 0);
|
||||
replace into test_resource_pool(id, name, type, description, enable, create_time, update_time, create_user, api_test,
|
||||
load_test, ui_test, server_url, all_org, deleted)
|
||||
values ('resourcePoolId1', 'resourcePoolName1', 'node', 'resourcePoolDescription', 1, unix_timestamp() * 1000,
|
||||
unix_timestamp() * 1000, 'admin', 1, 1, 1, 'http://localhost:8080', 1, 0);
|
||||
replace into project_test_resource_pool(project_id, test_resource_pool_id) value ('projectId', 'resourcePoolId');
|
||||
replace into project_test_resource_pool(project_id, test_resource_pool_id) value ('projectId', 'resourcePoolId1');
|
||||
replace into test_resource_pool_organization(id , test_resource_pool_id, org_id) value (UUID_SHORT(),'resourcePoolId', '100001');
|
|
@ -5,6 +5,10 @@ import com.github.pagehelper.Page;
|
|||
import com.github.pagehelper.PageHelper;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.sdk.dto.*;
|
||||
import io.metersphere.system.domain.TestResourcePool;
|
||||
import io.metersphere.system.dto.AddProjectRequest;
|
||||
import io.metersphere.system.dto.ProjectDTO;
|
||||
import io.metersphere.system.dto.UpdateProjectRequest;
|
||||
import io.metersphere.system.log.annotation.Log;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.sdk.util.PageUtils;
|
||||
|
@ -42,7 +46,7 @@ public class OrganizationProjectController {
|
|||
@RequiresPermissions(PermissionConstants.ORGANIZATION_PROJECT_READ_ADD)
|
||||
@Log(type = OperationLogType.ADD, expression = "#msClass.addLog(#project)", msClass = OrganizationProjectLogService.class)
|
||||
@Operation(summary = "系统设置-组织-项目-创建项目")
|
||||
public ProjectExtendDTO addProject(@RequestBody @Validated({Created.class}) AddProjectRequest project) {
|
||||
public ProjectDTO addProject(@RequestBody @Validated({Created.class}) AddProjectRequest project) {
|
||||
return organizationProjectService.add(project, SessionUtils.getUserId());
|
||||
}
|
||||
|
||||
|
@ -51,7 +55,7 @@ public class OrganizationProjectController {
|
|||
@Operation(summary = "系统设置-组织-项目-根据ID获取项目信息")
|
||||
@Parameter(name = "id", description = "项目id", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED))
|
||||
@RequiresPermissions(PermissionConstants.ORGANIZATION_PROJECT_READ)
|
||||
public ProjectExtendDTO getProject(@PathVariable @NotBlank String id) {
|
||||
public ProjectDTO getProject(@PathVariable @NotBlank String id) {
|
||||
return organizationProjectService.get(id);
|
||||
}
|
||||
|
||||
|
@ -68,7 +72,7 @@ public class OrganizationProjectController {
|
|||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateLog(#project)", msClass = OrganizationProjectLogService.class)
|
||||
@Operation(summary = "系统设置-组织-项目-编辑")
|
||||
@RequiresPermissions(PermissionConstants.ORGANIZATION_PROJECT_READ_UPDATE)
|
||||
public ProjectExtendDTO updateProject(@RequestBody @Validated({Updated.class}) UpdateProjectRequest project) {
|
||||
public ProjectDTO updateProject(@RequestBody @Validated({Updated.class}) UpdateProjectRequest project) {
|
||||
return organizationProjectService.update(project, SessionUtils.getUserId());
|
||||
}
|
||||
|
||||
|
@ -154,4 +158,11 @@ public class OrganizationProjectController {
|
|||
return organizationProjectService.getUserMemberList(organizationId, projectId, keyword);
|
||||
}
|
||||
|
||||
@GetMapping("/pool-options/{organizationId}")
|
||||
@Operation(summary = "系统设置-组织-项目-获取资源池下拉选项")
|
||||
@RequiresPermissions(PermissionConstants.ORGANIZATION_PROJECT_READ)
|
||||
public List<TestResourcePool> getProjectOptions(@PathVariable String organizationId) {
|
||||
return organizationProjectService.getTestResourcePoolOptions(organizationId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import com.github.pagehelper.Page;
|
|||
import com.github.pagehelper.PageHelper;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.sdk.dto.OptionDTO;
|
||||
import io.metersphere.sdk.dto.ProjectDTO;
|
||||
import io.metersphere.system.dto.ProjectDTO;
|
||||
import io.metersphere.sdk.util.BeanUtils;
|
||||
import io.metersphere.sdk.util.PageUtils;
|
||||
import io.metersphere.sdk.util.Pager;
|
||||
|
|
|
@ -5,13 +5,15 @@ import com.github.pagehelper.Page;
|
|||
import com.github.pagehelper.PageHelper;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.sdk.dto.*;
|
||||
import io.metersphere.system.log.annotation.Log;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.sdk.util.PageUtils;
|
||||
import io.metersphere.sdk.util.Pager;
|
||||
import io.metersphere.system.utils.SessionUtils;
|
||||
import io.metersphere.system.domain.TestResourcePool;
|
||||
import io.metersphere.system.domain.User;
|
||||
import io.metersphere.sdk.dto.UserExtend;
|
||||
import io.metersphere.system.dto.AddProjectRequest;
|
||||
import io.metersphere.system.dto.ProjectDTO;
|
||||
import io.metersphere.system.dto.UpdateProjectRequest;
|
||||
import io.metersphere.system.log.annotation.Log;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.system.request.ProjectAddMemberBatchRequest;
|
||||
import io.metersphere.system.request.ProjectAddMemberRequest;
|
||||
import io.metersphere.system.request.ProjectMemberRequest;
|
||||
|
@ -19,6 +21,7 @@ import io.metersphere.system.request.ProjectRequest;
|
|||
import io.metersphere.system.service.SystemProjectLogService;
|
||||
import io.metersphere.system.service.SystemProjectService;
|
||||
import io.metersphere.system.service.UserService;
|
||||
import io.metersphere.system.utils.SessionUtils;
|
||||
import io.metersphere.validation.groups.Created;
|
||||
import io.metersphere.validation.groups.Updated;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
@ -47,7 +50,7 @@ public class SystemProjectController {
|
|||
@RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ_ADD)
|
||||
@Log(type = OperationLogType.ADD, expression = "#msClass.addLog(#project)", msClass = SystemProjectLogService.class)
|
||||
@Operation(summary = "系统设置-系统-组织与项目-项目-创建项目")
|
||||
public ProjectExtendDTO addProject(@RequestBody @Validated({Created.class}) AddProjectRequest project) {
|
||||
public ProjectDTO addProject(@RequestBody @Validated({Created.class}) AddProjectRequest project) {
|
||||
return systemProjectService.add(project, SessionUtils.getUserId());
|
||||
}
|
||||
|
||||
|
@ -56,7 +59,7 @@ public class SystemProjectController {
|
|||
@Operation(summary = "系统设置-系统-组织与项目-项目-根据ID获取项目信息")
|
||||
@Parameter(name = "id", description = "项目id", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED))
|
||||
@RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ)
|
||||
public ProjectExtendDTO getProject(@PathVariable @NotBlank String id) {
|
||||
public ProjectDTO getProject(@PathVariable @NotBlank String id) {
|
||||
return systemProjectService.get(id);
|
||||
}
|
||||
|
||||
|
@ -73,7 +76,7 @@ public class SystemProjectController {
|
|||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateLog(#project)", msClass = SystemProjectLogService.class)
|
||||
@Operation(summary = "系统设置-系统-组织与项目-项目-编辑")
|
||||
@RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ_UPDATE)
|
||||
public ProjectExtendDTO updateProject(@RequestBody @Validated({Updated.class}) UpdateProjectRequest project) {
|
||||
public ProjectDTO updateProject(@RequestBody @Validated({Updated.class}) UpdateProjectRequest project) {
|
||||
return systemProjectService.update(project, SessionUtils.getUserId());
|
||||
}
|
||||
|
||||
|
@ -150,4 +153,11 @@ public class SystemProjectController {
|
|||
return userService.getUserList(keyword);
|
||||
}
|
||||
|
||||
@GetMapping("/pool-options/{organizationId}")
|
||||
@Operation(summary = "系统设置-系统-组织与项目-项目-获取资源池下拉选项")
|
||||
@RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ)
|
||||
public List<TestResourcePool> getProjectOptions(@PathVariable String organizationId) {
|
||||
return systemProjectService.getTestResourcePoolOptions(organizationId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
package io.metersphere.sdk.dto;
|
||||
package io.metersphere.system.dto;
|
||||
|
||||
import io.metersphere.sdk.dto.ProjectBaseRequest;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class AddProjectRequest extends ProjectBaseRequest {
|
||||
|
@ -14,7 +13,4 @@ public class AddProjectRequest extends ProjectBaseRequest {
|
|||
@Schema(description = "项目ID", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
@Size(min = 1, max = 50, message = "{project.id.length_range}")
|
||||
private String id;
|
||||
|
||||
@Schema(description = "成员数", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
private List<String> userIds;
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package io.metersphere.sdk.dto;
|
||||
package io.metersphere.system.dto;
|
||||
|
||||
import io.metersphere.project.domain.Project;
|
||||
import io.metersphere.sdk.dto.UserExtend;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
@ -21,6 +22,8 @@ public class ProjectDTO extends Project implements Serializable {
|
|||
private Boolean projectCreateUserIsAdmin;
|
||||
@Schema(description = "模块设置", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
private List<String> moduleIds;
|
||||
@Schema(description = "资源池", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
private List<ProjectResourcePoolDTO> resourcePoolList;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package io.metersphere.system.dto;
|
||||
|
||||
import io.metersphere.system.domain.TestResourcePool;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class ProjectResourcePoolDTO extends TestResourcePool implements Serializable {
|
||||
@Schema(description = "项目ID")
|
||||
private String projectId;
|
||||
@Schema(description = "资源池ID")
|
||||
private String id;
|
||||
|
||||
@Schema(description = "资源池名称")
|
||||
private String name;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package io.metersphere.sdk.dto;
|
||||
package io.metersphere.system.dto;
|
||||
|
||||
import io.metersphere.sdk.dto.ProjectBaseRequest;
|
||||
import io.metersphere.validation.groups.Updated;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
@ -7,8 +8,6 @@ import jakarta.validation.constraints.Size;
|
|||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class UpdateProjectRequest extends ProjectBaseRequest {
|
||||
|
@ -17,6 +16,4 @@ public class UpdateProjectRequest extends ProjectBaseRequest {
|
|||
@NotBlank(message = "{project.id.not_blank}", groups = {Updated.class})
|
||||
@Size(min = 1, max = 50, message = "{project.id.length_range}", groups = {Updated.class})
|
||||
private String id;
|
||||
@Schema(description = "成员数", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
private List<String> userIds;
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package io.metersphere.system.mapper;
|
||||
|
||||
import io.metersphere.sdk.dto.ProjectDTO;
|
||||
import io.metersphere.system.dto.ProjectDTO;
|
||||
import io.metersphere.system.dto.ProjectResourcePoolDTO;
|
||||
import io.metersphere.sdk.dto.UserExtend;
|
||||
import io.metersphere.system.dto.OrganizationProjectOptionsDTO;
|
||||
import io.metersphere.system.request.ProjectMemberRequest;
|
||||
|
@ -24,4 +25,6 @@ public interface ExtSystemProjectMapper {
|
|||
List<UserExtend> getUserMemberList(@Param("userIds") List<String> userIds, @Param("projectId") String projectId, @Param("keyword") String keyword);
|
||||
|
||||
List<ProjectDTO> getProjectExtendDTOList(@Param("projectIds") List<String> projectIds);
|
||||
|
||||
List<ProjectResourcePoolDTO> getProjectResourcePoolDTOList(@Param("projectIds") List<String> projectIds);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
</where>
|
||||
ORDER BY `user`.update_time DESC) temp GROUP BY temp.id ORDER BY adminFlag DESC
|
||||
</select>
|
||||
<select id="getProjectList" resultType="io.metersphere.sdk.dto.ProjectDTO">
|
||||
<select id="getProjectList" resultType="io.metersphere.system.dto.ProjectDTO">
|
||||
select p.id,
|
||||
p.num,
|
||||
p.organization_id,
|
||||
|
@ -150,7 +150,7 @@
|
|||
order by u.create_time desc
|
||||
limit 100
|
||||
</select>
|
||||
<select id="getProjectExtendDTOList" resultType="io.metersphere.sdk.dto.ProjectDTO">
|
||||
<select id="getProjectExtendDTOList" resultType="io.metersphere.system.dto.ProjectDTO">
|
||||
select p.id, count(distinct temp.id) as memberCount
|
||||
FROM project p
|
||||
LEFT JOIN (SELECT ur.source_id, u.id
|
||||
|
@ -167,6 +167,20 @@
|
|||
) temp on p.id = temp.source_id
|
||||
group by p.id
|
||||
</select>
|
||||
<select id="getProjectResourcePoolDTOList" resultType="io.metersphere.system.dto.ProjectResourcePoolDTO">
|
||||
SELECT p.project_id, t.*
|
||||
from project_test_resource_pool p
|
||||
INNER JOIN test_resource_pool t on p.test_resource_pool_id = t.id
|
||||
<where>
|
||||
t.enable = true and t.deleted = false
|
||||
<if test="projectIds != null and projectIds.size > 0 ">
|
||||
and p.project_id in
|
||||
<foreach collection="projectIds" item="projectId" open="(" separator="," close=")">
|
||||
#{projectId}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
|
@ -2,7 +2,10 @@ package io.metersphere.system.service;
|
|||
|
||||
import io.metersphere.project.domain.Project;
|
||||
import io.metersphere.project.domain.ProjectExample;
|
||||
import io.metersphere.project.domain.ProjectTestResourcePool;
|
||||
import io.metersphere.project.domain.ProjectTestResourcePoolExample;
|
||||
import io.metersphere.project.mapper.ProjectMapper;
|
||||
import io.metersphere.project.mapper.ProjectTestResourcePoolMapper;
|
||||
import io.metersphere.sdk.constants.HttpMethodConstants;
|
||||
import io.metersphere.sdk.constants.InternalUserRole;
|
||||
import io.metersphere.sdk.constants.OperationLogConstants;
|
||||
|
@ -10,18 +13,22 @@ import io.metersphere.sdk.constants.UserRoleType;
|
|||
import io.metersphere.sdk.dto.UserExtend;
|
||||
import io.metersphere.sdk.dto.*;
|
||||
import io.metersphere.sdk.exception.MSException;
|
||||
import io.metersphere.system.invoker.ProjectServiceInvoker;
|
||||
import io.metersphere.system.log.constants.OperationLogModule;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.system.log.service.OperationLogService;
|
||||
import io.metersphere.system.uid.UUID;
|
||||
import io.metersphere.sdk.util.BeanUtils;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.sdk.util.LogUtils;
|
||||
import io.metersphere.sdk.util.Translator;
|
||||
import io.metersphere.system.domain.*;
|
||||
import io.metersphere.system.dto.AddProjectRequest;
|
||||
import io.metersphere.system.dto.ProjectDTO;
|
||||
import io.metersphere.system.dto.ProjectResourcePoolDTO;
|
||||
import io.metersphere.system.dto.UpdateProjectRequest;
|
||||
import io.metersphere.system.invoker.ProjectServiceInvoker;
|
||||
import io.metersphere.system.log.constants.OperationLogModule;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.system.log.service.OperationLogService;
|
||||
import io.metersphere.system.mapper.*;
|
||||
import io.metersphere.system.request.ProjectAddMemberBatchRequest;
|
||||
import io.metersphere.system.uid.UUID;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
|
@ -34,6 +41,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
|
@ -59,25 +67,37 @@ public class CommonProjectService {
|
|||
private final ProjectServiceInvoker serviceInvoker;
|
||||
@Resource
|
||||
private OrganizationMapper organizationMapper;
|
||||
@Resource
|
||||
private TestResourcePoolMapper testResourcePoolMapper;
|
||||
@Resource
|
||||
private TestResourcePoolOrganizationMapper testResourcePoolOrganizationMapper;
|
||||
@Resource
|
||||
private ProjectTestResourcePoolMapper projectTestResourcePoolMapper;
|
||||
|
||||
@Autowired
|
||||
public CommonProjectService(ProjectServiceInvoker serviceInvoker) {
|
||||
this.serviceInvoker = serviceInvoker;
|
||||
}
|
||||
|
||||
public ProjectExtendDTO get(String id) {
|
||||
public ProjectDTO get(String id) {
|
||||
Project project = projectMapper.selectByPrimaryKey(id);
|
||||
ProjectExtendDTO projectExtendDTO = new ProjectExtendDTO();
|
||||
ProjectDTO projectDTO = new ProjectDTO();
|
||||
if (ObjectUtils.isNotEmpty(project)) {
|
||||
BeanUtils.copyBean(projectExtendDTO, project);
|
||||
projectExtendDTO.setOrganizationName(organizationMapper.selectByPrimaryKey(project.getOrganizationId()).getName());
|
||||
BeanUtils.copyBean(projectDTO, project);
|
||||
projectDTO.setOrganizationName(organizationMapper.selectByPrimaryKey(project.getOrganizationId()).getName());
|
||||
if (StringUtils.isNotEmpty(project.getModuleSetting())) {
|
||||
projectExtendDTO.setModuleIds(JSON.parseArray(project.getModuleSetting(), String.class));
|
||||
projectDTO.setModuleIds(JSON.parseArray(project.getModuleSetting(), String.class));
|
||||
}
|
||||
List<ProjectResourcePoolDTO> projectResourcePoolDTOList = extSystemProjectMapper.getProjectResourcePoolDTOList(List.of(project.getId()));
|
||||
if (CollectionUtils.isNotEmpty(projectResourcePoolDTOList)) {
|
||||
projectDTO.setResourcePoolList(projectResourcePoolDTOList);
|
||||
} else {
|
||||
projectDTO.setResourcePoolList(new ArrayList<>());
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return projectExtendDTO;
|
||||
return projectDTO;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -87,10 +107,10 @@ public class CommonProjectService {
|
|||
* @param module 日志记录模块
|
||||
* @return
|
||||
*/
|
||||
public ProjectExtendDTO add(AddProjectRequest addProjectDTO, String createUser, String path, String module) {
|
||||
public ProjectDTO add(AddProjectRequest addProjectDTO, String createUser, String path, String module) {
|
||||
|
||||
Project project = new Project();
|
||||
ProjectExtendDTO projectExtendDTO = new ProjectExtendDTO();
|
||||
ProjectDTO projectDTO = new ProjectDTO();
|
||||
project.setId(UUID.randomUUID().toString());
|
||||
project.setName(addProjectDTO.getName());
|
||||
project.setOrganizationId(addProjectDTO.getOrganizationId());
|
||||
|
@ -102,12 +122,12 @@ public class CommonProjectService {
|
|||
project.setEnable(addProjectDTO.getEnable());
|
||||
project.setDescription(addProjectDTO.getDescription());
|
||||
addProjectDTO.setId(project.getId());
|
||||
BeanUtils.copyBean(projectExtendDTO, project);
|
||||
projectExtendDTO.setOrganizationName(organizationMapper.selectByPrimaryKey(project.getOrganizationId()).getName());
|
||||
BeanUtils.copyBean(projectDTO, project);
|
||||
projectDTO.setOrganizationName(organizationMapper.selectByPrimaryKey(project.getOrganizationId()).getName());
|
||||
//判断是否有模块设置
|
||||
if (CollectionUtils.isNotEmpty(addProjectDTO.getModuleIds())) {
|
||||
project.setModuleSetting(JSON.toJSONString(addProjectDTO.getModuleIds()));
|
||||
projectExtendDTO.setModuleIds(addProjectDTO.getModuleIds());
|
||||
projectDTO.setModuleIds(addProjectDTO.getModuleIds());
|
||||
}
|
||||
|
||||
ProjectAddMemberBatchRequest memberRequest = new ProjectAddMemberBatchRequest();
|
||||
|
@ -116,13 +136,27 @@ public class CommonProjectService {
|
|||
memberRequest.setUserIds(List.of(createUser));
|
||||
} else {
|
||||
memberRequest.setUserIds(addProjectDTO.getUserIds());
|
||||
} //资源池
|
||||
if (CollectionUtils.isNotEmpty(addProjectDTO.getResourcePoolIds())) {
|
||||
checkResourcePoolExist(addProjectDTO.getResourcePoolIds());
|
||||
List<ProjectTestResourcePool> projectTestResourcePools = new ArrayList<>();
|
||||
ProjectTestResourcePoolExample projectTestResourcePoolExample = new ProjectTestResourcePoolExample();
|
||||
projectTestResourcePoolExample.createCriteria().andProjectIdEqualTo(project.getId());
|
||||
projectTestResourcePoolMapper.deleteByExample(projectTestResourcePoolExample);
|
||||
addProjectDTO.getResourcePoolIds().forEach(resourcePoolId -> {
|
||||
ProjectTestResourcePool projectTestResourcePool = new ProjectTestResourcePool();
|
||||
projectTestResourcePool.setProjectId(project.getId());
|
||||
projectTestResourcePool.setTestResourcePoolId(resourcePoolId);
|
||||
projectTestResourcePools.add(projectTestResourcePool);
|
||||
});
|
||||
projectTestResourcePoolMapper.batchInsert(projectTestResourcePools);
|
||||
}
|
||||
projectMapper.insertSelective(project);
|
||||
serviceInvoker.invokeCreateServices(project.getId());
|
||||
//添加项目管理员 创建的时候如果没有传管理员id 则默认创建者为管理员
|
||||
this.addProjectAdmin(memberRequest, createUser, path,
|
||||
OperationLogType.ADD.name(), Translator.get("add"), module);
|
||||
return projectExtendDTO;
|
||||
return projectDTO;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -195,6 +229,11 @@ public class CommonProjectService {
|
|||
Map<String, ProjectDTO> projectMap = projectDTOList.stream().collect(Collectors.toMap(ProjectDTO::getId, projectDTO -> projectDTO));
|
||||
//根据sourceId分组
|
||||
Map<String, List<UserExtend>> userMapList = users.stream().collect(Collectors.groupingBy(UserExtend::getSourceId));
|
||||
//获取资源池
|
||||
List<ProjectResourcePoolDTO> projectResourcePoolDTOList = extSystemProjectMapper.getProjectResourcePoolDTOList(projectIds);
|
||||
//根据projectId分组 key为项目id 值为资源池TestResourcePool
|
||||
Map<String, List<ProjectResourcePoolDTO>> poolMap = projectResourcePoolDTOList.stream().collect(Collectors.groupingBy(ProjectResourcePoolDTO::getProjectId));
|
||||
|
||||
projectList.forEach(projectDTO -> {
|
||||
if (StringUtils.isNotBlank(projectDTO.getModuleSetting())) {
|
||||
projectDTO.setModuleIds(JSON.parseArray(projectDTO.getModuleSetting(), String.class));
|
||||
|
@ -212,6 +251,12 @@ public class CommonProjectService {
|
|||
} else {
|
||||
projectDTO.setAdminList(new ArrayList<>());
|
||||
}
|
||||
List<ProjectResourcePoolDTO> projectResourcePoolDTOS = poolMap.get(projectDTO.getId());
|
||||
if (CollectionUtils.isNotEmpty(projectResourcePoolDTOS)) {
|
||||
projectDTO.setResourcePoolList(projectResourcePoolDTOS);
|
||||
} else {
|
||||
projectDTO.setResourcePoolList(new ArrayList<>());
|
||||
}
|
||||
projectDTO.setCreateUser(userMap.get(projectDTO.getCreateUser()));
|
||||
projectDTO.setUpdateUser(userMap.get(projectDTO.getUpdateUser()));
|
||||
projectDTO.setDeleteUser(userMap.get(projectDTO.getDeleteUser()));
|
||||
|
@ -219,9 +264,9 @@ public class CommonProjectService {
|
|||
return projectList;
|
||||
}
|
||||
|
||||
public ProjectExtendDTO update(UpdateProjectRequest updateProjectDto, String updateUser, String path, String module) {
|
||||
public ProjectDTO update(UpdateProjectRequest updateProjectDto, String updateUser, String path, String module) {
|
||||
Project project = new Project();
|
||||
ProjectExtendDTO projectExtendDTO = new ProjectExtendDTO();
|
||||
ProjectDTO projectDTO = new ProjectDTO();
|
||||
project.setId(updateProjectDto.getId());
|
||||
project.setName(updateProjectDto.getName());
|
||||
project.setDescription(updateProjectDto.getDescription());
|
||||
|
@ -233,8 +278,24 @@ public class CommonProjectService {
|
|||
project.setUpdateTime(System.currentTimeMillis());
|
||||
checkProjectExistByName(project);
|
||||
checkProjectNotExist(project.getId());
|
||||
projectExtendDTO.setOrganizationName(organizationMapper.selectByPrimaryKey(project.getOrganizationId()).getName());
|
||||
BeanUtils.copyBean(projectExtendDTO, project);
|
||||
projectDTO.setOrganizationName(organizationMapper.selectByPrimaryKey(project.getOrganizationId()).getName());
|
||||
BeanUtils.copyBean(projectDTO, project);
|
||||
//资源池
|
||||
if (CollectionUtils.isNotEmpty(updateProjectDto.getResourcePoolIds())) {
|
||||
checkResourcePoolExist(updateProjectDto.getResourcePoolIds());
|
||||
List<ProjectTestResourcePool> projectTestResourcePools = new ArrayList<>();
|
||||
ProjectTestResourcePoolExample projectTestResourcePoolExample = new ProjectTestResourcePoolExample();
|
||||
projectTestResourcePoolExample.createCriteria().andProjectIdEqualTo(project.getId());
|
||||
projectTestResourcePoolMapper.deleteByExample(projectTestResourcePoolExample);
|
||||
updateProjectDto.getResourcePoolIds().forEach(resourcePoolId -> {
|
||||
ProjectTestResourcePool projectTestResourcePool = new ProjectTestResourcePool();
|
||||
projectTestResourcePool.setProjectId(project.getId());
|
||||
projectTestResourcePool.setTestResourcePoolId(resourcePoolId);
|
||||
projectTestResourcePools.add(projectTestResourcePool);
|
||||
});
|
||||
projectTestResourcePoolMapper.batchInsert(projectTestResourcePools);
|
||||
}
|
||||
|
||||
UserRoleRelationExample example = new UserRoleRelationExample();
|
||||
example.createCriteria().andSourceIdEqualTo(project.getId()).andRoleIdEqualTo(InternalUserRole.PROJECT_ADMIN.getValue());
|
||||
List<UserRoleRelation> userRoleRelations = userRoleRelationMapper.selectByExample(example);
|
||||
|
@ -285,11 +346,20 @@ public class CommonProjectService {
|
|||
//判断是否有模块设置
|
||||
if (CollectionUtils.isNotEmpty(updateProjectDto.getModuleIds())) {
|
||||
project.setModuleSetting(JSON.toJSONString(updateProjectDto.getModuleIds()));
|
||||
projectExtendDTO.setModuleIds(updateProjectDto.getModuleIds());
|
||||
projectDTO.setModuleIds(updateProjectDto.getModuleIds());
|
||||
}
|
||||
|
||||
projectMapper.updateByPrimaryKeySelective(project);
|
||||
return projectExtendDTO;
|
||||
return projectDTO;
|
||||
}
|
||||
|
||||
public void checkResourcePoolExist(List<String> poolIds) {
|
||||
TestResourcePoolExample testResourcePoolExample = new TestResourcePoolExample();
|
||||
testResourcePoolExample.createCriteria().andIdIn(poolIds).andEnableEqualTo(true).andDeletedEqualTo(false);
|
||||
List<TestResourcePool> testResourcePools = testResourcePoolMapper.selectByExample(testResourcePoolExample);
|
||||
if (poolIds.size() != testResourcePools.size()) {
|
||||
throw new MSException(Translator.get("resource_pool_not_exist"));
|
||||
}
|
||||
}
|
||||
|
||||
public int delete(String id, String deleteUser) {
|
||||
|
@ -453,6 +523,10 @@ public class CommonProjectService {
|
|||
LogUtils.info("send delete_project message, project id: " + project.getId());
|
||||
|
||||
deleteProjectUserGroup(project.getId());
|
||||
//删除资源池关联表
|
||||
ProjectTestResourcePoolExample projectTestResourcePoolExample = new ProjectTestResourcePoolExample();
|
||||
projectTestResourcePoolExample.createCriteria().andProjectIdEqualTo(project.getId());
|
||||
projectTestResourcePoolMapper.deleteByExample(projectTestResourcePoolExample);
|
||||
// delete project
|
||||
projectMapper.deleteByPrimaryKey(project.getId());
|
||||
LogDTO logDTO = new LogDTO(OperationLogConstants.SYSTEM, project.getOrganizationId(), project.getId(), Translator.get("scheduled_tasks"), OperationLogType.DELETE.name(), OperationLogModule.SETTING_ORGANIZATION_PROJECT, Translator.get("delete") + Translator.get("project") + ": " + project.getName());
|
||||
|
@ -513,4 +587,25 @@ public class CommonProjectService {
|
|||
project.setUpdateTime(System.currentTimeMillis());
|
||||
projectMapper.updateByPrimaryKeySelective(project);
|
||||
}
|
||||
|
||||
public List<TestResourcePool> getTestResourcePoolOptions(String organizationId) {
|
||||
//获取制定组织的资源池 和全部组织的资源池
|
||||
List<TestResourcePool> testResourcePools = new ArrayList<>();
|
||||
TestResourcePoolOrganizationExample example = new TestResourcePoolOrganizationExample();
|
||||
example.createCriteria().andOrgIdEqualTo(organizationId);
|
||||
List<TestResourcePoolOrganization> orgPools = testResourcePoolOrganizationMapper.selectByExample(example);
|
||||
if (CollectionUtils.isNotEmpty(orgPools)) {
|
||||
List<String> poolIds = orgPools.stream().map(TestResourcePoolOrganization::getTestResourcePoolId).toList();
|
||||
TestResourcePoolExample poolExample = new TestResourcePoolExample();
|
||||
poolExample.createCriteria().andIdIn(poolIds).andEnableEqualTo(true).andDeletedEqualTo(false);
|
||||
testResourcePools.addAll(testResourcePoolMapper.selectByExample(poolExample));
|
||||
}
|
||||
//获取应用全部组织的资源池
|
||||
TestResourcePoolExample poolExample = new TestResourcePoolExample();
|
||||
poolExample.createCriteria().andAllOrgEqualTo(true).andEnableEqualTo(true).andDeletedEqualTo(false);
|
||||
testResourcePools.addAll(testResourcePoolMapper.selectByExample(poolExample));
|
||||
|
||||
testResourcePools = testResourcePools.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
||||
return testResourcePools;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,9 +3,9 @@ package io.metersphere.system.service;
|
|||
import io.metersphere.project.domain.Project;
|
||||
import io.metersphere.project.mapper.ProjectMapper;
|
||||
import io.metersphere.sdk.constants.HttpMethodConstants;
|
||||
import io.metersphere.sdk.dto.AddProjectRequest;
|
||||
import io.metersphere.system.dto.AddProjectRequest;
|
||||
import io.metersphere.sdk.dto.LogDTO;
|
||||
import io.metersphere.sdk.dto.UpdateProjectRequest;
|
||||
import io.metersphere.system.dto.UpdateProjectRequest;
|
||||
import io.metersphere.system.log.constants.OperationLogModule;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
|
|
|
@ -2,6 +2,10 @@ package io.metersphere.system.service;
|
|||
|
||||
import io.metersphere.sdk.dto.*;
|
||||
import io.metersphere.sdk.exception.MSException;
|
||||
import io.metersphere.system.domain.TestResourcePool;
|
||||
import io.metersphere.system.dto.AddProjectRequest;
|
||||
import io.metersphere.system.dto.ProjectDTO;
|
||||
import io.metersphere.system.dto.UpdateProjectRequest;
|
||||
import io.metersphere.system.log.constants.OperationLogModule;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.sdk.util.BeanUtils;
|
||||
|
@ -44,7 +48,7 @@ public class OrganizationProjectService {
|
|||
private final static String REMOVE_PROJECT_MEMBER = PREFIX + "/remove-member/";
|
||||
private final static String ADD_MEMBER = PREFIX + "/add-member";
|
||||
|
||||
public ProjectExtendDTO get(String id) {
|
||||
public ProjectDTO get(String id) {
|
||||
return commonProjectService.get(id);
|
||||
}
|
||||
|
||||
|
@ -52,7 +56,7 @@ public class OrganizationProjectService {
|
|||
* @param addProjectDTO 添加项目的时候 默认给用户组添加管理员的权限
|
||||
* @return
|
||||
*/
|
||||
public ProjectExtendDTO add(AddProjectRequest addProjectDTO, String createUser) {
|
||||
public ProjectDTO add(AddProjectRequest addProjectDTO, String createUser) {
|
||||
return commonProjectService.add(addProjectDTO, createUser, ADD_PROJECT, OperationLogModule.SETTING_ORGANIZATION_PROJECT);
|
||||
}
|
||||
|
||||
|
@ -63,7 +67,7 @@ public class OrganizationProjectService {
|
|||
return commonProjectService.buildUserInfo(projectList);
|
||||
}
|
||||
|
||||
public ProjectExtendDTO update(UpdateProjectRequest updateProjectDto, String updateUser) {
|
||||
public ProjectDTO update(UpdateProjectRequest updateProjectDto, String updateUser) {
|
||||
return commonProjectService.update(updateProjectDto, updateUser, UPDATE_PROJECT, OperationLogModule.SETTING_ORGANIZATION_PROJECT);
|
||||
}
|
||||
|
||||
|
@ -125,4 +129,8 @@ public class OrganizationProjectService {
|
|||
throw new MSException(Translator.get("organization_not_exists"));
|
||||
}
|
||||
}
|
||||
|
||||
public List<TestResourcePool> getTestResourcePoolOptions(String organizationId) {
|
||||
return commonProjectService.getTestResourcePoolOptions(organizationId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@ import io.metersphere.project.domain.Project;
|
|||
import io.metersphere.project.mapper.ProjectMapper;
|
||||
import io.metersphere.sdk.constants.HttpMethodConstants;
|
||||
import io.metersphere.sdk.constants.OperationLogConstants;
|
||||
import io.metersphere.sdk.dto.AddProjectRequest;
|
||||
import io.metersphere.system.dto.AddProjectRequest;
|
||||
import io.metersphere.sdk.dto.LogDTO;
|
||||
import io.metersphere.sdk.dto.UpdateProjectRequest;
|
||||
import io.metersphere.system.dto.UpdateProjectRequest;
|
||||
import io.metersphere.system.log.constants.OperationLogModule;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
package io.metersphere.system.service;
|
||||
|
||||
import io.metersphere.project.domain.Project;
|
||||
import io.metersphere.sdk.dto.AddProjectRequest;
|
||||
import io.metersphere.sdk.dto.ProjectDTO;
|
||||
import io.metersphere.sdk.dto.ProjectExtendDTO;
|
||||
import io.metersphere.sdk.dto.UpdateProjectRequest;
|
||||
import io.metersphere.sdk.dto.*;
|
||||
import io.metersphere.system.domain.TestResourcePool;
|
||||
import io.metersphere.system.dto.AddProjectRequest;
|
||||
import io.metersphere.system.dto.ProjectDTO;
|
||||
import io.metersphere.system.dto.UpdateProjectRequest;
|
||||
import io.metersphere.system.log.constants.OperationLogModule;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.sdk.util.Translator;
|
||||
import io.metersphere.system.dto.OrganizationProjectOptionsDTO;
|
||||
import io.metersphere.sdk.dto.UserExtend;
|
||||
import io.metersphere.system.mapper.ExtSystemProjectMapper;
|
||||
import io.metersphere.system.request.ProjectAddMemberBatchRequest;
|
||||
import io.metersphere.system.request.ProjectMemberRequest;
|
||||
|
@ -36,7 +36,7 @@ public class SystemProjectService {
|
|||
private final static String REMOVE_PROJECT_MEMBER = PREFIX + "/remove-member/";
|
||||
private final static String ADD_MEMBER = PREFIX + "/add-member";
|
||||
|
||||
public ProjectExtendDTO get(String id) {
|
||||
public ProjectDTO get(String id) {
|
||||
return commonProjectService.get(id);
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ public class SystemProjectService {
|
|||
* @param addProjectDTO 添加项目的时候 默认给用户组添加管理员的权限
|
||||
* @return
|
||||
*/
|
||||
public ProjectExtendDTO add(AddProjectRequest addProjectDTO, String createUser) {
|
||||
public ProjectDTO add(AddProjectRequest addProjectDTO, String createUser) {
|
||||
return commonProjectService.add(addProjectDTO, createUser, ADD_PROJECT, OperationLogModule.SETTING_SYSTEM_ORGANIZATION);
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ public class SystemProjectService {
|
|||
return commonProjectService.buildUserInfo(projectList);
|
||||
}
|
||||
|
||||
public ProjectExtendDTO update(UpdateProjectRequest updateProjectDto, String updateUser) {
|
||||
public ProjectDTO update(UpdateProjectRequest updateProjectDto, String updateUser) {
|
||||
return commonProjectService.update(updateProjectDto, updateUser, UPDATE_PROJECT, OperationLogModule.SETTING_SYSTEM_ORGANIZATION);
|
||||
}
|
||||
|
||||
|
@ -98,4 +98,9 @@ public class SystemProjectService {
|
|||
public void disable(String id, String updateUser) {
|
||||
commonProjectService.disable(id, updateUser);
|
||||
}
|
||||
|
||||
public List<TestResourcePool> getTestResourcePoolOptions(String organizationId) {
|
||||
return commonProjectService.getTestResourcePoolOptions(organizationId);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,21 +1,24 @@
|
|||
package io.metersphere.system.service;
|
||||
|
||||
import io.metersphere.project.domain.ProjectTestResourcePoolExample;
|
||||
import io.metersphere.project.mapper.ProjectTestResourcePoolMapper;
|
||||
import io.metersphere.sdk.constants.HttpMethodConstants;
|
||||
import io.metersphere.sdk.constants.OperationLogConstants;
|
||||
import io.metersphere.sdk.constants.ResourcePoolTypeEnum;
|
||||
import io.metersphere.sdk.dto.*;
|
||||
import io.metersphere.sdk.exception.MSException;
|
||||
import io.metersphere.system.log.constants.OperationLogModule;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.sdk.util.BeanUtils;
|
||||
import io.metersphere.sdk.util.CommonBeanFactory;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.sdk.util.Translator;
|
||||
import io.metersphere.system.domain.*;
|
||||
import io.metersphere.system.log.constants.OperationLogModule;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.system.mapper.OrganizationMapper;
|
||||
import io.metersphere.system.mapper.TestResourcePoolBlobMapper;
|
||||
import io.metersphere.system.mapper.TestResourcePoolMapper;
|
||||
import io.metersphere.system.mapper.TestResourcePoolOrganizationMapper;
|
||||
import io.metersphere.system.uid.UUID;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
@ -28,7 +31,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import io.metersphere.system.uid.UUID;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
|
@ -44,6 +46,8 @@ public class TestResourcePoolService {
|
|||
private SqlSessionFactory sqlSessionFactory;
|
||||
@Resource
|
||||
private OrganizationMapper organizationMapper;
|
||||
@Resource
|
||||
private ProjectTestResourcePoolMapper projectTestResourcePoolMapper;
|
||||
|
||||
|
||||
public TestResourcePool addTestResourcePool(TestResourcePoolDTO testResourcePool) {
|
||||
|
@ -164,12 +168,19 @@ public class TestResourcePoolService {
|
|||
}
|
||||
//删除与组织的关系
|
||||
deleteOrgRelation(testResourcePoolId);
|
||||
deleteProjectRelation(testResourcePoolId);
|
||||
testResourcePool.setUpdateTime(System.currentTimeMillis());
|
||||
testResourcePool.setEnable(false);
|
||||
testResourcePool.setDeleted(true);
|
||||
testResourcePoolMapper.updateByPrimaryKeySelective(testResourcePool);
|
||||
}
|
||||
|
||||
private void deleteProjectRelation(String testResourcePoolId) {
|
||||
ProjectTestResourcePoolExample projectTestResourcePoolExample = new ProjectTestResourcePoolExample();
|
||||
projectTestResourcePoolExample.createCriteria().andTestResourcePoolIdEqualTo(testResourcePoolId);
|
||||
projectTestResourcePoolMapper.deleteByExample(projectTestResourcePoolExample);
|
||||
}
|
||||
|
||||
private void deleteOrgRelation(String testResourcePoolId) {
|
||||
TestResourcePoolOrganizationExample testResourcePoolOrganizationExample = new TestResourcePoolOrganizationExample();
|
||||
testResourcePoolOrganizationExample.createCriteria().andTestResourcePoolIdEqualTo(testResourcePoolId);
|
||||
|
|
|
@ -2,13 +2,19 @@ package io.metersphere.system.controller;
|
|||
|
||||
import io.metersphere.project.domain.Project;
|
||||
import io.metersphere.project.domain.ProjectExample;
|
||||
import io.metersphere.project.domain.ProjectTestResourcePool;
|
||||
import io.metersphere.project.domain.ProjectTestResourcePoolExample;
|
||||
import io.metersphere.project.mapper.ProjectMapper;
|
||||
import io.metersphere.project.mapper.ProjectTestResourcePoolMapper;
|
||||
import io.metersphere.system.base.BaseTest;
|
||||
import io.metersphere.sdk.constants.InternalUserRole;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.sdk.constants.SessionConstants;
|
||||
import io.metersphere.system.controller.handler.ResultHolder;
|
||||
import io.metersphere.sdk.dto.*;
|
||||
import io.metersphere.system.dto.AddProjectRequest;
|
||||
import io.metersphere.system.dto.ProjectDTO;
|
||||
import io.metersphere.system.dto.UpdateProjectRequest;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.sdk.util.Pager;
|
||||
|
@ -66,6 +72,7 @@ public class OrganizationProjectControllerTests extends BaseTest {
|
|||
private final static String enableProject = prefix + "/enable/";
|
||||
private final static String getAdminList = prefix + "/user-admin-list/";
|
||||
private final static String getMemberList = prefix + "/user-member-list/";
|
||||
private final static String getPoolOptions = prefix + "/pool-options/";
|
||||
private static final ResultMatcher BAD_REQUEST_MATCHER = status().isBadRequest();
|
||||
private static final ResultMatcher ERROR_REQUEST_MATCHER = status().is5xxServerError();
|
||||
|
||||
|
@ -79,6 +86,8 @@ public class OrganizationProjectControllerTests extends BaseTest {
|
|||
private OrganizationService organizationService;
|
||||
@Resource
|
||||
private UserMapper userMapper;
|
||||
@Resource
|
||||
private ProjectTestResourcePoolMapper projectTestResourcePoolMapper;
|
||||
|
||||
private OrganizationDTO getDefault() {
|
||||
return organizationService.getDefault();
|
||||
|
@ -183,7 +192,7 @@ public class OrganizationProjectControllerTests extends BaseTest {
|
|||
public void testAddProjectSuccess() throws Exception {
|
||||
AddProjectRequest project = this.generatorAdd("organizationId","organization-name", "description", true, List.of("admin"));
|
||||
MvcResult mvcResult = this.responsePost(addProject, project);
|
||||
ProjectExtendDTO result = parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||
ProjectDTO result = parseObjectFromMvcResult(mvcResult, ProjectDTO.class);
|
||||
ProjectExample projectExample = new ProjectExample();
|
||||
projectExample.createCriteria().andOrganizationIdEqualTo(project.getOrganizationId()).andNameEqualTo(project.getName());
|
||||
List<Project> projects = projectMapper.selectByExample(projectExample);
|
||||
|
@ -209,7 +218,7 @@ public class OrganizationProjectControllerTests extends BaseTest {
|
|||
//userId为空的时候
|
||||
project = this.generatorAdd("organizationId","organization-userIdIsNull", "description", true, new ArrayList<>());
|
||||
mvcResult = this.responsePost(addProject, project);
|
||||
result = parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||
result = parseObjectFromMvcResult(mvcResult, ProjectDTO.class);
|
||||
projectExample = new ProjectExample();
|
||||
projectExample.createCriteria().andOrganizationIdEqualTo(project.getOrganizationId()).andNameEqualTo(project.getName());
|
||||
projects = projectMapper.selectByExample(projectExample);
|
||||
|
@ -236,7 +245,7 @@ public class OrganizationProjectControllerTests extends BaseTest {
|
|||
project.setModuleIds(moduleIds);
|
||||
project.setName("org-moduleSetting");
|
||||
mvcResult = this.responsePost(addProject, project);
|
||||
result = parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||
result = parseObjectFromMvcResult(mvcResult, ProjectDTO.class);
|
||||
projectExample = new ProjectExample();
|
||||
projectExample.createCriteria().andOrganizationIdEqualTo(project.getOrganizationId()).andNameEqualTo(project.getName());
|
||||
projects = projectMapper.selectByExample(projectExample);
|
||||
|
@ -256,6 +265,28 @@ public class OrganizationProjectControllerTests extends BaseTest {
|
|||
projectExtend = projectMapper.selectByPrimaryKey(projectId);
|
||||
Assertions.assertEquals(projectExtend.getModuleSetting(), JSON.toJSONString(moduleIds));
|
||||
|
||||
//设置资源池
|
||||
project.setResourcePoolIds(List.of("resourcePoolId"));
|
||||
project.setName("org-resourcePool");
|
||||
mvcResult = this.responsePost(addProject, project);
|
||||
result = parseObjectFromMvcResult(mvcResult, ProjectDTO.class);
|
||||
projectExample = new ProjectExample();
|
||||
projectExample.createCriteria().andOrganizationIdEqualTo(project.getOrganizationId()).andNameEqualTo(project.getName());
|
||||
projects = projectMapper.selectByExample(projectExample);
|
||||
assert result != null;
|
||||
projectId = result.getId();
|
||||
// 校验日志
|
||||
checkLog(projectId, OperationLogType.ADD);
|
||||
|
||||
compareProjectDTO(projects.get(0), result);
|
||||
//校验资源池
|
||||
ProjectTestResourcePoolExample projectTestResourcePoolExample = new ProjectTestResourcePoolExample();
|
||||
projectTestResourcePoolExample.createCriteria().andProjectIdEqualTo(projectId);
|
||||
List<ProjectTestResourcePool> projectTestResourcePools = projectTestResourcePoolMapper.selectByExample(projectTestResourcePoolExample);
|
||||
Assertions.assertTrue(projectTestResourcePools.stream().map(ProjectTestResourcePool::getTestResourcePoolId).toList().contains("resourcePoolId"));
|
||||
|
||||
|
||||
|
||||
project.setName("organization-testAddProjectSuccess1");
|
||||
project.setOrganizationId(getDefault().getId());
|
||||
// @@校验权限
|
||||
|
@ -282,6 +313,10 @@ public class OrganizationProjectControllerTests extends BaseTest {
|
|||
//项目成员在系统中不存在
|
||||
project = this.generatorAdd("organizationId", "name", null, true, List.of("admin", "admin1", "admin3"));
|
||||
this.requestPost(addProject, project, ERROR_REQUEST_MATCHER);
|
||||
//资源池不存在
|
||||
project = this.generatorAdd("organizationId", "org-pool-error", null, true, List.of("admin"));
|
||||
project.setResourcePoolIds(List.of("resourcePoolId3"));
|
||||
this.requestPost(addProject, project, ERROR_REQUEST_MATCHER);
|
||||
|
||||
}
|
||||
@Test
|
||||
|
@ -289,16 +324,20 @@ public class OrganizationProjectControllerTests extends BaseTest {
|
|||
public void testGetProject() throws Exception {
|
||||
AddProjectRequest project = this.generatorAdd("organizationId","organization-getName", "description", true, List.of("admin"));
|
||||
MvcResult mvcResult = this.responsePost(addProject, project);
|
||||
ProjectExtendDTO result = parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||
ProjectDTO result = parseObjectFromMvcResult(mvcResult, ProjectDTO.class);
|
||||
assert result != null;
|
||||
projectId = result.getId();
|
||||
mvcResult = this.responseGet(getProject + projectId);
|
||||
Project getProjects = parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||
Project getProjects = parseObjectFromMvcResult(mvcResult, ProjectDTO.class);
|
||||
Assertions.assertTrue(StringUtils.equals(getProjects.getId(), projectId));
|
||||
|
||||
mvcResult = this.responseGet(getProject + "projectId");
|
||||
getProjects = parseObjectFromMvcResult(mvcResult, ProjectDTO.class);
|
||||
assert getProjects != null;
|
||||
Assertions.assertTrue(StringUtils.equals(getProjects.getId(), "projectId"));
|
||||
|
||||
mvcResult = this.responseGet(getProject + "projectId1");
|
||||
getProjects = parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||
getProjects = parseObjectFromMvcResult(mvcResult, ProjectDTO.class);
|
||||
assert getProjects != null;
|
||||
Assertions.assertTrue(StringUtils.equals(getProjects.getId(), "projectId1"));
|
||||
// @@校验权限
|
||||
|
@ -309,7 +348,7 @@ public class OrganizationProjectControllerTests extends BaseTest {
|
|||
public void testGetProjectError() throws Exception {
|
||||
//项目不存在
|
||||
MvcResult mvcResult = this.responseGet(getProject + "111111");
|
||||
ProjectExtendDTO project = parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||
ProjectDTO project = parseObjectFromMvcResult(mvcResult, ProjectDTO.class);
|
||||
Assertions.assertNull(project);
|
||||
}
|
||||
|
||||
|
@ -428,7 +467,7 @@ public class OrganizationProjectControllerTests extends BaseTest {
|
|||
}
|
||||
project.setModuleIds(moduleIds);
|
||||
MvcResult mvcResult = this.responsePost(updateProject, project);
|
||||
ProjectExtendDTO result = parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||
ProjectDTO result = parseObjectFromMvcResult(mvcResult, ProjectDTO.class);
|
||||
Project currentProject = projectMapper.selectByPrimaryKey(project.getId());
|
||||
compareProjectDTO(currentProject, result);
|
||||
UserRoleRelationExample userRoleRelationExample = new UserRoleRelationExample();
|
||||
|
@ -447,7 +486,7 @@ public class OrganizationProjectControllerTests extends BaseTest {
|
|||
//用户id为空
|
||||
project = this.generatorUpdate("organizationId", "projectId2", "organization-TestNameUserIdIsNull", "Edit name", true, new ArrayList<>());
|
||||
mvcResult = this.responsePost(updateProject, project);
|
||||
result = parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||
result = parseObjectFromMvcResult(mvcResult, ProjectDTO.class);
|
||||
currentProject = projectMapper.selectByPrimaryKey(project.getId());
|
||||
compareProjectDTO(currentProject, result);
|
||||
userRoleRelationExample = new UserRoleRelationExample();
|
||||
|
@ -466,7 +505,7 @@ public class OrganizationProjectControllerTests extends BaseTest {
|
|||
moduleIds.add("uiTest");
|
||||
project.setModuleIds(moduleIds);
|
||||
mvcResult = this.responsePost(updateProject, project);
|
||||
result = parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||
result = parseObjectFromMvcResult(mvcResult, ProjectDTO.class);
|
||||
currentProject = projectMapper.selectByPrimaryKey(project.getId());
|
||||
compareProjectDTO(currentProject, result);
|
||||
userRoleRelationExample = new UserRoleRelationExample();
|
||||
|
@ -477,6 +516,20 @@ public class OrganizationProjectControllerTests extends BaseTest {
|
|||
//断言模块设置
|
||||
projectExtend = projectMapper.selectByPrimaryKey("projectId2");
|
||||
Assertions.assertEquals(projectExtend.getModuleSetting(), JSON.toJSONString(moduleIds));
|
||||
|
||||
//设置资源池
|
||||
project = this.generatorUpdate("organizationId", "projectId3", "org-updatePools", "org-updatePools", true, new ArrayList<>());
|
||||
project.setResourcePoolIds(List.of("resourcePoolId","resourcePoolId1"));
|
||||
mvcResult = this.responsePost(updateProject, project);
|
||||
result = parseObjectFromMvcResult(mvcResult, ProjectDTO.class);
|
||||
currentProject = projectMapper.selectByPrimaryKey(project.getId());
|
||||
compareProjectDTO(currentProject, result);
|
||||
//校验资源池
|
||||
ProjectTestResourcePoolExample projectTestResourcePoolExample = new ProjectTestResourcePoolExample();
|
||||
projectTestResourcePoolExample.createCriteria().andProjectIdEqualTo("projectId3");
|
||||
List<ProjectTestResourcePool> projectTestResourcePools = projectTestResourcePoolMapper.selectByExample(projectTestResourcePoolExample);
|
||||
Assertions.assertTrue(projectTestResourcePools.stream().map(ProjectTestResourcePool::getTestResourcePoolId).toList().containsAll(project.getResourcePoolIds()));
|
||||
|
||||
// @@校验权限
|
||||
project.setName("organization-TestName2");
|
||||
project.setId("projectId1");
|
||||
|
@ -504,6 +557,10 @@ public class OrganizationProjectControllerTests extends BaseTest {
|
|||
//项目不存在
|
||||
project = this.generatorUpdate("organizationId", "1111","123", null, true, List.of("admin"));
|
||||
this.requestPost(updateProject, project, ERROR_REQUEST_MATCHER);
|
||||
//资源池不存在
|
||||
project = this.generatorUpdate("organizationId", "projectId","org-Module-pool", null, true, List.of("admin"));
|
||||
project.setResourcePoolIds(List.of("resourcePoolId3"));
|
||||
this.requestPost(updateProject, project, ERROR_REQUEST_MATCHER);
|
||||
|
||||
}
|
||||
|
||||
|
@ -795,4 +852,12 @@ public class OrganizationProjectControllerTests extends BaseTest {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(23)
|
||||
public void testGetOptions() throws Exception {
|
||||
this.requestGetWithOkAndReturn(getPoolOptions + "organizationId");
|
||||
// @@校验权限
|
||||
requestGetPermissionTest(PermissionConstants.ORGANIZATION_PROJECT_READ, getPoolOptions + DEFAULT_ORGANIZATION_ID);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package io.metersphere.system.controller;
|
|||
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.sdk.constants.SessionConstants;
|
||||
import io.metersphere.sdk.dto.ProjectDTO;
|
||||
import io.metersphere.system.dto.ProjectDTO;
|
||||
import io.metersphere.sdk.dto.UserExtend;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.sdk.util.Pager;
|
||||
|
|
|
@ -2,13 +2,19 @@ package io.metersphere.system.controller;
|
|||
|
||||
import io.metersphere.project.domain.Project;
|
||||
import io.metersphere.project.domain.ProjectExample;
|
||||
import io.metersphere.project.domain.ProjectTestResourcePool;
|
||||
import io.metersphere.project.domain.ProjectTestResourcePoolExample;
|
||||
import io.metersphere.project.mapper.ProjectMapper;
|
||||
import io.metersphere.project.mapper.ProjectTestResourcePoolMapper;
|
||||
import io.metersphere.system.base.BaseTest;
|
||||
import io.metersphere.sdk.constants.InternalUserRole;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.sdk.constants.SessionConstants;
|
||||
import io.metersphere.system.controller.handler.ResultHolder;
|
||||
import io.metersphere.sdk.dto.*;
|
||||
import io.metersphere.system.dto.AddProjectRequest;
|
||||
import io.metersphere.system.dto.ProjectDTO;
|
||||
import io.metersphere.system.dto.UpdateProjectRequest;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.sdk.util.Pager;
|
||||
|
@ -62,6 +68,7 @@ public class SystemProjectControllerTests extends BaseTest {
|
|||
private final static String disableProject = prefix + "/disable/";
|
||||
private final static String enableProject = prefix + "/enable/";
|
||||
private final static String userList = prefix + "/user-list";
|
||||
private final static String getPoolOptions = prefix + "/pool-options/";
|
||||
private static final ResultMatcher BAD_REQUEST_MATCHER = status().isBadRequest();
|
||||
private static final ResultMatcher ERROR_REQUEST_MATCHER = status().is5xxServerError();
|
||||
|
||||
|
@ -73,6 +80,8 @@ public class SystemProjectControllerTests extends BaseTest {
|
|||
private UserRoleRelationMapper userRoleRelationMapper;
|
||||
@Resource
|
||||
private UserMapper userMapper;
|
||||
@Resource
|
||||
private ProjectTestResourcePoolMapper projectTestResourcePoolMapper;
|
||||
|
||||
private void requestPost(String url, Object param, ResultMatcher resultMatcher) throws Exception {
|
||||
mockMvc.perform(MockMvcRequestBuilders.post(url)
|
||||
|
@ -173,7 +182,7 @@ public class SystemProjectControllerTests extends BaseTest {
|
|||
public void testAddProjectSuccess() throws Exception {
|
||||
AddProjectRequest project = this.generatorAdd("organizationId","name", "description", true, List.of("admin"));
|
||||
MvcResult mvcResult = this.responsePost(addProject, project);
|
||||
ProjectExtendDTO result = parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||
ProjectDTO result = parseObjectFromMvcResult(mvcResult, ProjectDTO.class);
|
||||
ProjectExample projectExample = new ProjectExample();
|
||||
projectExample.createCriteria().andOrganizationIdEqualTo(project.getOrganizationId()).andNameEqualTo(project.getName());
|
||||
List<Project> projects = projectMapper.selectByExample(projectExample);
|
||||
|
@ -196,7 +205,7 @@ public class SystemProjectControllerTests extends BaseTest {
|
|||
//userId为空的时候
|
||||
project = this.generatorAdd("organizationId","userIdIsNull", "description", true, new ArrayList<>());
|
||||
mvcResult = this.responsePost(addProject, project);
|
||||
result = parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||
result = parseObjectFromMvcResult(mvcResult, ProjectDTO.class);
|
||||
projectExample = new ProjectExample();
|
||||
projectExample.createCriteria().andOrganizationIdEqualTo(project.getOrganizationId()).andNameEqualTo(project.getName());
|
||||
projects = projectMapper.selectByExample(projectExample);
|
||||
|
@ -223,7 +232,7 @@ public class SystemProjectControllerTests extends BaseTest {
|
|||
project.setModuleIds(moduleIds);
|
||||
project.setName("moduleSetting");
|
||||
mvcResult = this.responsePost(addProject, project);
|
||||
result = parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||
result = parseObjectFromMvcResult(mvcResult, ProjectDTO.class);
|
||||
projectExample = new ProjectExample();
|
||||
projectExample.createCriteria().andOrganizationIdEqualTo(project.getOrganizationId()).andNameEqualTo(project.getName());
|
||||
projects = projectMapper.selectByExample(projectExample);
|
||||
|
@ -243,6 +252,26 @@ public class SystemProjectControllerTests extends BaseTest {
|
|||
currentProject = projectMapper.selectByPrimaryKey(projectId);
|
||||
Assertions.assertEquals(currentProject.getModuleSetting(), JSON.toJSONString(moduleIds));
|
||||
|
||||
//设置资源池
|
||||
project.setResourcePoolIds(List.of("resourcePoolId"));
|
||||
project.setName("resourcePool");
|
||||
mvcResult = this.responsePost(addProject, project);
|
||||
result = parseObjectFromMvcResult(mvcResult, ProjectDTO.class);
|
||||
projectExample = new ProjectExample();
|
||||
projectExample.createCriteria().andOrganizationIdEqualTo(project.getOrganizationId()).andNameEqualTo(project.getName());
|
||||
projects = projectMapper.selectByExample(projectExample);
|
||||
assert result != null;
|
||||
projectId = result.getId();
|
||||
// 校验日志
|
||||
checkLog(projectId, OperationLogType.ADD);
|
||||
|
||||
compareProjectDTO(projects.get(0), result);
|
||||
//校验资源池
|
||||
ProjectTestResourcePoolExample projectTestResourcePoolExample = new ProjectTestResourcePoolExample();
|
||||
projectTestResourcePoolExample.createCriteria().andProjectIdEqualTo(projectId);
|
||||
List<ProjectTestResourcePool> projectTestResourcePools = projectTestResourcePoolMapper.selectByExample(projectTestResourcePoolExample);
|
||||
Assertions.assertTrue(projectTestResourcePools.stream().map(ProjectTestResourcePool::getTestResourcePoolId).toList().contains("resourcePoolId"));
|
||||
|
||||
|
||||
project.setName("testAddProjectSuccess1");
|
||||
// @@校验权限
|
||||
|
@ -269,6 +298,10 @@ public class SystemProjectControllerTests extends BaseTest {
|
|||
//项目成员在系统中不存在
|
||||
project = this.generatorAdd("organizationId", "name", null, true, List.of("admin", "admin1", "admin3"));
|
||||
this.requestPost(addProject, project, ERROR_REQUEST_MATCHER);
|
||||
//资源池不存在
|
||||
project = this.generatorAdd("organizationId", "pool", null, true, List.of("admin"));
|
||||
project.setResourcePoolIds(List.of("resourcePoolId3"));
|
||||
this.requestPost(addProject, project, ERROR_REQUEST_MATCHER);
|
||||
|
||||
}
|
||||
@Test
|
||||
|
@ -280,14 +313,17 @@ public class SystemProjectControllerTests extends BaseTest {
|
|||
moduleIds.add("uiTest");
|
||||
project.setModuleIds(moduleIds);
|
||||
MvcResult mvcResult = this.responsePost(addProject, project);
|
||||
ProjectExtendDTO result = parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||
ProjectDTO result = parseObjectFromMvcResult(mvcResult, ProjectDTO.class);
|
||||
assert result != null;
|
||||
projectId = result.getId();
|
||||
mvcResult = this.responseGet(getProject + projectId);
|
||||
Project getProjects = parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||
Project getProjects = parseObjectFromMvcResult(mvcResult, ProjectDTO.class);
|
||||
assert getProjects != null;
|
||||
Assertions.assertTrue(StringUtils.equals(getProjects.getId(), projectId));
|
||||
|
||||
mvcResult = this.responseGet(getProject + "projectId");
|
||||
getProjects = parseObjectFromMvcResult(mvcResult, ProjectDTO.class);
|
||||
assert getProjects != null;
|
||||
Assertions.assertTrue(StringUtils.equals(getProjects.getId(), "projectId"));
|
||||
// @@校验权限
|
||||
requestGetPermissionTest(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ, getProject + projectId);
|
||||
}
|
||||
|
@ -296,7 +332,7 @@ public class SystemProjectControllerTests extends BaseTest {
|
|||
public void testGetProjectError() throws Exception {
|
||||
//项目不存在
|
||||
MvcResult mvcResult = this.responseGet(getProject + "111111");
|
||||
ProjectExtendDTO project = parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||
ProjectDTO project = parseObjectFromMvcResult(mvcResult, ProjectDTO.class);
|
||||
Assertions.assertNull(project);
|
||||
}
|
||||
|
||||
|
@ -402,7 +438,7 @@ public class SystemProjectControllerTests extends BaseTest {
|
|||
public void testUpdateProject() throws Exception {
|
||||
UpdateProjectRequest project = this.generatorUpdate("organizationId", "projectId1","TestName", "Edit name", true, List.of("admin", "admin1"));
|
||||
MvcResult mvcResult = this.responsePost(updateProject, project);
|
||||
ProjectExtendDTO result = parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||
ProjectDTO result = parseObjectFromMvcResult(mvcResult, ProjectDTO.class);
|
||||
Project currentProject = projectMapper.selectByPrimaryKey(project.getId());
|
||||
compareProjectDTO(currentProject, result);
|
||||
UserRoleRelationExample userRoleRelationExample = new UserRoleRelationExample();
|
||||
|
@ -418,7 +454,7 @@ public class SystemProjectControllerTests extends BaseTest {
|
|||
Project projectExtend = projectMapper.selectByPrimaryKey("projectId1");
|
||||
projectExtend.setModuleSetting(null);
|
||||
mvcResult = this.responsePost(updateProject, project);
|
||||
result = parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||
result = parseObjectFromMvcResult(mvcResult, ProjectDTO.class);
|
||||
currentProject = projectMapper.selectByPrimaryKey(project.getId());
|
||||
compareProjectDTO(currentProject, result);
|
||||
userRoleRelationExample = new UserRoleRelationExample();
|
||||
|
@ -435,7 +471,7 @@ public class SystemProjectControllerTests extends BaseTest {
|
|||
moduleIds.add("loadTest");
|
||||
project.setModuleIds(moduleIds);
|
||||
mvcResult = this.responsePost(updateProject, project);
|
||||
result = parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||
result = parseObjectFromMvcResult(mvcResult, ProjectDTO.class);
|
||||
currentProject = projectMapper.selectByPrimaryKey(project.getId());
|
||||
compareProjectDTO(currentProject, result);
|
||||
userRoleRelationExample = new UserRoleRelationExample();
|
||||
|
@ -447,6 +483,19 @@ public class SystemProjectControllerTests extends BaseTest {
|
|||
projectExtend = projectMapper.selectByPrimaryKey("projectId1");
|
||||
Assertions.assertEquals(projectExtend.getModuleSetting(), JSON.toJSONString(moduleIds));
|
||||
|
||||
//设置资源池
|
||||
project = this.generatorUpdate("organizationId", "projectId5", "updatePools", "updatePools", true, new ArrayList<>());
|
||||
project.setResourcePoolIds(List.of("resourcePoolId","resourcePoolId1"));
|
||||
mvcResult = this.responsePost(updateProject, project);
|
||||
result = parseObjectFromMvcResult(mvcResult, ProjectDTO.class);
|
||||
currentProject = projectMapper.selectByPrimaryKey(project.getId());
|
||||
compareProjectDTO(currentProject, result);
|
||||
//校验资源池
|
||||
ProjectTestResourcePoolExample projectTestResourcePoolExample = new ProjectTestResourcePoolExample();
|
||||
projectTestResourcePoolExample.createCriteria().andProjectIdEqualTo("projectId5");
|
||||
List<ProjectTestResourcePool> projectTestResourcePools = projectTestResourcePoolMapper.selectByExample(projectTestResourcePoolExample);
|
||||
Assertions.assertTrue(projectTestResourcePools.stream().map(ProjectTestResourcePool::getTestResourcePoolId).toList().containsAll(project.getResourcePoolIds()));
|
||||
|
||||
|
||||
// @@校验权限
|
||||
project.setName("TestName2");
|
||||
|
@ -471,6 +520,10 @@ public class SystemProjectControllerTests extends BaseTest {
|
|||
//项目不存在
|
||||
project = this.generatorUpdate("organizationId", "1111","123", null, true, List.of("admin"));
|
||||
this.requestPost(updateProject, project, ERROR_REQUEST_MATCHER);
|
||||
//资源池不存在
|
||||
project = this.generatorUpdate("organizationId", "projectId2","pool-edit", "description", true, List.of("admin"));
|
||||
project.setResourcePoolIds(List.of("resourcePoolId3"));
|
||||
this.requestPost(updateProject, project, ERROR_REQUEST_MATCHER);
|
||||
|
||||
}
|
||||
|
||||
|
@ -710,4 +763,12 @@ public class SystemProjectControllerTests extends BaseTest {
|
|||
// @@校验权限
|
||||
requestGetPermissionTest(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ, userList + "?keyword=" + keyword);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(22)
|
||||
public void testGetOptions() throws Exception {
|
||||
this.requestGetWithOkAndReturn(getPoolOptions + "organizationId");
|
||||
// @@校验权限
|
||||
requestGetPermissionTest(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ, getPoolOptions + "organizationId");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,3 +31,14 @@ replace INTO user_role_relation (id, user_id, role_id, source_id, organization_i
|
|||
replace INTO user_role_relation (id, user_id, role_id, source_id, organization_id, create_time, create_user )VALUES ('c3bb9b4f-46d8-4952-9681-3124121332','admin1','org_member', (SELECT id FROM organization WHERE name LIKE '默认组织'), (SELECT id FROM organization WHERE name LIKE '默认组织'), '1684747668321','admin');
|
||||
INSERT INTO organization(id,num, name, description, create_time, update_time, create_user, update_user, delete_user, delete_time) VALUE
|
||||
('default-organization-20',null, 'default-20', 'XXX-1', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, 'admin', 'admin', null, null);
|
||||
|
||||
replace into test_resource_pool(id, name, type, description, enable, create_time, update_time, create_user, api_test,
|
||||
load_test, ui_test, server_url, all_org, deleted)
|
||||
values ('resourcePoolId', 'resourcePoolName', 'node', 'resourcePoolDescription', 1, unix_timestamp() * 1000,
|
||||
unix_timestamp() * 1000, 'admin', 1, 1, 1, 'http://localhost:8080', 1, 0);
|
||||
replace into test_resource_pool(id, name, type, description, enable, create_time, update_time, create_user, api_test,
|
||||
load_test, ui_test, server_url, all_org, deleted)
|
||||
values ('resourcePoolId1', 'resourcePoolName1', 'node', 'resourcePoolDescription', 1, unix_timestamp() * 1000,
|
||||
unix_timestamp() * 1000, 'admin', 1, 1, 1, 'http://localhost:8080', 1, 0);
|
||||
replace into project_test_resource_pool(project_id, test_resource_pool_id) value ('projectId', 'resourcePoolId');
|
||||
replace into project_test_resource_pool(project_id, test_resource_pool_id) value ('projectId', 'resourcePoolId1');
|
|
@ -1,21 +1,44 @@
|
|||
# 插入测试数据
|
||||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time,module_setting) VALUES ('projectId', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目', '系统默认创建的项目', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000, '["apiTest","uiTest"]');
|
||||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time, enable,module_setting) VALUES ('projectId', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目', '系统默认创建的项目', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000,1, '["apiTest","uiTest"]');
|
||||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time,enable) VALUES ('projectId1', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目1', '系统默认创建的项目', 'test', 'test', unix_timestamp() * 1000, unix_timestamp() * 1000,1);
|
||||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time,update_time,enable ) VALUES ('projectId2', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目2', '系统默认创建的项目', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000,1);
|
||||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time,update_time,enable, module_setting) VALUES ('projectId3', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目3', '系统默认创建的项目', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000,1,'["apiTest","uiTest"]');
|
||||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time,update_time,enable, module_setting) VALUES ('projectId4', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目4', '系统默认创建的项目', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000,1,'["apiTest","uiTest","loadTest"]');
|
||||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time,update_time,enable,module_setting) VALUES ('projectId5', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目5', '系统默认创建的项目', 'test', 'test', unix_timestamp() * 1000, unix_timestamp() * 1000,1,'["apiTest","uiTest"]');
|
||||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time,
|
||||
module_setting)
|
||||
VALUES ('projectId', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目', '系统默认创建的项目',
|
||||
'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000, '["apiTest","uiTest"]');
|
||||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time,
|
||||
enable, module_setting)
|
||||
VALUES ('projectId', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目', '系统默认创建的项目',
|
||||
'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000, 1, '["apiTest","uiTest"]');
|
||||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time,
|
||||
enable)
|
||||
VALUES ('projectId1', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目1', '系统默认创建的项目',
|
||||
'test', 'test', unix_timestamp() * 1000, unix_timestamp() * 1000, 1);
|
||||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time,
|
||||
enable)
|
||||
VALUES ('projectId2', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目2', '系统默认创建的项目',
|
||||
'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000, 1);
|
||||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time,
|
||||
enable, module_setting)
|
||||
VALUES ('projectId3', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目3', '系统默认创建的项目',
|
||||
'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000, 1, '["apiTest","uiTest"]');
|
||||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time,
|
||||
enable, module_setting)
|
||||
VALUES ('projectId4', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目4', '系统默认创建的项目',
|
||||
'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000, 1, '["apiTest","uiTest","loadTest"]');
|
||||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time,
|
||||
enable, module_setting)
|
||||
VALUES ('projectId5', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目5', '系统默认创建的项目',
|
||||
'test', 'test', unix_timestamp() * 1000, unix_timestamp() * 1000, 1, '["apiTest","uiTest"]');
|
||||
|
||||
replace INTO organization(id,num, name, description, create_time, update_time, create_user, update_user, delete_user, delete_time) VALUE
|
||||
('organizationId',null, 'test-org', 'project', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, 'admin', 'admin', null, null);
|
||||
replace INTO organization(id, num, name, description, create_time, update_time, create_user, update_user, delete_user,
|
||||
delete_time) VALUE
|
||||
('organizationId', null, 'test-org', 'project', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, 'admin', 'admin',
|
||||
null, null);
|
||||
|
||||
replace into user(id, name, email, password, create_time, update_time, language, last_organization_id, phone, source,
|
||||
last_project_id, create_user, update_user)
|
||||
VALUES ('admin1', 'test1', 'admin1@metersphere.io', MD5('admin1@metersphere.io'),
|
||||
UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, NULL, NUll, '', 'LOCAL', 'projectId1', 'admin', 'admin');
|
||||
replace
|
||||
into user(id, name, email, password, create_time, update_time, language, last_organization_id, phone, source,
|
||||
into user(id, name, email, password, create_time, update_time, language, last_organization_id, phone, source,
|
||||
last_project_id, create_user, update_user)
|
||||
VALUES ('admin2', 'test2', 'admin2@metersphere.io', MD5('admin2@metersphere.io'),
|
||||
UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, NULL, NUll, '', 'LOCAL', NULL, 'admin', 'admin');
|
||||
|
@ -25,8 +48,21 @@ VALUES ('test', 'test', 'admin3@metersphere.io', MD5('admin2@metersphere.io'),
|
|||
UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, NULL, NUll, '', 'LOCAL', NULL, 'admin', 'admin');
|
||||
|
||||
replace
|
||||
INTO user_role_relation(id, user_id, role_id, source_id, organization_id, create_time, create_user)
|
||||
VALUES ('c3bb9b4f-46d8-4952-9681-8889974487w','admin1','project_admin','projectId1', (SELECT id FROM organization WHERE name LIKE '默认组织'), '1684747668375','1684747668375');
|
||||
INTO user_role_relation(id, user_id, role_id, source_id, organization_id, create_time, create_user)
|
||||
VALUES ('c3bb9b4f-46d8-4952-9681-8889974487w', 'admin1', 'project_admin', 'projectId1',
|
||||
(SELECT id FROM organization WHERE name LIKE '默认组织'), '1684747668375', '1684747668375');
|
||||
replace
|
||||
INTO user_role_relation(id, user_id, role_id, source_id, organization_id, create_time, create_user)
|
||||
VALUES ('c3bb9b4f-46d8-4952-9681-8889974487q','admin2','project_admin','projectId1', (SELECT id FROM organization WHERE name LIKE '默认组织'), '1684747668321','1684747668336');
|
||||
INTO user_role_relation(id, user_id, role_id, source_id, organization_id, create_time, create_user)
|
||||
VALUES ('c3bb9b4f-46d8-4952-9681-8889974487q', 'admin2', 'project_admin', 'projectId1',
|
||||
(SELECT id FROM organization WHERE name LIKE '默认组织'), '1684747668321', '1684747668336');
|
||||
|
||||
replace into test_resource_pool(id, name, type, description, enable, create_time, update_time, create_user, api_test,
|
||||
load_test, ui_test, server_url, all_org, deleted)
|
||||
values ('resourcePoolId', 'resourcePoolName', 'node', 'resourcePoolDescription', 1, unix_timestamp() * 1000,
|
||||
unix_timestamp() * 1000, 'admin', 1, 1, 1, 'http://localhost:8080', 1, 0);
|
||||
replace into test_resource_pool(id, name, type, description, enable, create_time, update_time, create_user, api_test,
|
||||
load_test, ui_test, server_url, all_org, deleted)
|
||||
values ('resourcePoolId1', 'resourcePoolName1', 'node', 'resourcePoolDescription', 1, unix_timestamp() * 1000,
|
||||
unix_timestamp() * 1000, 'admin', 1, 1, 1, 'http://localhost:8080', 1, 0);
|
||||
replace into project_test_resource_pool(project_id, test_resource_pool_id) value ('projectId', 'resourcePoolId');
|
||||
replace into project_test_resource_pool(project_id, test_resource_pool_id) value ('projectId', 'resourcePoolId1');
|
Loading…
Reference in New Issue