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/post_attachment_bill.go

37 lines
725 B

2 years ago
package model
import "gorm.io/gorm"
type PostAttachmentBill struct {
*Model
PostID int64 `json:"post_id"`
UserID int64 `json:"user_id"`
PaidAmount int64 `json:"paid_amount"`
}
func (p *PostAttachmentBill) Get(db *gorm.DB) (*PostAttachmentBill, error) {
var pas PostAttachmentBill
if p.Model != nil && p.ID > 0 {
db = db.Where("id = ? AND is_del = ?", p.ID, 0)
}
if p.PostID > 0 {
db = db.Where("post_id = ?", p.PostID)
}
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 *PostAttachmentBill) Create(db *gorm.DB) (*PostAttachmentBill, error) {
err := db.Create(&p).Error
return p, err
}