client.go 252 KB

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