ch role list added name
This commit is contained in:
1 parent
5ab17b1539
commit
6f54e9c20b
2 files changed
+4
-3
No files matched your search
@@ -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)
|
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)
|
(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`,
|
FROM roles r%s ORDER BY r.id LIMIT $%d OFFSET $%d`,
|
||||||
where, len(args)-1, len(args))
|
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() {
|
for rows.Next() {
|
||||||
var item role.RoleListItemDTO
|
var item role.RoleListItemDTO
|
||||||
var scope string
|
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
|
return role.ListRoleDTO{}, err
|
||||||
}
|
}
|
||||||
item.Scope = rbac.Scope(scope)
|
item.Scope = rbac.Scope(scope)
|
||||||
|
|||||||
@@ -51,11 +51,12 @@ type ListFilter struct {
|
|||||||
Limit int
|
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.
|
// GET /roles/:id.
|
||||||
type RoleListItemDTO struct {
|
type RoleListItemDTO struct {
|
||||||
Id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
Code string `json:"code"`
|
Code string `json:"code"`
|
||||||
|
Name string `json:"name"`
|
||||||
Scope rbac.Scope `json:"scope"`
|
Scope rbac.Scope `json:"scope"`
|
||||||
ScopeName string `json:"scopeName"`
|
ScopeName string `json:"scopeName"`
|
||||||
UsersCount int64 `json:"usersCount"`
|
UsersCount int64 `json:"usersCount"`
|
||||||
|
|||||||
Reference in new issue
Block a user