fix(tenement):修正商户中带有JSONB字段的插入语句。

This commit is contained in:
徐涛 2023-06-27 15:05:04 +08:00
parent a1a72b7204
commit 0c389e440a

View File

@ -197,40 +197,33 @@ func (tr _TenementRepository) AddTenement(tx pgx.Tx, ctx context.Context, pid st
serial.StringSerialRequestChan <- 1 serial.StringSerialRequestChan <- 1
tenementId := serial.Prefix("T", <-serial.StringSerialResponseChan) tenementId := serial.Prefix("T", <-serial.StringSerialResponseChan)
currentTime := types.Now() currentTime := types.Now()
createSql, createArgs, _ := tr.ds. if _, err := tx.Exec(
Insert("tenement"). ctx,
Cols( "INSERT INTO tenement (id, park_id, full_name, short_name, abbr, address, contact_name, contact_phone, building, on_floor, invoice_info, moved_in_at, created_at, last_modified_at) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14)",
"id", "park_id", "full_name", "short_name", "abbr", "address", "contact_name", "contact_phone", []interface{}{
"building", "on_floor", "invoice_info", tenementId,
"moved_in_at", "created_at", "last_modified_at", pid,
). tenement.Name,
Vals( tenement.ShortName,
goqu.Vals{ tools.PinyinAbbr(tenement.Name),
tenementId, tenement.Address,
pid, tenement.Contact,
tenement.Name, tenement.Phone,
tenement.ShortName, tenement.Building,
tools.PinyinAbbr(tenement.Name), tenement.OnFloor,
tenement.Address, &model.InvoiceTitle{
tenement.Contact, Name: tenement.Name,
tenement.Phone, USCI: tenement.USCI,
tenement.Building, Address: tools.DefaultOrEmptyStr(tenement.InvoiceAddress, ""),
tenement.OnFloor, Phone: tools.DefaultOrEmptyStr(tenement.InvoicePhone, ""),
&model.InvoiceTitle{ Bank: tools.DefaultOrEmptyStr(tenement.Bank, ""),
Name: tenement.Name, Account: tools.DefaultOrEmptyStr(tenement.Account, ""),
USCI: tenement.USCI,
Address: tools.DefaultOrEmptyStr(tenement.InvoiceAddress, ""),
Phone: tools.DefaultOrEmptyStr(tenement.InvoicePhone, ""),
Bank: tools.DefaultOrEmptyStr(tenement.Bank, ""),
Account: tools.DefaultOrEmptyStr(tenement.Account, ""),
},
currentTime,
currentTime,
currentTime,
}, },
). currentTime,
Prepared(true).ToSQL() currentTime,
if _, err := tx.Exec(ctx, createSql, createArgs...); err != nil { currentTime,
}...,
); err != nil {
tr.log.Error("在指定园区中创建一个新的商户失败", zap.Error(err)) tr.log.Error("在指定园区中创建一个新的商户失败", zap.Error(err))
return err return err
} }