...
|
...
|
@@ -106,8 +106,8 @@ func (rolesService *RolesService) RoleList(roleListQuery *query.RoleListQuery) ( |
|
|
result := []dto.RoleItem{}
|
|
|
for _, v := range roleList.Roles {
|
|
|
result = append(result, dto.RoleItem{
|
|
|
RoleId: strconv.Itoa(v.RoleID),
|
|
|
OrgId: strconv.Itoa(v.OrgID),
|
|
|
RoleId: strconv.Itoa(int(v.RoleID)),
|
|
|
OrgId: strconv.Itoa(int(v.OrgID)),
|
|
|
RoleName: v.RoleName,
|
|
|
Describe: v.Desc,
|
|
|
OrgName: v.Ext.OrgName,
|
...
|
...
|
@@ -121,6 +121,19 @@ func (rolesService *RolesService) RoleList(roleListQuery *query.RoleListQuery) ( |
|
|
|
|
|
// 编辑角色关联权限菜单的前置准备数据
|
|
|
func (rolesService *RolesService) RoleMenuBeforeEdit(roleMenuBeforeEditQuery *query.RoleMenuBeforeEditQuery) (interface{}, error) {
|
|
|
//creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
|
|
|
// roleMenuBeforeEditQuery.Operator.CompanyId,
|
|
|
// roleMenuBeforeEditQuery.Operator.OrgId,
|
|
|
// roleMenuBeforeEditQuery.Operator.UserId)
|
|
|
//roleId, _ := strconv.Atoi(roleMenuBeforeEditQuery.RoleId)
|
|
|
//roles, err := creationUserGateway.RoleSearch(allied_creation_user.ReqRoleSearch{
|
|
|
// OrgId: roleMenuBeforeEditQuery.Operator.OrgId,
|
|
|
// Limit: 999,
|
|
|
// RoleType: 1,
|
|
|
//})
|
|
|
//if err != nil {
|
|
|
// return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
//}
|
|
|
|
|
|
return nil, nil
|
|
|
}
|
...
|
...
|
@@ -131,11 +144,10 @@ func (rolesService *RolesService) RoleUserBeforeEdit(roleUserBeforeEditQuery *qu |
|
|
roleUserBeforeEditQuery.Operator.CompanyId,
|
|
|
roleUserBeforeEditQuery.Operator.OrgId,
|
|
|
roleUserBeforeEditQuery.Operator.UserId)
|
|
|
//roleId, _ := strconv.Atoi(roleUserBeforeEditQuery.RoleId)
|
|
|
|
|
|
roleId, _ := strconv.Atoi(roleUserBeforeEditQuery.RoleId)
|
|
|
roles, err := creationUserGateway.RoleSearch(allied_creation_user.ReqRoleSearch{
|
|
|
OrgId: roleUserBeforeEditQuery.Operator.OrgId,
|
|
|
Limit: 100,
|
|
|
Limit: 999,
|
|
|
RoleType: 1,
|
|
|
})
|
|
|
if err != nil {
|
...
|
...
|
@@ -151,6 +163,19 @@ func (rolesService *RolesService) RoleUserBeforeEdit(roleUserBeforeEditQuery *qu |
|
|
"orgs": orgs.Orgs,
|
|
|
"roles": roles.Roles,
|
|
|
}
|
|
|
// 有传入角色ID才返回关联角色用户数据
|
|
|
if roleId > 0 {
|
|
|
relatedUser, err := creationUserGateway.RoleGetRelatedUser(allied_creation_user.ReqRoleGetRelatedUser{
|
|
|
RoleId: int64(roleId),
|
|
|
})
|
|
|
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
result["notInRoleUser"] = relatedUser.NotInRoleUser
|
|
|
result["roleUser"] = relatedUser.RoleUser
|
|
|
}
|
|
|
|
|
|
return result, nil
|
|
|
}
|
|
|
|
...
|
...
|
@@ -186,14 +211,14 @@ func (rolesService *RolesService) RoleRemove(roleRemoveCommand *command.RoleRemo |
|
|
roleRemoveCommand.Operator.UserId)
|
|
|
|
|
|
var roleIds []int64
|
|
|
for _, v := range roleRemoveCommand.RoleId {
|
|
|
for _, v := range roleRemoveCommand.RoleIds {
|
|
|
id, err := strconv.Atoi(v)
|
|
|
if err == nil {
|
|
|
roleIds = append(roleIds, int64(id))
|
|
|
}
|
|
|
}
|
|
|
_, err := creationUserGateway.RoleRemove(allied_creation_user.ReqRoleRemove{
|
|
|
//TODO 修改 为 切片类型
|
|
|
roleIds,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
...
|
...
|
@@ -220,7 +245,7 @@ func (rolesService *RolesService) RoleUserAdd(roleUserAddCommand *command.RoleUs |
|
|
UserIds: userIds,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
return roleUserAddCommand, err
|
|
|
}
|
...
|
...
|
@@ -244,15 +269,27 @@ func (rolesService *RolesService) RoleUserDelete(roleUserDeleteCommand *command. |
|
|
UserIds: userIds,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
return roleUserDeleteCommand, err
|
|
|
}
|
|
|
|
|
|
// 角色下关联用户的数据
|
|
|
// 角色下关联用户的数据 (暂时不需要这个)
|
|
|
func (rolesService *RolesService) RoleUserInfo(roleUserInfoQuery *query.RoleUserInfoQuery) (interface{}, error) {
|
|
|
//TODO
|
|
|
return nil, nil
|
|
|
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
|
|
|
roleUserInfoQuery.Operator.CompanyId,
|
|
|
roleUserInfoQuery.Operator.OrgId,
|
|
|
roleUserInfoQuery.Operator.UserId)
|
|
|
relatedUser, err := creationUserGateway.RoleGetRelatedUser(allied_creation_user.ReqRoleGetRelatedUser{
|
|
|
RoleId: roleUserInfoQuery.RoleId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
var result = make(map[string]interface{})
|
|
|
result["notInRoleUser"] = relatedUser.NotInRoleUser
|
|
|
result["roleUser"] = relatedUser.RoleUser
|
|
|
return result, nil
|
|
|
}
|
|
|
|
|
|
func NewRolesService(options map[string]interface{}) *RolesService {
|
...
|
...
|
|