...
|
...
|
@@ -66,11 +66,24 @@ func (rolesService *RolesService) RoleGet(roleGetQuery *query.RoleGetQuery) (int |
|
|
RoleId: int64(roleId),
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
accessMenus, err := creationUserGateway.RoleGetAccessMenus(allied_creation_user.ReqRoleGetAccessMenus{
|
|
|
RoleId: int64(roleId),
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
relatedUser, err := creationUserGateway.RoleGetRelatedUser(allied_creation_user.ReqRoleGetRelatedUser{
|
|
|
RoleId: int64(roleId),
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
//TODO 补充字段 :权限数据,关联用户数据
|
|
|
result := map[string]interface{}{
|
|
|
"role": roleData.Role,
|
|
|
"role": roleData,
|
|
|
"menus": accessMenus.Menus,
|
|
|
"users": relatedUser.RoleUser,
|
|
|
}
|
|
|
return result, nil
|
|
|
}
|
...
|
...
|
@@ -93,12 +106,13 @@ 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,
|
|
|
RoleType: v.RoleType,
|
|
|
Ext: v.Ext,
|
|
|
})
|
|
|
}
|
|
|
var cnt int64 = roleList.Count
|
...
|
...
|
@@ -107,14 +121,62 @@ 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
|
|
|
}
|
|
|
|
|
|
// 编辑角色关联用户的前置准备数据
|
|
|
func (rolesService *RolesService) RoleUserBeforeEdit(roleUserBeforeEditQuery *query.RoleUserBeforeEditQuery) (interface{}, error) {
|
|
|
//TODO
|
|
|
return nil, nil
|
|
|
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
|
|
|
roleUserBeforeEditQuery.Operator.CompanyId,
|
|
|
roleUserBeforeEditQuery.Operator.OrgId,
|
|
|
roleUserBeforeEditQuery.Operator.UserId)
|
|
|
roleId, _ := strconv.Atoi(roleUserBeforeEditQuery.RoleId)
|
|
|
roles, err := creationUserGateway.RoleSearch(allied_creation_user.ReqRoleSearch{
|
|
|
OrgId: roleUserBeforeEditQuery.Operator.OrgId,
|
|
|
Limit: 999,
|
|
|
RoleType: 1,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
orgs, err := creationUserGateway.OrgGetSubDepartment(allied_creation_user.ReqOrgGetSubDepartment{
|
|
|
OrgId: roleUserBeforeEditQuery.Operator.OrgId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
result := map[string]interface{}{
|
|
|
"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
|
|
|
}
|
|
|
|
|
|
// 角色编辑关联菜单权限
|
...
|
...
|
@@ -149,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.RoleBatchRemove(allied_creation_user.ReqRoleBatchRemove{
|
|
|
RoleIds: roleIds,
|
|
|
_, err := creationUserGateway.RoleRemove(allied_creation_user.ReqRoleRemove{
|
|
|
roleIds,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
...
|
...
|
@@ -183,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
|
|
|
}
|
...
|
...
|
@@ -207,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 {
|
...
|
...
|
|