40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
package data
|
|
|
|
import (
|
|
"PaymentCenter/app/http/entities"
|
|
"PaymentCenter/app/models/orderlogmodel"
|
|
"xorm.io/builder"
|
|
"xorm.io/xorm"
|
|
)
|
|
|
|
type OrderLogRepo struct {
|
|
repo xorm.Interface
|
|
}
|
|
|
|
func NewOrderLogRepo(repo xorm.Interface) *OrderLogRepo {
|
|
return &OrderLogRepo{
|
|
repo: repo,
|
|
}
|
|
}
|
|
|
|
func (m *OrderLogRepo) OrderLogList(conn builder.Cond, pageFilter entities.PageRequest, orderLogList *[]orderlogmodel.OrderLog) (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 *OrderLogRepo) OrderLogInsertOne(orderLog *orderlogmodel.OrderLog) (int64, error) {
|
|
return m.repo.InsertOne(orderLog)
|
|
}
|
|
|
|
func (m *OrderLogRepo) OrderLogDelete(orderLog *orderlogmodel.OrderLog, conn builder.Cond) (int64, error) {
|
|
return m.repo.Where(conn).Delete(orderLog)
|
|
}
|
|
|
|
// columns 参数为要更新的字段
|
|
func (m *OrderLogRepo) OrderLogUpdate(orderLog *orderlogmodel.OrderLog, conn builder.Cond, columns ...string) (int64, error) {
|
|
return m.repo.Where(conn).MustCols(columns...).Update(orderLog)
|
|
}
|