package networkdata

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

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

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

	neDataGroup := router.Group("/neData")

	// 性能统计信息
	kpiGroup := neDataGroup.Group("/kpi")
	{
		kpiGroup.GET("/title",
			middleware.PreAuthorize(nil),
			controller.NewPerfKPIController.Title,
		)
		kpiGroup.GET("/data",
			middleware.PreAuthorize(nil),
			controller.NewPerfKPIController.GoldKPI,
		)
	}

	// 告警数据信息
	alarmGroup := neDataGroup.Group("/alarm")
	{
		alarmGroup.GET("/list",
			middleware.PreAuthorize(nil),
			controller.NewAlarmController.List,
		)
		alarmGroup.DELETE("/:alarmIds",
			middleware.PreAuthorize(nil),
			controller.NewAlarmController.Remove,
		)
	}

	// 网元IMS
	imsGroup := neDataGroup.Group("/ims")
	{
		// CDR会话事件列表
		imsGroup.GET("/cdr/list",
			middleware.PreAuthorize(nil),
			controller.NewIMSController.CDRList,
		)
		// CDR会话删除
		imsGroup.DELETE("/cdr/:cdrIds",
			middleware.PreAuthorize(nil),
			collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.imsCDR", collectlogs.BUSINESS_TYPE_DELETE)),
			controller.NewIMSController.CDRRemove,
		)
	}

	// 网元AMF
	amfGroup := neDataGroup.Group("/amf")
	{
		// UE会话事件
		amfGroup.GET("/ue/list",
			middleware.PreAuthorize(nil),
			controller.NewAMFController.UEList,
		)
		// UE会话删除
		amfGroup.DELETE("/ue/:ueIds",
			middleware.PreAuthorize(nil),
			collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.amfUE", collectlogs.BUSINESS_TYPE_DELETE)),
			controller.NewAMFController.UERemove,
		)
	}

	// 网元UPF
	upfGroup := neDataGroup.Group("/upf")
	{
		upfGroup.GET("/totalFlow",
			middleware.PreAuthorize(nil),
			controller.NewUPFController.TotalFlow,
		)
	}

}
