package tool

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

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

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

	// iperf 网络性能测试工具
	iperfGroup := router.Group("/tool/iperf")
	{
		iperfGroup.GET("/v",
			middleware.AuthorizeUser(nil),
			controller.NewIPerf.Version,
		)
		iperfGroup.POST("/i",
			middleware.AuthorizeUser(nil),
			collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.iperf", collectlogs.BUSINESS_TYPE_OTHER)),
			controller.NewIPerf.Install,
		)
		iperfGroup.GET("/run",
			middleware.AuthorizeUser(nil),
			collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.iperf", collectlogs.BUSINESS_TYPE_OTHER)),
			controller.NewIPerf.Run,
		)
	}

	// ping ICMP网络探测工具
	pingGroup := router.Group("/tool/ping")
	{
		pingGroup.POST("",
			middleware.AuthorizeUser(nil),
			controller.NewPing.Statistics,
		)
		pingGroup.GET("",
			middleware.AuthorizeUser(nil),
			collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.ping", collectlogs.BUSINESS_TYPE_OTHER)),
			controller.NewPing.StatisticsOn,
		)
		pingGroup.GET("/v",
			middleware.AuthorizeUser(nil),
			controller.NewPing.Version,
		)
		pingGroup.GET("/run",
			middleware.AuthorizeUser(nil),
			collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.ping", collectlogs.BUSINESS_TYPE_OTHER)),
			controller.NewPing.Run,
		)
	}

	// MML 网元MML
	mml := controller.NewMML
	mmlGroup := router.Group("/tool/mml")
	{
		mmlGroup.GET("/system/list",
			middleware.AuthorizeUser(nil),
			mml.SystemList,
		)
		mmlGroup.GET("/subscriber/list",
			middleware.AuthorizeUser(nil),
			mml.SubscriberList,
		)
		mmlGroup.GET("/log/list",
			middleware.AuthorizeUser(nil),
			mml.LogList,
		)
		mmlGroup.POST("/command",
			middleware.AuthorizeUser(nil),
			mml.Command,
		)
	}

}
