Merge branch 'v1.1' of https://github.com/metersphere/server into v1.1
This commit is contained in:
commit
5aca08a677
|
@ -14,4 +14,6 @@ public interface ExtUserMapper {
|
||||||
|
|
||||||
String getDefaultLanguage(String paramKey);
|
String getDefaultLanguage(String paramKey);
|
||||||
|
|
||||||
|
List<User> searchUser(String condition);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,17 +3,17 @@
|
||||||
<mapper namespace="io.metersphere.base.mapper.ext.ExtUserMapper">
|
<mapper namespace="io.metersphere.base.mapper.ext.ExtUserMapper">
|
||||||
|
|
||||||
<resultMap id="BaseResultMap" type="io.metersphere.base.domain.User">
|
<resultMap id="BaseResultMap" type="io.metersphere.base.domain.User">
|
||||||
<id column="id" jdbcType="VARCHAR" property="id" />
|
<id column="id" jdbcType="VARCHAR" property="id"/>
|
||||||
<result column="name" jdbcType="VARCHAR" property="name" />
|
<result column="name" jdbcType="VARCHAR" property="name"/>
|
||||||
<result column="email" jdbcType="VARCHAR" property="email" />
|
<result column="email" jdbcType="VARCHAR" property="email"/>
|
||||||
<result column="password" jdbcType="VARCHAR" property="password" />
|
<result column="password" jdbcType="VARCHAR" property="password"/>
|
||||||
<result column="status" jdbcType="VARCHAR" property="status" />
|
<result column="status" jdbcType="VARCHAR" property="status"/>
|
||||||
<result column="create_time" jdbcType="BIGINT" property="createTime" />
|
<result column="create_time" jdbcType="BIGINT" property="createTime"/>
|
||||||
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
|
<result column="update_time" jdbcType="BIGINT" property="updateTime"/>
|
||||||
<result column="language" jdbcType="VARCHAR" property="language" />
|
<result column="language" jdbcType="VARCHAR" property="language"/>
|
||||||
<result column="last_workspace_id" jdbcType="VARCHAR" property="lastWorkspaceId" />
|
<result column="last_workspace_id" jdbcType="VARCHAR" property="lastWorkspaceId"/>
|
||||||
<result column="last_organization_id" jdbcType="VARCHAR" property="lastOrganizationId" />
|
<result column="last_organization_id" jdbcType="VARCHAR" property="lastOrganizationId"/>
|
||||||
<result column="phone" jdbcType="VARCHAR" property="phone" />
|
<result column="phone" jdbcType="VARCHAR" property="phone"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<select id="getUserList" resultMap="BaseResultMap">
|
<select id="getUserList" resultMap="BaseResultMap">
|
||||||
|
@ -47,4 +47,8 @@
|
||||||
where param_key=#{paramKey,jdbcType=VARCHAR}
|
where param_key=#{paramKey,jdbcType=VARCHAR}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="searchUser" parameterType="java.lang.String" resultType="io.metersphere.base.domain.User">
|
||||||
|
select id, name, email, last_organization_id, last_workspace_id from `user` where id like CONCAT('%', #{condition},'%') or email like CONCAT('%', #{condition},'%') limit 100;
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
|
@ -284,4 +284,10 @@ public class UserController {
|
||||||
return userService.getTestManagerAndTestUserList(request);
|
return userService.getTestManagerAndTestUserList(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/search/{condition}")
|
||||||
|
@RequiresRoles(value = {RoleConstants.ADMIN, RoleConstants.ORG_ADMIN, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
|
||||||
|
public List<User> searchUser(@PathVariable String condition) {
|
||||||
|
return userService.searchUser(condition);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -384,7 +384,7 @@ public class UserService {
|
||||||
userRoleExample.createCriteria().andUserIdEqualTo(userId).andSourceIdEqualTo(request.getOrganizationId());
|
userRoleExample.createCriteria().andUserIdEqualTo(userId).andSourceIdEqualTo(request.getOrganizationId());
|
||||||
List<UserRole> userRoles = userRoleMapper.selectByExample(userRoleExample);
|
List<UserRole> userRoles = userRoleMapper.selectByExample(userRoleExample);
|
||||||
if (userRoles.size() > 0) {
|
if (userRoles.size() > 0) {
|
||||||
MSException.throwException(Translator.get("user_already_exists"));
|
MSException.throwException(Translator.get("user_already_exists") + ": " + userId);
|
||||||
} else {
|
} else {
|
||||||
for (String roleId : request.getRoleIds()) {
|
for (String roleId : request.getRoleIds()) {
|
||||||
UserRole userRole = new UserRole();
|
UserRole userRole = new UserRole();
|
||||||
|
@ -568,4 +568,8 @@ public class UserService {
|
||||||
MSException.throwException(msg);
|
MSException.throwException(msg);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<User> searchUser(String condition) {
|
||||||
|
return extUserMapper.searchUser(condition);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,23 +28,31 @@
|
||||||
<el-dialog :title="$t('member.create')" :visible.sync="createVisible" width="30%" :destroy-on-close="true"
|
<el-dialog :title="$t('member.create')" :visible.sync="createVisible" width="30%" :destroy-on-close="true"
|
||||||
@close="handleClose">
|
@close="handleClose">
|
||||||
<el-form :model="form" ref="form" :rules="rules" label-position="right" label-width="100px" size="small">
|
<el-form :model="form" ref="form" :rules="rules" label-position="right" label-width="100px" size="small">
|
||||||
<el-form-item :label="$t('commons.member')" prop="memberSign" :rules="{required: true, message: $t('member.input_id_or_email'), trigger: 'change'}">
|
|
||||||
<el-autocomplete
|
<el-form-item :label="$t('commons.member')" prop="ids" :rules="{required: true, message: $t('member.input_id_or_email'), trigger: 'blur'}">
|
||||||
class="input-with-autocomplete"
|
<el-select
|
||||||
v-model="form.memberSign"
|
v-model="form.ids"
|
||||||
|
multiple
|
||||||
|
filterable
|
||||||
|
remote
|
||||||
|
reserve-keyword
|
||||||
|
:popper-append-to-body="false"
|
||||||
|
class="select-width"
|
||||||
:placeholder="$t('member.input_id_or_email')"
|
:placeholder="$t('member.input_id_or_email')"
|
||||||
:trigger-on-focus="false"
|
:remote-method="remoteMethod"
|
||||||
:fetch-suggestions="querySearch"
|
:loading="loading">
|
||||||
size="small"
|
<el-option
|
||||||
highlight-first-item
|
v-for="item in options"
|
||||||
value-key="email"
|
:key="item.id"
|
||||||
@select="handleSelect"
|
:label="item.id"
|
||||||
>
|
:value="item.id">
|
||||||
<template v-slot:default="scope">
|
<template>
|
||||||
<span class="org-member-name">{{scope.item.id}}</span>
|
<span class="org-member-name">{{item.id}}</span>
|
||||||
<span class="org-member-email">{{scope.item.email}}</span>
|
<span class="org-member-email">{{item.email}}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-autocomplete>
|
</el-option>
|
||||||
|
|
||||||
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="$t('commons.role')" prop="roleIds">
|
<el-form-item :label="$t('commons.role')" prop="roleIds">
|
||||||
<el-select v-model="form.roleIds" multiple :placeholder="$t('role.please_choose_role')" class="select-width">
|
<el-select v-model="form.roleIds" multiple :placeholder="$t('role.please_choose_role')" class="select-width">
|
||||||
|
@ -136,6 +144,9 @@
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
pageSize: 5,
|
pageSize: 5,
|
||||||
total: 0,
|
total: 0,
|
||||||
|
options: [],
|
||||||
|
loading: false,
|
||||||
|
ids: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -165,6 +176,7 @@
|
||||||
},
|
},
|
||||||
handleClose() {
|
handleClose() {
|
||||||
this.form = {};
|
this.form = {};
|
||||||
|
this.options = [];
|
||||||
},
|
},
|
||||||
edit(row) {
|
edit(row) {
|
||||||
this.updateVisible = true;
|
this.updateVisible = true;
|
||||||
|
@ -217,9 +229,9 @@
|
||||||
}
|
}
|
||||||
this.form = {};
|
this.form = {};
|
||||||
this.createVisible = true;
|
this.createVisible = true;
|
||||||
this.result = this.$get('/user/list/', response => {
|
// this.result = this.$get('/user/list/', response => {
|
||||||
this.userList = response.data;
|
// this.userList = response.data;
|
||||||
});
|
// });
|
||||||
this.result = this.$get('/role/list/org', response => {
|
this.result = this.$get('/role/list/org', response => {
|
||||||
this.$set(this.form, "roles", response.data);
|
this.$set(this.form, "roles", response.data);
|
||||||
})
|
})
|
||||||
|
@ -228,19 +240,8 @@
|
||||||
this.$refs[formName].validate((valid) => {
|
this.$refs[formName].validate((valid) => {
|
||||||
let orgId = this.currentUser().lastOrganizationId;
|
let orgId = this.currentUser().lastOrganizationId;
|
||||||
if (valid) {
|
if (valid) {
|
||||||
let userIds = [];
|
|
||||||
let userId = this.form.userId;
|
|
||||||
let email = this.form.memberSign;
|
|
||||||
let member = this.userList.find(user => user.id === email || user.email === email);
|
|
||||||
if (!member) {
|
|
||||||
this.$warning(this.$t('member.no_such_user'));
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
userId = member.id;
|
|
||||||
}
|
|
||||||
userIds.push(userId);
|
|
||||||
let param = {
|
let param = {
|
||||||
userIds: userIds,
|
userIds: this.form.ids,
|
||||||
roleIds: this.form.roleIds,
|
roleIds: this.form.roleIds,
|
||||||
organizationId: orgId
|
organizationId: orgId
|
||||||
};
|
};
|
||||||
|
@ -254,21 +255,21 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
querySearch(queryString, cb) {
|
remoteMethod(query) {
|
||||||
var userList = this.userList;
|
query = query.trim()
|
||||||
var results = queryString ? userList.filter(this.createFilter(queryString)) : userList;
|
if (query !== '') {
|
||||||
// 调用 callback 返回建议列表的数据
|
this.loading = true;
|
||||||
cb(results);
|
setTimeout(() => {
|
||||||
},
|
this.loading = false;
|
||||||
createFilter(queryString) {
|
this.$get("/user/search/" + query, response => {
|
||||||
return (user) => {
|
this.options = response.data;
|
||||||
return (user.email.indexOf(queryString.toLowerCase()) === 0 || user.id.indexOf(queryString.toLowerCase()) === 0);
|
})
|
||||||
};
|
}, 200);
|
||||||
},
|
} else {
|
||||||
handleSelect(item) {
|
this.options = [];
|
||||||
this.$set(this.form, "userId", item.id);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue