This commit is contained in:
vipg
2025-11-17 18:10:40 +08:00
parent a47e544657
commit 44e2d7c1f6
2 changed files with 31 additions and 11 deletions

View File

@@ -129,10 +129,10 @@ func CreateHandler(c *gin.Context) {
)
// 2. 插入国家名称到name表与currency_id关联
_, err = tx.Exec("INSERT INTO name (currency_id, name) VALUES ($1, $2)", currencyID, req.Name)
_, err = tx.Exec("INSERT INTO currency_name (currency_id, name) VALUES ($1, $2)", currencyID, req.Name)
if err != nil {
tx.Rollback() // 操作失败,回滚事务
zap.L().Error("❌ name表插入失败",
zap.L().Error("❌ currency_name表插入失败",
zap.String("req_id", reqID),
zap.String("currency_id", currencyID),
zap.Error(err),
@@ -145,10 +145,10 @@ func CreateHandler(c *gin.Context) {
}
// 3. 插入国家代码到code表与currency_id关联
_, err = tx.Exec("INSERT INTO code (currency_id, code) VALUES ($1, $2)", currencyID, req.Code)
_, err = tx.Exec("INSERT INTO currency_code (currency_id, code) VALUES ($1, $2)", currencyID, req.Code)
if err != nil {
tx.Rollback() // 操作失败,回滚事务
zap.L().Error("❌ code表插入失败",
zap.L().Error("❌ currency_code表插入失败",
zap.String("req_id", reqID),
zap.String("currency_id", currencyID),
zap.Error(err),