Documentation
¶
Index ¶
- func NewPermissionModule(logger logging.Logger, deps *core.Dependencies) core.Module
- type ListPermissionsOptions
- type PermissionHandler
- type PermissionModule
- type PermissionService
- func (s *PermissionService) GetSyncStatus(ctx context.Context) (*SyncStatus, error)
- func (s *PermissionService) ListPermissions(ctx context.Context, opts ListPermissionsOptions) ([]*ent.Permission, int, error)
- func (s *PermissionService) SyncEndpoints(ctx context.Context) (*SyncEndpointsResult, error)
- type SyncEndpointsResult
- type SyncStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewPermissionModule ¶
Types ¶
type ListPermissionsOptions ¶
type ListPermissionsOptions struct {
Page int
PageSize int
Scope string
Status string
Keyword string
}
ListPermissionsOptions represents the query options for listing permissions.
type PermissionHandler ¶
type PermissionHandler struct {
// contains filtered or unexported fields
}
func NewPermissionHandler ¶
func NewPermissionHandler(service *PermissionService, logger logging.Logger) *PermissionHandler
func (*PermissionHandler) GetSyncStatus ¶
func (h *PermissionHandler) GetSyncStatus(w http.ResponseWriter, r *http.Request)
GetSyncStatus gets the status of endpoint synchronization. @Summary Get sync status @Description Get the status of API endpoint synchronization @Tags Permissions @Accept json @Produce json @Success 200 {object} SyncStatus @Failure 500 {object} responder.Error @Router /permissions/sync-status [get]
func (*PermissionHandler) ListPermissions ¶
func (h *PermissionHandler) ListPermissions(w http.ResponseWriter, r *http.Request)
ListPermissions handles listing permission codes. @Summary List permissions @Tags Permissions @Accept json @Produce json @Param page query int false "Page number" default(1) @Param pageSize query int false "Page size" default(50) @Param scope query string false "Scope filter (api/ui/data)" @Param status query string false "Status filter (active/deprecated)" @Param q query string false "Search keyword" @Success 200 {object} responder.Response @Failure 400 {object} responder.Error @Failure 500 {object} responder.Error @Router /permissions [get]
func (*PermissionHandler) SyncEndpoints ¶
func (h *PermissionHandler) SyncEndpoints(w http.ResponseWriter, r *http.Request)
SyncEndpoints synchronizes all API endpoints from code to database. @Summary Sync permissions @Description Scan all modules and sync API endpoints to database @Tags Permissions @Accept json @Produce json @Success 200 {object} SyncEndpointsResult @Failure 400 {object} responder.Error @Failure 500 {object} responder.Error @Router /permissions/sync [post]
type PermissionModule ¶
type PermissionModule struct {
// contains filtered or unexported fields
}
func (*PermissionModule) Name ¶
func (m *PermissionModule) Name() string
func (*PermissionModule) RegisterPrivateRoutes ¶
func (m *PermissionModule) RegisterPrivateRoutes(r chi.Router)
RegisterPrivateRoutes registers protected permission endpoints.
func (*PermissionModule) RegisterPublicRoutes ¶
func (m *PermissionModule) RegisterPublicRoutes(r chi.Router)
RegisterPublicRoutes - permission module has no public routes.
type PermissionService ¶
type PermissionService struct {
// contains filtered or unexported fields
}
func NewPermissionService ¶
func NewPermissionService(client *ent.Client, logger logging.Logger, router chi.Routes, syncer *permissionsync.Syncer) *PermissionService
func (*PermissionService) GetSyncStatus ¶
func (s *PermissionService) GetSyncStatus(ctx context.Context) (*SyncStatus, error)
GetSyncStatus gets the current sync status.
func (*PermissionService) ListPermissions ¶
func (s *PermissionService) ListPermissions(ctx context.Context, opts ListPermissionsOptions) ([]*ent.Permission, int, error)
ListPermissions retrieves permissions with optional filters and pagination.
func (*PermissionService) SyncEndpoints ¶
func (s *PermissionService) SyncEndpoints(ctx context.Context) (*SyncEndpointsResult, error)
SyncEndpoints scans all registered routes and syncs permissions to database.
type SyncEndpointsResult ¶
type SyncEndpointsResult struct {
TotalRoutes int `json:"totalRoutes"`
Created int `json:"created"`
Updated int `json:"updated"`
Deleted int `json:"deleted"`
CreatedRoutes []string `json:"createdRoutes,omitempty"`
UpdatedRoutes []string `json:"updatedRoutes,omitempty"`
DeletedRoutes []string `json:"deletedRoutes,omitempty"`
}
SyncEndpointsResult represents the result of a sync operation.