42 lines
1.4 KiB
Go
42 lines
1.4 KiB
Go
package data
|
|
|
|
import (
|
|
"PaymentCenter/app/http/entities"
|
|
"PaymentCenter/app/models/ordercallbacklogmodel"
|
|
"PaymentCenter/app/utils/snowflake"
|
|
"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) {
|
|
orderLog.Id = snowflake.GetID()
|
|
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)
|
|
}
|