123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629 |
- // Code generated by ent, DO NOT EDIT.
- package intercept
- import (
- "context"
- "fmt"
- "wechat-api/ent"
- "wechat-api/ent/agent"
- "wechat-api/ent/batchmsg"
- "wechat-api/ent/contact"
- "wechat-api/ent/employee"
- "wechat-api/ent/label"
- "wechat-api/ent/labelrelationship"
- "wechat-api/ent/message"
- "wechat-api/ent/messagerecords"
- "wechat-api/ent/msg"
- "wechat-api/ent/predicate"
- "wechat-api/ent/server"
- "wechat-api/ent/sopnode"
- "wechat-api/ent/sopstage"
- "wechat-api/ent/soptask"
- "wechat-api/ent/token"
- "wechat-api/ent/tutorial"
- "wechat-api/ent/workexperience"
- "wechat-api/ent/wx"
- "entgo.io/ent/dialect/sql"
- )
- // The Query interface represents an operation that queries a graph.
- // By using this interface, users can write generic code that manipulates
- // query builders of different types.
- type Query interface {
- // Type returns the string representation of the query type.
- Type() string
- // Limit the number of records to be returned by this query.
- Limit(int)
- // Offset to start from.
- Offset(int)
- // Unique configures the query builder to filter duplicate records.
- Unique(bool)
- // Order specifies how the records should be ordered.
- Order(...func(*sql.Selector))
- // WhereP appends storage-level predicates to the query builder. Using this method, users
- // can use type-assertion to append predicates that do not depend on any generated package.
- WhereP(...func(*sql.Selector))
- }
- // The Func type is an adapter that allows ordinary functions to be used as interceptors.
- // Unlike traversal functions, interceptors are skipped during graph traversals. Note that the
- // implementation of Func is different from the one defined in entgo.io/ent.InterceptFunc.
- type Func func(context.Context, Query) error
- // Intercept calls f(ctx, q) and then applied the next Querier.
- func (f Func) Intercept(next ent.Querier) ent.Querier {
- return ent.QuerierFunc(func(ctx context.Context, q ent.Query) (ent.Value, error) {
- query, err := NewQuery(q)
- if err != nil {
- return nil, err
- }
- if err := f(ctx, query); err != nil {
- return nil, err
- }
- return next.Query(ctx, q)
- })
- }
- // The TraverseFunc type is an adapter to allow the use of ordinary function as Traverser.
- // If f is a function with the appropriate signature, TraverseFunc(f) is a Traverser that calls f.
- type TraverseFunc func(context.Context, Query) error
- // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
- func (f TraverseFunc) Intercept(next ent.Querier) ent.Querier {
- return next
- }
- // Traverse calls f(ctx, q).
- func (f TraverseFunc) Traverse(ctx context.Context, q ent.Query) error {
- query, err := NewQuery(q)
- if err != nil {
- return err
- }
- return f(ctx, query)
- }
- // The AgentFunc type is an adapter to allow the use of ordinary function as a Querier.
- type AgentFunc func(context.Context, *ent.AgentQuery) (ent.Value, error)
- // Query calls f(ctx, q).
- func (f AgentFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
- if q, ok := q.(*ent.AgentQuery); ok {
- return f(ctx, q)
- }
- return nil, fmt.Errorf("unexpected query type %T. expect *ent.AgentQuery", q)
- }
- // The TraverseAgent type is an adapter to allow the use of ordinary function as Traverser.
- type TraverseAgent func(context.Context, *ent.AgentQuery) error
- // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
- func (f TraverseAgent) Intercept(next ent.Querier) ent.Querier {
- return next
- }
- // Traverse calls f(ctx, q).
- func (f TraverseAgent) Traverse(ctx context.Context, q ent.Query) error {
- if q, ok := q.(*ent.AgentQuery); ok {
- return f(ctx, q)
- }
- return fmt.Errorf("unexpected query type %T. expect *ent.AgentQuery", q)
- }
- // The BatchMsgFunc type is an adapter to allow the use of ordinary function as a Querier.
- type BatchMsgFunc func(context.Context, *ent.BatchMsgQuery) (ent.Value, error)
- // Query calls f(ctx, q).
- func (f BatchMsgFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
- if q, ok := q.(*ent.BatchMsgQuery); ok {
- return f(ctx, q)
- }
- return nil, fmt.Errorf("unexpected query type %T. expect *ent.BatchMsgQuery", q)
- }
- // The TraverseBatchMsg type is an adapter to allow the use of ordinary function as Traverser.
- type TraverseBatchMsg func(context.Context, *ent.BatchMsgQuery) error
- // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
- func (f TraverseBatchMsg) Intercept(next ent.Querier) ent.Querier {
- return next
- }
- // Traverse calls f(ctx, q).
- func (f TraverseBatchMsg) Traverse(ctx context.Context, q ent.Query) error {
- if q, ok := q.(*ent.BatchMsgQuery); ok {
- return f(ctx, q)
- }
- return fmt.Errorf("unexpected query type %T. expect *ent.BatchMsgQuery", q)
- }
- // The ContactFunc type is an adapter to allow the use of ordinary function as a Querier.
- type ContactFunc func(context.Context, *ent.ContactQuery) (ent.Value, error)
- // Query calls f(ctx, q).
- func (f ContactFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
- if q, ok := q.(*ent.ContactQuery); ok {
- return f(ctx, q)
- }
- return nil, fmt.Errorf("unexpected query type %T. expect *ent.ContactQuery", q)
- }
- // The TraverseContact type is an adapter to allow the use of ordinary function as Traverser.
- type TraverseContact func(context.Context, *ent.ContactQuery) error
- // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
- func (f TraverseContact) Intercept(next ent.Querier) ent.Querier {
- return next
- }
- // Traverse calls f(ctx, q).
- func (f TraverseContact) Traverse(ctx context.Context, q ent.Query) error {
- if q, ok := q.(*ent.ContactQuery); ok {
- return f(ctx, q)
- }
- return fmt.Errorf("unexpected query type %T. expect *ent.ContactQuery", q)
- }
- // The EmployeeFunc type is an adapter to allow the use of ordinary function as a Querier.
- type EmployeeFunc func(context.Context, *ent.EmployeeQuery) (ent.Value, error)
- // Query calls f(ctx, q).
- func (f EmployeeFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
- if q, ok := q.(*ent.EmployeeQuery); ok {
- return f(ctx, q)
- }
- return nil, fmt.Errorf("unexpected query type %T. expect *ent.EmployeeQuery", q)
- }
- // The TraverseEmployee type is an adapter to allow the use of ordinary function as Traverser.
- type TraverseEmployee func(context.Context, *ent.EmployeeQuery) error
- // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
- func (f TraverseEmployee) Intercept(next ent.Querier) ent.Querier {
- return next
- }
- // Traverse calls f(ctx, q).
- func (f TraverseEmployee) Traverse(ctx context.Context, q ent.Query) error {
- if q, ok := q.(*ent.EmployeeQuery); ok {
- return f(ctx, q)
- }
- return fmt.Errorf("unexpected query type %T. expect *ent.EmployeeQuery", q)
- }
- // The LabelFunc type is an adapter to allow the use of ordinary function as a Querier.
- type LabelFunc func(context.Context, *ent.LabelQuery) (ent.Value, error)
- // Query calls f(ctx, q).
- func (f LabelFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
- if q, ok := q.(*ent.LabelQuery); ok {
- return f(ctx, q)
- }
- return nil, fmt.Errorf("unexpected query type %T. expect *ent.LabelQuery", q)
- }
- // The TraverseLabel type is an adapter to allow the use of ordinary function as Traverser.
- type TraverseLabel func(context.Context, *ent.LabelQuery) error
- // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
- func (f TraverseLabel) Intercept(next ent.Querier) ent.Querier {
- return next
- }
- // Traverse calls f(ctx, q).
- func (f TraverseLabel) Traverse(ctx context.Context, q ent.Query) error {
- if q, ok := q.(*ent.LabelQuery); ok {
- return f(ctx, q)
- }
- return fmt.Errorf("unexpected query type %T. expect *ent.LabelQuery", q)
- }
- // The LabelRelationshipFunc type is an adapter to allow the use of ordinary function as a Querier.
- type LabelRelationshipFunc func(context.Context, *ent.LabelRelationshipQuery) (ent.Value, error)
- // Query calls f(ctx, q).
- func (f LabelRelationshipFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
- if q, ok := q.(*ent.LabelRelationshipQuery); ok {
- return f(ctx, q)
- }
- return nil, fmt.Errorf("unexpected query type %T. expect *ent.LabelRelationshipQuery", q)
- }
- // The TraverseLabelRelationship type is an adapter to allow the use of ordinary function as Traverser.
- type TraverseLabelRelationship func(context.Context, *ent.LabelRelationshipQuery) error
- // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
- func (f TraverseLabelRelationship) Intercept(next ent.Querier) ent.Querier {
- return next
- }
- // Traverse calls f(ctx, q).
- func (f TraverseLabelRelationship) Traverse(ctx context.Context, q ent.Query) error {
- if q, ok := q.(*ent.LabelRelationshipQuery); ok {
- return f(ctx, q)
- }
- return fmt.Errorf("unexpected query type %T. expect *ent.LabelRelationshipQuery", q)
- }
- // The MessageFunc type is an adapter to allow the use of ordinary function as a Querier.
- type MessageFunc func(context.Context, *ent.MessageQuery) (ent.Value, error)
- // Query calls f(ctx, q).
- func (f MessageFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
- if q, ok := q.(*ent.MessageQuery); ok {
- return f(ctx, q)
- }
- return nil, fmt.Errorf("unexpected query type %T. expect *ent.MessageQuery", q)
- }
- // The TraverseMessage type is an adapter to allow the use of ordinary function as Traverser.
- type TraverseMessage func(context.Context, *ent.MessageQuery) error
- // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
- func (f TraverseMessage) Intercept(next ent.Querier) ent.Querier {
- return next
- }
- // Traverse calls f(ctx, q).
- func (f TraverseMessage) Traverse(ctx context.Context, q ent.Query) error {
- if q, ok := q.(*ent.MessageQuery); ok {
- return f(ctx, q)
- }
- return fmt.Errorf("unexpected query type %T. expect *ent.MessageQuery", q)
- }
- // The MessageRecordsFunc type is an adapter to allow the use of ordinary function as a Querier.
- type MessageRecordsFunc func(context.Context, *ent.MessageRecordsQuery) (ent.Value, error)
- // Query calls f(ctx, q).
- func (f MessageRecordsFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
- if q, ok := q.(*ent.MessageRecordsQuery); ok {
- return f(ctx, q)
- }
- return nil, fmt.Errorf("unexpected query type %T. expect *ent.MessageRecordsQuery", q)
- }
- // The TraverseMessageRecords type is an adapter to allow the use of ordinary function as Traverser.
- type TraverseMessageRecords func(context.Context, *ent.MessageRecordsQuery) error
- // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
- func (f TraverseMessageRecords) Intercept(next ent.Querier) ent.Querier {
- return next
- }
- // Traverse calls f(ctx, q).
- func (f TraverseMessageRecords) Traverse(ctx context.Context, q ent.Query) error {
- if q, ok := q.(*ent.MessageRecordsQuery); ok {
- return f(ctx, q)
- }
- return fmt.Errorf("unexpected query type %T. expect *ent.MessageRecordsQuery", q)
- }
- // The MsgFunc type is an adapter to allow the use of ordinary function as a Querier.
- type MsgFunc func(context.Context, *ent.MsgQuery) (ent.Value, error)
- // Query calls f(ctx, q).
- func (f MsgFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
- if q, ok := q.(*ent.MsgQuery); ok {
- return f(ctx, q)
- }
- return nil, fmt.Errorf("unexpected query type %T. expect *ent.MsgQuery", q)
- }
- // The TraverseMsg type is an adapter to allow the use of ordinary function as Traverser.
- type TraverseMsg func(context.Context, *ent.MsgQuery) error
- // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
- func (f TraverseMsg) Intercept(next ent.Querier) ent.Querier {
- return next
- }
- // Traverse calls f(ctx, q).
- func (f TraverseMsg) Traverse(ctx context.Context, q ent.Query) error {
- if q, ok := q.(*ent.MsgQuery); ok {
- return f(ctx, q)
- }
- return fmt.Errorf("unexpected query type %T. expect *ent.MsgQuery", q)
- }
- // The ServerFunc type is an adapter to allow the use of ordinary function as a Querier.
- type ServerFunc func(context.Context, *ent.ServerQuery) (ent.Value, error)
- // Query calls f(ctx, q).
- func (f ServerFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
- if q, ok := q.(*ent.ServerQuery); ok {
- return f(ctx, q)
- }
- return nil, fmt.Errorf("unexpected query type %T. expect *ent.ServerQuery", q)
- }
- // The TraverseServer type is an adapter to allow the use of ordinary function as Traverser.
- type TraverseServer func(context.Context, *ent.ServerQuery) error
- // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
- func (f TraverseServer) Intercept(next ent.Querier) ent.Querier {
- return next
- }
- // Traverse calls f(ctx, q).
- func (f TraverseServer) Traverse(ctx context.Context, q ent.Query) error {
- if q, ok := q.(*ent.ServerQuery); ok {
- return f(ctx, q)
- }
- return fmt.Errorf("unexpected query type %T. expect *ent.ServerQuery", q)
- }
- // The SopNodeFunc type is an adapter to allow the use of ordinary function as a Querier.
- type SopNodeFunc func(context.Context, *ent.SopNodeQuery) (ent.Value, error)
- // Query calls f(ctx, q).
- func (f SopNodeFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
- if q, ok := q.(*ent.SopNodeQuery); ok {
- return f(ctx, q)
- }
- return nil, fmt.Errorf("unexpected query type %T. expect *ent.SopNodeQuery", q)
- }
- // The TraverseSopNode type is an adapter to allow the use of ordinary function as Traverser.
- type TraverseSopNode func(context.Context, *ent.SopNodeQuery) error
- // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
- func (f TraverseSopNode) Intercept(next ent.Querier) ent.Querier {
- return next
- }
- // Traverse calls f(ctx, q).
- func (f TraverseSopNode) Traverse(ctx context.Context, q ent.Query) error {
- if q, ok := q.(*ent.SopNodeQuery); ok {
- return f(ctx, q)
- }
- return fmt.Errorf("unexpected query type %T. expect *ent.SopNodeQuery", q)
- }
- // The SopStageFunc type is an adapter to allow the use of ordinary function as a Querier.
- type SopStageFunc func(context.Context, *ent.SopStageQuery) (ent.Value, error)
- // Query calls f(ctx, q).
- func (f SopStageFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
- if q, ok := q.(*ent.SopStageQuery); ok {
- return f(ctx, q)
- }
- return nil, fmt.Errorf("unexpected query type %T. expect *ent.SopStageQuery", q)
- }
- // The TraverseSopStage type is an adapter to allow the use of ordinary function as Traverser.
- type TraverseSopStage func(context.Context, *ent.SopStageQuery) error
- // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
- func (f TraverseSopStage) Intercept(next ent.Querier) ent.Querier {
- return next
- }
- // Traverse calls f(ctx, q).
- func (f TraverseSopStage) Traverse(ctx context.Context, q ent.Query) error {
- if q, ok := q.(*ent.SopStageQuery); ok {
- return f(ctx, q)
- }
- return fmt.Errorf("unexpected query type %T. expect *ent.SopStageQuery", q)
- }
- // The SopTaskFunc type is an adapter to allow the use of ordinary function as a Querier.
- type SopTaskFunc func(context.Context, *ent.SopTaskQuery) (ent.Value, error)
- // Query calls f(ctx, q).
- func (f SopTaskFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
- if q, ok := q.(*ent.SopTaskQuery); ok {
- return f(ctx, q)
- }
- return nil, fmt.Errorf("unexpected query type %T. expect *ent.SopTaskQuery", q)
- }
- // The TraverseSopTask type is an adapter to allow the use of ordinary function as Traverser.
- type TraverseSopTask func(context.Context, *ent.SopTaskQuery) error
- // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
- func (f TraverseSopTask) Intercept(next ent.Querier) ent.Querier {
- return next
- }
- // Traverse calls f(ctx, q).
- func (f TraverseSopTask) Traverse(ctx context.Context, q ent.Query) error {
- if q, ok := q.(*ent.SopTaskQuery); ok {
- return f(ctx, q)
- }
- return fmt.Errorf("unexpected query type %T. expect *ent.SopTaskQuery", q)
- }
- // The TokenFunc type is an adapter to allow the use of ordinary function as a Querier.
- type TokenFunc func(context.Context, *ent.TokenQuery) (ent.Value, error)
- // Query calls f(ctx, q).
- func (f TokenFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
- if q, ok := q.(*ent.TokenQuery); ok {
- return f(ctx, q)
- }
- return nil, fmt.Errorf("unexpected query type %T. expect *ent.TokenQuery", q)
- }
- // The TraverseToken type is an adapter to allow the use of ordinary function as Traverser.
- type TraverseToken func(context.Context, *ent.TokenQuery) error
- // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
- func (f TraverseToken) Intercept(next ent.Querier) ent.Querier {
- return next
- }
- // Traverse calls f(ctx, q).
- func (f TraverseToken) Traverse(ctx context.Context, q ent.Query) error {
- if q, ok := q.(*ent.TokenQuery); ok {
- return f(ctx, q)
- }
- return fmt.Errorf("unexpected query type %T. expect *ent.TokenQuery", q)
- }
- // The TutorialFunc type is an adapter to allow the use of ordinary function as a Querier.
- type TutorialFunc func(context.Context, *ent.TutorialQuery) (ent.Value, error)
- // Query calls f(ctx, q).
- func (f TutorialFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
- if q, ok := q.(*ent.TutorialQuery); ok {
- return f(ctx, q)
- }
- return nil, fmt.Errorf("unexpected query type %T. expect *ent.TutorialQuery", q)
- }
- // The TraverseTutorial type is an adapter to allow the use of ordinary function as Traverser.
- type TraverseTutorial func(context.Context, *ent.TutorialQuery) error
- // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
- func (f TraverseTutorial) Intercept(next ent.Querier) ent.Querier {
- return next
- }
- // Traverse calls f(ctx, q).
- func (f TraverseTutorial) Traverse(ctx context.Context, q ent.Query) error {
- if q, ok := q.(*ent.TutorialQuery); ok {
- return f(ctx, q)
- }
- return fmt.Errorf("unexpected query type %T. expect *ent.TutorialQuery", q)
- }
- // The WorkExperienceFunc type is an adapter to allow the use of ordinary function as a Querier.
- type WorkExperienceFunc func(context.Context, *ent.WorkExperienceQuery) (ent.Value, error)
- // Query calls f(ctx, q).
- func (f WorkExperienceFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
- if q, ok := q.(*ent.WorkExperienceQuery); ok {
- return f(ctx, q)
- }
- return nil, fmt.Errorf("unexpected query type %T. expect *ent.WorkExperienceQuery", q)
- }
- // The TraverseWorkExperience type is an adapter to allow the use of ordinary function as Traverser.
- type TraverseWorkExperience func(context.Context, *ent.WorkExperienceQuery) error
- // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
- func (f TraverseWorkExperience) Intercept(next ent.Querier) ent.Querier {
- return next
- }
- // Traverse calls f(ctx, q).
- func (f TraverseWorkExperience) Traverse(ctx context.Context, q ent.Query) error {
- if q, ok := q.(*ent.WorkExperienceQuery); ok {
- return f(ctx, q)
- }
- return fmt.Errorf("unexpected query type %T. expect *ent.WorkExperienceQuery", q)
- }
- // The WxFunc type is an adapter to allow the use of ordinary function as a Querier.
- type WxFunc func(context.Context, *ent.WxQuery) (ent.Value, error)
- // Query calls f(ctx, q).
- func (f WxFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
- if q, ok := q.(*ent.WxQuery); ok {
- return f(ctx, q)
- }
- return nil, fmt.Errorf("unexpected query type %T. expect *ent.WxQuery", q)
- }
- // The TraverseWx type is an adapter to allow the use of ordinary function as Traverser.
- type TraverseWx func(context.Context, *ent.WxQuery) error
- // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
- func (f TraverseWx) Intercept(next ent.Querier) ent.Querier {
- return next
- }
- // Traverse calls f(ctx, q).
- func (f TraverseWx) Traverse(ctx context.Context, q ent.Query) error {
- if q, ok := q.(*ent.WxQuery); ok {
- return f(ctx, q)
- }
- return fmt.Errorf("unexpected query type %T. expect *ent.WxQuery", q)
- }
- // NewQuery returns the generic Query interface for the given typed query.
- func NewQuery(q ent.Query) (Query, error) {
- switch q := q.(type) {
- case *ent.AgentQuery:
- return &query[*ent.AgentQuery, predicate.Agent, agent.OrderOption]{typ: ent.TypeAgent, tq: q}, nil
- case *ent.BatchMsgQuery:
- return &query[*ent.BatchMsgQuery, predicate.BatchMsg, batchmsg.OrderOption]{typ: ent.TypeBatchMsg, tq: q}, nil
- case *ent.ContactQuery:
- return &query[*ent.ContactQuery, predicate.Contact, contact.OrderOption]{typ: ent.TypeContact, tq: q}, nil
- case *ent.EmployeeQuery:
- return &query[*ent.EmployeeQuery, predicate.Employee, employee.OrderOption]{typ: ent.TypeEmployee, tq: q}, nil
- case *ent.LabelQuery:
- return &query[*ent.LabelQuery, predicate.Label, label.OrderOption]{typ: ent.TypeLabel, tq: q}, nil
- case *ent.LabelRelationshipQuery:
- return &query[*ent.LabelRelationshipQuery, predicate.LabelRelationship, labelrelationship.OrderOption]{typ: ent.TypeLabelRelationship, tq: q}, nil
- case *ent.MessageQuery:
- return &query[*ent.MessageQuery, predicate.Message, message.OrderOption]{typ: ent.TypeMessage, tq: q}, nil
- case *ent.MessageRecordsQuery:
- return &query[*ent.MessageRecordsQuery, predicate.MessageRecords, messagerecords.OrderOption]{typ: ent.TypeMessageRecords, tq: q}, nil
- case *ent.MsgQuery:
- return &query[*ent.MsgQuery, predicate.Msg, msg.OrderOption]{typ: ent.TypeMsg, tq: q}, nil
- case *ent.ServerQuery:
- return &query[*ent.ServerQuery, predicate.Server, server.OrderOption]{typ: ent.TypeServer, tq: q}, nil
- case *ent.SopNodeQuery:
- return &query[*ent.SopNodeQuery, predicate.SopNode, sopnode.OrderOption]{typ: ent.TypeSopNode, tq: q}, nil
- case *ent.SopStageQuery:
- return &query[*ent.SopStageQuery, predicate.SopStage, sopstage.OrderOption]{typ: ent.TypeSopStage, tq: q}, nil
- case *ent.SopTaskQuery:
- return &query[*ent.SopTaskQuery, predicate.SopTask, soptask.OrderOption]{typ: ent.TypeSopTask, tq: q}, nil
- case *ent.TokenQuery:
- return &query[*ent.TokenQuery, predicate.Token, token.OrderOption]{typ: ent.TypeToken, tq: q}, nil
- case *ent.TutorialQuery:
- return &query[*ent.TutorialQuery, predicate.Tutorial, tutorial.OrderOption]{typ: ent.TypeTutorial, tq: q}, nil
- case *ent.WorkExperienceQuery:
- return &query[*ent.WorkExperienceQuery, predicate.WorkExperience, workexperience.OrderOption]{typ: ent.TypeWorkExperience, tq: q}, nil
- case *ent.WxQuery:
- return &query[*ent.WxQuery, predicate.Wx, wx.OrderOption]{typ: ent.TypeWx, tq: q}, nil
- default:
- return nil, fmt.Errorf("unknown query type %T", q)
- }
- }
- type query[T any, P ~func(*sql.Selector), R ~func(*sql.Selector)] struct {
- typ string
- tq interface {
- Limit(int) T
- Offset(int) T
- Unique(bool) T
- Order(...R) T
- Where(...P) T
- }
- }
- func (q query[T, P, R]) Type() string {
- return q.typ
- }
- func (q query[T, P, R]) Limit(limit int) {
- q.tq.Limit(limit)
- }
- func (q query[T, P, R]) Offset(offset int) {
- q.tq.Offset(offset)
- }
- func (q query[T, P, R]) Unique(unique bool) {
- q.tq.Unique(unique)
- }
- func (q query[T, P, R]) Order(orders ...func(*sql.Selector)) {
- rs := make([]R, len(orders))
- for i := range orders {
- rs[i] = orders[i]
- }
- q.tq.Order(rs...)
- }
- func (q query[T, P, R]) WhereP(ps ...func(*sql.Selector)) {
- p := make([]P, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- q.tq.Where(p...)
- }
|