Files
online-backend/internal/identity/permission/handler.go
GuwandykA 323e131216
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
changed role permission
2026-09-26 16:34:28 +05:00

41 lines
1.2 KiB
Go

package permission
import (
"net/http"
"online-back/internal/appresult"
"online-back/internal/handlers"
"online-back/internal/identity/rbac"
"online-back/internal/identity/rbac/perm"
"github.com/gin-gonic/gin"
)
const baseURL = "/permissions"
// handler serves the permission catalog. Permissions are defined in code
// (rbac/perm) - one per module - so there is nothing to create or edit here;
// roles pick from this list via POST/PUT /roles.
type handler struct{}
func NewHandler() handlers.Handler {
return &handler{}
}
func (h *handler) Register(router *gin.RouterGroup) {
group := rbac.Group(router, baseURL, rbac.RequireStaff(perm.Roles))
group.GET("", h.list)
}
// list godoc
// @Summary List permissions
// @Description Returns the permission catalog: one code per module, in display order. Holding a code grants read and write in that module; the role's scope decides which records.
// @Tags permission
// @Produce json
// @Security BearerAuth
// @Success 200 {object} appresult.AppSuccess
// @Router /permissions [get]
func (h *handler) list(c *gin.Context) {
c.JSON(http.StatusOK, appresult.SuccessWithData(perm.All))
}