client.go 234 KB

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