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 模块路由")

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