package processor

import (
	"encoding/json"
	"fmt"

	"nms_nbi/src/framework/logger"
	"nms_nbi/src/framework/vo/result"
	neDataModel "nms_nbi/src/modules/network_data/model"
	neDataService "nms_nbi/src/modules/network_data/service"
)

// GetUEConnect 获取UE会话事件-AMF
func GetUEConnect(requestID string, data any) ([]byte, error) {
	msgByte, _ := json.Marshal(data)
	var query neDataModel.UEEventQuery
	err := json.Unmarshal(msgByte, &query)
	if err != nil {
		logger.Warnf("ws processor GetUEConnect err: %s", err.Error())
		return nil, fmt.Errorf("query data structure error")
	}

	dataMap := neDataService.NewUEEventImpl.SelectPage(query)
	resultByte, err := json.Marshal(result.Ok(map[string]any{
		"requestId": requestID,
		"data":      dataMap,
	}))
	return resultByte, err
}
