fix: UE事件AMF表命名变更
This commit is contained in:
@@ -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 {
|
||||
Reference in New Issue
Block a user