intercept.go 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409
  1. // Code generated by ent, DO NOT EDIT.
  2. package intercept
  3. import (
  4. "context"
  5. "fmt"
  6. "wechat-api/ent"
  7. "wechat-api/ent/agent"
  8. "wechat-api/ent/agentbase"
  9. "wechat-api/ent/aliyunavatar"
  10. "wechat-api/ent/allocagent"
  11. "wechat-api/ent/apikey"
  12. "wechat-api/ent/batchmsg"
  13. "wechat-api/ent/category"
  14. "wechat-api/ent/chatrecords"
  15. "wechat-api/ent/chatsession"
  16. "wechat-api/ent/contact"
  17. "wechat-api/ent/contactfield"
  18. "wechat-api/ent/contactfieldtemplate"
  19. "wechat-api/ent/creditbalance"
  20. "wechat-api/ent/creditusage"
  21. "wechat-api/ent/employee"
  22. "wechat-api/ent/employeeconfig"
  23. "wechat-api/ent/label"
  24. "wechat-api/ent/labelrelationship"
  25. "wechat-api/ent/labeltagging"
  26. "wechat-api/ent/message"
  27. "wechat-api/ent/messagerecords"
  28. "wechat-api/ent/msg"
  29. "wechat-api/ent/payrecharge"
  30. "wechat-api/ent/predicate"
  31. "wechat-api/ent/server"
  32. "wechat-api/ent/sopnode"
  33. "wechat-api/ent/sopstage"
  34. "wechat-api/ent/soptask"
  35. "wechat-api/ent/token"
  36. "wechat-api/ent/tutorial"
  37. "wechat-api/ent/usagedetail"
  38. "wechat-api/ent/usagestatisticday"
  39. "wechat-api/ent/usagestatistichour"
  40. "wechat-api/ent/usagestatisticmonth"
  41. "wechat-api/ent/usagetotal"
  42. "wechat-api/ent/whatsapp"
  43. "wechat-api/ent/whatsappchannel"
  44. "wechat-api/ent/workexperience"
  45. "wechat-api/ent/wpchatroom"
  46. "wechat-api/ent/wpchatroommember"
  47. "wechat-api/ent/wx"
  48. "wechat-api/ent/wxcard"
  49. "wechat-api/ent/wxcarduser"
  50. "wechat-api/ent/wxcardvisit"
  51. "entgo.io/ent/dialect/sql"
  52. )
  53. // The Query interface represents an operation that queries a graph.
  54. // By using this interface, users can write generic code that manipulates
  55. // query builders of different types.
  56. type Query interface {
  57. // Type returns the string representation of the query type.
  58. Type() string
  59. // Limit the number of records to be returned by this query.
  60. Limit(int)
  61. // Offset to start from.
  62. Offset(int)
  63. // Unique configures the query builder to filter duplicate records.
  64. Unique(bool)
  65. // Order specifies how the records should be ordered.
  66. Order(...func(*sql.Selector))
  67. // WhereP appends storage-level predicates to the query builder. Using this method, users
  68. // can use type-assertion to append predicates that do not depend on any generated package.
  69. WhereP(...func(*sql.Selector))
  70. }
  71. // The Func type is an adapter that allows ordinary functions to be used as interceptors.
  72. // Unlike traversal functions, interceptors are skipped during graph traversals. Note that the
  73. // implementation of Func is different from the one defined in entgo.io/ent.InterceptFunc.
  74. type Func func(context.Context, Query) error
  75. // Intercept calls f(ctx, q) and then applied the next Querier.
  76. func (f Func) Intercept(next ent.Querier) ent.Querier {
  77. return ent.QuerierFunc(func(ctx context.Context, q ent.Query) (ent.Value, error) {
  78. query, err := NewQuery(q)
  79. if err != nil {
  80. return nil, err
  81. }
  82. if err := f(ctx, query); err != nil {
  83. return nil, err
  84. }
  85. return next.Query(ctx, q)
  86. })
  87. }
  88. // The TraverseFunc type is an adapter to allow the use of ordinary function as Traverser.
  89. // If f is a function with the appropriate signature, TraverseFunc(f) is a Traverser that calls f.
  90. type TraverseFunc func(context.Context, Query) error
  91. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  92. func (f TraverseFunc) Intercept(next ent.Querier) ent.Querier {
  93. return next
  94. }
  95. // Traverse calls f(ctx, q).
  96. func (f TraverseFunc) Traverse(ctx context.Context, q ent.Query) error {
  97. query, err := NewQuery(q)
  98. if err != nil {
  99. return err
  100. }
  101. return f(ctx, query)
  102. }
  103. // The AgentFunc type is an adapter to allow the use of ordinary function as a Querier.
  104. type AgentFunc func(context.Context, *ent.AgentQuery) (ent.Value, error)
  105. // Query calls f(ctx, q).
  106. func (f AgentFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  107. if q, ok := q.(*ent.AgentQuery); ok {
  108. return f(ctx, q)
  109. }
  110. return nil, fmt.Errorf("unexpected query type %T. expect *ent.AgentQuery", q)
  111. }
  112. // The TraverseAgent type is an adapter to allow the use of ordinary function as Traverser.
  113. type TraverseAgent func(context.Context, *ent.AgentQuery) error
  114. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  115. func (f TraverseAgent) Intercept(next ent.Querier) ent.Querier {
  116. return next
  117. }
  118. // Traverse calls f(ctx, q).
  119. func (f TraverseAgent) Traverse(ctx context.Context, q ent.Query) error {
  120. if q, ok := q.(*ent.AgentQuery); ok {
  121. return f(ctx, q)
  122. }
  123. return fmt.Errorf("unexpected query type %T. expect *ent.AgentQuery", q)
  124. }
  125. // The AgentBaseFunc type is an adapter to allow the use of ordinary function as a Querier.
  126. type AgentBaseFunc func(context.Context, *ent.AgentBaseQuery) (ent.Value, error)
  127. // Query calls f(ctx, q).
  128. func (f AgentBaseFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  129. if q, ok := q.(*ent.AgentBaseQuery); ok {
  130. return f(ctx, q)
  131. }
  132. return nil, fmt.Errorf("unexpected query type %T. expect *ent.AgentBaseQuery", q)
  133. }
  134. // The TraverseAgentBase type is an adapter to allow the use of ordinary function as Traverser.
  135. type TraverseAgentBase func(context.Context, *ent.AgentBaseQuery) error
  136. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  137. func (f TraverseAgentBase) Intercept(next ent.Querier) ent.Querier {
  138. return next
  139. }
  140. // Traverse calls f(ctx, q).
  141. func (f TraverseAgentBase) Traverse(ctx context.Context, q ent.Query) error {
  142. if q, ok := q.(*ent.AgentBaseQuery); ok {
  143. return f(ctx, q)
  144. }
  145. return fmt.Errorf("unexpected query type %T. expect *ent.AgentBaseQuery", q)
  146. }
  147. // The AliyunAvatarFunc type is an adapter to allow the use of ordinary function as a Querier.
  148. type AliyunAvatarFunc func(context.Context, *ent.AliyunAvatarQuery) (ent.Value, error)
  149. // Query calls f(ctx, q).
  150. func (f AliyunAvatarFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  151. if q, ok := q.(*ent.AliyunAvatarQuery); ok {
  152. return f(ctx, q)
  153. }
  154. return nil, fmt.Errorf("unexpected query type %T. expect *ent.AliyunAvatarQuery", q)
  155. }
  156. // The TraverseAliyunAvatar type is an adapter to allow the use of ordinary function as Traverser.
  157. type TraverseAliyunAvatar func(context.Context, *ent.AliyunAvatarQuery) error
  158. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  159. func (f TraverseAliyunAvatar) Intercept(next ent.Querier) ent.Querier {
  160. return next
  161. }
  162. // Traverse calls f(ctx, q).
  163. func (f TraverseAliyunAvatar) Traverse(ctx context.Context, q ent.Query) error {
  164. if q, ok := q.(*ent.AliyunAvatarQuery); ok {
  165. return f(ctx, q)
  166. }
  167. return fmt.Errorf("unexpected query type %T. expect *ent.AliyunAvatarQuery", q)
  168. }
  169. // The AllocAgentFunc type is an adapter to allow the use of ordinary function as a Querier.
  170. type AllocAgentFunc func(context.Context, *ent.AllocAgentQuery) (ent.Value, error)
  171. // Query calls f(ctx, q).
  172. func (f AllocAgentFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  173. if q, ok := q.(*ent.AllocAgentQuery); ok {
  174. return f(ctx, q)
  175. }
  176. return nil, fmt.Errorf("unexpected query type %T. expect *ent.AllocAgentQuery", q)
  177. }
  178. // The TraverseAllocAgent type is an adapter to allow the use of ordinary function as Traverser.
  179. type TraverseAllocAgent func(context.Context, *ent.AllocAgentQuery) error
  180. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  181. func (f TraverseAllocAgent) Intercept(next ent.Querier) ent.Querier {
  182. return next
  183. }
  184. // Traverse calls f(ctx, q).
  185. func (f TraverseAllocAgent) Traverse(ctx context.Context, q ent.Query) error {
  186. if q, ok := q.(*ent.AllocAgentQuery); ok {
  187. return f(ctx, q)
  188. }
  189. return fmt.Errorf("unexpected query type %T. expect *ent.AllocAgentQuery", q)
  190. }
  191. // The ApiKeyFunc type is an adapter to allow the use of ordinary function as a Querier.
  192. type ApiKeyFunc func(context.Context, *ent.ApiKeyQuery) (ent.Value, error)
  193. // Query calls f(ctx, q).
  194. func (f ApiKeyFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  195. if q, ok := q.(*ent.ApiKeyQuery); ok {
  196. return f(ctx, q)
  197. }
  198. return nil, fmt.Errorf("unexpected query type %T. expect *ent.ApiKeyQuery", q)
  199. }
  200. // The TraverseApiKey type is an adapter to allow the use of ordinary function as Traverser.
  201. type TraverseApiKey func(context.Context, *ent.ApiKeyQuery) error
  202. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  203. func (f TraverseApiKey) Intercept(next ent.Querier) ent.Querier {
  204. return next
  205. }
  206. // Traverse calls f(ctx, q).
  207. func (f TraverseApiKey) Traverse(ctx context.Context, q ent.Query) error {
  208. if q, ok := q.(*ent.ApiKeyQuery); ok {
  209. return f(ctx, q)
  210. }
  211. return fmt.Errorf("unexpected query type %T. expect *ent.ApiKeyQuery", q)
  212. }
  213. // The BatchMsgFunc type is an adapter to allow the use of ordinary function as a Querier.
  214. type BatchMsgFunc func(context.Context, *ent.BatchMsgQuery) (ent.Value, error)
  215. // Query calls f(ctx, q).
  216. func (f BatchMsgFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  217. if q, ok := q.(*ent.BatchMsgQuery); ok {
  218. return f(ctx, q)
  219. }
  220. return nil, fmt.Errorf("unexpected query type %T. expect *ent.BatchMsgQuery", q)
  221. }
  222. // The TraverseBatchMsg type is an adapter to allow the use of ordinary function as Traverser.
  223. type TraverseBatchMsg func(context.Context, *ent.BatchMsgQuery) error
  224. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  225. func (f TraverseBatchMsg) Intercept(next ent.Querier) ent.Querier {
  226. return next
  227. }
  228. // Traverse calls f(ctx, q).
  229. func (f TraverseBatchMsg) Traverse(ctx context.Context, q ent.Query) error {
  230. if q, ok := q.(*ent.BatchMsgQuery); ok {
  231. return f(ctx, q)
  232. }
  233. return fmt.Errorf("unexpected query type %T. expect *ent.BatchMsgQuery", q)
  234. }
  235. // The CategoryFunc type is an adapter to allow the use of ordinary function as a Querier.
  236. type CategoryFunc func(context.Context, *ent.CategoryQuery) (ent.Value, error)
  237. // Query calls f(ctx, q).
  238. func (f CategoryFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  239. if q, ok := q.(*ent.CategoryQuery); ok {
  240. return f(ctx, q)
  241. }
  242. return nil, fmt.Errorf("unexpected query type %T. expect *ent.CategoryQuery", q)
  243. }
  244. // The TraverseCategory type is an adapter to allow the use of ordinary function as Traverser.
  245. type TraverseCategory func(context.Context, *ent.CategoryQuery) error
  246. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  247. func (f TraverseCategory) Intercept(next ent.Querier) ent.Querier {
  248. return next
  249. }
  250. // Traverse calls f(ctx, q).
  251. func (f TraverseCategory) Traverse(ctx context.Context, q ent.Query) error {
  252. if q, ok := q.(*ent.CategoryQuery); ok {
  253. return f(ctx, q)
  254. }
  255. return fmt.Errorf("unexpected query type %T. expect *ent.CategoryQuery", q)
  256. }
  257. // The ChatRecordsFunc type is an adapter to allow the use of ordinary function as a Querier.
  258. type ChatRecordsFunc func(context.Context, *ent.ChatRecordsQuery) (ent.Value, error)
  259. // Query calls f(ctx, q).
  260. func (f ChatRecordsFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  261. if q, ok := q.(*ent.ChatRecordsQuery); ok {
  262. return f(ctx, q)
  263. }
  264. return nil, fmt.Errorf("unexpected query type %T. expect *ent.ChatRecordsQuery", q)
  265. }
  266. // The TraverseChatRecords type is an adapter to allow the use of ordinary function as Traverser.
  267. type TraverseChatRecords func(context.Context, *ent.ChatRecordsQuery) error
  268. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  269. func (f TraverseChatRecords) Intercept(next ent.Querier) ent.Querier {
  270. return next
  271. }
  272. // Traverse calls f(ctx, q).
  273. func (f TraverseChatRecords) Traverse(ctx context.Context, q ent.Query) error {
  274. if q, ok := q.(*ent.ChatRecordsQuery); ok {
  275. return f(ctx, q)
  276. }
  277. return fmt.Errorf("unexpected query type %T. expect *ent.ChatRecordsQuery", q)
  278. }
  279. // The ChatSessionFunc type is an adapter to allow the use of ordinary function as a Querier.
  280. type ChatSessionFunc func(context.Context, *ent.ChatSessionQuery) (ent.Value, error)
  281. // Query calls f(ctx, q).
  282. func (f ChatSessionFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  283. if q, ok := q.(*ent.ChatSessionQuery); ok {
  284. return f(ctx, q)
  285. }
  286. return nil, fmt.Errorf("unexpected query type %T. expect *ent.ChatSessionQuery", q)
  287. }
  288. // The TraverseChatSession type is an adapter to allow the use of ordinary function as Traverser.
  289. type TraverseChatSession func(context.Context, *ent.ChatSessionQuery) error
  290. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  291. func (f TraverseChatSession) Intercept(next ent.Querier) ent.Querier {
  292. return next
  293. }
  294. // Traverse calls f(ctx, q).
  295. func (f TraverseChatSession) Traverse(ctx context.Context, q ent.Query) error {
  296. if q, ok := q.(*ent.ChatSessionQuery); ok {
  297. return f(ctx, q)
  298. }
  299. return fmt.Errorf("unexpected query type %T. expect *ent.ChatSessionQuery", q)
  300. }
  301. // The ContactFunc type is an adapter to allow the use of ordinary function as a Querier.
  302. type ContactFunc func(context.Context, *ent.ContactQuery) (ent.Value, error)
  303. // Query calls f(ctx, q).
  304. func (f ContactFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  305. if q, ok := q.(*ent.ContactQuery); ok {
  306. return f(ctx, q)
  307. }
  308. return nil, fmt.Errorf("unexpected query type %T. expect *ent.ContactQuery", q)
  309. }
  310. // The TraverseContact type is an adapter to allow the use of ordinary function as Traverser.
  311. type TraverseContact func(context.Context, *ent.ContactQuery) error
  312. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  313. func (f TraverseContact) Intercept(next ent.Querier) ent.Querier {
  314. return next
  315. }
  316. // Traverse calls f(ctx, q).
  317. func (f TraverseContact) Traverse(ctx context.Context, q ent.Query) error {
  318. if q, ok := q.(*ent.ContactQuery); ok {
  319. return f(ctx, q)
  320. }
  321. return fmt.Errorf("unexpected query type %T. expect *ent.ContactQuery", q)
  322. }
  323. // The ContactFieldFunc type is an adapter to allow the use of ordinary function as a Querier.
  324. type ContactFieldFunc func(context.Context, *ent.ContactFieldQuery) (ent.Value, error)
  325. // Query calls f(ctx, q).
  326. func (f ContactFieldFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  327. if q, ok := q.(*ent.ContactFieldQuery); ok {
  328. return f(ctx, q)
  329. }
  330. return nil, fmt.Errorf("unexpected query type %T. expect *ent.ContactFieldQuery", q)
  331. }
  332. // The TraverseContactField type is an adapter to allow the use of ordinary function as Traverser.
  333. type TraverseContactField func(context.Context, *ent.ContactFieldQuery) error
  334. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  335. func (f TraverseContactField) Intercept(next ent.Querier) ent.Querier {
  336. return next
  337. }
  338. // Traverse calls f(ctx, q).
  339. func (f TraverseContactField) Traverse(ctx context.Context, q ent.Query) error {
  340. if q, ok := q.(*ent.ContactFieldQuery); ok {
  341. return f(ctx, q)
  342. }
  343. return fmt.Errorf("unexpected query type %T. expect *ent.ContactFieldQuery", q)
  344. }
  345. // The ContactFieldTemplateFunc type is an adapter to allow the use of ordinary function as a Querier.
  346. type ContactFieldTemplateFunc func(context.Context, *ent.ContactFieldTemplateQuery) (ent.Value, error)
  347. // Query calls f(ctx, q).
  348. func (f ContactFieldTemplateFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  349. if q, ok := q.(*ent.ContactFieldTemplateQuery); ok {
  350. return f(ctx, q)
  351. }
  352. return nil, fmt.Errorf("unexpected query type %T. expect *ent.ContactFieldTemplateQuery", q)
  353. }
  354. // The TraverseContactFieldTemplate type is an adapter to allow the use of ordinary function as Traverser.
  355. type TraverseContactFieldTemplate func(context.Context, *ent.ContactFieldTemplateQuery) error
  356. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  357. func (f TraverseContactFieldTemplate) Intercept(next ent.Querier) ent.Querier {
  358. return next
  359. }
  360. // Traverse calls f(ctx, q).
  361. func (f TraverseContactFieldTemplate) Traverse(ctx context.Context, q ent.Query) error {
  362. if q, ok := q.(*ent.ContactFieldTemplateQuery); ok {
  363. return f(ctx, q)
  364. }
  365. return fmt.Errorf("unexpected query type %T. expect *ent.ContactFieldTemplateQuery", q)
  366. }
  367. // The CreditBalanceFunc type is an adapter to allow the use of ordinary function as a Querier.
  368. type CreditBalanceFunc func(context.Context, *ent.CreditBalanceQuery) (ent.Value, error)
  369. // Query calls f(ctx, q).
  370. func (f CreditBalanceFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  371. if q, ok := q.(*ent.CreditBalanceQuery); ok {
  372. return f(ctx, q)
  373. }
  374. return nil, fmt.Errorf("unexpected query type %T. expect *ent.CreditBalanceQuery", q)
  375. }
  376. // The TraverseCreditBalance type is an adapter to allow the use of ordinary function as Traverser.
  377. type TraverseCreditBalance func(context.Context, *ent.CreditBalanceQuery) error
  378. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  379. func (f TraverseCreditBalance) Intercept(next ent.Querier) ent.Querier {
  380. return next
  381. }
  382. // Traverse calls f(ctx, q).
  383. func (f TraverseCreditBalance) Traverse(ctx context.Context, q ent.Query) error {
  384. if q, ok := q.(*ent.CreditBalanceQuery); ok {
  385. return f(ctx, q)
  386. }
  387. return fmt.Errorf("unexpected query type %T. expect *ent.CreditBalanceQuery", q)
  388. }
  389. // The CreditUsageFunc type is an adapter to allow the use of ordinary function as a Querier.
  390. type CreditUsageFunc func(context.Context, *ent.CreditUsageQuery) (ent.Value, error)
  391. // Query calls f(ctx, q).
  392. func (f CreditUsageFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  393. if q, ok := q.(*ent.CreditUsageQuery); ok {
  394. return f(ctx, q)
  395. }
  396. return nil, fmt.Errorf("unexpected query type %T. expect *ent.CreditUsageQuery", q)
  397. }
  398. // The TraverseCreditUsage type is an adapter to allow the use of ordinary function as Traverser.
  399. type TraverseCreditUsage func(context.Context, *ent.CreditUsageQuery) error
  400. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  401. func (f TraverseCreditUsage) Intercept(next ent.Querier) ent.Querier {
  402. return next
  403. }
  404. // Traverse calls f(ctx, q).
  405. func (f TraverseCreditUsage) Traverse(ctx context.Context, q ent.Query) error {
  406. if q, ok := q.(*ent.CreditUsageQuery); ok {
  407. return f(ctx, q)
  408. }
  409. return fmt.Errorf("unexpected query type %T. expect *ent.CreditUsageQuery", q)
  410. }
  411. // The EmployeeFunc type is an adapter to allow the use of ordinary function as a Querier.
  412. type EmployeeFunc func(context.Context, *ent.EmployeeQuery) (ent.Value, error)
  413. // Query calls f(ctx, q).
  414. func (f EmployeeFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  415. if q, ok := q.(*ent.EmployeeQuery); ok {
  416. return f(ctx, q)
  417. }
  418. return nil, fmt.Errorf("unexpected query type %T. expect *ent.EmployeeQuery", q)
  419. }
  420. // The TraverseEmployee type is an adapter to allow the use of ordinary function as Traverser.
  421. type TraverseEmployee func(context.Context, *ent.EmployeeQuery) error
  422. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  423. func (f TraverseEmployee) Intercept(next ent.Querier) ent.Querier {
  424. return next
  425. }
  426. // Traverse calls f(ctx, q).
  427. func (f TraverseEmployee) Traverse(ctx context.Context, q ent.Query) error {
  428. if q, ok := q.(*ent.EmployeeQuery); ok {
  429. return f(ctx, q)
  430. }
  431. return fmt.Errorf("unexpected query type %T. expect *ent.EmployeeQuery", q)
  432. }
  433. // The EmployeeConfigFunc type is an adapter to allow the use of ordinary function as a Querier.
  434. type EmployeeConfigFunc func(context.Context, *ent.EmployeeConfigQuery) (ent.Value, error)
  435. // Query calls f(ctx, q).
  436. func (f EmployeeConfigFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  437. if q, ok := q.(*ent.EmployeeConfigQuery); ok {
  438. return f(ctx, q)
  439. }
  440. return nil, fmt.Errorf("unexpected query type %T. expect *ent.EmployeeConfigQuery", q)
  441. }
  442. // The TraverseEmployeeConfig type is an adapter to allow the use of ordinary function as Traverser.
  443. type TraverseEmployeeConfig func(context.Context, *ent.EmployeeConfigQuery) error
  444. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  445. func (f TraverseEmployeeConfig) Intercept(next ent.Querier) ent.Querier {
  446. return next
  447. }
  448. // Traverse calls f(ctx, q).
  449. func (f TraverseEmployeeConfig) Traverse(ctx context.Context, q ent.Query) error {
  450. if q, ok := q.(*ent.EmployeeConfigQuery); ok {
  451. return f(ctx, q)
  452. }
  453. return fmt.Errorf("unexpected query type %T. expect *ent.EmployeeConfigQuery", q)
  454. }
  455. // The LabelFunc type is an adapter to allow the use of ordinary function as a Querier.
  456. type LabelFunc func(context.Context, *ent.LabelQuery) (ent.Value, error)
  457. // Query calls f(ctx, q).
  458. func (f LabelFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  459. if q, ok := q.(*ent.LabelQuery); ok {
  460. return f(ctx, q)
  461. }
  462. return nil, fmt.Errorf("unexpected query type %T. expect *ent.LabelQuery", q)
  463. }
  464. // The TraverseLabel type is an adapter to allow the use of ordinary function as Traverser.
  465. type TraverseLabel func(context.Context, *ent.LabelQuery) error
  466. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  467. func (f TraverseLabel) Intercept(next ent.Querier) ent.Querier {
  468. return next
  469. }
  470. // Traverse calls f(ctx, q).
  471. func (f TraverseLabel) Traverse(ctx context.Context, q ent.Query) error {
  472. if q, ok := q.(*ent.LabelQuery); ok {
  473. return f(ctx, q)
  474. }
  475. return fmt.Errorf("unexpected query type %T. expect *ent.LabelQuery", q)
  476. }
  477. // The LabelRelationshipFunc type is an adapter to allow the use of ordinary function as a Querier.
  478. type LabelRelationshipFunc func(context.Context, *ent.LabelRelationshipQuery) (ent.Value, error)
  479. // Query calls f(ctx, q).
  480. func (f LabelRelationshipFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  481. if q, ok := q.(*ent.LabelRelationshipQuery); ok {
  482. return f(ctx, q)
  483. }
  484. return nil, fmt.Errorf("unexpected query type %T. expect *ent.LabelRelationshipQuery", q)
  485. }
  486. // The TraverseLabelRelationship type is an adapter to allow the use of ordinary function as Traverser.
  487. type TraverseLabelRelationship func(context.Context, *ent.LabelRelationshipQuery) error
  488. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  489. func (f TraverseLabelRelationship) Intercept(next ent.Querier) ent.Querier {
  490. return next
  491. }
  492. // Traverse calls f(ctx, q).
  493. func (f TraverseLabelRelationship) Traverse(ctx context.Context, q ent.Query) error {
  494. if q, ok := q.(*ent.LabelRelationshipQuery); ok {
  495. return f(ctx, q)
  496. }
  497. return fmt.Errorf("unexpected query type %T. expect *ent.LabelRelationshipQuery", q)
  498. }
  499. // The LabelTaggingFunc type is an adapter to allow the use of ordinary function as a Querier.
  500. type LabelTaggingFunc func(context.Context, *ent.LabelTaggingQuery) (ent.Value, error)
  501. // Query calls f(ctx, q).
  502. func (f LabelTaggingFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  503. if q, ok := q.(*ent.LabelTaggingQuery); ok {
  504. return f(ctx, q)
  505. }
  506. return nil, fmt.Errorf("unexpected query type %T. expect *ent.LabelTaggingQuery", q)
  507. }
  508. // The TraverseLabelTagging type is an adapter to allow the use of ordinary function as Traverser.
  509. type TraverseLabelTagging func(context.Context, *ent.LabelTaggingQuery) error
  510. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  511. func (f TraverseLabelTagging) Intercept(next ent.Querier) ent.Querier {
  512. return next
  513. }
  514. // Traverse calls f(ctx, q).
  515. func (f TraverseLabelTagging) Traverse(ctx context.Context, q ent.Query) error {
  516. if q, ok := q.(*ent.LabelTaggingQuery); ok {
  517. return f(ctx, q)
  518. }
  519. return fmt.Errorf("unexpected query type %T. expect *ent.LabelTaggingQuery", q)
  520. }
  521. // The MessageFunc type is an adapter to allow the use of ordinary function as a Querier.
  522. type MessageFunc func(context.Context, *ent.MessageQuery) (ent.Value, error)
  523. // Query calls f(ctx, q).
  524. func (f MessageFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  525. if q, ok := q.(*ent.MessageQuery); ok {
  526. return f(ctx, q)
  527. }
  528. return nil, fmt.Errorf("unexpected query type %T. expect *ent.MessageQuery", q)
  529. }
  530. // The TraverseMessage type is an adapter to allow the use of ordinary function as Traverser.
  531. type TraverseMessage func(context.Context, *ent.MessageQuery) error
  532. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  533. func (f TraverseMessage) Intercept(next ent.Querier) ent.Querier {
  534. return next
  535. }
  536. // Traverse calls f(ctx, q).
  537. func (f TraverseMessage) Traverse(ctx context.Context, q ent.Query) error {
  538. if q, ok := q.(*ent.MessageQuery); ok {
  539. return f(ctx, q)
  540. }
  541. return fmt.Errorf("unexpected query type %T. expect *ent.MessageQuery", q)
  542. }
  543. // The MessageRecordsFunc type is an adapter to allow the use of ordinary function as a Querier.
  544. type MessageRecordsFunc func(context.Context, *ent.MessageRecordsQuery) (ent.Value, error)
  545. // Query calls f(ctx, q).
  546. func (f MessageRecordsFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  547. if q, ok := q.(*ent.MessageRecordsQuery); ok {
  548. return f(ctx, q)
  549. }
  550. return nil, fmt.Errorf("unexpected query type %T. expect *ent.MessageRecordsQuery", q)
  551. }
  552. // The TraverseMessageRecords type is an adapter to allow the use of ordinary function as Traverser.
  553. type TraverseMessageRecords func(context.Context, *ent.MessageRecordsQuery) error
  554. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  555. func (f TraverseMessageRecords) Intercept(next ent.Querier) ent.Querier {
  556. return next
  557. }
  558. // Traverse calls f(ctx, q).
  559. func (f TraverseMessageRecords) Traverse(ctx context.Context, q ent.Query) error {
  560. if q, ok := q.(*ent.MessageRecordsQuery); ok {
  561. return f(ctx, q)
  562. }
  563. return fmt.Errorf("unexpected query type %T. expect *ent.MessageRecordsQuery", q)
  564. }
  565. // The MsgFunc type is an adapter to allow the use of ordinary function as a Querier.
  566. type MsgFunc func(context.Context, *ent.MsgQuery) (ent.Value, error)
  567. // Query calls f(ctx, q).
  568. func (f MsgFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  569. if q, ok := q.(*ent.MsgQuery); ok {
  570. return f(ctx, q)
  571. }
  572. return nil, fmt.Errorf("unexpected query type %T. expect *ent.MsgQuery", q)
  573. }
  574. // The TraverseMsg type is an adapter to allow the use of ordinary function as Traverser.
  575. type TraverseMsg func(context.Context, *ent.MsgQuery) error
  576. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  577. func (f TraverseMsg) Intercept(next ent.Querier) ent.Querier {
  578. return next
  579. }
  580. // Traverse calls f(ctx, q).
  581. func (f TraverseMsg) Traverse(ctx context.Context, q ent.Query) error {
  582. if q, ok := q.(*ent.MsgQuery); ok {
  583. return f(ctx, q)
  584. }
  585. return fmt.Errorf("unexpected query type %T. expect *ent.MsgQuery", q)
  586. }
  587. // The PayRechargeFunc type is an adapter to allow the use of ordinary function as a Querier.
  588. type PayRechargeFunc func(context.Context, *ent.PayRechargeQuery) (ent.Value, error)
  589. // Query calls f(ctx, q).
  590. func (f PayRechargeFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  591. if q, ok := q.(*ent.PayRechargeQuery); ok {
  592. return f(ctx, q)
  593. }
  594. return nil, fmt.Errorf("unexpected query type %T. expect *ent.PayRechargeQuery", q)
  595. }
  596. // The TraversePayRecharge type is an adapter to allow the use of ordinary function as Traverser.
  597. type TraversePayRecharge func(context.Context, *ent.PayRechargeQuery) error
  598. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  599. func (f TraversePayRecharge) Intercept(next ent.Querier) ent.Querier {
  600. return next
  601. }
  602. // Traverse calls f(ctx, q).
  603. func (f TraversePayRecharge) Traverse(ctx context.Context, q ent.Query) error {
  604. if q, ok := q.(*ent.PayRechargeQuery); ok {
  605. return f(ctx, q)
  606. }
  607. return fmt.Errorf("unexpected query type %T. expect *ent.PayRechargeQuery", q)
  608. }
  609. // The ServerFunc type is an adapter to allow the use of ordinary function as a Querier.
  610. type ServerFunc func(context.Context, *ent.ServerQuery) (ent.Value, error)
  611. // Query calls f(ctx, q).
  612. func (f ServerFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  613. if q, ok := q.(*ent.ServerQuery); ok {
  614. return f(ctx, q)
  615. }
  616. return nil, fmt.Errorf("unexpected query type %T. expect *ent.ServerQuery", q)
  617. }
  618. // The TraverseServer type is an adapter to allow the use of ordinary function as Traverser.
  619. type TraverseServer func(context.Context, *ent.ServerQuery) error
  620. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  621. func (f TraverseServer) Intercept(next ent.Querier) ent.Querier {
  622. return next
  623. }
  624. // Traverse calls f(ctx, q).
  625. func (f TraverseServer) Traverse(ctx context.Context, q ent.Query) error {
  626. if q, ok := q.(*ent.ServerQuery); ok {
  627. return f(ctx, q)
  628. }
  629. return fmt.Errorf("unexpected query type %T. expect *ent.ServerQuery", q)
  630. }
  631. // The SopNodeFunc type is an adapter to allow the use of ordinary function as a Querier.
  632. type SopNodeFunc func(context.Context, *ent.SopNodeQuery) (ent.Value, error)
  633. // Query calls f(ctx, q).
  634. func (f SopNodeFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  635. if q, ok := q.(*ent.SopNodeQuery); ok {
  636. return f(ctx, q)
  637. }
  638. return nil, fmt.Errorf("unexpected query type %T. expect *ent.SopNodeQuery", q)
  639. }
  640. // The TraverseSopNode type is an adapter to allow the use of ordinary function as Traverser.
  641. type TraverseSopNode func(context.Context, *ent.SopNodeQuery) error
  642. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  643. func (f TraverseSopNode) Intercept(next ent.Querier) ent.Querier {
  644. return next
  645. }
  646. // Traverse calls f(ctx, q).
  647. func (f TraverseSopNode) Traverse(ctx context.Context, q ent.Query) error {
  648. if q, ok := q.(*ent.SopNodeQuery); ok {
  649. return f(ctx, q)
  650. }
  651. return fmt.Errorf("unexpected query type %T. expect *ent.SopNodeQuery", q)
  652. }
  653. // The SopStageFunc type is an adapter to allow the use of ordinary function as a Querier.
  654. type SopStageFunc func(context.Context, *ent.SopStageQuery) (ent.Value, error)
  655. // Query calls f(ctx, q).
  656. func (f SopStageFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  657. if q, ok := q.(*ent.SopStageQuery); ok {
  658. return f(ctx, q)
  659. }
  660. return nil, fmt.Errorf("unexpected query type %T. expect *ent.SopStageQuery", q)
  661. }
  662. // The TraverseSopStage type is an adapter to allow the use of ordinary function as Traverser.
  663. type TraverseSopStage func(context.Context, *ent.SopStageQuery) error
  664. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  665. func (f TraverseSopStage) Intercept(next ent.Querier) ent.Querier {
  666. return next
  667. }
  668. // Traverse calls f(ctx, q).
  669. func (f TraverseSopStage) Traverse(ctx context.Context, q ent.Query) error {
  670. if q, ok := q.(*ent.SopStageQuery); ok {
  671. return f(ctx, q)
  672. }
  673. return fmt.Errorf("unexpected query type %T. expect *ent.SopStageQuery", q)
  674. }
  675. // The SopTaskFunc type is an adapter to allow the use of ordinary function as a Querier.
  676. type SopTaskFunc func(context.Context, *ent.SopTaskQuery) (ent.Value, error)
  677. // Query calls f(ctx, q).
  678. func (f SopTaskFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  679. if q, ok := q.(*ent.SopTaskQuery); ok {
  680. return f(ctx, q)
  681. }
  682. return nil, fmt.Errorf("unexpected query type %T. expect *ent.SopTaskQuery", q)
  683. }
  684. // The TraverseSopTask type is an adapter to allow the use of ordinary function as Traverser.
  685. type TraverseSopTask func(context.Context, *ent.SopTaskQuery) error
  686. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  687. func (f TraverseSopTask) Intercept(next ent.Querier) ent.Querier {
  688. return next
  689. }
  690. // Traverse calls f(ctx, q).
  691. func (f TraverseSopTask) Traverse(ctx context.Context, q ent.Query) error {
  692. if q, ok := q.(*ent.SopTaskQuery); ok {
  693. return f(ctx, q)
  694. }
  695. return fmt.Errorf("unexpected query type %T. expect *ent.SopTaskQuery", q)
  696. }
  697. // The TokenFunc type is an adapter to allow the use of ordinary function as a Querier.
  698. type TokenFunc func(context.Context, *ent.TokenQuery) (ent.Value, error)
  699. // Query calls f(ctx, q).
  700. func (f TokenFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  701. if q, ok := q.(*ent.TokenQuery); ok {
  702. return f(ctx, q)
  703. }
  704. return nil, fmt.Errorf("unexpected query type %T. expect *ent.TokenQuery", q)
  705. }
  706. // The TraverseToken type is an adapter to allow the use of ordinary function as Traverser.
  707. type TraverseToken func(context.Context, *ent.TokenQuery) error
  708. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  709. func (f TraverseToken) Intercept(next ent.Querier) ent.Querier {
  710. return next
  711. }
  712. // Traverse calls f(ctx, q).
  713. func (f TraverseToken) Traverse(ctx context.Context, q ent.Query) error {
  714. if q, ok := q.(*ent.TokenQuery); ok {
  715. return f(ctx, q)
  716. }
  717. return fmt.Errorf("unexpected query type %T. expect *ent.TokenQuery", q)
  718. }
  719. // The TutorialFunc type is an adapter to allow the use of ordinary function as a Querier.
  720. type TutorialFunc func(context.Context, *ent.TutorialQuery) (ent.Value, error)
  721. // Query calls f(ctx, q).
  722. func (f TutorialFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  723. if q, ok := q.(*ent.TutorialQuery); ok {
  724. return f(ctx, q)
  725. }
  726. return nil, fmt.Errorf("unexpected query type %T. expect *ent.TutorialQuery", q)
  727. }
  728. // The TraverseTutorial type is an adapter to allow the use of ordinary function as Traverser.
  729. type TraverseTutorial func(context.Context, *ent.TutorialQuery) error
  730. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  731. func (f TraverseTutorial) Intercept(next ent.Querier) ent.Querier {
  732. return next
  733. }
  734. // Traverse calls f(ctx, q).
  735. func (f TraverseTutorial) Traverse(ctx context.Context, q ent.Query) error {
  736. if q, ok := q.(*ent.TutorialQuery); ok {
  737. return f(ctx, q)
  738. }
  739. return fmt.Errorf("unexpected query type %T. expect *ent.TutorialQuery", q)
  740. }
  741. // The UsageDetailFunc type is an adapter to allow the use of ordinary function as a Querier.
  742. type UsageDetailFunc func(context.Context, *ent.UsageDetailQuery) (ent.Value, error)
  743. // Query calls f(ctx, q).
  744. func (f UsageDetailFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  745. if q, ok := q.(*ent.UsageDetailQuery); ok {
  746. return f(ctx, q)
  747. }
  748. return nil, fmt.Errorf("unexpected query type %T. expect *ent.UsageDetailQuery", q)
  749. }
  750. // The TraverseUsageDetail type is an adapter to allow the use of ordinary function as Traverser.
  751. type TraverseUsageDetail func(context.Context, *ent.UsageDetailQuery) error
  752. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  753. func (f TraverseUsageDetail) Intercept(next ent.Querier) ent.Querier {
  754. return next
  755. }
  756. // Traverse calls f(ctx, q).
  757. func (f TraverseUsageDetail) Traverse(ctx context.Context, q ent.Query) error {
  758. if q, ok := q.(*ent.UsageDetailQuery); ok {
  759. return f(ctx, q)
  760. }
  761. return fmt.Errorf("unexpected query type %T. expect *ent.UsageDetailQuery", q)
  762. }
  763. // The UsageStatisticDayFunc type is an adapter to allow the use of ordinary function as a Querier.
  764. type UsageStatisticDayFunc func(context.Context, *ent.UsageStatisticDayQuery) (ent.Value, error)
  765. // Query calls f(ctx, q).
  766. func (f UsageStatisticDayFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  767. if q, ok := q.(*ent.UsageStatisticDayQuery); ok {
  768. return f(ctx, q)
  769. }
  770. return nil, fmt.Errorf("unexpected query type %T. expect *ent.UsageStatisticDayQuery", q)
  771. }
  772. // The TraverseUsageStatisticDay type is an adapter to allow the use of ordinary function as Traverser.
  773. type TraverseUsageStatisticDay func(context.Context, *ent.UsageStatisticDayQuery) error
  774. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  775. func (f TraverseUsageStatisticDay) Intercept(next ent.Querier) ent.Querier {
  776. return next
  777. }
  778. // Traverse calls f(ctx, q).
  779. func (f TraverseUsageStatisticDay) Traverse(ctx context.Context, q ent.Query) error {
  780. if q, ok := q.(*ent.UsageStatisticDayQuery); ok {
  781. return f(ctx, q)
  782. }
  783. return fmt.Errorf("unexpected query type %T. expect *ent.UsageStatisticDayQuery", q)
  784. }
  785. // The UsageStatisticHourFunc type is an adapter to allow the use of ordinary function as a Querier.
  786. type UsageStatisticHourFunc func(context.Context, *ent.UsageStatisticHourQuery) (ent.Value, error)
  787. // Query calls f(ctx, q).
  788. func (f UsageStatisticHourFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  789. if q, ok := q.(*ent.UsageStatisticHourQuery); ok {
  790. return f(ctx, q)
  791. }
  792. return nil, fmt.Errorf("unexpected query type %T. expect *ent.UsageStatisticHourQuery", q)
  793. }
  794. // The TraverseUsageStatisticHour type is an adapter to allow the use of ordinary function as Traverser.
  795. type TraverseUsageStatisticHour func(context.Context, *ent.UsageStatisticHourQuery) error
  796. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  797. func (f TraverseUsageStatisticHour) Intercept(next ent.Querier) ent.Querier {
  798. return next
  799. }
  800. // Traverse calls f(ctx, q).
  801. func (f TraverseUsageStatisticHour) Traverse(ctx context.Context, q ent.Query) error {
  802. if q, ok := q.(*ent.UsageStatisticHourQuery); ok {
  803. return f(ctx, q)
  804. }
  805. return fmt.Errorf("unexpected query type %T. expect *ent.UsageStatisticHourQuery", q)
  806. }
  807. // The UsageStatisticMonthFunc type is an adapter to allow the use of ordinary function as a Querier.
  808. type UsageStatisticMonthFunc func(context.Context, *ent.UsageStatisticMonthQuery) (ent.Value, error)
  809. // Query calls f(ctx, q).
  810. func (f UsageStatisticMonthFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  811. if q, ok := q.(*ent.UsageStatisticMonthQuery); ok {
  812. return f(ctx, q)
  813. }
  814. return nil, fmt.Errorf("unexpected query type %T. expect *ent.UsageStatisticMonthQuery", q)
  815. }
  816. // The TraverseUsageStatisticMonth type is an adapter to allow the use of ordinary function as Traverser.
  817. type TraverseUsageStatisticMonth func(context.Context, *ent.UsageStatisticMonthQuery) error
  818. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  819. func (f TraverseUsageStatisticMonth) Intercept(next ent.Querier) ent.Querier {
  820. return next
  821. }
  822. // Traverse calls f(ctx, q).
  823. func (f TraverseUsageStatisticMonth) Traverse(ctx context.Context, q ent.Query) error {
  824. if q, ok := q.(*ent.UsageStatisticMonthQuery); ok {
  825. return f(ctx, q)
  826. }
  827. return fmt.Errorf("unexpected query type %T. expect *ent.UsageStatisticMonthQuery", q)
  828. }
  829. // The UsageTotalFunc type is an adapter to allow the use of ordinary function as a Querier.
  830. type UsageTotalFunc func(context.Context, *ent.UsageTotalQuery) (ent.Value, error)
  831. // Query calls f(ctx, q).
  832. func (f UsageTotalFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  833. if q, ok := q.(*ent.UsageTotalQuery); ok {
  834. return f(ctx, q)
  835. }
  836. return nil, fmt.Errorf("unexpected query type %T. expect *ent.UsageTotalQuery", q)
  837. }
  838. // The TraverseUsageTotal type is an adapter to allow the use of ordinary function as Traverser.
  839. type TraverseUsageTotal func(context.Context, *ent.UsageTotalQuery) error
  840. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  841. func (f TraverseUsageTotal) Intercept(next ent.Querier) ent.Querier {
  842. return next
  843. }
  844. // Traverse calls f(ctx, q).
  845. func (f TraverseUsageTotal) Traverse(ctx context.Context, q ent.Query) error {
  846. if q, ok := q.(*ent.UsageTotalQuery); ok {
  847. return f(ctx, q)
  848. }
  849. return fmt.Errorf("unexpected query type %T. expect *ent.UsageTotalQuery", q)
  850. }
  851. // The WhatsappFunc type is an adapter to allow the use of ordinary function as a Querier.
  852. type WhatsappFunc func(context.Context, *ent.WhatsappQuery) (ent.Value, error)
  853. // Query calls f(ctx, q).
  854. func (f WhatsappFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  855. if q, ok := q.(*ent.WhatsappQuery); ok {
  856. return f(ctx, q)
  857. }
  858. return nil, fmt.Errorf("unexpected query type %T. expect *ent.WhatsappQuery", q)
  859. }
  860. // The TraverseWhatsapp type is an adapter to allow the use of ordinary function as Traverser.
  861. type TraverseWhatsapp func(context.Context, *ent.WhatsappQuery) error
  862. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  863. func (f TraverseWhatsapp) Intercept(next ent.Querier) ent.Querier {
  864. return next
  865. }
  866. // Traverse calls f(ctx, q).
  867. func (f TraverseWhatsapp) Traverse(ctx context.Context, q ent.Query) error {
  868. if q, ok := q.(*ent.WhatsappQuery); ok {
  869. return f(ctx, q)
  870. }
  871. return fmt.Errorf("unexpected query type %T. expect *ent.WhatsappQuery", q)
  872. }
  873. // The WhatsappChannelFunc type is an adapter to allow the use of ordinary function as a Querier.
  874. type WhatsappChannelFunc func(context.Context, *ent.WhatsappChannelQuery) (ent.Value, error)
  875. // Query calls f(ctx, q).
  876. func (f WhatsappChannelFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  877. if q, ok := q.(*ent.WhatsappChannelQuery); ok {
  878. return f(ctx, q)
  879. }
  880. return nil, fmt.Errorf("unexpected query type %T. expect *ent.WhatsappChannelQuery", q)
  881. }
  882. // The TraverseWhatsappChannel type is an adapter to allow the use of ordinary function as Traverser.
  883. type TraverseWhatsappChannel func(context.Context, *ent.WhatsappChannelQuery) error
  884. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  885. func (f TraverseWhatsappChannel) Intercept(next ent.Querier) ent.Querier {
  886. return next
  887. }
  888. // Traverse calls f(ctx, q).
  889. func (f TraverseWhatsappChannel) Traverse(ctx context.Context, q ent.Query) error {
  890. if q, ok := q.(*ent.WhatsappChannelQuery); ok {
  891. return f(ctx, q)
  892. }
  893. return fmt.Errorf("unexpected query type %T. expect *ent.WhatsappChannelQuery", q)
  894. }
  895. // The WorkExperienceFunc type is an adapter to allow the use of ordinary function as a Querier.
  896. type WorkExperienceFunc func(context.Context, *ent.WorkExperienceQuery) (ent.Value, error)
  897. // Query calls f(ctx, q).
  898. func (f WorkExperienceFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  899. if q, ok := q.(*ent.WorkExperienceQuery); ok {
  900. return f(ctx, q)
  901. }
  902. return nil, fmt.Errorf("unexpected query type %T. expect *ent.WorkExperienceQuery", q)
  903. }
  904. // The TraverseWorkExperience type is an adapter to allow the use of ordinary function as Traverser.
  905. type TraverseWorkExperience func(context.Context, *ent.WorkExperienceQuery) error
  906. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  907. func (f TraverseWorkExperience) Intercept(next ent.Querier) ent.Querier {
  908. return next
  909. }
  910. // Traverse calls f(ctx, q).
  911. func (f TraverseWorkExperience) Traverse(ctx context.Context, q ent.Query) error {
  912. if q, ok := q.(*ent.WorkExperienceQuery); ok {
  913. return f(ctx, q)
  914. }
  915. return fmt.Errorf("unexpected query type %T. expect *ent.WorkExperienceQuery", q)
  916. }
  917. // The WpChatroomFunc type is an adapter to allow the use of ordinary function as a Querier.
  918. type WpChatroomFunc func(context.Context, *ent.WpChatroomQuery) (ent.Value, error)
  919. // Query calls f(ctx, q).
  920. func (f WpChatroomFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  921. if q, ok := q.(*ent.WpChatroomQuery); ok {
  922. return f(ctx, q)
  923. }
  924. return nil, fmt.Errorf("unexpected query type %T. expect *ent.WpChatroomQuery", q)
  925. }
  926. // The TraverseWpChatroom type is an adapter to allow the use of ordinary function as Traverser.
  927. type TraverseWpChatroom func(context.Context, *ent.WpChatroomQuery) error
  928. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  929. func (f TraverseWpChatroom) Intercept(next ent.Querier) ent.Querier {
  930. return next
  931. }
  932. // Traverse calls f(ctx, q).
  933. func (f TraverseWpChatroom) Traverse(ctx context.Context, q ent.Query) error {
  934. if q, ok := q.(*ent.WpChatroomQuery); ok {
  935. return f(ctx, q)
  936. }
  937. return fmt.Errorf("unexpected query type %T. expect *ent.WpChatroomQuery", q)
  938. }
  939. // The WpChatroomMemberFunc type is an adapter to allow the use of ordinary function as a Querier.
  940. type WpChatroomMemberFunc func(context.Context, *ent.WpChatroomMemberQuery) (ent.Value, error)
  941. // Query calls f(ctx, q).
  942. func (f WpChatroomMemberFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  943. if q, ok := q.(*ent.WpChatroomMemberQuery); ok {
  944. return f(ctx, q)
  945. }
  946. return nil, fmt.Errorf("unexpected query type %T. expect *ent.WpChatroomMemberQuery", q)
  947. }
  948. // The TraverseWpChatroomMember type is an adapter to allow the use of ordinary function as Traverser.
  949. type TraverseWpChatroomMember func(context.Context, *ent.WpChatroomMemberQuery) error
  950. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  951. func (f TraverseWpChatroomMember) Intercept(next ent.Querier) ent.Querier {
  952. return next
  953. }
  954. // Traverse calls f(ctx, q).
  955. func (f TraverseWpChatroomMember) Traverse(ctx context.Context, q ent.Query) error {
  956. if q, ok := q.(*ent.WpChatroomMemberQuery); ok {
  957. return f(ctx, q)
  958. }
  959. return fmt.Errorf("unexpected query type %T. expect *ent.WpChatroomMemberQuery", q)
  960. }
  961. // The WxFunc type is an adapter to allow the use of ordinary function as a Querier.
  962. type WxFunc func(context.Context, *ent.WxQuery) (ent.Value, error)
  963. // Query calls f(ctx, q).
  964. func (f WxFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  965. if q, ok := q.(*ent.WxQuery); ok {
  966. return f(ctx, q)
  967. }
  968. return nil, fmt.Errorf("unexpected query type %T. expect *ent.WxQuery", q)
  969. }
  970. // The TraverseWx type is an adapter to allow the use of ordinary function as Traverser.
  971. type TraverseWx func(context.Context, *ent.WxQuery) error
  972. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  973. func (f TraverseWx) Intercept(next ent.Querier) ent.Querier {
  974. return next
  975. }
  976. // Traverse calls f(ctx, q).
  977. func (f TraverseWx) Traverse(ctx context.Context, q ent.Query) error {
  978. if q, ok := q.(*ent.WxQuery); ok {
  979. return f(ctx, q)
  980. }
  981. return fmt.Errorf("unexpected query type %T. expect *ent.WxQuery", q)
  982. }
  983. // The WxCardFunc type is an adapter to allow the use of ordinary function as a Querier.
  984. type WxCardFunc func(context.Context, *ent.WxCardQuery) (ent.Value, error)
  985. // Query calls f(ctx, q).
  986. func (f WxCardFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  987. if q, ok := q.(*ent.WxCardQuery); ok {
  988. return f(ctx, q)
  989. }
  990. return nil, fmt.Errorf("unexpected query type %T. expect *ent.WxCardQuery", q)
  991. }
  992. // The TraverseWxCard type is an adapter to allow the use of ordinary function as Traverser.
  993. type TraverseWxCard func(context.Context, *ent.WxCardQuery) error
  994. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  995. func (f TraverseWxCard) Intercept(next ent.Querier) ent.Querier {
  996. return next
  997. }
  998. // Traverse calls f(ctx, q).
  999. func (f TraverseWxCard) Traverse(ctx context.Context, q ent.Query) error {
  1000. if q, ok := q.(*ent.WxCardQuery); ok {
  1001. return f(ctx, q)
  1002. }
  1003. return fmt.Errorf("unexpected query type %T. expect *ent.WxCardQuery", q)
  1004. }
  1005. // The WxCardUserFunc type is an adapter to allow the use of ordinary function as a Querier.
  1006. type WxCardUserFunc func(context.Context, *ent.WxCardUserQuery) (ent.Value, error)
  1007. // Query calls f(ctx, q).
  1008. func (f WxCardUserFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  1009. if q, ok := q.(*ent.WxCardUserQuery); ok {
  1010. return f(ctx, q)
  1011. }
  1012. return nil, fmt.Errorf("unexpected query type %T. expect *ent.WxCardUserQuery", q)
  1013. }
  1014. // The TraverseWxCardUser type is an adapter to allow the use of ordinary function as Traverser.
  1015. type TraverseWxCardUser func(context.Context, *ent.WxCardUserQuery) error
  1016. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  1017. func (f TraverseWxCardUser) Intercept(next ent.Querier) ent.Querier {
  1018. return next
  1019. }
  1020. // Traverse calls f(ctx, q).
  1021. func (f TraverseWxCardUser) Traverse(ctx context.Context, q ent.Query) error {
  1022. if q, ok := q.(*ent.WxCardUserQuery); ok {
  1023. return f(ctx, q)
  1024. }
  1025. return fmt.Errorf("unexpected query type %T. expect *ent.WxCardUserQuery", q)
  1026. }
  1027. // The WxCardVisitFunc type is an adapter to allow the use of ordinary function as a Querier.
  1028. type WxCardVisitFunc func(context.Context, *ent.WxCardVisitQuery) (ent.Value, error)
  1029. // Query calls f(ctx, q).
  1030. func (f WxCardVisitFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  1031. if q, ok := q.(*ent.WxCardVisitQuery); ok {
  1032. return f(ctx, q)
  1033. }
  1034. return nil, fmt.Errorf("unexpected query type %T. expect *ent.WxCardVisitQuery", q)
  1035. }
  1036. // The TraverseWxCardVisit type is an adapter to allow the use of ordinary function as Traverser.
  1037. type TraverseWxCardVisit func(context.Context, *ent.WxCardVisitQuery) error
  1038. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  1039. func (f TraverseWxCardVisit) Intercept(next ent.Querier) ent.Querier {
  1040. return next
  1041. }
  1042. // Traverse calls f(ctx, q).
  1043. func (f TraverseWxCardVisit) Traverse(ctx context.Context, q ent.Query) error {
  1044. if q, ok := q.(*ent.WxCardVisitQuery); ok {
  1045. return f(ctx, q)
  1046. }
  1047. return fmt.Errorf("unexpected query type %T. expect *ent.WxCardVisitQuery", q)
  1048. }
  1049. // NewQuery returns the generic Query interface for the given typed query.
  1050. func NewQuery(q ent.Query) (Query, error) {
  1051. switch q := q.(type) {
  1052. case *ent.AgentQuery:
  1053. return &query[*ent.AgentQuery, predicate.Agent, agent.OrderOption]{typ: ent.TypeAgent, tq: q}, nil
  1054. case *ent.AgentBaseQuery:
  1055. return &query[*ent.AgentBaseQuery, predicate.AgentBase, agentbase.OrderOption]{typ: ent.TypeAgentBase, tq: q}, nil
  1056. case *ent.AliyunAvatarQuery:
  1057. return &query[*ent.AliyunAvatarQuery, predicate.AliyunAvatar, aliyunavatar.OrderOption]{typ: ent.TypeAliyunAvatar, tq: q}, nil
  1058. case *ent.AllocAgentQuery:
  1059. return &query[*ent.AllocAgentQuery, predicate.AllocAgent, allocagent.OrderOption]{typ: ent.TypeAllocAgent, tq: q}, nil
  1060. case *ent.ApiKeyQuery:
  1061. return &query[*ent.ApiKeyQuery, predicate.ApiKey, apikey.OrderOption]{typ: ent.TypeApiKey, tq: q}, nil
  1062. case *ent.BatchMsgQuery:
  1063. return &query[*ent.BatchMsgQuery, predicate.BatchMsg, batchmsg.OrderOption]{typ: ent.TypeBatchMsg, tq: q}, nil
  1064. case *ent.CategoryQuery:
  1065. return &query[*ent.CategoryQuery, predicate.Category, category.OrderOption]{typ: ent.TypeCategory, tq: q}, nil
  1066. case *ent.ChatRecordsQuery:
  1067. return &query[*ent.ChatRecordsQuery, predicate.ChatRecords, chatrecords.OrderOption]{typ: ent.TypeChatRecords, tq: q}, nil
  1068. case *ent.ChatSessionQuery:
  1069. return &query[*ent.ChatSessionQuery, predicate.ChatSession, chatsession.OrderOption]{typ: ent.TypeChatSession, tq: q}, nil
  1070. case *ent.ContactQuery:
  1071. return &query[*ent.ContactQuery, predicate.Contact, contact.OrderOption]{typ: ent.TypeContact, tq: q}, nil
  1072. case *ent.ContactFieldQuery:
  1073. return &query[*ent.ContactFieldQuery, predicate.ContactField, contactfield.OrderOption]{typ: ent.TypeContactField, tq: q}, nil
  1074. case *ent.ContactFieldTemplateQuery:
  1075. return &query[*ent.ContactFieldTemplateQuery, predicate.ContactFieldTemplate, contactfieldtemplate.OrderOption]{typ: ent.TypeContactFieldTemplate, tq: q}, nil
  1076. case *ent.CreditBalanceQuery:
  1077. return &query[*ent.CreditBalanceQuery, predicate.CreditBalance, creditbalance.OrderOption]{typ: ent.TypeCreditBalance, tq: q}, nil
  1078. case *ent.CreditUsageQuery:
  1079. return &query[*ent.CreditUsageQuery, predicate.CreditUsage, creditusage.OrderOption]{typ: ent.TypeCreditUsage, tq: q}, nil
  1080. case *ent.EmployeeQuery:
  1081. return &query[*ent.EmployeeQuery, predicate.Employee, employee.OrderOption]{typ: ent.TypeEmployee, tq: q}, nil
  1082. case *ent.EmployeeConfigQuery:
  1083. return &query[*ent.EmployeeConfigQuery, predicate.EmployeeConfig, employeeconfig.OrderOption]{typ: ent.TypeEmployeeConfig, tq: q}, nil
  1084. case *ent.LabelQuery:
  1085. return &query[*ent.LabelQuery, predicate.Label, label.OrderOption]{typ: ent.TypeLabel, tq: q}, nil
  1086. case *ent.LabelRelationshipQuery:
  1087. return &query[*ent.LabelRelationshipQuery, predicate.LabelRelationship, labelrelationship.OrderOption]{typ: ent.TypeLabelRelationship, tq: q}, nil
  1088. case *ent.LabelTaggingQuery:
  1089. return &query[*ent.LabelTaggingQuery, predicate.LabelTagging, labeltagging.OrderOption]{typ: ent.TypeLabelTagging, tq: q}, nil
  1090. case *ent.MessageQuery:
  1091. return &query[*ent.MessageQuery, predicate.Message, message.OrderOption]{typ: ent.TypeMessage, tq: q}, nil
  1092. case *ent.MessageRecordsQuery:
  1093. return &query[*ent.MessageRecordsQuery, predicate.MessageRecords, messagerecords.OrderOption]{typ: ent.TypeMessageRecords, tq: q}, nil
  1094. case *ent.MsgQuery:
  1095. return &query[*ent.MsgQuery, predicate.Msg, msg.OrderOption]{typ: ent.TypeMsg, tq: q}, nil
  1096. case *ent.PayRechargeQuery:
  1097. return &query[*ent.PayRechargeQuery, predicate.PayRecharge, payrecharge.OrderOption]{typ: ent.TypePayRecharge, tq: q}, nil
  1098. case *ent.ServerQuery:
  1099. return &query[*ent.ServerQuery, predicate.Server, server.OrderOption]{typ: ent.TypeServer, tq: q}, nil
  1100. case *ent.SopNodeQuery:
  1101. return &query[*ent.SopNodeQuery, predicate.SopNode, sopnode.OrderOption]{typ: ent.TypeSopNode, tq: q}, nil
  1102. case *ent.SopStageQuery:
  1103. return &query[*ent.SopStageQuery, predicate.SopStage, sopstage.OrderOption]{typ: ent.TypeSopStage, tq: q}, nil
  1104. case *ent.SopTaskQuery:
  1105. return &query[*ent.SopTaskQuery, predicate.SopTask, soptask.OrderOption]{typ: ent.TypeSopTask, tq: q}, nil
  1106. case *ent.TokenQuery:
  1107. return &query[*ent.TokenQuery, predicate.Token, token.OrderOption]{typ: ent.TypeToken, tq: q}, nil
  1108. case *ent.TutorialQuery:
  1109. return &query[*ent.TutorialQuery, predicate.Tutorial, tutorial.OrderOption]{typ: ent.TypeTutorial, tq: q}, nil
  1110. case *ent.UsageDetailQuery:
  1111. return &query[*ent.UsageDetailQuery, predicate.UsageDetail, usagedetail.OrderOption]{typ: ent.TypeUsageDetail, tq: q}, nil
  1112. case *ent.UsageStatisticDayQuery:
  1113. return &query[*ent.UsageStatisticDayQuery, predicate.UsageStatisticDay, usagestatisticday.OrderOption]{typ: ent.TypeUsageStatisticDay, tq: q}, nil
  1114. case *ent.UsageStatisticHourQuery:
  1115. return &query[*ent.UsageStatisticHourQuery, predicate.UsageStatisticHour, usagestatistichour.OrderOption]{typ: ent.TypeUsageStatisticHour, tq: q}, nil
  1116. case *ent.UsageStatisticMonthQuery:
  1117. return &query[*ent.UsageStatisticMonthQuery, predicate.UsageStatisticMonth, usagestatisticmonth.OrderOption]{typ: ent.TypeUsageStatisticMonth, tq: q}, nil
  1118. case *ent.UsageTotalQuery:
  1119. return &query[*ent.UsageTotalQuery, predicate.UsageTotal, usagetotal.OrderOption]{typ: ent.TypeUsageTotal, tq: q}, nil
  1120. case *ent.WhatsappQuery:
  1121. return &query[*ent.WhatsappQuery, predicate.Whatsapp, whatsapp.OrderOption]{typ: ent.TypeWhatsapp, tq: q}, nil
  1122. case *ent.WhatsappChannelQuery:
  1123. return &query[*ent.WhatsappChannelQuery, predicate.WhatsappChannel, whatsappchannel.OrderOption]{typ: ent.TypeWhatsappChannel, tq: q}, nil
  1124. case *ent.WorkExperienceQuery:
  1125. return &query[*ent.WorkExperienceQuery, predicate.WorkExperience, workexperience.OrderOption]{typ: ent.TypeWorkExperience, tq: q}, nil
  1126. case *ent.WpChatroomQuery:
  1127. return &query[*ent.WpChatroomQuery, predicate.WpChatroom, wpchatroom.OrderOption]{typ: ent.TypeWpChatroom, tq: q}, nil
  1128. case *ent.WpChatroomMemberQuery:
  1129. return &query[*ent.WpChatroomMemberQuery, predicate.WpChatroomMember, wpchatroommember.OrderOption]{typ: ent.TypeWpChatroomMember, tq: q}, nil
  1130. case *ent.WxQuery:
  1131. return &query[*ent.WxQuery, predicate.Wx, wx.OrderOption]{typ: ent.TypeWx, tq: q}, nil
  1132. case *ent.WxCardQuery:
  1133. return &query[*ent.WxCardQuery, predicate.WxCard, wxcard.OrderOption]{typ: ent.TypeWxCard, tq: q}, nil
  1134. case *ent.WxCardUserQuery:
  1135. return &query[*ent.WxCardUserQuery, predicate.WxCardUser, wxcarduser.OrderOption]{typ: ent.TypeWxCardUser, tq: q}, nil
  1136. case *ent.WxCardVisitQuery:
  1137. return &query[*ent.WxCardVisitQuery, predicate.WxCardVisit, wxcardvisit.OrderOption]{typ: ent.TypeWxCardVisit, tq: q}, nil
  1138. default:
  1139. return nil, fmt.Errorf("unknown query type %T", q)
  1140. }
  1141. }
  1142. type query[T any, P ~func(*sql.Selector), R ~func(*sql.Selector)] struct {
  1143. typ string
  1144. tq interface {
  1145. Limit(int) T
  1146. Offset(int) T
  1147. Unique(bool) T
  1148. Order(...R) T
  1149. Where(...P) T
  1150. }
  1151. }
  1152. func (q query[T, P, R]) Type() string {
  1153. return q.typ
  1154. }
  1155. func (q query[T, P, R]) Limit(limit int) {
  1156. q.tq.Limit(limit)
  1157. }
  1158. func (q query[T, P, R]) Offset(offset int) {
  1159. q.tq.Offset(offset)
  1160. }
  1161. func (q query[T, P, R]) Unique(unique bool) {
  1162. q.tq.Unique(unique)
  1163. }
  1164. func (q query[T, P, R]) Order(orders ...func(*sql.Selector)) {
  1165. rs := make([]R, len(orders))
  1166. for i := range orders {
  1167. rs[i] = orders[i]
  1168. }
  1169. q.tq.Order(rs...)
  1170. }
  1171. func (q query[T, P, R]) WhereP(ps ...func(*sql.Selector)) {
  1172. p := make([]P, len(ps))
  1173. for i := range ps {
  1174. p[i] = ps[i]
  1175. }
  1176. q.tq.Where(p...)
  1177. }