diff --git a/backend/framework/domain/src/main/java/io/metersphere/system/domain/UserInvite.java b/backend/framework/domain/src/main/java/io/metersphere/system/domain/UserInvite.java new file mode 100644 index 0000000000..6aff351c94 --- /dev/null +++ b/backend/framework/domain/src/main/java/io/metersphere/system/domain/UserInvite.java @@ -0,0 +1,111 @@ +package io.metersphere.system.domain; + +import io.metersphere.validation.groups.*; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.*; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Arrays; +import lombok.Data; + +@Data +public class UserInvite implements Serializable { + @Schema(title = "用户ID", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{user_invite.id.not_blank}", groups = {Updated.class}) + @Size(min = 1, max = 50, message = "{user_invite.id.length_range}", groups = {Created.class, Updated.class}) + private String id; + + @Schema(title = "邀请邮箱", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{user_invite.email.not_blank}", groups = {Created.class}) + @Size(min = 1, max = 255, message = "{user_invite.email.length_range}", groups = {Created.class, Updated.class}) + private String email; + + @Schema(title = "邀请用户", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{user_invite.invite_user.not_blank}", groups = {Created.class}) + @Size(min = 1, max = 50, message = "{user_invite.invite_user.length_range}", groups = {Created.class, Updated.class}) + private String inviteUser; + + @Schema(title = "邀请时间", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "{user_invite.invite_time.not_blank}", groups = {Created.class}) + private Long inviteTime; + + @Schema(title = "所属权限") + private String roles; + + private static final long serialVersionUID = 1L; + + public enum Column { + id("id", "id", "VARCHAR", false), + email("email", "email", "VARCHAR", false), + inviteUser("invite_user", "inviteUser", "VARCHAR", false), + inviteTime("invite_time", "inviteTime", "BIGINT", false), + roles("roles", "roles", "LONGVARCHAR", 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 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(); + } + } +} \ No newline at end of file diff --git a/backend/framework/domain/src/main/java/io/metersphere/system/domain/UserInviteExample.java b/backend/framework/domain/src/main/java/io/metersphere/system/domain/UserInviteExample.java new file mode 100644 index 0000000000..1586fe1ee8 --- /dev/null +++ b/backend/framework/domain/src/main/java/io/metersphere/system/domain/UserInviteExample.java @@ -0,0 +1,470 @@ +package io.metersphere.system.domain; + +import java.util.ArrayList; +import java.util.List; + +public class UserInviteExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + public UserInviteExample() { + oredCriteria = new ArrayList(); + } + + 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 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 criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andIdIsNull() { + addCriterion("id is null"); + return (Criteria) this; + } + + public Criteria andIdIsNotNull() { + addCriterion("id is not null"); + return (Criteria) this; + } + + public Criteria andIdEqualTo(String value) { + addCriterion("id =", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotEqualTo(String value) { + addCriterion("id <>", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThan(String value) { + addCriterion("id >", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThanOrEqualTo(String value) { + addCriterion("id >=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThan(String value) { + addCriterion("id <", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThanOrEqualTo(String value) { + addCriterion("id <=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLike(String value) { + addCriterion("id like", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotLike(String value) { + addCriterion("id not like", value, "id"); + return (Criteria) this; + } + + public Criteria andIdIn(List values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List values) { + addCriterion("id not in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdBetween(String value1, String value2) { + addCriterion("id between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andIdNotBetween(String value1, String value2) { + addCriterion("id not between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andEmailIsNull() { + addCriterion("email is null"); + return (Criteria) this; + } + + public Criteria andEmailIsNotNull() { + addCriterion("email is not null"); + return (Criteria) this; + } + + public Criteria andEmailEqualTo(String value) { + addCriterion("email =", value, "email"); + return (Criteria) this; + } + + public Criteria andEmailNotEqualTo(String value) { + addCriterion("email <>", value, "email"); + return (Criteria) this; + } + + public Criteria andEmailGreaterThan(String value) { + addCriterion("email >", value, "email"); + return (Criteria) this; + } + + public Criteria andEmailGreaterThanOrEqualTo(String value) { + addCriterion("email >=", value, "email"); + return (Criteria) this; + } + + public Criteria andEmailLessThan(String value) { + addCriterion("email <", value, "email"); + return (Criteria) this; + } + + public Criteria andEmailLessThanOrEqualTo(String value) { + addCriterion("email <=", value, "email"); + return (Criteria) this; + } + + public Criteria andEmailLike(String value) { + addCriterion("email like", value, "email"); + return (Criteria) this; + } + + public Criteria andEmailNotLike(String value) { + addCriterion("email not like", value, "email"); + return (Criteria) this; + } + + public Criteria andEmailIn(List values) { + addCriterion("email in", values, "email"); + return (Criteria) this; + } + + public Criteria andEmailNotIn(List values) { + addCriterion("email not in", values, "email"); + return (Criteria) this; + } + + public Criteria andEmailBetween(String value1, String value2) { + addCriterion("email between", value1, value2, "email"); + return (Criteria) this; + } + + public Criteria andEmailNotBetween(String value1, String value2) { + addCriterion("email not between", value1, value2, "email"); + return (Criteria) this; + } + + public Criteria andInviteUserIsNull() { + addCriterion("invite_user is null"); + return (Criteria) this; + } + + public Criteria andInviteUserIsNotNull() { + addCriterion("invite_user is not null"); + return (Criteria) this; + } + + public Criteria andInviteUserEqualTo(String value) { + addCriterion("invite_user =", value, "inviteUser"); + return (Criteria) this; + } + + public Criteria andInviteUserNotEqualTo(String value) { + addCriterion("invite_user <>", value, "inviteUser"); + return (Criteria) this; + } + + public Criteria andInviteUserGreaterThan(String value) { + addCriterion("invite_user >", value, "inviteUser"); + return (Criteria) this; + } + + public Criteria andInviteUserGreaterThanOrEqualTo(String value) { + addCriterion("invite_user >=", value, "inviteUser"); + return (Criteria) this; + } + + public Criteria andInviteUserLessThan(String value) { + addCriterion("invite_user <", value, "inviteUser"); + return (Criteria) this; + } + + public Criteria andInviteUserLessThanOrEqualTo(String value) { + addCriterion("invite_user <=", value, "inviteUser"); + return (Criteria) this; + } + + public Criteria andInviteUserLike(String value) { + addCriterion("invite_user like", value, "inviteUser"); + return (Criteria) this; + } + + public Criteria andInviteUserNotLike(String value) { + addCriterion("invite_user not like", value, "inviteUser"); + return (Criteria) this; + } + + public Criteria andInviteUserIn(List values) { + addCriterion("invite_user in", values, "inviteUser"); + return (Criteria) this; + } + + public Criteria andInviteUserNotIn(List values) { + addCriterion("invite_user not in", values, "inviteUser"); + return (Criteria) this; + } + + public Criteria andInviteUserBetween(String value1, String value2) { + addCriterion("invite_user between", value1, value2, "inviteUser"); + return (Criteria) this; + } + + public Criteria andInviteUserNotBetween(String value1, String value2) { + addCriterion("invite_user not between", value1, value2, "inviteUser"); + return (Criteria) this; + } + + public Criteria andInviteTimeIsNull() { + addCriterion("invite_time is null"); + return (Criteria) this; + } + + public Criteria andInviteTimeIsNotNull() { + addCriterion("invite_time is not null"); + return (Criteria) this; + } + + public Criteria andInviteTimeEqualTo(Long value) { + addCriterion("invite_time =", value, "inviteTime"); + return (Criteria) this; + } + + public Criteria andInviteTimeNotEqualTo(Long value) { + addCriterion("invite_time <>", value, "inviteTime"); + return (Criteria) this; + } + + public Criteria andInviteTimeGreaterThan(Long value) { + addCriterion("invite_time >", value, "inviteTime"); + return (Criteria) this; + } + + public Criteria andInviteTimeGreaterThanOrEqualTo(Long value) { + addCriterion("invite_time >=", value, "inviteTime"); + return (Criteria) this; + } + + public Criteria andInviteTimeLessThan(Long value) { + addCriterion("invite_time <", value, "inviteTime"); + return (Criteria) this; + } + + public Criteria andInviteTimeLessThanOrEqualTo(Long value) { + addCriterion("invite_time <=", value, "inviteTime"); + return (Criteria) this; + } + + public Criteria andInviteTimeIn(List values) { + addCriterion("invite_time in", values, "inviteTime"); + return (Criteria) this; + } + + public Criteria andInviteTimeNotIn(List values) { + addCriterion("invite_time not in", values, "inviteTime"); + return (Criteria) this; + } + + public Criteria andInviteTimeBetween(Long value1, Long value2) { + addCriterion("invite_time between", value1, value2, "inviteTime"); + return (Criteria) this; + } + + public Criteria andInviteTimeNotBetween(Long value1, Long value2) { + addCriterion("invite_time not between", value1, value2, "inviteTime"); + 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); + } + } +} \ No newline at end of file diff --git a/backend/framework/domain/src/main/java/io/metersphere/system/mapper/UserInviteMapper.java b/backend/framework/domain/src/main/java/io/metersphere/system/mapper/UserInviteMapper.java new file mode 100644 index 0000000000..9b682fb9cf --- /dev/null +++ b/backend/framework/domain/src/main/java/io/metersphere/system/mapper/UserInviteMapper.java @@ -0,0 +1,40 @@ +package io.metersphere.system.mapper; + +import io.metersphere.system.domain.UserInvite; +import io.metersphere.system.domain.UserInviteExample; +import java.util.List; +import org.apache.ibatis.annotations.Param; + +public interface UserInviteMapper { + long countByExample(UserInviteExample example); + + int deleteByExample(UserInviteExample example); + + int deleteByPrimaryKey(String id); + + int insert(UserInvite record); + + int insertSelective(UserInvite record); + + List selectByExampleWithBLOBs(UserInviteExample example); + + List selectByExample(UserInviteExample example); + + UserInvite selectByPrimaryKey(String id); + + int updateByExampleSelective(@Param("record") UserInvite record, @Param("example") UserInviteExample example); + + int updateByExampleWithBLOBs(@Param("record") UserInvite record, @Param("example") UserInviteExample example); + + int updateByExample(@Param("record") UserInvite record, @Param("example") UserInviteExample example); + + int updateByPrimaryKeySelective(UserInvite record); + + int updateByPrimaryKeyWithBLOBs(UserInvite record); + + int updateByPrimaryKey(UserInvite record); + + int batchInsert(@Param("list") List list); + + int batchInsertSelective(@Param("list") List list, @Param("selective") UserInvite.Column ... selective); +} \ No newline at end of file diff --git a/backend/framework/domain/src/main/java/io/metersphere/system/mapper/UserInviteMapper.xml b/backend/framework/domain/src/main/java/io/metersphere/system/mapper/UserInviteMapper.xml new file mode 100644 index 0000000000..02994c94cf --- /dev/null +++ b/backend/framework/domain/src/main/java/io/metersphere/system/mapper/UserInviteMapper.xml @@ -0,0 +1,289 @@ + + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + id, email, invite_user, invite_time + + + roles + + + + + + delete from user_invite + where id = #{id,jdbcType=VARCHAR} + + + delete from user_invite + + + + + + insert into user_invite (id, email, invite_user, + invite_time, roles) + values (#{id,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, #{inviteUser,jdbcType=VARCHAR}, + #{inviteTime,jdbcType=BIGINT}, #{roles,jdbcType=LONGVARCHAR}) + + + insert into user_invite + + + id, + + + email, + + + invite_user, + + + invite_time, + + + roles, + + + + + #{id,jdbcType=VARCHAR}, + + + #{email,jdbcType=VARCHAR}, + + + #{inviteUser,jdbcType=VARCHAR}, + + + #{inviteTime,jdbcType=BIGINT}, + + + #{roles,jdbcType=LONGVARCHAR}, + + + + + + update user_invite + + + id = #{record.id,jdbcType=VARCHAR}, + + + email = #{record.email,jdbcType=VARCHAR}, + + + invite_user = #{record.inviteUser,jdbcType=VARCHAR}, + + + invite_time = #{record.inviteTime,jdbcType=BIGINT}, + + + roles = #{record.roles,jdbcType=LONGVARCHAR}, + + + + + + + + update user_invite + set id = #{record.id,jdbcType=VARCHAR}, + email = #{record.email,jdbcType=VARCHAR}, + invite_user = #{record.inviteUser,jdbcType=VARCHAR}, + invite_time = #{record.inviteTime,jdbcType=BIGINT}, + roles = #{record.roles,jdbcType=LONGVARCHAR} + + + + + + update user_invite + set id = #{record.id,jdbcType=VARCHAR}, + email = #{record.email,jdbcType=VARCHAR}, + invite_user = #{record.inviteUser,jdbcType=VARCHAR}, + invite_time = #{record.inviteTime,jdbcType=BIGINT} + + + + + + update user_invite + + + email = #{email,jdbcType=VARCHAR}, + + + invite_user = #{inviteUser,jdbcType=VARCHAR}, + + + invite_time = #{inviteTime,jdbcType=BIGINT}, + + + roles = #{roles,jdbcType=LONGVARCHAR}, + + + where id = #{id,jdbcType=VARCHAR} + + + update user_invite + set email = #{email,jdbcType=VARCHAR}, + invite_user = #{inviteUser,jdbcType=VARCHAR}, + invite_time = #{inviteTime,jdbcType=BIGINT}, + roles = #{roles,jdbcType=LONGVARCHAR} + where id = #{id,jdbcType=VARCHAR} + + + update user_invite + set email = #{email,jdbcType=VARCHAR}, + invite_user = #{inviteUser,jdbcType=VARCHAR}, + invite_time = #{inviteTime,jdbcType=BIGINT} + where id = #{id,jdbcType=VARCHAR} + + + insert into user_invite + (id, email, invite_user, invite_time, roles) + values + + (#{item.id,jdbcType=VARCHAR}, #{item.email,jdbcType=VARCHAR}, #{item.inviteUser,jdbcType=VARCHAR}, + #{item.inviteTime,jdbcType=BIGINT}, #{item.roles,jdbcType=LONGVARCHAR}) + + + + insert into user_invite ( + + ${column.escapedColumnName} + + ) + values + + ( + + + #{item.id,jdbcType=VARCHAR} + + + #{item.email,jdbcType=VARCHAR} + + + #{item.inviteUser,jdbcType=VARCHAR} + + + #{item.inviteTime,jdbcType=BIGINT} + + + #{item.roles,jdbcType=LONGVARCHAR} + + + ) + + + \ No newline at end of file diff --git a/backend/framework/domain/src/main/resources/migration/3.0.0/ddl/V3.0.0_11__system_setting.sql b/backend/framework/domain/src/main/resources/migration/3.0.0/ddl/V3.0.0_11__system_setting.sql index b17864b0fe..61386fd00c 100644 --- a/backend/framework/domain/src/main/resources/migration/3.0.0/ddl/V3.0.0_11__system_setting.sql +++ b/backend/framework/domain/src/main/resources/migration/3.0.0/ddl/V3.0.0_11__system_setting.sql @@ -341,3 +341,16 @@ CREATE INDEX idx_org_id ON test_resource_pool_organization(`org_id`); -- set innodb lock wait timeout to default SET SESSION innodb_lock_wait_timeout = DEFAULT; + +-- 用户邀请记录 +CREATE TABLE IF NOT EXISTS user_invite +( + `id` VARCHAR(50) NOT NULL COMMENT '用户ID', + `email` VARCHAR(255) NOT NULL COMMENT '邀请邮箱', + `roles` TEXT COMMENT '所属权限', + `invite_user` VARCHAR(50) NOT NULL COMMENT '邀请用户', + `invite_time` BIGINT NOT NULL COMMENT '邀请时间', + PRIMARY KEY (id) +) ENGINE = InnoDB + DEFAULT CHARSET = utf8mb4 + COLLATE = utf8mb4_general_ci COMMENT = '用户邀请记录'; diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/TableBatchProcessDTO.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/TableBatchProcessDTO.java index 57609e7814..0a08c6dc3a 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/TableBatchProcessDTO.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/TableBatchProcessDTO.java @@ -11,16 +11,15 @@ import java.util.List; @Data public class TableBatchProcessDTO { - @Schema(description = "用户ID", requiredMode = Schema.RequiredMode.REQUIRED) + @Schema(description = "不处理的ID") + List excludeIds; + @Schema(description = "选择的ID", requiredMode = Schema.RequiredMode.REQUIRED) @Valid private List< @NotBlank(message = "{id must not be blank}", groups = {Created.class, Updated.class}) String > selectIds; - @Schema(description = "不处理的用户ID") - List excludeIds; - @Schema(description = "是否选择所有数据") private boolean selectAll; diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/mapper/BaseUserMapper.xml b/backend/framework/sdk/src/main/java/io/metersphere/sdk/mapper/BaseUserMapper.xml index f5bb7e4bf8..af481095db 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/mapper/BaseUserMapper.xml +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/mapper/BaseUserMapper.xml @@ -73,8 +73,12 @@ FROM user WHERE DELETED = 0 - AND name LIKE CONCAT('%', #{keyword}, '%') - OR email LIKE CONCAT('%', #{keyword}, '%') + AND ( + id = #{keyword} OR + (name LIKE CONCAT('%', #{keyword}, '%') + OR email LIKE CONCAT('%', #{keyword}, '%')) + ) +