作者 yangfu

角色关联用户修改

@@ -12,7 +12,7 @@ import ( @@ -12,7 +12,7 @@ import (
12 type GetRoleRelatedUsersQuery struct { 12 type GetRoleRelatedUsersQuery struct {
13 OperateInfo *domain.OperateInfo `json:"-"` 13 OperateInfo *domain.OperateInfo `json:"-"`
14 // 组织ID 14 // 组织ID
15 - OrgId int64 `cname:"组织ID" json:"orgId,string,omitempty"` 15 + OrgId int64 `cname:"组织ID" json:"orgId,omitempty"`
16 16
17 // 角色ID 17 // 角色ID
18 RoleId int64 `cname:"角色ID" json:"roleId" valid:"Required"` 18 RoleId int64 `cname:"角色ID" json:"roleId" valid:"Required"`
@@ -20,6 +20,8 @@ type GetRoleRelatedUsersQuery struct { @@ -20,6 +20,8 @@ type GetRoleRelatedUsersQuery struct {
20 DepartmentId int64 `cname:"部门编号" json:"departmentId,omitempty"` 20 DepartmentId int64 `cname:"部门编号" json:"departmentId,omitempty"`
21 // 只需要关联的用户 true:仅返回关联用户信息 false:返回所有其他信息(未关联的用户) 21 // 只需要关联的用户 true:仅返回关联用户信息 false:返回所有其他信息(未关联的用户)
22 //OnlyRelatedUser bool `cname:"部门编号" json:"onlyRelatedUser,omitempty"` 22 //OnlyRelatedUser bool `cname:"部门编号" json:"onlyRelatedUser,omitempty"`
  23 + // 组织ID
  24 + InOrgIds []int64 `cname:"组织ID" json:"orgIds,omitempty"`
23 } 25 }
24 26
25 func (getRoleRelatedUsersQuery *GetRoleRelatedUsersQuery) Valid(validation *validation.Validation) { 27 func (getRoleRelatedUsersQuery *GetRoleRelatedUsersQuery) Valid(validation *validation.Validation) {
@@ -218,10 +218,15 @@ func (roleService *RoleService) GetRoleRelatedUsers(getRoleRelatedUsersQuery *qu @@ -218,10 +218,15 @@ func (roleService *RoleService) GetRoleRelatedUsers(getRoleRelatedUsersQuery *qu
218 } 218 }
219 queryOptions := make(map[string]interface{}) 219 queryOptions := make(map[string]interface{})
220 queryOptions["companyId"] = role.CompanyId 220 queryOptions["companyId"] = role.CompanyId
221 - queryOptions["organizationId"] = getRoleRelatedUsersQuery.OrgId  
222 if getRoleRelatedUsersQuery.DepartmentId > 0 { 221 if getRoleRelatedUsersQuery.DepartmentId > 0 {
223 queryOptions["departmentId"] = getRoleRelatedUsersQuery.DepartmentId 222 queryOptions["departmentId"] = getRoleRelatedUsersQuery.DepartmentId
224 } 223 }
  224 + // 按组织过滤
  225 + if len(getRoleRelatedUsersQuery.InOrgIds) > 0 {
  226 + queryOptions["inOrgIds"] = getRoleRelatedUsersQuery.InOrgIds
  227 + } else {
  228 + queryOptions["organizationId"] = getRoleRelatedUsersQuery.OrgId
  229 + }
225 queryOptions["userType"] = domain.UserTypeEmployee 230 queryOptions["userType"] = domain.UserTypeEmployee
226 _, users, err := userRepository.Find(queryOptions) 231 _, users, err := userRepository.Find(queryOptions)
227 if err != nil { 232 if err != nil {
@@ -92,6 +92,17 @@ func (controller *RoleController) GetRoleRelatedUsers() { @@ -92,6 +92,17 @@ func (controller *RoleController) GetRoleRelatedUsers() {
92 controller.Response(data, err) 92 controller.Response(data, err)
93 } 93 }
94 94
  95 +func (controller *RoleController) RoleRelatedUsers() {
  96 + roleService := service.NewRoleService(nil)
  97 + getRoleRelatedUsersQuery := &query.GetRoleRelatedUsersQuery{}
  98 + controller.Unmarshal(getRoleRelatedUsersQuery)
  99 + roleId, _ := controller.GetInt64(":roleId")
  100 + getRoleRelatedUsersQuery.RoleId = roleId
  101 + getRoleRelatedUsersQuery.OperateInfo = ParseOperateInfo(controller.BaseController)
  102 + data, err := roleService.GetRoleRelatedUsers(getRoleRelatedUsersQuery)
  103 + controller.Response(data, err)
  104 +}
  105 +
95 func (controller *RoleController) GetRoleAccessMenus() { 106 func (controller *RoleController) GetRoleAccessMenus() {
96 roleService := service.NewRoleService(nil) 107 roleService := service.NewRoleService(nil)
97 getRoleAccessMenusQuery := &query.GetRoleAccessMenusQuery{} 108 getRoleAccessMenusQuery := &query.GetRoleAccessMenusQuery{}
@@ -12,6 +12,7 @@ func init() { @@ -12,6 +12,7 @@ func init() {
12 web.Router("/role/:roleId", &controllers.RoleController{}, "Delete:RemoveRole") 12 web.Router("/role/:roleId", &controllers.RoleController{}, "Delete:RemoveRole")
13 web.Router("/role/search", &controllers.RoleController{}, "Post:SearchRole") 13 web.Router("/role/search", &controllers.RoleController{}, "Post:SearchRole")
14 web.Router("/role/:roleId/related-user", &controllers.RoleController{}, "Get:GetRoleRelatedUsers") 14 web.Router("/role/:roleId/related-user", &controllers.RoleController{}, "Get:GetRoleRelatedUsers")
  15 + web.Router("/role/:roleId/related-user", &controllers.RoleController{}, "Post:RoleRelatedUsers")
15 web.Router("/role/:roleId/access-menus", &controllers.RoleController{}, "Get:GetRoleAccessMenus") 16 web.Router("/role/:roleId/access-menus", &controllers.RoleController{}, "Get:GetRoleAccessMenus")
16 web.Router("/role/:roleId/access-menus", &controllers.RoleController{}, "Put:UpdateRoleAccessMenus") 17 web.Router("/role/:roleId/access-menus", &controllers.RoleController{}, "Put:UpdateRoleAccessMenus")
17 web.Router("/role/assign", &controllers.RoleController{}, "Post:AssginRoleToUsers") 18 web.Router("/role/assign", &controllers.RoleController{}, "Post:AssginRoleToUsers")