From aca19f6dfae380b61d7f6db96d088cbc6cc092d7 Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Fri, 10 Jul 2020 16:27:41 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E8=BF=87ldap=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E7=9A=84=E7=94=A8=E6=88=B7=E4=B8=8D=E8=83=BD=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=AF=86=E7=A0=81=E5=92=8C=E9=82=AE=E7=AE=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/metersphere/base/domain/User.java | 5 +- .../metersphere/base/domain/UserExample.java | 182 ++++++++++++------ .../metersphere/base/mapper/UserMapper.java | 6 +- .../io/metersphere/base/mapper/UserMapper.xml | 76 +++++--- .../commons/constants/UserSource.java | 5 + .../main/java/io/metersphere/dto/UserDTO.java | 2 + .../ldap/controller/LdapController.java | 2 + .../db/migration/V7__modify_user_table.sql | 1 + .../settings/personal/PersonSetting.vue | 6 +- 9 files changed, 190 insertions(+), 95 deletions(-) create mode 100644 backend/src/main/java/io/metersphere/commons/constants/UserSource.java create mode 100644 backend/src/main/resources/db/migration/V7__modify_user_table.sql diff --git a/backend/src/main/java/io/metersphere/base/domain/User.java b/backend/src/main/java/io/metersphere/base/domain/User.java index 2236965d75..e5e79131a3 100644 --- a/backend/src/main/java/io/metersphere/base/domain/User.java +++ b/backend/src/main/java/io/metersphere/base/domain/User.java @@ -1,8 +1,7 @@ package io.metersphere.base.domain; -import lombok.Data; - import java.io.Serializable; +import lombok.Data; @Data public class User implements Serializable { @@ -28,5 +27,7 @@ public class User implements Serializable { private String phone; + private String source; + private static final long serialVersionUID = 1L; } \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/UserExample.java b/backend/src/main/java/io/metersphere/base/domain/UserExample.java index 5b31d94f4d..986bec6d9d 100644 --- a/backend/src/main/java/io/metersphere/base/domain/UserExample.java +++ b/backend/src/main/java/io/metersphere/base/domain/UserExample.java @@ -175,72 +175,72 @@ public class UserExample { } public Criteria andNameIsNull() { - addCriterion("name is null"); + addCriterion("`name` is null"); return (Criteria) this; } public Criteria andNameIsNotNull() { - addCriterion("name is not null"); + addCriterion("`name` is not null"); return (Criteria) this; } public Criteria andNameEqualTo(String value) { - addCriterion("name =", value, "name"); + addCriterion("`name` =", value, "name"); return (Criteria) this; } public Criteria andNameNotEqualTo(String value) { - addCriterion("name <>", value, "name"); + addCriterion("`name` <>", value, "name"); return (Criteria) this; } public Criteria andNameGreaterThan(String value) { - addCriterion("name >", value, "name"); + addCriterion("`name` >", value, "name"); return (Criteria) this; } public Criteria andNameGreaterThanOrEqualTo(String value) { - addCriterion("name >=", value, "name"); + addCriterion("`name` >=", value, "name"); return (Criteria) this; } public Criteria andNameLessThan(String value) { - addCriterion("name <", value, "name"); + addCriterion("`name` <", value, "name"); return (Criteria) this; } public Criteria andNameLessThanOrEqualTo(String value) { - addCriterion("name <=", value, "name"); + addCriterion("`name` <=", value, "name"); return (Criteria) this; } public Criteria andNameLike(String value) { - addCriterion("name like", value, "name"); + addCriterion("`name` like", value, "name"); return (Criteria) this; } public Criteria andNameNotLike(String value) { - addCriterion("name not like", value, "name"); + addCriterion("`name` not like", value, "name"); return (Criteria) this; } public Criteria andNameIn(List values) { - addCriterion("name in", values, "name"); + addCriterion("`name` in", values, "name"); return (Criteria) this; } public Criteria andNameNotIn(List values) { - addCriterion("name not in", values, "name"); + addCriterion("`name` not in", values, "name"); return (Criteria) this; } public Criteria andNameBetween(String value1, String value2) { - addCriterion("name between", value1, value2, "name"); + addCriterion("`name` between", value1, value2, "name"); return (Criteria) this; } public Criteria andNameNotBetween(String value1, String value2) { - addCriterion("name not between", value1, value2, "name"); + addCriterion("`name` not between", value1, value2, "name"); return (Criteria) this; } @@ -315,142 +315,142 @@ public class UserExample { } public Criteria andPasswordIsNull() { - addCriterion("password is null"); + addCriterion("`password` is null"); return (Criteria) this; } public Criteria andPasswordIsNotNull() { - addCriterion("password is not null"); + addCriterion("`password` is not null"); return (Criteria) this; } public Criteria andPasswordEqualTo(String value) { - addCriterion("password =", value, "password"); + addCriterion("`password` =", value, "password"); return (Criteria) this; } public Criteria andPasswordNotEqualTo(String value) { - addCriterion("password <>", value, "password"); + addCriterion("`password` <>", value, "password"); return (Criteria) this; } public Criteria andPasswordGreaterThan(String value) { - addCriterion("password >", value, "password"); + addCriterion("`password` >", value, "password"); return (Criteria) this; } public Criteria andPasswordGreaterThanOrEqualTo(String value) { - addCriterion("password >=", value, "password"); + addCriterion("`password` >=", value, "password"); return (Criteria) this; } public Criteria andPasswordLessThan(String value) { - addCriterion("password <", value, "password"); + addCriterion("`password` <", value, "password"); return (Criteria) this; } public Criteria andPasswordLessThanOrEqualTo(String value) { - addCriterion("password <=", value, "password"); + addCriterion("`password` <=", value, "password"); return (Criteria) this; } public Criteria andPasswordLike(String value) { - addCriterion("password like", value, "password"); + addCriterion("`password` like", value, "password"); return (Criteria) this; } public Criteria andPasswordNotLike(String value) { - addCriterion("password not like", value, "password"); + addCriterion("`password` not like", value, "password"); return (Criteria) this; } public Criteria andPasswordIn(List values) { - addCriterion("password in", values, "password"); + addCriterion("`password` in", values, "password"); return (Criteria) this; } public Criteria andPasswordNotIn(List values) { - addCriterion("password not in", values, "password"); + addCriterion("`password` not in", values, "password"); return (Criteria) this; } public Criteria andPasswordBetween(String value1, String value2) { - addCriterion("password between", value1, value2, "password"); + addCriterion("`password` between", value1, value2, "password"); return (Criteria) this; } public Criteria andPasswordNotBetween(String value1, String value2) { - addCriterion("password not between", value1, value2, "password"); + addCriterion("`password` not between", value1, value2, "password"); return (Criteria) this; } public Criteria andStatusIsNull() { - addCriterion("status is null"); + addCriterion("`status` is null"); return (Criteria) this; } public Criteria andStatusIsNotNull() { - addCriterion("status is not null"); + addCriterion("`status` is not null"); return (Criteria) this; } public Criteria andStatusEqualTo(String value) { - addCriterion("status =", value, "status"); + addCriterion("`status` =", value, "status"); return (Criteria) this; } public Criteria andStatusNotEqualTo(String value) { - addCriterion("status <>", value, "status"); + addCriterion("`status` <>", value, "status"); return (Criteria) this; } public Criteria andStatusGreaterThan(String value) { - addCriterion("status >", value, "status"); + addCriterion("`status` >", value, "status"); return (Criteria) this; } public Criteria andStatusGreaterThanOrEqualTo(String value) { - addCriterion("status >=", value, "status"); + addCriterion("`status` >=", value, "status"); return (Criteria) this; } public Criteria andStatusLessThan(String value) { - addCriterion("status <", value, "status"); + addCriterion("`status` <", value, "status"); return (Criteria) this; } public Criteria andStatusLessThanOrEqualTo(String value) { - addCriterion("status <=", value, "status"); + addCriterion("`status` <=", value, "status"); return (Criteria) this; } public Criteria andStatusLike(String value) { - addCriterion("status like", value, "status"); + addCriterion("`status` like", value, "status"); return (Criteria) this; } public Criteria andStatusNotLike(String value) { - addCriterion("status not like", value, "status"); + addCriterion("`status` not like", value, "status"); return (Criteria) this; } public Criteria andStatusIn(List values) { - addCriterion("status in", values, "status"); + addCriterion("`status` in", values, "status"); return (Criteria) this; } public Criteria andStatusNotIn(List values) { - addCriterion("status not in", values, "status"); + addCriterion("`status` not in", values, "status"); return (Criteria) this; } public Criteria andStatusBetween(String value1, String value2) { - addCriterion("status between", value1, value2, "status"); + addCriterion("`status` between", value1, value2, "status"); return (Criteria) this; } public Criteria andStatusNotBetween(String value1, String value2) { - addCriterion("status not between", value1, value2, "status"); + addCriterion("`status` not between", value1, value2, "status"); return (Criteria) this; } @@ -575,72 +575,72 @@ public class UserExample { } public Criteria andLanguageIsNull() { - addCriterion("language is null"); + addCriterion("`language` is null"); return (Criteria) this; } public Criteria andLanguageIsNotNull() { - addCriterion("language is not null"); + addCriterion("`language` is not null"); return (Criteria) this; } public Criteria andLanguageEqualTo(String value) { - addCriterion("language =", value, "language"); + addCriterion("`language` =", value, "language"); return (Criteria) this; } public Criteria andLanguageNotEqualTo(String value) { - addCriterion("language <>", value, "language"); + addCriterion("`language` <>", value, "language"); return (Criteria) this; } public Criteria andLanguageGreaterThan(String value) { - addCriterion("language >", value, "language"); + addCriterion("`language` >", value, "language"); return (Criteria) this; } public Criteria andLanguageGreaterThanOrEqualTo(String value) { - addCriterion("language >=", value, "language"); + addCriterion("`language` >=", value, "language"); return (Criteria) this; } public Criteria andLanguageLessThan(String value) { - addCriterion("language <", value, "language"); + addCriterion("`language` <", value, "language"); return (Criteria) this; } public Criteria andLanguageLessThanOrEqualTo(String value) { - addCriterion("language <=", value, "language"); + addCriterion("`language` <=", value, "language"); return (Criteria) this; } public Criteria andLanguageLike(String value) { - addCriterion("language like", value, "language"); + addCriterion("`language` like", value, "language"); return (Criteria) this; } public Criteria andLanguageNotLike(String value) { - addCriterion("language not like", value, "language"); + addCriterion("`language` not like", value, "language"); return (Criteria) this; } public Criteria andLanguageIn(List values) { - addCriterion("language in", values, "language"); + addCriterion("`language` in", values, "language"); return (Criteria) this; } public Criteria andLanguageNotIn(List values) { - addCriterion("language not in", values, "language"); + addCriterion("`language` not in", values, "language"); return (Criteria) this; } public Criteria andLanguageBetween(String value1, String value2) { - addCriterion("language between", value1, value2, "language"); + addCriterion("`language` between", value1, value2, "language"); return (Criteria) this; } public Criteria andLanguageNotBetween(String value1, String value2) { - addCriterion("language not between", value1, value2, "language"); + addCriterion("`language` not between", value1, value2, "language"); return (Criteria) this; } @@ -853,6 +853,76 @@ public class UserExample { addCriterion("phone not between", value1, value2, "phone"); return (Criteria) this; } + + public Criteria andSourceIsNull() { + addCriterion("`source` is null"); + return (Criteria) this; + } + + public Criteria andSourceIsNotNull() { + addCriterion("`source` is not null"); + return (Criteria) this; + } + + public Criteria andSourceEqualTo(String value) { + addCriterion("`source` =", value, "source"); + return (Criteria) this; + } + + public Criteria andSourceNotEqualTo(String value) { + addCriterion("`source` <>", value, "source"); + return (Criteria) this; + } + + public Criteria andSourceGreaterThan(String value) { + addCriterion("`source` >", value, "source"); + return (Criteria) this; + } + + public Criteria andSourceGreaterThanOrEqualTo(String value) { + addCriterion("`source` >=", value, "source"); + return (Criteria) this; + } + + public Criteria andSourceLessThan(String value) { + addCriterion("`source` <", value, "source"); + return (Criteria) this; + } + + public Criteria andSourceLessThanOrEqualTo(String value) { + addCriterion("`source` <=", value, "source"); + return (Criteria) this; + } + + public Criteria andSourceLike(String value) { + addCriterion("`source` like", value, "source"); + return (Criteria) this; + } + + public Criteria andSourceNotLike(String value) { + addCriterion("`source` not like", value, "source"); + return (Criteria) this; + } + + public Criteria andSourceIn(List values) { + addCriterion("`source` in", values, "source"); + return (Criteria) this; + } + + public Criteria andSourceNotIn(List values) { + addCriterion("`source` not in", values, "source"); + return (Criteria) this; + } + + public Criteria andSourceBetween(String value1, String value2) { + addCriterion("`source` between", value1, value2, "source"); + return (Criteria) this; + } + + public Criteria andSourceNotBetween(String value1, String value2) { + addCriterion("`source` not between", value1, value2, "source"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/backend/src/main/java/io/metersphere/base/mapper/UserMapper.java b/backend/src/main/java/io/metersphere/base/mapper/UserMapper.java index 69d4f62258..286dd2ab87 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/UserMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/UserMapper.java @@ -2,9 +2,8 @@ package io.metersphere.base.mapper; import io.metersphere.base.domain.User; import io.metersphere.base.domain.UserExample; -import org.apache.ibatis.annotations.Param; - import java.util.List; +import org.apache.ibatis.annotations.Param; public interface UserMapper { long countByExample(UserExample example); @@ -28,7 +27,4 @@ public interface UserMapper { int updateByPrimaryKeySelective(User record); int updateByPrimaryKey(User record); - - - } \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/UserMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/UserMapper.xml index 2e9797c759..5481b28259 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/UserMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/UserMapper.xml @@ -13,6 +13,7 @@ + @@ -73,8 +74,8 @@ - id, name, email, password, status, create_time, update_time, language, last_workspace_id, - last_organization_id, phone + id, `name`, email, `password`, `status`, create_time, update_time, `language`, last_workspace_id, + last_organization_id, phone, `source` @@ -202,16 +211,16 @@ id = #{record.id,jdbcType=VARCHAR}, - name = #{record.name,jdbcType=VARCHAR}, + `name` = #{record.name,jdbcType=VARCHAR}, email = #{record.email,jdbcType=VARCHAR}, - password = #{record.password,jdbcType=VARCHAR}, + `password` = #{record.password,jdbcType=VARCHAR}, - status = #{record.status,jdbcType=VARCHAR}, + `status` = #{record.status,jdbcType=VARCHAR}, create_time = #{record.createTime,jdbcType=BIGINT}, @@ -220,7 +229,7 @@ update_time = #{record.updateTime,jdbcType=BIGINT}, - language = #{record.language,jdbcType=VARCHAR}, + `language` = #{record.language,jdbcType=VARCHAR}, last_workspace_id = #{record.lastWorkspaceId,jdbcType=VARCHAR}, @@ -231,6 +240,9 @@ phone = #{record.phone,jdbcType=VARCHAR}, + + `source` = #{record.source,jdbcType=VARCHAR}, + @@ -239,16 +251,17 @@ update user set id = #{record.id,jdbcType=VARCHAR}, - name = #{record.name,jdbcType=VARCHAR}, + `name` = #{record.name,jdbcType=VARCHAR}, email = #{record.email,jdbcType=VARCHAR}, - password = #{record.password,jdbcType=VARCHAR}, - status = #{record.status,jdbcType=VARCHAR}, + `password` = #{record.password,jdbcType=VARCHAR}, + `status` = #{record.status,jdbcType=VARCHAR}, create_time = #{record.createTime,jdbcType=BIGINT}, update_time = #{record.updateTime,jdbcType=BIGINT}, - language = #{record.language,jdbcType=VARCHAR}, + `language` = #{record.language,jdbcType=VARCHAR}, last_workspace_id = #{record.lastWorkspaceId,jdbcType=VARCHAR}, last_organization_id = #{record.lastOrganizationId,jdbcType=VARCHAR}, - phone = #{record.phone,jdbcType=VARCHAR} + phone = #{record.phone,jdbcType=VARCHAR}, + `source` = #{record.source,jdbcType=VARCHAR} @@ -257,16 +270,16 @@ update user - name = #{name,jdbcType=VARCHAR}, + `name` = #{name,jdbcType=VARCHAR}, email = #{email,jdbcType=VARCHAR}, - password = #{password,jdbcType=VARCHAR}, + `password` = #{password,jdbcType=VARCHAR}, - status = #{status,jdbcType=VARCHAR}, + `status` = #{status,jdbcType=VARCHAR}, create_time = #{createTime,jdbcType=BIGINT}, @@ -275,7 +288,7 @@ update_time = #{updateTime,jdbcType=BIGINT}, - language = #{language,jdbcType=VARCHAR}, + `language` = #{language,jdbcType=VARCHAR}, last_workspace_id = #{lastWorkspaceId,jdbcType=VARCHAR}, @@ -286,22 +299,25 @@ phone = #{phone,jdbcType=VARCHAR}, + + `source` = #{source,jdbcType=VARCHAR}, + where id = #{id,jdbcType=VARCHAR} update user - set name = #{name,jdbcType=VARCHAR}, + set `name` = #{name,jdbcType=VARCHAR}, email = #{email,jdbcType=VARCHAR}, - password = #{password,jdbcType=VARCHAR}, - status = #{status,jdbcType=VARCHAR}, + `password` = #{password,jdbcType=VARCHAR}, + `status` = #{status,jdbcType=VARCHAR}, create_time = #{createTime,jdbcType=BIGINT}, update_time = #{updateTime,jdbcType=BIGINT}, - language = #{language,jdbcType=VARCHAR}, + `language` = #{language,jdbcType=VARCHAR}, last_workspace_id = #{lastWorkspaceId,jdbcType=VARCHAR}, last_organization_id = #{lastOrganizationId,jdbcType=VARCHAR}, - phone = #{phone,jdbcType=VARCHAR} + phone = #{phone,jdbcType=VARCHAR}, + `source` = #{source,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR} - \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/commons/constants/UserSource.java b/backend/src/main/java/io/metersphere/commons/constants/UserSource.java new file mode 100644 index 0000000000..1deb49eaeb --- /dev/null +++ b/backend/src/main/java/io/metersphere/commons/constants/UserSource.java @@ -0,0 +1,5 @@ +package io.metersphere.commons.constants; + +public enum UserSource { + Local, Ldap +} diff --git a/backend/src/main/java/io/metersphere/dto/UserDTO.java b/backend/src/main/java/io/metersphere/dto/UserDTO.java index d736479da7..944c2a62a3 100644 --- a/backend/src/main/java/io/metersphere/dto/UserDTO.java +++ b/backend/src/main/java/io/metersphere/dto/UserDTO.java @@ -21,6 +21,8 @@ public class UserDTO { private String status; + private String source; + private Long createTime; private Long updateTime; diff --git a/backend/src/main/java/io/metersphere/ldap/controller/LdapController.java b/backend/src/main/java/io/metersphere/ldap/controller/LdapController.java index 0956c66abf..3786314112 100644 --- a/backend/src/main/java/io/metersphere/ldap/controller/LdapController.java +++ b/backend/src/main/java/io/metersphere/ldap/controller/LdapController.java @@ -2,6 +2,7 @@ package io.metersphere.ldap.controller; import io.metersphere.base.domain.User; import io.metersphere.commons.constants.ParamConstants; +import io.metersphere.commons.constants.UserSource; import io.metersphere.commons.exception.MSException; import io.metersphere.controller.ResultHolder; import io.metersphere.controller.request.LoginRequest; @@ -55,6 +56,7 @@ public class LdapController { user.setName(username); user.setEmail(email); user.setPassword(password); + user.setSource(UserSource.Ldap.name()); userService.createUser(user); } else { request.setUsername(u.getId()); diff --git a/backend/src/main/resources/db/migration/V7__modify_user_table.sql b/backend/src/main/resources/db/migration/V7__modify_user_table.sql new file mode 100644 index 0000000000..66dc7bd29d --- /dev/null +++ b/backend/src/main/resources/db/migration/V7__modify_user_table.sql @@ -0,0 +1 @@ +alter table user add source varchar(50) null; \ No newline at end of file diff --git a/frontend/src/business/components/settings/personal/PersonSetting.vue b/frontend/src/business/components/settings/personal/PersonSetting.vue index 70935ad8ce..25bbd84ec7 100644 --- a/frontend/src/business/components/settings/personal/PersonSetting.vue +++ b/frontend/src/business/components/settings/personal/PersonSetting.vue @@ -24,7 +24,7 @@ @@ -43,7 +43,7 @@ - + @@ -89,6 +89,7 @@ data() { return { result: {}, + isLdapUser: false, updateVisible: false, editPasswordVisible: false, tableData: [], @@ -198,6 +199,7 @@ initTableData() { this.result = this.$get("/user/info/" + this.currentUser().id, response => { let data = response.data; + this.isLdapUser = response.data.source === 'Ldap' ? true : false; let dataList = []; dataList[0] = data; this.tableData = dataList;