package controller

import (
	"fmt"

	"be.ems/src/framework/resp"
	"be.ems/src/modules/ne_data/model"
	neDataService "be.ems/src/modules/ne_data/service"

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

// 实例化控制层 AlarmForwardController 结构体
var NewAlarmForward = &AlarmForwardController{
	alarmForwardLogService: neDataService.NewAlarmForwardLog,
}

// 告警数据
//
// PATH /alarm/forward
type AlarmForwardController struct {
	alarmForwardLogService *neDataService.AlarmForwardLog // 告警转发记录服务
}

// 告警转发日志列表
//
// GET /log/list
//
//	@Tags			ne_data/alarm_forward
//	@Accept			json
//	@Produce		json
//	@Param			neType		query		string	false	"NE Type"											Enums(IMS,AMF,AUSF,UDM,SMF,PCF,NSSF,NRF,UPF,MME,CBC,OMC,SGWC,SMSC)	Enums(1,2,3,4)
//	@Param			sortField	query		string	false	"Sort fields, fill in result fields"				default(event_time)
//	@Param			sortOrder	query		string	false	"Sort by ascending or descending order, asc desc"	default(asc)
//	@Param			pageNum		query		number	true	"pageNum"											default(1)
//	@Param			pageSize	query		number	true	"pageSize"											default(10)
//	@Success		200			{object}	object	"Response Results"
//	@Security		TokenAuth
//	@Summary		Alarm Forward Log List
//	@Description	Alarm Forward Log List
//	@Router			/neData/alarm/forward/log/list [get]
func (s AlarmForwardController) List(c *gin.Context) {
	var query model.AlarmForwardLogQuery
	if err := c.ShouldBindQuery(&query); err != nil {
		errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
		c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs))
		return
	}
	// 查询数据
	rows, total := s.alarmForwardLogService.FindByPage(query)
	c.JSON(200, resp.OkData(map[string]any{"rows": rows, "total": total}))
}
