Files
GuwandykA f1337706f0
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
swagger: document the ?lang= query parameter on every admin endpoint
appresult.Localize applies to all /api/admin routes, so each handler's
godoc now declares lang (tm, ru, en, all; default tm) and Swagger UI
offers it as a dropdown.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 22:08:32 +05:00

42 lines
1.3 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
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Router /permissions [get]
func (h *handler) list(c *gin.Context) {
c.JSON(http.StatusOK, appresult.SuccessWithData(perm.All))
}