mtfosbot/model/opay_donate_list.go

39 lines
1000 B
Go
Raw Normal View History

2018-09-07 08:33:37 +00:00
package model
2018-09-17 13:46:59 +00:00
import (
"time"
"github.com/jmoiron/sqlx"
)
2018-09-07 08:33:37 +00:00
// OpayDonateList - struct
type OpayDonateList struct {
OpayID string `db:"opayid" cc:"opayid"`
DonateID string `db:"donate_id" cc:"donate_id"`
Price int `db:"price" cc:"price"`
Text string `db:"text" cc:"text"`
2018-09-17 13:46:59 +00:00
Name string `db:"name" cc:"name"`
2018-09-07 08:33:37 +00:00
Ctime time.Time `db:"ctime" cc:"ctime"`
Mtime time.Time `db:"mtime" cc:"ctime"`
}
2018-09-17 13:46:59 +00:00
// GetDonateListWithIDs -
func GetDonateListWithIDs(ids []string) (ls []*OpayDonateList, err error) {
if len(ids) == 0 {
return
}
s, i, err := sqlx.In(`select * from "public"."opay_donate_list" where "donate_id" in (?)`, ids)
if err != nil {
return
}
s = x.Rebind(s)
err = x.Select(&ls, s, i...)
return
}
// InsertData -
func (p *OpayDonateList) InsertData() (err error) {
_, err = x.NamedExec(`insert into "public"."opay_donate_list" ("opayid", "donate_id", "price", "text", "name") values (:opayid, :donate_id, :price, :text, :name)`, p)
return
}