package routes

import (
	"github.com/gofiber/fiber/v2"

	"github.com/break/junhong_cmp_fiber/internal/handler/admin"
	"github.com/break/junhong_cmp_fiber/internal/model/dto"
	"github.com/break/junhong_cmp_fiber/pkg/openapi"
)

func registerAuthorizationRoutes(router fiber.Router, handler *admin.AuthorizationHandler, doc *openapi.Generator, basePath string) {
	authorizations := router.Group("/authorizations")
	groupPath := basePath + "/authorizations"

	Register(authorizations, doc, groupPath, "GET", "", handler.List, RouteSpec{
		Summary: "授权记录列表",
		Tags:    []string{"授权记录管理"},
		Input:   new(dto.AuthorizationListReq),
		Output:  new(dto.AuthorizationListResp),
		Auth:    true,
	})

	Register(authorizations, doc, groupPath, "GET", "/:id", handler.GetDetail, RouteSpec{
		Summary: "授权记录详情",
		Tags:    []string{"授权记录管理"},
		Input:   new(dto.AuthorizationDetailReq),
		Output:  new(dto.AuthorizationItem),
		Auth:    true,
	})

	Register(authorizations, doc, groupPath, "PUT", "/:id/remark", handler.UpdateRemark, RouteSpec{
		Summary: "修改授权备注",
		Tags:    []string{"授权记录管理"},
		Input:   new(dto.UpdateAuthorizationRemarkReq),
		Output:  new(dto.AuthorizationItem),
		Auth:    true,
	})
}
