client.go 108 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "log"
  8. "reflect"
  9. "wechat-api/ent/migrate"
  10. "wechat-api/ent/agent"
  11. "wechat-api/ent/batchmsg"
  12. "wechat-api/ent/contact"
  13. "wechat-api/ent/employee"
  14. "wechat-api/ent/label"
  15. "wechat-api/ent/labelrelationship"
  16. "wechat-api/ent/message"
  17. "wechat-api/ent/messagerecords"
  18. "wechat-api/ent/msg"
  19. "wechat-api/ent/server"
  20. "wechat-api/ent/sopnode"
  21. "wechat-api/ent/sopstage"
  22. "wechat-api/ent/soptask"
  23. "wechat-api/ent/token"
  24. "wechat-api/ent/tutorial"
  25. "wechat-api/ent/workexperience"
  26. "wechat-api/ent/wx"
  27. "entgo.io/ent"
  28. "entgo.io/ent/dialect"
  29. "entgo.io/ent/dialect/sql"
  30. "entgo.io/ent/dialect/sql/sqlgraph"
  31. stdsql "database/sql"
  32. )
  33. // Client is the client that holds all ent builders.
  34. type Client struct {
  35. config
  36. // Schema is the client for creating, migrating and dropping schema.
  37. Schema *migrate.Schema
  38. // Agent is the client for interacting with the Agent builders.
  39. Agent *AgentClient
  40. // BatchMsg is the client for interacting with the BatchMsg builders.
  41. BatchMsg *BatchMsgClient
  42. // Contact is the client for interacting with the Contact builders.
  43. Contact *ContactClient
  44. // Employee is the client for interacting with the Employee builders.
  45. Employee *EmployeeClient
  46. // Label is the client for interacting with the Label builders.
  47. Label *LabelClient
  48. // LabelRelationship is the client for interacting with the LabelRelationship builders.
  49. LabelRelationship *LabelRelationshipClient
  50. // Message is the client for interacting with the Message builders.
  51. Message *MessageClient
  52. // MessageRecords is the client for interacting with the MessageRecords builders.
  53. MessageRecords *MessageRecordsClient
  54. // Msg is the client for interacting with the Msg builders.
  55. Msg *MsgClient
  56. // Server is the client for interacting with the Server builders.
  57. Server *ServerClient
  58. // SopNode is the client for interacting with the SopNode builders.
  59. SopNode *SopNodeClient
  60. // SopStage is the client for interacting with the SopStage builders.
  61. SopStage *SopStageClient
  62. // SopTask is the client for interacting with the SopTask builders.
  63. SopTask *SopTaskClient
  64. // Token is the client for interacting with the Token builders.
  65. Token *TokenClient
  66. // Tutorial is the client for interacting with the Tutorial builders.
  67. Tutorial *TutorialClient
  68. // WorkExperience is the client for interacting with the WorkExperience builders.
  69. WorkExperience *WorkExperienceClient
  70. // Wx is the client for interacting with the Wx builders.
  71. Wx *WxClient
  72. }
  73. // NewClient creates a new client configured with the given options.
  74. func NewClient(opts ...Option) *Client {
  75. client := &Client{config: newConfig(opts...)}
  76. client.init()
  77. return client
  78. }
  79. func (c *Client) init() {
  80. c.Schema = migrate.NewSchema(c.driver)
  81. c.Agent = NewAgentClient(c.config)
  82. c.BatchMsg = NewBatchMsgClient(c.config)
  83. c.Contact = NewContactClient(c.config)
  84. c.Employee = NewEmployeeClient(c.config)
  85. c.Label = NewLabelClient(c.config)
  86. c.LabelRelationship = NewLabelRelationshipClient(c.config)
  87. c.Message = NewMessageClient(c.config)
  88. c.MessageRecords = NewMessageRecordsClient(c.config)
  89. c.Msg = NewMsgClient(c.config)
  90. c.Server = NewServerClient(c.config)
  91. c.SopNode = NewSopNodeClient(c.config)
  92. c.SopStage = NewSopStageClient(c.config)
  93. c.SopTask = NewSopTaskClient(c.config)
  94. c.Token = NewTokenClient(c.config)
  95. c.Tutorial = NewTutorialClient(c.config)
  96. c.WorkExperience = NewWorkExperienceClient(c.config)
  97. c.Wx = NewWxClient(c.config)
  98. }
  99. type (
  100. // config is the configuration for the client and its builder.
  101. config struct {
  102. // driver used for executing database requests.
  103. driver dialect.Driver
  104. // debug enable a debug logging.
  105. debug bool
  106. // log used for logging on debug mode.
  107. log func(...any)
  108. // hooks to execute on mutations.
  109. hooks *hooks
  110. // interceptors to execute on queries.
  111. inters *inters
  112. }
  113. // Option function to configure the client.
  114. Option func(*config)
  115. )
  116. // newConfig creates a new config for the client.
  117. func newConfig(opts ...Option) config {
  118. cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}}
  119. cfg.options(opts...)
  120. return cfg
  121. }
  122. // options applies the options on the config object.
  123. func (c *config) options(opts ...Option) {
  124. for _, opt := range opts {
  125. opt(c)
  126. }
  127. if c.debug {
  128. c.driver = dialect.Debug(c.driver, c.log)
  129. }
  130. }
  131. // Debug enables debug logging on the ent.Driver.
  132. func Debug() Option {
  133. return func(c *config) {
  134. c.debug = true
  135. }
  136. }
  137. // Log sets the logging function for debug mode.
  138. func Log(fn func(...any)) Option {
  139. return func(c *config) {
  140. c.log = fn
  141. }
  142. }
  143. // Driver configures the client driver.
  144. func Driver(driver dialect.Driver) Option {
  145. return func(c *config) {
  146. c.driver = driver
  147. }
  148. }
  149. // Open opens a database/sql.DB specified by the driver name and
  150. // the data source name, and returns a new client attached to it.
  151. // Optional parameters can be added for configuring the client.
  152. func Open(driverName, dataSourceName string, options ...Option) (*Client, error) {
  153. switch driverName {
  154. case dialect.MySQL, dialect.Postgres, dialect.SQLite:
  155. drv, err := sql.Open(driverName, dataSourceName)
  156. if err != nil {
  157. return nil, err
  158. }
  159. return NewClient(append(options, Driver(drv))...), nil
  160. default:
  161. return nil, fmt.Errorf("unsupported driver: %q", driverName)
  162. }
  163. }
  164. // ErrTxStarted is returned when trying to start a new transaction from a transactional client.
  165. var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction")
  166. // Tx returns a new transactional client. The provided context
  167. // is used until the transaction is committed or rolled back.
  168. func (c *Client) Tx(ctx context.Context) (*Tx, error) {
  169. if _, ok := c.driver.(*txDriver); ok {
  170. return nil, ErrTxStarted
  171. }
  172. tx, err := newTx(ctx, c.driver)
  173. if err != nil {
  174. return nil, fmt.Errorf("ent: starting a transaction: %w", err)
  175. }
  176. cfg := c.config
  177. cfg.driver = tx
  178. return &Tx{
  179. ctx: ctx,
  180. config: cfg,
  181. Agent: NewAgentClient(cfg),
  182. BatchMsg: NewBatchMsgClient(cfg),
  183. Contact: NewContactClient(cfg),
  184. Employee: NewEmployeeClient(cfg),
  185. Label: NewLabelClient(cfg),
  186. LabelRelationship: NewLabelRelationshipClient(cfg),
  187. Message: NewMessageClient(cfg),
  188. MessageRecords: NewMessageRecordsClient(cfg),
  189. Msg: NewMsgClient(cfg),
  190. Server: NewServerClient(cfg),
  191. SopNode: NewSopNodeClient(cfg),
  192. SopStage: NewSopStageClient(cfg),
  193. SopTask: NewSopTaskClient(cfg),
  194. Token: NewTokenClient(cfg),
  195. Tutorial: NewTutorialClient(cfg),
  196. WorkExperience: NewWorkExperienceClient(cfg),
  197. Wx: NewWxClient(cfg),
  198. }, nil
  199. }
  200. // BeginTx returns a transactional client with specified options.
  201. func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) {
  202. if _, ok := c.driver.(*txDriver); ok {
  203. return nil, errors.New("ent: cannot start a transaction within a transaction")
  204. }
  205. tx, err := c.driver.(interface {
  206. BeginTx(context.Context, *sql.TxOptions) (dialect.Tx, error)
  207. }).BeginTx(ctx, opts)
  208. if err != nil {
  209. return nil, fmt.Errorf("ent: starting a transaction: %w", err)
  210. }
  211. cfg := c.config
  212. cfg.driver = &txDriver{tx: tx, drv: c.driver}
  213. return &Tx{
  214. ctx: ctx,
  215. config: cfg,
  216. Agent: NewAgentClient(cfg),
  217. BatchMsg: NewBatchMsgClient(cfg),
  218. Contact: NewContactClient(cfg),
  219. Employee: NewEmployeeClient(cfg),
  220. Label: NewLabelClient(cfg),
  221. LabelRelationship: NewLabelRelationshipClient(cfg),
  222. Message: NewMessageClient(cfg),
  223. MessageRecords: NewMessageRecordsClient(cfg),
  224. Msg: NewMsgClient(cfg),
  225. Server: NewServerClient(cfg),
  226. SopNode: NewSopNodeClient(cfg),
  227. SopStage: NewSopStageClient(cfg),
  228. SopTask: NewSopTaskClient(cfg),
  229. Token: NewTokenClient(cfg),
  230. Tutorial: NewTutorialClient(cfg),
  231. WorkExperience: NewWorkExperienceClient(cfg),
  232. Wx: NewWxClient(cfg),
  233. }, nil
  234. }
  235. // Debug returns a new debug-client. It's used to get verbose logging on specific operations.
  236. //
  237. // client.Debug().
  238. // Agent.
  239. // Query().
  240. // Count(ctx)
  241. func (c *Client) Debug() *Client {
  242. if c.debug {
  243. return c
  244. }
  245. cfg := c.config
  246. cfg.driver = dialect.Debug(c.driver, c.log)
  247. client := &Client{config: cfg}
  248. client.init()
  249. return client
  250. }
  251. // Close closes the database connection and prevents new queries from starting.
  252. func (c *Client) Close() error {
  253. return c.driver.Close()
  254. }
  255. // Use adds the mutation hooks to all the entity clients.
  256. // In order to add hooks to a specific client, call: `client.Node.Use(...)`.
  257. func (c *Client) Use(hooks ...Hook) {
  258. for _, n := range []interface{ Use(...Hook) }{
  259. c.Agent, c.BatchMsg, c.Contact, c.Employee, c.Label, c.LabelRelationship,
  260. c.Message, c.MessageRecords, c.Msg, c.Server, c.SopNode, c.SopStage, c.SopTask,
  261. c.Token, c.Tutorial, c.WorkExperience, c.Wx,
  262. } {
  263. n.Use(hooks...)
  264. }
  265. }
  266. // Intercept adds the query interceptors to all the entity clients.
  267. // In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`.
  268. func (c *Client) Intercept(interceptors ...Interceptor) {
  269. for _, n := range []interface{ Intercept(...Interceptor) }{
  270. c.Agent, c.BatchMsg, c.Contact, c.Employee, c.Label, c.LabelRelationship,
  271. c.Message, c.MessageRecords, c.Msg, c.Server, c.SopNode, c.SopStage, c.SopTask,
  272. c.Token, c.Tutorial, c.WorkExperience, c.Wx,
  273. } {
  274. n.Intercept(interceptors...)
  275. }
  276. }
  277. // Mutate implements the ent.Mutator interface.
  278. func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
  279. switch m := m.(type) {
  280. case *AgentMutation:
  281. return c.Agent.mutate(ctx, m)
  282. case *BatchMsgMutation:
  283. return c.BatchMsg.mutate(ctx, m)
  284. case *ContactMutation:
  285. return c.Contact.mutate(ctx, m)
  286. case *EmployeeMutation:
  287. return c.Employee.mutate(ctx, m)
  288. case *LabelMutation:
  289. return c.Label.mutate(ctx, m)
  290. case *LabelRelationshipMutation:
  291. return c.LabelRelationship.mutate(ctx, m)
  292. case *MessageMutation:
  293. return c.Message.mutate(ctx, m)
  294. case *MessageRecordsMutation:
  295. return c.MessageRecords.mutate(ctx, m)
  296. case *MsgMutation:
  297. return c.Msg.mutate(ctx, m)
  298. case *ServerMutation:
  299. return c.Server.mutate(ctx, m)
  300. case *SopNodeMutation:
  301. return c.SopNode.mutate(ctx, m)
  302. case *SopStageMutation:
  303. return c.SopStage.mutate(ctx, m)
  304. case *SopTaskMutation:
  305. return c.SopTask.mutate(ctx, m)
  306. case *TokenMutation:
  307. return c.Token.mutate(ctx, m)
  308. case *TutorialMutation:
  309. return c.Tutorial.mutate(ctx, m)
  310. case *WorkExperienceMutation:
  311. return c.WorkExperience.mutate(ctx, m)
  312. case *WxMutation:
  313. return c.Wx.mutate(ctx, m)
  314. default:
  315. return nil, fmt.Errorf("ent: unknown mutation type %T", m)
  316. }
  317. }
  318. // AgentClient is a client for the Agent schema.
  319. type AgentClient struct {
  320. config
  321. }
  322. // NewAgentClient returns a client for the Agent from the given config.
  323. func NewAgentClient(c config) *AgentClient {
  324. return &AgentClient{config: c}
  325. }
  326. // Use adds a list of mutation hooks to the hooks stack.
  327. // A call to `Use(f, g, h)` equals to `agent.Hooks(f(g(h())))`.
  328. func (c *AgentClient) Use(hooks ...Hook) {
  329. c.hooks.Agent = append(c.hooks.Agent, hooks...)
  330. }
  331. // Intercept adds a list of query interceptors to the interceptors stack.
  332. // A call to `Intercept(f, g, h)` equals to `agent.Intercept(f(g(h())))`.
  333. func (c *AgentClient) Intercept(interceptors ...Interceptor) {
  334. c.inters.Agent = append(c.inters.Agent, interceptors...)
  335. }
  336. // Create returns a builder for creating a Agent entity.
  337. func (c *AgentClient) Create() *AgentCreate {
  338. mutation := newAgentMutation(c.config, OpCreate)
  339. return &AgentCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  340. }
  341. // CreateBulk returns a builder for creating a bulk of Agent entities.
  342. func (c *AgentClient) CreateBulk(builders ...*AgentCreate) *AgentCreateBulk {
  343. return &AgentCreateBulk{config: c.config, builders: builders}
  344. }
  345. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  346. // a builder and applies setFunc on it.
  347. func (c *AgentClient) MapCreateBulk(slice any, setFunc func(*AgentCreate, int)) *AgentCreateBulk {
  348. rv := reflect.ValueOf(slice)
  349. if rv.Kind() != reflect.Slice {
  350. return &AgentCreateBulk{err: fmt.Errorf("calling to AgentClient.MapCreateBulk with wrong type %T, need slice", slice)}
  351. }
  352. builders := make([]*AgentCreate, rv.Len())
  353. for i := 0; i < rv.Len(); i++ {
  354. builders[i] = c.Create()
  355. setFunc(builders[i], i)
  356. }
  357. return &AgentCreateBulk{config: c.config, builders: builders}
  358. }
  359. // Update returns an update builder for Agent.
  360. func (c *AgentClient) Update() *AgentUpdate {
  361. mutation := newAgentMutation(c.config, OpUpdate)
  362. return &AgentUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  363. }
  364. // UpdateOne returns an update builder for the given entity.
  365. func (c *AgentClient) UpdateOne(a *Agent) *AgentUpdateOne {
  366. mutation := newAgentMutation(c.config, OpUpdateOne, withAgent(a))
  367. return &AgentUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  368. }
  369. // UpdateOneID returns an update builder for the given id.
  370. func (c *AgentClient) UpdateOneID(id uint64) *AgentUpdateOne {
  371. mutation := newAgentMutation(c.config, OpUpdateOne, withAgentID(id))
  372. return &AgentUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  373. }
  374. // Delete returns a delete builder for Agent.
  375. func (c *AgentClient) Delete() *AgentDelete {
  376. mutation := newAgentMutation(c.config, OpDelete)
  377. return &AgentDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  378. }
  379. // DeleteOne returns a builder for deleting the given entity.
  380. func (c *AgentClient) DeleteOne(a *Agent) *AgentDeleteOne {
  381. return c.DeleteOneID(a.ID)
  382. }
  383. // DeleteOneID returns a builder for deleting the given entity by its id.
  384. func (c *AgentClient) DeleteOneID(id uint64) *AgentDeleteOne {
  385. builder := c.Delete().Where(agent.ID(id))
  386. builder.mutation.id = &id
  387. builder.mutation.op = OpDeleteOne
  388. return &AgentDeleteOne{builder}
  389. }
  390. // Query returns a query builder for Agent.
  391. func (c *AgentClient) Query() *AgentQuery {
  392. return &AgentQuery{
  393. config: c.config,
  394. ctx: &QueryContext{Type: TypeAgent},
  395. inters: c.Interceptors(),
  396. }
  397. }
  398. // Get returns a Agent entity by its id.
  399. func (c *AgentClient) Get(ctx context.Context, id uint64) (*Agent, error) {
  400. return c.Query().Where(agent.ID(id)).Only(ctx)
  401. }
  402. // GetX is like Get, but panics if an error occurs.
  403. func (c *AgentClient) GetX(ctx context.Context, id uint64) *Agent {
  404. obj, err := c.Get(ctx, id)
  405. if err != nil {
  406. panic(err)
  407. }
  408. return obj
  409. }
  410. // QueryWxAgent queries the wx_agent edge of a Agent.
  411. func (c *AgentClient) QueryWxAgent(a *Agent) *WxQuery {
  412. query := (&WxClient{config: c.config}).Query()
  413. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  414. id := a.ID
  415. step := sqlgraph.NewStep(
  416. sqlgraph.From(agent.Table, agent.FieldID, id),
  417. sqlgraph.To(wx.Table, wx.FieldID),
  418. sqlgraph.Edge(sqlgraph.O2M, false, agent.WxAgentTable, agent.WxAgentColumn),
  419. )
  420. fromV = sqlgraph.Neighbors(a.driver.Dialect(), step)
  421. return fromV, nil
  422. }
  423. return query
  424. }
  425. // Hooks returns the client hooks.
  426. func (c *AgentClient) Hooks() []Hook {
  427. hooks := c.hooks.Agent
  428. return append(hooks[:len(hooks):len(hooks)], agent.Hooks[:]...)
  429. }
  430. // Interceptors returns the client interceptors.
  431. func (c *AgentClient) Interceptors() []Interceptor {
  432. inters := c.inters.Agent
  433. return append(inters[:len(inters):len(inters)], agent.Interceptors[:]...)
  434. }
  435. func (c *AgentClient) mutate(ctx context.Context, m *AgentMutation) (Value, error) {
  436. switch m.Op() {
  437. case OpCreate:
  438. return (&AgentCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  439. case OpUpdate:
  440. return (&AgentUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  441. case OpUpdateOne:
  442. return (&AgentUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  443. case OpDelete, OpDeleteOne:
  444. return (&AgentDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  445. default:
  446. return nil, fmt.Errorf("ent: unknown Agent mutation op: %q", m.Op())
  447. }
  448. }
  449. // BatchMsgClient is a client for the BatchMsg schema.
  450. type BatchMsgClient struct {
  451. config
  452. }
  453. // NewBatchMsgClient returns a client for the BatchMsg from the given config.
  454. func NewBatchMsgClient(c config) *BatchMsgClient {
  455. return &BatchMsgClient{config: c}
  456. }
  457. // Use adds a list of mutation hooks to the hooks stack.
  458. // A call to `Use(f, g, h)` equals to `batchmsg.Hooks(f(g(h())))`.
  459. func (c *BatchMsgClient) Use(hooks ...Hook) {
  460. c.hooks.BatchMsg = append(c.hooks.BatchMsg, hooks...)
  461. }
  462. // Intercept adds a list of query interceptors to the interceptors stack.
  463. // A call to `Intercept(f, g, h)` equals to `batchmsg.Intercept(f(g(h())))`.
  464. func (c *BatchMsgClient) Intercept(interceptors ...Interceptor) {
  465. c.inters.BatchMsg = append(c.inters.BatchMsg, interceptors...)
  466. }
  467. // Create returns a builder for creating a BatchMsg entity.
  468. func (c *BatchMsgClient) Create() *BatchMsgCreate {
  469. mutation := newBatchMsgMutation(c.config, OpCreate)
  470. return &BatchMsgCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  471. }
  472. // CreateBulk returns a builder for creating a bulk of BatchMsg entities.
  473. func (c *BatchMsgClient) CreateBulk(builders ...*BatchMsgCreate) *BatchMsgCreateBulk {
  474. return &BatchMsgCreateBulk{config: c.config, builders: builders}
  475. }
  476. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  477. // a builder and applies setFunc on it.
  478. func (c *BatchMsgClient) MapCreateBulk(slice any, setFunc func(*BatchMsgCreate, int)) *BatchMsgCreateBulk {
  479. rv := reflect.ValueOf(slice)
  480. if rv.Kind() != reflect.Slice {
  481. return &BatchMsgCreateBulk{err: fmt.Errorf("calling to BatchMsgClient.MapCreateBulk with wrong type %T, need slice", slice)}
  482. }
  483. builders := make([]*BatchMsgCreate, rv.Len())
  484. for i := 0; i < rv.Len(); i++ {
  485. builders[i] = c.Create()
  486. setFunc(builders[i], i)
  487. }
  488. return &BatchMsgCreateBulk{config: c.config, builders: builders}
  489. }
  490. // Update returns an update builder for BatchMsg.
  491. func (c *BatchMsgClient) Update() *BatchMsgUpdate {
  492. mutation := newBatchMsgMutation(c.config, OpUpdate)
  493. return &BatchMsgUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  494. }
  495. // UpdateOne returns an update builder for the given entity.
  496. func (c *BatchMsgClient) UpdateOne(bm *BatchMsg) *BatchMsgUpdateOne {
  497. mutation := newBatchMsgMutation(c.config, OpUpdateOne, withBatchMsg(bm))
  498. return &BatchMsgUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  499. }
  500. // UpdateOneID returns an update builder for the given id.
  501. func (c *BatchMsgClient) UpdateOneID(id uint64) *BatchMsgUpdateOne {
  502. mutation := newBatchMsgMutation(c.config, OpUpdateOne, withBatchMsgID(id))
  503. return &BatchMsgUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  504. }
  505. // Delete returns a delete builder for BatchMsg.
  506. func (c *BatchMsgClient) Delete() *BatchMsgDelete {
  507. mutation := newBatchMsgMutation(c.config, OpDelete)
  508. return &BatchMsgDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  509. }
  510. // DeleteOne returns a builder for deleting the given entity.
  511. func (c *BatchMsgClient) DeleteOne(bm *BatchMsg) *BatchMsgDeleteOne {
  512. return c.DeleteOneID(bm.ID)
  513. }
  514. // DeleteOneID returns a builder for deleting the given entity by its id.
  515. func (c *BatchMsgClient) DeleteOneID(id uint64) *BatchMsgDeleteOne {
  516. builder := c.Delete().Where(batchmsg.ID(id))
  517. builder.mutation.id = &id
  518. builder.mutation.op = OpDeleteOne
  519. return &BatchMsgDeleteOne{builder}
  520. }
  521. // Query returns a query builder for BatchMsg.
  522. func (c *BatchMsgClient) Query() *BatchMsgQuery {
  523. return &BatchMsgQuery{
  524. config: c.config,
  525. ctx: &QueryContext{Type: TypeBatchMsg},
  526. inters: c.Interceptors(),
  527. }
  528. }
  529. // Get returns a BatchMsg entity by its id.
  530. func (c *BatchMsgClient) Get(ctx context.Context, id uint64) (*BatchMsg, error) {
  531. return c.Query().Where(batchmsg.ID(id)).Only(ctx)
  532. }
  533. // GetX is like Get, but panics if an error occurs.
  534. func (c *BatchMsgClient) GetX(ctx context.Context, id uint64) *BatchMsg {
  535. obj, err := c.Get(ctx, id)
  536. if err != nil {
  537. panic(err)
  538. }
  539. return obj
  540. }
  541. // Hooks returns the client hooks.
  542. func (c *BatchMsgClient) Hooks() []Hook {
  543. hooks := c.hooks.BatchMsg
  544. return append(hooks[:len(hooks):len(hooks)], batchmsg.Hooks[:]...)
  545. }
  546. // Interceptors returns the client interceptors.
  547. func (c *BatchMsgClient) Interceptors() []Interceptor {
  548. inters := c.inters.BatchMsg
  549. return append(inters[:len(inters):len(inters)], batchmsg.Interceptors[:]...)
  550. }
  551. func (c *BatchMsgClient) mutate(ctx context.Context, m *BatchMsgMutation) (Value, error) {
  552. switch m.Op() {
  553. case OpCreate:
  554. return (&BatchMsgCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  555. case OpUpdate:
  556. return (&BatchMsgUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  557. case OpUpdateOne:
  558. return (&BatchMsgUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  559. case OpDelete, OpDeleteOne:
  560. return (&BatchMsgDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  561. default:
  562. return nil, fmt.Errorf("ent: unknown BatchMsg mutation op: %q", m.Op())
  563. }
  564. }
  565. // ContactClient is a client for the Contact schema.
  566. type ContactClient struct {
  567. config
  568. }
  569. // NewContactClient returns a client for the Contact from the given config.
  570. func NewContactClient(c config) *ContactClient {
  571. return &ContactClient{config: c}
  572. }
  573. // Use adds a list of mutation hooks to the hooks stack.
  574. // A call to `Use(f, g, h)` equals to `contact.Hooks(f(g(h())))`.
  575. func (c *ContactClient) Use(hooks ...Hook) {
  576. c.hooks.Contact = append(c.hooks.Contact, hooks...)
  577. }
  578. // Intercept adds a list of query interceptors to the interceptors stack.
  579. // A call to `Intercept(f, g, h)` equals to `contact.Intercept(f(g(h())))`.
  580. func (c *ContactClient) Intercept(interceptors ...Interceptor) {
  581. c.inters.Contact = append(c.inters.Contact, interceptors...)
  582. }
  583. // Create returns a builder for creating a Contact entity.
  584. func (c *ContactClient) Create() *ContactCreate {
  585. mutation := newContactMutation(c.config, OpCreate)
  586. return &ContactCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  587. }
  588. // CreateBulk returns a builder for creating a bulk of Contact entities.
  589. func (c *ContactClient) CreateBulk(builders ...*ContactCreate) *ContactCreateBulk {
  590. return &ContactCreateBulk{config: c.config, builders: builders}
  591. }
  592. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  593. // a builder and applies setFunc on it.
  594. func (c *ContactClient) MapCreateBulk(slice any, setFunc func(*ContactCreate, int)) *ContactCreateBulk {
  595. rv := reflect.ValueOf(slice)
  596. if rv.Kind() != reflect.Slice {
  597. return &ContactCreateBulk{err: fmt.Errorf("calling to ContactClient.MapCreateBulk with wrong type %T, need slice", slice)}
  598. }
  599. builders := make([]*ContactCreate, rv.Len())
  600. for i := 0; i < rv.Len(); i++ {
  601. builders[i] = c.Create()
  602. setFunc(builders[i], i)
  603. }
  604. return &ContactCreateBulk{config: c.config, builders: builders}
  605. }
  606. // Update returns an update builder for Contact.
  607. func (c *ContactClient) Update() *ContactUpdate {
  608. mutation := newContactMutation(c.config, OpUpdate)
  609. return &ContactUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  610. }
  611. // UpdateOne returns an update builder for the given entity.
  612. func (c *ContactClient) UpdateOne(co *Contact) *ContactUpdateOne {
  613. mutation := newContactMutation(c.config, OpUpdateOne, withContact(co))
  614. return &ContactUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  615. }
  616. // UpdateOneID returns an update builder for the given id.
  617. func (c *ContactClient) UpdateOneID(id uint64) *ContactUpdateOne {
  618. mutation := newContactMutation(c.config, OpUpdateOne, withContactID(id))
  619. return &ContactUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  620. }
  621. // Delete returns a delete builder for Contact.
  622. func (c *ContactClient) Delete() *ContactDelete {
  623. mutation := newContactMutation(c.config, OpDelete)
  624. return &ContactDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  625. }
  626. // DeleteOne returns a builder for deleting the given entity.
  627. func (c *ContactClient) DeleteOne(co *Contact) *ContactDeleteOne {
  628. return c.DeleteOneID(co.ID)
  629. }
  630. // DeleteOneID returns a builder for deleting the given entity by its id.
  631. func (c *ContactClient) DeleteOneID(id uint64) *ContactDeleteOne {
  632. builder := c.Delete().Where(contact.ID(id))
  633. builder.mutation.id = &id
  634. builder.mutation.op = OpDeleteOne
  635. return &ContactDeleteOne{builder}
  636. }
  637. // Query returns a query builder for Contact.
  638. func (c *ContactClient) Query() *ContactQuery {
  639. return &ContactQuery{
  640. config: c.config,
  641. ctx: &QueryContext{Type: TypeContact},
  642. inters: c.Interceptors(),
  643. }
  644. }
  645. // Get returns a Contact entity by its id.
  646. func (c *ContactClient) Get(ctx context.Context, id uint64) (*Contact, error) {
  647. return c.Query().Where(contact.ID(id)).Only(ctx)
  648. }
  649. // GetX is like Get, but panics if an error occurs.
  650. func (c *ContactClient) GetX(ctx context.Context, id uint64) *Contact {
  651. obj, err := c.Get(ctx, id)
  652. if err != nil {
  653. panic(err)
  654. }
  655. return obj
  656. }
  657. // QueryContactRelationships queries the contact_relationships edge of a Contact.
  658. func (c *ContactClient) QueryContactRelationships(co *Contact) *LabelRelationshipQuery {
  659. query := (&LabelRelationshipClient{config: c.config}).Query()
  660. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  661. id := co.ID
  662. step := sqlgraph.NewStep(
  663. sqlgraph.From(contact.Table, contact.FieldID, id),
  664. sqlgraph.To(labelrelationship.Table, labelrelationship.FieldID),
  665. sqlgraph.Edge(sqlgraph.O2M, false, contact.ContactRelationshipsTable, contact.ContactRelationshipsColumn),
  666. )
  667. fromV = sqlgraph.Neighbors(co.driver.Dialect(), step)
  668. return fromV, nil
  669. }
  670. return query
  671. }
  672. // QueryContactMessages queries the contact_messages edge of a Contact.
  673. func (c *ContactClient) QueryContactMessages(co *Contact) *MessageRecordsQuery {
  674. query := (&MessageRecordsClient{config: c.config}).Query()
  675. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  676. id := co.ID
  677. step := sqlgraph.NewStep(
  678. sqlgraph.From(contact.Table, contact.FieldID, id),
  679. sqlgraph.To(messagerecords.Table, messagerecords.FieldID),
  680. sqlgraph.Edge(sqlgraph.O2M, false, contact.ContactMessagesTable, contact.ContactMessagesColumn),
  681. )
  682. fromV = sqlgraph.Neighbors(co.driver.Dialect(), step)
  683. return fromV, nil
  684. }
  685. return query
  686. }
  687. // Hooks returns the client hooks.
  688. func (c *ContactClient) Hooks() []Hook {
  689. hooks := c.hooks.Contact
  690. return append(hooks[:len(hooks):len(hooks)], contact.Hooks[:]...)
  691. }
  692. // Interceptors returns the client interceptors.
  693. func (c *ContactClient) Interceptors() []Interceptor {
  694. inters := c.inters.Contact
  695. return append(inters[:len(inters):len(inters)], contact.Interceptors[:]...)
  696. }
  697. func (c *ContactClient) mutate(ctx context.Context, m *ContactMutation) (Value, error) {
  698. switch m.Op() {
  699. case OpCreate:
  700. return (&ContactCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  701. case OpUpdate:
  702. return (&ContactUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  703. case OpUpdateOne:
  704. return (&ContactUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  705. case OpDelete, OpDeleteOne:
  706. return (&ContactDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  707. default:
  708. return nil, fmt.Errorf("ent: unknown Contact mutation op: %q", m.Op())
  709. }
  710. }
  711. // EmployeeClient is a client for the Employee schema.
  712. type EmployeeClient struct {
  713. config
  714. }
  715. // NewEmployeeClient returns a client for the Employee from the given config.
  716. func NewEmployeeClient(c config) *EmployeeClient {
  717. return &EmployeeClient{config: c}
  718. }
  719. // Use adds a list of mutation hooks to the hooks stack.
  720. // A call to `Use(f, g, h)` equals to `employee.Hooks(f(g(h())))`.
  721. func (c *EmployeeClient) Use(hooks ...Hook) {
  722. c.hooks.Employee = append(c.hooks.Employee, hooks...)
  723. }
  724. // Intercept adds a list of query interceptors to the interceptors stack.
  725. // A call to `Intercept(f, g, h)` equals to `employee.Intercept(f(g(h())))`.
  726. func (c *EmployeeClient) Intercept(interceptors ...Interceptor) {
  727. c.inters.Employee = append(c.inters.Employee, interceptors...)
  728. }
  729. // Create returns a builder for creating a Employee entity.
  730. func (c *EmployeeClient) Create() *EmployeeCreate {
  731. mutation := newEmployeeMutation(c.config, OpCreate)
  732. return &EmployeeCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  733. }
  734. // CreateBulk returns a builder for creating a bulk of Employee entities.
  735. func (c *EmployeeClient) CreateBulk(builders ...*EmployeeCreate) *EmployeeCreateBulk {
  736. return &EmployeeCreateBulk{config: c.config, builders: builders}
  737. }
  738. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  739. // a builder and applies setFunc on it.
  740. func (c *EmployeeClient) MapCreateBulk(slice any, setFunc func(*EmployeeCreate, int)) *EmployeeCreateBulk {
  741. rv := reflect.ValueOf(slice)
  742. if rv.Kind() != reflect.Slice {
  743. return &EmployeeCreateBulk{err: fmt.Errorf("calling to EmployeeClient.MapCreateBulk with wrong type %T, need slice", slice)}
  744. }
  745. builders := make([]*EmployeeCreate, rv.Len())
  746. for i := 0; i < rv.Len(); i++ {
  747. builders[i] = c.Create()
  748. setFunc(builders[i], i)
  749. }
  750. return &EmployeeCreateBulk{config: c.config, builders: builders}
  751. }
  752. // Update returns an update builder for Employee.
  753. func (c *EmployeeClient) Update() *EmployeeUpdate {
  754. mutation := newEmployeeMutation(c.config, OpUpdate)
  755. return &EmployeeUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  756. }
  757. // UpdateOne returns an update builder for the given entity.
  758. func (c *EmployeeClient) UpdateOne(e *Employee) *EmployeeUpdateOne {
  759. mutation := newEmployeeMutation(c.config, OpUpdateOne, withEmployee(e))
  760. return &EmployeeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  761. }
  762. // UpdateOneID returns an update builder for the given id.
  763. func (c *EmployeeClient) UpdateOneID(id uint64) *EmployeeUpdateOne {
  764. mutation := newEmployeeMutation(c.config, OpUpdateOne, withEmployeeID(id))
  765. return &EmployeeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  766. }
  767. // Delete returns a delete builder for Employee.
  768. func (c *EmployeeClient) Delete() *EmployeeDelete {
  769. mutation := newEmployeeMutation(c.config, OpDelete)
  770. return &EmployeeDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  771. }
  772. // DeleteOne returns a builder for deleting the given entity.
  773. func (c *EmployeeClient) DeleteOne(e *Employee) *EmployeeDeleteOne {
  774. return c.DeleteOneID(e.ID)
  775. }
  776. // DeleteOneID returns a builder for deleting the given entity by its id.
  777. func (c *EmployeeClient) DeleteOneID(id uint64) *EmployeeDeleteOne {
  778. builder := c.Delete().Where(employee.ID(id))
  779. builder.mutation.id = &id
  780. builder.mutation.op = OpDeleteOne
  781. return &EmployeeDeleteOne{builder}
  782. }
  783. // Query returns a query builder for Employee.
  784. func (c *EmployeeClient) Query() *EmployeeQuery {
  785. return &EmployeeQuery{
  786. config: c.config,
  787. ctx: &QueryContext{Type: TypeEmployee},
  788. inters: c.Interceptors(),
  789. }
  790. }
  791. // Get returns a Employee entity by its id.
  792. func (c *EmployeeClient) Get(ctx context.Context, id uint64) (*Employee, error) {
  793. return c.Query().Where(employee.ID(id)).Only(ctx)
  794. }
  795. // GetX is like Get, but panics if an error occurs.
  796. func (c *EmployeeClient) GetX(ctx context.Context, id uint64) *Employee {
  797. obj, err := c.Get(ctx, id)
  798. if err != nil {
  799. panic(err)
  800. }
  801. return obj
  802. }
  803. // QueryEmWorkExperiences queries the em_work_experiences edge of a Employee.
  804. func (c *EmployeeClient) QueryEmWorkExperiences(e *Employee) *WorkExperienceQuery {
  805. query := (&WorkExperienceClient{config: c.config}).Query()
  806. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  807. id := e.ID
  808. step := sqlgraph.NewStep(
  809. sqlgraph.From(employee.Table, employee.FieldID, id),
  810. sqlgraph.To(workexperience.Table, workexperience.FieldID),
  811. sqlgraph.Edge(sqlgraph.O2M, false, employee.EmWorkExperiencesTable, employee.EmWorkExperiencesColumn),
  812. )
  813. fromV = sqlgraph.Neighbors(e.driver.Dialect(), step)
  814. return fromV, nil
  815. }
  816. return query
  817. }
  818. // QueryEmTutorial queries the em_tutorial edge of a Employee.
  819. func (c *EmployeeClient) QueryEmTutorial(e *Employee) *TutorialQuery {
  820. query := (&TutorialClient{config: c.config}).Query()
  821. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  822. id := e.ID
  823. step := sqlgraph.NewStep(
  824. sqlgraph.From(employee.Table, employee.FieldID, id),
  825. sqlgraph.To(tutorial.Table, tutorial.FieldID),
  826. sqlgraph.Edge(sqlgraph.O2M, false, employee.EmTutorialTable, employee.EmTutorialColumn),
  827. )
  828. fromV = sqlgraph.Neighbors(e.driver.Dialect(), step)
  829. return fromV, nil
  830. }
  831. return query
  832. }
  833. // Hooks returns the client hooks.
  834. func (c *EmployeeClient) Hooks() []Hook {
  835. hooks := c.hooks.Employee
  836. return append(hooks[:len(hooks):len(hooks)], employee.Hooks[:]...)
  837. }
  838. // Interceptors returns the client interceptors.
  839. func (c *EmployeeClient) Interceptors() []Interceptor {
  840. inters := c.inters.Employee
  841. return append(inters[:len(inters):len(inters)], employee.Interceptors[:]...)
  842. }
  843. func (c *EmployeeClient) mutate(ctx context.Context, m *EmployeeMutation) (Value, error) {
  844. switch m.Op() {
  845. case OpCreate:
  846. return (&EmployeeCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  847. case OpUpdate:
  848. return (&EmployeeUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  849. case OpUpdateOne:
  850. return (&EmployeeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  851. case OpDelete, OpDeleteOne:
  852. return (&EmployeeDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  853. default:
  854. return nil, fmt.Errorf("ent: unknown Employee mutation op: %q", m.Op())
  855. }
  856. }
  857. // LabelClient is a client for the Label schema.
  858. type LabelClient struct {
  859. config
  860. }
  861. // NewLabelClient returns a client for the Label from the given config.
  862. func NewLabelClient(c config) *LabelClient {
  863. return &LabelClient{config: c}
  864. }
  865. // Use adds a list of mutation hooks to the hooks stack.
  866. // A call to `Use(f, g, h)` equals to `label.Hooks(f(g(h())))`.
  867. func (c *LabelClient) Use(hooks ...Hook) {
  868. c.hooks.Label = append(c.hooks.Label, hooks...)
  869. }
  870. // Intercept adds a list of query interceptors to the interceptors stack.
  871. // A call to `Intercept(f, g, h)` equals to `label.Intercept(f(g(h())))`.
  872. func (c *LabelClient) Intercept(interceptors ...Interceptor) {
  873. c.inters.Label = append(c.inters.Label, interceptors...)
  874. }
  875. // Create returns a builder for creating a Label entity.
  876. func (c *LabelClient) Create() *LabelCreate {
  877. mutation := newLabelMutation(c.config, OpCreate)
  878. return &LabelCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  879. }
  880. // CreateBulk returns a builder for creating a bulk of Label entities.
  881. func (c *LabelClient) CreateBulk(builders ...*LabelCreate) *LabelCreateBulk {
  882. return &LabelCreateBulk{config: c.config, builders: builders}
  883. }
  884. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  885. // a builder and applies setFunc on it.
  886. func (c *LabelClient) MapCreateBulk(slice any, setFunc func(*LabelCreate, int)) *LabelCreateBulk {
  887. rv := reflect.ValueOf(slice)
  888. if rv.Kind() != reflect.Slice {
  889. return &LabelCreateBulk{err: fmt.Errorf("calling to LabelClient.MapCreateBulk with wrong type %T, need slice", slice)}
  890. }
  891. builders := make([]*LabelCreate, rv.Len())
  892. for i := 0; i < rv.Len(); i++ {
  893. builders[i] = c.Create()
  894. setFunc(builders[i], i)
  895. }
  896. return &LabelCreateBulk{config: c.config, builders: builders}
  897. }
  898. // Update returns an update builder for Label.
  899. func (c *LabelClient) Update() *LabelUpdate {
  900. mutation := newLabelMutation(c.config, OpUpdate)
  901. return &LabelUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  902. }
  903. // UpdateOne returns an update builder for the given entity.
  904. func (c *LabelClient) UpdateOne(l *Label) *LabelUpdateOne {
  905. mutation := newLabelMutation(c.config, OpUpdateOne, withLabel(l))
  906. return &LabelUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  907. }
  908. // UpdateOneID returns an update builder for the given id.
  909. func (c *LabelClient) UpdateOneID(id uint64) *LabelUpdateOne {
  910. mutation := newLabelMutation(c.config, OpUpdateOne, withLabelID(id))
  911. return &LabelUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  912. }
  913. // Delete returns a delete builder for Label.
  914. func (c *LabelClient) Delete() *LabelDelete {
  915. mutation := newLabelMutation(c.config, OpDelete)
  916. return &LabelDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  917. }
  918. // DeleteOne returns a builder for deleting the given entity.
  919. func (c *LabelClient) DeleteOne(l *Label) *LabelDeleteOne {
  920. return c.DeleteOneID(l.ID)
  921. }
  922. // DeleteOneID returns a builder for deleting the given entity by its id.
  923. func (c *LabelClient) DeleteOneID(id uint64) *LabelDeleteOne {
  924. builder := c.Delete().Where(label.ID(id))
  925. builder.mutation.id = &id
  926. builder.mutation.op = OpDeleteOne
  927. return &LabelDeleteOne{builder}
  928. }
  929. // Query returns a query builder for Label.
  930. func (c *LabelClient) Query() *LabelQuery {
  931. return &LabelQuery{
  932. config: c.config,
  933. ctx: &QueryContext{Type: TypeLabel},
  934. inters: c.Interceptors(),
  935. }
  936. }
  937. // Get returns a Label entity by its id.
  938. func (c *LabelClient) Get(ctx context.Context, id uint64) (*Label, error) {
  939. return c.Query().Where(label.ID(id)).Only(ctx)
  940. }
  941. // GetX is like Get, but panics if an error occurs.
  942. func (c *LabelClient) GetX(ctx context.Context, id uint64) *Label {
  943. obj, err := c.Get(ctx, id)
  944. if err != nil {
  945. panic(err)
  946. }
  947. return obj
  948. }
  949. // QueryLabelRelationships queries the label_relationships edge of a Label.
  950. func (c *LabelClient) QueryLabelRelationships(l *Label) *LabelRelationshipQuery {
  951. query := (&LabelRelationshipClient{config: c.config}).Query()
  952. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  953. id := l.ID
  954. step := sqlgraph.NewStep(
  955. sqlgraph.From(label.Table, label.FieldID, id),
  956. sqlgraph.To(labelrelationship.Table, labelrelationship.FieldID),
  957. sqlgraph.Edge(sqlgraph.O2M, false, label.LabelRelationshipsTable, label.LabelRelationshipsColumn),
  958. )
  959. fromV = sqlgraph.Neighbors(l.driver.Dialect(), step)
  960. return fromV, nil
  961. }
  962. return query
  963. }
  964. // Hooks returns the client hooks.
  965. func (c *LabelClient) Hooks() []Hook {
  966. return c.hooks.Label
  967. }
  968. // Interceptors returns the client interceptors.
  969. func (c *LabelClient) Interceptors() []Interceptor {
  970. return c.inters.Label
  971. }
  972. func (c *LabelClient) mutate(ctx context.Context, m *LabelMutation) (Value, error) {
  973. switch m.Op() {
  974. case OpCreate:
  975. return (&LabelCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  976. case OpUpdate:
  977. return (&LabelUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  978. case OpUpdateOne:
  979. return (&LabelUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  980. case OpDelete, OpDeleteOne:
  981. return (&LabelDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  982. default:
  983. return nil, fmt.Errorf("ent: unknown Label mutation op: %q", m.Op())
  984. }
  985. }
  986. // LabelRelationshipClient is a client for the LabelRelationship schema.
  987. type LabelRelationshipClient struct {
  988. config
  989. }
  990. // NewLabelRelationshipClient returns a client for the LabelRelationship from the given config.
  991. func NewLabelRelationshipClient(c config) *LabelRelationshipClient {
  992. return &LabelRelationshipClient{config: c}
  993. }
  994. // Use adds a list of mutation hooks to the hooks stack.
  995. // A call to `Use(f, g, h)` equals to `labelrelationship.Hooks(f(g(h())))`.
  996. func (c *LabelRelationshipClient) Use(hooks ...Hook) {
  997. c.hooks.LabelRelationship = append(c.hooks.LabelRelationship, hooks...)
  998. }
  999. // Intercept adds a list of query interceptors to the interceptors stack.
  1000. // A call to `Intercept(f, g, h)` equals to `labelrelationship.Intercept(f(g(h())))`.
  1001. func (c *LabelRelationshipClient) Intercept(interceptors ...Interceptor) {
  1002. c.inters.LabelRelationship = append(c.inters.LabelRelationship, interceptors...)
  1003. }
  1004. // Create returns a builder for creating a LabelRelationship entity.
  1005. func (c *LabelRelationshipClient) Create() *LabelRelationshipCreate {
  1006. mutation := newLabelRelationshipMutation(c.config, OpCreate)
  1007. return &LabelRelationshipCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1008. }
  1009. // CreateBulk returns a builder for creating a bulk of LabelRelationship entities.
  1010. func (c *LabelRelationshipClient) CreateBulk(builders ...*LabelRelationshipCreate) *LabelRelationshipCreateBulk {
  1011. return &LabelRelationshipCreateBulk{config: c.config, builders: builders}
  1012. }
  1013. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  1014. // a builder and applies setFunc on it.
  1015. func (c *LabelRelationshipClient) MapCreateBulk(slice any, setFunc func(*LabelRelationshipCreate, int)) *LabelRelationshipCreateBulk {
  1016. rv := reflect.ValueOf(slice)
  1017. if rv.Kind() != reflect.Slice {
  1018. return &LabelRelationshipCreateBulk{err: fmt.Errorf("calling to LabelRelationshipClient.MapCreateBulk with wrong type %T, need slice", slice)}
  1019. }
  1020. builders := make([]*LabelRelationshipCreate, rv.Len())
  1021. for i := 0; i < rv.Len(); i++ {
  1022. builders[i] = c.Create()
  1023. setFunc(builders[i], i)
  1024. }
  1025. return &LabelRelationshipCreateBulk{config: c.config, builders: builders}
  1026. }
  1027. // Update returns an update builder for LabelRelationship.
  1028. func (c *LabelRelationshipClient) Update() *LabelRelationshipUpdate {
  1029. mutation := newLabelRelationshipMutation(c.config, OpUpdate)
  1030. return &LabelRelationshipUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1031. }
  1032. // UpdateOne returns an update builder for the given entity.
  1033. func (c *LabelRelationshipClient) UpdateOne(lr *LabelRelationship) *LabelRelationshipUpdateOne {
  1034. mutation := newLabelRelationshipMutation(c.config, OpUpdateOne, withLabelRelationship(lr))
  1035. return &LabelRelationshipUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1036. }
  1037. // UpdateOneID returns an update builder for the given id.
  1038. func (c *LabelRelationshipClient) UpdateOneID(id uint64) *LabelRelationshipUpdateOne {
  1039. mutation := newLabelRelationshipMutation(c.config, OpUpdateOne, withLabelRelationshipID(id))
  1040. return &LabelRelationshipUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1041. }
  1042. // Delete returns a delete builder for LabelRelationship.
  1043. func (c *LabelRelationshipClient) Delete() *LabelRelationshipDelete {
  1044. mutation := newLabelRelationshipMutation(c.config, OpDelete)
  1045. return &LabelRelationshipDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1046. }
  1047. // DeleteOne returns a builder for deleting the given entity.
  1048. func (c *LabelRelationshipClient) DeleteOne(lr *LabelRelationship) *LabelRelationshipDeleteOne {
  1049. return c.DeleteOneID(lr.ID)
  1050. }
  1051. // DeleteOneID returns a builder for deleting the given entity by its id.
  1052. func (c *LabelRelationshipClient) DeleteOneID(id uint64) *LabelRelationshipDeleteOne {
  1053. builder := c.Delete().Where(labelrelationship.ID(id))
  1054. builder.mutation.id = &id
  1055. builder.mutation.op = OpDeleteOne
  1056. return &LabelRelationshipDeleteOne{builder}
  1057. }
  1058. // Query returns a query builder for LabelRelationship.
  1059. func (c *LabelRelationshipClient) Query() *LabelRelationshipQuery {
  1060. return &LabelRelationshipQuery{
  1061. config: c.config,
  1062. ctx: &QueryContext{Type: TypeLabelRelationship},
  1063. inters: c.Interceptors(),
  1064. }
  1065. }
  1066. // Get returns a LabelRelationship entity by its id.
  1067. func (c *LabelRelationshipClient) Get(ctx context.Context, id uint64) (*LabelRelationship, error) {
  1068. return c.Query().Where(labelrelationship.ID(id)).Only(ctx)
  1069. }
  1070. // GetX is like Get, but panics if an error occurs.
  1071. func (c *LabelRelationshipClient) GetX(ctx context.Context, id uint64) *LabelRelationship {
  1072. obj, err := c.Get(ctx, id)
  1073. if err != nil {
  1074. panic(err)
  1075. }
  1076. return obj
  1077. }
  1078. // QueryContacts queries the contacts edge of a LabelRelationship.
  1079. func (c *LabelRelationshipClient) QueryContacts(lr *LabelRelationship) *ContactQuery {
  1080. query := (&ContactClient{config: c.config}).Query()
  1081. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  1082. id := lr.ID
  1083. step := sqlgraph.NewStep(
  1084. sqlgraph.From(labelrelationship.Table, labelrelationship.FieldID, id),
  1085. sqlgraph.To(contact.Table, contact.FieldID),
  1086. sqlgraph.Edge(sqlgraph.M2O, true, labelrelationship.ContactsTable, labelrelationship.ContactsColumn),
  1087. )
  1088. fromV = sqlgraph.Neighbors(lr.driver.Dialect(), step)
  1089. return fromV, nil
  1090. }
  1091. return query
  1092. }
  1093. // QueryLabels queries the labels edge of a LabelRelationship.
  1094. func (c *LabelRelationshipClient) QueryLabels(lr *LabelRelationship) *LabelQuery {
  1095. query := (&LabelClient{config: c.config}).Query()
  1096. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  1097. id := lr.ID
  1098. step := sqlgraph.NewStep(
  1099. sqlgraph.From(labelrelationship.Table, labelrelationship.FieldID, id),
  1100. sqlgraph.To(label.Table, label.FieldID),
  1101. sqlgraph.Edge(sqlgraph.M2O, true, labelrelationship.LabelsTable, labelrelationship.LabelsColumn),
  1102. )
  1103. fromV = sqlgraph.Neighbors(lr.driver.Dialect(), step)
  1104. return fromV, nil
  1105. }
  1106. return query
  1107. }
  1108. // Hooks returns the client hooks.
  1109. func (c *LabelRelationshipClient) Hooks() []Hook {
  1110. hooks := c.hooks.LabelRelationship
  1111. return append(hooks[:len(hooks):len(hooks)], labelrelationship.Hooks[:]...)
  1112. }
  1113. // Interceptors returns the client interceptors.
  1114. func (c *LabelRelationshipClient) Interceptors() []Interceptor {
  1115. inters := c.inters.LabelRelationship
  1116. return append(inters[:len(inters):len(inters)], labelrelationship.Interceptors[:]...)
  1117. }
  1118. func (c *LabelRelationshipClient) mutate(ctx context.Context, m *LabelRelationshipMutation) (Value, error) {
  1119. switch m.Op() {
  1120. case OpCreate:
  1121. return (&LabelRelationshipCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1122. case OpUpdate:
  1123. return (&LabelRelationshipUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1124. case OpUpdateOne:
  1125. return (&LabelRelationshipUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1126. case OpDelete, OpDeleteOne:
  1127. return (&LabelRelationshipDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  1128. default:
  1129. return nil, fmt.Errorf("ent: unknown LabelRelationship mutation op: %q", m.Op())
  1130. }
  1131. }
  1132. // MessageClient is a client for the Message schema.
  1133. type MessageClient struct {
  1134. config
  1135. }
  1136. // NewMessageClient returns a client for the Message from the given config.
  1137. func NewMessageClient(c config) *MessageClient {
  1138. return &MessageClient{config: c}
  1139. }
  1140. // Use adds a list of mutation hooks to the hooks stack.
  1141. // A call to `Use(f, g, h)` equals to `message.Hooks(f(g(h())))`.
  1142. func (c *MessageClient) Use(hooks ...Hook) {
  1143. c.hooks.Message = append(c.hooks.Message, hooks...)
  1144. }
  1145. // Intercept adds a list of query interceptors to the interceptors stack.
  1146. // A call to `Intercept(f, g, h)` equals to `message.Intercept(f(g(h())))`.
  1147. func (c *MessageClient) Intercept(interceptors ...Interceptor) {
  1148. c.inters.Message = append(c.inters.Message, interceptors...)
  1149. }
  1150. // Create returns a builder for creating a Message entity.
  1151. func (c *MessageClient) Create() *MessageCreate {
  1152. mutation := newMessageMutation(c.config, OpCreate)
  1153. return &MessageCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1154. }
  1155. // CreateBulk returns a builder for creating a bulk of Message entities.
  1156. func (c *MessageClient) CreateBulk(builders ...*MessageCreate) *MessageCreateBulk {
  1157. return &MessageCreateBulk{config: c.config, builders: builders}
  1158. }
  1159. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  1160. // a builder and applies setFunc on it.
  1161. func (c *MessageClient) MapCreateBulk(slice any, setFunc func(*MessageCreate, int)) *MessageCreateBulk {
  1162. rv := reflect.ValueOf(slice)
  1163. if rv.Kind() != reflect.Slice {
  1164. return &MessageCreateBulk{err: fmt.Errorf("calling to MessageClient.MapCreateBulk with wrong type %T, need slice", slice)}
  1165. }
  1166. builders := make([]*MessageCreate, rv.Len())
  1167. for i := 0; i < rv.Len(); i++ {
  1168. builders[i] = c.Create()
  1169. setFunc(builders[i], i)
  1170. }
  1171. return &MessageCreateBulk{config: c.config, builders: builders}
  1172. }
  1173. // Update returns an update builder for Message.
  1174. func (c *MessageClient) Update() *MessageUpdate {
  1175. mutation := newMessageMutation(c.config, OpUpdate)
  1176. return &MessageUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1177. }
  1178. // UpdateOne returns an update builder for the given entity.
  1179. func (c *MessageClient) UpdateOne(m *Message) *MessageUpdateOne {
  1180. mutation := newMessageMutation(c.config, OpUpdateOne, withMessage(m))
  1181. return &MessageUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1182. }
  1183. // UpdateOneID returns an update builder for the given id.
  1184. func (c *MessageClient) UpdateOneID(id int) *MessageUpdateOne {
  1185. mutation := newMessageMutation(c.config, OpUpdateOne, withMessageID(id))
  1186. return &MessageUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1187. }
  1188. // Delete returns a delete builder for Message.
  1189. func (c *MessageClient) Delete() *MessageDelete {
  1190. mutation := newMessageMutation(c.config, OpDelete)
  1191. return &MessageDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1192. }
  1193. // DeleteOne returns a builder for deleting the given entity.
  1194. func (c *MessageClient) DeleteOne(m *Message) *MessageDeleteOne {
  1195. return c.DeleteOneID(m.ID)
  1196. }
  1197. // DeleteOneID returns a builder for deleting the given entity by its id.
  1198. func (c *MessageClient) DeleteOneID(id int) *MessageDeleteOne {
  1199. builder := c.Delete().Where(message.ID(id))
  1200. builder.mutation.id = &id
  1201. builder.mutation.op = OpDeleteOne
  1202. return &MessageDeleteOne{builder}
  1203. }
  1204. // Query returns a query builder for Message.
  1205. func (c *MessageClient) Query() *MessageQuery {
  1206. return &MessageQuery{
  1207. config: c.config,
  1208. ctx: &QueryContext{Type: TypeMessage},
  1209. inters: c.Interceptors(),
  1210. }
  1211. }
  1212. // Get returns a Message entity by its id.
  1213. func (c *MessageClient) Get(ctx context.Context, id int) (*Message, error) {
  1214. return c.Query().Where(message.ID(id)).Only(ctx)
  1215. }
  1216. // GetX is like Get, but panics if an error occurs.
  1217. func (c *MessageClient) GetX(ctx context.Context, id int) *Message {
  1218. obj, err := c.Get(ctx, id)
  1219. if err != nil {
  1220. panic(err)
  1221. }
  1222. return obj
  1223. }
  1224. // Hooks returns the client hooks.
  1225. func (c *MessageClient) Hooks() []Hook {
  1226. return c.hooks.Message
  1227. }
  1228. // Interceptors returns the client interceptors.
  1229. func (c *MessageClient) Interceptors() []Interceptor {
  1230. return c.inters.Message
  1231. }
  1232. func (c *MessageClient) mutate(ctx context.Context, m *MessageMutation) (Value, error) {
  1233. switch m.Op() {
  1234. case OpCreate:
  1235. return (&MessageCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1236. case OpUpdate:
  1237. return (&MessageUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1238. case OpUpdateOne:
  1239. return (&MessageUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1240. case OpDelete, OpDeleteOne:
  1241. return (&MessageDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  1242. default:
  1243. return nil, fmt.Errorf("ent: unknown Message mutation op: %q", m.Op())
  1244. }
  1245. }
  1246. // MessageRecordsClient is a client for the MessageRecords schema.
  1247. type MessageRecordsClient struct {
  1248. config
  1249. }
  1250. // NewMessageRecordsClient returns a client for the MessageRecords from the given config.
  1251. func NewMessageRecordsClient(c config) *MessageRecordsClient {
  1252. return &MessageRecordsClient{config: c}
  1253. }
  1254. // Use adds a list of mutation hooks to the hooks stack.
  1255. // A call to `Use(f, g, h)` equals to `messagerecords.Hooks(f(g(h())))`.
  1256. func (c *MessageRecordsClient) Use(hooks ...Hook) {
  1257. c.hooks.MessageRecords = append(c.hooks.MessageRecords, hooks...)
  1258. }
  1259. // Intercept adds a list of query interceptors to the interceptors stack.
  1260. // A call to `Intercept(f, g, h)` equals to `messagerecords.Intercept(f(g(h())))`.
  1261. func (c *MessageRecordsClient) Intercept(interceptors ...Interceptor) {
  1262. c.inters.MessageRecords = append(c.inters.MessageRecords, interceptors...)
  1263. }
  1264. // Create returns a builder for creating a MessageRecords entity.
  1265. func (c *MessageRecordsClient) Create() *MessageRecordsCreate {
  1266. mutation := newMessageRecordsMutation(c.config, OpCreate)
  1267. return &MessageRecordsCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1268. }
  1269. // CreateBulk returns a builder for creating a bulk of MessageRecords entities.
  1270. func (c *MessageRecordsClient) CreateBulk(builders ...*MessageRecordsCreate) *MessageRecordsCreateBulk {
  1271. return &MessageRecordsCreateBulk{config: c.config, builders: builders}
  1272. }
  1273. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  1274. // a builder and applies setFunc on it.
  1275. func (c *MessageRecordsClient) MapCreateBulk(slice any, setFunc func(*MessageRecordsCreate, int)) *MessageRecordsCreateBulk {
  1276. rv := reflect.ValueOf(slice)
  1277. if rv.Kind() != reflect.Slice {
  1278. return &MessageRecordsCreateBulk{err: fmt.Errorf("calling to MessageRecordsClient.MapCreateBulk with wrong type %T, need slice", slice)}
  1279. }
  1280. builders := make([]*MessageRecordsCreate, rv.Len())
  1281. for i := 0; i < rv.Len(); i++ {
  1282. builders[i] = c.Create()
  1283. setFunc(builders[i], i)
  1284. }
  1285. return &MessageRecordsCreateBulk{config: c.config, builders: builders}
  1286. }
  1287. // Update returns an update builder for MessageRecords.
  1288. func (c *MessageRecordsClient) Update() *MessageRecordsUpdate {
  1289. mutation := newMessageRecordsMutation(c.config, OpUpdate)
  1290. return &MessageRecordsUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1291. }
  1292. // UpdateOne returns an update builder for the given entity.
  1293. func (c *MessageRecordsClient) UpdateOne(mr *MessageRecords) *MessageRecordsUpdateOne {
  1294. mutation := newMessageRecordsMutation(c.config, OpUpdateOne, withMessageRecords(mr))
  1295. return &MessageRecordsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1296. }
  1297. // UpdateOneID returns an update builder for the given id.
  1298. func (c *MessageRecordsClient) UpdateOneID(id uint64) *MessageRecordsUpdateOne {
  1299. mutation := newMessageRecordsMutation(c.config, OpUpdateOne, withMessageRecordsID(id))
  1300. return &MessageRecordsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1301. }
  1302. // Delete returns a delete builder for MessageRecords.
  1303. func (c *MessageRecordsClient) Delete() *MessageRecordsDelete {
  1304. mutation := newMessageRecordsMutation(c.config, OpDelete)
  1305. return &MessageRecordsDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1306. }
  1307. // DeleteOne returns a builder for deleting the given entity.
  1308. func (c *MessageRecordsClient) DeleteOne(mr *MessageRecords) *MessageRecordsDeleteOne {
  1309. return c.DeleteOneID(mr.ID)
  1310. }
  1311. // DeleteOneID returns a builder for deleting the given entity by its id.
  1312. func (c *MessageRecordsClient) DeleteOneID(id uint64) *MessageRecordsDeleteOne {
  1313. builder := c.Delete().Where(messagerecords.ID(id))
  1314. builder.mutation.id = &id
  1315. builder.mutation.op = OpDeleteOne
  1316. return &MessageRecordsDeleteOne{builder}
  1317. }
  1318. // Query returns a query builder for MessageRecords.
  1319. func (c *MessageRecordsClient) Query() *MessageRecordsQuery {
  1320. return &MessageRecordsQuery{
  1321. config: c.config,
  1322. ctx: &QueryContext{Type: TypeMessageRecords},
  1323. inters: c.Interceptors(),
  1324. }
  1325. }
  1326. // Get returns a MessageRecords entity by its id.
  1327. func (c *MessageRecordsClient) Get(ctx context.Context, id uint64) (*MessageRecords, error) {
  1328. return c.Query().Where(messagerecords.ID(id)).Only(ctx)
  1329. }
  1330. // GetX is like Get, but panics if an error occurs.
  1331. func (c *MessageRecordsClient) GetX(ctx context.Context, id uint64) *MessageRecords {
  1332. obj, err := c.Get(ctx, id)
  1333. if err != nil {
  1334. panic(err)
  1335. }
  1336. return obj
  1337. }
  1338. // QuerySopStage queries the sop_stage edge of a MessageRecords.
  1339. func (c *MessageRecordsClient) QuerySopStage(mr *MessageRecords) *SopStageQuery {
  1340. query := (&SopStageClient{config: c.config}).Query()
  1341. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  1342. id := mr.ID
  1343. step := sqlgraph.NewStep(
  1344. sqlgraph.From(messagerecords.Table, messagerecords.FieldID, id),
  1345. sqlgraph.To(sopstage.Table, sopstage.FieldID),
  1346. sqlgraph.Edge(sqlgraph.M2O, true, messagerecords.SopStageTable, messagerecords.SopStageColumn),
  1347. )
  1348. fromV = sqlgraph.Neighbors(mr.driver.Dialect(), step)
  1349. return fromV, nil
  1350. }
  1351. return query
  1352. }
  1353. // QuerySopNode queries the sop_node edge of a MessageRecords.
  1354. func (c *MessageRecordsClient) QuerySopNode(mr *MessageRecords) *SopNodeQuery {
  1355. query := (&SopNodeClient{config: c.config}).Query()
  1356. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  1357. id := mr.ID
  1358. step := sqlgraph.NewStep(
  1359. sqlgraph.From(messagerecords.Table, messagerecords.FieldID, id),
  1360. sqlgraph.To(sopnode.Table, sopnode.FieldID),
  1361. sqlgraph.Edge(sqlgraph.M2O, true, messagerecords.SopNodeTable, messagerecords.SopNodeColumn),
  1362. )
  1363. fromV = sqlgraph.Neighbors(mr.driver.Dialect(), step)
  1364. return fromV, nil
  1365. }
  1366. return query
  1367. }
  1368. // QueryMessageContact queries the message_contact edge of a MessageRecords.
  1369. func (c *MessageRecordsClient) QueryMessageContact(mr *MessageRecords) *ContactQuery {
  1370. query := (&ContactClient{config: c.config}).Query()
  1371. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  1372. id := mr.ID
  1373. step := sqlgraph.NewStep(
  1374. sqlgraph.From(messagerecords.Table, messagerecords.FieldID, id),
  1375. sqlgraph.To(contact.Table, contact.FieldID),
  1376. sqlgraph.Edge(sqlgraph.M2O, true, messagerecords.MessageContactTable, messagerecords.MessageContactColumn),
  1377. )
  1378. fromV = sqlgraph.Neighbors(mr.driver.Dialect(), step)
  1379. return fromV, nil
  1380. }
  1381. return query
  1382. }
  1383. // Hooks returns the client hooks.
  1384. func (c *MessageRecordsClient) Hooks() []Hook {
  1385. hooks := c.hooks.MessageRecords
  1386. return append(hooks[:len(hooks):len(hooks)], messagerecords.Hooks[:]...)
  1387. }
  1388. // Interceptors returns the client interceptors.
  1389. func (c *MessageRecordsClient) Interceptors() []Interceptor {
  1390. inters := c.inters.MessageRecords
  1391. return append(inters[:len(inters):len(inters)], messagerecords.Interceptors[:]...)
  1392. }
  1393. func (c *MessageRecordsClient) mutate(ctx context.Context, m *MessageRecordsMutation) (Value, error) {
  1394. switch m.Op() {
  1395. case OpCreate:
  1396. return (&MessageRecordsCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1397. case OpUpdate:
  1398. return (&MessageRecordsUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1399. case OpUpdateOne:
  1400. return (&MessageRecordsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1401. case OpDelete, OpDeleteOne:
  1402. return (&MessageRecordsDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  1403. default:
  1404. return nil, fmt.Errorf("ent: unknown MessageRecords mutation op: %q", m.Op())
  1405. }
  1406. }
  1407. // MsgClient is a client for the Msg schema.
  1408. type MsgClient struct {
  1409. config
  1410. }
  1411. // NewMsgClient returns a client for the Msg from the given config.
  1412. func NewMsgClient(c config) *MsgClient {
  1413. return &MsgClient{config: c}
  1414. }
  1415. // Use adds a list of mutation hooks to the hooks stack.
  1416. // A call to `Use(f, g, h)` equals to `msg.Hooks(f(g(h())))`.
  1417. func (c *MsgClient) Use(hooks ...Hook) {
  1418. c.hooks.Msg = append(c.hooks.Msg, hooks...)
  1419. }
  1420. // Intercept adds a list of query interceptors to the interceptors stack.
  1421. // A call to `Intercept(f, g, h)` equals to `msg.Intercept(f(g(h())))`.
  1422. func (c *MsgClient) Intercept(interceptors ...Interceptor) {
  1423. c.inters.Msg = append(c.inters.Msg, interceptors...)
  1424. }
  1425. // Create returns a builder for creating a Msg entity.
  1426. func (c *MsgClient) Create() *MsgCreate {
  1427. mutation := newMsgMutation(c.config, OpCreate)
  1428. return &MsgCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1429. }
  1430. // CreateBulk returns a builder for creating a bulk of Msg entities.
  1431. func (c *MsgClient) CreateBulk(builders ...*MsgCreate) *MsgCreateBulk {
  1432. return &MsgCreateBulk{config: c.config, builders: builders}
  1433. }
  1434. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  1435. // a builder and applies setFunc on it.
  1436. func (c *MsgClient) MapCreateBulk(slice any, setFunc func(*MsgCreate, int)) *MsgCreateBulk {
  1437. rv := reflect.ValueOf(slice)
  1438. if rv.Kind() != reflect.Slice {
  1439. return &MsgCreateBulk{err: fmt.Errorf("calling to MsgClient.MapCreateBulk with wrong type %T, need slice", slice)}
  1440. }
  1441. builders := make([]*MsgCreate, rv.Len())
  1442. for i := 0; i < rv.Len(); i++ {
  1443. builders[i] = c.Create()
  1444. setFunc(builders[i], i)
  1445. }
  1446. return &MsgCreateBulk{config: c.config, builders: builders}
  1447. }
  1448. // Update returns an update builder for Msg.
  1449. func (c *MsgClient) Update() *MsgUpdate {
  1450. mutation := newMsgMutation(c.config, OpUpdate)
  1451. return &MsgUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1452. }
  1453. // UpdateOne returns an update builder for the given entity.
  1454. func (c *MsgClient) UpdateOne(m *Msg) *MsgUpdateOne {
  1455. mutation := newMsgMutation(c.config, OpUpdateOne, withMsg(m))
  1456. return &MsgUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1457. }
  1458. // UpdateOneID returns an update builder for the given id.
  1459. func (c *MsgClient) UpdateOneID(id uint64) *MsgUpdateOne {
  1460. mutation := newMsgMutation(c.config, OpUpdateOne, withMsgID(id))
  1461. return &MsgUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1462. }
  1463. // Delete returns a delete builder for Msg.
  1464. func (c *MsgClient) Delete() *MsgDelete {
  1465. mutation := newMsgMutation(c.config, OpDelete)
  1466. return &MsgDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1467. }
  1468. // DeleteOne returns a builder for deleting the given entity.
  1469. func (c *MsgClient) DeleteOne(m *Msg) *MsgDeleteOne {
  1470. return c.DeleteOneID(m.ID)
  1471. }
  1472. // DeleteOneID returns a builder for deleting the given entity by its id.
  1473. func (c *MsgClient) DeleteOneID(id uint64) *MsgDeleteOne {
  1474. builder := c.Delete().Where(msg.ID(id))
  1475. builder.mutation.id = &id
  1476. builder.mutation.op = OpDeleteOne
  1477. return &MsgDeleteOne{builder}
  1478. }
  1479. // Query returns a query builder for Msg.
  1480. func (c *MsgClient) Query() *MsgQuery {
  1481. return &MsgQuery{
  1482. config: c.config,
  1483. ctx: &QueryContext{Type: TypeMsg},
  1484. inters: c.Interceptors(),
  1485. }
  1486. }
  1487. // Get returns a Msg entity by its id.
  1488. func (c *MsgClient) Get(ctx context.Context, id uint64) (*Msg, error) {
  1489. return c.Query().Where(msg.ID(id)).Only(ctx)
  1490. }
  1491. // GetX is like Get, but panics if an error occurs.
  1492. func (c *MsgClient) GetX(ctx context.Context, id uint64) *Msg {
  1493. obj, err := c.Get(ctx, id)
  1494. if err != nil {
  1495. panic(err)
  1496. }
  1497. return obj
  1498. }
  1499. // Hooks returns the client hooks.
  1500. func (c *MsgClient) Hooks() []Hook {
  1501. hooks := c.hooks.Msg
  1502. return append(hooks[:len(hooks):len(hooks)], msg.Hooks[:]...)
  1503. }
  1504. // Interceptors returns the client interceptors.
  1505. func (c *MsgClient) Interceptors() []Interceptor {
  1506. inters := c.inters.Msg
  1507. return append(inters[:len(inters):len(inters)], msg.Interceptors[:]...)
  1508. }
  1509. func (c *MsgClient) mutate(ctx context.Context, m *MsgMutation) (Value, error) {
  1510. switch m.Op() {
  1511. case OpCreate:
  1512. return (&MsgCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1513. case OpUpdate:
  1514. return (&MsgUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1515. case OpUpdateOne:
  1516. return (&MsgUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1517. case OpDelete, OpDeleteOne:
  1518. return (&MsgDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  1519. default:
  1520. return nil, fmt.Errorf("ent: unknown Msg mutation op: %q", m.Op())
  1521. }
  1522. }
  1523. // ServerClient is a client for the Server schema.
  1524. type ServerClient struct {
  1525. config
  1526. }
  1527. // NewServerClient returns a client for the Server from the given config.
  1528. func NewServerClient(c config) *ServerClient {
  1529. return &ServerClient{config: c}
  1530. }
  1531. // Use adds a list of mutation hooks to the hooks stack.
  1532. // A call to `Use(f, g, h)` equals to `server.Hooks(f(g(h())))`.
  1533. func (c *ServerClient) Use(hooks ...Hook) {
  1534. c.hooks.Server = append(c.hooks.Server, hooks...)
  1535. }
  1536. // Intercept adds a list of query interceptors to the interceptors stack.
  1537. // A call to `Intercept(f, g, h)` equals to `server.Intercept(f(g(h())))`.
  1538. func (c *ServerClient) Intercept(interceptors ...Interceptor) {
  1539. c.inters.Server = append(c.inters.Server, interceptors...)
  1540. }
  1541. // Create returns a builder for creating a Server entity.
  1542. func (c *ServerClient) Create() *ServerCreate {
  1543. mutation := newServerMutation(c.config, OpCreate)
  1544. return &ServerCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1545. }
  1546. // CreateBulk returns a builder for creating a bulk of Server entities.
  1547. func (c *ServerClient) CreateBulk(builders ...*ServerCreate) *ServerCreateBulk {
  1548. return &ServerCreateBulk{config: c.config, builders: builders}
  1549. }
  1550. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  1551. // a builder and applies setFunc on it.
  1552. func (c *ServerClient) MapCreateBulk(slice any, setFunc func(*ServerCreate, int)) *ServerCreateBulk {
  1553. rv := reflect.ValueOf(slice)
  1554. if rv.Kind() != reflect.Slice {
  1555. return &ServerCreateBulk{err: fmt.Errorf("calling to ServerClient.MapCreateBulk with wrong type %T, need slice", slice)}
  1556. }
  1557. builders := make([]*ServerCreate, rv.Len())
  1558. for i := 0; i < rv.Len(); i++ {
  1559. builders[i] = c.Create()
  1560. setFunc(builders[i], i)
  1561. }
  1562. return &ServerCreateBulk{config: c.config, builders: builders}
  1563. }
  1564. // Update returns an update builder for Server.
  1565. func (c *ServerClient) Update() *ServerUpdate {
  1566. mutation := newServerMutation(c.config, OpUpdate)
  1567. return &ServerUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1568. }
  1569. // UpdateOne returns an update builder for the given entity.
  1570. func (c *ServerClient) UpdateOne(s *Server) *ServerUpdateOne {
  1571. mutation := newServerMutation(c.config, OpUpdateOne, withServer(s))
  1572. return &ServerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1573. }
  1574. // UpdateOneID returns an update builder for the given id.
  1575. func (c *ServerClient) UpdateOneID(id uint64) *ServerUpdateOne {
  1576. mutation := newServerMutation(c.config, OpUpdateOne, withServerID(id))
  1577. return &ServerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1578. }
  1579. // Delete returns a delete builder for Server.
  1580. func (c *ServerClient) Delete() *ServerDelete {
  1581. mutation := newServerMutation(c.config, OpDelete)
  1582. return &ServerDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1583. }
  1584. // DeleteOne returns a builder for deleting the given entity.
  1585. func (c *ServerClient) DeleteOne(s *Server) *ServerDeleteOne {
  1586. return c.DeleteOneID(s.ID)
  1587. }
  1588. // DeleteOneID returns a builder for deleting the given entity by its id.
  1589. func (c *ServerClient) DeleteOneID(id uint64) *ServerDeleteOne {
  1590. builder := c.Delete().Where(server.ID(id))
  1591. builder.mutation.id = &id
  1592. builder.mutation.op = OpDeleteOne
  1593. return &ServerDeleteOne{builder}
  1594. }
  1595. // Query returns a query builder for Server.
  1596. func (c *ServerClient) Query() *ServerQuery {
  1597. return &ServerQuery{
  1598. config: c.config,
  1599. ctx: &QueryContext{Type: TypeServer},
  1600. inters: c.Interceptors(),
  1601. }
  1602. }
  1603. // Get returns a Server entity by its id.
  1604. func (c *ServerClient) Get(ctx context.Context, id uint64) (*Server, error) {
  1605. return c.Query().Where(server.ID(id)).Only(ctx)
  1606. }
  1607. // GetX is like Get, but panics if an error occurs.
  1608. func (c *ServerClient) GetX(ctx context.Context, id uint64) *Server {
  1609. obj, err := c.Get(ctx, id)
  1610. if err != nil {
  1611. panic(err)
  1612. }
  1613. return obj
  1614. }
  1615. // QueryWxs queries the wxs edge of a Server.
  1616. func (c *ServerClient) QueryWxs(s *Server) *WxQuery {
  1617. query := (&WxClient{config: c.config}).Query()
  1618. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  1619. id := s.ID
  1620. step := sqlgraph.NewStep(
  1621. sqlgraph.From(server.Table, server.FieldID, id),
  1622. sqlgraph.To(wx.Table, wx.FieldID),
  1623. sqlgraph.Edge(sqlgraph.O2M, false, server.WxsTable, server.WxsColumn),
  1624. )
  1625. fromV = sqlgraph.Neighbors(s.driver.Dialect(), step)
  1626. return fromV, nil
  1627. }
  1628. return query
  1629. }
  1630. // Hooks returns the client hooks.
  1631. func (c *ServerClient) Hooks() []Hook {
  1632. hooks := c.hooks.Server
  1633. return append(hooks[:len(hooks):len(hooks)], server.Hooks[:]...)
  1634. }
  1635. // Interceptors returns the client interceptors.
  1636. func (c *ServerClient) Interceptors() []Interceptor {
  1637. inters := c.inters.Server
  1638. return append(inters[:len(inters):len(inters)], server.Interceptors[:]...)
  1639. }
  1640. func (c *ServerClient) mutate(ctx context.Context, m *ServerMutation) (Value, error) {
  1641. switch m.Op() {
  1642. case OpCreate:
  1643. return (&ServerCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1644. case OpUpdate:
  1645. return (&ServerUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1646. case OpUpdateOne:
  1647. return (&ServerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1648. case OpDelete, OpDeleteOne:
  1649. return (&ServerDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  1650. default:
  1651. return nil, fmt.Errorf("ent: unknown Server mutation op: %q", m.Op())
  1652. }
  1653. }
  1654. // SopNodeClient is a client for the SopNode schema.
  1655. type SopNodeClient struct {
  1656. config
  1657. }
  1658. // NewSopNodeClient returns a client for the SopNode from the given config.
  1659. func NewSopNodeClient(c config) *SopNodeClient {
  1660. return &SopNodeClient{config: c}
  1661. }
  1662. // Use adds a list of mutation hooks to the hooks stack.
  1663. // A call to `Use(f, g, h)` equals to `sopnode.Hooks(f(g(h())))`.
  1664. func (c *SopNodeClient) Use(hooks ...Hook) {
  1665. c.hooks.SopNode = append(c.hooks.SopNode, hooks...)
  1666. }
  1667. // Intercept adds a list of query interceptors to the interceptors stack.
  1668. // A call to `Intercept(f, g, h)` equals to `sopnode.Intercept(f(g(h())))`.
  1669. func (c *SopNodeClient) Intercept(interceptors ...Interceptor) {
  1670. c.inters.SopNode = append(c.inters.SopNode, interceptors...)
  1671. }
  1672. // Create returns a builder for creating a SopNode entity.
  1673. func (c *SopNodeClient) Create() *SopNodeCreate {
  1674. mutation := newSopNodeMutation(c.config, OpCreate)
  1675. return &SopNodeCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1676. }
  1677. // CreateBulk returns a builder for creating a bulk of SopNode entities.
  1678. func (c *SopNodeClient) CreateBulk(builders ...*SopNodeCreate) *SopNodeCreateBulk {
  1679. return &SopNodeCreateBulk{config: c.config, builders: builders}
  1680. }
  1681. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  1682. // a builder and applies setFunc on it.
  1683. func (c *SopNodeClient) MapCreateBulk(slice any, setFunc func(*SopNodeCreate, int)) *SopNodeCreateBulk {
  1684. rv := reflect.ValueOf(slice)
  1685. if rv.Kind() != reflect.Slice {
  1686. return &SopNodeCreateBulk{err: fmt.Errorf("calling to SopNodeClient.MapCreateBulk with wrong type %T, need slice", slice)}
  1687. }
  1688. builders := make([]*SopNodeCreate, rv.Len())
  1689. for i := 0; i < rv.Len(); i++ {
  1690. builders[i] = c.Create()
  1691. setFunc(builders[i], i)
  1692. }
  1693. return &SopNodeCreateBulk{config: c.config, builders: builders}
  1694. }
  1695. // Update returns an update builder for SopNode.
  1696. func (c *SopNodeClient) Update() *SopNodeUpdate {
  1697. mutation := newSopNodeMutation(c.config, OpUpdate)
  1698. return &SopNodeUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1699. }
  1700. // UpdateOne returns an update builder for the given entity.
  1701. func (c *SopNodeClient) UpdateOne(sn *SopNode) *SopNodeUpdateOne {
  1702. mutation := newSopNodeMutation(c.config, OpUpdateOne, withSopNode(sn))
  1703. return &SopNodeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1704. }
  1705. // UpdateOneID returns an update builder for the given id.
  1706. func (c *SopNodeClient) UpdateOneID(id uint64) *SopNodeUpdateOne {
  1707. mutation := newSopNodeMutation(c.config, OpUpdateOne, withSopNodeID(id))
  1708. return &SopNodeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1709. }
  1710. // Delete returns a delete builder for SopNode.
  1711. func (c *SopNodeClient) Delete() *SopNodeDelete {
  1712. mutation := newSopNodeMutation(c.config, OpDelete)
  1713. return &SopNodeDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1714. }
  1715. // DeleteOne returns a builder for deleting the given entity.
  1716. func (c *SopNodeClient) DeleteOne(sn *SopNode) *SopNodeDeleteOne {
  1717. return c.DeleteOneID(sn.ID)
  1718. }
  1719. // DeleteOneID returns a builder for deleting the given entity by its id.
  1720. func (c *SopNodeClient) DeleteOneID(id uint64) *SopNodeDeleteOne {
  1721. builder := c.Delete().Where(sopnode.ID(id))
  1722. builder.mutation.id = &id
  1723. builder.mutation.op = OpDeleteOne
  1724. return &SopNodeDeleteOne{builder}
  1725. }
  1726. // Query returns a query builder for SopNode.
  1727. func (c *SopNodeClient) Query() *SopNodeQuery {
  1728. return &SopNodeQuery{
  1729. config: c.config,
  1730. ctx: &QueryContext{Type: TypeSopNode},
  1731. inters: c.Interceptors(),
  1732. }
  1733. }
  1734. // Get returns a SopNode entity by its id.
  1735. func (c *SopNodeClient) Get(ctx context.Context, id uint64) (*SopNode, error) {
  1736. return c.Query().Where(sopnode.ID(id)).Only(ctx)
  1737. }
  1738. // GetX is like Get, but panics if an error occurs.
  1739. func (c *SopNodeClient) GetX(ctx context.Context, id uint64) *SopNode {
  1740. obj, err := c.Get(ctx, id)
  1741. if err != nil {
  1742. panic(err)
  1743. }
  1744. return obj
  1745. }
  1746. // QuerySopStage queries the sop_stage edge of a SopNode.
  1747. func (c *SopNodeClient) QuerySopStage(sn *SopNode) *SopStageQuery {
  1748. query := (&SopStageClient{config: c.config}).Query()
  1749. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  1750. id := sn.ID
  1751. step := sqlgraph.NewStep(
  1752. sqlgraph.From(sopnode.Table, sopnode.FieldID, id),
  1753. sqlgraph.To(sopstage.Table, sopstage.FieldID),
  1754. sqlgraph.Edge(sqlgraph.M2O, true, sopnode.SopStageTable, sopnode.SopStageColumn),
  1755. )
  1756. fromV = sqlgraph.Neighbors(sn.driver.Dialect(), step)
  1757. return fromV, nil
  1758. }
  1759. return query
  1760. }
  1761. // QueryNodeMessages queries the node_messages edge of a SopNode.
  1762. func (c *SopNodeClient) QueryNodeMessages(sn *SopNode) *MessageRecordsQuery {
  1763. query := (&MessageRecordsClient{config: c.config}).Query()
  1764. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  1765. id := sn.ID
  1766. step := sqlgraph.NewStep(
  1767. sqlgraph.From(sopnode.Table, sopnode.FieldID, id),
  1768. sqlgraph.To(messagerecords.Table, messagerecords.FieldID),
  1769. sqlgraph.Edge(sqlgraph.O2M, false, sopnode.NodeMessagesTable, sopnode.NodeMessagesColumn),
  1770. )
  1771. fromV = sqlgraph.Neighbors(sn.driver.Dialect(), step)
  1772. return fromV, nil
  1773. }
  1774. return query
  1775. }
  1776. // Hooks returns the client hooks.
  1777. func (c *SopNodeClient) Hooks() []Hook {
  1778. hooks := c.hooks.SopNode
  1779. return append(hooks[:len(hooks):len(hooks)], sopnode.Hooks[:]...)
  1780. }
  1781. // Interceptors returns the client interceptors.
  1782. func (c *SopNodeClient) Interceptors() []Interceptor {
  1783. inters := c.inters.SopNode
  1784. return append(inters[:len(inters):len(inters)], sopnode.Interceptors[:]...)
  1785. }
  1786. func (c *SopNodeClient) mutate(ctx context.Context, m *SopNodeMutation) (Value, error) {
  1787. switch m.Op() {
  1788. case OpCreate:
  1789. return (&SopNodeCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1790. case OpUpdate:
  1791. return (&SopNodeUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1792. case OpUpdateOne:
  1793. return (&SopNodeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1794. case OpDelete, OpDeleteOne:
  1795. return (&SopNodeDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  1796. default:
  1797. return nil, fmt.Errorf("ent: unknown SopNode mutation op: %q", m.Op())
  1798. }
  1799. }
  1800. // SopStageClient is a client for the SopStage schema.
  1801. type SopStageClient struct {
  1802. config
  1803. }
  1804. // NewSopStageClient returns a client for the SopStage from the given config.
  1805. func NewSopStageClient(c config) *SopStageClient {
  1806. return &SopStageClient{config: c}
  1807. }
  1808. // Use adds a list of mutation hooks to the hooks stack.
  1809. // A call to `Use(f, g, h)` equals to `sopstage.Hooks(f(g(h())))`.
  1810. func (c *SopStageClient) Use(hooks ...Hook) {
  1811. c.hooks.SopStage = append(c.hooks.SopStage, hooks...)
  1812. }
  1813. // Intercept adds a list of query interceptors to the interceptors stack.
  1814. // A call to `Intercept(f, g, h)` equals to `sopstage.Intercept(f(g(h())))`.
  1815. func (c *SopStageClient) Intercept(interceptors ...Interceptor) {
  1816. c.inters.SopStage = append(c.inters.SopStage, interceptors...)
  1817. }
  1818. // Create returns a builder for creating a SopStage entity.
  1819. func (c *SopStageClient) Create() *SopStageCreate {
  1820. mutation := newSopStageMutation(c.config, OpCreate)
  1821. return &SopStageCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1822. }
  1823. // CreateBulk returns a builder for creating a bulk of SopStage entities.
  1824. func (c *SopStageClient) CreateBulk(builders ...*SopStageCreate) *SopStageCreateBulk {
  1825. return &SopStageCreateBulk{config: c.config, builders: builders}
  1826. }
  1827. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  1828. // a builder and applies setFunc on it.
  1829. func (c *SopStageClient) MapCreateBulk(slice any, setFunc func(*SopStageCreate, int)) *SopStageCreateBulk {
  1830. rv := reflect.ValueOf(slice)
  1831. if rv.Kind() != reflect.Slice {
  1832. return &SopStageCreateBulk{err: fmt.Errorf("calling to SopStageClient.MapCreateBulk with wrong type %T, need slice", slice)}
  1833. }
  1834. builders := make([]*SopStageCreate, rv.Len())
  1835. for i := 0; i < rv.Len(); i++ {
  1836. builders[i] = c.Create()
  1837. setFunc(builders[i], i)
  1838. }
  1839. return &SopStageCreateBulk{config: c.config, builders: builders}
  1840. }
  1841. // Update returns an update builder for SopStage.
  1842. func (c *SopStageClient) Update() *SopStageUpdate {
  1843. mutation := newSopStageMutation(c.config, OpUpdate)
  1844. return &SopStageUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1845. }
  1846. // UpdateOne returns an update builder for the given entity.
  1847. func (c *SopStageClient) UpdateOne(ss *SopStage) *SopStageUpdateOne {
  1848. mutation := newSopStageMutation(c.config, OpUpdateOne, withSopStage(ss))
  1849. return &SopStageUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1850. }
  1851. // UpdateOneID returns an update builder for the given id.
  1852. func (c *SopStageClient) UpdateOneID(id uint64) *SopStageUpdateOne {
  1853. mutation := newSopStageMutation(c.config, OpUpdateOne, withSopStageID(id))
  1854. return &SopStageUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1855. }
  1856. // Delete returns a delete builder for SopStage.
  1857. func (c *SopStageClient) Delete() *SopStageDelete {
  1858. mutation := newSopStageMutation(c.config, OpDelete)
  1859. return &SopStageDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1860. }
  1861. // DeleteOne returns a builder for deleting the given entity.
  1862. func (c *SopStageClient) DeleteOne(ss *SopStage) *SopStageDeleteOne {
  1863. return c.DeleteOneID(ss.ID)
  1864. }
  1865. // DeleteOneID returns a builder for deleting the given entity by its id.
  1866. func (c *SopStageClient) DeleteOneID(id uint64) *SopStageDeleteOne {
  1867. builder := c.Delete().Where(sopstage.ID(id))
  1868. builder.mutation.id = &id
  1869. builder.mutation.op = OpDeleteOne
  1870. return &SopStageDeleteOne{builder}
  1871. }
  1872. // Query returns a query builder for SopStage.
  1873. func (c *SopStageClient) Query() *SopStageQuery {
  1874. return &SopStageQuery{
  1875. config: c.config,
  1876. ctx: &QueryContext{Type: TypeSopStage},
  1877. inters: c.Interceptors(),
  1878. }
  1879. }
  1880. // Get returns a SopStage entity by its id.
  1881. func (c *SopStageClient) Get(ctx context.Context, id uint64) (*SopStage, error) {
  1882. return c.Query().Where(sopstage.ID(id)).Only(ctx)
  1883. }
  1884. // GetX is like Get, but panics if an error occurs.
  1885. func (c *SopStageClient) GetX(ctx context.Context, id uint64) *SopStage {
  1886. obj, err := c.Get(ctx, id)
  1887. if err != nil {
  1888. panic(err)
  1889. }
  1890. return obj
  1891. }
  1892. // QuerySopTask queries the sop_task edge of a SopStage.
  1893. func (c *SopStageClient) QuerySopTask(ss *SopStage) *SopTaskQuery {
  1894. query := (&SopTaskClient{config: c.config}).Query()
  1895. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  1896. id := ss.ID
  1897. step := sqlgraph.NewStep(
  1898. sqlgraph.From(sopstage.Table, sopstage.FieldID, id),
  1899. sqlgraph.To(soptask.Table, soptask.FieldID),
  1900. sqlgraph.Edge(sqlgraph.M2O, true, sopstage.SopTaskTable, sopstage.SopTaskColumn),
  1901. )
  1902. fromV = sqlgraph.Neighbors(ss.driver.Dialect(), step)
  1903. return fromV, nil
  1904. }
  1905. return query
  1906. }
  1907. // QueryStageNodes queries the stage_nodes edge of a SopStage.
  1908. func (c *SopStageClient) QueryStageNodes(ss *SopStage) *SopNodeQuery {
  1909. query := (&SopNodeClient{config: c.config}).Query()
  1910. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  1911. id := ss.ID
  1912. step := sqlgraph.NewStep(
  1913. sqlgraph.From(sopstage.Table, sopstage.FieldID, id),
  1914. sqlgraph.To(sopnode.Table, sopnode.FieldID),
  1915. sqlgraph.Edge(sqlgraph.O2M, false, sopstage.StageNodesTable, sopstage.StageNodesColumn),
  1916. )
  1917. fromV = sqlgraph.Neighbors(ss.driver.Dialect(), step)
  1918. return fromV, nil
  1919. }
  1920. return query
  1921. }
  1922. // QueryStageMessages queries the stage_messages edge of a SopStage.
  1923. func (c *SopStageClient) QueryStageMessages(ss *SopStage) *MessageRecordsQuery {
  1924. query := (&MessageRecordsClient{config: c.config}).Query()
  1925. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  1926. id := ss.ID
  1927. step := sqlgraph.NewStep(
  1928. sqlgraph.From(sopstage.Table, sopstage.FieldID, id),
  1929. sqlgraph.To(messagerecords.Table, messagerecords.FieldID),
  1930. sqlgraph.Edge(sqlgraph.O2M, false, sopstage.StageMessagesTable, sopstage.StageMessagesColumn),
  1931. )
  1932. fromV = sqlgraph.Neighbors(ss.driver.Dialect(), step)
  1933. return fromV, nil
  1934. }
  1935. return query
  1936. }
  1937. // Hooks returns the client hooks.
  1938. func (c *SopStageClient) Hooks() []Hook {
  1939. hooks := c.hooks.SopStage
  1940. return append(hooks[:len(hooks):len(hooks)], sopstage.Hooks[:]...)
  1941. }
  1942. // Interceptors returns the client interceptors.
  1943. func (c *SopStageClient) Interceptors() []Interceptor {
  1944. inters := c.inters.SopStage
  1945. return append(inters[:len(inters):len(inters)], sopstage.Interceptors[:]...)
  1946. }
  1947. func (c *SopStageClient) mutate(ctx context.Context, m *SopStageMutation) (Value, error) {
  1948. switch m.Op() {
  1949. case OpCreate:
  1950. return (&SopStageCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1951. case OpUpdate:
  1952. return (&SopStageUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1953. case OpUpdateOne:
  1954. return (&SopStageUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1955. case OpDelete, OpDeleteOne:
  1956. return (&SopStageDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  1957. default:
  1958. return nil, fmt.Errorf("ent: unknown SopStage mutation op: %q", m.Op())
  1959. }
  1960. }
  1961. // SopTaskClient is a client for the SopTask schema.
  1962. type SopTaskClient struct {
  1963. config
  1964. }
  1965. // NewSopTaskClient returns a client for the SopTask from the given config.
  1966. func NewSopTaskClient(c config) *SopTaskClient {
  1967. return &SopTaskClient{config: c}
  1968. }
  1969. // Use adds a list of mutation hooks to the hooks stack.
  1970. // A call to `Use(f, g, h)` equals to `soptask.Hooks(f(g(h())))`.
  1971. func (c *SopTaskClient) Use(hooks ...Hook) {
  1972. c.hooks.SopTask = append(c.hooks.SopTask, hooks...)
  1973. }
  1974. // Intercept adds a list of query interceptors to the interceptors stack.
  1975. // A call to `Intercept(f, g, h)` equals to `soptask.Intercept(f(g(h())))`.
  1976. func (c *SopTaskClient) Intercept(interceptors ...Interceptor) {
  1977. c.inters.SopTask = append(c.inters.SopTask, interceptors...)
  1978. }
  1979. // Create returns a builder for creating a SopTask entity.
  1980. func (c *SopTaskClient) Create() *SopTaskCreate {
  1981. mutation := newSopTaskMutation(c.config, OpCreate)
  1982. return &SopTaskCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1983. }
  1984. // CreateBulk returns a builder for creating a bulk of SopTask entities.
  1985. func (c *SopTaskClient) CreateBulk(builders ...*SopTaskCreate) *SopTaskCreateBulk {
  1986. return &SopTaskCreateBulk{config: c.config, builders: builders}
  1987. }
  1988. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  1989. // a builder and applies setFunc on it.
  1990. func (c *SopTaskClient) MapCreateBulk(slice any, setFunc func(*SopTaskCreate, int)) *SopTaskCreateBulk {
  1991. rv := reflect.ValueOf(slice)
  1992. if rv.Kind() != reflect.Slice {
  1993. return &SopTaskCreateBulk{err: fmt.Errorf("calling to SopTaskClient.MapCreateBulk with wrong type %T, need slice", slice)}
  1994. }
  1995. builders := make([]*SopTaskCreate, rv.Len())
  1996. for i := 0; i < rv.Len(); i++ {
  1997. builders[i] = c.Create()
  1998. setFunc(builders[i], i)
  1999. }
  2000. return &SopTaskCreateBulk{config: c.config, builders: builders}
  2001. }
  2002. // Update returns an update builder for SopTask.
  2003. func (c *SopTaskClient) Update() *SopTaskUpdate {
  2004. mutation := newSopTaskMutation(c.config, OpUpdate)
  2005. return &SopTaskUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2006. }
  2007. // UpdateOne returns an update builder for the given entity.
  2008. func (c *SopTaskClient) UpdateOne(st *SopTask) *SopTaskUpdateOne {
  2009. mutation := newSopTaskMutation(c.config, OpUpdateOne, withSopTask(st))
  2010. return &SopTaskUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2011. }
  2012. // UpdateOneID returns an update builder for the given id.
  2013. func (c *SopTaskClient) UpdateOneID(id uint64) *SopTaskUpdateOne {
  2014. mutation := newSopTaskMutation(c.config, OpUpdateOne, withSopTaskID(id))
  2015. return &SopTaskUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2016. }
  2017. // Delete returns a delete builder for SopTask.
  2018. func (c *SopTaskClient) Delete() *SopTaskDelete {
  2019. mutation := newSopTaskMutation(c.config, OpDelete)
  2020. return &SopTaskDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2021. }
  2022. // DeleteOne returns a builder for deleting the given entity.
  2023. func (c *SopTaskClient) DeleteOne(st *SopTask) *SopTaskDeleteOne {
  2024. return c.DeleteOneID(st.ID)
  2025. }
  2026. // DeleteOneID returns a builder for deleting the given entity by its id.
  2027. func (c *SopTaskClient) DeleteOneID(id uint64) *SopTaskDeleteOne {
  2028. builder := c.Delete().Where(soptask.ID(id))
  2029. builder.mutation.id = &id
  2030. builder.mutation.op = OpDeleteOne
  2031. return &SopTaskDeleteOne{builder}
  2032. }
  2033. // Query returns a query builder for SopTask.
  2034. func (c *SopTaskClient) Query() *SopTaskQuery {
  2035. return &SopTaskQuery{
  2036. config: c.config,
  2037. ctx: &QueryContext{Type: TypeSopTask},
  2038. inters: c.Interceptors(),
  2039. }
  2040. }
  2041. // Get returns a SopTask entity by its id.
  2042. func (c *SopTaskClient) Get(ctx context.Context, id uint64) (*SopTask, error) {
  2043. return c.Query().Where(soptask.ID(id)).Only(ctx)
  2044. }
  2045. // GetX is like Get, but panics if an error occurs.
  2046. func (c *SopTaskClient) GetX(ctx context.Context, id uint64) *SopTask {
  2047. obj, err := c.Get(ctx, id)
  2048. if err != nil {
  2049. panic(err)
  2050. }
  2051. return obj
  2052. }
  2053. // QueryTaskStages queries the task_stages edge of a SopTask.
  2054. func (c *SopTaskClient) QueryTaskStages(st *SopTask) *SopStageQuery {
  2055. query := (&SopStageClient{config: c.config}).Query()
  2056. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  2057. id := st.ID
  2058. step := sqlgraph.NewStep(
  2059. sqlgraph.From(soptask.Table, soptask.FieldID, id),
  2060. sqlgraph.To(sopstage.Table, sopstage.FieldID),
  2061. sqlgraph.Edge(sqlgraph.O2M, false, soptask.TaskStagesTable, soptask.TaskStagesColumn),
  2062. )
  2063. fromV = sqlgraph.Neighbors(st.driver.Dialect(), step)
  2064. return fromV, nil
  2065. }
  2066. return query
  2067. }
  2068. // Hooks returns the client hooks.
  2069. func (c *SopTaskClient) Hooks() []Hook {
  2070. hooks := c.hooks.SopTask
  2071. return append(hooks[:len(hooks):len(hooks)], soptask.Hooks[:]...)
  2072. }
  2073. // Interceptors returns the client interceptors.
  2074. func (c *SopTaskClient) Interceptors() []Interceptor {
  2075. inters := c.inters.SopTask
  2076. return append(inters[:len(inters):len(inters)], soptask.Interceptors[:]...)
  2077. }
  2078. func (c *SopTaskClient) mutate(ctx context.Context, m *SopTaskMutation) (Value, error) {
  2079. switch m.Op() {
  2080. case OpCreate:
  2081. return (&SopTaskCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2082. case OpUpdate:
  2083. return (&SopTaskUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2084. case OpUpdateOne:
  2085. return (&SopTaskUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2086. case OpDelete, OpDeleteOne:
  2087. return (&SopTaskDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  2088. default:
  2089. return nil, fmt.Errorf("ent: unknown SopTask mutation op: %q", m.Op())
  2090. }
  2091. }
  2092. // TokenClient is a client for the Token schema.
  2093. type TokenClient struct {
  2094. config
  2095. }
  2096. // NewTokenClient returns a client for the Token from the given config.
  2097. func NewTokenClient(c config) *TokenClient {
  2098. return &TokenClient{config: c}
  2099. }
  2100. // Use adds a list of mutation hooks to the hooks stack.
  2101. // A call to `Use(f, g, h)` equals to `token.Hooks(f(g(h())))`.
  2102. func (c *TokenClient) Use(hooks ...Hook) {
  2103. c.hooks.Token = append(c.hooks.Token, hooks...)
  2104. }
  2105. // Intercept adds a list of query interceptors to the interceptors stack.
  2106. // A call to `Intercept(f, g, h)` equals to `token.Intercept(f(g(h())))`.
  2107. func (c *TokenClient) Intercept(interceptors ...Interceptor) {
  2108. c.inters.Token = append(c.inters.Token, interceptors...)
  2109. }
  2110. // Create returns a builder for creating a Token entity.
  2111. func (c *TokenClient) Create() *TokenCreate {
  2112. mutation := newTokenMutation(c.config, OpCreate)
  2113. return &TokenCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2114. }
  2115. // CreateBulk returns a builder for creating a bulk of Token entities.
  2116. func (c *TokenClient) CreateBulk(builders ...*TokenCreate) *TokenCreateBulk {
  2117. return &TokenCreateBulk{config: c.config, builders: builders}
  2118. }
  2119. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  2120. // a builder and applies setFunc on it.
  2121. func (c *TokenClient) MapCreateBulk(slice any, setFunc func(*TokenCreate, int)) *TokenCreateBulk {
  2122. rv := reflect.ValueOf(slice)
  2123. if rv.Kind() != reflect.Slice {
  2124. return &TokenCreateBulk{err: fmt.Errorf("calling to TokenClient.MapCreateBulk with wrong type %T, need slice", slice)}
  2125. }
  2126. builders := make([]*TokenCreate, rv.Len())
  2127. for i := 0; i < rv.Len(); i++ {
  2128. builders[i] = c.Create()
  2129. setFunc(builders[i], i)
  2130. }
  2131. return &TokenCreateBulk{config: c.config, builders: builders}
  2132. }
  2133. // Update returns an update builder for Token.
  2134. func (c *TokenClient) Update() *TokenUpdate {
  2135. mutation := newTokenMutation(c.config, OpUpdate)
  2136. return &TokenUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2137. }
  2138. // UpdateOne returns an update builder for the given entity.
  2139. func (c *TokenClient) UpdateOne(t *Token) *TokenUpdateOne {
  2140. mutation := newTokenMutation(c.config, OpUpdateOne, withToken(t))
  2141. return &TokenUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2142. }
  2143. // UpdateOneID returns an update builder for the given id.
  2144. func (c *TokenClient) UpdateOneID(id uint64) *TokenUpdateOne {
  2145. mutation := newTokenMutation(c.config, OpUpdateOne, withTokenID(id))
  2146. return &TokenUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2147. }
  2148. // Delete returns a delete builder for Token.
  2149. func (c *TokenClient) Delete() *TokenDelete {
  2150. mutation := newTokenMutation(c.config, OpDelete)
  2151. return &TokenDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2152. }
  2153. // DeleteOne returns a builder for deleting the given entity.
  2154. func (c *TokenClient) DeleteOne(t *Token) *TokenDeleteOne {
  2155. return c.DeleteOneID(t.ID)
  2156. }
  2157. // DeleteOneID returns a builder for deleting the given entity by its id.
  2158. func (c *TokenClient) DeleteOneID(id uint64) *TokenDeleteOne {
  2159. builder := c.Delete().Where(token.ID(id))
  2160. builder.mutation.id = &id
  2161. builder.mutation.op = OpDeleteOne
  2162. return &TokenDeleteOne{builder}
  2163. }
  2164. // Query returns a query builder for Token.
  2165. func (c *TokenClient) Query() *TokenQuery {
  2166. return &TokenQuery{
  2167. config: c.config,
  2168. ctx: &QueryContext{Type: TypeToken},
  2169. inters: c.Interceptors(),
  2170. }
  2171. }
  2172. // Get returns a Token entity by its id.
  2173. func (c *TokenClient) Get(ctx context.Context, id uint64) (*Token, error) {
  2174. return c.Query().Where(token.ID(id)).Only(ctx)
  2175. }
  2176. // GetX is like Get, but panics if an error occurs.
  2177. func (c *TokenClient) GetX(ctx context.Context, id uint64) *Token {
  2178. obj, err := c.Get(ctx, id)
  2179. if err != nil {
  2180. panic(err)
  2181. }
  2182. return obj
  2183. }
  2184. // Hooks returns the client hooks.
  2185. func (c *TokenClient) Hooks() []Hook {
  2186. hooks := c.hooks.Token
  2187. return append(hooks[:len(hooks):len(hooks)], token.Hooks[:]...)
  2188. }
  2189. // Interceptors returns the client interceptors.
  2190. func (c *TokenClient) Interceptors() []Interceptor {
  2191. inters := c.inters.Token
  2192. return append(inters[:len(inters):len(inters)], token.Interceptors[:]...)
  2193. }
  2194. func (c *TokenClient) mutate(ctx context.Context, m *TokenMutation) (Value, error) {
  2195. switch m.Op() {
  2196. case OpCreate:
  2197. return (&TokenCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2198. case OpUpdate:
  2199. return (&TokenUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2200. case OpUpdateOne:
  2201. return (&TokenUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2202. case OpDelete, OpDeleteOne:
  2203. return (&TokenDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  2204. default:
  2205. return nil, fmt.Errorf("ent: unknown Token mutation op: %q", m.Op())
  2206. }
  2207. }
  2208. // TutorialClient is a client for the Tutorial schema.
  2209. type TutorialClient struct {
  2210. config
  2211. }
  2212. // NewTutorialClient returns a client for the Tutorial from the given config.
  2213. func NewTutorialClient(c config) *TutorialClient {
  2214. return &TutorialClient{config: c}
  2215. }
  2216. // Use adds a list of mutation hooks to the hooks stack.
  2217. // A call to `Use(f, g, h)` equals to `tutorial.Hooks(f(g(h())))`.
  2218. func (c *TutorialClient) Use(hooks ...Hook) {
  2219. c.hooks.Tutorial = append(c.hooks.Tutorial, hooks...)
  2220. }
  2221. // Intercept adds a list of query interceptors to the interceptors stack.
  2222. // A call to `Intercept(f, g, h)` equals to `tutorial.Intercept(f(g(h())))`.
  2223. func (c *TutorialClient) Intercept(interceptors ...Interceptor) {
  2224. c.inters.Tutorial = append(c.inters.Tutorial, interceptors...)
  2225. }
  2226. // Create returns a builder for creating a Tutorial entity.
  2227. func (c *TutorialClient) Create() *TutorialCreate {
  2228. mutation := newTutorialMutation(c.config, OpCreate)
  2229. return &TutorialCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2230. }
  2231. // CreateBulk returns a builder for creating a bulk of Tutorial entities.
  2232. func (c *TutorialClient) CreateBulk(builders ...*TutorialCreate) *TutorialCreateBulk {
  2233. return &TutorialCreateBulk{config: c.config, builders: builders}
  2234. }
  2235. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  2236. // a builder and applies setFunc on it.
  2237. func (c *TutorialClient) MapCreateBulk(slice any, setFunc func(*TutorialCreate, int)) *TutorialCreateBulk {
  2238. rv := reflect.ValueOf(slice)
  2239. if rv.Kind() != reflect.Slice {
  2240. return &TutorialCreateBulk{err: fmt.Errorf("calling to TutorialClient.MapCreateBulk with wrong type %T, need slice", slice)}
  2241. }
  2242. builders := make([]*TutorialCreate, rv.Len())
  2243. for i := 0; i < rv.Len(); i++ {
  2244. builders[i] = c.Create()
  2245. setFunc(builders[i], i)
  2246. }
  2247. return &TutorialCreateBulk{config: c.config, builders: builders}
  2248. }
  2249. // Update returns an update builder for Tutorial.
  2250. func (c *TutorialClient) Update() *TutorialUpdate {
  2251. mutation := newTutorialMutation(c.config, OpUpdate)
  2252. return &TutorialUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2253. }
  2254. // UpdateOne returns an update builder for the given entity.
  2255. func (c *TutorialClient) UpdateOne(t *Tutorial) *TutorialUpdateOne {
  2256. mutation := newTutorialMutation(c.config, OpUpdateOne, withTutorial(t))
  2257. return &TutorialUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2258. }
  2259. // UpdateOneID returns an update builder for the given id.
  2260. func (c *TutorialClient) UpdateOneID(id uint64) *TutorialUpdateOne {
  2261. mutation := newTutorialMutation(c.config, OpUpdateOne, withTutorialID(id))
  2262. return &TutorialUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2263. }
  2264. // Delete returns a delete builder for Tutorial.
  2265. func (c *TutorialClient) Delete() *TutorialDelete {
  2266. mutation := newTutorialMutation(c.config, OpDelete)
  2267. return &TutorialDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2268. }
  2269. // DeleteOne returns a builder for deleting the given entity.
  2270. func (c *TutorialClient) DeleteOne(t *Tutorial) *TutorialDeleteOne {
  2271. return c.DeleteOneID(t.ID)
  2272. }
  2273. // DeleteOneID returns a builder for deleting the given entity by its id.
  2274. func (c *TutorialClient) DeleteOneID(id uint64) *TutorialDeleteOne {
  2275. builder := c.Delete().Where(tutorial.ID(id))
  2276. builder.mutation.id = &id
  2277. builder.mutation.op = OpDeleteOne
  2278. return &TutorialDeleteOne{builder}
  2279. }
  2280. // Query returns a query builder for Tutorial.
  2281. func (c *TutorialClient) Query() *TutorialQuery {
  2282. return &TutorialQuery{
  2283. config: c.config,
  2284. ctx: &QueryContext{Type: TypeTutorial},
  2285. inters: c.Interceptors(),
  2286. }
  2287. }
  2288. // Get returns a Tutorial entity by its id.
  2289. func (c *TutorialClient) Get(ctx context.Context, id uint64) (*Tutorial, error) {
  2290. return c.Query().Where(tutorial.ID(id)).Only(ctx)
  2291. }
  2292. // GetX is like Get, but panics if an error occurs.
  2293. func (c *TutorialClient) GetX(ctx context.Context, id uint64) *Tutorial {
  2294. obj, err := c.Get(ctx, id)
  2295. if err != nil {
  2296. panic(err)
  2297. }
  2298. return obj
  2299. }
  2300. // QueryEmployee queries the employee edge of a Tutorial.
  2301. func (c *TutorialClient) QueryEmployee(t *Tutorial) *EmployeeQuery {
  2302. query := (&EmployeeClient{config: c.config}).Query()
  2303. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  2304. id := t.ID
  2305. step := sqlgraph.NewStep(
  2306. sqlgraph.From(tutorial.Table, tutorial.FieldID, id),
  2307. sqlgraph.To(employee.Table, employee.FieldID),
  2308. sqlgraph.Edge(sqlgraph.M2O, true, tutorial.EmployeeTable, tutorial.EmployeeColumn),
  2309. )
  2310. fromV = sqlgraph.Neighbors(t.driver.Dialect(), step)
  2311. return fromV, nil
  2312. }
  2313. return query
  2314. }
  2315. // Hooks returns the client hooks.
  2316. func (c *TutorialClient) Hooks() []Hook {
  2317. hooks := c.hooks.Tutorial
  2318. return append(hooks[:len(hooks):len(hooks)], tutorial.Hooks[:]...)
  2319. }
  2320. // Interceptors returns the client interceptors.
  2321. func (c *TutorialClient) Interceptors() []Interceptor {
  2322. inters := c.inters.Tutorial
  2323. return append(inters[:len(inters):len(inters)], tutorial.Interceptors[:]...)
  2324. }
  2325. func (c *TutorialClient) mutate(ctx context.Context, m *TutorialMutation) (Value, error) {
  2326. switch m.Op() {
  2327. case OpCreate:
  2328. return (&TutorialCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2329. case OpUpdate:
  2330. return (&TutorialUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2331. case OpUpdateOne:
  2332. return (&TutorialUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2333. case OpDelete, OpDeleteOne:
  2334. return (&TutorialDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  2335. default:
  2336. return nil, fmt.Errorf("ent: unknown Tutorial mutation op: %q", m.Op())
  2337. }
  2338. }
  2339. // WorkExperienceClient is a client for the WorkExperience schema.
  2340. type WorkExperienceClient struct {
  2341. config
  2342. }
  2343. // NewWorkExperienceClient returns a client for the WorkExperience from the given config.
  2344. func NewWorkExperienceClient(c config) *WorkExperienceClient {
  2345. return &WorkExperienceClient{config: c}
  2346. }
  2347. // Use adds a list of mutation hooks to the hooks stack.
  2348. // A call to `Use(f, g, h)` equals to `workexperience.Hooks(f(g(h())))`.
  2349. func (c *WorkExperienceClient) Use(hooks ...Hook) {
  2350. c.hooks.WorkExperience = append(c.hooks.WorkExperience, hooks...)
  2351. }
  2352. // Intercept adds a list of query interceptors to the interceptors stack.
  2353. // A call to `Intercept(f, g, h)` equals to `workexperience.Intercept(f(g(h())))`.
  2354. func (c *WorkExperienceClient) Intercept(interceptors ...Interceptor) {
  2355. c.inters.WorkExperience = append(c.inters.WorkExperience, interceptors...)
  2356. }
  2357. // Create returns a builder for creating a WorkExperience entity.
  2358. func (c *WorkExperienceClient) Create() *WorkExperienceCreate {
  2359. mutation := newWorkExperienceMutation(c.config, OpCreate)
  2360. return &WorkExperienceCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2361. }
  2362. // CreateBulk returns a builder for creating a bulk of WorkExperience entities.
  2363. func (c *WorkExperienceClient) CreateBulk(builders ...*WorkExperienceCreate) *WorkExperienceCreateBulk {
  2364. return &WorkExperienceCreateBulk{config: c.config, builders: builders}
  2365. }
  2366. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  2367. // a builder and applies setFunc on it.
  2368. func (c *WorkExperienceClient) MapCreateBulk(slice any, setFunc func(*WorkExperienceCreate, int)) *WorkExperienceCreateBulk {
  2369. rv := reflect.ValueOf(slice)
  2370. if rv.Kind() != reflect.Slice {
  2371. return &WorkExperienceCreateBulk{err: fmt.Errorf("calling to WorkExperienceClient.MapCreateBulk with wrong type %T, need slice", slice)}
  2372. }
  2373. builders := make([]*WorkExperienceCreate, rv.Len())
  2374. for i := 0; i < rv.Len(); i++ {
  2375. builders[i] = c.Create()
  2376. setFunc(builders[i], i)
  2377. }
  2378. return &WorkExperienceCreateBulk{config: c.config, builders: builders}
  2379. }
  2380. // Update returns an update builder for WorkExperience.
  2381. func (c *WorkExperienceClient) Update() *WorkExperienceUpdate {
  2382. mutation := newWorkExperienceMutation(c.config, OpUpdate)
  2383. return &WorkExperienceUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2384. }
  2385. // UpdateOne returns an update builder for the given entity.
  2386. func (c *WorkExperienceClient) UpdateOne(we *WorkExperience) *WorkExperienceUpdateOne {
  2387. mutation := newWorkExperienceMutation(c.config, OpUpdateOne, withWorkExperience(we))
  2388. return &WorkExperienceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2389. }
  2390. // UpdateOneID returns an update builder for the given id.
  2391. func (c *WorkExperienceClient) UpdateOneID(id uint64) *WorkExperienceUpdateOne {
  2392. mutation := newWorkExperienceMutation(c.config, OpUpdateOne, withWorkExperienceID(id))
  2393. return &WorkExperienceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2394. }
  2395. // Delete returns a delete builder for WorkExperience.
  2396. func (c *WorkExperienceClient) Delete() *WorkExperienceDelete {
  2397. mutation := newWorkExperienceMutation(c.config, OpDelete)
  2398. return &WorkExperienceDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2399. }
  2400. // DeleteOne returns a builder for deleting the given entity.
  2401. func (c *WorkExperienceClient) DeleteOne(we *WorkExperience) *WorkExperienceDeleteOne {
  2402. return c.DeleteOneID(we.ID)
  2403. }
  2404. // DeleteOneID returns a builder for deleting the given entity by its id.
  2405. func (c *WorkExperienceClient) DeleteOneID(id uint64) *WorkExperienceDeleteOne {
  2406. builder := c.Delete().Where(workexperience.ID(id))
  2407. builder.mutation.id = &id
  2408. builder.mutation.op = OpDeleteOne
  2409. return &WorkExperienceDeleteOne{builder}
  2410. }
  2411. // Query returns a query builder for WorkExperience.
  2412. func (c *WorkExperienceClient) Query() *WorkExperienceQuery {
  2413. return &WorkExperienceQuery{
  2414. config: c.config,
  2415. ctx: &QueryContext{Type: TypeWorkExperience},
  2416. inters: c.Interceptors(),
  2417. }
  2418. }
  2419. // Get returns a WorkExperience entity by its id.
  2420. func (c *WorkExperienceClient) Get(ctx context.Context, id uint64) (*WorkExperience, error) {
  2421. return c.Query().Where(workexperience.ID(id)).Only(ctx)
  2422. }
  2423. // GetX is like Get, but panics if an error occurs.
  2424. func (c *WorkExperienceClient) GetX(ctx context.Context, id uint64) *WorkExperience {
  2425. obj, err := c.Get(ctx, id)
  2426. if err != nil {
  2427. panic(err)
  2428. }
  2429. return obj
  2430. }
  2431. // QueryEmployee queries the employee edge of a WorkExperience.
  2432. func (c *WorkExperienceClient) QueryEmployee(we *WorkExperience) *EmployeeQuery {
  2433. query := (&EmployeeClient{config: c.config}).Query()
  2434. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  2435. id := we.ID
  2436. step := sqlgraph.NewStep(
  2437. sqlgraph.From(workexperience.Table, workexperience.FieldID, id),
  2438. sqlgraph.To(employee.Table, employee.FieldID),
  2439. sqlgraph.Edge(sqlgraph.M2O, true, workexperience.EmployeeTable, workexperience.EmployeeColumn),
  2440. )
  2441. fromV = sqlgraph.Neighbors(we.driver.Dialect(), step)
  2442. return fromV, nil
  2443. }
  2444. return query
  2445. }
  2446. // Hooks returns the client hooks.
  2447. func (c *WorkExperienceClient) Hooks() []Hook {
  2448. hooks := c.hooks.WorkExperience
  2449. return append(hooks[:len(hooks):len(hooks)], workexperience.Hooks[:]...)
  2450. }
  2451. // Interceptors returns the client interceptors.
  2452. func (c *WorkExperienceClient) Interceptors() []Interceptor {
  2453. inters := c.inters.WorkExperience
  2454. return append(inters[:len(inters):len(inters)], workexperience.Interceptors[:]...)
  2455. }
  2456. func (c *WorkExperienceClient) mutate(ctx context.Context, m *WorkExperienceMutation) (Value, error) {
  2457. switch m.Op() {
  2458. case OpCreate:
  2459. return (&WorkExperienceCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2460. case OpUpdate:
  2461. return (&WorkExperienceUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2462. case OpUpdateOne:
  2463. return (&WorkExperienceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2464. case OpDelete, OpDeleteOne:
  2465. return (&WorkExperienceDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  2466. default:
  2467. return nil, fmt.Errorf("ent: unknown WorkExperience mutation op: %q", m.Op())
  2468. }
  2469. }
  2470. // WxClient is a client for the Wx schema.
  2471. type WxClient struct {
  2472. config
  2473. }
  2474. // NewWxClient returns a client for the Wx from the given config.
  2475. func NewWxClient(c config) *WxClient {
  2476. return &WxClient{config: c}
  2477. }
  2478. // Use adds a list of mutation hooks to the hooks stack.
  2479. // A call to `Use(f, g, h)` equals to `wx.Hooks(f(g(h())))`.
  2480. func (c *WxClient) Use(hooks ...Hook) {
  2481. c.hooks.Wx = append(c.hooks.Wx, hooks...)
  2482. }
  2483. // Intercept adds a list of query interceptors to the interceptors stack.
  2484. // A call to `Intercept(f, g, h)` equals to `wx.Intercept(f(g(h())))`.
  2485. func (c *WxClient) Intercept(interceptors ...Interceptor) {
  2486. c.inters.Wx = append(c.inters.Wx, interceptors...)
  2487. }
  2488. // Create returns a builder for creating a Wx entity.
  2489. func (c *WxClient) Create() *WxCreate {
  2490. mutation := newWxMutation(c.config, OpCreate)
  2491. return &WxCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2492. }
  2493. // CreateBulk returns a builder for creating a bulk of Wx entities.
  2494. func (c *WxClient) CreateBulk(builders ...*WxCreate) *WxCreateBulk {
  2495. return &WxCreateBulk{config: c.config, builders: builders}
  2496. }
  2497. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  2498. // a builder and applies setFunc on it.
  2499. func (c *WxClient) MapCreateBulk(slice any, setFunc func(*WxCreate, int)) *WxCreateBulk {
  2500. rv := reflect.ValueOf(slice)
  2501. if rv.Kind() != reflect.Slice {
  2502. return &WxCreateBulk{err: fmt.Errorf("calling to WxClient.MapCreateBulk with wrong type %T, need slice", slice)}
  2503. }
  2504. builders := make([]*WxCreate, rv.Len())
  2505. for i := 0; i < rv.Len(); i++ {
  2506. builders[i] = c.Create()
  2507. setFunc(builders[i], i)
  2508. }
  2509. return &WxCreateBulk{config: c.config, builders: builders}
  2510. }
  2511. // Update returns an update builder for Wx.
  2512. func (c *WxClient) Update() *WxUpdate {
  2513. mutation := newWxMutation(c.config, OpUpdate)
  2514. return &WxUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2515. }
  2516. // UpdateOne returns an update builder for the given entity.
  2517. func (c *WxClient) UpdateOne(w *Wx) *WxUpdateOne {
  2518. mutation := newWxMutation(c.config, OpUpdateOne, withWx(w))
  2519. return &WxUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2520. }
  2521. // UpdateOneID returns an update builder for the given id.
  2522. func (c *WxClient) UpdateOneID(id uint64) *WxUpdateOne {
  2523. mutation := newWxMutation(c.config, OpUpdateOne, withWxID(id))
  2524. return &WxUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2525. }
  2526. // Delete returns a delete builder for Wx.
  2527. func (c *WxClient) Delete() *WxDelete {
  2528. mutation := newWxMutation(c.config, OpDelete)
  2529. return &WxDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2530. }
  2531. // DeleteOne returns a builder for deleting the given entity.
  2532. func (c *WxClient) DeleteOne(w *Wx) *WxDeleteOne {
  2533. return c.DeleteOneID(w.ID)
  2534. }
  2535. // DeleteOneID returns a builder for deleting the given entity by its id.
  2536. func (c *WxClient) DeleteOneID(id uint64) *WxDeleteOne {
  2537. builder := c.Delete().Where(wx.ID(id))
  2538. builder.mutation.id = &id
  2539. builder.mutation.op = OpDeleteOne
  2540. return &WxDeleteOne{builder}
  2541. }
  2542. // Query returns a query builder for Wx.
  2543. func (c *WxClient) Query() *WxQuery {
  2544. return &WxQuery{
  2545. config: c.config,
  2546. ctx: &QueryContext{Type: TypeWx},
  2547. inters: c.Interceptors(),
  2548. }
  2549. }
  2550. // Get returns a Wx entity by its id.
  2551. func (c *WxClient) Get(ctx context.Context, id uint64) (*Wx, error) {
  2552. return c.Query().Where(wx.ID(id)).Only(ctx)
  2553. }
  2554. // GetX is like Get, but panics if an error occurs.
  2555. func (c *WxClient) GetX(ctx context.Context, id uint64) *Wx {
  2556. obj, err := c.Get(ctx, id)
  2557. if err != nil {
  2558. panic(err)
  2559. }
  2560. return obj
  2561. }
  2562. // QueryServer queries the server edge of a Wx.
  2563. func (c *WxClient) QueryServer(w *Wx) *ServerQuery {
  2564. query := (&ServerClient{config: c.config}).Query()
  2565. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  2566. id := w.ID
  2567. step := sqlgraph.NewStep(
  2568. sqlgraph.From(wx.Table, wx.FieldID, id),
  2569. sqlgraph.To(server.Table, server.FieldID),
  2570. sqlgraph.Edge(sqlgraph.M2O, true, wx.ServerTable, wx.ServerColumn),
  2571. )
  2572. fromV = sqlgraph.Neighbors(w.driver.Dialect(), step)
  2573. return fromV, nil
  2574. }
  2575. return query
  2576. }
  2577. // QueryAgent queries the agent edge of a Wx.
  2578. func (c *WxClient) QueryAgent(w *Wx) *AgentQuery {
  2579. query := (&AgentClient{config: c.config}).Query()
  2580. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  2581. id := w.ID
  2582. step := sqlgraph.NewStep(
  2583. sqlgraph.From(wx.Table, wx.FieldID, id),
  2584. sqlgraph.To(agent.Table, agent.FieldID),
  2585. sqlgraph.Edge(sqlgraph.M2O, true, wx.AgentTable, wx.AgentColumn),
  2586. )
  2587. fromV = sqlgraph.Neighbors(w.driver.Dialect(), step)
  2588. return fromV, nil
  2589. }
  2590. return query
  2591. }
  2592. // Hooks returns the client hooks.
  2593. func (c *WxClient) Hooks() []Hook {
  2594. hooks := c.hooks.Wx
  2595. return append(hooks[:len(hooks):len(hooks)], wx.Hooks[:]...)
  2596. }
  2597. // Interceptors returns the client interceptors.
  2598. func (c *WxClient) Interceptors() []Interceptor {
  2599. inters := c.inters.Wx
  2600. return append(inters[:len(inters):len(inters)], wx.Interceptors[:]...)
  2601. }
  2602. func (c *WxClient) mutate(ctx context.Context, m *WxMutation) (Value, error) {
  2603. switch m.Op() {
  2604. case OpCreate:
  2605. return (&WxCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2606. case OpUpdate:
  2607. return (&WxUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2608. case OpUpdateOne:
  2609. return (&WxUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2610. case OpDelete, OpDeleteOne:
  2611. return (&WxDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  2612. default:
  2613. return nil, fmt.Errorf("ent: unknown Wx mutation op: %q", m.Op())
  2614. }
  2615. }
  2616. // hooks and interceptors per client, for fast access.
  2617. type (
  2618. hooks struct {
  2619. Agent, BatchMsg, Contact, Employee, Label, LabelRelationship, Message,
  2620. MessageRecords, Msg, Server, SopNode, SopStage, SopTask, Token, Tutorial,
  2621. WorkExperience, Wx []ent.Hook
  2622. }
  2623. inters struct {
  2624. Agent, BatchMsg, Contact, Employee, Label, LabelRelationship, Message,
  2625. MessageRecords, Msg, Server, SopNode, SopStage, SopTask, Token, Tutorial,
  2626. WorkExperience, Wx []ent.Interceptor
  2627. }
  2628. )
  2629. // ExecContext allows calling the underlying ExecContext method of the driver if it is supported by it.
  2630. // See, database/sql#DB.ExecContext for more information.
  2631. func (c *config) ExecContext(ctx context.Context, query string, args ...any) (stdsql.Result, error) {
  2632. ex, ok := c.driver.(interface {
  2633. ExecContext(context.Context, string, ...any) (stdsql.Result, error)
  2634. })
  2635. if !ok {
  2636. return nil, fmt.Errorf("Driver.ExecContext is not supported")
  2637. }
  2638. return ex.ExecContext(ctx, query, args...)
  2639. }
  2640. // QueryContext allows calling the underlying QueryContext method of the driver if it is supported by it.
  2641. // See, database/sql#DB.QueryContext for more information.
  2642. func (c *config) QueryContext(ctx context.Context, query string, args ...any) (*stdsql.Rows, error) {
  2643. q, ok := c.driver.(interface {
  2644. QueryContext(context.Context, string, ...any) (*stdsql.Rows, error)
  2645. })
  2646. if !ok {
  2647. return nil, fmt.Errorf("Driver.QueryContext is not supported")
  2648. }
  2649. return q.QueryContext(ctx, query, args...)
  2650. }