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 {