package core

import (
	"be.ems/src/framework/logger"
	"be.ems/src/framework/middleware"
	"be.ems/src/framework/middleware/collectlogs"
	"be.ems/src/modules/core/controller"

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

// 模块路由注册
func Setup(router *gin.Engine) {
	logger.Infof("开始加载 ====> core 模块路由")

	// 核心网信息
	coreInfoGroup := router.Group("/core/info")
	{
		coreInfoGroup.GET("/list",
			middleware.AuthorizeUser(nil),
			controller.NewCoreInfo.List,
		)
		coreInfoGroup.GET("/:id",
			middleware.CryptoApi(false, true),
			middleware.AuthorizeUser(nil),
			controller.NewCoreInfo.Info,
		)
		coreInfoGroup.POST("",
			middleware.CryptoApi(true, true),
			middleware.AuthorizeUser(nil),
			collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.coreInfo", collectlogs.BUSINESS_TYPE_INSERT)),
			controller.NewCoreInfo.Add,
		)
		coreInfoGroup.PUT("",
			middleware.CryptoApi(true, true),
			middleware.AuthorizeUser(nil),
			collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.coreInfo", collectlogs.BUSINESS_TYPE_UPDATE)),
			controller.NewCoreInfo.Edit,
		)
		coreInfoGroup.DELETE(":id",
			middleware.AuthorizeUser(nil),
			collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.coreInfo", collectlogs.BUSINESS_TYPE_DELETE)),
			controller.NewCoreInfo.Remove,
		)
	}

}
