fix: export csv file contain tenant name

This commit is contained in:
2024-10-15 10:10:19 +08:00
parent 25232876b0
commit f592f1c544
11 changed files with 39 additions and 4 deletions

View File

@@ -130,6 +130,7 @@ func (s *IMSController) CDRExport(c *gin.Context) {
"F1": "Duration",
"G1": "Result",
"H1": "Time",
"I1": "Tenant Name", // for multi-tenancy
}
// 读取字典数据 CDR SIP响应代码类别类型
dictCDRSipCode := sysService.NewSysDictDataImpl.SelectDictDataByType("cdr_sip_code")
@@ -195,6 +196,11 @@ func (s *IMSController) CDRExport(c *gin.Context) {
releaseTime := parse.Number(v)
timeStr = date.ParseDateToStr(releaseTime, date.YYYY_MM_DDTHH_MM_SSZ)
}
// tenant name
tenantName := ""
if v, ok := cdrJSON["tenantName"]; ok && v != nil {
tenantName = v.(string)
}
dataCells = append(dataCells, map[string]any{
"A" + idx: row.ID,
@@ -205,6 +211,7 @@ func (s *IMSController) CDRExport(c *gin.Context) {
"F" + idx: duration,
"G" + idx: callResult,
"H" + idx: timeStr,
"I" + idx: tenantName,
})
}

View File

@@ -134,6 +134,7 @@ func (s *SMFController) CDRExport(c *gin.Context) {
"H1": "Duration",
"I1": "Invocation Time",
"J1": "PDU Session Charging Information",
"K1": "Tenant Name", // for multi-tenancy
}
// 从第二行开始的数据
dataCells := make([]map[string]any, 0)
@@ -243,6 +244,11 @@ PDU Type: %s
PDU IPv4 Address: %s
PDU IPv6 Addres Swith Prefix: %s`, User_Identifier, SSC_Mode, RAT_Type, DNN_ID, PDU_Type, PDU_IPv4, PDU_IPv6)
}
// Tenant Name
tenantName := ""
if v, ok := cdrJSON["tenantName"]; ok && v != nil {
tenantName = v.(string)
}
dataCells = append(dataCells, map[string]any{
"A" + idx: row.ID,
@@ -255,6 +261,7 @@ PDU IPv6 Addres Swith Prefix: %s`, User_Identifier, SSC_Mode, RAT_Type, DNN_ID,
"H" + idx: duration,
"I" + idx: invocationTimestamp,
"J" + idx: pduSessionChargingInformation,
"K" + idx: tenantName,
})
}

View File

@@ -128,6 +128,7 @@ func (s *SMSCController) CDRExport(c *gin.Context) {
"E1": "Called",
"F1": "Result",
"G1": "Time",
"H1": "Tenant Name", // for multi-tenancy
}
// 从第二行开始的数据
dataCells := make([]map[string]any, 0)
@@ -174,6 +175,11 @@ func (s *SMSCController) CDRExport(c *gin.Context) {
releaseTime := parse.Number(v)
timeStr = date.ParseDateToStr(releaseTime, date.YYYY_MM_DDTHH_MM_SSZ)
}
// Tenant name
tenantName := ""
if v, ok := cdrJSON["tenantName"]; ok && v != nil {
tenantName = v.(string)
}
dataCells = append(dataCells, map[string]any{
"A" + idx: row.ID,
@@ -183,6 +189,7 @@ func (s *SMSCController) CDRExport(c *gin.Context) {
"E" + idx: called,
"F" + idx: callResult,
"G" + idx: timeStr,
"H" + idx: tenantName,
})
}

View File

@@ -11,6 +11,8 @@ type CDREventSMSC struct {
Timestamp int64 `json:"timestamp" gorm:"column:timestamp"`
CDRJSONStr string `json:"cdrJSON" gorm:"column:cdr_json"`
CreatedAt time.Time `json:"createdAt" gorm:"column:created_at;default:CURRENT_TIMESTAMP"`
TenantID string `json:"tenantID" gorm:"column:tenant_id"` // for multi-tenancy
TenantName string `json:"tenantName" gorm:"column:tenant_name"` // for multi-tenancy
}
// CDREventSMSCQuery CDR会话对象SMSC查询参数结构体
@@ -23,7 +25,7 @@ type CDREventSMSCQuery struct {
CalledParty string `json:"calledParty" form:"calledParty"` // 被叫号码
StartTime string `json:"startTime" form:"startTime"`
EndTime string `json:"endTime" form:"endTime"`
TenantName string `json:"tenantName" form:"tenantName"`
TenantName string `json:"tenantName" form:"tenantName"` // for multi-tenancy
UserName string `json:"userName" form:"userName"`
SortField string `json:"sortField" form:"sortField" binding:"omitempty,oneof=timestamp"` // 排序字段,填写结果字段
SortOrder string `json:"sortOrder" form:"sortOrder" binding:"omitempty,oneof=asc desc"` // 排序升降序asc desc

View File

@@ -151,6 +151,7 @@ func (s *SysLogOperateController) Export(c *gin.Context) {
"G1": i18n.TKey(language, "log.operate.export.status"),
"H1": i18n.TKey(language, "log.operate.export.operTime"),
"I1": i18n.TKey(language, "log.operate.export.costTime"),
"J1": i18n.TKey(language, "log.operate.export.tenantName"),
}
// 从第二行开始的数据
dataCells := make([]map[string]any, 0)
@@ -203,6 +204,7 @@ func (s *SysLogOperateController) Export(c *gin.Context) {
"G" + idx: statusValue,
"H" + idx: date.ParseDateToStr(row.OperTime, date.YYYY_MM_DDTHH_MM_SSZ),
"I" + idx: row.CostTime,
"J" + idx: row.TenantName,
})
}