style: UDM用户数据导出文件带createTime字段

This commit is contained in:
TsMask
2025-09-26 20:06:21 +08:00
parent c597f305ff
commit 395a4319df
4 changed files with 60 additions and 12 deletions

View File

@@ -499,13 +499,19 @@ func (s *UDMAuthController) Export(c *gin.Context) {
if fileType == "csv" {
// 转换数据
data := [][]string{}
data = append(data, []string{"imsi", "ki", "algo", "amf", "opc"})
data = append(data, []string{"imsi", "ki", "algo", "amf", "opc", "create_time"})
for _, v := range rows {
opc := v.Opc
if opc == "-" {
opc = ""
}
data = append(data, []string{v.IMSI, v.Ki, v.AlgoIndex, v.Amf, opc})
createTime := ""
if v.CreateTime == 0 {
createTime = time.Now().Format(time.RFC3339)
} else {
createTime = time.UnixMilli(v.CreateTime).Format(time.RFC3339)
}
data = append(data, []string{v.IMSI, v.Ki, v.AlgoIndex, v.Amf, opc, createTime})
}
// 输出到文件
if err := file.WriterFileCSV(data, filePath); err != nil {
@@ -522,7 +528,13 @@ func (s *UDMAuthController) Export(c *gin.Context) {
if opc == "-" {
opc = ""
}
data = append(data, []string{v.IMSI, v.Ki, v.AlgoIndex, v.Amf, opc})
createTime := ""
if v.CreateTime == 0 {
createTime = time.Now().Format(time.RFC3339)
} else {
createTime = time.UnixMilli(v.CreateTime).Format(time.RFC3339)
}
data = append(data, []string{v.IMSI, v.Ki, v.AlgoIndex, v.Amf, opc, createTime})
}
// 输出到文件
if err := file.WriterFileTXTLine(data, ",", filePath); err != nil {

View File

@@ -505,10 +505,16 @@ func (s *UDMSubController) Export(c *gin.Context) {
if fileType == "csv" {
// 转换数据
data := [][]string{}
data = append(data, []string{"IMSI", "MSISDN", "UeAmbrTpl", "NssaiTpl", "AreaForbiddenTpl", "ServiceAreaRestrictionTpl", "RatRestrictions", "CnTypeRestrictions", "SmfSel", "SmData", "EPSDat"})
data = append(data, []string{"IMSI", "MSISDN", "UeAmbrTpl", "NssaiTpl", "AreaForbiddenTpl", "ServiceAreaRestrictionTpl", "RatRestrictions", "CnTypeRestrictions", "SmfSel", "SmData", "EPSDat", "CreateTime"})
for _, v := range rows {
epsDat := fmt.Sprintf("%s,%s,%s,%s,%s,%s,%s,%s", v.EpsFlag, v.EpsOdb, v.HplmnOdb, v.Ard, v.Epstpl, v.ContextId, v.ApnContext, v.StaticIp)
data = append(data, []string{v.IMSI, v.MSISDN, v.UeAmbrTpl, v.NssaiTpl, v.AreaForbiddenTpl, v.ServiceAreaRestrictionTpl, v.RatRestrictions, v.CnTypeRestrictions, v.SmfSel, v.SmData, epsDat})
createTime := ""
if v.CreateTime == 0 {
createTime = time.Now().Format(time.RFC3339)
} else {
createTime = time.UnixMilli(v.CreateTime).Format(time.RFC3339)
}
data = append(data, []string{v.IMSI, v.MSISDN, v.UeAmbrTpl, v.NssaiTpl, v.AreaForbiddenTpl, v.ServiceAreaRestrictionTpl, v.RatRestrictions, v.CnTypeRestrictions, v.SmfSel, v.SmData, epsDat, createTime})
}
// 输出到文件
if err := file.WriterFileCSV(data, filePath); err != nil {
@@ -522,7 +528,13 @@ func (s *UDMSubController) Export(c *gin.Context) {
data := [][]string{}
for _, v := range rows {
epsDat := fmt.Sprintf("%s,%s,%s,%s,%s,%s,%s,%s", v.EpsFlag, v.EpsOdb, v.HplmnOdb, v.Ard, v.Epstpl, v.ContextId, v.ApnContext, v.StaticIp)
data = append(data, []string{v.IMSI, v.MSISDN, v.UeAmbrTpl, v.NssaiTpl, v.AreaForbiddenTpl, v.ServiceAreaRestrictionTpl, v.RatRestrictions, v.CnTypeRestrictions, v.SmfSel, v.SmData, epsDat})
createTime := ""
if v.CreateTime == 0 {
createTime = time.Now().Format(time.RFC3339)
} else {
createTime = time.UnixMilli(v.CreateTime).Format(time.RFC3339)
}
data = append(data, []string{v.IMSI, v.MSISDN, v.UeAmbrTpl, v.NssaiTpl, v.AreaForbiddenTpl, v.ServiceAreaRestrictionTpl, v.RatRestrictions, v.CnTypeRestrictions, v.SmfSel, v.SmData, epsDat, createTime})
}
// 输出到文件
if err := file.WriterFileTXTLine(data, ",", filePath); err != nil {

View File

@@ -437,9 +437,15 @@ func (s *UDMVOIPController) Export(c *gin.Context) {
if fileType == "csv" {
// 转换数据
data := [][]string{}
data = append(data, []string{"username", "password"})
data = append(data, []string{"username", "password", "createTime"})
for _, v := range rows {
data = append(data, []string{v.UserName, v.Password})
createTime := ""
if v.CreateTime == 0 {
createTime = time.Now().Format(time.RFC3339)
} else {
createTime = time.UnixMilli(v.CreateTime).Format(time.RFC3339)
}
data = append(data, []string{v.UserName, v.Password, createTime})
}
// 输出到文件
if err := file.WriterFileCSV(data, filePath); err != nil {
@@ -452,7 +458,13 @@ func (s *UDMVOIPController) Export(c *gin.Context) {
// 转换数据
data := [][]string{}
for _, v := range rows {
data = append(data, []string{v.UserName, v.Password})
createTime := ""
if v.CreateTime == 0 {
createTime = time.Now().Format(time.RFC3339)
} else {
createTime = time.UnixMilli(v.CreateTime).Format(time.RFC3339)
}
data = append(data, []string{v.UserName, v.Password, createTime})
}
// 输出到文件
if err := file.WriterFileTXTLine(data, ",", filePath); err != nil {

View File

@@ -481,9 +481,15 @@ func (s *UDMVolteIMSController) Export(c *gin.Context) {
if fileType == "csv" {
// 转换数据
data := [][]string{}
data = append(data, []string{"IMSI", "MSISDN", "TAG", "VNI"})
data = append(data, []string{"IMSI", "MSISDN", "TAG", "VNI", "CreateTime"})
for _, v := range rows {
data = append(data, []string{v.IMSI, v.MSISDN, v.Tag, v.VNI})
createTime := ""
if v.CreateTime == 0 {
createTime = time.Now().Format(time.RFC3339)
} else {
createTime = time.UnixMilli(v.CreateTime).Format(time.RFC3339)
}
data = append(data, []string{v.IMSI, v.MSISDN, v.Tag, v.VNI, createTime})
}
// 输出到文件
if err := file.WriterFileCSV(data, filePath); err != nil {
@@ -496,7 +502,13 @@ func (s *UDMVolteIMSController) Export(c *gin.Context) {
// 转换数据
data := [][]string{}
for _, v := range rows {
data = append(data, []string{v.IMSI, v.MSISDN, v.Tag, v.VNI})
createTime := ""
if v.CreateTime == 0 {
createTime = time.Now().Format(time.RFC3339)
} else {
createTime = time.UnixMilli(v.CreateTime).Format(time.RFC3339)
}
data = append(data, []string{v.IMSI, v.MSISDN, v.Tag, v.VNI, createTime})
}
// 输出到文件
if err := file.WriterFileTXTLine(data, ",", filePath); err != nil {