组织成员管理

This commit is contained in:
shiziyuan9527 2020-02-24 14:06:07 +08:00
parent 7ec03015dd
commit 814c573010
8 changed files with 257 additions and 2 deletions

View File

@ -2,6 +2,7 @@ package io.metersphere.base.mapper.ext;
import io.metersphere.base.domain.User;
import io.metersphere.controller.request.member.QueryMemberRequest;
import io.metersphere.controller.request.organization.QueryOrgMemberRequest;
import io.metersphere.dto.UserRoleHelpDTO;
import org.apache.ibatis.annotations.Param;
@ -12,4 +13,6 @@ public interface ExtUserRoleMapper {
List<UserRoleHelpDTO> getUserRoleHelpList(@Param("userId") String userId);
List<User> getMemberList(@Param("member") QueryMemberRequest request);
List<User> getOrgMemberList(@Param("orgMember") QueryOrgMemberRequest request);
}

View File

@ -35,4 +35,12 @@
</if>
</select>
<select id="getOrgMemberList" resultType="io.metersphere.base.domain.User">
SELECT `user`.* FROM user_role JOIN `user` ON user_role.user_id = `user`.id
WHERE user_role.source_id = #{orgMember.organizationId} AND user_role.role_id = #{orgMember.roleId}
<if test="orgMember.name != null">
AND `user`.name like CONCAT('%', #{orgMember.name},'%')
</if>
</select>
</mapper>

View File

@ -9,6 +9,7 @@ import io.metersphere.commons.utils.Pager;
import io.metersphere.controller.request.member.AddMemberRequest;
import io.metersphere.controller.request.member.QueryMemberRequest;
import io.metersphere.controller.request.organization.AddOrgMemberRequest;
import io.metersphere.controller.request.organization.QueryOrgMemberRequest;
import io.metersphere.dto.UserDTO;
import io.metersphere.dto.UserRoleDTO;
import io.metersphere.service.UserService;
@ -115,4 +116,13 @@ public class UserController {
userService.delOrganizationMember(organizationId, userId);
}
/**
* 查询组织成员列表
*/
@PostMapping("/orgmember/list/{goPage}/{pageSize}")
public Pager<List<User>> getOrgMemberList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryOrgMemberRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, userService.getOrgMemberList(request));
}
}

View File

@ -0,0 +1,34 @@
package io.metersphere.controller.request.organization;
import io.metersphere.commons.constants.RoleConstants;
public class QueryOrgMemberRequest {
private String name;
private String organizationId;
private String roleId = RoleConstants.ORG_ADMIN;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getOrganizationId() {
return organizationId;
}
public void setOrganizationId(String organizationId) {
this.organizationId = organizationId;
}
public String getRoleId() {
return roleId;
}
public void setRoleId(String roleId) {
this.roleId = roleId;
}
}

View File

@ -11,6 +11,7 @@ import io.metersphere.commons.exception.MSException;
import io.metersphere.controller.request.member.AddMemberRequest;
import io.metersphere.controller.request.member.QueryMemberRequest;
import io.metersphere.controller.request.organization.AddOrgMemberRequest;
import io.metersphere.controller.request.organization.QueryOrgMemberRequest;
import io.metersphere.dto.UserDTO;
import io.metersphere.dto.UserRoleDTO;
import io.metersphere.dto.UserRoleHelpDTO;
@ -265,7 +266,7 @@ public class UserService {
for (String userId : request.getUserIds()) {
UserRole userRole = new UserRole();
userRole.setId(UUID.randomUUID().toString());
userRole.setRoleId(RoleConstants.ORG_OTHER);
userRole.setRoleId(RoleConstants.ORG_ADMIN);
userRole.setSourceId(request.getOrganizationId());
userRole.setUserId(userId);
userRole.setUpdateTime(System.currentTimeMillis());
@ -277,8 +278,12 @@ public class UserService {
public void delOrganizationMember(String organizationId, String userId) {
UserRoleExample userRoleExample = new UserRoleExample();
userRoleExample.createCriteria().andRoleIdEqualTo(RoleConstants.ORG_OTHER)
userRoleExample.createCriteria().andRoleIdEqualTo(RoleConstants.ORG_ADMIN)
.andUserIdEqualTo(userId).andSourceIdEqualTo(organizationId);
userRoleMapper.deleteByExample(userRoleExample);
}
public List<User> getOrgMemberList(QueryOrgMemberRequest request) {
return extUserRoleMapper.getOrgMemberList(request);
}
}

View File

@ -7,6 +7,7 @@ import User from "../settings/User";
import CreateTestPlan from "../testPlan/CreateTestPlan";
import AllTestPlan from "../testPlan/AllTestPlan";
import Organization from "../settings/Organization";
import OrganizationMember from "../settings/OrganizationMember";
import Member from "../settings/Member";
import TestResourcePool from "../settings/TestResourcePool";
import MsProject from "../project/MsProject";
@ -48,6 +49,10 @@ const router = new VueRouter({
roles: ['admin']
}
},
{
path: 'organizationmember',
component: OrganizationMember,
},
{
path: 'member',
component: Member

View File

@ -0,0 +1,189 @@
<template>
<div v-loading="result.loading">
<el-card>
<div slot="header">
<el-row type="flex" justify="space-between" align="middle">
<span class="title">成员
<ms-create-box :tips="btnTips" :exec="create"/>
</span>
<span class="search">
<el-input type="text" size="small" placeholder="根据用户名搜索" prefix-icon="el-icon-search"
maxlength="60" v-model="condition" @change="search" clearable/>
</span>
</el-row>
</div>
<el-table :data="tableData" style="width: 100%">
<el-table-column prop="name" label="用户名"/>
<el-table-column prop="email" label="邮箱"/>
<el-table-column prop="phone" label="电话"/>
<el-table-column>
<template slot-scope="scope">
<el-button @click="del(scope.row)" type="danger" icon="el-icon-delete" size="mini" circle/>
</template>
</el-table-column>
</el-table>
<div>
<el-row>
<el-col :span="22" :offset="1">
<div class="table-page">
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page.sync="currentPage"
:page-sizes="[5, 10, 20, 50, 100]"
:page-size="pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="total">
</el-pagination>
</div>
</el-col>
</el-row>
</div>
</el-card>
<el-dialog title="添加成员" :visible.sync="createVisible" width="30%">
<el-form :model="form" ref="form" :rules="rules" label-position="left" label-width="100px" size="small">
<el-form-item label="成员" prop="userIds">
<el-select v-model="form.userIds" multiple placeholder="请选择成员" class="select-width">
<el-option
v-for="item in form.userList"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm('form')" size="medium">保存</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import MsCreateBox from "./CreateBox";
export default {
name: "OrganizationMember",
components: {MsCreateBox},
created() {
this.initTableData();
},
data() {
return {
result: {},
btnTips: "添加组织成员",
createVisible: false,
form: {},
queryPath: "/user/orgmember/list",
condition: "",
tableData: [],
rules: {
userIds: [
{required: true, message: '请选择成员', trigger: ['blur', 'change']}
]
},
multipleSelection: [],
currentOrganizationId: "d2f49498-3333-4872-ab98-59174d4a81da",
currentPage: 1,
pageSize: 5,
total: 0
}
},
methods: {
initTableData() {
let param = {
name: this.condition,
organizationId: this.currentOrganizationId
};
this.result = this.$post(this.buildPagePath(this.queryPath), param, response => {
let data = response.data;
this.total = data.itemCount;
this.tableData = data.listObject;
})
},
buildPagePath(path) {
return path + "/" + this.currentPage + "/" + this.pageSize;
},
search() {
this.initTableData();
},
handleSizeChange(size) {
this.pageSize = size;
},
handleCurrentChange(current) {
this.currentPage = current;
},
del(row) {
this.$confirm('移除该成员, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.loading = true;
this.$get('/user/member/delete/' + this.currentWorkspaceId + '/' + row.id).then(() => {
this.initTableData();
this.loading = false;
});
this.$message({
type: 'success',
message: '删除成功!'
});
}).catch(() => {
this.loading = false;
this.$message({
type: 'info',
message: '已取消删除'
});
});
},
create() {
this.loading = true;
this.$get('/user/list').then(response => {
if (response.data.success) {
this.createVisible = true;
this.form = {userList: response.data.data};
} else {
this.$message.error(response.message);
}
this.loading = false;
}).catch(() => {
this.loading = false;
this.$message({
type: 'error',
message: '获取用户列表失败'
});
});
},
submitForm(formName) {
this.loading = true;
this.$refs[formName].validate((valid) => {
if (valid) {
let param = {
userIds: this.form.userIds,
workspaceId: this.currentWorkspaceId
};
this.$post("user/member/add", param).then(() => {
this.initTableData();
this.createVisible = false;
this.loading = false;
}).catch(() => {
this.loading = false;
})
} else {
return false;
}
});
}
}
}
</script>
<style scoped>
.table-page {
padding-top: 20px;
margin-right: -9px;
float: right;
}
</style>

View File

@ -8,6 +8,7 @@
<el-menu-item index="/setting/user" v-permission="['admin']">用户</el-menu-item>
<el-menu-item index="/setting/testresourcepool" v-permission="['test']">测试资源池</el-menu-item>
<el-menu-item index="/setting/organization" v-permission="['admin']">组织</el-menu-item>
<el-menu-item index="/setting/organizationmember" v-permission="['org_admin']">组织成员</el-menu-item>
<el-menu-item index="/setting/workspace" v-permission="['org_admin']">工作空间</el-menu-item>
<el-menu-item>API Keys</el-menu-item>
</el-submenu>