intercept.go 39 KB

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