You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
paopao-ce/internal/dao/jinzhu/dbr/wallet_recharge.go

35 lines
682 B

2 years ago
package model
import "gorm.io/gorm"
type WalletRecharge struct {
*Model
UserID int64 `json:"user_id"`
Amount int64 `json:"amount"`
TradeNo string `json:"trade_no"`
TradeStatus string `json:"trade_status"`
}
func (p *WalletRecharge) Get(db *gorm.DB) (*WalletRecharge, error) {
var pas WalletRecharge
if p.Model != nil && p.ID > 0 {
db = db.Where("id = ? AND is_del = ?", p.ID, 0)
}
if p.UserID > 0 {
db = db.Where("user_id = ?", p.UserID)
}
err := db.First(&pas).Error
if err != nil {
return &pas, err
}
return &pas, nil
}
func (p *WalletRecharge) Create(db *gorm.DB) (*WalletRecharge, error) {
err := db.Create(&p).Error
return p, err
}