ch role list added name
Some checks failed
CI/CD / Vet, test, build (push) Has been cancelled
CI/CD / Docker image (push) Has been cancelled
CI/CD / Deploy binary to server (push) Has been cancelled

This commit is contained in:
2026-09-30 13:44:10 +05:00
parent 5ab17b1539
commit 6f54e9c20b
2 changed files with 4 additions and 3 deletions

View File

@@ -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)

View File

@@ -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"`