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