intercept.go 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049
  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/batchmsg"
  11. "wechat-api/ent/category"
  12. "wechat-api/ent/chatrecords"
  13. "wechat-api/ent/chatsession"
  14. "wechat-api/ent/contact"
  15. "wechat-api/ent/employee"
  16. "wechat-api/ent/employeeconfig"
  17. "wechat-api/ent/label"
  18. "wechat-api/ent/labelrelationship"
  19. "wechat-api/ent/labeltagging"
  20. "wechat-api/ent/message"
  21. "wechat-api/ent/messagerecords"
  22. "wechat-api/ent/msg"
  23. "wechat-api/ent/predicate"
  24. "wechat-api/ent/server"
  25. "wechat-api/ent/sopnode"
  26. "wechat-api/ent/sopstage"
  27. "wechat-api/ent/soptask"
  28. "wechat-api/ent/token"
  29. "wechat-api/ent/tutorial"
  30. "wechat-api/ent/usagedetail"
  31. "wechat-api/ent/usagetotal"
  32. "wechat-api/ent/workexperience"
  33. "wechat-api/ent/wpchatroom"
  34. "wechat-api/ent/wpchatroommember"
  35. "wechat-api/ent/wx"
  36. "wechat-api/ent/wxcard"
  37. "wechat-api/ent/wxcarduser"
  38. "wechat-api/ent/wxcardvisit"
  39. "entgo.io/ent/dialect/sql"
  40. )
  41. // The Query interface represents an operation that queries a graph.
  42. // By using this interface, users can write generic code that manipulates
  43. // query builders of different types.
  44. type Query interface {
  45. // Type returns the string representation of the query type.
  46. Type() string
  47. // Limit the number of records to be returned by this query.
  48. Limit(int)
  49. // Offset to start from.
  50. Offset(int)
  51. // Unique configures the query builder to filter duplicate records.
  52. Unique(bool)
  53. // Order specifies how the records should be ordered.
  54. Order(...func(*sql.Selector))
  55. // WhereP appends storage-level predicates to the query builder. Using this method, users
  56. // can use type-assertion to append predicates that do not depend on any generated package.
  57. WhereP(...func(*sql.Selector))
  58. }
  59. // The Func type is an adapter that allows ordinary functions to be used as interceptors.
  60. // Unlike traversal functions, interceptors are skipped during graph traversals. Note that the
  61. // implementation of Func is different from the one defined in entgo.io/ent.InterceptFunc.
  62. type Func func(context.Context, Query) error
  63. // Intercept calls f(ctx, q) and then applied the next Querier.
  64. func (f Func) Intercept(next ent.Querier) ent.Querier {
  65. return ent.QuerierFunc(func(ctx context.Context, q ent.Query) (ent.Value, error) {
  66. query, err := NewQuery(q)
  67. if err != nil {
  68. return nil, err
  69. }
  70. if err := f(ctx, query); err != nil {
  71. return nil, err
  72. }
  73. return next.Query(ctx, q)
  74. })
  75. }
  76. // The TraverseFunc type is an adapter to allow the use of ordinary function as Traverser.
  77. // If f is a function with the appropriate signature, TraverseFunc(f) is a Traverser that calls f.
  78. type TraverseFunc func(context.Context, Query) error
  79. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  80. func (f TraverseFunc) Intercept(next ent.Querier) ent.Querier {
  81. return next
  82. }
  83. // Traverse calls f(ctx, q).
  84. func (f TraverseFunc) Traverse(ctx context.Context, q ent.Query) error {
  85. query, err := NewQuery(q)
  86. if err != nil {
  87. return err
  88. }
  89. return f(ctx, query)
  90. }
  91. // The AgentFunc type is an adapter to allow the use of ordinary function as a Querier.
  92. type AgentFunc func(context.Context, *ent.AgentQuery) (ent.Value, error)
  93. // Query calls f(ctx, q).
  94. func (f AgentFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  95. if q, ok := q.(*ent.AgentQuery); ok {
  96. return f(ctx, q)
  97. }
  98. return nil, fmt.Errorf("unexpected query type %T. expect *ent.AgentQuery", q)
  99. }
  100. // The TraverseAgent type is an adapter to allow the use of ordinary function as Traverser.
  101. type TraverseAgent func(context.Context, *ent.AgentQuery) error
  102. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  103. func (f TraverseAgent) Intercept(next ent.Querier) ent.Querier {
  104. return next
  105. }
  106. // Traverse calls f(ctx, q).
  107. func (f TraverseAgent) Traverse(ctx context.Context, q ent.Query) error {
  108. if q, ok := q.(*ent.AgentQuery); ok {
  109. return f(ctx, q)
  110. }
  111. return fmt.Errorf("unexpected query type %T. expect *ent.AgentQuery", q)
  112. }
  113. // The AgentBaseFunc type is an adapter to allow the use of ordinary function as a Querier.
  114. type AgentBaseFunc func(context.Context, *ent.AgentBaseQuery) (ent.Value, error)
  115. // Query calls f(ctx, q).
  116. func (f AgentBaseFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  117. if q, ok := q.(*ent.AgentBaseQuery); ok {
  118. return f(ctx, q)
  119. }
  120. return nil, fmt.Errorf("unexpected query type %T. expect *ent.AgentBaseQuery", q)
  121. }
  122. // The TraverseAgentBase type is an adapter to allow the use of ordinary function as Traverser.
  123. type TraverseAgentBase func(context.Context, *ent.AgentBaseQuery) error
  124. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  125. func (f TraverseAgentBase) Intercept(next ent.Querier) ent.Querier {
  126. return next
  127. }
  128. // Traverse calls f(ctx, q).
  129. func (f TraverseAgentBase) Traverse(ctx context.Context, q ent.Query) error {
  130. if q, ok := q.(*ent.AgentBaseQuery); ok {
  131. return f(ctx, q)
  132. }
  133. return fmt.Errorf("unexpected query type %T. expect *ent.AgentBaseQuery", q)
  134. }
  135. // The AliyunAvatarFunc type is an adapter to allow the use of ordinary function as a Querier.
  136. type AliyunAvatarFunc func(context.Context, *ent.AliyunAvatarQuery) (ent.Value, error)
  137. // Query calls f(ctx, q).
  138. func (f AliyunAvatarFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  139. if q, ok := q.(*ent.AliyunAvatarQuery); ok {
  140. return f(ctx, q)
  141. }
  142. return nil, fmt.Errorf("unexpected query type %T. expect *ent.AliyunAvatarQuery", q)
  143. }
  144. // The TraverseAliyunAvatar type is an adapter to allow the use of ordinary function as Traverser.
  145. type TraverseAliyunAvatar func(context.Context, *ent.AliyunAvatarQuery) error
  146. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  147. func (f TraverseAliyunAvatar) Intercept(next ent.Querier) ent.Querier {
  148. return next
  149. }
  150. // Traverse calls f(ctx, q).
  151. func (f TraverseAliyunAvatar) Traverse(ctx context.Context, q ent.Query) error {
  152. if q, ok := q.(*ent.AliyunAvatarQuery); ok {
  153. return f(ctx, q)
  154. }
  155. return fmt.Errorf("unexpected query type %T. expect *ent.AliyunAvatarQuery", q)
  156. }
  157. // The BatchMsgFunc type is an adapter to allow the use of ordinary function as a Querier.
  158. type BatchMsgFunc func(context.Context, *ent.BatchMsgQuery) (ent.Value, error)
  159. // Query calls f(ctx, q).
  160. func (f BatchMsgFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  161. if q, ok := q.(*ent.BatchMsgQuery); ok {
  162. return f(ctx, q)
  163. }
  164. return nil, fmt.Errorf("unexpected query type %T. expect *ent.BatchMsgQuery", q)
  165. }
  166. // The TraverseBatchMsg type is an adapter to allow the use of ordinary function as Traverser.
  167. type TraverseBatchMsg func(context.Context, *ent.BatchMsgQuery) error
  168. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  169. func (f TraverseBatchMsg) Intercept(next ent.Querier) ent.Querier {
  170. return next
  171. }
  172. // Traverse calls f(ctx, q).
  173. func (f TraverseBatchMsg) Traverse(ctx context.Context, q ent.Query) error {
  174. if q, ok := q.(*ent.BatchMsgQuery); ok {
  175. return f(ctx, q)
  176. }
  177. return fmt.Errorf("unexpected query type %T. expect *ent.BatchMsgQuery", q)
  178. }
  179. // The CategoryFunc type is an adapter to allow the use of ordinary function as a Querier.
  180. type CategoryFunc func(context.Context, *ent.CategoryQuery) (ent.Value, error)
  181. // Query calls f(ctx, q).
  182. func (f CategoryFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  183. if q, ok := q.(*ent.CategoryQuery); ok {
  184. return f(ctx, q)
  185. }
  186. return nil, fmt.Errorf("unexpected query type %T. expect *ent.CategoryQuery", q)
  187. }
  188. // The TraverseCategory type is an adapter to allow the use of ordinary function as Traverser.
  189. type TraverseCategory func(context.Context, *ent.CategoryQuery) error
  190. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  191. func (f TraverseCategory) Intercept(next ent.Querier) ent.Querier {
  192. return next
  193. }
  194. // Traverse calls f(ctx, q).
  195. func (f TraverseCategory) Traverse(ctx context.Context, q ent.Query) error {
  196. if q, ok := q.(*ent.CategoryQuery); ok {
  197. return f(ctx, q)
  198. }
  199. return fmt.Errorf("unexpected query type %T. expect *ent.CategoryQuery", q)
  200. }
  201. // The ChatRecordsFunc type is an adapter to allow the use of ordinary function as a Querier.
  202. type ChatRecordsFunc func(context.Context, *ent.ChatRecordsQuery) (ent.Value, error)
  203. // Query calls f(ctx, q).
  204. func (f ChatRecordsFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  205. if q, ok := q.(*ent.ChatRecordsQuery); ok {
  206. return f(ctx, q)
  207. }
  208. return nil, fmt.Errorf("unexpected query type %T. expect *ent.ChatRecordsQuery", q)
  209. }
  210. // The TraverseChatRecords type is an adapter to allow the use of ordinary function as Traverser.
  211. type TraverseChatRecords func(context.Context, *ent.ChatRecordsQuery) error
  212. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  213. func (f TraverseChatRecords) Intercept(next ent.Querier) ent.Querier {
  214. return next
  215. }
  216. // Traverse calls f(ctx, q).
  217. func (f TraverseChatRecords) Traverse(ctx context.Context, q ent.Query) error {
  218. if q, ok := q.(*ent.ChatRecordsQuery); ok {
  219. return f(ctx, q)
  220. }
  221. return fmt.Errorf("unexpected query type %T. expect *ent.ChatRecordsQuery", q)
  222. }
  223. // The ChatSessionFunc type is an adapter to allow the use of ordinary function as a Querier.
  224. type ChatSessionFunc func(context.Context, *ent.ChatSessionQuery) (ent.Value, error)
  225. // Query calls f(ctx, q).
  226. func (f ChatSessionFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  227. if q, ok := q.(*ent.ChatSessionQuery); ok {
  228. return f(ctx, q)
  229. }
  230. return nil, fmt.Errorf("unexpected query type %T. expect *ent.ChatSessionQuery", q)
  231. }
  232. // The TraverseChatSession type is an adapter to allow the use of ordinary function as Traverser.
  233. type TraverseChatSession func(context.Context, *ent.ChatSessionQuery) error
  234. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  235. func (f TraverseChatSession) Intercept(next ent.Querier) ent.Querier {
  236. return next
  237. }
  238. // Traverse calls f(ctx, q).
  239. func (f TraverseChatSession) Traverse(ctx context.Context, q ent.Query) error {
  240. if q, ok := q.(*ent.ChatSessionQuery); ok {
  241. return f(ctx, q)
  242. }
  243. return fmt.Errorf("unexpected query type %T. expect *ent.ChatSessionQuery", q)
  244. }
  245. // The ContactFunc type is an adapter to allow the use of ordinary function as a Querier.
  246. type ContactFunc func(context.Context, *ent.ContactQuery) (ent.Value, error)
  247. // Query calls f(ctx, q).
  248. func (f ContactFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  249. if q, ok := q.(*ent.ContactQuery); ok {
  250. return f(ctx, q)
  251. }
  252. return nil, fmt.Errorf("unexpected query type %T. expect *ent.ContactQuery", q)
  253. }
  254. // The TraverseContact type is an adapter to allow the use of ordinary function as Traverser.
  255. type TraverseContact func(context.Context, *ent.ContactQuery) error
  256. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  257. func (f TraverseContact) Intercept(next ent.Querier) ent.Querier {
  258. return next
  259. }
  260. // Traverse calls f(ctx, q).
  261. func (f TraverseContact) Traverse(ctx context.Context, q ent.Query) error {
  262. if q, ok := q.(*ent.ContactQuery); ok {
  263. return f(ctx, q)
  264. }
  265. return fmt.Errorf("unexpected query type %T. expect *ent.ContactQuery", q)
  266. }
  267. // The EmployeeFunc type is an adapter to allow the use of ordinary function as a Querier.
  268. type EmployeeFunc func(context.Context, *ent.EmployeeQuery) (ent.Value, error)
  269. // Query calls f(ctx, q).
  270. func (f EmployeeFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  271. if q, ok := q.(*ent.EmployeeQuery); ok {
  272. return f(ctx, q)
  273. }
  274. return nil, fmt.Errorf("unexpected query type %T. expect *ent.EmployeeQuery", q)
  275. }
  276. // The TraverseEmployee type is an adapter to allow the use of ordinary function as Traverser.
  277. type TraverseEmployee func(context.Context, *ent.EmployeeQuery) error
  278. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  279. func (f TraverseEmployee) Intercept(next ent.Querier) ent.Querier {
  280. return next
  281. }
  282. // Traverse calls f(ctx, q).
  283. func (f TraverseEmployee) Traverse(ctx context.Context, q ent.Query) error {
  284. if q, ok := q.(*ent.EmployeeQuery); ok {
  285. return f(ctx, q)
  286. }
  287. return fmt.Errorf("unexpected query type %T. expect *ent.EmployeeQuery", q)
  288. }
  289. // The EmployeeConfigFunc type is an adapter to allow the use of ordinary function as a Querier.
  290. type EmployeeConfigFunc func(context.Context, *ent.EmployeeConfigQuery) (ent.Value, error)
  291. // Query calls f(ctx, q).
  292. func (f EmployeeConfigFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  293. if q, ok := q.(*ent.EmployeeConfigQuery); ok {
  294. return f(ctx, q)
  295. }
  296. return nil, fmt.Errorf("unexpected query type %T. expect *ent.EmployeeConfigQuery", q)
  297. }
  298. // The TraverseEmployeeConfig type is an adapter to allow the use of ordinary function as Traverser.
  299. type TraverseEmployeeConfig func(context.Context, *ent.EmployeeConfigQuery) error
  300. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  301. func (f TraverseEmployeeConfig) Intercept(next ent.Querier) ent.Querier {
  302. return next
  303. }
  304. // Traverse calls f(ctx, q).
  305. func (f TraverseEmployeeConfig) Traverse(ctx context.Context, q ent.Query) error {
  306. if q, ok := q.(*ent.EmployeeConfigQuery); ok {
  307. return f(ctx, q)
  308. }
  309. return fmt.Errorf("unexpected query type %T. expect *ent.EmployeeConfigQuery", q)
  310. }
  311. // The LabelFunc type is an adapter to allow the use of ordinary function as a Querier.
  312. type LabelFunc func(context.Context, *ent.LabelQuery) (ent.Value, error)
  313. // Query calls f(ctx, q).
  314. func (f LabelFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  315. if q, ok := q.(*ent.LabelQuery); ok {
  316. return f(ctx, q)
  317. }
  318. return nil, fmt.Errorf("unexpected query type %T. expect *ent.LabelQuery", q)
  319. }
  320. // The TraverseLabel type is an adapter to allow the use of ordinary function as Traverser.
  321. type TraverseLabel func(context.Context, *ent.LabelQuery) error
  322. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  323. func (f TraverseLabel) Intercept(next ent.Querier) ent.Querier {
  324. return next
  325. }
  326. // Traverse calls f(ctx, q).
  327. func (f TraverseLabel) Traverse(ctx context.Context, q ent.Query) error {
  328. if q, ok := q.(*ent.LabelQuery); ok {
  329. return f(ctx, q)
  330. }
  331. return fmt.Errorf("unexpected query type %T. expect *ent.LabelQuery", q)
  332. }
  333. // The LabelRelationshipFunc type is an adapter to allow the use of ordinary function as a Querier.
  334. type LabelRelationshipFunc func(context.Context, *ent.LabelRelationshipQuery) (ent.Value, error)
  335. // Query calls f(ctx, q).
  336. func (f LabelRelationshipFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  337. if q, ok := q.(*ent.LabelRelationshipQuery); ok {
  338. return f(ctx, q)
  339. }
  340. return nil, fmt.Errorf("unexpected query type %T. expect *ent.LabelRelationshipQuery", q)
  341. }
  342. // The TraverseLabelRelationship type is an adapter to allow the use of ordinary function as Traverser.
  343. type TraverseLabelRelationship func(context.Context, *ent.LabelRelationshipQuery) error
  344. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  345. func (f TraverseLabelRelationship) Intercept(next ent.Querier) ent.Querier {
  346. return next
  347. }
  348. // Traverse calls f(ctx, q).
  349. func (f TraverseLabelRelationship) Traverse(ctx context.Context, q ent.Query) error {
  350. if q, ok := q.(*ent.LabelRelationshipQuery); ok {
  351. return f(ctx, q)
  352. }
  353. return fmt.Errorf("unexpected query type %T. expect *ent.LabelRelationshipQuery", q)
  354. }
  355. // The LabelTaggingFunc type is an adapter to allow the use of ordinary function as a Querier.
  356. type LabelTaggingFunc func(context.Context, *ent.LabelTaggingQuery) (ent.Value, error)
  357. // Query calls f(ctx, q).
  358. func (f LabelTaggingFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  359. if q, ok := q.(*ent.LabelTaggingQuery); ok {
  360. return f(ctx, q)
  361. }
  362. return nil, fmt.Errorf("unexpected query type %T. expect *ent.LabelTaggingQuery", q)
  363. }
  364. // The TraverseLabelTagging type is an adapter to allow the use of ordinary function as Traverser.
  365. type TraverseLabelTagging func(context.Context, *ent.LabelTaggingQuery) error
  366. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  367. func (f TraverseLabelTagging) Intercept(next ent.Querier) ent.Querier {
  368. return next
  369. }
  370. // Traverse calls f(ctx, q).
  371. func (f TraverseLabelTagging) Traverse(ctx context.Context, q ent.Query) error {
  372. if q, ok := q.(*ent.LabelTaggingQuery); ok {
  373. return f(ctx, q)
  374. }
  375. return fmt.Errorf("unexpected query type %T. expect *ent.LabelTaggingQuery", q)
  376. }
  377. // The MessageFunc type is an adapter to allow the use of ordinary function as a Querier.
  378. type MessageFunc func(context.Context, *ent.MessageQuery) (ent.Value, error)
  379. // Query calls f(ctx, q).
  380. func (f MessageFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  381. if q, ok := q.(*ent.MessageQuery); ok {
  382. return f(ctx, q)
  383. }
  384. return nil, fmt.Errorf("unexpected query type %T. expect *ent.MessageQuery", q)
  385. }
  386. // The TraverseMessage type is an adapter to allow the use of ordinary function as Traverser.
  387. type TraverseMessage func(context.Context, *ent.MessageQuery) error
  388. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  389. func (f TraverseMessage) Intercept(next ent.Querier) ent.Querier {
  390. return next
  391. }
  392. // Traverse calls f(ctx, q).
  393. func (f TraverseMessage) Traverse(ctx context.Context, q ent.Query) error {
  394. if q, ok := q.(*ent.MessageQuery); ok {
  395. return f(ctx, q)
  396. }
  397. return fmt.Errorf("unexpected query type %T. expect *ent.MessageQuery", q)
  398. }
  399. // The MessageRecordsFunc type is an adapter to allow the use of ordinary function as a Querier.
  400. type MessageRecordsFunc func(context.Context, *ent.MessageRecordsQuery) (ent.Value, error)
  401. // Query calls f(ctx, q).
  402. func (f MessageRecordsFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  403. if q, ok := q.(*ent.MessageRecordsQuery); ok {
  404. return f(ctx, q)
  405. }
  406. return nil, fmt.Errorf("unexpected query type %T. expect *ent.MessageRecordsQuery", q)
  407. }
  408. // The TraverseMessageRecords type is an adapter to allow the use of ordinary function as Traverser.
  409. type TraverseMessageRecords func(context.Context, *ent.MessageRecordsQuery) error
  410. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  411. func (f TraverseMessageRecords) Intercept(next ent.Querier) ent.Querier {
  412. return next
  413. }
  414. // Traverse calls f(ctx, q).
  415. func (f TraverseMessageRecords) Traverse(ctx context.Context, q ent.Query) error {
  416. if q, ok := q.(*ent.MessageRecordsQuery); ok {
  417. return f(ctx, q)
  418. }
  419. return fmt.Errorf("unexpected query type %T. expect *ent.MessageRecordsQuery", q)
  420. }
  421. // The MsgFunc type is an adapter to allow the use of ordinary function as a Querier.
  422. type MsgFunc func(context.Context, *ent.MsgQuery) (ent.Value, error)
  423. // Query calls f(ctx, q).
  424. func (f MsgFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  425. if q, ok := q.(*ent.MsgQuery); ok {
  426. return f(ctx, q)
  427. }
  428. return nil, fmt.Errorf("unexpected query type %T. expect *ent.MsgQuery", q)
  429. }
  430. // The TraverseMsg type is an adapter to allow the use of ordinary function as Traverser.
  431. type TraverseMsg func(context.Context, *ent.MsgQuery) error
  432. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  433. func (f TraverseMsg) Intercept(next ent.Querier) ent.Querier {
  434. return next
  435. }
  436. // Traverse calls f(ctx, q).
  437. func (f TraverseMsg) Traverse(ctx context.Context, q ent.Query) error {
  438. if q, ok := q.(*ent.MsgQuery); ok {
  439. return f(ctx, q)
  440. }
  441. return fmt.Errorf("unexpected query type %T. expect *ent.MsgQuery", q)
  442. }
  443. // The ServerFunc type is an adapter to allow the use of ordinary function as a Querier.
  444. type ServerFunc func(context.Context, *ent.ServerQuery) (ent.Value, error)
  445. // Query calls f(ctx, q).
  446. func (f ServerFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  447. if q, ok := q.(*ent.ServerQuery); ok {
  448. return f(ctx, q)
  449. }
  450. return nil, fmt.Errorf("unexpected query type %T. expect *ent.ServerQuery", q)
  451. }
  452. // The TraverseServer type is an adapter to allow the use of ordinary function as Traverser.
  453. type TraverseServer func(context.Context, *ent.ServerQuery) error
  454. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  455. func (f TraverseServer) Intercept(next ent.Querier) ent.Querier {
  456. return next
  457. }
  458. // Traverse calls f(ctx, q).
  459. func (f TraverseServer) Traverse(ctx context.Context, q ent.Query) error {
  460. if q, ok := q.(*ent.ServerQuery); ok {
  461. return f(ctx, q)
  462. }
  463. return fmt.Errorf("unexpected query type %T. expect *ent.ServerQuery", q)
  464. }
  465. // The SopNodeFunc type is an adapter to allow the use of ordinary function as a Querier.
  466. type SopNodeFunc func(context.Context, *ent.SopNodeQuery) (ent.Value, error)
  467. // Query calls f(ctx, q).
  468. func (f SopNodeFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  469. if q, ok := q.(*ent.SopNodeQuery); ok {
  470. return f(ctx, q)
  471. }
  472. return nil, fmt.Errorf("unexpected query type %T. expect *ent.SopNodeQuery", q)
  473. }
  474. // The TraverseSopNode type is an adapter to allow the use of ordinary function as Traverser.
  475. type TraverseSopNode func(context.Context, *ent.SopNodeQuery) error
  476. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  477. func (f TraverseSopNode) Intercept(next ent.Querier) ent.Querier {
  478. return next
  479. }
  480. // Traverse calls f(ctx, q).
  481. func (f TraverseSopNode) Traverse(ctx context.Context, q ent.Query) error {
  482. if q, ok := q.(*ent.SopNodeQuery); ok {
  483. return f(ctx, q)
  484. }
  485. return fmt.Errorf("unexpected query type %T. expect *ent.SopNodeQuery", q)
  486. }
  487. // The SopStageFunc type is an adapter to allow the use of ordinary function as a Querier.
  488. type SopStageFunc func(context.Context, *ent.SopStageQuery) (ent.Value, error)
  489. // Query calls f(ctx, q).
  490. func (f SopStageFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  491. if q, ok := q.(*ent.SopStageQuery); ok {
  492. return f(ctx, q)
  493. }
  494. return nil, fmt.Errorf("unexpected query type %T. expect *ent.SopStageQuery", q)
  495. }
  496. // The TraverseSopStage type is an adapter to allow the use of ordinary function as Traverser.
  497. type TraverseSopStage func(context.Context, *ent.SopStageQuery) error
  498. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  499. func (f TraverseSopStage) Intercept(next ent.Querier) ent.Querier {
  500. return next
  501. }
  502. // Traverse calls f(ctx, q).
  503. func (f TraverseSopStage) Traverse(ctx context.Context, q ent.Query) error {
  504. if q, ok := q.(*ent.SopStageQuery); ok {
  505. return f(ctx, q)
  506. }
  507. return fmt.Errorf("unexpected query type %T. expect *ent.SopStageQuery", q)
  508. }
  509. // The SopTaskFunc type is an adapter to allow the use of ordinary function as a Querier.
  510. type SopTaskFunc func(context.Context, *ent.SopTaskQuery) (ent.Value, error)
  511. // Query calls f(ctx, q).
  512. func (f SopTaskFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  513. if q, ok := q.(*ent.SopTaskQuery); ok {
  514. return f(ctx, q)
  515. }
  516. return nil, fmt.Errorf("unexpected query type %T. expect *ent.SopTaskQuery", q)
  517. }
  518. // The TraverseSopTask type is an adapter to allow the use of ordinary function as Traverser.
  519. type TraverseSopTask func(context.Context, *ent.SopTaskQuery) error
  520. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  521. func (f TraverseSopTask) Intercept(next ent.Querier) ent.Querier {
  522. return next
  523. }
  524. // Traverse calls f(ctx, q).
  525. func (f TraverseSopTask) Traverse(ctx context.Context, q ent.Query) error {
  526. if q, ok := q.(*ent.SopTaskQuery); ok {
  527. return f(ctx, q)
  528. }
  529. return fmt.Errorf("unexpected query type %T. expect *ent.SopTaskQuery", q)
  530. }
  531. // The TokenFunc type is an adapter to allow the use of ordinary function as a Querier.
  532. type TokenFunc func(context.Context, *ent.TokenQuery) (ent.Value, error)
  533. // Query calls f(ctx, q).
  534. func (f TokenFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  535. if q, ok := q.(*ent.TokenQuery); ok {
  536. return f(ctx, q)
  537. }
  538. return nil, fmt.Errorf("unexpected query type %T. expect *ent.TokenQuery", q)
  539. }
  540. // The TraverseToken type is an adapter to allow the use of ordinary function as Traverser.
  541. type TraverseToken func(context.Context, *ent.TokenQuery) error
  542. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  543. func (f TraverseToken) Intercept(next ent.Querier) ent.Querier {
  544. return next
  545. }
  546. // Traverse calls f(ctx, q).
  547. func (f TraverseToken) Traverse(ctx context.Context, q ent.Query) error {
  548. if q, ok := q.(*ent.TokenQuery); ok {
  549. return f(ctx, q)
  550. }
  551. return fmt.Errorf("unexpected query type %T. expect *ent.TokenQuery", q)
  552. }
  553. // The TutorialFunc type is an adapter to allow the use of ordinary function as a Querier.
  554. type TutorialFunc func(context.Context, *ent.TutorialQuery) (ent.Value, error)
  555. // Query calls f(ctx, q).
  556. func (f TutorialFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  557. if q, ok := q.(*ent.TutorialQuery); ok {
  558. return f(ctx, q)
  559. }
  560. return nil, fmt.Errorf("unexpected query type %T. expect *ent.TutorialQuery", q)
  561. }
  562. // The TraverseTutorial type is an adapter to allow the use of ordinary function as Traverser.
  563. type TraverseTutorial func(context.Context, *ent.TutorialQuery) error
  564. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  565. func (f TraverseTutorial) Intercept(next ent.Querier) ent.Querier {
  566. return next
  567. }
  568. // Traverse calls f(ctx, q).
  569. func (f TraverseTutorial) Traverse(ctx context.Context, q ent.Query) error {
  570. if q, ok := q.(*ent.TutorialQuery); ok {
  571. return f(ctx, q)
  572. }
  573. return fmt.Errorf("unexpected query type %T. expect *ent.TutorialQuery", q)
  574. }
  575. // The UsageDetailFunc type is an adapter to allow the use of ordinary function as a Querier.
  576. type UsageDetailFunc func(context.Context, *ent.UsageDetailQuery) (ent.Value, error)
  577. // Query calls f(ctx, q).
  578. func (f UsageDetailFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  579. if q, ok := q.(*ent.UsageDetailQuery); ok {
  580. return f(ctx, q)
  581. }
  582. return nil, fmt.Errorf("unexpected query type %T. expect *ent.UsageDetailQuery", q)
  583. }
  584. // The TraverseUsageDetail type is an adapter to allow the use of ordinary function as Traverser.
  585. type TraverseUsageDetail func(context.Context, *ent.UsageDetailQuery) error
  586. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  587. func (f TraverseUsageDetail) Intercept(next ent.Querier) ent.Querier {
  588. return next
  589. }
  590. // Traverse calls f(ctx, q).
  591. func (f TraverseUsageDetail) Traverse(ctx context.Context, q ent.Query) error {
  592. if q, ok := q.(*ent.UsageDetailQuery); ok {
  593. return f(ctx, q)
  594. }
  595. return fmt.Errorf("unexpected query type %T. expect *ent.UsageDetailQuery", q)
  596. }
  597. // The UsageTotalFunc type is an adapter to allow the use of ordinary function as a Querier.
  598. type UsageTotalFunc func(context.Context, *ent.UsageTotalQuery) (ent.Value, error)
  599. // Query calls f(ctx, q).
  600. func (f UsageTotalFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  601. if q, ok := q.(*ent.UsageTotalQuery); ok {
  602. return f(ctx, q)
  603. }
  604. return nil, fmt.Errorf("unexpected query type %T. expect *ent.UsageTotalQuery", q)
  605. }
  606. // The TraverseUsageTotal type is an adapter to allow the use of ordinary function as Traverser.
  607. type TraverseUsageTotal func(context.Context, *ent.UsageTotalQuery) error
  608. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  609. func (f TraverseUsageTotal) Intercept(next ent.Querier) ent.Querier {
  610. return next
  611. }
  612. // Traverse calls f(ctx, q).
  613. func (f TraverseUsageTotal) Traverse(ctx context.Context, q ent.Query) error {
  614. if q, ok := q.(*ent.UsageTotalQuery); ok {
  615. return f(ctx, q)
  616. }
  617. return fmt.Errorf("unexpected query type %T. expect *ent.UsageTotalQuery", q)
  618. }
  619. // The WorkExperienceFunc type is an adapter to allow the use of ordinary function as a Querier.
  620. type WorkExperienceFunc func(context.Context, *ent.WorkExperienceQuery) (ent.Value, error)
  621. // Query calls f(ctx, q).
  622. func (f WorkExperienceFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  623. if q, ok := q.(*ent.WorkExperienceQuery); ok {
  624. return f(ctx, q)
  625. }
  626. return nil, fmt.Errorf("unexpected query type %T. expect *ent.WorkExperienceQuery", q)
  627. }
  628. // The TraverseWorkExperience type is an adapter to allow the use of ordinary function as Traverser.
  629. type TraverseWorkExperience func(context.Context, *ent.WorkExperienceQuery) error
  630. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  631. func (f TraverseWorkExperience) Intercept(next ent.Querier) ent.Querier {
  632. return next
  633. }
  634. // Traverse calls f(ctx, q).
  635. func (f TraverseWorkExperience) Traverse(ctx context.Context, q ent.Query) error {
  636. if q, ok := q.(*ent.WorkExperienceQuery); ok {
  637. return f(ctx, q)
  638. }
  639. return fmt.Errorf("unexpected query type %T. expect *ent.WorkExperienceQuery", q)
  640. }
  641. // The WpChatroomFunc type is an adapter to allow the use of ordinary function as a Querier.
  642. type WpChatroomFunc func(context.Context, *ent.WpChatroomQuery) (ent.Value, error)
  643. // Query calls f(ctx, q).
  644. func (f WpChatroomFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  645. if q, ok := q.(*ent.WpChatroomQuery); ok {
  646. return f(ctx, q)
  647. }
  648. return nil, fmt.Errorf("unexpected query type %T. expect *ent.WpChatroomQuery", q)
  649. }
  650. // The TraverseWpChatroom type is an adapter to allow the use of ordinary function as Traverser.
  651. type TraverseWpChatroom func(context.Context, *ent.WpChatroomQuery) error
  652. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  653. func (f TraverseWpChatroom) Intercept(next ent.Querier) ent.Querier {
  654. return next
  655. }
  656. // Traverse calls f(ctx, q).
  657. func (f TraverseWpChatroom) Traverse(ctx context.Context, q ent.Query) error {
  658. if q, ok := q.(*ent.WpChatroomQuery); ok {
  659. return f(ctx, q)
  660. }
  661. return fmt.Errorf("unexpected query type %T. expect *ent.WpChatroomQuery", q)
  662. }
  663. // The WpChatroomMemberFunc type is an adapter to allow the use of ordinary function as a Querier.
  664. type WpChatroomMemberFunc func(context.Context, *ent.WpChatroomMemberQuery) (ent.Value, error)
  665. // Query calls f(ctx, q).
  666. func (f WpChatroomMemberFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  667. if q, ok := q.(*ent.WpChatroomMemberQuery); ok {
  668. return f(ctx, q)
  669. }
  670. return nil, fmt.Errorf("unexpected query type %T. expect *ent.WpChatroomMemberQuery", q)
  671. }
  672. // The TraverseWpChatroomMember type is an adapter to allow the use of ordinary function as Traverser.
  673. type TraverseWpChatroomMember func(context.Context, *ent.WpChatroomMemberQuery) error
  674. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  675. func (f TraverseWpChatroomMember) Intercept(next ent.Querier) ent.Querier {
  676. return next
  677. }
  678. // Traverse calls f(ctx, q).
  679. func (f TraverseWpChatroomMember) Traverse(ctx context.Context, q ent.Query) error {
  680. if q, ok := q.(*ent.WpChatroomMemberQuery); ok {
  681. return f(ctx, q)
  682. }
  683. return fmt.Errorf("unexpected query type %T. expect *ent.WpChatroomMemberQuery", q)
  684. }
  685. // The WxFunc type is an adapter to allow the use of ordinary function as a Querier.
  686. type WxFunc func(context.Context, *ent.WxQuery) (ent.Value, error)
  687. // Query calls f(ctx, q).
  688. func (f WxFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  689. if q, ok := q.(*ent.WxQuery); ok {
  690. return f(ctx, q)
  691. }
  692. return nil, fmt.Errorf("unexpected query type %T. expect *ent.WxQuery", q)
  693. }
  694. // The TraverseWx type is an adapter to allow the use of ordinary function as Traverser.
  695. type TraverseWx func(context.Context, *ent.WxQuery) error
  696. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  697. func (f TraverseWx) Intercept(next ent.Querier) ent.Querier {
  698. return next
  699. }
  700. // Traverse calls f(ctx, q).
  701. func (f TraverseWx) Traverse(ctx context.Context, q ent.Query) error {
  702. if q, ok := q.(*ent.WxQuery); ok {
  703. return f(ctx, q)
  704. }
  705. return fmt.Errorf("unexpected query type %T. expect *ent.WxQuery", q)
  706. }
  707. // The WxCardFunc type is an adapter to allow the use of ordinary function as a Querier.
  708. type WxCardFunc func(context.Context, *ent.WxCardQuery) (ent.Value, error)
  709. // Query calls f(ctx, q).
  710. func (f WxCardFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  711. if q, ok := q.(*ent.WxCardQuery); ok {
  712. return f(ctx, q)
  713. }
  714. return nil, fmt.Errorf("unexpected query type %T. expect *ent.WxCardQuery", q)
  715. }
  716. // The TraverseWxCard type is an adapter to allow the use of ordinary function as Traverser.
  717. type TraverseWxCard func(context.Context, *ent.WxCardQuery) error
  718. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  719. func (f TraverseWxCard) Intercept(next ent.Querier) ent.Querier {
  720. return next
  721. }
  722. // Traverse calls f(ctx, q).
  723. func (f TraverseWxCard) Traverse(ctx context.Context, q ent.Query) error {
  724. if q, ok := q.(*ent.WxCardQuery); ok {
  725. return f(ctx, q)
  726. }
  727. return fmt.Errorf("unexpected query type %T. expect *ent.WxCardQuery", q)
  728. }
  729. // The WxCardUserFunc type is an adapter to allow the use of ordinary function as a Querier.
  730. type WxCardUserFunc func(context.Context, *ent.WxCardUserQuery) (ent.Value, error)
  731. // Query calls f(ctx, q).
  732. func (f WxCardUserFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  733. if q, ok := q.(*ent.WxCardUserQuery); ok {
  734. return f(ctx, q)
  735. }
  736. return nil, fmt.Errorf("unexpected query type %T. expect *ent.WxCardUserQuery", q)
  737. }
  738. // The TraverseWxCardUser type is an adapter to allow the use of ordinary function as Traverser.
  739. type TraverseWxCardUser func(context.Context, *ent.WxCardUserQuery) error
  740. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  741. func (f TraverseWxCardUser) Intercept(next ent.Querier) ent.Querier {
  742. return next
  743. }
  744. // Traverse calls f(ctx, q).
  745. func (f TraverseWxCardUser) Traverse(ctx context.Context, q ent.Query) error {
  746. if q, ok := q.(*ent.WxCardUserQuery); ok {
  747. return f(ctx, q)
  748. }
  749. return fmt.Errorf("unexpected query type %T. expect *ent.WxCardUserQuery", q)
  750. }
  751. // The WxCardVisitFunc type is an adapter to allow the use of ordinary function as a Querier.
  752. type WxCardVisitFunc func(context.Context, *ent.WxCardVisitQuery) (ent.Value, error)
  753. // Query calls f(ctx, q).
  754. func (f WxCardVisitFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
  755. if q, ok := q.(*ent.WxCardVisitQuery); ok {
  756. return f(ctx, q)
  757. }
  758. return nil, fmt.Errorf("unexpected query type %T. expect *ent.WxCardVisitQuery", q)
  759. }
  760. // The TraverseWxCardVisit type is an adapter to allow the use of ordinary function as Traverser.
  761. type TraverseWxCardVisit func(context.Context, *ent.WxCardVisitQuery) error
  762. // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
  763. func (f TraverseWxCardVisit) Intercept(next ent.Querier) ent.Querier {
  764. return next
  765. }
  766. // Traverse calls f(ctx, q).
  767. func (f TraverseWxCardVisit) Traverse(ctx context.Context, q ent.Query) error {
  768. if q, ok := q.(*ent.WxCardVisitQuery); ok {
  769. return f(ctx, q)
  770. }
  771. return fmt.Errorf("unexpected query type %T. expect *ent.WxCardVisitQuery", q)
  772. }
  773. // NewQuery returns the generic Query interface for the given typed query.
  774. func NewQuery(q ent.Query) (Query, error) {
  775. switch q := q.(type) {
  776. case *ent.AgentQuery:
  777. return &query[*ent.AgentQuery, predicate.Agent, agent.OrderOption]{typ: ent.TypeAgent, tq: q}, nil
  778. case *ent.AgentBaseQuery:
  779. return &query[*ent.AgentBaseQuery, predicate.AgentBase, agentbase.OrderOption]{typ: ent.TypeAgentBase, tq: q}, nil
  780. case *ent.AliyunAvatarQuery:
  781. return &query[*ent.AliyunAvatarQuery, predicate.AliyunAvatar, aliyunavatar.OrderOption]{typ: ent.TypeAliyunAvatar, tq: q}, nil
  782. case *ent.BatchMsgQuery:
  783. return &query[*ent.BatchMsgQuery, predicate.BatchMsg, batchmsg.OrderOption]{typ: ent.TypeBatchMsg, tq: q}, nil
  784. case *ent.CategoryQuery:
  785. return &query[*ent.CategoryQuery, predicate.Category, category.OrderOption]{typ: ent.TypeCategory, tq: q}, nil
  786. case *ent.ChatRecordsQuery:
  787. return &query[*ent.ChatRecordsQuery, predicate.ChatRecords, chatrecords.OrderOption]{typ: ent.TypeChatRecords, tq: q}, nil
  788. case *ent.ChatSessionQuery:
  789. return &query[*ent.ChatSessionQuery, predicate.ChatSession, chatsession.OrderOption]{typ: ent.TypeChatSession, tq: q}, nil
  790. case *ent.ContactQuery:
  791. return &query[*ent.ContactQuery, predicate.Contact, contact.OrderOption]{typ: ent.TypeContact, tq: q}, nil
  792. case *ent.EmployeeQuery:
  793. return &query[*ent.EmployeeQuery, predicate.Employee, employee.OrderOption]{typ: ent.TypeEmployee, tq: q}, nil
  794. case *ent.EmployeeConfigQuery:
  795. return &query[*ent.EmployeeConfigQuery, predicate.EmployeeConfig, employeeconfig.OrderOption]{typ: ent.TypeEmployeeConfig, tq: q}, nil
  796. case *ent.LabelQuery:
  797. return &query[*ent.LabelQuery, predicate.Label, label.OrderOption]{typ: ent.TypeLabel, tq: q}, nil
  798. case *ent.LabelRelationshipQuery:
  799. return &query[*ent.LabelRelationshipQuery, predicate.LabelRelationship, labelrelationship.OrderOption]{typ: ent.TypeLabelRelationship, tq: q}, nil
  800. case *ent.LabelTaggingQuery:
  801. return &query[*ent.LabelTaggingQuery, predicate.LabelTagging, labeltagging.OrderOption]{typ: ent.TypeLabelTagging, tq: q}, nil
  802. case *ent.MessageQuery:
  803. return &query[*ent.MessageQuery, predicate.Message, message.OrderOption]{typ: ent.TypeMessage, tq: q}, nil
  804. case *ent.MessageRecordsQuery:
  805. return &query[*ent.MessageRecordsQuery, predicate.MessageRecords, messagerecords.OrderOption]{typ: ent.TypeMessageRecords, tq: q}, nil
  806. case *ent.MsgQuery:
  807. return &query[*ent.MsgQuery, predicate.Msg, msg.OrderOption]{typ: ent.TypeMsg, tq: q}, nil
  808. case *ent.ServerQuery:
  809. return &query[*ent.ServerQuery, predicate.Server, server.OrderOption]{typ: ent.TypeServer, tq: q}, nil
  810. case *ent.SopNodeQuery:
  811. return &query[*ent.SopNodeQuery, predicate.SopNode, sopnode.OrderOption]{typ: ent.TypeSopNode, tq: q}, nil
  812. case *ent.SopStageQuery:
  813. return &query[*ent.SopStageQuery, predicate.SopStage, sopstage.OrderOption]{typ: ent.TypeSopStage, tq: q}, nil
  814. case *ent.SopTaskQuery:
  815. return &query[*ent.SopTaskQuery, predicate.SopTask, soptask.OrderOption]{typ: ent.TypeSopTask, tq: q}, nil
  816. case *ent.TokenQuery:
  817. return &query[*ent.TokenQuery, predicate.Token, token.OrderOption]{typ: ent.TypeToken, tq: q}, nil
  818. case *ent.TutorialQuery:
  819. return &query[*ent.TutorialQuery, predicate.Tutorial, tutorial.OrderOption]{typ: ent.TypeTutorial, tq: q}, nil
  820. case *ent.UsageDetailQuery:
  821. return &query[*ent.UsageDetailQuery, predicate.UsageDetail, usagedetail.OrderOption]{typ: ent.TypeUsageDetail, tq: q}, nil
  822. case *ent.UsageTotalQuery:
  823. return &query[*ent.UsageTotalQuery, predicate.UsageTotal, usagetotal.OrderOption]{typ: ent.TypeUsageTotal, tq: q}, nil
  824. case *ent.WorkExperienceQuery:
  825. return &query[*ent.WorkExperienceQuery, predicate.WorkExperience, workexperience.OrderOption]{typ: ent.TypeWorkExperience, tq: q}, nil
  826. case *ent.WpChatroomQuery:
  827. return &query[*ent.WpChatroomQuery, predicate.WpChatroom, wpchatroom.OrderOption]{typ: ent.TypeWpChatroom, tq: q}, nil
  828. case *ent.WpChatroomMemberQuery:
  829. return &query[*ent.WpChatroomMemberQuery, predicate.WpChatroomMember, wpchatroommember.OrderOption]{typ: ent.TypeWpChatroomMember, tq: q}, nil
  830. case *ent.WxQuery:
  831. return &query[*ent.WxQuery, predicate.Wx, wx.OrderOption]{typ: ent.TypeWx, tq: q}, nil
  832. case *ent.WxCardQuery:
  833. return &query[*ent.WxCardQuery, predicate.WxCard, wxcard.OrderOption]{typ: ent.TypeWxCard, tq: q}, nil
  834. case *ent.WxCardUserQuery:
  835. return &query[*ent.WxCardUserQuery, predicate.WxCardUser, wxcarduser.OrderOption]{typ: ent.TypeWxCardUser, tq: q}, nil
  836. case *ent.WxCardVisitQuery:
  837. return &query[*ent.WxCardVisitQuery, predicate.WxCardVisit, wxcardvisit.OrderOption]{typ: ent.TypeWxCardVisit, tq: q}, nil
  838. default:
  839. return nil, fmt.Errorf("unknown query type %T", q)
  840. }
  841. }
  842. type query[T any, P ~func(*sql.Selector), R ~func(*sql.Selector)] struct {
  843. typ string
  844. tq interface {
  845. Limit(int) T
  846. Offset(int) T
  847. Unique(bool) T
  848. Order(...R) T
  849. Where(...P) T
  850. }
  851. }
  852. func (q query[T, P, R]) Type() string {
  853. return q.typ
  854. }
  855. func (q query[T, P, R]) Limit(limit int) {
  856. q.tq.Limit(limit)
  857. }
  858. func (q query[T, P, R]) Offset(offset int) {
  859. q.tq.Offset(offset)
  860. }
  861. func (q query[T, P, R]) Unique(unique bool) {
  862. q.tq.Unique(unique)
  863. }
  864. func (q query[T, P, R]) Order(orders ...func(*sql.Selector)) {
  865. rs := make([]R, len(orders))
  866. for i := range orders {
  867. rs[i] = orders[i]
  868. }
  869. q.tq.Order(rs...)
  870. }
  871. func (q query[T, P, R]) WhereP(ps ...func(*sql.Selector)) {
  872. p := make([]P, len(ps))
  873. for i := range ps {
  874. p[i] = ps[i]
  875. }
  876. q.tq.Where(p...)
  877. }