PaymentCenter/app/data/order_callback_log.go

40 lines
1.3 KiB
Go

package data
import (
"PaymentCenter/app/http/entities"
"PaymentCenter/app/models/ordercallbacklogmodel"
"xorm.io/builder"
"xorm.io/xorm"
)
type OrderCallbackLogRepo struct {
repo xorm.Interface
}
func NewOrderCallbackLogRepo(repo xorm.Interface) *OrderCallbackLogRepo {
return &OrderCallbackLogRepo{
repo: repo,
}
}
func (m *OrderCallbackLogRepo) OrderCallbackLogList(conn builder.Cond, pageFilter entities.PageRequest, orderLogList *[]ordercallbacklogmodel.OrderCallbackLog) (int64, error) {
repo := m.repo.Where(conn)
if pageFilter.Page > 0 {
repo = repo.Limit(pageFilter.PageSize, pageFilter.PageSize*(pageFilter.Page-1))
}
return repo.Desc("create_time").FindAndCount(orderLogList)
}
func (m *OrderCallbackLogRepo) OrderCallbackLogInsertOne(orderLog *ordercallbacklogmodel.OrderCallbackLog) (int64, error) {
return m.repo.InsertOne(orderLog)
}
func (m *OrderCallbackLogRepo) OrderCallbackLogDelete(orderLog *ordercallbacklogmodel.OrderCallbackLog, conn builder.Cond) (int64, error) {
return m.repo.Where(conn).Delete(orderLog)
}
// columns 参数为要更新的字段
func (m *OrderCallbackLogRepo) OrderCallbackLogUpdate(orderLog *ordercallbacklogmodel.OrderCallbackLog, conn builder.Cond, columns ...string) (int64, error) {
return m.repo.Where(conn).MustCols(columns...).Update(orderLog)
}