fix: UE事件AMF表命名变更
This commit is contained in:
@@ -24,7 +24,7 @@ import (
|
||||
// 实例化控制层 AMFController 结构体
|
||||
var NewAMFController = &AMFController{
|
||||
neInfoService: neService.NewNeInfoImpl,
|
||||
ueEventService: neDataService.NewUEEventImpl,
|
||||
ueEventService: neDataService.NewUEEventAMFImpl,
|
||||
}
|
||||
|
||||
// 网元AMF
|
||||
@@ -33,8 +33,8 @@ var NewAMFController = &AMFController{
|
||||
type AMFController struct {
|
||||
// 网元信息服务
|
||||
neInfoService neService.INeInfo
|
||||
// CDR会话事件服务
|
||||
ueEventService neDataService.IUEEvent
|
||||
// UE会话事件服务
|
||||
ueEventService neDataService.IUEEventAMF
|
||||
}
|
||||
|
||||
// UE会话列表
|
||||
@@ -42,7 +42,7 @@ type AMFController struct {
|
||||
// GET /ue/list
|
||||
func (s *AMFController) UEList(c *gin.Context) {
|
||||
language := ctx.AcceptLanguage(c)
|
||||
var querys model.UEEventQuery
|
||||
var querys model.UEEventAMFQuery
|
||||
if err := c.ShouldBindQuery(&querys); err != nil {
|
||||
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||
return
|
||||
@@ -93,7 +93,7 @@ func (s *AMFController) UERemove(c *gin.Context) {
|
||||
func (s *AMFController) UEExport(c *gin.Context) {
|
||||
language := ctx.AcceptLanguage(c)
|
||||
// 查询结果,根据查询条件结果,单页最大值限制
|
||||
var querys model.UEEventQuery
|
||||
var querys model.UEEventAMFQuery
|
||||
if err := c.ShouldBindBodyWith(&querys, binding.JSON); err != nil {
|
||||
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||
return
|
||||
@@ -108,7 +108,7 @@ func (s *AMFController) UEExport(c *gin.Context) {
|
||||
c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.exportEmpty")))
|
||||
return
|
||||
}
|
||||
rows := data["rows"].([]model.UEEvent)
|
||||
rows := data["rows"].([]model.UEEventAMF)
|
||||
|
||||
// 导出文件名称
|
||||
fileName := fmt.Sprintf("amf_ue_event_export_%d_%d.xlsx", len(rows), time.Now().UnixMilli())
|
||||
|
||||
@@ -2,20 +2,20 @@ package model
|
||||
|
||||
import "time"
|
||||
|
||||
// UEEvent UE会话对象 ue_event
|
||||
type UEEvent struct {
|
||||
// UEEventAMF UE会话对象 ue_event_amf
|
||||
type UEEventAMF struct {
|
||||
ID string `json:"id" gorm:"column:id;primaryKey;autoIncrement"`
|
||||
NeType string `json:"neType" gorm:"column:ne_type"`
|
||||
NeName string `json:"neName" gorm:"column:ne_name"`
|
||||
RmUID string `json:"rmUID" gorm:"column:rm_uid"` // 可能没有
|
||||
Timestamp int64 `json:"timestamp" gorm:"column:timestamp"`
|
||||
EventType string `json:"eventType" gorm:"column:event_type"`
|
||||
EventType string `json:"eventType" gorm:"column:event_type"` // 事件类型 auth-result detach cm-state
|
||||
EventJSONStr string `json:"eventJSON" gorm:"column:event_json"`
|
||||
CreatedAt time.Time `json:"createdAt" gorm:"column:created_at;default:CURRENT_TIMESTAMP"`
|
||||
}
|
||||
|
||||
// UEEventQuery UE会话对象查询参数结构体
|
||||
type UEEventQuery struct {
|
||||
// UEEventAMFQuery UE会话对象查询参数结构体
|
||||
type UEEventAMFQuery struct {
|
||||
NeType string `json:"neType" form:"neType" binding:"required"` // 网元类型, 暂时支持AMF
|
||||
NeID string `json:"neId" form:"neId" binding:"required"`
|
||||
RmUID string `json:"rmUID" form:"rmUID"`
|
||||
@@ -2,13 +2,13 @@ package repository
|
||||
|
||||
import "be.ems/src/modules/network_data/model"
|
||||
|
||||
// UE会话事件 数据层接口
|
||||
type IUEEvent interface {
|
||||
// UE会话事件AMF 数据层接口
|
||||
type IUEEventAMF interface {
|
||||
// SelectPage 根据条件分页查询
|
||||
SelectPage(querys model.UEEventQuery) map[string]any
|
||||
SelectPage(querys model.UEEventAMFQuery) map[string]any
|
||||
|
||||
// SelectByIds 通过ID查询
|
||||
SelectByIds(ueIds []string) []model.UEEvent
|
||||
SelectByIds(ueIds []string) []model.UEEventAMF
|
||||
|
||||
// DeleteByIds 批量删除信息
|
||||
DeleteByIds(ueIds []string) int64
|
||||
@@ -11,9 +11,9 @@ import (
|
||||
"be.ems/src/modules/network_data/model"
|
||||
)
|
||||
|
||||
// 实例化数据层 UEEventImpl 结构体
|
||||
var NewUEEventImpl = &UEEventImpl{
|
||||
selectSql: `select id, ne_type, ne_name, rm_uid, timestamp, event_type, event_json, created_at from ue_event`,
|
||||
// 实例化数据层 UEEventAMFImpl 结构体
|
||||
var NewUEEventAMFImpl = &UEEventAMFImpl{
|
||||
selectSql: `select id, ne_type, ne_name, rm_uid, timestamp, event_type, event_json, created_at from ue_event_amf`,
|
||||
|
||||
resultMap: map[string]string{
|
||||
"id": "ID",
|
||||
@@ -27,8 +27,8 @@ var NewUEEventImpl = &UEEventImpl{
|
||||
},
|
||||
}
|
||||
|
||||
// UEEventImpl UE会话事件 数据层处理
|
||||
type UEEventImpl struct {
|
||||
// UEEventAMFImpl UE会话事件 数据层处理
|
||||
type UEEventAMFImpl struct {
|
||||
// 查询视图对象SQL
|
||||
selectSql string
|
||||
// 结果字段与实体映射
|
||||
@@ -36,10 +36,10 @@ type UEEventImpl struct {
|
||||
}
|
||||
|
||||
// convertResultRows 将结果记录转实体结果组
|
||||
func (r *UEEventImpl) convertResultRows(rows []map[string]any) []model.UEEvent {
|
||||
arr := make([]model.UEEvent, 0)
|
||||
func (r *UEEventAMFImpl) convertResultRows(rows []map[string]any) []model.UEEventAMF {
|
||||
arr := make([]model.UEEventAMF, 0)
|
||||
for _, row := range rows {
|
||||
item := model.UEEvent{}
|
||||
item := model.UEEventAMF{}
|
||||
for key, value := range row {
|
||||
if keyMapper, ok := r.resultMap[key]; ok {
|
||||
repo.SetFieldValue(&item, keyMapper, value)
|
||||
@@ -51,7 +51,7 @@ func (r *UEEventImpl) convertResultRows(rows []map[string]any) []model.UEEvent {
|
||||
}
|
||||
|
||||
// SelectPage 根据条件分页查询
|
||||
func (r *UEEventImpl) SelectPage(querys model.UEEventQuery) map[string]any {
|
||||
func (r *UEEventAMFImpl) SelectPage(querys model.UEEventAMFQuery) map[string]any {
|
||||
// 查询条件拼接
|
||||
var conditions []string
|
||||
var params []any
|
||||
@@ -77,10 +77,6 @@ func (r *UEEventImpl) SelectPage(querys model.UEEventQuery) map[string]any {
|
||||
}
|
||||
params = append(params, querys.EndTime)
|
||||
}
|
||||
if querys.IMSI != "" {
|
||||
conditions = append(conditions, "JSON_EXTRACT(event_json, '$.imsi') = ?")
|
||||
params = append(params, querys.IMSI)
|
||||
}
|
||||
if querys.EventType != "" {
|
||||
eventTypes := strings.Split(querys.EventType, ",")
|
||||
placeholder := repo.KeyPlaceholderByQuery(len(eventTypes))
|
||||
@@ -89,6 +85,10 @@ func (r *UEEventImpl) SelectPage(querys model.UEEventQuery) map[string]any {
|
||||
params = append(params, eventType)
|
||||
}
|
||||
}
|
||||
if querys.IMSI != "" {
|
||||
conditions = append(conditions, "JSON_EXTRACT(event_json, '$.imsi') = ?")
|
||||
params = append(params, querys.IMSI)
|
||||
}
|
||||
|
||||
// 构建查询条件语句
|
||||
whereSql := ""
|
||||
@@ -98,11 +98,11 @@ func (r *UEEventImpl) SelectPage(querys model.UEEventQuery) map[string]any {
|
||||
|
||||
result := map[string]any{
|
||||
"total": 0,
|
||||
"rows": []model.UEEvent{},
|
||||
"rows": []model.UEEventAMF{},
|
||||
}
|
||||
|
||||
// 查询数量 长度为0直接返回
|
||||
totalSql := "select count(1) as 'total' from ue_event"
|
||||
totalSql := "select count(1) as 'total' from ue_event_amf"
|
||||
totalRows, err := datasource.RawDB("", totalSql+whereSql, params)
|
||||
if err != nil {
|
||||
logger.Errorf("total err => %v", err)
|
||||
@@ -148,23 +148,23 @@ func (r *UEEventImpl) SelectPage(querys model.UEEventQuery) map[string]any {
|
||||
}
|
||||
|
||||
// SelectByIds 通过ID查询
|
||||
func (r *UEEventImpl) SelectByIds(ueIds []string) []model.UEEvent {
|
||||
func (r *UEEventAMFImpl) SelectByIds(ueIds []string) []model.UEEventAMF {
|
||||
placeholder := repo.KeyPlaceholderByQuery(len(ueIds))
|
||||
querySql := r.selectSql + " where id in (" + placeholder + ")"
|
||||
parameters := repo.ConvertIdsSlice(ueIds)
|
||||
results, err := datasource.RawDB("", querySql, parameters)
|
||||
if err != nil {
|
||||
logger.Errorf("query err => %v", err)
|
||||
return []model.UEEvent{}
|
||||
return []model.UEEventAMF{}
|
||||
}
|
||||
// 转换实体
|
||||
return r.convertResultRows(results)
|
||||
}
|
||||
|
||||
// DeleteByIds 批量删除信息
|
||||
func (r *UEEventImpl) DeleteByIds(ueIds []string) int64 {
|
||||
func (r *UEEventAMFImpl) DeleteByIds(ueIds []string) int64 {
|
||||
placeholder := repo.KeyPlaceholderByQuery(len(ueIds))
|
||||
sql := "delete from ue_event where id in (" + placeholder + ")"
|
||||
sql := "delete from ue_event_amf where id in (" + placeholder + ")"
|
||||
parameters := repo.ConvertIdsSlice(ueIds)
|
||||
results, err := datasource.ExecDB("", sql, parameters)
|
||||
if err != nil {
|
||||
@@ -3,9 +3,9 @@ package service
|
||||
import "be.ems/src/modules/network_data/model"
|
||||
|
||||
// UE会话事件 服务层接口
|
||||
type IUEEvent interface {
|
||||
type IUEEventAMF interface {
|
||||
// SelectPage 根据条件分页查询
|
||||
SelectPage(querys model.UEEventQuery) map[string]any
|
||||
SelectPage(querys model.UEEventAMFQuery) map[string]any
|
||||
|
||||
// DeleteByIds 批量删除信息
|
||||
DeleteByIds(ueIds []string) (int64, error)
|
||||
@@ -7,24 +7,24 @@ import (
|
||||
"be.ems/src/modules/network_data/repository"
|
||||
)
|
||||
|
||||
// 实例化数据层 UEEventImpl 结构体
|
||||
var NewUEEventImpl = &UEEventImpl{
|
||||
ueEventRepository: repository.NewUEEventImpl,
|
||||
// 实例化数据层 UEEventAMFImpl 结构体
|
||||
var NewUEEventAMFImpl = &UEEventAMFImpl{
|
||||
ueEventRepository: repository.NewUEEventAMFImpl,
|
||||
}
|
||||
|
||||
// UEEventImpl UE会话事件 服务层处理
|
||||
type UEEventImpl struct {
|
||||
// UEEventAMFImpl UE会话事件 服务层处理
|
||||
type UEEventAMFImpl struct {
|
||||
// UE会话事件数据信息
|
||||
ueEventRepository repository.IUEEvent
|
||||
ueEventRepository repository.IUEEventAMF
|
||||
}
|
||||
|
||||
// SelectPage 根据条件分页查询
|
||||
func (r *UEEventImpl) SelectPage(querys model.UEEventQuery) map[string]any {
|
||||
func (r *UEEventAMFImpl) SelectPage(querys model.UEEventAMFQuery) map[string]any {
|
||||
return r.ueEventRepository.SelectPage(querys)
|
||||
}
|
||||
|
||||
// DeleteByIds 批量删除信息
|
||||
func (r *UEEventImpl) DeleteByIds(ueIds []string) (int64, error) {
|
||||
func (r *UEEventAMFImpl) DeleteByIds(ueIds []string) (int64, error) {
|
||||
// 检查是否存在
|
||||
ids := r.ueEventRepository.SelectByIds(ueIds)
|
||||
if len(ids) <= 0 {
|
||||
Reference in New Issue
Block a user