client.go 125 KB

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