package system

import (
	"kra/internal/server/middleware"

	"github.com/gin-gonic/gin"
)

type ApiRouter struct{}

func (r *ApiRouter) InitApiRouter(Router *gin.RouterGroup, PublicRouter *gin.RouterGroup) {
	apiRouter := Router.Group("api").Use(middleware.OperationRecordMiddleware())
	apiRouterWithoutRecord := Router.Group("api")
	apiPublicRouter := PublicRouter.Group("api")
	{
		apiRouter.POST("createApi", apiApi.CreateApi)
		apiRouter.POST("deleteApi", apiApi.DeleteApi)
		apiRouter.POST("updateApi", apiApi.UpdateApi)
		apiRouter.POST("getApiById", apiApi.GetApiById)
		apiRouter.DELETE("deleteApisByIds", apiApi.DeleteApisByIds)
		apiRouter.POST("ignoreApi", apiApi.IgnoreApi)
		apiRouter.POST("enterSyncApi", apiApi.EnterSyncApi)
	}
	{
		apiRouterWithoutRecord.POST("getAllApis", apiApi.GetAllApis)
		apiRouterWithoutRecord.POST("getApiList", apiApi.GetApiList)
		apiRouterWithoutRecord.GET("syncApi", apiApi.SyncApi)
		apiRouterWithoutRecord.GET("getApiGroups", apiApi.GetApiGroups)
	}
	{
		apiPublicRouter.GET("freshCasbin", apiApi.FreshCasbin)
	}
}
