package data import ( "PaymentCenter/app/http/entities" "PaymentCenter/app/models/orderrequestlogmodel" "PaymentCenter/app/utils/snowflake" "xorm.io/builder" "xorm.io/xorm" ) type OrderRequestLogRepo struct { repo xorm.Interface } func NewOrderRequestLogRepo(repo xorm.Interface) *OrderRequestLogRepo { return &OrderRequestLogRepo{ repo: repo, } } func (m *OrderRequestLogRepo) OrderRequestLogList(conn builder.Cond, pageFilter entities.PageRequest, orderLogList *[]orderrequestlogmodel.OrderRequestLog) (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 *OrderRequestLogRepo) OrderRequestLogInsertOne(orderLog *orderrequestlogmodel.OrderRequestLog) (int64, error) { orderLog.Id = snowflake.GetID() return m.repo.InsertOne(orderLog) } func (m *OrderRequestLogRepo) OrderRequestLogDelete(orderLog *orderrequestlogmodel.OrderRequestLog, conn builder.Cond) (int64, error) { return m.repo.Where(conn).Delete(orderLog) } // columns 参数为要更新的字段 func (m *OrderRequestLogRepo) OrderRequestLogUpdate(orderLog *orderrequestlogmodel.OrderRequestLog, conn builder.Cond, columns ...string) (int64, error) { return m.repo.Where(conn).MustCols(columns...).Update(orderLog) } // 后台查询订单日志列表 func (m *OrderRequestLogRepo) OrderRequestLogBackendList(conn builder.Cond, pageFilter entities.PageRequest, orderLogList *[]orderrequestlogmodel.OrderRequestLog) (int64, error) { repo := m.repo.Where(conn) if pageFilter.Page > 0 { repo = repo.Limit(pageFilter.PageSize, pageFilter.PageSize*(pageFilter.Page-1)) } repo.Join("left", "orders", "orders.app_id = order_request_log.app_id and orders.out_trade_no = order_request_log.out_trade_no") return repo.Desc("order_request_log.create_time").FindAndCount(orderLogList) } // 查询订单日志 func (m *OrderRequestLogRepo) OrderRequestLogGet(orderLog *orderrequestlogmodel.OrderRequestLog, conn builder.Cond) (bool, error) { return m.repo.Where(conn).Get(orderLog) }