You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

947 lines
21 KiB
Go

// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"fmt"
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/ent/department"
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/ent/dictionary"
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/ent/dictionarydetail"
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/ent/district"
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/ent/loginrecord"
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/ent/oauthprovider"
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/ent/role"
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/ent/token"
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/ent/user"
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/ent/usermeta"
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/ent/usersocial"
"git.noahlan.cn/noahlan/ntool-biz/core/page"
)
type PageDetails = page.Pagination
// OrderDirection defines the directions in which to order a list of items.
type OrderDirection string
const (
// OrderDirectionAsc specifies an ascending order.
OrderDirectionAsc OrderDirection = "ASC"
// OrderDirectionDesc specifies a descending order.
OrderDirectionDesc OrderDirection = "DESC"
)
// Validate the order direction value.
func (o OrderDirection) Validate() error {
if o != OrderDirectionAsc && o != OrderDirectionDesc {
return fmt.Errorf("%s is not a valid OrderDirection", o)
}
return nil
}
// String implements fmt.Stringer interface.
func (o OrderDirection) String() string {
return string(o)
}
func (o OrderDirection) reverse() OrderDirection {
if o == OrderDirectionDesc {
return OrderDirectionAsc
}
return OrderDirectionDesc
}
const errInvalidPagination = "INVALID_PAGINATION"
type DepartmentPager struct {
Order department.OrderOption
Filter func(*DepartmentQuery) (*DepartmentQuery, error)
}
// DepartmentPaginateOption enables pagination customization.
type DepartmentPaginateOption func(*DepartmentPager)
// DefaultDepartmentOrder is the default ordering of Department.
var DefaultDepartmentOrder = Desc(department.FieldID)
func newDepartmentPager(opts []DepartmentPaginateOption) (*DepartmentPager, error) {
pager := &DepartmentPager{}
for _, opt := range opts {
opt(pager)
}
if pager.Order == nil {
pager.Order = DefaultDepartmentOrder
}
return pager, nil
}
func (p *DepartmentPager) ApplyFilter(query *DepartmentQuery) (*DepartmentQuery, error) {
if p.Filter != nil {
return p.Filter(query)
}
return query, nil
}
// DepartmentPageList is Department PageList result.
type DepartmentPageList struct {
List []*Department `json:"list"`
PageDetails *PageDetails `json:"pageDetails"`
}
func (d *DepartmentQuery) Page(
ctx context.Context, pageNum uint64, pageSize uint64, opts ...DepartmentPaginateOption,
) (*DepartmentPageList, error) {
pager, err := newDepartmentPager(opts)
if err != nil {
return nil, err
}
if d, err = pager.ApplyFilter(d); err != nil {
return nil, err
}
ret := &DepartmentPageList{}
ret.PageDetails = &PageDetails{
Current: int64(pageNum),
Size: int64(pageSize),
}
acClone := d.Clone()
acClone.modifiers = d.modifiers
count, err := acClone.Count(ctx)
if err != nil {
return nil, err
}
ret.PageDetails.Total = int64(count)
if pager.Order != nil {
d = d.Order(pager.Order)
} else {
d = d.Order(DefaultDepartmentOrder)
}
d = d.Offset(int((pageNum - 1) * pageSize)).Limit(int(pageSize))
list, err := d.All(ctx)
if err != nil {
return nil, err
}
ret.List = list
return ret, nil
}
type DictionaryPager struct {
Order dictionary.OrderOption
Filter func(*DictionaryQuery) (*DictionaryQuery, error)
}
// DictionaryPaginateOption enables pagination customization.
type DictionaryPaginateOption func(*DictionaryPager)
// DefaultDictionaryOrder is the default ordering of Dictionary.
var DefaultDictionaryOrder = Desc(dictionary.FieldID)
func newDictionaryPager(opts []DictionaryPaginateOption) (*DictionaryPager, error) {
pager := &DictionaryPager{}
for _, opt := range opts {
opt(pager)
}
if pager.Order == nil {
pager.Order = DefaultDictionaryOrder
}
return pager, nil
}
func (p *DictionaryPager) ApplyFilter(query *DictionaryQuery) (*DictionaryQuery, error) {
if p.Filter != nil {
return p.Filter(query)
}
return query, nil
}
// DictionaryPageList is Dictionary PageList result.
type DictionaryPageList struct {
List []*Dictionary `json:"list"`
PageDetails *PageDetails `json:"pageDetails"`
}
func (d *DictionaryQuery) Page(
ctx context.Context, pageNum uint64, pageSize uint64, opts ...DictionaryPaginateOption,
) (*DictionaryPageList, error) {
pager, err := newDictionaryPager(opts)
if err != nil {
return nil, err
}
if d, err = pager.ApplyFilter(d); err != nil {
return nil, err
}
ret := &DictionaryPageList{}
ret.PageDetails = &PageDetails{
Current: int64(pageNum),
Size: int64(pageSize),
}
acClone := d.Clone()
acClone.modifiers = d.modifiers
count, err := acClone.Count(ctx)
if err != nil {
return nil, err
}
ret.PageDetails.Total = int64(count)
if pager.Order != nil {
d = d.Order(pager.Order)
} else {
d = d.Order(DefaultDictionaryOrder)
}
d = d.Offset(int((pageNum - 1) * pageSize)).Limit(int(pageSize))
list, err := d.All(ctx)
if err != nil {
return nil, err
}
ret.List = list
return ret, nil
}
type DictionaryDetailPager struct {
Order dictionarydetail.OrderOption
Filter func(*DictionaryDetailQuery) (*DictionaryDetailQuery, error)
}
// DictionaryDetailPaginateOption enables pagination customization.
type DictionaryDetailPaginateOption func(*DictionaryDetailPager)
// DefaultDictionaryDetailOrder is the default ordering of DictionaryDetail.
var DefaultDictionaryDetailOrder = Desc(dictionarydetail.FieldID)
func newDictionaryDetailPager(opts []DictionaryDetailPaginateOption) (*DictionaryDetailPager, error) {
pager := &DictionaryDetailPager{}
for _, opt := range opts {
opt(pager)
}
if pager.Order == nil {
pager.Order = DefaultDictionaryDetailOrder
}
return pager, nil
}
func (p *DictionaryDetailPager) ApplyFilter(query *DictionaryDetailQuery) (*DictionaryDetailQuery, error) {
if p.Filter != nil {
return p.Filter(query)
}
return query, nil
}
// DictionaryDetailPageList is DictionaryDetail PageList result.
type DictionaryDetailPageList struct {
List []*DictionaryDetail `json:"list"`
PageDetails *PageDetails `json:"pageDetails"`
}
func (dd *DictionaryDetailQuery) Page(
ctx context.Context, pageNum uint64, pageSize uint64, opts ...DictionaryDetailPaginateOption,
) (*DictionaryDetailPageList, error) {
pager, err := newDictionaryDetailPager(opts)
if err != nil {
return nil, err
}
if dd, err = pager.ApplyFilter(dd); err != nil {
return nil, err
}
ret := &DictionaryDetailPageList{}
ret.PageDetails = &PageDetails{
Current: int64(pageNum),
Size: int64(pageSize),
}
acClone := dd.Clone()
acClone.modifiers = dd.modifiers
count, err := acClone.Count(ctx)
if err != nil {
return nil, err
}
ret.PageDetails.Total = int64(count)
if pager.Order != nil {
dd = dd.Order(pager.Order)
} else {
dd = dd.Order(DefaultDictionaryDetailOrder)
}
dd = dd.Offset(int((pageNum - 1) * pageSize)).Limit(int(pageSize))
list, err := dd.All(ctx)
if err != nil {
return nil, err
}
ret.List = list
return ret, nil
}
type DistrictPager struct {
Order district.OrderOption
Filter func(*DistrictQuery) (*DistrictQuery, error)
}
// DistrictPaginateOption enables pagination customization.
type DistrictPaginateOption func(*DistrictPager)
// DefaultDistrictOrder is the default ordering of District.
var DefaultDistrictOrder = Desc(district.FieldID)
func newDistrictPager(opts []DistrictPaginateOption) (*DistrictPager, error) {
pager := &DistrictPager{}
for _, opt := range opts {
opt(pager)
}
if pager.Order == nil {
pager.Order = DefaultDistrictOrder
}
return pager, nil
}
func (p *DistrictPager) ApplyFilter(query *DistrictQuery) (*DistrictQuery, error) {
if p.Filter != nil {
return p.Filter(query)
}
return query, nil
}
// DistrictPageList is District PageList result.
type DistrictPageList struct {
List []*District `json:"list"`
PageDetails *PageDetails `json:"pageDetails"`
}
func (d *DistrictQuery) Page(
ctx context.Context, pageNum uint64, pageSize uint64, opts ...DistrictPaginateOption,
) (*DistrictPageList, error) {
pager, err := newDistrictPager(opts)
if err != nil {
return nil, err
}
if d, err = pager.ApplyFilter(d); err != nil {
return nil, err
}
ret := &DistrictPageList{}
ret.PageDetails = &PageDetails{
Current: int64(pageNum),
Size: int64(pageSize),
}
acClone := d.Clone()
acClone.modifiers = d.modifiers
count, err := acClone.Count(ctx)
if err != nil {
return nil, err
}
ret.PageDetails.Total = int64(count)
if pager.Order != nil {
d = d.Order(pager.Order)
} else {
d = d.Order(DefaultDistrictOrder)
}
d = d.Offset(int((pageNum - 1) * pageSize)).Limit(int(pageSize))
list, err := d.All(ctx)
if err != nil {
return nil, err
}
ret.List = list
return ret, nil
}
type LoginRecordPager struct {
Order loginrecord.OrderOption
Filter func(*LoginRecordQuery) (*LoginRecordQuery, error)
}
// LoginRecordPaginateOption enables pagination customization.
type LoginRecordPaginateOption func(*LoginRecordPager)
// DefaultLoginRecordOrder is the default ordering of LoginRecord.
var DefaultLoginRecordOrder = Desc(loginrecord.FieldID)
func newLoginRecordPager(opts []LoginRecordPaginateOption) (*LoginRecordPager, error) {
pager := &LoginRecordPager{}
for _, opt := range opts {
opt(pager)
}
if pager.Order == nil {
pager.Order = DefaultLoginRecordOrder
}
return pager, nil
}
func (p *LoginRecordPager) ApplyFilter(query *LoginRecordQuery) (*LoginRecordQuery, error) {
if p.Filter != nil {
return p.Filter(query)
}
return query, nil
}
// LoginRecordPageList is LoginRecord PageList result.
type LoginRecordPageList struct {
List []*LoginRecord `json:"list"`
PageDetails *PageDetails `json:"pageDetails"`
}
func (lr *LoginRecordQuery) Page(
ctx context.Context, pageNum uint64, pageSize uint64, opts ...LoginRecordPaginateOption,
) (*LoginRecordPageList, error) {
pager, err := newLoginRecordPager(opts)
if err != nil {
return nil, err
}
if lr, err = pager.ApplyFilter(lr); err != nil {
return nil, err
}
ret := &LoginRecordPageList{}
ret.PageDetails = &PageDetails{
Current: int64(pageNum),
Size: int64(pageSize),
}
acClone := lr.Clone()
acClone.modifiers = lr.modifiers
count, err := acClone.Count(ctx)
if err != nil {
return nil, err
}
ret.PageDetails.Total = int64(count)
if pager.Order != nil {
lr = lr.Order(pager.Order)
} else {
lr = lr.Order(DefaultLoginRecordOrder)
}
lr = lr.Offset(int((pageNum - 1) * pageSize)).Limit(int(pageSize))
list, err := lr.All(ctx)
if err != nil {
return nil, err
}
ret.List = list
return ret, nil
}
type OauthProviderPager struct {
Order oauthprovider.OrderOption
Filter func(*OauthProviderQuery) (*OauthProviderQuery, error)
}
// OauthProviderPaginateOption enables pagination customization.
type OauthProviderPaginateOption func(*OauthProviderPager)
// DefaultOauthProviderOrder is the default ordering of OauthProvider.
var DefaultOauthProviderOrder = Desc(oauthprovider.FieldID)
func newOauthProviderPager(opts []OauthProviderPaginateOption) (*OauthProviderPager, error) {
pager := &OauthProviderPager{}
for _, opt := range opts {
opt(pager)
}
if pager.Order == nil {
pager.Order = DefaultOauthProviderOrder
}
return pager, nil
}
func (p *OauthProviderPager) ApplyFilter(query *OauthProviderQuery) (*OauthProviderQuery, error) {
if p.Filter != nil {
return p.Filter(query)
}
return query, nil
}
// OauthProviderPageList is OauthProvider PageList result.
type OauthProviderPageList struct {
List []*OauthProvider `json:"list"`
PageDetails *PageDetails `json:"pageDetails"`
}
func (op *OauthProviderQuery) Page(
ctx context.Context, pageNum uint64, pageSize uint64, opts ...OauthProviderPaginateOption,
) (*OauthProviderPageList, error) {
pager, err := newOauthProviderPager(opts)
if err != nil {
return nil, err
}
if op, err = pager.ApplyFilter(op); err != nil {
return nil, err
}
ret := &OauthProviderPageList{}
ret.PageDetails = &PageDetails{
Current: int64(pageNum),
Size: int64(pageSize),
}
acClone := op.Clone()
acClone.modifiers = op.modifiers
count, err := acClone.Count(ctx)
if err != nil {
return nil, err
}
ret.PageDetails.Total = int64(count)
if pager.Order != nil {
op = op.Order(pager.Order)
} else {
op = op.Order(DefaultOauthProviderOrder)
}
op = op.Offset(int((pageNum - 1) * pageSize)).Limit(int(pageSize))
list, err := op.All(ctx)
if err != nil {
return nil, err
}
ret.List = list
return ret, nil
}
type RolePager struct {
Order role.OrderOption
Filter func(*RoleQuery) (*RoleQuery, error)
}
// RolePaginateOption enables pagination customization.
type RolePaginateOption func(*RolePager)
// DefaultRoleOrder is the default ordering of Role.
var DefaultRoleOrder = Desc(role.FieldID)
func newRolePager(opts []RolePaginateOption) (*RolePager, error) {
pager := &RolePager{}
for _, opt := range opts {
opt(pager)
}
if pager.Order == nil {
pager.Order = DefaultRoleOrder
}
return pager, nil
}
func (p *RolePager) ApplyFilter(query *RoleQuery) (*RoleQuery, error) {
if p.Filter != nil {
return p.Filter(query)
}
return query, nil
}
// RolePageList is Role PageList result.
type RolePageList struct {
List []*Role `json:"list"`
PageDetails *PageDetails `json:"pageDetails"`
}
func (r *RoleQuery) Page(
ctx context.Context, pageNum uint64, pageSize uint64, opts ...RolePaginateOption,
) (*RolePageList, error) {
pager, err := newRolePager(opts)
if err != nil {
return nil, err
}
if r, err = pager.ApplyFilter(r); err != nil {
return nil, err
}
ret := &RolePageList{}
ret.PageDetails = &PageDetails{
Current: int64(pageNum),
Size: int64(pageSize),
}
acClone := r.Clone()
acClone.modifiers = r.modifiers
count, err := acClone.Count(ctx)
if err != nil {
return nil, err
}
ret.PageDetails.Total = int64(count)
if pager.Order != nil {
r = r.Order(pager.Order)
} else {
r = r.Order(DefaultRoleOrder)
}
r = r.Offset(int((pageNum - 1) * pageSize)).Limit(int(pageSize))
list, err := r.All(ctx)
if err != nil {
return nil, err
}
ret.List = list
return ret, nil
}
type TokenPager struct {
Order token.OrderOption
Filter func(*TokenQuery) (*TokenQuery, error)
}
// TokenPaginateOption enables pagination customization.
type TokenPaginateOption func(*TokenPager)
// DefaultTokenOrder is the default ordering of Token.
var DefaultTokenOrder = Desc(token.FieldID)
func newTokenPager(opts []TokenPaginateOption) (*TokenPager, error) {
pager := &TokenPager{}
for _, opt := range opts {
opt(pager)
}
if pager.Order == nil {
pager.Order = DefaultTokenOrder
}
return pager, nil
}
func (p *TokenPager) ApplyFilter(query *TokenQuery) (*TokenQuery, error) {
if p.Filter != nil {
return p.Filter(query)
}
return query, nil
}
// TokenPageList is Token PageList result.
type TokenPageList struct {
List []*Token `json:"list"`
PageDetails *PageDetails `json:"pageDetails"`
}
func (t *TokenQuery) Page(
ctx context.Context, pageNum uint64, pageSize uint64, opts ...TokenPaginateOption,
) (*TokenPageList, error) {
pager, err := newTokenPager(opts)
if err != nil {
return nil, err
}
if t, err = pager.ApplyFilter(t); err != nil {
return nil, err
}
ret := &TokenPageList{}
ret.PageDetails = &PageDetails{
Current: int64(pageNum),
Size: int64(pageSize),
}
acClone := t.Clone()
acClone.modifiers = t.modifiers
count, err := acClone.Count(ctx)
if err != nil {
return nil, err
}
ret.PageDetails.Total = int64(count)
if pager.Order != nil {
t = t.Order(pager.Order)
} else {
t = t.Order(DefaultTokenOrder)
}
t = t.Offset(int((pageNum - 1) * pageSize)).Limit(int(pageSize))
list, err := t.All(ctx)
if err != nil {
return nil, err
}
ret.List = list
return ret, nil
}
type UserPager struct {
Order user.OrderOption
Filter func(*UserQuery) (*UserQuery, error)
}
// UserPaginateOption enables pagination customization.
type UserPaginateOption func(*UserPager)
// DefaultUserOrder is the default ordering of User.
var DefaultUserOrder = Desc(user.FieldID)
func newUserPager(opts []UserPaginateOption) (*UserPager, error) {
pager := &UserPager{}
for _, opt := range opts {
opt(pager)
}
if pager.Order == nil {
pager.Order = DefaultUserOrder
}
return pager, nil
}
func (p *UserPager) ApplyFilter(query *UserQuery) (*UserQuery, error) {
if p.Filter != nil {
return p.Filter(query)
}
return query, nil
}
// UserPageList is User PageList result.
type UserPageList struct {
List []*User `json:"list"`
PageDetails *PageDetails `json:"pageDetails"`
}
func (u *UserQuery) Page(
ctx context.Context, pageNum uint64, pageSize uint64, opts ...UserPaginateOption,
) (*UserPageList, error) {
pager, err := newUserPager(opts)
if err != nil {
return nil, err
}
if u, err = pager.ApplyFilter(u); err != nil {
return nil, err
}
ret := &UserPageList{}
ret.PageDetails = &PageDetails{
Current: int64(pageNum),
Size: int64(pageSize),
}
acClone := u.Clone()
acClone.modifiers = u.modifiers
count, err := acClone.Count(ctx)
if err != nil {
return nil, err
}
ret.PageDetails.Total = int64(count)
if pager.Order != nil {
u = u.Order(pager.Order)
} else {
u = u.Order(DefaultUserOrder)
}
u = u.Offset(int((pageNum - 1) * pageSize)).Limit(int(pageSize))
list, err := u.All(ctx)
if err != nil {
return nil, err
}
ret.List = list
return ret, nil
}
type UserMetaPager struct {
Order usermeta.OrderOption
Filter func(*UserMetaQuery) (*UserMetaQuery, error)
}
// UserMetaPaginateOption enables pagination customization.
type UserMetaPaginateOption func(*UserMetaPager)
// DefaultUserMetaOrder is the default ordering of UserMeta.
var DefaultUserMetaOrder = Desc(usermeta.FieldID)
func newUserMetaPager(opts []UserMetaPaginateOption) (*UserMetaPager, error) {
pager := &UserMetaPager{}
for _, opt := range opts {
opt(pager)
}
if pager.Order == nil {
pager.Order = DefaultUserMetaOrder
}
return pager, nil
}
func (p *UserMetaPager) ApplyFilter(query *UserMetaQuery) (*UserMetaQuery, error) {
if p.Filter != nil {
return p.Filter(query)
}
return query, nil
}
// UserMetaPageList is UserMeta PageList result.
type UserMetaPageList struct {
List []*UserMeta `json:"list"`
PageDetails *PageDetails `json:"pageDetails"`
}
func (um *UserMetaQuery) Page(
ctx context.Context, pageNum uint64, pageSize uint64, opts ...UserMetaPaginateOption,
) (*UserMetaPageList, error) {
pager, err := newUserMetaPager(opts)
if err != nil {
return nil, err
}
if um, err = pager.ApplyFilter(um); err != nil {
return nil, err
}
ret := &UserMetaPageList{}
ret.PageDetails = &PageDetails{
Current: int64(pageNum),
Size: int64(pageSize),
}
acClone := um.Clone()
acClone.modifiers = um.modifiers
count, err := acClone.Count(ctx)
if err != nil {
return nil, err
}
ret.PageDetails.Total = int64(count)
if pager.Order != nil {
um = um.Order(pager.Order)
} else {
um = um.Order(DefaultUserMetaOrder)
}
um = um.Offset(int((pageNum - 1) * pageSize)).Limit(int(pageSize))
list, err := um.All(ctx)
if err != nil {
return nil, err
}
ret.List = list
return ret, nil
}
type UserSocialPager struct {
Order usersocial.OrderOption
Filter func(*UserSocialQuery) (*UserSocialQuery, error)
}
// UserSocialPaginateOption enables pagination customization.
type UserSocialPaginateOption func(*UserSocialPager)
// DefaultUserSocialOrder is the default ordering of UserSocial.
var DefaultUserSocialOrder = Desc(usersocial.FieldID)
func newUserSocialPager(opts []UserSocialPaginateOption) (*UserSocialPager, error) {
pager := &UserSocialPager{}
for _, opt := range opts {
opt(pager)
}
if pager.Order == nil {
pager.Order = DefaultUserSocialOrder
}
return pager, nil
}
func (p *UserSocialPager) ApplyFilter(query *UserSocialQuery) (*UserSocialQuery, error) {
if p.Filter != nil {
return p.Filter(query)
}
return query, nil
}
// UserSocialPageList is UserSocial PageList result.
type UserSocialPageList struct {
List []*UserSocial `json:"list"`
PageDetails *PageDetails `json:"pageDetails"`
}
func (us *UserSocialQuery) Page(
ctx context.Context, pageNum uint64, pageSize uint64, opts ...UserSocialPaginateOption,
) (*UserSocialPageList, error) {
pager, err := newUserSocialPager(opts)
if err != nil {
return nil, err
}
if us, err = pager.ApplyFilter(us); err != nil {
return nil, err
}
ret := &UserSocialPageList{}
ret.PageDetails = &PageDetails{
Current: int64(pageNum),
Size: int64(pageSize),
}
acClone := us.Clone()
acClone.modifiers = us.modifiers
count, err := acClone.Count(ctx)
if err != nil {
return nil, err
}
ret.PageDetails.Total = int64(count)
if pager.Order != nil {
us = us.Order(pager.Order)
} else {
us = us.Order(DefaultUserSocialOrder)
}
us = us.Offset(int((pageNum - 1) * pageSize)).Limit(int(pageSize))
list, err := us.All(ctx)
if err != nil {
return nil, err
}
ret.List = list
return ret, nil
}