client.go 186 KB

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