ch role list added name
This commit is contained in:
@@ -45,7 +45,7 @@ func (r *repository) List(ctx context.Context, filter role.ListFilter) (role.Lis
|
||||
}
|
||||
|
||||
args = append(args, filter.Limit, (filter.Page-1)*filter.Limit)
|
||||
query := fmt.Sprintf(`SELECT r.id, r.code, r.scope,
|
||||
query := fmt.Sprintf(`SELECT r.id, r.code, r.name, r.scope,
|
||||
(SELECT COUNT(*) FROM users u WHERE u.role_id = r.id AND u.deleted_at IS NULL)
|
||||
FROM roles r%s ORDER BY r.id LIMIT $%d OFFSET $%d`,
|
||||
where, len(args)-1, len(args))
|
||||
@@ -59,7 +59,7 @@ func (r *repository) List(ctx context.Context, filter role.ListFilter) (role.Lis
|
||||
for rows.Next() {
|
||||
var item role.RoleListItemDTO
|
||||
var scope string
|
||||
if err := rows.Scan(&item.Id, &item.Code, &scope, &item.UsersCount); err != nil {
|
||||
if err := rows.Scan(&item.Id, &item.Code, &item.Name, &scope, &item.UsersCount); err != nil {
|
||||
return role.ListRoleDTO{}, err
|
||||
}
|
||||
item.Scope = rbac.Scope(scope)
|
||||
|
||||
@@ -51,11 +51,12 @@ type ListFilter struct {
|
||||
Limit int
|
||||
}
|
||||
|
||||
// RoleListItemDTO is the list row; name, permissions and the rest come from
|
||||
// RoleListItemDTO is the list row; permissions and the rest come from
|
||||
// GET /roles/:id.
|
||||
type RoleListItemDTO struct {
|
||||
Id int64 `json:"id"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Scope rbac.Scope `json:"scope"`
|
||||
ScopeName string `json:"scopeName"`
|
||||
UsersCount int64 `json:"usersCount"`
|
||||
|
||||
Reference in New Issue
Block a user