组织菜单成员列表添加角色列

This commit is contained in:
shiziyuan9527 2020-02-27 15:27:51 +08:00
parent cf828f87b2
commit 27b57dcb9a
6 changed files with 151 additions and 1 deletions

View File

@ -3,6 +3,7 @@ package io.metersphere.base.mapper.ext;
import io.metersphere.base.domain.User; import io.metersphere.base.domain.User;
import io.metersphere.controller.request.member.QueryMemberRequest; import io.metersphere.controller.request.member.QueryMemberRequest;
import io.metersphere.controller.request.organization.QueryOrgMemberRequest; import io.metersphere.controller.request.organization.QueryOrgMemberRequest;
import io.metersphere.dto.OrganizationMemberDTO;
import io.metersphere.dto.UserRoleHelpDTO; import io.metersphere.dto.UserRoleHelpDTO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -15,4 +16,8 @@ public interface ExtUserRoleMapper {
List<User> getMemberList(@Param("member") QueryMemberRequest request); List<User> getMemberList(@Param("member") QueryMemberRequest request);
List<User> getOrgMemberList(@Param("orgMember") QueryOrgMemberRequest request); List<User> getOrgMemberList(@Param("orgMember") QueryOrgMemberRequest request);
List<OrganizationMemberDTO> getOrganizationMemberDTO(@Param("orgMember") QueryOrgMemberRequest request);
} }

View File

@ -2,6 +2,21 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="io.metersphere.base.mapper.ext.ExtUserRoleMapper"> <mapper namespace="io.metersphere.base.mapper.ext.ExtUserRoleMapper">
<resultMap id="BaseOrganizationMemberDTOMap" type="io.metersphere.dto.OrganizationMemberDTO">
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="email" jdbcType="VARCHAR" property="email" />
<result column="phone" jdbcType="VARCHAR" property="phone" />
<result column="status" jdbcType="VARCHAR" property="status" />
<result column="create_time" jdbcType="BIGINT" property="createTime" />
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
<result column="language" jdbcType="VARCHAR" property="language" />
<collection property="roles" ofType="io.metersphere.base.domain.Role">
<id column="rid" jdbcType="VARCHAR" property="id" />
<result column="rname" jdbcType="VARCHAR" property="name" />
</collection>
</resultMap>
<select id="getUserRoleHelpList" parameterType="java.lang.String" <select id="getUserRoleHelpList" parameterType="java.lang.String"
resultType="io.metersphere.dto.UserRoleHelpDTO"> resultType="io.metersphere.dto.UserRoleHelpDTO">
SELECT SELECT
@ -38,4 +53,16 @@
</if> </if>
</select> </select>
<select id="getOrganizationMemberDTO" resultMap="BaseOrganizationMemberDTOMap">
select u.id, u.name, u.email, u.language, u.create_time, u.update_time, u.phone,
o.id, o.name, ur.id, r.id as rid, r.name as rname
from organization o
join user_role ur on o.id = ur.source_id
join user u on ur.user_id = u.id
join role r on r.id = ur.role_id
where o.id = #{orgMember.organizationId}
</select>
</mapper> </mapper>

View File

@ -10,6 +10,7 @@ import io.metersphere.controller.request.member.AddMemberRequest;
import io.metersphere.controller.request.member.QueryMemberRequest; import io.metersphere.controller.request.member.QueryMemberRequest;
import io.metersphere.controller.request.organization.AddOrgMemberRequest; import io.metersphere.controller.request.organization.AddOrgMemberRequest;
import io.metersphere.controller.request.organization.QueryOrgMemberRequest; import io.metersphere.controller.request.organization.QueryOrgMemberRequest;
import io.metersphere.dto.OrganizationMemberDTO;
import io.metersphere.dto.UserDTO; import io.metersphere.dto.UserDTO;
import io.metersphere.dto.UserRoleDTO; import io.metersphere.dto.UserRoleDTO;
import io.metersphere.service.UserService; import io.metersphere.service.UserService;
@ -139,4 +140,10 @@ public class UserController {
return PageUtils.setPageInfo(page, userService.getOrgMemberList(request)); return PageUtils.setPageInfo(page, userService.getOrgMemberList(request));
} }
@PostMapping("/orgmemberdto/list/{goPage}/{pageSize}")
public Pager<List<OrganizationMemberDTO>> getOrganizationMemberDTO(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryOrgMemberRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, userService.getOrganizationMemberDTO(request));
}
} }

View File

@ -0,0 +1,98 @@
package io.metersphere.dto;
import io.metersphere.base.domain.Role;
import java.util.ArrayList;
import java.util.List;
public class OrganizationMemberDTO {
private String id;
private String name;
private String email;
private String phone;
private String status;
private Long createTime;
private Long updateTime;
private String language;
private List<Role> roles = new ArrayList<>();
public List<Role> getRoles() {
return roles;
}
public void setRoles(List<Role> roles) {
this.roles = roles;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public Long getCreateTime() {
return createTime;
}
public void setCreateTime(Long createTime) {
this.createTime = createTime;
}
public Long getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Long updateTime) {
this.updateTime = updateTime;
}
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language;
}
}

View File

@ -10,6 +10,7 @@ import io.metersphere.controller.request.member.AddMemberRequest;
import io.metersphere.controller.request.member.QueryMemberRequest; import io.metersphere.controller.request.member.QueryMemberRequest;
import io.metersphere.controller.request.organization.AddOrgMemberRequest; import io.metersphere.controller.request.organization.AddOrgMemberRequest;
import io.metersphere.controller.request.organization.QueryOrgMemberRequest; import io.metersphere.controller.request.organization.QueryOrgMemberRequest;
import io.metersphere.dto.OrganizationMemberDTO;
import io.metersphere.dto.UserDTO; import io.metersphere.dto.UserDTO;
import io.metersphere.dto.UserRoleDTO; import io.metersphere.dto.UserRoleDTO;
import io.metersphere.dto.UserRoleHelpDTO; import io.metersphere.dto.UserRoleHelpDTO;
@ -306,4 +307,8 @@ public class UserService {
example.createCriteria().andIdEqualTo(userId).andPasswordEqualTo(CodingUtil.md5(password)); example.createCriteria().andIdEqualTo(userId).andPasswordEqualTo(CodingUtil.md5(password));
return userMapper.countByExample(example) > 0; return userMapper.countByExample(example) > 0;
} }
public List<OrganizationMemberDTO> getOrganizationMemberDTO(QueryOrgMemberRequest request) {
return extUserRoleMapper.getOrganizationMemberDTO(request);
}
} }

View File

@ -16,6 +16,14 @@
<el-table-column prop="name" label="用户名"/> <el-table-column prop="name" label="用户名"/>
<el-table-column prop="email" label="邮箱"/> <el-table-column prop="email" label="邮箱"/>
<el-table-column prop="phone" label="电话"/> <el-table-column prop="phone" label="电话"/>
<el-table-column prop="roles" label="角色" width="140">
<template slot-scope="scope">
<el-tag v-for="(role, index) in scope.row.roles" :key="index" size="mini" effect="dark">
{{ role.name }}
</el-tag>
</template>
</el-table-column>
<el-table-column> <el-table-column>
<template slot-scope="scope"> <template slot-scope="scope">
<el-button @click="del(scope.row)" type="danger" icon="el-icon-delete" size="mini" circle/> <el-button @click="del(scope.row)" type="danger" icon="el-icon-delete" size="mini" circle/>
@ -77,7 +85,7 @@
btnTips: "添加组织成员", btnTips: "添加组织成员",
createVisible: false, createVisible: false,
form: {}, form: {},
queryPath: "/user/orgmember/list", queryPath: "/user/orgmemberdto/list",
condition: "", condition: "",
tableData: [], tableData: [],
rules: { rules: {