intercept.go 57 KB

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