修复pgsql和数据库导入bug,增加默认mod中的datatypes (#1712)
* 多文件: fix error specified more than once in PG * Update sys_authority.go * Update sys_authority.go * sys_export_template.go: 导入Excel时使用批量插入提高性能 * 添加gorm.io/datatypes --------- Co-authored-by: crazyrunsnail <fjyuan1991@163.com> Co-authored-by: XiMo-210 <2831802697@qq.com>
This commit is contained in:
@@ -336,6 +336,7 @@ func (sysExportTemplateService *SysExportTemplateService) ImportExcel(templateID
|
||||
return db.Transaction(func(tx *gorm.DB) error {
|
||||
excelTitle := rows[0]
|
||||
values := rows[1:]
|
||||
items := make([]map[string]interface{}, len(values))
|
||||
for _, row := range values {
|
||||
var item = make(map[string]interface{})
|
||||
for ii, value := range row {
|
||||
@@ -354,12 +355,10 @@ func (sysExportTemplateService *SysExportTemplateService) ImportExcel(templateID
|
||||
// item["updated_at"] = time.Now()
|
||||
//}
|
||||
|
||||
cErr := tx.Table(template.TableName).Create(&item).Error
|
||||
if cErr != nil {
|
||||
return cErr
|
||||
}
|
||||
items = append(items, item)
|
||||
}
|
||||
return nil
|
||||
cErr := tx.Table(template.TableName).CreateInBatches(&items, 1000).Error
|
||||
return cErr
|
||||
})
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user