add
This commit is contained in:
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user