client.go 277 KB

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