// Code generated by ent, DO NOT EDIT.

package db

import "context"

// PageInfo 分页信息
type PageInfo struct {
	NextToken   string `json:"next_token,omitempty"`
	HasNextPage bool   `json:"has_next_page"`
	TotalCount  int64  `json:"total_count"`
}

func (ae *AIEmployeeQuery) Page(ctx context.Context, page, size int) ([]*AIEmployee, *PageInfo, error) {
	cnt, err := ae.Count(ctx)
	if err != nil {
		return nil, nil, err
	}
	offset := size * (page - 1)
	rs, err := ae.Offset(offset).Limit(size).All(ctx)
	if err != nil {
		return nil, nil, err
	}
	has := (page * size) < cnt
	return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil
}

func (at *AITaskQuery) Page(ctx context.Context, page, size int) ([]*AITask, *PageInfo, error) {
	cnt, err := at.Count(ctx)
	if err != nil {
		return nil, nil, err
	}
	offset := size * (page - 1)
	rs, err := at.Offset(offset).Limit(size).All(ctx)
	if err != nil {
		return nil, nil, err
	}
	has := (page * size) < cnt
	return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil
}

func (a *AdminQuery) Page(ctx context.Context, page, size int) ([]*Admin, *PageInfo, error) {
	cnt, err := a.Count(ctx)
	if err != nil {
		return nil, nil, err
	}
	offset := size * (page - 1)
	rs, err := a.Offset(offset).Limit(size).All(ctx)
	if err != nil {
		return nil, nil, err
	}
	has := (page * size) < cnt
	return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil
}

func (alh *AdminLoginHistoryQuery) Page(ctx context.Context, page, size int) ([]*AdminLoginHistory, *PageInfo, error) {
	cnt, err := alh.Count(ctx)
	if err != nil {
		return nil, nil, err
	}
	offset := size * (page - 1)
	rs, err := alh.Offset(offset).Limit(size).All(ctx)
	if err != nil {
		return nil, nil, err
	}
	has := (page * size) < cnt
	return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil
}

func (ar *AdminRoleQuery) Page(ctx context.Context, page, size int) ([]*AdminRole, *PageInfo, error) {
	cnt, err := ar.Count(ctx)
	if err != nil {
		return nil, nil, err
	}
	offset := size * (page - 1)
	rs, err := ar.Offset(offset).Limit(size).All(ctx)
	if err != nil {
		return nil, nil, err
	}
	has := (page * size) < cnt
	return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil
}

func (ak *ApiKeyQuery) Page(ctx context.Context, page, size int) ([]*ApiKey, *PageInfo, error) {
	cnt, err := ak.Count(ctx)
	if err != nil {
		return nil, nil, err
	}
	offset := size * (page - 1)
	rs, err := ak.Offset(offset).Limit(size).All(ctx)
	if err != nil {
		return nil, nil, err
	}
	has := (page * size) < cnt
	return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil
}

func (bp *BillingPlanQuery) Page(ctx context.Context, page, size int) ([]*BillingPlan, *PageInfo, error) {
	cnt, err := bp.Count(ctx)
	if err != nil {
		return nil, nil, err
	}
	offset := size * (page - 1)
	rs, err := bp.Offset(offset).Limit(size).All(ctx)
	if err != nil {
		return nil, nil, err
	}
	has := (page * size) < cnt
	return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil
}

func (bq *BillingQuotaQuery) Page(ctx context.Context, page, size int) ([]*BillingQuota, *PageInfo, error) {
	cnt, err := bq.Count(ctx)
	if err != nil {
		return nil, nil, err
	}
	offset := size * (page - 1)
	rs, err := bq.Offset(offset).Limit(size).All(ctx)
	if err != nil {
		return nil, nil, err
	}
	has := (page * size) < cnt
	return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil
}

func (br *BillingRecordQuery) Page(ctx context.Context, page, size int) ([]*BillingRecord, *PageInfo, error) {
	cnt, err := br.Count(ctx)
	if err != nil {
		return nil, nil, err
	}
	offset := size * (page - 1)
	rs, err := br.Offset(offset).Limit(size).All(ctx)
	if err != nil {
		return nil, nil, err
	}
	has := (page * size) < cnt
	return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil
}

func (bu *BillingUsageQuery) Page(ctx context.Context, page, size int) ([]*BillingUsage, *PageInfo, error) {
	cnt, err := bu.Count(ctx)
	if err != nil {
		return nil, nil, err
	}
	offset := size * (page - 1)
	rs, err := bu.Offset(offset).Limit(size).All(ctx)
	if err != nil {
		return nil, nil, err
	}
	has := (page * size) < cnt
	return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil
}

func (cs *CodeSnippetQuery) Page(ctx context.Context, page, size int) ([]*CodeSnippet, *PageInfo, error) {
	cnt, err := cs.Count(ctx)
	if err != nil {
		return nil, nil, err
	}
	offset := size * (page - 1)
	rs, err := cs.Offset(offset).Limit(size).All(ctx)
	if err != nil {
		return nil, nil, err
	}
	has := (page * size) < cnt
	return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil
}

func (e *ExtensionQuery) Page(ctx context.Context, page, size int) ([]*Extension, *PageInfo, error) {
	cnt, err := e.Count(ctx)
	if err != nil {
		return nil, nil, err
	}
	offset := size * (page - 1)
	rs, err := e.Offset(offset).Limit(size).All(ctx)
	if err != nil {
		return nil, nil, err
	}
	has := (page * size) < cnt
	return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil
}

func (ic *InviteCodeQuery) Page(ctx context.Context, page, size int) ([]*InviteCode, *PageInfo, error) {
	cnt, err := ic.Count(ctx)
	if err != nil {
		return nil, nil, err
	}
	offset := size * (page - 1)
	rs, err := ic.Offset(offset).Limit(size).All(ctx)
	if err != nil {
		return nil, nil, err
	}
	has := (page * size) < cnt
	return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil
}

func (l *LicenseQuery) Page(ctx context.Context, page, size int) ([]*License, *PageInfo, error) {
	cnt, err := l.Count(ctx)
	if err != nil {
		return nil, nil, err
	}
	offset := size * (page - 1)
	rs, err := l.Offset(offset).Limit(size).All(ctx)
	if err != nil {
		return nil, nil, err
	}
	has := (page * size) < cnt
	return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil
}

func (m *ModelQuery) Page(ctx context.Context, page, size int) ([]*Model, *PageInfo, error) {
	cnt, err := m.Count(ctx)
	if err != nil {
		return nil, nil, err
	}
	offset := size * (page - 1)
	rs, err := m.Offset(offset).Limit(size).All(ctx)
	if err != nil {
		return nil, nil, err
	}
	has := (page * size) < cnt
	return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil
}

func (mp *ModelProviderQuery) Page(ctx context.Context, page, size int) ([]*ModelProvider, *PageInfo, error) {
	cnt, err := mp.Count(ctx)
	if err != nil {
		return nil, nil, err
	}
	offset := size * (page - 1)
	rs, err := mp.Offset(offset).Limit(size).All(ctx)
	if err != nil {
		return nil, nil, err
	}
	has := (page * size) < cnt
	return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil
}

func (mpm *ModelProviderModelQuery) Page(ctx context.Context, page, size int) ([]*ModelProviderModel, *PageInfo, error) {
	cnt, err := mpm.Count(ctx)
	if err != nil {
		return nil, nil, err
	}
	offset := size * (page - 1)
	rs, err := mpm.Offset(offset).Limit(size).All(ctx)
	if err != nil {
		return nil, nil, err
	}
	has := (page * size) < cnt
	return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil
}

func (r *RoleQuery) Page(ctx context.Context, page, size int) ([]*Role, *PageInfo, error) {
	cnt, err := r.Count(ctx)
	if err != nil {
		return nil, nil, err
	}
	offset := size * (page - 1)
	rs, err := r.Offset(offset).Limit(size).All(ctx)
	if err != nil {
		return nil, nil, err
	}
	has := (page * size) < cnt
	return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil
}

func (ss *SecurityScanningQuery) Page(ctx context.Context, page, size int) ([]*SecurityScanning, *PageInfo, error) {
	cnt, err := ss.Count(ctx)
	if err != nil {
		return nil, nil, err
	}
	offset := size * (page - 1)
	rs, err := ss.Offset(offset).Limit(size).All(ctx)
	if err != nil {
		return nil, nil, err
	}
	has := (page * size) < cnt
	return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil
}

func (ssr *SecurityScanningResultQuery) Page(ctx context.Context, page, size int) ([]*SecurityScanningResult, *PageInfo, error) {
	cnt, err := ssr.Count(ctx)
	if err != nil {
		return nil, nil, err
	}
	offset := size * (page - 1)
	rs, err := ssr.Offset(offset).Limit(size).All(ctx)
	if err != nil {
		return nil, nil, err
	}
	has := (page * size) < cnt
	return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil
}

func (s *SettingQuery) Page(ctx context.Context, page, size int) ([]*Setting, *PageInfo, error) {
	cnt, err := s.Count(ctx)
	if err != nil {
		return nil, nil, err
	}
	offset := size * (page - 1)
	rs, err := s.Offset(offset).Limit(size).All(ctx)
	if err != nil {
		return nil, nil, err
	}
	has := (page * size) < cnt
	return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil
}

func (t *TaskQuery) Page(ctx context.Context, page, size int) ([]*Task, *PageInfo, error) {
	cnt, err := t.Count(ctx)
	if err != nil {
		return nil, nil, err
	}
	offset := size * (page - 1)
	rs, err := t.Offset(offset).Limit(size).All(ctx)
	if err != nil {
		return nil, nil, err
	}
	has := (page * size) < cnt
	return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil
}

func (tr *TaskRecordQuery) Page(ctx context.Context, page, size int) ([]*TaskRecord, *PageInfo, error) {
	cnt, err := tr.Count(ctx)
	if err != nil {
		return nil, nil, err
	}
	offset := size * (page - 1)
	rs, err := tr.Offset(offset).Limit(size).All(ctx)
	if err != nil {
		return nil, nil, err
	}
	has := (page * size) < cnt
	return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil
}

func (u *UserQuery) Page(ctx context.Context, page, size int) ([]*User, *PageInfo, error) {
	cnt, err := u.Count(ctx)
	if err != nil {
		return nil, nil, err
	}
	offset := size * (page - 1)
	rs, err := u.Offset(offset).Limit(size).All(ctx)
	if err != nil {
		return nil, nil, err
	}
	has := (page * size) < cnt
	return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil
}

func (ug *UserGroupQuery) Page(ctx context.Context, page, size int) ([]*UserGroup, *PageInfo, error) {
	cnt, err := ug.Count(ctx)
	if err != nil {
		return nil, nil, err
	}
	offset := size * (page - 1)
	rs, err := ug.Offset(offset).Limit(size).All(ctx)
	if err != nil {
		return nil, nil, err
	}
	has := (page * size) < cnt
	return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil
}

func (uga *UserGroupAdminQuery) Page(ctx context.Context, page, size int) ([]*UserGroupAdmin, *PageInfo, error) {
	cnt, err := uga.Count(ctx)
	if err != nil {
		return nil, nil, err
	}
	offset := size * (page - 1)
	rs, err := uga.Offset(offset).Limit(size).All(ctx)
	if err != nil {
		return nil, nil, err
	}
	has := (page * size) < cnt
	return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil
}

func (ugu *UserGroupUserQuery) Page(ctx context.Context, page, size int) ([]*UserGroupUser, *PageInfo, error) {
	cnt, err := ugu.Count(ctx)
	if err != nil {
		return nil, nil, err
	}
	offset := size * (page - 1)
	rs, err := ugu.Offset(offset).Limit(size).All(ctx)
	if err != nil {
		return nil, nil, err
	}
	has := (page * size) < cnt
	return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil
}

func (ui *UserIdentityQuery) Page(ctx context.Context, page, size int) ([]*UserIdentity, *PageInfo, error) {
	cnt, err := ui.Count(ctx)
	if err != nil {
		return nil, nil, err
	}
	offset := size * (page - 1)
	rs, err := ui.Offset(offset).Limit(size).All(ctx)
	if err != nil {
		return nil, nil, err
	}
	has := (page * size) < cnt
	return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil
}

func (ulh *UserLoginHistoryQuery) Page(ctx context.Context, page, size int) ([]*UserLoginHistory, *PageInfo, error) {
	cnt, err := ulh.Count(ctx)
	if err != nil {
		return nil, nil, err
	}
	offset := size * (page - 1)
	rs, err := ulh.Offset(offset).Limit(size).All(ctx)
	if err != nil {
		return nil, nil, err
	}
	has := (page * size) < cnt
	return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil
}

func (w *WorkspaceQuery) Page(ctx context.Context, page, size int) ([]*Workspace, *PageInfo, error) {
	cnt, err := w.Count(ctx)
	if err != nil {
		return nil, nil, err
	}
	offset := size * (page - 1)
	rs, err := w.Offset(offset).Limit(size).All(ctx)
	if err != nil {
		return nil, nil, err
	}
	has := (page * size) < cnt
	return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil
}

func (wf *WorkspaceFileQuery) Page(ctx context.Context, page, size int) ([]*WorkspaceFile, *PageInfo, error) {
	cnt, err := wf.Count(ctx)
	if err != nil {
		return nil, nil, err
	}
	offset := size * (page - 1)
	rs, err := wf.Offset(offset).Limit(size).All(ctx)
	if err != nil {
		return nil, nil, err
	}
	has := (page * size) < cnt
	return rs, &PageInfo{HasNextPage: has, TotalCount: int64(cnt)}, nil
}
