From 7eddb6853b235bd17cd46a5f340a74110d3fca06 Mon Sep 17 00:00:00 2001 From: NorthLan <6995syu@163.com> Date: Thu, 26 May 2022 21:18:02 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=BC=B9=E5=B8=81=E6=95=B0=E6=8D=AE=E6=A8=A1=E5=9E=8B.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/user_center/model/user_coin_model.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/user_center/model/user_coin_model.go b/app/user_center/model/user_coin_model.go index e72a141..86ec935 100644 --- a/app/user_center/model/user_coin_model.go +++ b/app/user_center/model/user_coin_model.go @@ -16,7 +16,6 @@ type ( // and implement the added methods in customUserCoinModel. UserCoinModel interface { userCoinModel - UpdateCoin(ctx context.Context, tx *gorm.DB, integral *UserCoin) error // ChangeCoin 用户弹币变动 ChangeCoin(ctx context.Context, tx *gorm.DB, userId int64, change int64) (int64, error) } @@ -33,7 +32,7 @@ func NewUserCoinModel(conn *gorm.DB) UserCoinModel { } } -func (m *customUserCoinModel) UpdateCoin(ctx context.Context, tx *gorm.DB, coin *UserCoin) error { +func (m *customUserCoinModel) updateCoin(ctx context.Context, tx *gorm.DB, coin *UserCoin) error { if coin.Coin < 0 { return errors.New("无法将弹币更新至负数") } @@ -55,8 +54,8 @@ func (m *customUserCoinModel) ChangeCoin(ctx context.Context, tx *gorm.DB, userI } // 用户积分记录不存在,进行插入 if err = m.Insert(ctx, tx, &UserCoin{ - UserId: userId, - Coin: change, + UserId: userId, + Coin: change, }); err != nil { return nerr.NewError(nerr.NewUserCoinErr, "新建用户弹币记录失败") } @@ -69,7 +68,7 @@ func (m *customUserCoinModel) ChangeCoin(ctx context.Context, tx *gorm.DB, userI return nerr.NewError(nerr.UserCoinNotEnoughErr, "用户弹币不足") } data.Coin += change - if err = m.UpdateCoin(ctx, tx, data); err != nil { + if err = m.updateCoin(ctx, tx, data); err != nil { if errors.Is(err, gormx.ErrRowsAffectedZero) { return err }