From 3b3441851c2caddb03bfef97d22a6e97e0afeae5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?piexlmax=EF=BC=88=E5=A5=87=E6=B7=BC?= Date: Fri, 15 Mar 2024 14:55:20 +0800 Subject: [PATCH] =?UTF-8?q?feature:=E4=BF=9D=E8=AF=81=E5=AD=98=E5=9C=A8GVA?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E7=BB=93=E6=9E=84=E7=9A=84=E8=A1=A8=E6=A0=BC?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E8=87=AA=E5=8A=A8=E5=A1=AB=E5=85=85created?= =?UTF-8?q?=E5=92=8Cupdated?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/service/system/sys_export_template.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/server/service/system/sys_export_template.go b/server/service/system/sys_export_template.go index 8a0adf21..7422d8ff 100644 --- a/server/service/system/sys_export_template.go +++ b/server/service/system/sys_export_template.go @@ -15,6 +15,7 @@ import ( "net/url" "strconv" "strings" + "time" ) type SysExportTemplateService struct { @@ -305,6 +306,15 @@ func (sysExportTemplateService *SysExportTemplateService) ImportExcel(templateID key := titleKeyMap[excelTitle[ii]] item[key] = value } + needCreated := tx.Migrator().HasColumn(template.TableName, "created_at") + needUpdated := tx.Migrator().HasColumn(template.TableName, "updated_at") + if item["created_at"] == nil && needCreated { + item["created_at"] = time.Now() + } + if item["updated_at"] == nil && needUpdated { + item["updated_at"] = time.Now() + } + cErr := tx.Table(template.TableName).Create(&item).Error if cErr != nil { return cErr