diff --git a/example/admin/companyinout.go b/example/admin/companyinout.go index 7ef500b..35aa71f 100644 --- a/example/admin/companyinout.go +++ b/example/admin/companyinout.go @@ -483,7 +483,12 @@ func decodeData2Sql(table [][]string, this *Context, orgId int) error { companyData["industry_id"] = industry.GetCeilInt("id") } - company := this.Db.Get("company", "id", Map{"name": companyData["name"]}) + company := this.Db.Get("company", "id", Map{"sn": companyData["sn"]}) + //没有则创建 + if company == nil { + company = this.Db.Get("company", "id", Map{"name": companyData["name"]}) + } + //没有则创建 if company == nil { //更新两张表 @@ -493,7 +498,7 @@ func decodeData2Sql(table [][]string, this *Context, orgId int) error { company = Map{"id": id} } else { //有则更新 - this.Db.Update("company", companyData, Map{"name": companyData["name"]}) + this.Db.Update("company", companyData, Map{"id": company.GetCeilInt("id")}) companyData["company_id"] = company.GetCeilInt("id") companyData["create_time"] = time.Now().Unix() } diff --git a/example/iedc.exe b/example/iedc.exe index 8b3c114..b008b94 100644 Binary files a/example/iedc.exe and b/example/iedc.exe differ