changed role permission
This commit is contained in:
1 parent
f0ecf23879
commit
323e131216
74 files changed
+2915
-4713
No files matched your search
@@ -31,14 +31,7 @@ var activityLogColumnsSQL = strings.Join(activityLogColumns, ", ")
|
||||
|
||||
const activityLogFromClause = ` FROM activity_logs al
|
||||
LEFT JOIN users u ON u.id = al.user_id
|
||||
LEFT JOIN LATERAL (
|
||||
SELECT ru.role_id
|
||||
FROM role_user ru
|
||||
WHERE ru.user_id = u.id
|
||||
ORDER BY ru.id
|
||||
LIMIT 1
|
||||
) ru ON true
|
||||
LEFT JOIN roles r ON r.id = ru.role_id`
|
||||
LEFT JOIN roles r ON r.id = u.role_id`
|
||||
|
||||
const activityLogSelectColumns = `al.id, al.user_id, al.method, al.path, al.module, al.action, al.status_code, al.request_body, al.ip, al.created_at, COALESCE(u.username, ''), COALESCE(r.code, '')`
|
||||
|
||||
@@ -119,14 +112,7 @@ func (r *repository) Create(ctx context.Context, dto activitylog.CreateActivityL
|
||||
SELECT ` + activityLogSelectColumns + `
|
||||
FROM inserted al
|
||||
LEFT JOIN users u ON u.id = al.user_id
|
||||
LEFT JOIN LATERAL (
|
||||
SELECT ru.role_id
|
||||
FROM role_user ru
|
||||
WHERE ru.user_id = u.id
|
||||
ORDER BY ru.id
|
||||
LIMIT 1
|
||||
) ru ON true
|
||||
LEFT JOIN roles r ON r.id = ru.role_id`
|
||||
LEFT JOIN roles r ON r.id = u.role_id`
|
||||
|
||||
row := r.client.QueryRow(ctx, query,
|
||||
dto.UserId, dto.Method, dto.Path, dto.Module, dto.Action, dto.StatusCode, dto.RequestBody, dto.Ip,
|
||||
|
||||
@@ -8,6 +8,8 @@ import (
|
||||
|
||||
"online-back/internal/appresult"
|
||||
"online-back/internal/handlers"
|
||||
"online-back/internal/identity/rbac"
|
||||
"online-back/internal/identity/rbac/perm"
|
||||
"online-back/internal/shared"
|
||||
"online-back/pkg/logging"
|
||||
|
||||
@@ -29,14 +31,14 @@ func NewHandler(logger *logging.Logger, repository Repository) handlers.Handler
|
||||
// Register only wires read endpoints: activity log entries are written by
|
||||
// the Record middleware, never through the API.
|
||||
func (h *handler) Register(router *gin.RouterGroup) {
|
||||
group := router.Group(baseURL, appresult.JwtTokenCheck())
|
||||
group := rbac.Group(router, baseURL, rbac.RequireStaff(perm.ActivityLogs))
|
||||
group.GET("", h.list)
|
||||
group.GET("/:id", h.getByID)
|
||||
}
|
||||
|
||||
// list godoc
|
||||
// @Summary List activity logs
|
||||
// @Description Returns a paginated audit trail of user actions (create/update/delete). Each log includes the actor's username and role from role_user.
|
||||
// @Description Returns a paginated audit trail of user actions (create/update/delete). Each log includes the actor's username and role code.
|
||||
// @Tags activity-logs
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
|
||||
Reference in new issue
Block a user