组织菜单成员列表角色列更改查询方式

This commit is contained in:
shiziyuan9527 2020-02-27 17:02:26 +08:00
parent 4fb03996c2
commit 84c779ce05
6 changed files with 68 additions and 2 deletions

View File

@ -1,5 +1,6 @@
package io.metersphere.base.mapper.ext; package io.metersphere.base.mapper.ext;
import io.metersphere.base.domain.Role;
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;
@ -19,5 +20,7 @@ public interface ExtUserRoleMapper {
List<OrganizationMemberDTO> getOrganizationMemberDTO(@Param("orgMember") QueryOrgMemberRequest request); List<OrganizationMemberDTO> getOrganizationMemberDTO(@Param("orgMember") QueryOrgMemberRequest request);
List<Role> getOrganizationMemberRoles(@Param("orgId") String orgId, @Param("userId") String userId);
} }

View File

@ -63,6 +63,14 @@
where o.id = #{orgMember.organizationId} where o.id = #{orgMember.organizationId}
</select> </select>
<select id="getOrganizationMemberRoles" resultType="io.metersphere.base.domain.Role">
select r.id, r.name
from organization o
join user_role ur on o.id = ur.source_id
join role r on r.id = ur.role_id
where o.id = #{orgId} and ur.user_id = #{userId}
</select>
</mapper> </mapper>

View File

@ -140,6 +140,9 @@ public class UserController {
return PageUtils.setPageInfo(page, userService.getOrgMemberList(request)); return PageUtils.setPageInfo(page, userService.getOrgMemberList(request));
} }
/**
* 查询组织成员列表 带角色信息
*/
@PostMapping("/orgmemberdto/list/{goPage}/{pageSize}") @PostMapping("/orgmemberdto/list/{goPage}/{pageSize}")
public Pager<List<OrganizationMemberDTO>> getOrganizationMemberDTO(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryOrgMemberRequest request) { public Pager<List<OrganizationMemberDTO>> getOrganizationMemberDTO(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryOrgMemberRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true); Page<Object> page = PageHelper.startPage(goPage, pageSize, true);

View File

@ -0,0 +1,23 @@
package io.metersphere.controller;
import io.metersphere.base.domain.Role;
import io.metersphere.service.UserRoleService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
@RequestMapping("userrole")
@RestController
public class UserRoleController {
@Resource
private UserRoleService userRoleService;
@GetMapping("/list/{orgId}/{userId}")
public List<Role> getOrganizationMemberRoles(@PathVariable String orgId, @PathVariable String userId) {
return userRoleService.getOrganizationMemberRoles(orgId, userId);
}
}

View File

@ -0,0 +1,22 @@
package io.metersphere.service;
import io.metersphere.base.domain.Role;
import io.metersphere.base.mapper.ext.ExtUserRoleMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
@Service
@Transactional(rollbackFor = Exception.class)
public class UserRoleService {
@Resource
private ExtUserRoleMapper extUserRoleMapper;
public List<Role> getOrganizationMemberRoles(String orgId, String userId) {
return extUserRoleMapper.getOrganizationMemberRoles(orgId, userId);
}
}

View File

@ -85,7 +85,7 @@
btnTips: "添加组织成员", btnTips: "添加组织成员",
createVisible: false, createVisible: false,
form: {}, form: {},
queryPath: "/user/orgmemberdto/list", queryPath: "/user/orgmember/list",
condition: "", condition: "",
tableData: [], tableData: [],
rules: { rules: {
@ -111,8 +111,15 @@
}; };
this.result = this.$post(this.buildPagePath(this.queryPath), param, response => { this.result = this.$post(this.buildPagePath(this.queryPath), param, response => {
let data = response.data; let data = response.data;
this.total = data.itemCount;
this.tableData = data.listObject; this.tableData = data.listObject;
let url = "/userrole/list/" + this.currentUser().lastOrganizationId;
for (let i = 0; i < this.tableData.length; i++) {
this.$get(url + "/" + this.tableData[i].id, response => {
let roles = response.data;
this.$set(this.tableData[i], "roles", roles);
})
}
this.total = data.itemCount;
}) })
}, },
buildPagePath(path) { buildPagePath(path) {