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 }