作者 yangfu

角色关联用户修改

... ... @@ -12,7 +12,7 @@ import (
type GetRoleRelatedUsersQuery struct {
OperateInfo *domain.OperateInfo `json:"-"`
// 组织ID
OrgId int64 `cname:"组织ID" json:"orgId,string,omitempty"`
OrgId int64 `cname:"组织ID" json:"orgId,omitempty"`
// 角色ID
RoleId int64 `cname:"角色ID" json:"roleId" valid:"Required"`
... ... @@ -20,6 +20,8 @@ type GetRoleRelatedUsersQuery struct {
DepartmentId int64 `cname:"部门编号" json:"departmentId,omitempty"`
// 只需要关联的用户 true:仅返回关联用户信息 false:返回所有其他信息(未关联的用户)
//OnlyRelatedUser bool `cname:"部门编号" json:"onlyRelatedUser,omitempty"`
// 组织ID
InOrgIds []int64 `cname:"组织ID" json:"orgIds,omitempty"`
}
func (getRoleRelatedUsersQuery *GetRoleRelatedUsersQuery) Valid(validation *validation.Validation) {
... ...
... ... @@ -218,10 +218,15 @@ func (roleService *RoleService) GetRoleRelatedUsers(getRoleRelatedUsersQuery *qu
}
queryOptions := make(map[string]interface{})
queryOptions["companyId"] = role.CompanyId
queryOptions["organizationId"] = getRoleRelatedUsersQuery.OrgId
if getRoleRelatedUsersQuery.DepartmentId > 0 {
queryOptions["departmentId"] = getRoleRelatedUsersQuery.DepartmentId
}
// 按组织过滤
if len(getRoleRelatedUsersQuery.InOrgIds) > 0 {
queryOptions["inOrgIds"] = getRoleRelatedUsersQuery.InOrgIds
} else {
queryOptions["organizationId"] = getRoleRelatedUsersQuery.OrgId
}
queryOptions["userType"] = domain.UserTypeEmployee
_, users, err := userRepository.Find(queryOptions)
if err != nil {
... ...
... ... @@ -92,6 +92,17 @@ func (controller *RoleController) GetRoleRelatedUsers() {
controller.Response(data, err)
}
func (controller *RoleController) RoleRelatedUsers() {
roleService := service.NewRoleService(nil)
getRoleRelatedUsersQuery := &query.GetRoleRelatedUsersQuery{}
controller.Unmarshal(getRoleRelatedUsersQuery)
roleId, _ := controller.GetInt64(":roleId")
getRoleRelatedUsersQuery.RoleId = roleId
getRoleRelatedUsersQuery.OperateInfo = ParseOperateInfo(controller.BaseController)
data, err := roleService.GetRoleRelatedUsers(getRoleRelatedUsersQuery)
controller.Response(data, err)
}
func (controller *RoleController) GetRoleAccessMenus() {
roleService := service.NewRoleService(nil)
getRoleAccessMenusQuery := &query.GetRoleAccessMenusQuery{}
... ...
... ... @@ -12,6 +12,7 @@ func init() {
web.Router("/role/:roleId", &controllers.RoleController{}, "Delete:RemoveRole")
web.Router("/role/search", &controllers.RoleController{}, "Post:SearchRole")
web.Router("/role/:roleId/related-user", &controllers.RoleController{}, "Get:GetRoleRelatedUsers")
web.Router("/role/:roleId/related-user", &controllers.RoleController{}, "Post:RoleRelatedUsers")
web.Router("/role/:roleId/access-menus", &controllers.RoleController{}, "Get:GetRoleAccessMenus")
web.Router("/role/:roleId/access-menus", &controllers.RoleController{}, "Put:UpdateRoleAccessMenus")
web.Router("/role/assign", &controllers.RoleController{}, "Post:AssginRoleToUsers")
... ...