package data import ( "PaymentCenter/app/http/entities" "PaymentCenter/app/models/paychannelmodel" "xorm.io/builder" "xorm.io/xorm" ) type PayChannelRepo struct { repo xorm.Interface } func NewPayChannelRepo(repo xorm.Interface) *PayChannelRepo { return &PayChannelRepo{ repo: repo, } } func (m *PayChannelRepo) PayChannelList(conn builder.Cond, pageFilter entities.PageRequest, payChannelList *[]paychannelmodel.PayChannel) (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(payChannelList) } func (m *PayChannelRepo) PayChannelInsertOne(merchant *paychannelmodel.PayChannel) (int64, error) { return m.repo.InsertOne(merchant) } func (m *PayChannelRepo) PayChannelDelete(merchant *paychannelmodel.PayChannel, conn builder.Cond) (int64, error) { return m.repo.Where(conn).Delete(merchant) } // columns 参数为要更新的字段,即使为空 func (m *PayChannelRepo) PayChannelUpdate(merchant *paychannelmodel.PayChannel, conn builder.Cond, columns ...string) (int64, error) { return m.repo.Where(conn).MustCols(columns...).Update(merchant) }