ci: 删除部分代码
This commit is contained in:
parent
7adf0a87b9
commit
965364c2fc
|
@ -30,7 +30,7 @@ public class UserKey implements Serializable {
|
||||||
private Long createTime;
|
private Long createTime;
|
||||||
|
|
||||||
@Schema(title = "状态")
|
@Schema(title = "状态")
|
||||||
private String status;
|
private Boolean enable;
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
}
|
}
|
|
@ -444,73 +444,63 @@ public class UserKeyExample {
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Criteria andStatusIsNull() {
|
public Criteria andEnableIsNull() {
|
||||||
addCriterion("`status` is null");
|
addCriterion("`enable` is null");
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Criteria andStatusIsNotNull() {
|
public Criteria andEnableIsNotNull() {
|
||||||
addCriterion("`status` is not null");
|
addCriterion("`enable` is not null");
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Criteria andStatusEqualTo(String value) {
|
public Criteria andEnableEqualTo(Boolean value) {
|
||||||
addCriterion("`status` =", value, "status");
|
addCriterion("`enable` =", value, "enable");
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Criteria andStatusNotEqualTo(String value) {
|
public Criteria andEnableNotEqualTo(Boolean value) {
|
||||||
addCriterion("`status` <>", value, "status");
|
addCriterion("`enable` <>", value, "enable");
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Criteria andStatusGreaterThan(String value) {
|
public Criteria andEnableGreaterThan(Boolean value) {
|
||||||
addCriterion("`status` >", value, "status");
|
addCriterion("`enable` >", value, "enable");
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Criteria andStatusGreaterThanOrEqualTo(String value) {
|
public Criteria andEnableGreaterThanOrEqualTo(Boolean value) {
|
||||||
addCriterion("`status` >=", value, "status");
|
addCriterion("`enable` >=", value, "enable");
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Criteria andStatusLessThan(String value) {
|
public Criteria andEnableLessThan(Boolean value) {
|
||||||
addCriterion("`status` <", value, "status");
|
addCriterion("`enable` <", value, "enable");
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Criteria andStatusLessThanOrEqualTo(String value) {
|
public Criteria andEnableLessThanOrEqualTo(Boolean value) {
|
||||||
addCriterion("`status` <=", value, "status");
|
addCriterion("`enable` <=", value, "enable");
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Criteria andStatusLike(String value) {
|
public Criteria andEnableIn(List<Boolean> values) {
|
||||||
addCriterion("`status` like", value, "status");
|
addCriterion("`enable` in", values, "enable");
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Criteria andStatusNotLike(String value) {
|
public Criteria andEnableNotIn(List<Boolean> values) {
|
||||||
addCriterion("`status` not like", value, "status");
|
addCriterion("`enable` not in", values, "enable");
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Criteria andStatusIn(List<String> values) {
|
public Criteria andEnableBetween(Boolean value1, Boolean value2) {
|
||||||
addCriterion("`status` in", values, "status");
|
addCriterion("`enable` between", value1, value2, "enable");
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Criteria andStatusNotIn(List<String> values) {
|
public Criteria andEnableNotBetween(Boolean value1, Boolean value2) {
|
||||||
addCriterion("`status` not in", values, "status");
|
addCriterion("`enable` not between", value1, value2, "enable");
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andStatusBetween(String value1, String value2) {
|
|
||||||
addCriterion("`status` between", value1, value2, "status");
|
|
||||||
return (Criteria) this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Criteria andStatusNotBetween(String value1, String value2) {
|
|
||||||
addCriterion("`status` not between", value1, value2, "status");
|
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<result column="access_key" jdbcType="VARCHAR" property="accessKey" />
|
<result column="access_key" jdbcType="VARCHAR" property="accessKey" />
|
||||||
<result column="secret_key" jdbcType="VARCHAR" property="secretKey" />
|
<result column="secret_key" jdbcType="VARCHAR" property="secretKey" />
|
||||||
<result column="create_time" jdbcType="BIGINT" property="createTime" />
|
<result column="create_time" jdbcType="BIGINT" property="createTime" />
|
||||||
<result column="status" jdbcType="VARCHAR" property="status" />
|
<result column="enable" jdbcType="BIT" property="enable" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
<sql id="Example_Where_Clause">
|
<sql id="Example_Where_Clause">
|
||||||
<where>
|
<where>
|
||||||
|
@ -68,7 +68,7 @@
|
||||||
</where>
|
</where>
|
||||||
</sql>
|
</sql>
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
id, create_user, access_key, secret_key, create_time, `status`
|
id, create_user, access_key, secret_key, create_time, `enable`
|
||||||
</sql>
|
</sql>
|
||||||
<select id="selectByExample" parameterType="io.metersphere.system.domain.UserKeyExample" resultMap="BaseResultMap">
|
<select id="selectByExample" parameterType="io.metersphere.system.domain.UserKeyExample" resultMap="BaseResultMap">
|
||||||
select
|
select
|
||||||
|
@ -102,10 +102,10 @@
|
||||||
</delete>
|
</delete>
|
||||||
<insert id="insert" parameterType="io.metersphere.system.domain.UserKey">
|
<insert id="insert" parameterType="io.metersphere.system.domain.UserKey">
|
||||||
insert into user_key (id, create_user, access_key,
|
insert into user_key (id, create_user, access_key,
|
||||||
secret_key, create_time, `status`
|
secret_key, create_time, `enable`
|
||||||
)
|
)
|
||||||
values (#{id,jdbcType=VARCHAR}, #{createUser,jdbcType=VARCHAR}, #{accessKey,jdbcType=VARCHAR},
|
values (#{id,jdbcType=VARCHAR}, #{createUser,jdbcType=VARCHAR}, #{accessKey,jdbcType=VARCHAR},
|
||||||
#{secretKey,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{status,jdbcType=VARCHAR}
|
#{secretKey,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{enable,jdbcType=BIT}
|
||||||
)
|
)
|
||||||
</insert>
|
</insert>
|
||||||
<insert id="insertSelective" parameterType="io.metersphere.system.domain.UserKey">
|
<insert id="insertSelective" parameterType="io.metersphere.system.domain.UserKey">
|
||||||
|
@ -126,8 +126,8 @@
|
||||||
<if test="createTime != null">
|
<if test="createTime != null">
|
||||||
create_time,
|
create_time,
|
||||||
</if>
|
</if>
|
||||||
<if test="status != null">
|
<if test="enable != null">
|
||||||
`status`,
|
`enable`,
|
||||||
</if>
|
</if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
@ -146,8 +146,8 @@
|
||||||
<if test="createTime != null">
|
<if test="createTime != null">
|
||||||
#{createTime,jdbcType=BIGINT},
|
#{createTime,jdbcType=BIGINT},
|
||||||
</if>
|
</if>
|
||||||
<if test="status != null">
|
<if test="enable != null">
|
||||||
#{status,jdbcType=VARCHAR},
|
#{enable,jdbcType=BIT},
|
||||||
</if>
|
</if>
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
|
@ -175,8 +175,8 @@
|
||||||
<if test="record.createTime != null">
|
<if test="record.createTime != null">
|
||||||
create_time = #{record.createTime,jdbcType=BIGINT},
|
create_time = #{record.createTime,jdbcType=BIGINT},
|
||||||
</if>
|
</if>
|
||||||
<if test="record.status != null">
|
<if test="record.enable != null">
|
||||||
`status` = #{record.status,jdbcType=VARCHAR},
|
`enable` = #{record.enable,jdbcType=BIT},
|
||||||
</if>
|
</if>
|
||||||
</set>
|
</set>
|
||||||
<if test="_parameter != null">
|
<if test="_parameter != null">
|
||||||
|
@ -190,7 +190,7 @@
|
||||||
access_key = #{record.accessKey,jdbcType=VARCHAR},
|
access_key = #{record.accessKey,jdbcType=VARCHAR},
|
||||||
secret_key = #{record.secretKey,jdbcType=VARCHAR},
|
secret_key = #{record.secretKey,jdbcType=VARCHAR},
|
||||||
create_time = #{record.createTime,jdbcType=BIGINT},
|
create_time = #{record.createTime,jdbcType=BIGINT},
|
||||||
`status` = #{record.status,jdbcType=VARCHAR}
|
`enable` = #{record.enable,jdbcType=BIT}
|
||||||
<if test="_parameter != null">
|
<if test="_parameter != null">
|
||||||
<include refid="Update_By_Example_Where_Clause" />
|
<include refid="Update_By_Example_Where_Clause" />
|
||||||
</if>
|
</if>
|
||||||
|
@ -210,8 +210,8 @@
|
||||||
<if test="createTime != null">
|
<if test="createTime != null">
|
||||||
create_time = #{createTime,jdbcType=BIGINT},
|
create_time = #{createTime,jdbcType=BIGINT},
|
||||||
</if>
|
</if>
|
||||||
<if test="status != null">
|
<if test="enable != null">
|
||||||
`status` = #{status,jdbcType=VARCHAR},
|
`enable` = #{enable,jdbcType=BIT},
|
||||||
</if>
|
</if>
|
||||||
</set>
|
</set>
|
||||||
where id = #{id,jdbcType=VARCHAR}
|
where id = #{id,jdbcType=VARCHAR}
|
||||||
|
@ -222,7 +222,7 @@
|
||||||
access_key = #{accessKey,jdbcType=VARCHAR},
|
access_key = #{accessKey,jdbcType=VARCHAR},
|
||||||
secret_key = #{secretKey,jdbcType=VARCHAR},
|
secret_key = #{secretKey,jdbcType=VARCHAR},
|
||||||
create_time = #{createTime,jdbcType=BIGINT},
|
create_time = #{createTime,jdbcType=BIGINT},
|
||||||
`status` = #{status,jdbcType=VARCHAR}
|
`enable` = #{enable,jdbcType=BIT}
|
||||||
where id = #{id,jdbcType=VARCHAR}
|
where id = #{id,jdbcType=VARCHAR}
|
||||||
</update>
|
</update>
|
||||||
</mapper>
|
</mapper>
|
|
@ -121,18 +121,19 @@ CREATE TABLE novice_statistics
|
||||||
COLLATE = utf8mb4_general_ci COMMENT = '新手村';
|
COLLATE = utf8mb4_general_ci COMMENT = '新手村';
|
||||||
|
|
||||||
DROP TABLE IF EXISTS operation_log;
|
DROP TABLE IF EXISTS operation_log;
|
||||||
CREATE TABLE operation_log(
|
CREATE TABLE operation_log
|
||||||
`id` VARCHAR(50) NOT NULL COMMENT '主键' ,
|
(
|
||||||
`project_id` VARCHAR(50) NOT NULL DEFAULT 'NONE' COMMENT '项目id' ,
|
`id` VARCHAR(50) NOT NULL COMMENT '主键',
|
||||||
`create_time` BIGINT NOT NULL COMMENT '操作时间' ,
|
`project_id` VARCHAR(50) NOT NULL DEFAULT 'NONE' COMMENT '项目id',
|
||||||
`create_user` VARCHAR(50) COMMENT '操作人' ,
|
`create_time` BIGINT NOT NULL COMMENT '操作时间',
|
||||||
`source_id` VARCHAR(50) COMMENT '资源id' ,
|
`create_user` VARCHAR(50) COMMENT '操作人',
|
||||||
`method` VARCHAR(255) NOT NULL COMMENT '操作方法' ,
|
`source_id` VARCHAR(50) COMMENT '资源id',
|
||||||
`type` VARCHAR(20) NOT NULL COMMENT '操作类型/add/update/delete' ,
|
`method` VARCHAR(255) NOT NULL COMMENT '操作方法',
|
||||||
`module` VARCHAR(20) COMMENT '操作模块/api/case/scenario/ui' ,
|
`type` VARCHAR(20) NOT NULL COMMENT '操作类型/add/update/delete',
|
||||||
`details` VARCHAR(500) COMMENT '操作详情' ,
|
`module` VARCHAR(50) COMMENT '操作模块/api/case/scenario/ui',
|
||||||
`path` VARCHAR(255) COMMENT '操作路径' ,
|
`details` VARCHAR(500) COMMENT '操作详情',
|
||||||
PRIMARY KEY (id)
|
`path` VARCHAR(255) COMMENT '操作路径',
|
||||||
|
PRIMARY KEY (id)
|
||||||
) ENGINE = InnoDB
|
) ENGINE = InnoDB
|
||||||
DEFAULT CHARSET = utf8mb4
|
DEFAULT CHARSET = utf8mb4
|
||||||
COLLATE = utf8mb4_general_ci COMMENT = '操作日志';
|
COLLATE = utf8mb4_general_ci COMMENT = '操作日志';
|
||||||
|
@ -381,7 +382,7 @@ CREATE TABLE user_key
|
||||||
`access_key` VARCHAR(50) NOT NULL COMMENT 'access_key',
|
`access_key` VARCHAR(50) NOT NULL COMMENT 'access_key',
|
||||||
`secret_key` VARCHAR(50) NOT NULL COMMENT 'secret key',
|
`secret_key` VARCHAR(50) NOT NULL COMMENT 'secret key',
|
||||||
`create_time` BIGINT NOT NULL COMMENT '创建时间',
|
`create_time` BIGINT NOT NULL COMMENT '创建时间',
|
||||||
`status` VARCHAR(10) COMMENT '状态',
|
`enable` BIT COMMENT '状态',
|
||||||
PRIMARY KEY (id)
|
PRIMARY KEY (id)
|
||||||
) ENGINE = InnoDB
|
) ENGINE = InnoDB
|
||||||
DEFAULT CHARSET = utf8mb4
|
DEFAULT CHARSET = utf8mb4
|
||||||
|
|
|
@ -11,7 +11,7 @@ insert into user(id, name, email, password, create_time, update_time, language,
|
||||||
VALUES ('admin', 'Administrator', 'admin@metersphere.io', MD5('metersphere'), UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, NULL, NUll, '', 'LOCAL', NULL, 'admin', 'admin');
|
VALUES ('admin', 'Administrator', 'admin@metersphere.io', MD5('metersphere'), UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, NULL, NUll, '', 'LOCAL', NULL, 'admin', 'admin');
|
||||||
|
|
||||||
-- 初始化用户组
|
-- 初始化用户组
|
||||||
INSERT INTO user_role (id, name, description, internal, type, create_time, update_time, create_user, scope_id) VALUES ('admin', '系统管理员(系统)', '拥有系统全部组织以及项目的操作权限', 1, 'SYSTEM', 1621224000000, 1621224000000, 'admin', 'system');
|
INSERT INTO user_role (id, name, description, internal, type, create_time, update_time, create_user, scope_id) VALUES ('admin', '系统管理员(系统)', '拥有系统全部组织以及项目的操作权限', 1, 'SYSTEM', 1621224000000, 1621224000000, 'admin', 'global');
|
||||||
INSERT INTO user_role (id, name, description, internal, type, create_time, update_time, create_user, scope_id) VALUES ('org_admin', '组织管理员(系统)', '组织管理员', 1, 'ORGANIZATION', 1620674220007, 1620674220000, 'admin', 'global');
|
INSERT INTO user_role (id, name, description, internal, type, create_time, update_time, create_user, scope_id) VALUES ('org_admin', '组织管理员(系统)', '组织管理员', 1, 'ORGANIZATION', 1620674220007, 1620674220000, 'admin', 'global');
|
||||||
INSERT INTO user_role (id, name, description, internal, type, create_time, update_time, create_user, scope_id) VALUES ('org_member', '组织成员(系统)', '组织成员', 1, 'ORGANIZATION', 1620674220008, 1620674220000, 'admin', 'global');
|
INSERT INTO user_role (id, name, description, internal, type, create_time, update_time, create_user, scope_id) VALUES ('org_member', '组织成员(系统)', '组织成员', 1, 'ORGANIZATION', 1620674220008, 1620674220000, 'admin', 'global');
|
||||||
INSERT INTO user_role (id, name, description, internal, type, create_time, update_time, create_user, scope_id) VALUES ('project_admin', '项目管理员(系统)', '项目管理员', 1, 'PROJECT', 1620674220004, 1620674220000, 'admin', 'global');
|
INSERT INTO user_role (id, name, description, internal, type, create_time, update_time, create_user, scope_id) VALUES ('project_admin', '项目管理员(系统)', '项目管理员', 1, 'PROJECT', 1620674220004, 1620674220000, 'admin', 'global');
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
package io.metersphere.sdk.constants;
|
|
||||||
|
|
||||||
public enum ApiKeyConstants {
|
|
||||||
ACTIVE, DISABLED
|
|
||||||
}
|
|
|
@ -11,5 +11,4 @@ public class UserRoleConstants {
|
||||||
public static final String WS_MEMBER = "ws_member";
|
public static final String WS_MEMBER = "ws_member";
|
||||||
public static final String PROJECT_ADMIN = "project_admin";
|
public static final String PROJECT_ADMIN = "project_admin";
|
||||||
public static final String PROJECT_MEMBER = "project_member";
|
public static final String PROJECT_MEMBER = "project_member";
|
||||||
public static final String READ_ONLY = "read_only";
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package io.metersphere.sdk.constants;
|
package io.metersphere.sdk.constants;
|
||||||
|
|
||||||
public class UserRoleType {
|
public enum UserRoleType {
|
||||||
public static final String SYSTEM = "SYSTEM";
|
SYSTEM,
|
||||||
public static final String ORGANIZATION = "ORGANIZATION";
|
ORGANIZATION,
|
||||||
public static final String PROJECT = "PROJECT";
|
PROJECT,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
package io.metersphere.sdk.constants;
|
package io.metersphere.sdk.constants;
|
||||||
|
|
||||||
public enum UserSource {
|
public enum UserSource {
|
||||||
LOCAL, LDAP, CAS, OIDC, OAuth2
|
LOCAL, LDAP, CAS, OIDC, OAUTH2
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
package io.metersphere.sdk.constants;
|
|
||||||
|
|
||||||
public class UserStatus {
|
|
||||||
public static final String NORMAL = "1";
|
|
||||||
public static final String DISABLED = "0";
|
|
||||||
}
|
|
|
@ -123,7 +123,7 @@ public class BaseUserService {
|
||||||
private void checkNewOrganizationAndProject(UserDTO user) {
|
private void checkNewOrganizationAndProject(UserDTO user) {
|
||||||
List<UserRoleRelation> userRoleRelations = user.getUserRoleRelations();
|
List<UserRoleRelation> userRoleRelations = user.getUserRoleRelations();
|
||||||
List<String> projectRoleIds = user.getUserRoles()
|
List<String> projectRoleIds = user.getUserRoles()
|
||||||
.stream().filter(ug -> StringUtils.equals(ug.getType(), UserRoleType.PROJECT))
|
.stream().filter(ug -> StringUtils.equals(ug.getType(), UserRoleType.PROJECT.name()))
|
||||||
.map(UserRole::getId)
|
.map(UserRole::getId)
|
||||||
.toList();
|
.toList();
|
||||||
List<UserRoleRelation> project = userRoleRelations.stream().filter(ug -> projectRoleIds.contains(ug.getRoleId()))
|
List<UserRoleRelation> project = userRoleRelations.stream().filter(ug -> projectRoleIds.contains(ug.getRoleId()))
|
||||||
|
@ -131,7 +131,7 @@ public class BaseUserService {
|
||||||
if (CollectionUtils.isEmpty(project)) {
|
if (CollectionUtils.isEmpty(project)) {
|
||||||
List<String> organizationIds = user.getUserRoles()
|
List<String> organizationIds = user.getUserRoles()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(ug -> StringUtils.equals(ug.getType(), UserRoleType.ORGANIZATION))
|
.filter(ug -> StringUtils.equals(ug.getType(), UserRoleType.ORGANIZATION.name()))
|
||||||
.map(UserRole::getId)
|
.map(UserRole::getId)
|
||||||
.toList();
|
.toList();
|
||||||
List<UserRoleRelation> organizations = userRoleRelations.stream().filter(ug -> organizationIds.contains(ug.getRoleId()))
|
List<UserRoleRelation> organizations = userRoleRelations.stream().filter(ug -> organizationIds.contains(ug.getRoleId()))
|
||||||
|
@ -211,7 +211,7 @@ public class BaseUserService {
|
||||||
|
|
||||||
List<UserRoleRelation> roleRelations = user.getUserRoleRelations();
|
List<UserRoleRelation> roleRelations = user.getUserRoleRelations();
|
||||||
List<String> projectRoleIds = user.getUserRoles()
|
List<String> projectRoleIds = user.getUserRoles()
|
||||||
.stream().filter(ug -> StringUtils.equals(ug.getType(), UserRoleType.PROJECT))
|
.stream().filter(ug -> StringUtils.equals(ug.getType(), UserRoleType.PROJECT.name()))
|
||||||
.map(UserRole::getId)
|
.map(UserRole::getId)
|
||||||
.toList();
|
.toList();
|
||||||
List<String> projectIdsWithPermission = roleRelations.stream().filter(ug -> projectRoleIds.contains(ug.getRoleId()))
|
List<String> projectIdsWithPermission = roleRelations.stream().filter(ug -> projectRoleIds.contains(ug.getRoleId()))
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package io.metersphere.sdk.service;
|
package io.metersphere.sdk.service;
|
||||||
|
|
||||||
import io.metersphere.sdk.constants.ApiKeyConstants;
|
|
||||||
import io.metersphere.sdk.exception.MSException;
|
import io.metersphere.sdk.exception.MSException;
|
||||||
import io.metersphere.sdk.util.Translator;
|
import io.metersphere.sdk.util.Translator;
|
||||||
import io.metersphere.system.domain.UserKey;
|
import io.metersphere.system.domain.UserKey;
|
||||||
|
@ -47,7 +47,7 @@ public class UserKeyService {
|
||||||
UserKey userKeys = new UserKey();
|
UserKey userKeys = new UserKey();
|
||||||
userKeys.setId(UUID.randomUUID().toString());
|
userKeys.setId(UUID.randomUUID().toString());
|
||||||
userKeys.setCreateUser(userId);
|
userKeys.setCreateUser(userId);
|
||||||
userKeys.setStatus(ApiKeyConstants.ACTIVE.name());
|
userKeys.setEnable(true);
|
||||||
userKeys.setAccessKey(RandomStringUtils.randomAlphanumeric(16));
|
userKeys.setAccessKey(RandomStringUtils.randomAlphanumeric(16));
|
||||||
userKeys.setSecretKey(RandomStringUtils.randomAlphanumeric(16));
|
userKeys.setSecretKey(RandomStringUtils.randomAlphanumeric(16));
|
||||||
userKeys.setCreateTime(System.currentTimeMillis());
|
userKeys.setCreateTime(System.currentTimeMillis());
|
||||||
|
@ -62,20 +62,20 @@ public class UserKeyService {
|
||||||
public void activeUserKey(String id) {
|
public void activeUserKey(String id) {
|
||||||
UserKey userKeys = new UserKey();
|
UserKey userKeys = new UserKey();
|
||||||
userKeys.setId(id);
|
userKeys.setId(id);
|
||||||
userKeys.setStatus(ApiKeyConstants.ACTIVE.name());
|
userKeys.setEnable(true);
|
||||||
userKeyMapper.updateByPrimaryKeySelective(userKeys);
|
userKeyMapper.updateByPrimaryKeySelective(userKeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disableUserKey(String id) {
|
public void disableUserKey(String id) {
|
||||||
UserKey userKeys = new UserKey();
|
UserKey userKeys = new UserKey();
|
||||||
userKeys.setId(id);
|
userKeys.setId(id);
|
||||||
userKeys.setStatus(ApiKeyConstants.DISABLED.name());
|
userKeys.setEnable(false);
|
||||||
userKeyMapper.updateByPrimaryKeySelective(userKeys);
|
userKeyMapper.updateByPrimaryKeySelective(userKeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserKey getUserKey(String accessKey) {
|
public UserKey getUserKey(String accessKey) {
|
||||||
UserKeyExample userKeyExample = new UserKeyExample();
|
UserKeyExample userKeyExample = new UserKeyExample();
|
||||||
userKeyExample.createCriteria().andAccessKeyEqualTo(accessKey).andStatusEqualTo(ApiKeyConstants.ACTIVE.name());
|
userKeyExample.createCriteria().andAccessKeyEqualTo(accessKey).andEnableEqualTo(true);
|
||||||
List<UserKey> userKeysList = userKeyMapper.selectByExample(userKeyExample);
|
List<UserKey> userKeysList = userKeyMapper.selectByExample(userKeyExample);
|
||||||
if (!CollectionUtils.isEmpty(userKeysList)) {
|
if (!CollectionUtils.isEmpty(userKeysList)) {
|
||||||
return userKeysList.get(0);
|
return userKeysList.get(0);
|
||||||
|
|
Loading…
Reference in New Issue