client.go 158 KB

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