package chart

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

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

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

	chartGroup := router.Group("/chart")

	// 关系图
	chartGraphGroup := chartGroup.Group("/graph")
	{
		chartGraphGroup.GET("",
			middleware.PreAuthorize(nil),
			controller.NewChartGraph.Load,
		)
		chartGraphGroup.GET("/groups",
			middleware.PreAuthorize(nil),
			controller.NewChartGraph.GroupNames,
		)
		chartGraphGroup.POST("",
			middleware.PreAuthorize(nil),
			collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.chartGraph", collectlogs.BUSINESS_TYPE_UPDATE)),
			controller.NewChartGraph.Save,
		)
		chartGraphGroup.DELETE("/:group",
			middleware.PreAuthorize(nil),
			collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.chartGraph", collectlogs.BUSINESS_TYPE_DELETE)),
			controller.NewChartGraph.Delete,
		)
	}
}
