intercept.go 52 KB

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