client.go 284 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "log"
  8. "reflect"
  9. "github.com/Wei-Shaw/sub2api/ent/migrate"
  10. "entgo.io/ent"
  11. "entgo.io/ent/dialect"
  12. "entgo.io/ent/dialect/sql"
  13. "entgo.io/ent/dialect/sql/sqlgraph"
  14. "github.com/Wei-Shaw/sub2api/ent/account"
  15. "github.com/Wei-Shaw/sub2api/ent/accountgroup"
  16. "github.com/Wei-Shaw/sub2api/ent/announcement"
  17. "github.com/Wei-Shaw/sub2api/ent/announcementread"
  18. "github.com/Wei-Shaw/sub2api/ent/apikey"
  19. "github.com/Wei-Shaw/sub2api/ent/authidentity"
  20. "github.com/Wei-Shaw/sub2api/ent/authidentitychannel"
  21. "github.com/Wei-Shaw/sub2api/ent/batchimageevent"
  22. "github.com/Wei-Shaw/sub2api/ent/batchimageitem"
  23. "github.com/Wei-Shaw/sub2api/ent/batchimagejob"
  24. "github.com/Wei-Shaw/sub2api/ent/channelmonitor"
  25. "github.com/Wei-Shaw/sub2api/ent/channelmonitordailyrollup"
  26. "github.com/Wei-Shaw/sub2api/ent/channelmonitorhistory"
  27. "github.com/Wei-Shaw/sub2api/ent/channelmonitorrequesttemplate"
  28. "github.com/Wei-Shaw/sub2api/ent/compositemodelroute"
  29. "github.com/Wei-Shaw/sub2api/ent/errorpassthroughrule"
  30. "github.com/Wei-Shaw/sub2api/ent/group"
  31. "github.com/Wei-Shaw/sub2api/ent/idempotencyrecord"
  32. "github.com/Wei-Shaw/sub2api/ent/identityadoptiondecision"
  33. "github.com/Wei-Shaw/sub2api/ent/paymentauditlog"
  34. "github.com/Wei-Shaw/sub2api/ent/paymentorder"
  35. "github.com/Wei-Shaw/sub2api/ent/paymentproviderinstance"
  36. "github.com/Wei-Shaw/sub2api/ent/pendingauthsession"
  37. "github.com/Wei-Shaw/sub2api/ent/promocode"
  38. "github.com/Wei-Shaw/sub2api/ent/promocodeusage"
  39. "github.com/Wei-Shaw/sub2api/ent/proxy"
  40. "github.com/Wei-Shaw/sub2api/ent/redeemcode"
  41. "github.com/Wei-Shaw/sub2api/ent/securitypolicykeyword"
  42. "github.com/Wei-Shaw/sub2api/ent/securitysecret"
  43. "github.com/Wei-Shaw/sub2api/ent/setting"
  44. "github.com/Wei-Shaw/sub2api/ent/subscriptionplan"
  45. "github.com/Wei-Shaw/sub2api/ent/tlsfingerprintprofile"
  46. "github.com/Wei-Shaw/sub2api/ent/usagecleanuptask"
  47. "github.com/Wei-Shaw/sub2api/ent/usagelog"
  48. "github.com/Wei-Shaw/sub2api/ent/user"
  49. "github.com/Wei-Shaw/sub2api/ent/userallowedgroup"
  50. "github.com/Wei-Shaw/sub2api/ent/userattributedefinition"
  51. "github.com/Wei-Shaw/sub2api/ent/userattributevalue"
  52. "github.com/Wei-Shaw/sub2api/ent/userplatformquota"
  53. "github.com/Wei-Shaw/sub2api/ent/usersubscription"
  54. stdsql "database/sql"
  55. )
  56. // Client is the client that holds all ent builders.
  57. type Client struct {
  58. config
  59. // Schema is the client for creating, migrating and dropping schema.
  60. Schema *migrate.Schema
  61. // APIKey is the client for interacting with the APIKey builders.
  62. APIKey *APIKeyClient
  63. // Account is the client for interacting with the Account builders.
  64. Account *AccountClient
  65. // AccountGroup is the client for interacting with the AccountGroup builders.
  66. AccountGroup *AccountGroupClient
  67. // Announcement is the client for interacting with the Announcement builders.
  68. Announcement *AnnouncementClient
  69. // AnnouncementRead is the client for interacting with the AnnouncementRead builders.
  70. AnnouncementRead *AnnouncementReadClient
  71. // AuthIdentity is the client for interacting with the AuthIdentity builders.
  72. AuthIdentity *AuthIdentityClient
  73. // AuthIdentityChannel is the client for interacting with the AuthIdentityChannel builders.
  74. AuthIdentityChannel *AuthIdentityChannelClient
  75. // BatchImageEvent is the client for interacting with the BatchImageEvent builders.
  76. BatchImageEvent *BatchImageEventClient
  77. // BatchImageItem is the client for interacting with the BatchImageItem builders.
  78. BatchImageItem *BatchImageItemClient
  79. // BatchImageJob is the client for interacting with the BatchImageJob builders.
  80. BatchImageJob *BatchImageJobClient
  81. // ChannelMonitor is the client for interacting with the ChannelMonitor builders.
  82. ChannelMonitor *ChannelMonitorClient
  83. // ChannelMonitorDailyRollup is the client for interacting with the ChannelMonitorDailyRollup builders.
  84. ChannelMonitorDailyRollup *ChannelMonitorDailyRollupClient
  85. // ChannelMonitorHistory is the client for interacting with the ChannelMonitorHistory builders.
  86. ChannelMonitorHistory *ChannelMonitorHistoryClient
  87. // ChannelMonitorRequestTemplate is the client for interacting with the ChannelMonitorRequestTemplate builders.
  88. ChannelMonitorRequestTemplate *ChannelMonitorRequestTemplateClient
  89. // CompositeModelRoute is the client for interacting with the CompositeModelRoute builders.
  90. CompositeModelRoute *CompositeModelRouteClient
  91. // ErrorPassthroughRule is the client for interacting with the ErrorPassthroughRule builders.
  92. ErrorPassthroughRule *ErrorPassthroughRuleClient
  93. // Group is the client for interacting with the Group builders.
  94. Group *GroupClient
  95. // IdempotencyRecord is the client for interacting with the IdempotencyRecord builders.
  96. IdempotencyRecord *IdempotencyRecordClient
  97. // IdentityAdoptionDecision is the client for interacting with the IdentityAdoptionDecision builders.
  98. IdentityAdoptionDecision *IdentityAdoptionDecisionClient
  99. // PaymentAuditLog is the client for interacting with the PaymentAuditLog builders.
  100. PaymentAuditLog *PaymentAuditLogClient
  101. // PaymentOrder is the client for interacting with the PaymentOrder builders.
  102. PaymentOrder *PaymentOrderClient
  103. // PaymentProviderInstance is the client for interacting with the PaymentProviderInstance builders.
  104. PaymentProviderInstance *PaymentProviderInstanceClient
  105. // PendingAuthSession is the client for interacting with the PendingAuthSession builders.
  106. PendingAuthSession *PendingAuthSessionClient
  107. // PromoCode is the client for interacting with the PromoCode builders.
  108. PromoCode *PromoCodeClient
  109. // PromoCodeUsage is the client for interacting with the PromoCodeUsage builders.
  110. PromoCodeUsage *PromoCodeUsageClient
  111. // Proxy is the client for interacting with the Proxy builders.
  112. Proxy *ProxyClient
  113. // RedeemCode is the client for interacting with the RedeemCode builders.
  114. RedeemCode *RedeemCodeClient
  115. // SecurityPolicyKeyword is the client for interacting with the SecurityPolicyKeyword builders.
  116. SecurityPolicyKeyword *SecurityPolicyKeywordClient
  117. // SecuritySecret is the client for interacting with the SecuritySecret builders.
  118. SecuritySecret *SecuritySecretClient
  119. // Setting is the client for interacting with the Setting builders.
  120. Setting *SettingClient
  121. // SubscriptionPlan is the client for interacting with the SubscriptionPlan builders.
  122. SubscriptionPlan *SubscriptionPlanClient
  123. // TLSFingerprintProfile is the client for interacting with the TLSFingerprintProfile builders.
  124. TLSFingerprintProfile *TLSFingerprintProfileClient
  125. // UsageCleanupTask is the client for interacting with the UsageCleanupTask builders.
  126. UsageCleanupTask *UsageCleanupTaskClient
  127. // UsageLog is the client for interacting with the UsageLog builders.
  128. UsageLog *UsageLogClient
  129. // User is the client for interacting with the User builders.
  130. User *UserClient
  131. // UserAllowedGroup is the client for interacting with the UserAllowedGroup builders.
  132. UserAllowedGroup *UserAllowedGroupClient
  133. // UserAttributeDefinition is the client for interacting with the UserAttributeDefinition builders.
  134. UserAttributeDefinition *UserAttributeDefinitionClient
  135. // UserAttributeValue is the client for interacting with the UserAttributeValue builders.
  136. UserAttributeValue *UserAttributeValueClient
  137. // UserPlatformQuota is the client for interacting with the UserPlatformQuota builders.
  138. UserPlatformQuota *UserPlatformQuotaClient
  139. // UserSubscription is the client for interacting with the UserSubscription builders.
  140. UserSubscription *UserSubscriptionClient
  141. }
  142. // NewClient creates a new client configured with the given options.
  143. func NewClient(opts ...Option) *Client {
  144. client := &Client{config: newConfig(opts...)}
  145. client.init()
  146. return client
  147. }
  148. func (c *Client) init() {
  149. c.Schema = migrate.NewSchema(c.driver)
  150. c.APIKey = NewAPIKeyClient(c.config)
  151. c.Account = NewAccountClient(c.config)
  152. c.AccountGroup = NewAccountGroupClient(c.config)
  153. c.Announcement = NewAnnouncementClient(c.config)
  154. c.AnnouncementRead = NewAnnouncementReadClient(c.config)
  155. c.AuthIdentity = NewAuthIdentityClient(c.config)
  156. c.AuthIdentityChannel = NewAuthIdentityChannelClient(c.config)
  157. c.BatchImageEvent = NewBatchImageEventClient(c.config)
  158. c.BatchImageItem = NewBatchImageItemClient(c.config)
  159. c.BatchImageJob = NewBatchImageJobClient(c.config)
  160. c.ChannelMonitor = NewChannelMonitorClient(c.config)
  161. c.ChannelMonitorDailyRollup = NewChannelMonitorDailyRollupClient(c.config)
  162. c.ChannelMonitorHistory = NewChannelMonitorHistoryClient(c.config)
  163. c.ChannelMonitorRequestTemplate = NewChannelMonitorRequestTemplateClient(c.config)
  164. c.CompositeModelRoute = NewCompositeModelRouteClient(c.config)
  165. c.ErrorPassthroughRule = NewErrorPassthroughRuleClient(c.config)
  166. c.Group = NewGroupClient(c.config)
  167. c.IdempotencyRecord = NewIdempotencyRecordClient(c.config)
  168. c.IdentityAdoptionDecision = NewIdentityAdoptionDecisionClient(c.config)
  169. c.PaymentAuditLog = NewPaymentAuditLogClient(c.config)
  170. c.PaymentOrder = NewPaymentOrderClient(c.config)
  171. c.PaymentProviderInstance = NewPaymentProviderInstanceClient(c.config)
  172. c.PendingAuthSession = NewPendingAuthSessionClient(c.config)
  173. c.PromoCode = NewPromoCodeClient(c.config)
  174. c.PromoCodeUsage = NewPromoCodeUsageClient(c.config)
  175. c.Proxy = NewProxyClient(c.config)
  176. c.RedeemCode = NewRedeemCodeClient(c.config)
  177. c.SecurityPolicyKeyword = NewSecurityPolicyKeywordClient(c.config)
  178. c.SecuritySecret = NewSecuritySecretClient(c.config)
  179. c.Setting = NewSettingClient(c.config)
  180. c.SubscriptionPlan = NewSubscriptionPlanClient(c.config)
  181. c.TLSFingerprintProfile = NewTLSFingerprintProfileClient(c.config)
  182. c.UsageCleanupTask = NewUsageCleanupTaskClient(c.config)
  183. c.UsageLog = NewUsageLogClient(c.config)
  184. c.User = NewUserClient(c.config)
  185. c.UserAllowedGroup = NewUserAllowedGroupClient(c.config)
  186. c.UserAttributeDefinition = NewUserAttributeDefinitionClient(c.config)
  187. c.UserAttributeValue = NewUserAttributeValueClient(c.config)
  188. c.UserPlatformQuota = NewUserPlatformQuotaClient(c.config)
  189. c.UserSubscription = NewUserSubscriptionClient(c.config)
  190. }
  191. type (
  192. // config is the configuration for the client and its builder.
  193. config struct {
  194. // driver used for executing database requests.
  195. driver dialect.Driver
  196. // debug enable a debug logging.
  197. debug bool
  198. // log used for logging on debug mode.
  199. log func(...any)
  200. // hooks to execute on mutations.
  201. hooks *hooks
  202. // interceptors to execute on queries.
  203. inters *inters
  204. }
  205. // Option function to configure the client.
  206. Option func(*config)
  207. )
  208. // newConfig creates a new config for the client.
  209. func newConfig(opts ...Option) config {
  210. cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}}
  211. cfg.options(opts...)
  212. return cfg
  213. }
  214. // options applies the options on the config object.
  215. func (c *config) options(opts ...Option) {
  216. for _, opt := range opts {
  217. opt(c)
  218. }
  219. if c.debug {
  220. c.driver = dialect.Debug(c.driver, c.log)
  221. }
  222. }
  223. // Debug enables debug logging on the ent.Driver.
  224. func Debug() Option {
  225. return func(c *config) {
  226. c.debug = true
  227. }
  228. }
  229. // Log sets the logging function for debug mode.
  230. func Log(fn func(...any)) Option {
  231. return func(c *config) {
  232. c.log = fn
  233. }
  234. }
  235. // Driver configures the client driver.
  236. func Driver(driver dialect.Driver) Option {
  237. return func(c *config) {
  238. c.driver = driver
  239. }
  240. }
  241. // Open opens a database/sql.DB specified by the driver name and
  242. // the data source name, and returns a new client attached to it.
  243. // Optional parameters can be added for configuring the client.
  244. func Open(driverName, dataSourceName string, options ...Option) (*Client, error) {
  245. switch driverName {
  246. case dialect.MySQL, dialect.Postgres, dialect.SQLite:
  247. drv, err := sql.Open(driverName, dataSourceName)
  248. if err != nil {
  249. return nil, err
  250. }
  251. return NewClient(append(options, Driver(drv))...), nil
  252. default:
  253. return nil, fmt.Errorf("unsupported driver: %q", driverName)
  254. }
  255. }
  256. // ErrTxStarted is returned when trying to start a new transaction from a transactional client.
  257. var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction")
  258. // Tx returns a new transactional client. The provided context
  259. // is used until the transaction is committed or rolled back.
  260. func (c *Client) Tx(ctx context.Context) (*Tx, error) {
  261. if _, ok := c.driver.(*txDriver); ok {
  262. return nil, ErrTxStarted
  263. }
  264. tx, err := newTx(ctx, c.driver)
  265. if err != nil {
  266. return nil, fmt.Errorf("ent: starting a transaction: %w", err)
  267. }
  268. cfg := c.config
  269. cfg.driver = tx
  270. return &Tx{
  271. ctx: ctx,
  272. config: cfg,
  273. APIKey: NewAPIKeyClient(cfg),
  274. Account: NewAccountClient(cfg),
  275. AccountGroup: NewAccountGroupClient(cfg),
  276. Announcement: NewAnnouncementClient(cfg),
  277. AnnouncementRead: NewAnnouncementReadClient(cfg),
  278. AuthIdentity: NewAuthIdentityClient(cfg),
  279. AuthIdentityChannel: NewAuthIdentityChannelClient(cfg),
  280. BatchImageEvent: NewBatchImageEventClient(cfg),
  281. BatchImageItem: NewBatchImageItemClient(cfg),
  282. BatchImageJob: NewBatchImageJobClient(cfg),
  283. ChannelMonitor: NewChannelMonitorClient(cfg),
  284. ChannelMonitorDailyRollup: NewChannelMonitorDailyRollupClient(cfg),
  285. ChannelMonitorHistory: NewChannelMonitorHistoryClient(cfg),
  286. ChannelMonitorRequestTemplate: NewChannelMonitorRequestTemplateClient(cfg),
  287. CompositeModelRoute: NewCompositeModelRouteClient(cfg),
  288. ErrorPassthroughRule: NewErrorPassthroughRuleClient(cfg),
  289. Group: NewGroupClient(cfg),
  290. IdempotencyRecord: NewIdempotencyRecordClient(cfg),
  291. IdentityAdoptionDecision: NewIdentityAdoptionDecisionClient(cfg),
  292. PaymentAuditLog: NewPaymentAuditLogClient(cfg),
  293. PaymentOrder: NewPaymentOrderClient(cfg),
  294. PaymentProviderInstance: NewPaymentProviderInstanceClient(cfg),
  295. PendingAuthSession: NewPendingAuthSessionClient(cfg),
  296. PromoCode: NewPromoCodeClient(cfg),
  297. PromoCodeUsage: NewPromoCodeUsageClient(cfg),
  298. Proxy: NewProxyClient(cfg),
  299. RedeemCode: NewRedeemCodeClient(cfg),
  300. SecurityPolicyKeyword: NewSecurityPolicyKeywordClient(cfg),
  301. SecuritySecret: NewSecuritySecretClient(cfg),
  302. Setting: NewSettingClient(cfg),
  303. SubscriptionPlan: NewSubscriptionPlanClient(cfg),
  304. TLSFingerprintProfile: NewTLSFingerprintProfileClient(cfg),
  305. UsageCleanupTask: NewUsageCleanupTaskClient(cfg),
  306. UsageLog: NewUsageLogClient(cfg),
  307. User: NewUserClient(cfg),
  308. UserAllowedGroup: NewUserAllowedGroupClient(cfg),
  309. UserAttributeDefinition: NewUserAttributeDefinitionClient(cfg),
  310. UserAttributeValue: NewUserAttributeValueClient(cfg),
  311. UserPlatformQuota: NewUserPlatformQuotaClient(cfg),
  312. UserSubscription: NewUserSubscriptionClient(cfg),
  313. }, nil
  314. }
  315. // BeginTx returns a transactional client with specified options.
  316. func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) {
  317. if _, ok := c.driver.(*txDriver); ok {
  318. return nil, errors.New("ent: cannot start a transaction within a transaction")
  319. }
  320. tx, err := c.driver.(interface {
  321. BeginTx(context.Context, *sql.TxOptions) (dialect.Tx, error)
  322. }).BeginTx(ctx, opts)
  323. if err != nil {
  324. return nil, fmt.Errorf("ent: starting a transaction: %w", err)
  325. }
  326. cfg := c.config
  327. cfg.driver = &txDriver{tx: tx, drv: c.driver}
  328. return &Tx{
  329. ctx: ctx,
  330. config: cfg,
  331. APIKey: NewAPIKeyClient(cfg),
  332. Account: NewAccountClient(cfg),
  333. AccountGroup: NewAccountGroupClient(cfg),
  334. Announcement: NewAnnouncementClient(cfg),
  335. AnnouncementRead: NewAnnouncementReadClient(cfg),
  336. AuthIdentity: NewAuthIdentityClient(cfg),
  337. AuthIdentityChannel: NewAuthIdentityChannelClient(cfg),
  338. BatchImageEvent: NewBatchImageEventClient(cfg),
  339. BatchImageItem: NewBatchImageItemClient(cfg),
  340. BatchImageJob: NewBatchImageJobClient(cfg),
  341. ChannelMonitor: NewChannelMonitorClient(cfg),
  342. ChannelMonitorDailyRollup: NewChannelMonitorDailyRollupClient(cfg),
  343. ChannelMonitorHistory: NewChannelMonitorHistoryClient(cfg),
  344. ChannelMonitorRequestTemplate: NewChannelMonitorRequestTemplateClient(cfg),
  345. CompositeModelRoute: NewCompositeModelRouteClient(cfg),
  346. ErrorPassthroughRule: NewErrorPassthroughRuleClient(cfg),
  347. Group: NewGroupClient(cfg),
  348. IdempotencyRecord: NewIdempotencyRecordClient(cfg),
  349. IdentityAdoptionDecision: NewIdentityAdoptionDecisionClient(cfg),
  350. PaymentAuditLog: NewPaymentAuditLogClient(cfg),
  351. PaymentOrder: NewPaymentOrderClient(cfg),
  352. PaymentProviderInstance: NewPaymentProviderInstanceClient(cfg),
  353. PendingAuthSession: NewPendingAuthSessionClient(cfg),
  354. PromoCode: NewPromoCodeClient(cfg),
  355. PromoCodeUsage: NewPromoCodeUsageClient(cfg),
  356. Proxy: NewProxyClient(cfg),
  357. RedeemCode: NewRedeemCodeClient(cfg),
  358. SecurityPolicyKeyword: NewSecurityPolicyKeywordClient(cfg),
  359. SecuritySecret: NewSecuritySecretClient(cfg),
  360. Setting: NewSettingClient(cfg),
  361. SubscriptionPlan: NewSubscriptionPlanClient(cfg),
  362. TLSFingerprintProfile: NewTLSFingerprintProfileClient(cfg),
  363. UsageCleanupTask: NewUsageCleanupTaskClient(cfg),
  364. UsageLog: NewUsageLogClient(cfg),
  365. User: NewUserClient(cfg),
  366. UserAllowedGroup: NewUserAllowedGroupClient(cfg),
  367. UserAttributeDefinition: NewUserAttributeDefinitionClient(cfg),
  368. UserAttributeValue: NewUserAttributeValueClient(cfg),
  369. UserPlatformQuota: NewUserPlatformQuotaClient(cfg),
  370. UserSubscription: NewUserSubscriptionClient(cfg),
  371. }, nil
  372. }
  373. // Debug returns a new debug-client. It's used to get verbose logging on specific operations.
  374. //
  375. // client.Debug().
  376. // APIKey.
  377. // Query().
  378. // Count(ctx)
  379. func (c *Client) Debug() *Client {
  380. if c.debug {
  381. return c
  382. }
  383. cfg := c.config
  384. cfg.driver = dialect.Debug(c.driver, c.log)
  385. client := &Client{config: cfg}
  386. client.init()
  387. return client
  388. }
  389. // Close closes the database connection and prevents new queries from starting.
  390. func (c *Client) Close() error {
  391. return c.driver.Close()
  392. }
  393. // Use adds the mutation hooks to all the entity clients.
  394. // In order to add hooks to a specific client, call: `client.Node.Use(...)`.
  395. func (c *Client) Use(hooks ...Hook) {
  396. for _, n := range []interface{ Use(...Hook) }{
  397. c.APIKey, c.Account, c.AccountGroup, c.Announcement, c.AnnouncementRead,
  398. c.AuthIdentity, c.AuthIdentityChannel, c.BatchImageEvent, c.BatchImageItem,
  399. c.BatchImageJob, c.ChannelMonitor, c.ChannelMonitorDailyRollup,
  400. c.ChannelMonitorHistory, c.ChannelMonitorRequestTemplate,
  401. c.CompositeModelRoute, c.ErrorPassthroughRule, c.Group, c.IdempotencyRecord,
  402. c.IdentityAdoptionDecision, c.PaymentAuditLog, c.PaymentOrder,
  403. c.PaymentProviderInstance, c.PendingAuthSession, c.PromoCode, c.PromoCodeUsage,
  404. c.Proxy, c.RedeemCode, c.SecurityPolicyKeyword, c.SecuritySecret, c.Setting,
  405. c.SubscriptionPlan, c.TLSFingerprintProfile, c.UsageCleanupTask, c.UsageLog,
  406. c.User, c.UserAllowedGroup, c.UserAttributeDefinition, c.UserAttributeValue,
  407. c.UserPlatformQuota, c.UserSubscription,
  408. } {
  409. n.Use(hooks...)
  410. }
  411. }
  412. // Intercept adds the query interceptors to all the entity clients.
  413. // In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`.
  414. func (c *Client) Intercept(interceptors ...Interceptor) {
  415. for _, n := range []interface{ Intercept(...Interceptor) }{
  416. c.APIKey, c.Account, c.AccountGroup, c.Announcement, c.AnnouncementRead,
  417. c.AuthIdentity, c.AuthIdentityChannel, c.BatchImageEvent, c.BatchImageItem,
  418. c.BatchImageJob, c.ChannelMonitor, c.ChannelMonitorDailyRollup,
  419. c.ChannelMonitorHistory, c.ChannelMonitorRequestTemplate,
  420. c.CompositeModelRoute, c.ErrorPassthroughRule, c.Group, c.IdempotencyRecord,
  421. c.IdentityAdoptionDecision, c.PaymentAuditLog, c.PaymentOrder,
  422. c.PaymentProviderInstance, c.PendingAuthSession, c.PromoCode, c.PromoCodeUsage,
  423. c.Proxy, c.RedeemCode, c.SecurityPolicyKeyword, c.SecuritySecret, c.Setting,
  424. c.SubscriptionPlan, c.TLSFingerprintProfile, c.UsageCleanupTask, c.UsageLog,
  425. c.User, c.UserAllowedGroup, c.UserAttributeDefinition, c.UserAttributeValue,
  426. c.UserPlatformQuota, c.UserSubscription,
  427. } {
  428. n.Intercept(interceptors...)
  429. }
  430. }
  431. // Mutate implements the ent.Mutator interface.
  432. func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
  433. switch m := m.(type) {
  434. case *APIKeyMutation:
  435. return c.APIKey.mutate(ctx, m)
  436. case *AccountMutation:
  437. return c.Account.mutate(ctx, m)
  438. case *AccountGroupMutation:
  439. return c.AccountGroup.mutate(ctx, m)
  440. case *AnnouncementMutation:
  441. return c.Announcement.mutate(ctx, m)
  442. case *AnnouncementReadMutation:
  443. return c.AnnouncementRead.mutate(ctx, m)
  444. case *AuthIdentityMutation:
  445. return c.AuthIdentity.mutate(ctx, m)
  446. case *AuthIdentityChannelMutation:
  447. return c.AuthIdentityChannel.mutate(ctx, m)
  448. case *BatchImageEventMutation:
  449. return c.BatchImageEvent.mutate(ctx, m)
  450. case *BatchImageItemMutation:
  451. return c.BatchImageItem.mutate(ctx, m)
  452. case *BatchImageJobMutation:
  453. return c.BatchImageJob.mutate(ctx, m)
  454. case *ChannelMonitorMutation:
  455. return c.ChannelMonitor.mutate(ctx, m)
  456. case *ChannelMonitorDailyRollupMutation:
  457. return c.ChannelMonitorDailyRollup.mutate(ctx, m)
  458. case *ChannelMonitorHistoryMutation:
  459. return c.ChannelMonitorHistory.mutate(ctx, m)
  460. case *ChannelMonitorRequestTemplateMutation:
  461. return c.ChannelMonitorRequestTemplate.mutate(ctx, m)
  462. case *CompositeModelRouteMutation:
  463. return c.CompositeModelRoute.mutate(ctx, m)
  464. case *ErrorPassthroughRuleMutation:
  465. return c.ErrorPassthroughRule.mutate(ctx, m)
  466. case *GroupMutation:
  467. return c.Group.mutate(ctx, m)
  468. case *IdempotencyRecordMutation:
  469. return c.IdempotencyRecord.mutate(ctx, m)
  470. case *IdentityAdoptionDecisionMutation:
  471. return c.IdentityAdoptionDecision.mutate(ctx, m)
  472. case *PaymentAuditLogMutation:
  473. return c.PaymentAuditLog.mutate(ctx, m)
  474. case *PaymentOrderMutation:
  475. return c.PaymentOrder.mutate(ctx, m)
  476. case *PaymentProviderInstanceMutation:
  477. return c.PaymentProviderInstance.mutate(ctx, m)
  478. case *PendingAuthSessionMutation:
  479. return c.PendingAuthSession.mutate(ctx, m)
  480. case *PromoCodeMutation:
  481. return c.PromoCode.mutate(ctx, m)
  482. case *PromoCodeUsageMutation:
  483. return c.PromoCodeUsage.mutate(ctx, m)
  484. case *ProxyMutation:
  485. return c.Proxy.mutate(ctx, m)
  486. case *RedeemCodeMutation:
  487. return c.RedeemCode.mutate(ctx, m)
  488. case *SecurityPolicyKeywordMutation:
  489. return c.SecurityPolicyKeyword.mutate(ctx, m)
  490. case *SecuritySecretMutation:
  491. return c.SecuritySecret.mutate(ctx, m)
  492. case *SettingMutation:
  493. return c.Setting.mutate(ctx, m)
  494. case *SubscriptionPlanMutation:
  495. return c.SubscriptionPlan.mutate(ctx, m)
  496. case *TLSFingerprintProfileMutation:
  497. return c.TLSFingerprintProfile.mutate(ctx, m)
  498. case *UsageCleanupTaskMutation:
  499. return c.UsageCleanupTask.mutate(ctx, m)
  500. case *UsageLogMutation:
  501. return c.UsageLog.mutate(ctx, m)
  502. case *UserMutation:
  503. return c.User.mutate(ctx, m)
  504. case *UserAllowedGroupMutation:
  505. return c.UserAllowedGroup.mutate(ctx, m)
  506. case *UserAttributeDefinitionMutation:
  507. return c.UserAttributeDefinition.mutate(ctx, m)
  508. case *UserAttributeValueMutation:
  509. return c.UserAttributeValue.mutate(ctx, m)
  510. case *UserPlatformQuotaMutation:
  511. return c.UserPlatformQuota.mutate(ctx, m)
  512. case *UserSubscriptionMutation:
  513. return c.UserSubscription.mutate(ctx, m)
  514. default:
  515. return nil, fmt.Errorf("ent: unknown mutation type %T", m)
  516. }
  517. }
  518. // APIKeyClient is a client for the APIKey schema.
  519. type APIKeyClient struct {
  520. config
  521. }
  522. // NewAPIKeyClient returns a client for the APIKey from the given config.
  523. func NewAPIKeyClient(c config) *APIKeyClient {
  524. return &APIKeyClient{config: c}
  525. }
  526. // Use adds a list of mutation hooks to the hooks stack.
  527. // A call to `Use(f, g, h)` equals to `apikey.Hooks(f(g(h())))`.
  528. func (c *APIKeyClient) Use(hooks ...Hook) {
  529. c.hooks.APIKey = append(c.hooks.APIKey, hooks...)
  530. }
  531. // Intercept adds a list of query interceptors to the interceptors stack.
  532. // A call to `Intercept(f, g, h)` equals to `apikey.Intercept(f(g(h())))`.
  533. func (c *APIKeyClient) Intercept(interceptors ...Interceptor) {
  534. c.inters.APIKey = append(c.inters.APIKey, interceptors...)
  535. }
  536. // Create returns a builder for creating a APIKey entity.
  537. func (c *APIKeyClient) Create() *APIKeyCreate {
  538. mutation := newAPIKeyMutation(c.config, OpCreate)
  539. return &APIKeyCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  540. }
  541. // CreateBulk returns a builder for creating a bulk of APIKey entities.
  542. func (c *APIKeyClient) CreateBulk(builders ...*APIKeyCreate) *APIKeyCreateBulk {
  543. return &APIKeyCreateBulk{config: c.config, builders: builders}
  544. }
  545. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  546. // a builder and applies setFunc on it.
  547. func (c *APIKeyClient) MapCreateBulk(slice any, setFunc func(*APIKeyCreate, int)) *APIKeyCreateBulk {
  548. rv := reflect.ValueOf(slice)
  549. if rv.Kind() != reflect.Slice {
  550. return &APIKeyCreateBulk{err: fmt.Errorf("calling to APIKeyClient.MapCreateBulk with wrong type %T, need slice", slice)}
  551. }
  552. builders := make([]*APIKeyCreate, rv.Len())
  553. for i := 0; i < rv.Len(); i++ {
  554. builders[i] = c.Create()
  555. setFunc(builders[i], i)
  556. }
  557. return &APIKeyCreateBulk{config: c.config, builders: builders}
  558. }
  559. // Update returns an update builder for APIKey.
  560. func (c *APIKeyClient) Update() *APIKeyUpdate {
  561. mutation := newAPIKeyMutation(c.config, OpUpdate)
  562. return &APIKeyUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  563. }
  564. // UpdateOne returns an update builder for the given entity.
  565. func (c *APIKeyClient) UpdateOne(_m *APIKey) *APIKeyUpdateOne {
  566. mutation := newAPIKeyMutation(c.config, OpUpdateOne, withAPIKey(_m))
  567. return &APIKeyUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  568. }
  569. // UpdateOneID returns an update builder for the given id.
  570. func (c *APIKeyClient) UpdateOneID(id int64) *APIKeyUpdateOne {
  571. mutation := newAPIKeyMutation(c.config, OpUpdateOne, withAPIKeyID(id))
  572. return &APIKeyUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  573. }
  574. // Delete returns a delete builder for APIKey.
  575. func (c *APIKeyClient) Delete() *APIKeyDelete {
  576. mutation := newAPIKeyMutation(c.config, OpDelete)
  577. return &APIKeyDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  578. }
  579. // DeleteOne returns a builder for deleting the given entity.
  580. func (c *APIKeyClient) DeleteOne(_m *APIKey) *APIKeyDeleteOne {
  581. return c.DeleteOneID(_m.ID)
  582. }
  583. // DeleteOneID returns a builder for deleting the given entity by its id.
  584. func (c *APIKeyClient) DeleteOneID(id int64) *APIKeyDeleteOne {
  585. builder := c.Delete().Where(apikey.ID(id))
  586. builder.mutation.id = &id
  587. builder.mutation.op = OpDeleteOne
  588. return &APIKeyDeleteOne{builder}
  589. }
  590. // Query returns a query builder for APIKey.
  591. func (c *APIKeyClient) Query() *APIKeyQuery {
  592. return &APIKeyQuery{
  593. config: c.config,
  594. ctx: &QueryContext{Type: TypeAPIKey},
  595. inters: c.Interceptors(),
  596. }
  597. }
  598. // Get returns a APIKey entity by its id.
  599. func (c *APIKeyClient) Get(ctx context.Context, id int64) (*APIKey, error) {
  600. return c.Query().Where(apikey.ID(id)).Only(ctx)
  601. }
  602. // GetX is like Get, but panics if an error occurs.
  603. func (c *APIKeyClient) GetX(ctx context.Context, id int64) *APIKey {
  604. obj, err := c.Get(ctx, id)
  605. if err != nil {
  606. panic(err)
  607. }
  608. return obj
  609. }
  610. // QueryUser queries the user edge of a APIKey.
  611. func (c *APIKeyClient) QueryUser(_m *APIKey) *UserQuery {
  612. query := (&UserClient{config: c.config}).Query()
  613. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  614. id := _m.ID
  615. step := sqlgraph.NewStep(
  616. sqlgraph.From(apikey.Table, apikey.FieldID, id),
  617. sqlgraph.To(user.Table, user.FieldID),
  618. sqlgraph.Edge(sqlgraph.M2O, true, apikey.UserTable, apikey.UserColumn),
  619. )
  620. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  621. return fromV, nil
  622. }
  623. return query
  624. }
  625. // QueryGroup queries the group edge of a APIKey.
  626. func (c *APIKeyClient) QueryGroup(_m *APIKey) *GroupQuery {
  627. query := (&GroupClient{config: c.config}).Query()
  628. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  629. id := _m.ID
  630. step := sqlgraph.NewStep(
  631. sqlgraph.From(apikey.Table, apikey.FieldID, id),
  632. sqlgraph.To(group.Table, group.FieldID),
  633. sqlgraph.Edge(sqlgraph.M2O, true, apikey.GroupTable, apikey.GroupColumn),
  634. )
  635. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  636. return fromV, nil
  637. }
  638. return query
  639. }
  640. // QueryUsageLogs queries the usage_logs edge of a APIKey.
  641. func (c *APIKeyClient) QueryUsageLogs(_m *APIKey) *UsageLogQuery {
  642. query := (&UsageLogClient{config: c.config}).Query()
  643. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  644. id := _m.ID
  645. step := sqlgraph.NewStep(
  646. sqlgraph.From(apikey.Table, apikey.FieldID, id),
  647. sqlgraph.To(usagelog.Table, usagelog.FieldID),
  648. sqlgraph.Edge(sqlgraph.O2M, false, apikey.UsageLogsTable, apikey.UsageLogsColumn),
  649. )
  650. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  651. return fromV, nil
  652. }
  653. return query
  654. }
  655. // Hooks returns the client hooks.
  656. func (c *APIKeyClient) Hooks() []Hook {
  657. hooks := c.hooks.APIKey
  658. return append(hooks[:len(hooks):len(hooks)], apikey.Hooks[:]...)
  659. }
  660. // Interceptors returns the client interceptors.
  661. func (c *APIKeyClient) Interceptors() []Interceptor {
  662. inters := c.inters.APIKey
  663. return append(inters[:len(inters):len(inters)], apikey.Interceptors[:]...)
  664. }
  665. func (c *APIKeyClient) mutate(ctx context.Context, m *APIKeyMutation) (Value, error) {
  666. switch m.Op() {
  667. case OpCreate:
  668. return (&APIKeyCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  669. case OpUpdate:
  670. return (&APIKeyUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  671. case OpUpdateOne:
  672. return (&APIKeyUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  673. case OpDelete, OpDeleteOne:
  674. return (&APIKeyDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  675. default:
  676. return nil, fmt.Errorf("ent: unknown APIKey mutation op: %q", m.Op())
  677. }
  678. }
  679. // AccountClient is a client for the Account schema.
  680. type AccountClient struct {
  681. config
  682. }
  683. // NewAccountClient returns a client for the Account from the given config.
  684. func NewAccountClient(c config) *AccountClient {
  685. return &AccountClient{config: c}
  686. }
  687. // Use adds a list of mutation hooks to the hooks stack.
  688. // A call to `Use(f, g, h)` equals to `account.Hooks(f(g(h())))`.
  689. func (c *AccountClient) Use(hooks ...Hook) {
  690. c.hooks.Account = append(c.hooks.Account, hooks...)
  691. }
  692. // Intercept adds a list of query interceptors to the interceptors stack.
  693. // A call to `Intercept(f, g, h)` equals to `account.Intercept(f(g(h())))`.
  694. func (c *AccountClient) Intercept(interceptors ...Interceptor) {
  695. c.inters.Account = append(c.inters.Account, interceptors...)
  696. }
  697. // Create returns a builder for creating a Account entity.
  698. func (c *AccountClient) Create() *AccountCreate {
  699. mutation := newAccountMutation(c.config, OpCreate)
  700. return &AccountCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  701. }
  702. // CreateBulk returns a builder for creating a bulk of Account entities.
  703. func (c *AccountClient) CreateBulk(builders ...*AccountCreate) *AccountCreateBulk {
  704. return &AccountCreateBulk{config: c.config, builders: builders}
  705. }
  706. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  707. // a builder and applies setFunc on it.
  708. func (c *AccountClient) MapCreateBulk(slice any, setFunc func(*AccountCreate, int)) *AccountCreateBulk {
  709. rv := reflect.ValueOf(slice)
  710. if rv.Kind() != reflect.Slice {
  711. return &AccountCreateBulk{err: fmt.Errorf("calling to AccountClient.MapCreateBulk with wrong type %T, need slice", slice)}
  712. }
  713. builders := make([]*AccountCreate, rv.Len())
  714. for i := 0; i < rv.Len(); i++ {
  715. builders[i] = c.Create()
  716. setFunc(builders[i], i)
  717. }
  718. return &AccountCreateBulk{config: c.config, builders: builders}
  719. }
  720. // Update returns an update builder for Account.
  721. func (c *AccountClient) Update() *AccountUpdate {
  722. mutation := newAccountMutation(c.config, OpUpdate)
  723. return &AccountUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  724. }
  725. // UpdateOne returns an update builder for the given entity.
  726. func (c *AccountClient) UpdateOne(_m *Account) *AccountUpdateOne {
  727. mutation := newAccountMutation(c.config, OpUpdateOne, withAccount(_m))
  728. return &AccountUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  729. }
  730. // UpdateOneID returns an update builder for the given id.
  731. func (c *AccountClient) UpdateOneID(id int64) *AccountUpdateOne {
  732. mutation := newAccountMutation(c.config, OpUpdateOne, withAccountID(id))
  733. return &AccountUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  734. }
  735. // Delete returns a delete builder for Account.
  736. func (c *AccountClient) Delete() *AccountDelete {
  737. mutation := newAccountMutation(c.config, OpDelete)
  738. return &AccountDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  739. }
  740. // DeleteOne returns a builder for deleting the given entity.
  741. func (c *AccountClient) DeleteOne(_m *Account) *AccountDeleteOne {
  742. return c.DeleteOneID(_m.ID)
  743. }
  744. // DeleteOneID returns a builder for deleting the given entity by its id.
  745. func (c *AccountClient) DeleteOneID(id int64) *AccountDeleteOne {
  746. builder := c.Delete().Where(account.ID(id))
  747. builder.mutation.id = &id
  748. builder.mutation.op = OpDeleteOne
  749. return &AccountDeleteOne{builder}
  750. }
  751. // Query returns a query builder for Account.
  752. func (c *AccountClient) Query() *AccountQuery {
  753. return &AccountQuery{
  754. config: c.config,
  755. ctx: &QueryContext{Type: TypeAccount},
  756. inters: c.Interceptors(),
  757. }
  758. }
  759. // Get returns a Account entity by its id.
  760. func (c *AccountClient) Get(ctx context.Context, id int64) (*Account, error) {
  761. return c.Query().Where(account.ID(id)).Only(ctx)
  762. }
  763. // GetX is like Get, but panics if an error occurs.
  764. func (c *AccountClient) GetX(ctx context.Context, id int64) *Account {
  765. obj, err := c.Get(ctx, id)
  766. if err != nil {
  767. panic(err)
  768. }
  769. return obj
  770. }
  771. // QueryGroups queries the groups edge of a Account.
  772. func (c *AccountClient) QueryGroups(_m *Account) *GroupQuery {
  773. query := (&GroupClient{config: c.config}).Query()
  774. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  775. id := _m.ID
  776. step := sqlgraph.NewStep(
  777. sqlgraph.From(account.Table, account.FieldID, id),
  778. sqlgraph.To(group.Table, group.FieldID),
  779. sqlgraph.Edge(sqlgraph.M2M, false, account.GroupsTable, account.GroupsPrimaryKey...),
  780. )
  781. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  782. return fromV, nil
  783. }
  784. return query
  785. }
  786. // QueryProxy queries the proxy edge of a Account.
  787. func (c *AccountClient) QueryProxy(_m *Account) *ProxyQuery {
  788. query := (&ProxyClient{config: c.config}).Query()
  789. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  790. id := _m.ID
  791. step := sqlgraph.NewStep(
  792. sqlgraph.From(account.Table, account.FieldID, id),
  793. sqlgraph.To(proxy.Table, proxy.FieldID),
  794. sqlgraph.Edge(sqlgraph.M2O, false, account.ProxyTable, account.ProxyColumn),
  795. )
  796. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  797. return fromV, nil
  798. }
  799. return query
  800. }
  801. // QueryParent queries the parent edge of a Account.
  802. func (c *AccountClient) QueryParent(_m *Account) *AccountQuery {
  803. query := (&AccountClient{config: c.config}).Query()
  804. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  805. id := _m.ID
  806. step := sqlgraph.NewStep(
  807. sqlgraph.From(account.Table, account.FieldID, id),
  808. sqlgraph.To(account.Table, account.FieldID),
  809. sqlgraph.Edge(sqlgraph.M2O, true, account.ParentTable, account.ParentColumn),
  810. )
  811. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  812. return fromV, nil
  813. }
  814. return query
  815. }
  816. // QueryChildren queries the children edge of a Account.
  817. func (c *AccountClient) QueryChildren(_m *Account) *AccountQuery {
  818. query := (&AccountClient{config: c.config}).Query()
  819. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  820. id := _m.ID
  821. step := sqlgraph.NewStep(
  822. sqlgraph.From(account.Table, account.FieldID, id),
  823. sqlgraph.To(account.Table, account.FieldID),
  824. sqlgraph.Edge(sqlgraph.O2M, false, account.ChildrenTable, account.ChildrenColumn),
  825. )
  826. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  827. return fromV, nil
  828. }
  829. return query
  830. }
  831. // QueryUsageLogs queries the usage_logs edge of a Account.
  832. func (c *AccountClient) QueryUsageLogs(_m *Account) *UsageLogQuery {
  833. query := (&UsageLogClient{config: c.config}).Query()
  834. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  835. id := _m.ID
  836. step := sqlgraph.NewStep(
  837. sqlgraph.From(account.Table, account.FieldID, id),
  838. sqlgraph.To(usagelog.Table, usagelog.FieldID),
  839. sqlgraph.Edge(sqlgraph.O2M, false, account.UsageLogsTable, account.UsageLogsColumn),
  840. )
  841. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  842. return fromV, nil
  843. }
  844. return query
  845. }
  846. // QueryAccountGroups queries the account_groups edge of a Account.
  847. func (c *AccountClient) QueryAccountGroups(_m *Account) *AccountGroupQuery {
  848. query := (&AccountGroupClient{config: c.config}).Query()
  849. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  850. id := _m.ID
  851. step := sqlgraph.NewStep(
  852. sqlgraph.From(account.Table, account.FieldID, id),
  853. sqlgraph.To(accountgroup.Table, accountgroup.AccountColumn),
  854. sqlgraph.Edge(sqlgraph.O2M, true, account.AccountGroupsTable, account.AccountGroupsColumn),
  855. )
  856. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  857. return fromV, nil
  858. }
  859. return query
  860. }
  861. // Hooks returns the client hooks.
  862. func (c *AccountClient) Hooks() []Hook {
  863. hooks := c.hooks.Account
  864. return append(hooks[:len(hooks):len(hooks)], account.Hooks[:]...)
  865. }
  866. // Interceptors returns the client interceptors.
  867. func (c *AccountClient) Interceptors() []Interceptor {
  868. inters := c.inters.Account
  869. return append(inters[:len(inters):len(inters)], account.Interceptors[:]...)
  870. }
  871. func (c *AccountClient) mutate(ctx context.Context, m *AccountMutation) (Value, error) {
  872. switch m.Op() {
  873. case OpCreate:
  874. return (&AccountCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  875. case OpUpdate:
  876. return (&AccountUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  877. case OpUpdateOne:
  878. return (&AccountUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  879. case OpDelete, OpDeleteOne:
  880. return (&AccountDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  881. default:
  882. return nil, fmt.Errorf("ent: unknown Account mutation op: %q", m.Op())
  883. }
  884. }
  885. // AccountGroupClient is a client for the AccountGroup schema.
  886. type AccountGroupClient struct {
  887. config
  888. }
  889. // NewAccountGroupClient returns a client for the AccountGroup from the given config.
  890. func NewAccountGroupClient(c config) *AccountGroupClient {
  891. return &AccountGroupClient{config: c}
  892. }
  893. // Use adds a list of mutation hooks to the hooks stack.
  894. // A call to `Use(f, g, h)` equals to `accountgroup.Hooks(f(g(h())))`.
  895. func (c *AccountGroupClient) Use(hooks ...Hook) {
  896. c.hooks.AccountGroup = append(c.hooks.AccountGroup, hooks...)
  897. }
  898. // Intercept adds a list of query interceptors to the interceptors stack.
  899. // A call to `Intercept(f, g, h)` equals to `accountgroup.Intercept(f(g(h())))`.
  900. func (c *AccountGroupClient) Intercept(interceptors ...Interceptor) {
  901. c.inters.AccountGroup = append(c.inters.AccountGroup, interceptors...)
  902. }
  903. // Create returns a builder for creating a AccountGroup entity.
  904. func (c *AccountGroupClient) Create() *AccountGroupCreate {
  905. mutation := newAccountGroupMutation(c.config, OpCreate)
  906. return &AccountGroupCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  907. }
  908. // CreateBulk returns a builder for creating a bulk of AccountGroup entities.
  909. func (c *AccountGroupClient) CreateBulk(builders ...*AccountGroupCreate) *AccountGroupCreateBulk {
  910. return &AccountGroupCreateBulk{config: c.config, builders: builders}
  911. }
  912. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  913. // a builder and applies setFunc on it.
  914. func (c *AccountGroupClient) MapCreateBulk(slice any, setFunc func(*AccountGroupCreate, int)) *AccountGroupCreateBulk {
  915. rv := reflect.ValueOf(slice)
  916. if rv.Kind() != reflect.Slice {
  917. return &AccountGroupCreateBulk{err: fmt.Errorf("calling to AccountGroupClient.MapCreateBulk with wrong type %T, need slice", slice)}
  918. }
  919. builders := make([]*AccountGroupCreate, rv.Len())
  920. for i := 0; i < rv.Len(); i++ {
  921. builders[i] = c.Create()
  922. setFunc(builders[i], i)
  923. }
  924. return &AccountGroupCreateBulk{config: c.config, builders: builders}
  925. }
  926. // Update returns an update builder for AccountGroup.
  927. func (c *AccountGroupClient) Update() *AccountGroupUpdate {
  928. mutation := newAccountGroupMutation(c.config, OpUpdate)
  929. return &AccountGroupUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  930. }
  931. // UpdateOne returns an update builder for the given entity.
  932. func (c *AccountGroupClient) UpdateOne(_m *AccountGroup) *AccountGroupUpdateOne {
  933. mutation := newAccountGroupMutation(c.config, OpUpdateOne)
  934. mutation.account = &_m.AccountID
  935. mutation.group = &_m.GroupID
  936. return &AccountGroupUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  937. }
  938. // Delete returns a delete builder for AccountGroup.
  939. func (c *AccountGroupClient) Delete() *AccountGroupDelete {
  940. mutation := newAccountGroupMutation(c.config, OpDelete)
  941. return &AccountGroupDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  942. }
  943. // Query returns a query builder for AccountGroup.
  944. func (c *AccountGroupClient) Query() *AccountGroupQuery {
  945. return &AccountGroupQuery{
  946. config: c.config,
  947. ctx: &QueryContext{Type: TypeAccountGroup},
  948. inters: c.Interceptors(),
  949. }
  950. }
  951. // QueryAccount queries the account edge of a AccountGroup.
  952. func (c *AccountGroupClient) QueryAccount(_m *AccountGroup) *AccountQuery {
  953. return c.Query().
  954. Where(accountgroup.AccountID(_m.AccountID), accountgroup.GroupID(_m.GroupID)).
  955. QueryAccount()
  956. }
  957. // QueryGroup queries the group edge of a AccountGroup.
  958. func (c *AccountGroupClient) QueryGroup(_m *AccountGroup) *GroupQuery {
  959. return c.Query().
  960. Where(accountgroup.AccountID(_m.AccountID), accountgroup.GroupID(_m.GroupID)).
  961. QueryGroup()
  962. }
  963. // Hooks returns the client hooks.
  964. func (c *AccountGroupClient) Hooks() []Hook {
  965. return c.hooks.AccountGroup
  966. }
  967. // Interceptors returns the client interceptors.
  968. func (c *AccountGroupClient) Interceptors() []Interceptor {
  969. return c.inters.AccountGroup
  970. }
  971. func (c *AccountGroupClient) mutate(ctx context.Context, m *AccountGroupMutation) (Value, error) {
  972. switch m.Op() {
  973. case OpCreate:
  974. return (&AccountGroupCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  975. case OpUpdate:
  976. return (&AccountGroupUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  977. case OpUpdateOne:
  978. return (&AccountGroupUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  979. case OpDelete, OpDeleteOne:
  980. return (&AccountGroupDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  981. default:
  982. return nil, fmt.Errorf("ent: unknown AccountGroup mutation op: %q", m.Op())
  983. }
  984. }
  985. // AnnouncementClient is a client for the Announcement schema.
  986. type AnnouncementClient struct {
  987. config
  988. }
  989. // NewAnnouncementClient returns a client for the Announcement from the given config.
  990. func NewAnnouncementClient(c config) *AnnouncementClient {
  991. return &AnnouncementClient{config: c}
  992. }
  993. // Use adds a list of mutation hooks to the hooks stack.
  994. // A call to `Use(f, g, h)` equals to `announcement.Hooks(f(g(h())))`.
  995. func (c *AnnouncementClient) Use(hooks ...Hook) {
  996. c.hooks.Announcement = append(c.hooks.Announcement, hooks...)
  997. }
  998. // Intercept adds a list of query interceptors to the interceptors stack.
  999. // A call to `Intercept(f, g, h)` equals to `announcement.Intercept(f(g(h())))`.
  1000. func (c *AnnouncementClient) Intercept(interceptors ...Interceptor) {
  1001. c.inters.Announcement = append(c.inters.Announcement, interceptors...)
  1002. }
  1003. // Create returns a builder for creating a Announcement entity.
  1004. func (c *AnnouncementClient) Create() *AnnouncementCreate {
  1005. mutation := newAnnouncementMutation(c.config, OpCreate)
  1006. return &AnnouncementCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1007. }
  1008. // CreateBulk returns a builder for creating a bulk of Announcement entities.
  1009. func (c *AnnouncementClient) CreateBulk(builders ...*AnnouncementCreate) *AnnouncementCreateBulk {
  1010. return &AnnouncementCreateBulk{config: c.config, builders: builders}
  1011. }
  1012. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  1013. // a builder and applies setFunc on it.
  1014. func (c *AnnouncementClient) MapCreateBulk(slice any, setFunc func(*AnnouncementCreate, int)) *AnnouncementCreateBulk {
  1015. rv := reflect.ValueOf(slice)
  1016. if rv.Kind() != reflect.Slice {
  1017. return &AnnouncementCreateBulk{err: fmt.Errorf("calling to AnnouncementClient.MapCreateBulk with wrong type %T, need slice", slice)}
  1018. }
  1019. builders := make([]*AnnouncementCreate, rv.Len())
  1020. for i := 0; i < rv.Len(); i++ {
  1021. builders[i] = c.Create()
  1022. setFunc(builders[i], i)
  1023. }
  1024. return &AnnouncementCreateBulk{config: c.config, builders: builders}
  1025. }
  1026. // Update returns an update builder for Announcement.
  1027. func (c *AnnouncementClient) Update() *AnnouncementUpdate {
  1028. mutation := newAnnouncementMutation(c.config, OpUpdate)
  1029. return &AnnouncementUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1030. }
  1031. // UpdateOne returns an update builder for the given entity.
  1032. func (c *AnnouncementClient) UpdateOne(_m *Announcement) *AnnouncementUpdateOne {
  1033. mutation := newAnnouncementMutation(c.config, OpUpdateOne, withAnnouncement(_m))
  1034. return &AnnouncementUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1035. }
  1036. // UpdateOneID returns an update builder for the given id.
  1037. func (c *AnnouncementClient) UpdateOneID(id int64) *AnnouncementUpdateOne {
  1038. mutation := newAnnouncementMutation(c.config, OpUpdateOne, withAnnouncementID(id))
  1039. return &AnnouncementUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1040. }
  1041. // Delete returns a delete builder for Announcement.
  1042. func (c *AnnouncementClient) Delete() *AnnouncementDelete {
  1043. mutation := newAnnouncementMutation(c.config, OpDelete)
  1044. return &AnnouncementDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1045. }
  1046. // DeleteOne returns a builder for deleting the given entity.
  1047. func (c *AnnouncementClient) DeleteOne(_m *Announcement) *AnnouncementDeleteOne {
  1048. return c.DeleteOneID(_m.ID)
  1049. }
  1050. // DeleteOneID returns a builder for deleting the given entity by its id.
  1051. func (c *AnnouncementClient) DeleteOneID(id int64) *AnnouncementDeleteOne {
  1052. builder := c.Delete().Where(announcement.ID(id))
  1053. builder.mutation.id = &id
  1054. builder.mutation.op = OpDeleteOne
  1055. return &AnnouncementDeleteOne{builder}
  1056. }
  1057. // Query returns a query builder for Announcement.
  1058. func (c *AnnouncementClient) Query() *AnnouncementQuery {
  1059. return &AnnouncementQuery{
  1060. config: c.config,
  1061. ctx: &QueryContext{Type: TypeAnnouncement},
  1062. inters: c.Interceptors(),
  1063. }
  1064. }
  1065. // Get returns a Announcement entity by its id.
  1066. func (c *AnnouncementClient) Get(ctx context.Context, id int64) (*Announcement, error) {
  1067. return c.Query().Where(announcement.ID(id)).Only(ctx)
  1068. }
  1069. // GetX is like Get, but panics if an error occurs.
  1070. func (c *AnnouncementClient) GetX(ctx context.Context, id int64) *Announcement {
  1071. obj, err := c.Get(ctx, id)
  1072. if err != nil {
  1073. panic(err)
  1074. }
  1075. return obj
  1076. }
  1077. // QueryReads queries the reads edge of a Announcement.
  1078. func (c *AnnouncementClient) QueryReads(_m *Announcement) *AnnouncementReadQuery {
  1079. query := (&AnnouncementReadClient{config: c.config}).Query()
  1080. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  1081. id := _m.ID
  1082. step := sqlgraph.NewStep(
  1083. sqlgraph.From(announcement.Table, announcement.FieldID, id),
  1084. sqlgraph.To(announcementread.Table, announcementread.FieldID),
  1085. sqlgraph.Edge(sqlgraph.O2M, false, announcement.ReadsTable, announcement.ReadsColumn),
  1086. )
  1087. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  1088. return fromV, nil
  1089. }
  1090. return query
  1091. }
  1092. // Hooks returns the client hooks.
  1093. func (c *AnnouncementClient) Hooks() []Hook {
  1094. return c.hooks.Announcement
  1095. }
  1096. // Interceptors returns the client interceptors.
  1097. func (c *AnnouncementClient) Interceptors() []Interceptor {
  1098. return c.inters.Announcement
  1099. }
  1100. func (c *AnnouncementClient) mutate(ctx context.Context, m *AnnouncementMutation) (Value, error) {
  1101. switch m.Op() {
  1102. case OpCreate:
  1103. return (&AnnouncementCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1104. case OpUpdate:
  1105. return (&AnnouncementUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1106. case OpUpdateOne:
  1107. return (&AnnouncementUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1108. case OpDelete, OpDeleteOne:
  1109. return (&AnnouncementDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  1110. default:
  1111. return nil, fmt.Errorf("ent: unknown Announcement mutation op: %q", m.Op())
  1112. }
  1113. }
  1114. // AnnouncementReadClient is a client for the AnnouncementRead schema.
  1115. type AnnouncementReadClient struct {
  1116. config
  1117. }
  1118. // NewAnnouncementReadClient returns a client for the AnnouncementRead from the given config.
  1119. func NewAnnouncementReadClient(c config) *AnnouncementReadClient {
  1120. return &AnnouncementReadClient{config: c}
  1121. }
  1122. // Use adds a list of mutation hooks to the hooks stack.
  1123. // A call to `Use(f, g, h)` equals to `announcementread.Hooks(f(g(h())))`.
  1124. func (c *AnnouncementReadClient) Use(hooks ...Hook) {
  1125. c.hooks.AnnouncementRead = append(c.hooks.AnnouncementRead, hooks...)
  1126. }
  1127. // Intercept adds a list of query interceptors to the interceptors stack.
  1128. // A call to `Intercept(f, g, h)` equals to `announcementread.Intercept(f(g(h())))`.
  1129. func (c *AnnouncementReadClient) Intercept(interceptors ...Interceptor) {
  1130. c.inters.AnnouncementRead = append(c.inters.AnnouncementRead, interceptors...)
  1131. }
  1132. // Create returns a builder for creating a AnnouncementRead entity.
  1133. func (c *AnnouncementReadClient) Create() *AnnouncementReadCreate {
  1134. mutation := newAnnouncementReadMutation(c.config, OpCreate)
  1135. return &AnnouncementReadCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1136. }
  1137. // CreateBulk returns a builder for creating a bulk of AnnouncementRead entities.
  1138. func (c *AnnouncementReadClient) CreateBulk(builders ...*AnnouncementReadCreate) *AnnouncementReadCreateBulk {
  1139. return &AnnouncementReadCreateBulk{config: c.config, builders: builders}
  1140. }
  1141. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  1142. // a builder and applies setFunc on it.
  1143. func (c *AnnouncementReadClient) MapCreateBulk(slice any, setFunc func(*AnnouncementReadCreate, int)) *AnnouncementReadCreateBulk {
  1144. rv := reflect.ValueOf(slice)
  1145. if rv.Kind() != reflect.Slice {
  1146. return &AnnouncementReadCreateBulk{err: fmt.Errorf("calling to AnnouncementReadClient.MapCreateBulk with wrong type %T, need slice", slice)}
  1147. }
  1148. builders := make([]*AnnouncementReadCreate, rv.Len())
  1149. for i := 0; i < rv.Len(); i++ {
  1150. builders[i] = c.Create()
  1151. setFunc(builders[i], i)
  1152. }
  1153. return &AnnouncementReadCreateBulk{config: c.config, builders: builders}
  1154. }
  1155. // Update returns an update builder for AnnouncementRead.
  1156. func (c *AnnouncementReadClient) Update() *AnnouncementReadUpdate {
  1157. mutation := newAnnouncementReadMutation(c.config, OpUpdate)
  1158. return &AnnouncementReadUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1159. }
  1160. // UpdateOne returns an update builder for the given entity.
  1161. func (c *AnnouncementReadClient) UpdateOne(_m *AnnouncementRead) *AnnouncementReadUpdateOne {
  1162. mutation := newAnnouncementReadMutation(c.config, OpUpdateOne, withAnnouncementRead(_m))
  1163. return &AnnouncementReadUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1164. }
  1165. // UpdateOneID returns an update builder for the given id.
  1166. func (c *AnnouncementReadClient) UpdateOneID(id int64) *AnnouncementReadUpdateOne {
  1167. mutation := newAnnouncementReadMutation(c.config, OpUpdateOne, withAnnouncementReadID(id))
  1168. return &AnnouncementReadUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1169. }
  1170. // Delete returns a delete builder for AnnouncementRead.
  1171. func (c *AnnouncementReadClient) Delete() *AnnouncementReadDelete {
  1172. mutation := newAnnouncementReadMutation(c.config, OpDelete)
  1173. return &AnnouncementReadDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1174. }
  1175. // DeleteOne returns a builder for deleting the given entity.
  1176. func (c *AnnouncementReadClient) DeleteOne(_m *AnnouncementRead) *AnnouncementReadDeleteOne {
  1177. return c.DeleteOneID(_m.ID)
  1178. }
  1179. // DeleteOneID returns a builder for deleting the given entity by its id.
  1180. func (c *AnnouncementReadClient) DeleteOneID(id int64) *AnnouncementReadDeleteOne {
  1181. builder := c.Delete().Where(announcementread.ID(id))
  1182. builder.mutation.id = &id
  1183. builder.mutation.op = OpDeleteOne
  1184. return &AnnouncementReadDeleteOne{builder}
  1185. }
  1186. // Query returns a query builder for AnnouncementRead.
  1187. func (c *AnnouncementReadClient) Query() *AnnouncementReadQuery {
  1188. return &AnnouncementReadQuery{
  1189. config: c.config,
  1190. ctx: &QueryContext{Type: TypeAnnouncementRead},
  1191. inters: c.Interceptors(),
  1192. }
  1193. }
  1194. // Get returns a AnnouncementRead entity by its id.
  1195. func (c *AnnouncementReadClient) Get(ctx context.Context, id int64) (*AnnouncementRead, error) {
  1196. return c.Query().Where(announcementread.ID(id)).Only(ctx)
  1197. }
  1198. // GetX is like Get, but panics if an error occurs.
  1199. func (c *AnnouncementReadClient) GetX(ctx context.Context, id int64) *AnnouncementRead {
  1200. obj, err := c.Get(ctx, id)
  1201. if err != nil {
  1202. panic(err)
  1203. }
  1204. return obj
  1205. }
  1206. // QueryAnnouncement queries the announcement edge of a AnnouncementRead.
  1207. func (c *AnnouncementReadClient) QueryAnnouncement(_m *AnnouncementRead) *AnnouncementQuery {
  1208. query := (&AnnouncementClient{config: c.config}).Query()
  1209. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  1210. id := _m.ID
  1211. step := sqlgraph.NewStep(
  1212. sqlgraph.From(announcementread.Table, announcementread.FieldID, id),
  1213. sqlgraph.To(announcement.Table, announcement.FieldID),
  1214. sqlgraph.Edge(sqlgraph.M2O, true, announcementread.AnnouncementTable, announcementread.AnnouncementColumn),
  1215. )
  1216. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  1217. return fromV, nil
  1218. }
  1219. return query
  1220. }
  1221. // QueryUser queries the user edge of a AnnouncementRead.
  1222. func (c *AnnouncementReadClient) QueryUser(_m *AnnouncementRead) *UserQuery {
  1223. query := (&UserClient{config: c.config}).Query()
  1224. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  1225. id := _m.ID
  1226. step := sqlgraph.NewStep(
  1227. sqlgraph.From(announcementread.Table, announcementread.FieldID, id),
  1228. sqlgraph.To(user.Table, user.FieldID),
  1229. sqlgraph.Edge(sqlgraph.M2O, true, announcementread.UserTable, announcementread.UserColumn),
  1230. )
  1231. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  1232. return fromV, nil
  1233. }
  1234. return query
  1235. }
  1236. // Hooks returns the client hooks.
  1237. func (c *AnnouncementReadClient) Hooks() []Hook {
  1238. return c.hooks.AnnouncementRead
  1239. }
  1240. // Interceptors returns the client interceptors.
  1241. func (c *AnnouncementReadClient) Interceptors() []Interceptor {
  1242. return c.inters.AnnouncementRead
  1243. }
  1244. func (c *AnnouncementReadClient) mutate(ctx context.Context, m *AnnouncementReadMutation) (Value, error) {
  1245. switch m.Op() {
  1246. case OpCreate:
  1247. return (&AnnouncementReadCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1248. case OpUpdate:
  1249. return (&AnnouncementReadUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1250. case OpUpdateOne:
  1251. return (&AnnouncementReadUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1252. case OpDelete, OpDeleteOne:
  1253. return (&AnnouncementReadDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  1254. default:
  1255. return nil, fmt.Errorf("ent: unknown AnnouncementRead mutation op: %q", m.Op())
  1256. }
  1257. }
  1258. // AuthIdentityClient is a client for the AuthIdentity schema.
  1259. type AuthIdentityClient struct {
  1260. config
  1261. }
  1262. // NewAuthIdentityClient returns a client for the AuthIdentity from the given config.
  1263. func NewAuthIdentityClient(c config) *AuthIdentityClient {
  1264. return &AuthIdentityClient{config: c}
  1265. }
  1266. // Use adds a list of mutation hooks to the hooks stack.
  1267. // A call to `Use(f, g, h)` equals to `authidentity.Hooks(f(g(h())))`.
  1268. func (c *AuthIdentityClient) Use(hooks ...Hook) {
  1269. c.hooks.AuthIdentity = append(c.hooks.AuthIdentity, hooks...)
  1270. }
  1271. // Intercept adds a list of query interceptors to the interceptors stack.
  1272. // A call to `Intercept(f, g, h)` equals to `authidentity.Intercept(f(g(h())))`.
  1273. func (c *AuthIdentityClient) Intercept(interceptors ...Interceptor) {
  1274. c.inters.AuthIdentity = append(c.inters.AuthIdentity, interceptors...)
  1275. }
  1276. // Create returns a builder for creating a AuthIdentity entity.
  1277. func (c *AuthIdentityClient) Create() *AuthIdentityCreate {
  1278. mutation := newAuthIdentityMutation(c.config, OpCreate)
  1279. return &AuthIdentityCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1280. }
  1281. // CreateBulk returns a builder for creating a bulk of AuthIdentity entities.
  1282. func (c *AuthIdentityClient) CreateBulk(builders ...*AuthIdentityCreate) *AuthIdentityCreateBulk {
  1283. return &AuthIdentityCreateBulk{config: c.config, builders: builders}
  1284. }
  1285. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  1286. // a builder and applies setFunc on it.
  1287. func (c *AuthIdentityClient) MapCreateBulk(slice any, setFunc func(*AuthIdentityCreate, int)) *AuthIdentityCreateBulk {
  1288. rv := reflect.ValueOf(slice)
  1289. if rv.Kind() != reflect.Slice {
  1290. return &AuthIdentityCreateBulk{err: fmt.Errorf("calling to AuthIdentityClient.MapCreateBulk with wrong type %T, need slice", slice)}
  1291. }
  1292. builders := make([]*AuthIdentityCreate, rv.Len())
  1293. for i := 0; i < rv.Len(); i++ {
  1294. builders[i] = c.Create()
  1295. setFunc(builders[i], i)
  1296. }
  1297. return &AuthIdentityCreateBulk{config: c.config, builders: builders}
  1298. }
  1299. // Update returns an update builder for AuthIdentity.
  1300. func (c *AuthIdentityClient) Update() *AuthIdentityUpdate {
  1301. mutation := newAuthIdentityMutation(c.config, OpUpdate)
  1302. return &AuthIdentityUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1303. }
  1304. // UpdateOne returns an update builder for the given entity.
  1305. func (c *AuthIdentityClient) UpdateOne(_m *AuthIdentity) *AuthIdentityUpdateOne {
  1306. mutation := newAuthIdentityMutation(c.config, OpUpdateOne, withAuthIdentity(_m))
  1307. return &AuthIdentityUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1308. }
  1309. // UpdateOneID returns an update builder for the given id.
  1310. func (c *AuthIdentityClient) UpdateOneID(id int64) *AuthIdentityUpdateOne {
  1311. mutation := newAuthIdentityMutation(c.config, OpUpdateOne, withAuthIdentityID(id))
  1312. return &AuthIdentityUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1313. }
  1314. // Delete returns a delete builder for AuthIdentity.
  1315. func (c *AuthIdentityClient) Delete() *AuthIdentityDelete {
  1316. mutation := newAuthIdentityMutation(c.config, OpDelete)
  1317. return &AuthIdentityDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1318. }
  1319. // DeleteOne returns a builder for deleting the given entity.
  1320. func (c *AuthIdentityClient) DeleteOne(_m *AuthIdentity) *AuthIdentityDeleteOne {
  1321. return c.DeleteOneID(_m.ID)
  1322. }
  1323. // DeleteOneID returns a builder for deleting the given entity by its id.
  1324. func (c *AuthIdentityClient) DeleteOneID(id int64) *AuthIdentityDeleteOne {
  1325. builder := c.Delete().Where(authidentity.ID(id))
  1326. builder.mutation.id = &id
  1327. builder.mutation.op = OpDeleteOne
  1328. return &AuthIdentityDeleteOne{builder}
  1329. }
  1330. // Query returns a query builder for AuthIdentity.
  1331. func (c *AuthIdentityClient) Query() *AuthIdentityQuery {
  1332. return &AuthIdentityQuery{
  1333. config: c.config,
  1334. ctx: &QueryContext{Type: TypeAuthIdentity},
  1335. inters: c.Interceptors(),
  1336. }
  1337. }
  1338. // Get returns a AuthIdentity entity by its id.
  1339. func (c *AuthIdentityClient) Get(ctx context.Context, id int64) (*AuthIdentity, error) {
  1340. return c.Query().Where(authidentity.ID(id)).Only(ctx)
  1341. }
  1342. // GetX is like Get, but panics if an error occurs.
  1343. func (c *AuthIdentityClient) GetX(ctx context.Context, id int64) *AuthIdentity {
  1344. obj, err := c.Get(ctx, id)
  1345. if err != nil {
  1346. panic(err)
  1347. }
  1348. return obj
  1349. }
  1350. // QueryUser queries the user edge of a AuthIdentity.
  1351. func (c *AuthIdentityClient) QueryUser(_m *AuthIdentity) *UserQuery {
  1352. query := (&UserClient{config: c.config}).Query()
  1353. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  1354. id := _m.ID
  1355. step := sqlgraph.NewStep(
  1356. sqlgraph.From(authidentity.Table, authidentity.FieldID, id),
  1357. sqlgraph.To(user.Table, user.FieldID),
  1358. sqlgraph.Edge(sqlgraph.M2O, true, authidentity.UserTable, authidentity.UserColumn),
  1359. )
  1360. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  1361. return fromV, nil
  1362. }
  1363. return query
  1364. }
  1365. // QueryChannels queries the channels edge of a AuthIdentity.
  1366. func (c *AuthIdentityClient) QueryChannels(_m *AuthIdentity) *AuthIdentityChannelQuery {
  1367. query := (&AuthIdentityChannelClient{config: c.config}).Query()
  1368. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  1369. id := _m.ID
  1370. step := sqlgraph.NewStep(
  1371. sqlgraph.From(authidentity.Table, authidentity.FieldID, id),
  1372. sqlgraph.To(authidentitychannel.Table, authidentitychannel.FieldID),
  1373. sqlgraph.Edge(sqlgraph.O2M, false, authidentity.ChannelsTable, authidentity.ChannelsColumn),
  1374. )
  1375. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  1376. return fromV, nil
  1377. }
  1378. return query
  1379. }
  1380. // QueryAdoptionDecisions queries the adoption_decisions edge of a AuthIdentity.
  1381. func (c *AuthIdentityClient) QueryAdoptionDecisions(_m *AuthIdentity) *IdentityAdoptionDecisionQuery {
  1382. query := (&IdentityAdoptionDecisionClient{config: c.config}).Query()
  1383. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  1384. id := _m.ID
  1385. step := sqlgraph.NewStep(
  1386. sqlgraph.From(authidentity.Table, authidentity.FieldID, id),
  1387. sqlgraph.To(identityadoptiondecision.Table, identityadoptiondecision.FieldID),
  1388. sqlgraph.Edge(sqlgraph.O2M, false, authidentity.AdoptionDecisionsTable, authidentity.AdoptionDecisionsColumn),
  1389. )
  1390. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  1391. return fromV, nil
  1392. }
  1393. return query
  1394. }
  1395. // Hooks returns the client hooks.
  1396. func (c *AuthIdentityClient) Hooks() []Hook {
  1397. return c.hooks.AuthIdentity
  1398. }
  1399. // Interceptors returns the client interceptors.
  1400. func (c *AuthIdentityClient) Interceptors() []Interceptor {
  1401. return c.inters.AuthIdentity
  1402. }
  1403. func (c *AuthIdentityClient) mutate(ctx context.Context, m *AuthIdentityMutation) (Value, error) {
  1404. switch m.Op() {
  1405. case OpCreate:
  1406. return (&AuthIdentityCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1407. case OpUpdate:
  1408. return (&AuthIdentityUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1409. case OpUpdateOne:
  1410. return (&AuthIdentityUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1411. case OpDelete, OpDeleteOne:
  1412. return (&AuthIdentityDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  1413. default:
  1414. return nil, fmt.Errorf("ent: unknown AuthIdentity mutation op: %q", m.Op())
  1415. }
  1416. }
  1417. // AuthIdentityChannelClient is a client for the AuthIdentityChannel schema.
  1418. type AuthIdentityChannelClient struct {
  1419. config
  1420. }
  1421. // NewAuthIdentityChannelClient returns a client for the AuthIdentityChannel from the given config.
  1422. func NewAuthIdentityChannelClient(c config) *AuthIdentityChannelClient {
  1423. return &AuthIdentityChannelClient{config: c}
  1424. }
  1425. // Use adds a list of mutation hooks to the hooks stack.
  1426. // A call to `Use(f, g, h)` equals to `authidentitychannel.Hooks(f(g(h())))`.
  1427. func (c *AuthIdentityChannelClient) Use(hooks ...Hook) {
  1428. c.hooks.AuthIdentityChannel = append(c.hooks.AuthIdentityChannel, hooks...)
  1429. }
  1430. // Intercept adds a list of query interceptors to the interceptors stack.
  1431. // A call to `Intercept(f, g, h)` equals to `authidentitychannel.Intercept(f(g(h())))`.
  1432. func (c *AuthIdentityChannelClient) Intercept(interceptors ...Interceptor) {
  1433. c.inters.AuthIdentityChannel = append(c.inters.AuthIdentityChannel, interceptors...)
  1434. }
  1435. // Create returns a builder for creating a AuthIdentityChannel entity.
  1436. func (c *AuthIdentityChannelClient) Create() *AuthIdentityChannelCreate {
  1437. mutation := newAuthIdentityChannelMutation(c.config, OpCreate)
  1438. return &AuthIdentityChannelCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1439. }
  1440. // CreateBulk returns a builder for creating a bulk of AuthIdentityChannel entities.
  1441. func (c *AuthIdentityChannelClient) CreateBulk(builders ...*AuthIdentityChannelCreate) *AuthIdentityChannelCreateBulk {
  1442. return &AuthIdentityChannelCreateBulk{config: c.config, builders: builders}
  1443. }
  1444. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  1445. // a builder and applies setFunc on it.
  1446. func (c *AuthIdentityChannelClient) MapCreateBulk(slice any, setFunc func(*AuthIdentityChannelCreate, int)) *AuthIdentityChannelCreateBulk {
  1447. rv := reflect.ValueOf(slice)
  1448. if rv.Kind() != reflect.Slice {
  1449. return &AuthIdentityChannelCreateBulk{err: fmt.Errorf("calling to AuthIdentityChannelClient.MapCreateBulk with wrong type %T, need slice", slice)}
  1450. }
  1451. builders := make([]*AuthIdentityChannelCreate, rv.Len())
  1452. for i := 0; i < rv.Len(); i++ {
  1453. builders[i] = c.Create()
  1454. setFunc(builders[i], i)
  1455. }
  1456. return &AuthIdentityChannelCreateBulk{config: c.config, builders: builders}
  1457. }
  1458. // Update returns an update builder for AuthIdentityChannel.
  1459. func (c *AuthIdentityChannelClient) Update() *AuthIdentityChannelUpdate {
  1460. mutation := newAuthIdentityChannelMutation(c.config, OpUpdate)
  1461. return &AuthIdentityChannelUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1462. }
  1463. // UpdateOne returns an update builder for the given entity.
  1464. func (c *AuthIdentityChannelClient) UpdateOne(_m *AuthIdentityChannel) *AuthIdentityChannelUpdateOne {
  1465. mutation := newAuthIdentityChannelMutation(c.config, OpUpdateOne, withAuthIdentityChannel(_m))
  1466. return &AuthIdentityChannelUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1467. }
  1468. // UpdateOneID returns an update builder for the given id.
  1469. func (c *AuthIdentityChannelClient) UpdateOneID(id int64) *AuthIdentityChannelUpdateOne {
  1470. mutation := newAuthIdentityChannelMutation(c.config, OpUpdateOne, withAuthIdentityChannelID(id))
  1471. return &AuthIdentityChannelUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1472. }
  1473. // Delete returns a delete builder for AuthIdentityChannel.
  1474. func (c *AuthIdentityChannelClient) Delete() *AuthIdentityChannelDelete {
  1475. mutation := newAuthIdentityChannelMutation(c.config, OpDelete)
  1476. return &AuthIdentityChannelDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1477. }
  1478. // DeleteOne returns a builder for deleting the given entity.
  1479. func (c *AuthIdentityChannelClient) DeleteOne(_m *AuthIdentityChannel) *AuthIdentityChannelDeleteOne {
  1480. return c.DeleteOneID(_m.ID)
  1481. }
  1482. // DeleteOneID returns a builder for deleting the given entity by its id.
  1483. func (c *AuthIdentityChannelClient) DeleteOneID(id int64) *AuthIdentityChannelDeleteOne {
  1484. builder := c.Delete().Where(authidentitychannel.ID(id))
  1485. builder.mutation.id = &id
  1486. builder.mutation.op = OpDeleteOne
  1487. return &AuthIdentityChannelDeleteOne{builder}
  1488. }
  1489. // Query returns a query builder for AuthIdentityChannel.
  1490. func (c *AuthIdentityChannelClient) Query() *AuthIdentityChannelQuery {
  1491. return &AuthIdentityChannelQuery{
  1492. config: c.config,
  1493. ctx: &QueryContext{Type: TypeAuthIdentityChannel},
  1494. inters: c.Interceptors(),
  1495. }
  1496. }
  1497. // Get returns a AuthIdentityChannel entity by its id.
  1498. func (c *AuthIdentityChannelClient) Get(ctx context.Context, id int64) (*AuthIdentityChannel, error) {
  1499. return c.Query().Where(authidentitychannel.ID(id)).Only(ctx)
  1500. }
  1501. // GetX is like Get, but panics if an error occurs.
  1502. func (c *AuthIdentityChannelClient) GetX(ctx context.Context, id int64) *AuthIdentityChannel {
  1503. obj, err := c.Get(ctx, id)
  1504. if err != nil {
  1505. panic(err)
  1506. }
  1507. return obj
  1508. }
  1509. // QueryIdentity queries the identity edge of a AuthIdentityChannel.
  1510. func (c *AuthIdentityChannelClient) QueryIdentity(_m *AuthIdentityChannel) *AuthIdentityQuery {
  1511. query := (&AuthIdentityClient{config: c.config}).Query()
  1512. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  1513. id := _m.ID
  1514. step := sqlgraph.NewStep(
  1515. sqlgraph.From(authidentitychannel.Table, authidentitychannel.FieldID, id),
  1516. sqlgraph.To(authidentity.Table, authidentity.FieldID),
  1517. sqlgraph.Edge(sqlgraph.M2O, true, authidentitychannel.IdentityTable, authidentitychannel.IdentityColumn),
  1518. )
  1519. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  1520. return fromV, nil
  1521. }
  1522. return query
  1523. }
  1524. // Hooks returns the client hooks.
  1525. func (c *AuthIdentityChannelClient) Hooks() []Hook {
  1526. return c.hooks.AuthIdentityChannel
  1527. }
  1528. // Interceptors returns the client interceptors.
  1529. func (c *AuthIdentityChannelClient) Interceptors() []Interceptor {
  1530. return c.inters.AuthIdentityChannel
  1531. }
  1532. func (c *AuthIdentityChannelClient) mutate(ctx context.Context, m *AuthIdentityChannelMutation) (Value, error) {
  1533. switch m.Op() {
  1534. case OpCreate:
  1535. return (&AuthIdentityChannelCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1536. case OpUpdate:
  1537. return (&AuthIdentityChannelUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1538. case OpUpdateOne:
  1539. return (&AuthIdentityChannelUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1540. case OpDelete, OpDeleteOne:
  1541. return (&AuthIdentityChannelDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  1542. default:
  1543. return nil, fmt.Errorf("ent: unknown AuthIdentityChannel mutation op: %q", m.Op())
  1544. }
  1545. }
  1546. // BatchImageEventClient is a client for the BatchImageEvent schema.
  1547. type BatchImageEventClient struct {
  1548. config
  1549. }
  1550. // NewBatchImageEventClient returns a client for the BatchImageEvent from the given config.
  1551. func NewBatchImageEventClient(c config) *BatchImageEventClient {
  1552. return &BatchImageEventClient{config: c}
  1553. }
  1554. // Use adds a list of mutation hooks to the hooks stack.
  1555. // A call to `Use(f, g, h)` equals to `batchimageevent.Hooks(f(g(h())))`.
  1556. func (c *BatchImageEventClient) Use(hooks ...Hook) {
  1557. c.hooks.BatchImageEvent = append(c.hooks.BatchImageEvent, hooks...)
  1558. }
  1559. // Intercept adds a list of query interceptors to the interceptors stack.
  1560. // A call to `Intercept(f, g, h)` equals to `batchimageevent.Intercept(f(g(h())))`.
  1561. func (c *BatchImageEventClient) Intercept(interceptors ...Interceptor) {
  1562. c.inters.BatchImageEvent = append(c.inters.BatchImageEvent, interceptors...)
  1563. }
  1564. // Create returns a builder for creating a BatchImageEvent entity.
  1565. func (c *BatchImageEventClient) Create() *BatchImageEventCreate {
  1566. mutation := newBatchImageEventMutation(c.config, OpCreate)
  1567. return &BatchImageEventCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1568. }
  1569. // CreateBulk returns a builder for creating a bulk of BatchImageEvent entities.
  1570. func (c *BatchImageEventClient) CreateBulk(builders ...*BatchImageEventCreate) *BatchImageEventCreateBulk {
  1571. return &BatchImageEventCreateBulk{config: c.config, builders: builders}
  1572. }
  1573. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  1574. // a builder and applies setFunc on it.
  1575. func (c *BatchImageEventClient) MapCreateBulk(slice any, setFunc func(*BatchImageEventCreate, int)) *BatchImageEventCreateBulk {
  1576. rv := reflect.ValueOf(slice)
  1577. if rv.Kind() != reflect.Slice {
  1578. return &BatchImageEventCreateBulk{err: fmt.Errorf("calling to BatchImageEventClient.MapCreateBulk with wrong type %T, need slice", slice)}
  1579. }
  1580. builders := make([]*BatchImageEventCreate, rv.Len())
  1581. for i := 0; i < rv.Len(); i++ {
  1582. builders[i] = c.Create()
  1583. setFunc(builders[i], i)
  1584. }
  1585. return &BatchImageEventCreateBulk{config: c.config, builders: builders}
  1586. }
  1587. // Update returns an update builder for BatchImageEvent.
  1588. func (c *BatchImageEventClient) Update() *BatchImageEventUpdate {
  1589. mutation := newBatchImageEventMutation(c.config, OpUpdate)
  1590. return &BatchImageEventUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1591. }
  1592. // UpdateOne returns an update builder for the given entity.
  1593. func (c *BatchImageEventClient) UpdateOne(_m *BatchImageEvent) *BatchImageEventUpdateOne {
  1594. mutation := newBatchImageEventMutation(c.config, OpUpdateOne, withBatchImageEvent(_m))
  1595. return &BatchImageEventUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1596. }
  1597. // UpdateOneID returns an update builder for the given id.
  1598. func (c *BatchImageEventClient) UpdateOneID(id int64) *BatchImageEventUpdateOne {
  1599. mutation := newBatchImageEventMutation(c.config, OpUpdateOne, withBatchImageEventID(id))
  1600. return &BatchImageEventUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1601. }
  1602. // Delete returns a delete builder for BatchImageEvent.
  1603. func (c *BatchImageEventClient) Delete() *BatchImageEventDelete {
  1604. mutation := newBatchImageEventMutation(c.config, OpDelete)
  1605. return &BatchImageEventDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1606. }
  1607. // DeleteOne returns a builder for deleting the given entity.
  1608. func (c *BatchImageEventClient) DeleteOne(_m *BatchImageEvent) *BatchImageEventDeleteOne {
  1609. return c.DeleteOneID(_m.ID)
  1610. }
  1611. // DeleteOneID returns a builder for deleting the given entity by its id.
  1612. func (c *BatchImageEventClient) DeleteOneID(id int64) *BatchImageEventDeleteOne {
  1613. builder := c.Delete().Where(batchimageevent.ID(id))
  1614. builder.mutation.id = &id
  1615. builder.mutation.op = OpDeleteOne
  1616. return &BatchImageEventDeleteOne{builder}
  1617. }
  1618. // Query returns a query builder for BatchImageEvent.
  1619. func (c *BatchImageEventClient) Query() *BatchImageEventQuery {
  1620. return &BatchImageEventQuery{
  1621. config: c.config,
  1622. ctx: &QueryContext{Type: TypeBatchImageEvent},
  1623. inters: c.Interceptors(),
  1624. }
  1625. }
  1626. // Get returns a BatchImageEvent entity by its id.
  1627. func (c *BatchImageEventClient) Get(ctx context.Context, id int64) (*BatchImageEvent, error) {
  1628. return c.Query().Where(batchimageevent.ID(id)).Only(ctx)
  1629. }
  1630. // GetX is like Get, but panics if an error occurs.
  1631. func (c *BatchImageEventClient) GetX(ctx context.Context, id int64) *BatchImageEvent {
  1632. obj, err := c.Get(ctx, id)
  1633. if err != nil {
  1634. panic(err)
  1635. }
  1636. return obj
  1637. }
  1638. // Hooks returns the client hooks.
  1639. func (c *BatchImageEventClient) Hooks() []Hook {
  1640. return c.hooks.BatchImageEvent
  1641. }
  1642. // Interceptors returns the client interceptors.
  1643. func (c *BatchImageEventClient) Interceptors() []Interceptor {
  1644. return c.inters.BatchImageEvent
  1645. }
  1646. func (c *BatchImageEventClient) mutate(ctx context.Context, m *BatchImageEventMutation) (Value, error) {
  1647. switch m.Op() {
  1648. case OpCreate:
  1649. return (&BatchImageEventCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1650. case OpUpdate:
  1651. return (&BatchImageEventUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1652. case OpUpdateOne:
  1653. return (&BatchImageEventUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1654. case OpDelete, OpDeleteOne:
  1655. return (&BatchImageEventDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  1656. default:
  1657. return nil, fmt.Errorf("ent: unknown BatchImageEvent mutation op: %q", m.Op())
  1658. }
  1659. }
  1660. // BatchImageItemClient is a client for the BatchImageItem schema.
  1661. type BatchImageItemClient struct {
  1662. config
  1663. }
  1664. // NewBatchImageItemClient returns a client for the BatchImageItem from the given config.
  1665. func NewBatchImageItemClient(c config) *BatchImageItemClient {
  1666. return &BatchImageItemClient{config: c}
  1667. }
  1668. // Use adds a list of mutation hooks to the hooks stack.
  1669. // A call to `Use(f, g, h)` equals to `batchimageitem.Hooks(f(g(h())))`.
  1670. func (c *BatchImageItemClient) Use(hooks ...Hook) {
  1671. c.hooks.BatchImageItem = append(c.hooks.BatchImageItem, hooks...)
  1672. }
  1673. // Intercept adds a list of query interceptors to the interceptors stack.
  1674. // A call to `Intercept(f, g, h)` equals to `batchimageitem.Intercept(f(g(h())))`.
  1675. func (c *BatchImageItemClient) Intercept(interceptors ...Interceptor) {
  1676. c.inters.BatchImageItem = append(c.inters.BatchImageItem, interceptors...)
  1677. }
  1678. // Create returns a builder for creating a BatchImageItem entity.
  1679. func (c *BatchImageItemClient) Create() *BatchImageItemCreate {
  1680. mutation := newBatchImageItemMutation(c.config, OpCreate)
  1681. return &BatchImageItemCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1682. }
  1683. // CreateBulk returns a builder for creating a bulk of BatchImageItem entities.
  1684. func (c *BatchImageItemClient) CreateBulk(builders ...*BatchImageItemCreate) *BatchImageItemCreateBulk {
  1685. return &BatchImageItemCreateBulk{config: c.config, builders: builders}
  1686. }
  1687. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  1688. // a builder and applies setFunc on it.
  1689. func (c *BatchImageItemClient) MapCreateBulk(slice any, setFunc func(*BatchImageItemCreate, int)) *BatchImageItemCreateBulk {
  1690. rv := reflect.ValueOf(slice)
  1691. if rv.Kind() != reflect.Slice {
  1692. return &BatchImageItemCreateBulk{err: fmt.Errorf("calling to BatchImageItemClient.MapCreateBulk with wrong type %T, need slice", slice)}
  1693. }
  1694. builders := make([]*BatchImageItemCreate, rv.Len())
  1695. for i := 0; i < rv.Len(); i++ {
  1696. builders[i] = c.Create()
  1697. setFunc(builders[i], i)
  1698. }
  1699. return &BatchImageItemCreateBulk{config: c.config, builders: builders}
  1700. }
  1701. // Update returns an update builder for BatchImageItem.
  1702. func (c *BatchImageItemClient) Update() *BatchImageItemUpdate {
  1703. mutation := newBatchImageItemMutation(c.config, OpUpdate)
  1704. return &BatchImageItemUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1705. }
  1706. // UpdateOne returns an update builder for the given entity.
  1707. func (c *BatchImageItemClient) UpdateOne(_m *BatchImageItem) *BatchImageItemUpdateOne {
  1708. mutation := newBatchImageItemMutation(c.config, OpUpdateOne, withBatchImageItem(_m))
  1709. return &BatchImageItemUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1710. }
  1711. // UpdateOneID returns an update builder for the given id.
  1712. func (c *BatchImageItemClient) UpdateOneID(id int64) *BatchImageItemUpdateOne {
  1713. mutation := newBatchImageItemMutation(c.config, OpUpdateOne, withBatchImageItemID(id))
  1714. return &BatchImageItemUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1715. }
  1716. // Delete returns a delete builder for BatchImageItem.
  1717. func (c *BatchImageItemClient) Delete() *BatchImageItemDelete {
  1718. mutation := newBatchImageItemMutation(c.config, OpDelete)
  1719. return &BatchImageItemDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1720. }
  1721. // DeleteOne returns a builder for deleting the given entity.
  1722. func (c *BatchImageItemClient) DeleteOne(_m *BatchImageItem) *BatchImageItemDeleteOne {
  1723. return c.DeleteOneID(_m.ID)
  1724. }
  1725. // DeleteOneID returns a builder for deleting the given entity by its id.
  1726. func (c *BatchImageItemClient) DeleteOneID(id int64) *BatchImageItemDeleteOne {
  1727. builder := c.Delete().Where(batchimageitem.ID(id))
  1728. builder.mutation.id = &id
  1729. builder.mutation.op = OpDeleteOne
  1730. return &BatchImageItemDeleteOne{builder}
  1731. }
  1732. // Query returns a query builder for BatchImageItem.
  1733. func (c *BatchImageItemClient) Query() *BatchImageItemQuery {
  1734. return &BatchImageItemQuery{
  1735. config: c.config,
  1736. ctx: &QueryContext{Type: TypeBatchImageItem},
  1737. inters: c.Interceptors(),
  1738. }
  1739. }
  1740. // Get returns a BatchImageItem entity by its id.
  1741. func (c *BatchImageItemClient) Get(ctx context.Context, id int64) (*BatchImageItem, error) {
  1742. return c.Query().Where(batchimageitem.ID(id)).Only(ctx)
  1743. }
  1744. // GetX is like Get, but panics if an error occurs.
  1745. func (c *BatchImageItemClient) GetX(ctx context.Context, id int64) *BatchImageItem {
  1746. obj, err := c.Get(ctx, id)
  1747. if err != nil {
  1748. panic(err)
  1749. }
  1750. return obj
  1751. }
  1752. // Hooks returns the client hooks.
  1753. func (c *BatchImageItemClient) Hooks() []Hook {
  1754. return c.hooks.BatchImageItem
  1755. }
  1756. // Interceptors returns the client interceptors.
  1757. func (c *BatchImageItemClient) Interceptors() []Interceptor {
  1758. return c.inters.BatchImageItem
  1759. }
  1760. func (c *BatchImageItemClient) mutate(ctx context.Context, m *BatchImageItemMutation) (Value, error) {
  1761. switch m.Op() {
  1762. case OpCreate:
  1763. return (&BatchImageItemCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1764. case OpUpdate:
  1765. return (&BatchImageItemUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1766. case OpUpdateOne:
  1767. return (&BatchImageItemUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1768. case OpDelete, OpDeleteOne:
  1769. return (&BatchImageItemDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  1770. default:
  1771. return nil, fmt.Errorf("ent: unknown BatchImageItem mutation op: %q", m.Op())
  1772. }
  1773. }
  1774. // BatchImageJobClient is a client for the BatchImageJob schema.
  1775. type BatchImageJobClient struct {
  1776. config
  1777. }
  1778. // NewBatchImageJobClient returns a client for the BatchImageJob from the given config.
  1779. func NewBatchImageJobClient(c config) *BatchImageJobClient {
  1780. return &BatchImageJobClient{config: c}
  1781. }
  1782. // Use adds a list of mutation hooks to the hooks stack.
  1783. // A call to `Use(f, g, h)` equals to `batchimagejob.Hooks(f(g(h())))`.
  1784. func (c *BatchImageJobClient) Use(hooks ...Hook) {
  1785. c.hooks.BatchImageJob = append(c.hooks.BatchImageJob, hooks...)
  1786. }
  1787. // Intercept adds a list of query interceptors to the interceptors stack.
  1788. // A call to `Intercept(f, g, h)` equals to `batchimagejob.Intercept(f(g(h())))`.
  1789. func (c *BatchImageJobClient) Intercept(interceptors ...Interceptor) {
  1790. c.inters.BatchImageJob = append(c.inters.BatchImageJob, interceptors...)
  1791. }
  1792. // Create returns a builder for creating a BatchImageJob entity.
  1793. func (c *BatchImageJobClient) Create() *BatchImageJobCreate {
  1794. mutation := newBatchImageJobMutation(c.config, OpCreate)
  1795. return &BatchImageJobCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1796. }
  1797. // CreateBulk returns a builder for creating a bulk of BatchImageJob entities.
  1798. func (c *BatchImageJobClient) CreateBulk(builders ...*BatchImageJobCreate) *BatchImageJobCreateBulk {
  1799. return &BatchImageJobCreateBulk{config: c.config, builders: builders}
  1800. }
  1801. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  1802. // a builder and applies setFunc on it.
  1803. func (c *BatchImageJobClient) MapCreateBulk(slice any, setFunc func(*BatchImageJobCreate, int)) *BatchImageJobCreateBulk {
  1804. rv := reflect.ValueOf(slice)
  1805. if rv.Kind() != reflect.Slice {
  1806. return &BatchImageJobCreateBulk{err: fmt.Errorf("calling to BatchImageJobClient.MapCreateBulk with wrong type %T, need slice", slice)}
  1807. }
  1808. builders := make([]*BatchImageJobCreate, rv.Len())
  1809. for i := 0; i < rv.Len(); i++ {
  1810. builders[i] = c.Create()
  1811. setFunc(builders[i], i)
  1812. }
  1813. return &BatchImageJobCreateBulk{config: c.config, builders: builders}
  1814. }
  1815. // Update returns an update builder for BatchImageJob.
  1816. func (c *BatchImageJobClient) Update() *BatchImageJobUpdate {
  1817. mutation := newBatchImageJobMutation(c.config, OpUpdate)
  1818. return &BatchImageJobUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1819. }
  1820. // UpdateOne returns an update builder for the given entity.
  1821. func (c *BatchImageJobClient) UpdateOne(_m *BatchImageJob) *BatchImageJobUpdateOne {
  1822. mutation := newBatchImageJobMutation(c.config, OpUpdateOne, withBatchImageJob(_m))
  1823. return &BatchImageJobUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1824. }
  1825. // UpdateOneID returns an update builder for the given id.
  1826. func (c *BatchImageJobClient) UpdateOneID(id int64) *BatchImageJobUpdateOne {
  1827. mutation := newBatchImageJobMutation(c.config, OpUpdateOne, withBatchImageJobID(id))
  1828. return &BatchImageJobUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1829. }
  1830. // Delete returns a delete builder for BatchImageJob.
  1831. func (c *BatchImageJobClient) Delete() *BatchImageJobDelete {
  1832. mutation := newBatchImageJobMutation(c.config, OpDelete)
  1833. return &BatchImageJobDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1834. }
  1835. // DeleteOne returns a builder for deleting the given entity.
  1836. func (c *BatchImageJobClient) DeleteOne(_m *BatchImageJob) *BatchImageJobDeleteOne {
  1837. return c.DeleteOneID(_m.ID)
  1838. }
  1839. // DeleteOneID returns a builder for deleting the given entity by its id.
  1840. func (c *BatchImageJobClient) DeleteOneID(id int64) *BatchImageJobDeleteOne {
  1841. builder := c.Delete().Where(batchimagejob.ID(id))
  1842. builder.mutation.id = &id
  1843. builder.mutation.op = OpDeleteOne
  1844. return &BatchImageJobDeleteOne{builder}
  1845. }
  1846. // Query returns a query builder for BatchImageJob.
  1847. func (c *BatchImageJobClient) Query() *BatchImageJobQuery {
  1848. return &BatchImageJobQuery{
  1849. config: c.config,
  1850. ctx: &QueryContext{Type: TypeBatchImageJob},
  1851. inters: c.Interceptors(),
  1852. }
  1853. }
  1854. // Get returns a BatchImageJob entity by its id.
  1855. func (c *BatchImageJobClient) Get(ctx context.Context, id int64) (*BatchImageJob, error) {
  1856. return c.Query().Where(batchimagejob.ID(id)).Only(ctx)
  1857. }
  1858. // GetX is like Get, but panics if an error occurs.
  1859. func (c *BatchImageJobClient) GetX(ctx context.Context, id int64) *BatchImageJob {
  1860. obj, err := c.Get(ctx, id)
  1861. if err != nil {
  1862. panic(err)
  1863. }
  1864. return obj
  1865. }
  1866. // Hooks returns the client hooks.
  1867. func (c *BatchImageJobClient) Hooks() []Hook {
  1868. return c.hooks.BatchImageJob
  1869. }
  1870. // Interceptors returns the client interceptors.
  1871. func (c *BatchImageJobClient) Interceptors() []Interceptor {
  1872. return c.inters.BatchImageJob
  1873. }
  1874. func (c *BatchImageJobClient) mutate(ctx context.Context, m *BatchImageJobMutation) (Value, error) {
  1875. switch m.Op() {
  1876. case OpCreate:
  1877. return (&BatchImageJobCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1878. case OpUpdate:
  1879. return (&BatchImageJobUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1880. case OpUpdateOne:
  1881. return (&BatchImageJobUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  1882. case OpDelete, OpDeleteOne:
  1883. return (&BatchImageJobDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  1884. default:
  1885. return nil, fmt.Errorf("ent: unknown BatchImageJob mutation op: %q", m.Op())
  1886. }
  1887. }
  1888. // ChannelMonitorClient is a client for the ChannelMonitor schema.
  1889. type ChannelMonitorClient struct {
  1890. config
  1891. }
  1892. // NewChannelMonitorClient returns a client for the ChannelMonitor from the given config.
  1893. func NewChannelMonitorClient(c config) *ChannelMonitorClient {
  1894. return &ChannelMonitorClient{config: c}
  1895. }
  1896. // Use adds a list of mutation hooks to the hooks stack.
  1897. // A call to `Use(f, g, h)` equals to `channelmonitor.Hooks(f(g(h())))`.
  1898. func (c *ChannelMonitorClient) Use(hooks ...Hook) {
  1899. c.hooks.ChannelMonitor = append(c.hooks.ChannelMonitor, hooks...)
  1900. }
  1901. // Intercept adds a list of query interceptors to the interceptors stack.
  1902. // A call to `Intercept(f, g, h)` equals to `channelmonitor.Intercept(f(g(h())))`.
  1903. func (c *ChannelMonitorClient) Intercept(interceptors ...Interceptor) {
  1904. c.inters.ChannelMonitor = append(c.inters.ChannelMonitor, interceptors...)
  1905. }
  1906. // Create returns a builder for creating a ChannelMonitor entity.
  1907. func (c *ChannelMonitorClient) Create() *ChannelMonitorCreate {
  1908. mutation := newChannelMonitorMutation(c.config, OpCreate)
  1909. return &ChannelMonitorCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1910. }
  1911. // CreateBulk returns a builder for creating a bulk of ChannelMonitor entities.
  1912. func (c *ChannelMonitorClient) CreateBulk(builders ...*ChannelMonitorCreate) *ChannelMonitorCreateBulk {
  1913. return &ChannelMonitorCreateBulk{config: c.config, builders: builders}
  1914. }
  1915. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  1916. // a builder and applies setFunc on it.
  1917. func (c *ChannelMonitorClient) MapCreateBulk(slice any, setFunc func(*ChannelMonitorCreate, int)) *ChannelMonitorCreateBulk {
  1918. rv := reflect.ValueOf(slice)
  1919. if rv.Kind() != reflect.Slice {
  1920. return &ChannelMonitorCreateBulk{err: fmt.Errorf("calling to ChannelMonitorClient.MapCreateBulk with wrong type %T, need slice", slice)}
  1921. }
  1922. builders := make([]*ChannelMonitorCreate, rv.Len())
  1923. for i := 0; i < rv.Len(); i++ {
  1924. builders[i] = c.Create()
  1925. setFunc(builders[i], i)
  1926. }
  1927. return &ChannelMonitorCreateBulk{config: c.config, builders: builders}
  1928. }
  1929. // Update returns an update builder for ChannelMonitor.
  1930. func (c *ChannelMonitorClient) Update() *ChannelMonitorUpdate {
  1931. mutation := newChannelMonitorMutation(c.config, OpUpdate)
  1932. return &ChannelMonitorUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1933. }
  1934. // UpdateOne returns an update builder for the given entity.
  1935. func (c *ChannelMonitorClient) UpdateOne(_m *ChannelMonitor) *ChannelMonitorUpdateOne {
  1936. mutation := newChannelMonitorMutation(c.config, OpUpdateOne, withChannelMonitor(_m))
  1937. return &ChannelMonitorUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1938. }
  1939. // UpdateOneID returns an update builder for the given id.
  1940. func (c *ChannelMonitorClient) UpdateOneID(id int64) *ChannelMonitorUpdateOne {
  1941. mutation := newChannelMonitorMutation(c.config, OpUpdateOne, withChannelMonitorID(id))
  1942. return &ChannelMonitorUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1943. }
  1944. // Delete returns a delete builder for ChannelMonitor.
  1945. func (c *ChannelMonitorClient) Delete() *ChannelMonitorDelete {
  1946. mutation := newChannelMonitorMutation(c.config, OpDelete)
  1947. return &ChannelMonitorDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  1948. }
  1949. // DeleteOne returns a builder for deleting the given entity.
  1950. func (c *ChannelMonitorClient) DeleteOne(_m *ChannelMonitor) *ChannelMonitorDeleteOne {
  1951. return c.DeleteOneID(_m.ID)
  1952. }
  1953. // DeleteOneID returns a builder for deleting the given entity by its id.
  1954. func (c *ChannelMonitorClient) DeleteOneID(id int64) *ChannelMonitorDeleteOne {
  1955. builder := c.Delete().Where(channelmonitor.ID(id))
  1956. builder.mutation.id = &id
  1957. builder.mutation.op = OpDeleteOne
  1958. return &ChannelMonitorDeleteOne{builder}
  1959. }
  1960. // Query returns a query builder for ChannelMonitor.
  1961. func (c *ChannelMonitorClient) Query() *ChannelMonitorQuery {
  1962. return &ChannelMonitorQuery{
  1963. config: c.config,
  1964. ctx: &QueryContext{Type: TypeChannelMonitor},
  1965. inters: c.Interceptors(),
  1966. }
  1967. }
  1968. // Get returns a ChannelMonitor entity by its id.
  1969. func (c *ChannelMonitorClient) Get(ctx context.Context, id int64) (*ChannelMonitor, error) {
  1970. return c.Query().Where(channelmonitor.ID(id)).Only(ctx)
  1971. }
  1972. // GetX is like Get, but panics if an error occurs.
  1973. func (c *ChannelMonitorClient) GetX(ctx context.Context, id int64) *ChannelMonitor {
  1974. obj, err := c.Get(ctx, id)
  1975. if err != nil {
  1976. panic(err)
  1977. }
  1978. return obj
  1979. }
  1980. // QueryHistory queries the history edge of a ChannelMonitor.
  1981. func (c *ChannelMonitorClient) QueryHistory(_m *ChannelMonitor) *ChannelMonitorHistoryQuery {
  1982. query := (&ChannelMonitorHistoryClient{config: c.config}).Query()
  1983. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  1984. id := _m.ID
  1985. step := sqlgraph.NewStep(
  1986. sqlgraph.From(channelmonitor.Table, channelmonitor.FieldID, id),
  1987. sqlgraph.To(channelmonitorhistory.Table, channelmonitorhistory.FieldID),
  1988. sqlgraph.Edge(sqlgraph.O2M, false, channelmonitor.HistoryTable, channelmonitor.HistoryColumn),
  1989. )
  1990. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  1991. return fromV, nil
  1992. }
  1993. return query
  1994. }
  1995. // QueryDailyRollups queries the daily_rollups edge of a ChannelMonitor.
  1996. func (c *ChannelMonitorClient) QueryDailyRollups(_m *ChannelMonitor) *ChannelMonitorDailyRollupQuery {
  1997. query := (&ChannelMonitorDailyRollupClient{config: c.config}).Query()
  1998. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  1999. id := _m.ID
  2000. step := sqlgraph.NewStep(
  2001. sqlgraph.From(channelmonitor.Table, channelmonitor.FieldID, id),
  2002. sqlgraph.To(channelmonitordailyrollup.Table, channelmonitordailyrollup.FieldID),
  2003. sqlgraph.Edge(sqlgraph.O2M, false, channelmonitor.DailyRollupsTable, channelmonitor.DailyRollupsColumn),
  2004. )
  2005. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  2006. return fromV, nil
  2007. }
  2008. return query
  2009. }
  2010. // QueryRequestTemplate queries the request_template edge of a ChannelMonitor.
  2011. func (c *ChannelMonitorClient) QueryRequestTemplate(_m *ChannelMonitor) *ChannelMonitorRequestTemplateQuery {
  2012. query := (&ChannelMonitorRequestTemplateClient{config: c.config}).Query()
  2013. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  2014. id := _m.ID
  2015. step := sqlgraph.NewStep(
  2016. sqlgraph.From(channelmonitor.Table, channelmonitor.FieldID, id),
  2017. sqlgraph.To(channelmonitorrequesttemplate.Table, channelmonitorrequesttemplate.FieldID),
  2018. sqlgraph.Edge(sqlgraph.M2O, false, channelmonitor.RequestTemplateTable, channelmonitor.RequestTemplateColumn),
  2019. )
  2020. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  2021. return fromV, nil
  2022. }
  2023. return query
  2024. }
  2025. // Hooks returns the client hooks.
  2026. func (c *ChannelMonitorClient) Hooks() []Hook {
  2027. return c.hooks.ChannelMonitor
  2028. }
  2029. // Interceptors returns the client interceptors.
  2030. func (c *ChannelMonitorClient) Interceptors() []Interceptor {
  2031. return c.inters.ChannelMonitor
  2032. }
  2033. func (c *ChannelMonitorClient) mutate(ctx context.Context, m *ChannelMonitorMutation) (Value, error) {
  2034. switch m.Op() {
  2035. case OpCreate:
  2036. return (&ChannelMonitorCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2037. case OpUpdate:
  2038. return (&ChannelMonitorUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2039. case OpUpdateOne:
  2040. return (&ChannelMonitorUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2041. case OpDelete, OpDeleteOne:
  2042. return (&ChannelMonitorDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  2043. default:
  2044. return nil, fmt.Errorf("ent: unknown ChannelMonitor mutation op: %q", m.Op())
  2045. }
  2046. }
  2047. // ChannelMonitorDailyRollupClient is a client for the ChannelMonitorDailyRollup schema.
  2048. type ChannelMonitorDailyRollupClient struct {
  2049. config
  2050. }
  2051. // NewChannelMonitorDailyRollupClient returns a client for the ChannelMonitorDailyRollup from the given config.
  2052. func NewChannelMonitorDailyRollupClient(c config) *ChannelMonitorDailyRollupClient {
  2053. return &ChannelMonitorDailyRollupClient{config: c}
  2054. }
  2055. // Use adds a list of mutation hooks to the hooks stack.
  2056. // A call to `Use(f, g, h)` equals to `channelmonitordailyrollup.Hooks(f(g(h())))`.
  2057. func (c *ChannelMonitorDailyRollupClient) Use(hooks ...Hook) {
  2058. c.hooks.ChannelMonitorDailyRollup = append(c.hooks.ChannelMonitorDailyRollup, hooks...)
  2059. }
  2060. // Intercept adds a list of query interceptors to the interceptors stack.
  2061. // A call to `Intercept(f, g, h)` equals to `channelmonitordailyrollup.Intercept(f(g(h())))`.
  2062. func (c *ChannelMonitorDailyRollupClient) Intercept(interceptors ...Interceptor) {
  2063. c.inters.ChannelMonitorDailyRollup = append(c.inters.ChannelMonitorDailyRollup, interceptors...)
  2064. }
  2065. // Create returns a builder for creating a ChannelMonitorDailyRollup entity.
  2066. func (c *ChannelMonitorDailyRollupClient) Create() *ChannelMonitorDailyRollupCreate {
  2067. mutation := newChannelMonitorDailyRollupMutation(c.config, OpCreate)
  2068. return &ChannelMonitorDailyRollupCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2069. }
  2070. // CreateBulk returns a builder for creating a bulk of ChannelMonitorDailyRollup entities.
  2071. func (c *ChannelMonitorDailyRollupClient) CreateBulk(builders ...*ChannelMonitorDailyRollupCreate) *ChannelMonitorDailyRollupCreateBulk {
  2072. return &ChannelMonitorDailyRollupCreateBulk{config: c.config, builders: builders}
  2073. }
  2074. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  2075. // a builder and applies setFunc on it.
  2076. func (c *ChannelMonitorDailyRollupClient) MapCreateBulk(slice any, setFunc func(*ChannelMonitorDailyRollupCreate, int)) *ChannelMonitorDailyRollupCreateBulk {
  2077. rv := reflect.ValueOf(slice)
  2078. if rv.Kind() != reflect.Slice {
  2079. return &ChannelMonitorDailyRollupCreateBulk{err: fmt.Errorf("calling to ChannelMonitorDailyRollupClient.MapCreateBulk with wrong type %T, need slice", slice)}
  2080. }
  2081. builders := make([]*ChannelMonitorDailyRollupCreate, rv.Len())
  2082. for i := 0; i < rv.Len(); i++ {
  2083. builders[i] = c.Create()
  2084. setFunc(builders[i], i)
  2085. }
  2086. return &ChannelMonitorDailyRollupCreateBulk{config: c.config, builders: builders}
  2087. }
  2088. // Update returns an update builder for ChannelMonitorDailyRollup.
  2089. func (c *ChannelMonitorDailyRollupClient) Update() *ChannelMonitorDailyRollupUpdate {
  2090. mutation := newChannelMonitorDailyRollupMutation(c.config, OpUpdate)
  2091. return &ChannelMonitorDailyRollupUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2092. }
  2093. // UpdateOne returns an update builder for the given entity.
  2094. func (c *ChannelMonitorDailyRollupClient) UpdateOne(_m *ChannelMonitorDailyRollup) *ChannelMonitorDailyRollupUpdateOne {
  2095. mutation := newChannelMonitorDailyRollupMutation(c.config, OpUpdateOne, withChannelMonitorDailyRollup(_m))
  2096. return &ChannelMonitorDailyRollupUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2097. }
  2098. // UpdateOneID returns an update builder for the given id.
  2099. func (c *ChannelMonitorDailyRollupClient) UpdateOneID(id int64) *ChannelMonitorDailyRollupUpdateOne {
  2100. mutation := newChannelMonitorDailyRollupMutation(c.config, OpUpdateOne, withChannelMonitorDailyRollupID(id))
  2101. return &ChannelMonitorDailyRollupUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2102. }
  2103. // Delete returns a delete builder for ChannelMonitorDailyRollup.
  2104. func (c *ChannelMonitorDailyRollupClient) Delete() *ChannelMonitorDailyRollupDelete {
  2105. mutation := newChannelMonitorDailyRollupMutation(c.config, OpDelete)
  2106. return &ChannelMonitorDailyRollupDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2107. }
  2108. // DeleteOne returns a builder for deleting the given entity.
  2109. func (c *ChannelMonitorDailyRollupClient) DeleteOne(_m *ChannelMonitorDailyRollup) *ChannelMonitorDailyRollupDeleteOne {
  2110. return c.DeleteOneID(_m.ID)
  2111. }
  2112. // DeleteOneID returns a builder for deleting the given entity by its id.
  2113. func (c *ChannelMonitorDailyRollupClient) DeleteOneID(id int64) *ChannelMonitorDailyRollupDeleteOne {
  2114. builder := c.Delete().Where(channelmonitordailyrollup.ID(id))
  2115. builder.mutation.id = &id
  2116. builder.mutation.op = OpDeleteOne
  2117. return &ChannelMonitorDailyRollupDeleteOne{builder}
  2118. }
  2119. // Query returns a query builder for ChannelMonitorDailyRollup.
  2120. func (c *ChannelMonitorDailyRollupClient) Query() *ChannelMonitorDailyRollupQuery {
  2121. return &ChannelMonitorDailyRollupQuery{
  2122. config: c.config,
  2123. ctx: &QueryContext{Type: TypeChannelMonitorDailyRollup},
  2124. inters: c.Interceptors(),
  2125. }
  2126. }
  2127. // Get returns a ChannelMonitorDailyRollup entity by its id.
  2128. func (c *ChannelMonitorDailyRollupClient) Get(ctx context.Context, id int64) (*ChannelMonitorDailyRollup, error) {
  2129. return c.Query().Where(channelmonitordailyrollup.ID(id)).Only(ctx)
  2130. }
  2131. // GetX is like Get, but panics if an error occurs.
  2132. func (c *ChannelMonitorDailyRollupClient) GetX(ctx context.Context, id int64) *ChannelMonitorDailyRollup {
  2133. obj, err := c.Get(ctx, id)
  2134. if err != nil {
  2135. panic(err)
  2136. }
  2137. return obj
  2138. }
  2139. // QueryMonitor queries the monitor edge of a ChannelMonitorDailyRollup.
  2140. func (c *ChannelMonitorDailyRollupClient) QueryMonitor(_m *ChannelMonitorDailyRollup) *ChannelMonitorQuery {
  2141. query := (&ChannelMonitorClient{config: c.config}).Query()
  2142. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  2143. id := _m.ID
  2144. step := sqlgraph.NewStep(
  2145. sqlgraph.From(channelmonitordailyrollup.Table, channelmonitordailyrollup.FieldID, id),
  2146. sqlgraph.To(channelmonitor.Table, channelmonitor.FieldID),
  2147. sqlgraph.Edge(sqlgraph.M2O, true, channelmonitordailyrollup.MonitorTable, channelmonitordailyrollup.MonitorColumn),
  2148. )
  2149. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  2150. return fromV, nil
  2151. }
  2152. return query
  2153. }
  2154. // Hooks returns the client hooks.
  2155. func (c *ChannelMonitorDailyRollupClient) Hooks() []Hook {
  2156. return c.hooks.ChannelMonitorDailyRollup
  2157. }
  2158. // Interceptors returns the client interceptors.
  2159. func (c *ChannelMonitorDailyRollupClient) Interceptors() []Interceptor {
  2160. return c.inters.ChannelMonitorDailyRollup
  2161. }
  2162. func (c *ChannelMonitorDailyRollupClient) mutate(ctx context.Context, m *ChannelMonitorDailyRollupMutation) (Value, error) {
  2163. switch m.Op() {
  2164. case OpCreate:
  2165. return (&ChannelMonitorDailyRollupCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2166. case OpUpdate:
  2167. return (&ChannelMonitorDailyRollupUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2168. case OpUpdateOne:
  2169. return (&ChannelMonitorDailyRollupUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2170. case OpDelete, OpDeleteOne:
  2171. return (&ChannelMonitorDailyRollupDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  2172. default:
  2173. return nil, fmt.Errorf("ent: unknown ChannelMonitorDailyRollup mutation op: %q", m.Op())
  2174. }
  2175. }
  2176. // ChannelMonitorHistoryClient is a client for the ChannelMonitorHistory schema.
  2177. type ChannelMonitorHistoryClient struct {
  2178. config
  2179. }
  2180. // NewChannelMonitorHistoryClient returns a client for the ChannelMonitorHistory from the given config.
  2181. func NewChannelMonitorHistoryClient(c config) *ChannelMonitorHistoryClient {
  2182. return &ChannelMonitorHistoryClient{config: c}
  2183. }
  2184. // Use adds a list of mutation hooks to the hooks stack.
  2185. // A call to `Use(f, g, h)` equals to `channelmonitorhistory.Hooks(f(g(h())))`.
  2186. func (c *ChannelMonitorHistoryClient) Use(hooks ...Hook) {
  2187. c.hooks.ChannelMonitorHistory = append(c.hooks.ChannelMonitorHistory, hooks...)
  2188. }
  2189. // Intercept adds a list of query interceptors to the interceptors stack.
  2190. // A call to `Intercept(f, g, h)` equals to `channelmonitorhistory.Intercept(f(g(h())))`.
  2191. func (c *ChannelMonitorHistoryClient) Intercept(interceptors ...Interceptor) {
  2192. c.inters.ChannelMonitorHistory = append(c.inters.ChannelMonitorHistory, interceptors...)
  2193. }
  2194. // Create returns a builder for creating a ChannelMonitorHistory entity.
  2195. func (c *ChannelMonitorHistoryClient) Create() *ChannelMonitorHistoryCreate {
  2196. mutation := newChannelMonitorHistoryMutation(c.config, OpCreate)
  2197. return &ChannelMonitorHistoryCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2198. }
  2199. // CreateBulk returns a builder for creating a bulk of ChannelMonitorHistory entities.
  2200. func (c *ChannelMonitorHistoryClient) CreateBulk(builders ...*ChannelMonitorHistoryCreate) *ChannelMonitorHistoryCreateBulk {
  2201. return &ChannelMonitorHistoryCreateBulk{config: c.config, builders: builders}
  2202. }
  2203. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  2204. // a builder and applies setFunc on it.
  2205. func (c *ChannelMonitorHistoryClient) MapCreateBulk(slice any, setFunc func(*ChannelMonitorHistoryCreate, int)) *ChannelMonitorHistoryCreateBulk {
  2206. rv := reflect.ValueOf(slice)
  2207. if rv.Kind() != reflect.Slice {
  2208. return &ChannelMonitorHistoryCreateBulk{err: fmt.Errorf("calling to ChannelMonitorHistoryClient.MapCreateBulk with wrong type %T, need slice", slice)}
  2209. }
  2210. builders := make([]*ChannelMonitorHistoryCreate, rv.Len())
  2211. for i := 0; i < rv.Len(); i++ {
  2212. builders[i] = c.Create()
  2213. setFunc(builders[i], i)
  2214. }
  2215. return &ChannelMonitorHistoryCreateBulk{config: c.config, builders: builders}
  2216. }
  2217. // Update returns an update builder for ChannelMonitorHistory.
  2218. func (c *ChannelMonitorHistoryClient) Update() *ChannelMonitorHistoryUpdate {
  2219. mutation := newChannelMonitorHistoryMutation(c.config, OpUpdate)
  2220. return &ChannelMonitorHistoryUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2221. }
  2222. // UpdateOne returns an update builder for the given entity.
  2223. func (c *ChannelMonitorHistoryClient) UpdateOne(_m *ChannelMonitorHistory) *ChannelMonitorHistoryUpdateOne {
  2224. mutation := newChannelMonitorHistoryMutation(c.config, OpUpdateOne, withChannelMonitorHistory(_m))
  2225. return &ChannelMonitorHistoryUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2226. }
  2227. // UpdateOneID returns an update builder for the given id.
  2228. func (c *ChannelMonitorHistoryClient) UpdateOneID(id int64) *ChannelMonitorHistoryUpdateOne {
  2229. mutation := newChannelMonitorHistoryMutation(c.config, OpUpdateOne, withChannelMonitorHistoryID(id))
  2230. return &ChannelMonitorHistoryUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2231. }
  2232. // Delete returns a delete builder for ChannelMonitorHistory.
  2233. func (c *ChannelMonitorHistoryClient) Delete() *ChannelMonitorHistoryDelete {
  2234. mutation := newChannelMonitorHistoryMutation(c.config, OpDelete)
  2235. return &ChannelMonitorHistoryDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2236. }
  2237. // DeleteOne returns a builder for deleting the given entity.
  2238. func (c *ChannelMonitorHistoryClient) DeleteOne(_m *ChannelMonitorHistory) *ChannelMonitorHistoryDeleteOne {
  2239. return c.DeleteOneID(_m.ID)
  2240. }
  2241. // DeleteOneID returns a builder for deleting the given entity by its id.
  2242. func (c *ChannelMonitorHistoryClient) DeleteOneID(id int64) *ChannelMonitorHistoryDeleteOne {
  2243. builder := c.Delete().Where(channelmonitorhistory.ID(id))
  2244. builder.mutation.id = &id
  2245. builder.mutation.op = OpDeleteOne
  2246. return &ChannelMonitorHistoryDeleteOne{builder}
  2247. }
  2248. // Query returns a query builder for ChannelMonitorHistory.
  2249. func (c *ChannelMonitorHistoryClient) Query() *ChannelMonitorHistoryQuery {
  2250. return &ChannelMonitorHistoryQuery{
  2251. config: c.config,
  2252. ctx: &QueryContext{Type: TypeChannelMonitorHistory},
  2253. inters: c.Interceptors(),
  2254. }
  2255. }
  2256. // Get returns a ChannelMonitorHistory entity by its id.
  2257. func (c *ChannelMonitorHistoryClient) Get(ctx context.Context, id int64) (*ChannelMonitorHistory, error) {
  2258. return c.Query().Where(channelmonitorhistory.ID(id)).Only(ctx)
  2259. }
  2260. // GetX is like Get, but panics if an error occurs.
  2261. func (c *ChannelMonitorHistoryClient) GetX(ctx context.Context, id int64) *ChannelMonitorHistory {
  2262. obj, err := c.Get(ctx, id)
  2263. if err != nil {
  2264. panic(err)
  2265. }
  2266. return obj
  2267. }
  2268. // QueryMonitor queries the monitor edge of a ChannelMonitorHistory.
  2269. func (c *ChannelMonitorHistoryClient) QueryMonitor(_m *ChannelMonitorHistory) *ChannelMonitorQuery {
  2270. query := (&ChannelMonitorClient{config: c.config}).Query()
  2271. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  2272. id := _m.ID
  2273. step := sqlgraph.NewStep(
  2274. sqlgraph.From(channelmonitorhistory.Table, channelmonitorhistory.FieldID, id),
  2275. sqlgraph.To(channelmonitor.Table, channelmonitor.FieldID),
  2276. sqlgraph.Edge(sqlgraph.M2O, true, channelmonitorhistory.MonitorTable, channelmonitorhistory.MonitorColumn),
  2277. )
  2278. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  2279. return fromV, nil
  2280. }
  2281. return query
  2282. }
  2283. // Hooks returns the client hooks.
  2284. func (c *ChannelMonitorHistoryClient) Hooks() []Hook {
  2285. return c.hooks.ChannelMonitorHistory
  2286. }
  2287. // Interceptors returns the client interceptors.
  2288. func (c *ChannelMonitorHistoryClient) Interceptors() []Interceptor {
  2289. return c.inters.ChannelMonitorHistory
  2290. }
  2291. func (c *ChannelMonitorHistoryClient) mutate(ctx context.Context, m *ChannelMonitorHistoryMutation) (Value, error) {
  2292. switch m.Op() {
  2293. case OpCreate:
  2294. return (&ChannelMonitorHistoryCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2295. case OpUpdate:
  2296. return (&ChannelMonitorHistoryUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2297. case OpUpdateOne:
  2298. return (&ChannelMonitorHistoryUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2299. case OpDelete, OpDeleteOne:
  2300. return (&ChannelMonitorHistoryDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  2301. default:
  2302. return nil, fmt.Errorf("ent: unknown ChannelMonitorHistory mutation op: %q", m.Op())
  2303. }
  2304. }
  2305. // ChannelMonitorRequestTemplateClient is a client for the ChannelMonitorRequestTemplate schema.
  2306. type ChannelMonitorRequestTemplateClient struct {
  2307. config
  2308. }
  2309. // NewChannelMonitorRequestTemplateClient returns a client for the ChannelMonitorRequestTemplate from the given config.
  2310. func NewChannelMonitorRequestTemplateClient(c config) *ChannelMonitorRequestTemplateClient {
  2311. return &ChannelMonitorRequestTemplateClient{config: c}
  2312. }
  2313. // Use adds a list of mutation hooks to the hooks stack.
  2314. // A call to `Use(f, g, h)` equals to `channelmonitorrequesttemplate.Hooks(f(g(h())))`.
  2315. func (c *ChannelMonitorRequestTemplateClient) Use(hooks ...Hook) {
  2316. c.hooks.ChannelMonitorRequestTemplate = append(c.hooks.ChannelMonitorRequestTemplate, hooks...)
  2317. }
  2318. // Intercept adds a list of query interceptors to the interceptors stack.
  2319. // A call to `Intercept(f, g, h)` equals to `channelmonitorrequesttemplate.Intercept(f(g(h())))`.
  2320. func (c *ChannelMonitorRequestTemplateClient) Intercept(interceptors ...Interceptor) {
  2321. c.inters.ChannelMonitorRequestTemplate = append(c.inters.ChannelMonitorRequestTemplate, interceptors...)
  2322. }
  2323. // Create returns a builder for creating a ChannelMonitorRequestTemplate entity.
  2324. func (c *ChannelMonitorRequestTemplateClient) Create() *ChannelMonitorRequestTemplateCreate {
  2325. mutation := newChannelMonitorRequestTemplateMutation(c.config, OpCreate)
  2326. return &ChannelMonitorRequestTemplateCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2327. }
  2328. // CreateBulk returns a builder for creating a bulk of ChannelMonitorRequestTemplate entities.
  2329. func (c *ChannelMonitorRequestTemplateClient) CreateBulk(builders ...*ChannelMonitorRequestTemplateCreate) *ChannelMonitorRequestTemplateCreateBulk {
  2330. return &ChannelMonitorRequestTemplateCreateBulk{config: c.config, builders: builders}
  2331. }
  2332. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  2333. // a builder and applies setFunc on it.
  2334. func (c *ChannelMonitorRequestTemplateClient) MapCreateBulk(slice any, setFunc func(*ChannelMonitorRequestTemplateCreate, int)) *ChannelMonitorRequestTemplateCreateBulk {
  2335. rv := reflect.ValueOf(slice)
  2336. if rv.Kind() != reflect.Slice {
  2337. return &ChannelMonitorRequestTemplateCreateBulk{err: fmt.Errorf("calling to ChannelMonitorRequestTemplateClient.MapCreateBulk with wrong type %T, need slice", slice)}
  2338. }
  2339. builders := make([]*ChannelMonitorRequestTemplateCreate, rv.Len())
  2340. for i := 0; i < rv.Len(); i++ {
  2341. builders[i] = c.Create()
  2342. setFunc(builders[i], i)
  2343. }
  2344. return &ChannelMonitorRequestTemplateCreateBulk{config: c.config, builders: builders}
  2345. }
  2346. // Update returns an update builder for ChannelMonitorRequestTemplate.
  2347. func (c *ChannelMonitorRequestTemplateClient) Update() *ChannelMonitorRequestTemplateUpdate {
  2348. mutation := newChannelMonitorRequestTemplateMutation(c.config, OpUpdate)
  2349. return &ChannelMonitorRequestTemplateUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2350. }
  2351. // UpdateOne returns an update builder for the given entity.
  2352. func (c *ChannelMonitorRequestTemplateClient) UpdateOne(_m *ChannelMonitorRequestTemplate) *ChannelMonitorRequestTemplateUpdateOne {
  2353. mutation := newChannelMonitorRequestTemplateMutation(c.config, OpUpdateOne, withChannelMonitorRequestTemplate(_m))
  2354. return &ChannelMonitorRequestTemplateUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2355. }
  2356. // UpdateOneID returns an update builder for the given id.
  2357. func (c *ChannelMonitorRequestTemplateClient) UpdateOneID(id int64) *ChannelMonitorRequestTemplateUpdateOne {
  2358. mutation := newChannelMonitorRequestTemplateMutation(c.config, OpUpdateOne, withChannelMonitorRequestTemplateID(id))
  2359. return &ChannelMonitorRequestTemplateUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2360. }
  2361. // Delete returns a delete builder for ChannelMonitorRequestTemplate.
  2362. func (c *ChannelMonitorRequestTemplateClient) Delete() *ChannelMonitorRequestTemplateDelete {
  2363. mutation := newChannelMonitorRequestTemplateMutation(c.config, OpDelete)
  2364. return &ChannelMonitorRequestTemplateDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2365. }
  2366. // DeleteOne returns a builder for deleting the given entity.
  2367. func (c *ChannelMonitorRequestTemplateClient) DeleteOne(_m *ChannelMonitorRequestTemplate) *ChannelMonitorRequestTemplateDeleteOne {
  2368. return c.DeleteOneID(_m.ID)
  2369. }
  2370. // DeleteOneID returns a builder for deleting the given entity by its id.
  2371. func (c *ChannelMonitorRequestTemplateClient) DeleteOneID(id int64) *ChannelMonitorRequestTemplateDeleteOne {
  2372. builder := c.Delete().Where(channelmonitorrequesttemplate.ID(id))
  2373. builder.mutation.id = &id
  2374. builder.mutation.op = OpDeleteOne
  2375. return &ChannelMonitorRequestTemplateDeleteOne{builder}
  2376. }
  2377. // Query returns a query builder for ChannelMonitorRequestTemplate.
  2378. func (c *ChannelMonitorRequestTemplateClient) Query() *ChannelMonitorRequestTemplateQuery {
  2379. return &ChannelMonitorRequestTemplateQuery{
  2380. config: c.config,
  2381. ctx: &QueryContext{Type: TypeChannelMonitorRequestTemplate},
  2382. inters: c.Interceptors(),
  2383. }
  2384. }
  2385. // Get returns a ChannelMonitorRequestTemplate entity by its id.
  2386. func (c *ChannelMonitorRequestTemplateClient) Get(ctx context.Context, id int64) (*ChannelMonitorRequestTemplate, error) {
  2387. return c.Query().Where(channelmonitorrequesttemplate.ID(id)).Only(ctx)
  2388. }
  2389. // GetX is like Get, but panics if an error occurs.
  2390. func (c *ChannelMonitorRequestTemplateClient) GetX(ctx context.Context, id int64) *ChannelMonitorRequestTemplate {
  2391. obj, err := c.Get(ctx, id)
  2392. if err != nil {
  2393. panic(err)
  2394. }
  2395. return obj
  2396. }
  2397. // QueryMonitors queries the monitors edge of a ChannelMonitorRequestTemplate.
  2398. func (c *ChannelMonitorRequestTemplateClient) QueryMonitors(_m *ChannelMonitorRequestTemplate) *ChannelMonitorQuery {
  2399. query := (&ChannelMonitorClient{config: c.config}).Query()
  2400. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  2401. id := _m.ID
  2402. step := sqlgraph.NewStep(
  2403. sqlgraph.From(channelmonitorrequesttemplate.Table, channelmonitorrequesttemplate.FieldID, id),
  2404. sqlgraph.To(channelmonitor.Table, channelmonitor.FieldID),
  2405. sqlgraph.Edge(sqlgraph.O2M, true, channelmonitorrequesttemplate.MonitorsTable, channelmonitorrequesttemplate.MonitorsColumn),
  2406. )
  2407. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  2408. return fromV, nil
  2409. }
  2410. return query
  2411. }
  2412. // Hooks returns the client hooks.
  2413. func (c *ChannelMonitorRequestTemplateClient) Hooks() []Hook {
  2414. return c.hooks.ChannelMonitorRequestTemplate
  2415. }
  2416. // Interceptors returns the client interceptors.
  2417. func (c *ChannelMonitorRequestTemplateClient) Interceptors() []Interceptor {
  2418. return c.inters.ChannelMonitorRequestTemplate
  2419. }
  2420. func (c *ChannelMonitorRequestTemplateClient) mutate(ctx context.Context, m *ChannelMonitorRequestTemplateMutation) (Value, error) {
  2421. switch m.Op() {
  2422. case OpCreate:
  2423. return (&ChannelMonitorRequestTemplateCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2424. case OpUpdate:
  2425. return (&ChannelMonitorRequestTemplateUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2426. case OpUpdateOne:
  2427. return (&ChannelMonitorRequestTemplateUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2428. case OpDelete, OpDeleteOne:
  2429. return (&ChannelMonitorRequestTemplateDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  2430. default:
  2431. return nil, fmt.Errorf("ent: unknown ChannelMonitorRequestTemplate mutation op: %q", m.Op())
  2432. }
  2433. }
  2434. // CompositeModelRouteClient is a client for the CompositeModelRoute schema.
  2435. type CompositeModelRouteClient struct {
  2436. config
  2437. }
  2438. // NewCompositeModelRouteClient returns a client for the CompositeModelRoute from the given config.
  2439. func NewCompositeModelRouteClient(c config) *CompositeModelRouteClient {
  2440. return &CompositeModelRouteClient{config: c}
  2441. }
  2442. // Use adds a list of mutation hooks to the hooks stack.
  2443. // A call to `Use(f, g, h)` equals to `compositemodelroute.Hooks(f(g(h())))`.
  2444. func (c *CompositeModelRouteClient) Use(hooks ...Hook) {
  2445. c.hooks.CompositeModelRoute = append(c.hooks.CompositeModelRoute, hooks...)
  2446. }
  2447. // Intercept adds a list of query interceptors to the interceptors stack.
  2448. // A call to `Intercept(f, g, h)` equals to `compositemodelroute.Intercept(f(g(h())))`.
  2449. func (c *CompositeModelRouteClient) Intercept(interceptors ...Interceptor) {
  2450. c.inters.CompositeModelRoute = append(c.inters.CompositeModelRoute, interceptors...)
  2451. }
  2452. // Create returns a builder for creating a CompositeModelRoute entity.
  2453. func (c *CompositeModelRouteClient) Create() *CompositeModelRouteCreate {
  2454. mutation := newCompositeModelRouteMutation(c.config, OpCreate)
  2455. return &CompositeModelRouteCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2456. }
  2457. // CreateBulk returns a builder for creating a bulk of CompositeModelRoute entities.
  2458. func (c *CompositeModelRouteClient) CreateBulk(builders ...*CompositeModelRouteCreate) *CompositeModelRouteCreateBulk {
  2459. return &CompositeModelRouteCreateBulk{config: c.config, builders: builders}
  2460. }
  2461. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  2462. // a builder and applies setFunc on it.
  2463. func (c *CompositeModelRouteClient) MapCreateBulk(slice any, setFunc func(*CompositeModelRouteCreate, int)) *CompositeModelRouteCreateBulk {
  2464. rv := reflect.ValueOf(slice)
  2465. if rv.Kind() != reflect.Slice {
  2466. return &CompositeModelRouteCreateBulk{err: fmt.Errorf("calling to CompositeModelRouteClient.MapCreateBulk with wrong type %T, need slice", slice)}
  2467. }
  2468. builders := make([]*CompositeModelRouteCreate, rv.Len())
  2469. for i := 0; i < rv.Len(); i++ {
  2470. builders[i] = c.Create()
  2471. setFunc(builders[i], i)
  2472. }
  2473. return &CompositeModelRouteCreateBulk{config: c.config, builders: builders}
  2474. }
  2475. // Update returns an update builder for CompositeModelRoute.
  2476. func (c *CompositeModelRouteClient) Update() *CompositeModelRouteUpdate {
  2477. mutation := newCompositeModelRouteMutation(c.config, OpUpdate)
  2478. return &CompositeModelRouteUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2479. }
  2480. // UpdateOne returns an update builder for the given entity.
  2481. func (c *CompositeModelRouteClient) UpdateOne(_m *CompositeModelRoute) *CompositeModelRouteUpdateOne {
  2482. mutation := newCompositeModelRouteMutation(c.config, OpUpdateOne, withCompositeModelRoute(_m))
  2483. return &CompositeModelRouteUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2484. }
  2485. // UpdateOneID returns an update builder for the given id.
  2486. func (c *CompositeModelRouteClient) UpdateOneID(id int64) *CompositeModelRouteUpdateOne {
  2487. mutation := newCompositeModelRouteMutation(c.config, OpUpdateOne, withCompositeModelRouteID(id))
  2488. return &CompositeModelRouteUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2489. }
  2490. // Delete returns a delete builder for CompositeModelRoute.
  2491. func (c *CompositeModelRouteClient) Delete() *CompositeModelRouteDelete {
  2492. mutation := newCompositeModelRouteMutation(c.config, OpDelete)
  2493. return &CompositeModelRouteDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2494. }
  2495. // DeleteOne returns a builder for deleting the given entity.
  2496. func (c *CompositeModelRouteClient) DeleteOne(_m *CompositeModelRoute) *CompositeModelRouteDeleteOne {
  2497. return c.DeleteOneID(_m.ID)
  2498. }
  2499. // DeleteOneID returns a builder for deleting the given entity by its id.
  2500. func (c *CompositeModelRouteClient) DeleteOneID(id int64) *CompositeModelRouteDeleteOne {
  2501. builder := c.Delete().Where(compositemodelroute.ID(id))
  2502. builder.mutation.id = &id
  2503. builder.mutation.op = OpDeleteOne
  2504. return &CompositeModelRouteDeleteOne{builder}
  2505. }
  2506. // Query returns a query builder for CompositeModelRoute.
  2507. func (c *CompositeModelRouteClient) Query() *CompositeModelRouteQuery {
  2508. return &CompositeModelRouteQuery{
  2509. config: c.config,
  2510. ctx: &QueryContext{Type: TypeCompositeModelRoute},
  2511. inters: c.Interceptors(),
  2512. }
  2513. }
  2514. // Get returns a CompositeModelRoute entity by its id.
  2515. func (c *CompositeModelRouteClient) Get(ctx context.Context, id int64) (*CompositeModelRoute, error) {
  2516. return c.Query().Where(compositemodelroute.ID(id)).Only(ctx)
  2517. }
  2518. // GetX is like Get, but panics if an error occurs.
  2519. func (c *CompositeModelRouteClient) GetX(ctx context.Context, id int64) *CompositeModelRoute {
  2520. obj, err := c.Get(ctx, id)
  2521. if err != nil {
  2522. panic(err)
  2523. }
  2524. return obj
  2525. }
  2526. // QueryGroup queries the group edge of a CompositeModelRoute.
  2527. func (c *CompositeModelRouteClient) QueryGroup(_m *CompositeModelRoute) *GroupQuery {
  2528. query := (&GroupClient{config: c.config}).Query()
  2529. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  2530. id := _m.ID
  2531. step := sqlgraph.NewStep(
  2532. sqlgraph.From(compositemodelroute.Table, compositemodelroute.FieldID, id),
  2533. sqlgraph.To(group.Table, group.FieldID),
  2534. sqlgraph.Edge(sqlgraph.M2O, false, compositemodelroute.GroupTable, compositemodelroute.GroupColumn),
  2535. )
  2536. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  2537. return fromV, nil
  2538. }
  2539. return query
  2540. }
  2541. // Hooks returns the client hooks.
  2542. func (c *CompositeModelRouteClient) Hooks() []Hook {
  2543. hooks := c.hooks.CompositeModelRoute
  2544. return append(hooks[:len(hooks):len(hooks)], compositemodelroute.Hooks[:]...)
  2545. }
  2546. // Interceptors returns the client interceptors.
  2547. func (c *CompositeModelRouteClient) Interceptors() []Interceptor {
  2548. inters := c.inters.CompositeModelRoute
  2549. return append(inters[:len(inters):len(inters)], compositemodelroute.Interceptors[:]...)
  2550. }
  2551. func (c *CompositeModelRouteClient) mutate(ctx context.Context, m *CompositeModelRouteMutation) (Value, error) {
  2552. switch m.Op() {
  2553. case OpCreate:
  2554. return (&CompositeModelRouteCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2555. case OpUpdate:
  2556. return (&CompositeModelRouteUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2557. case OpUpdateOne:
  2558. return (&CompositeModelRouteUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2559. case OpDelete, OpDeleteOne:
  2560. return (&CompositeModelRouteDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  2561. default:
  2562. return nil, fmt.Errorf("ent: unknown CompositeModelRoute mutation op: %q", m.Op())
  2563. }
  2564. }
  2565. // ErrorPassthroughRuleClient is a client for the ErrorPassthroughRule schema.
  2566. type ErrorPassthroughRuleClient struct {
  2567. config
  2568. }
  2569. // NewErrorPassthroughRuleClient returns a client for the ErrorPassthroughRule from the given config.
  2570. func NewErrorPassthroughRuleClient(c config) *ErrorPassthroughRuleClient {
  2571. return &ErrorPassthroughRuleClient{config: c}
  2572. }
  2573. // Use adds a list of mutation hooks to the hooks stack.
  2574. // A call to `Use(f, g, h)` equals to `errorpassthroughrule.Hooks(f(g(h())))`.
  2575. func (c *ErrorPassthroughRuleClient) Use(hooks ...Hook) {
  2576. c.hooks.ErrorPassthroughRule = append(c.hooks.ErrorPassthroughRule, hooks...)
  2577. }
  2578. // Intercept adds a list of query interceptors to the interceptors stack.
  2579. // A call to `Intercept(f, g, h)` equals to `errorpassthroughrule.Intercept(f(g(h())))`.
  2580. func (c *ErrorPassthroughRuleClient) Intercept(interceptors ...Interceptor) {
  2581. c.inters.ErrorPassthroughRule = append(c.inters.ErrorPassthroughRule, interceptors...)
  2582. }
  2583. // Create returns a builder for creating a ErrorPassthroughRule entity.
  2584. func (c *ErrorPassthroughRuleClient) Create() *ErrorPassthroughRuleCreate {
  2585. mutation := newErrorPassthroughRuleMutation(c.config, OpCreate)
  2586. return &ErrorPassthroughRuleCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2587. }
  2588. // CreateBulk returns a builder for creating a bulk of ErrorPassthroughRule entities.
  2589. func (c *ErrorPassthroughRuleClient) CreateBulk(builders ...*ErrorPassthroughRuleCreate) *ErrorPassthroughRuleCreateBulk {
  2590. return &ErrorPassthroughRuleCreateBulk{config: c.config, builders: builders}
  2591. }
  2592. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  2593. // a builder and applies setFunc on it.
  2594. func (c *ErrorPassthroughRuleClient) MapCreateBulk(slice any, setFunc func(*ErrorPassthroughRuleCreate, int)) *ErrorPassthroughRuleCreateBulk {
  2595. rv := reflect.ValueOf(slice)
  2596. if rv.Kind() != reflect.Slice {
  2597. return &ErrorPassthroughRuleCreateBulk{err: fmt.Errorf("calling to ErrorPassthroughRuleClient.MapCreateBulk with wrong type %T, need slice", slice)}
  2598. }
  2599. builders := make([]*ErrorPassthroughRuleCreate, rv.Len())
  2600. for i := 0; i < rv.Len(); i++ {
  2601. builders[i] = c.Create()
  2602. setFunc(builders[i], i)
  2603. }
  2604. return &ErrorPassthroughRuleCreateBulk{config: c.config, builders: builders}
  2605. }
  2606. // Update returns an update builder for ErrorPassthroughRule.
  2607. func (c *ErrorPassthroughRuleClient) Update() *ErrorPassthroughRuleUpdate {
  2608. mutation := newErrorPassthroughRuleMutation(c.config, OpUpdate)
  2609. return &ErrorPassthroughRuleUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2610. }
  2611. // UpdateOne returns an update builder for the given entity.
  2612. func (c *ErrorPassthroughRuleClient) UpdateOne(_m *ErrorPassthroughRule) *ErrorPassthroughRuleUpdateOne {
  2613. mutation := newErrorPassthroughRuleMutation(c.config, OpUpdateOne, withErrorPassthroughRule(_m))
  2614. return &ErrorPassthroughRuleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2615. }
  2616. // UpdateOneID returns an update builder for the given id.
  2617. func (c *ErrorPassthroughRuleClient) UpdateOneID(id int64) *ErrorPassthroughRuleUpdateOne {
  2618. mutation := newErrorPassthroughRuleMutation(c.config, OpUpdateOne, withErrorPassthroughRuleID(id))
  2619. return &ErrorPassthroughRuleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2620. }
  2621. // Delete returns a delete builder for ErrorPassthroughRule.
  2622. func (c *ErrorPassthroughRuleClient) Delete() *ErrorPassthroughRuleDelete {
  2623. mutation := newErrorPassthroughRuleMutation(c.config, OpDelete)
  2624. return &ErrorPassthroughRuleDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2625. }
  2626. // DeleteOne returns a builder for deleting the given entity.
  2627. func (c *ErrorPassthroughRuleClient) DeleteOne(_m *ErrorPassthroughRule) *ErrorPassthroughRuleDeleteOne {
  2628. return c.DeleteOneID(_m.ID)
  2629. }
  2630. // DeleteOneID returns a builder for deleting the given entity by its id.
  2631. func (c *ErrorPassthroughRuleClient) DeleteOneID(id int64) *ErrorPassthroughRuleDeleteOne {
  2632. builder := c.Delete().Where(errorpassthroughrule.ID(id))
  2633. builder.mutation.id = &id
  2634. builder.mutation.op = OpDeleteOne
  2635. return &ErrorPassthroughRuleDeleteOne{builder}
  2636. }
  2637. // Query returns a query builder for ErrorPassthroughRule.
  2638. func (c *ErrorPassthroughRuleClient) Query() *ErrorPassthroughRuleQuery {
  2639. return &ErrorPassthroughRuleQuery{
  2640. config: c.config,
  2641. ctx: &QueryContext{Type: TypeErrorPassthroughRule},
  2642. inters: c.Interceptors(),
  2643. }
  2644. }
  2645. // Get returns a ErrorPassthroughRule entity by its id.
  2646. func (c *ErrorPassthroughRuleClient) Get(ctx context.Context, id int64) (*ErrorPassthroughRule, error) {
  2647. return c.Query().Where(errorpassthroughrule.ID(id)).Only(ctx)
  2648. }
  2649. // GetX is like Get, but panics if an error occurs.
  2650. func (c *ErrorPassthroughRuleClient) GetX(ctx context.Context, id int64) *ErrorPassthroughRule {
  2651. obj, err := c.Get(ctx, id)
  2652. if err != nil {
  2653. panic(err)
  2654. }
  2655. return obj
  2656. }
  2657. // Hooks returns the client hooks.
  2658. func (c *ErrorPassthroughRuleClient) Hooks() []Hook {
  2659. return c.hooks.ErrorPassthroughRule
  2660. }
  2661. // Interceptors returns the client interceptors.
  2662. func (c *ErrorPassthroughRuleClient) Interceptors() []Interceptor {
  2663. return c.inters.ErrorPassthroughRule
  2664. }
  2665. func (c *ErrorPassthroughRuleClient) mutate(ctx context.Context, m *ErrorPassthroughRuleMutation) (Value, error) {
  2666. switch m.Op() {
  2667. case OpCreate:
  2668. return (&ErrorPassthroughRuleCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2669. case OpUpdate:
  2670. return (&ErrorPassthroughRuleUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2671. case OpUpdateOne:
  2672. return (&ErrorPassthroughRuleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2673. case OpDelete, OpDeleteOne:
  2674. return (&ErrorPassthroughRuleDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  2675. default:
  2676. return nil, fmt.Errorf("ent: unknown ErrorPassthroughRule mutation op: %q", m.Op())
  2677. }
  2678. }
  2679. // GroupClient is a client for the Group schema.
  2680. type GroupClient struct {
  2681. config
  2682. }
  2683. // NewGroupClient returns a client for the Group from the given config.
  2684. func NewGroupClient(c config) *GroupClient {
  2685. return &GroupClient{config: c}
  2686. }
  2687. // Use adds a list of mutation hooks to the hooks stack.
  2688. // A call to `Use(f, g, h)` equals to `group.Hooks(f(g(h())))`.
  2689. func (c *GroupClient) Use(hooks ...Hook) {
  2690. c.hooks.Group = append(c.hooks.Group, hooks...)
  2691. }
  2692. // Intercept adds a list of query interceptors to the interceptors stack.
  2693. // A call to `Intercept(f, g, h)` equals to `group.Intercept(f(g(h())))`.
  2694. func (c *GroupClient) Intercept(interceptors ...Interceptor) {
  2695. c.inters.Group = append(c.inters.Group, interceptors...)
  2696. }
  2697. // Create returns a builder for creating a Group entity.
  2698. func (c *GroupClient) Create() *GroupCreate {
  2699. mutation := newGroupMutation(c.config, OpCreate)
  2700. return &GroupCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2701. }
  2702. // CreateBulk returns a builder for creating a bulk of Group entities.
  2703. func (c *GroupClient) CreateBulk(builders ...*GroupCreate) *GroupCreateBulk {
  2704. return &GroupCreateBulk{config: c.config, builders: builders}
  2705. }
  2706. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  2707. // a builder and applies setFunc on it.
  2708. func (c *GroupClient) MapCreateBulk(slice any, setFunc func(*GroupCreate, int)) *GroupCreateBulk {
  2709. rv := reflect.ValueOf(slice)
  2710. if rv.Kind() != reflect.Slice {
  2711. return &GroupCreateBulk{err: fmt.Errorf("calling to GroupClient.MapCreateBulk with wrong type %T, need slice", slice)}
  2712. }
  2713. builders := make([]*GroupCreate, rv.Len())
  2714. for i := 0; i < rv.Len(); i++ {
  2715. builders[i] = c.Create()
  2716. setFunc(builders[i], i)
  2717. }
  2718. return &GroupCreateBulk{config: c.config, builders: builders}
  2719. }
  2720. // Update returns an update builder for Group.
  2721. func (c *GroupClient) Update() *GroupUpdate {
  2722. mutation := newGroupMutation(c.config, OpUpdate)
  2723. return &GroupUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2724. }
  2725. // UpdateOne returns an update builder for the given entity.
  2726. func (c *GroupClient) UpdateOne(_m *Group) *GroupUpdateOne {
  2727. mutation := newGroupMutation(c.config, OpUpdateOne, withGroup(_m))
  2728. return &GroupUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2729. }
  2730. // UpdateOneID returns an update builder for the given id.
  2731. func (c *GroupClient) UpdateOneID(id int64) *GroupUpdateOne {
  2732. mutation := newGroupMutation(c.config, OpUpdateOne, withGroupID(id))
  2733. return &GroupUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2734. }
  2735. // Delete returns a delete builder for Group.
  2736. func (c *GroupClient) Delete() *GroupDelete {
  2737. mutation := newGroupMutation(c.config, OpDelete)
  2738. return &GroupDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2739. }
  2740. // DeleteOne returns a builder for deleting the given entity.
  2741. func (c *GroupClient) DeleteOne(_m *Group) *GroupDeleteOne {
  2742. return c.DeleteOneID(_m.ID)
  2743. }
  2744. // DeleteOneID returns a builder for deleting the given entity by its id.
  2745. func (c *GroupClient) DeleteOneID(id int64) *GroupDeleteOne {
  2746. builder := c.Delete().Where(group.ID(id))
  2747. builder.mutation.id = &id
  2748. builder.mutation.op = OpDeleteOne
  2749. return &GroupDeleteOne{builder}
  2750. }
  2751. // Query returns a query builder for Group.
  2752. func (c *GroupClient) Query() *GroupQuery {
  2753. return &GroupQuery{
  2754. config: c.config,
  2755. ctx: &QueryContext{Type: TypeGroup},
  2756. inters: c.Interceptors(),
  2757. }
  2758. }
  2759. // Get returns a Group entity by its id.
  2760. func (c *GroupClient) Get(ctx context.Context, id int64) (*Group, error) {
  2761. return c.Query().Where(group.ID(id)).Only(ctx)
  2762. }
  2763. // GetX is like Get, but panics if an error occurs.
  2764. func (c *GroupClient) GetX(ctx context.Context, id int64) *Group {
  2765. obj, err := c.Get(ctx, id)
  2766. if err != nil {
  2767. panic(err)
  2768. }
  2769. return obj
  2770. }
  2771. // QueryAPIKeys queries the api_keys edge of a Group.
  2772. func (c *GroupClient) QueryAPIKeys(_m *Group) *APIKeyQuery {
  2773. query := (&APIKeyClient{config: c.config}).Query()
  2774. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  2775. id := _m.ID
  2776. step := sqlgraph.NewStep(
  2777. sqlgraph.From(group.Table, group.FieldID, id),
  2778. sqlgraph.To(apikey.Table, apikey.FieldID),
  2779. sqlgraph.Edge(sqlgraph.O2M, false, group.APIKeysTable, group.APIKeysColumn),
  2780. )
  2781. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  2782. return fromV, nil
  2783. }
  2784. return query
  2785. }
  2786. // QueryRedeemCodes queries the redeem_codes edge of a Group.
  2787. func (c *GroupClient) QueryRedeemCodes(_m *Group) *RedeemCodeQuery {
  2788. query := (&RedeemCodeClient{config: c.config}).Query()
  2789. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  2790. id := _m.ID
  2791. step := sqlgraph.NewStep(
  2792. sqlgraph.From(group.Table, group.FieldID, id),
  2793. sqlgraph.To(redeemcode.Table, redeemcode.FieldID),
  2794. sqlgraph.Edge(sqlgraph.O2M, false, group.RedeemCodesTable, group.RedeemCodesColumn),
  2795. )
  2796. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  2797. return fromV, nil
  2798. }
  2799. return query
  2800. }
  2801. // QuerySubscriptions queries the subscriptions edge of a Group.
  2802. func (c *GroupClient) QuerySubscriptions(_m *Group) *UserSubscriptionQuery {
  2803. query := (&UserSubscriptionClient{config: c.config}).Query()
  2804. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  2805. id := _m.ID
  2806. step := sqlgraph.NewStep(
  2807. sqlgraph.From(group.Table, group.FieldID, id),
  2808. sqlgraph.To(usersubscription.Table, usersubscription.FieldID),
  2809. sqlgraph.Edge(sqlgraph.O2M, false, group.SubscriptionsTable, group.SubscriptionsColumn),
  2810. )
  2811. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  2812. return fromV, nil
  2813. }
  2814. return query
  2815. }
  2816. // QueryUsageLogs queries the usage_logs edge of a Group.
  2817. func (c *GroupClient) QueryUsageLogs(_m *Group) *UsageLogQuery {
  2818. query := (&UsageLogClient{config: c.config}).Query()
  2819. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  2820. id := _m.ID
  2821. step := sqlgraph.NewStep(
  2822. sqlgraph.From(group.Table, group.FieldID, id),
  2823. sqlgraph.To(usagelog.Table, usagelog.FieldID),
  2824. sqlgraph.Edge(sqlgraph.O2M, false, group.UsageLogsTable, group.UsageLogsColumn),
  2825. )
  2826. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  2827. return fromV, nil
  2828. }
  2829. return query
  2830. }
  2831. // QueryAccounts queries the accounts edge of a Group.
  2832. func (c *GroupClient) QueryAccounts(_m *Group) *AccountQuery {
  2833. query := (&AccountClient{config: c.config}).Query()
  2834. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  2835. id := _m.ID
  2836. step := sqlgraph.NewStep(
  2837. sqlgraph.From(group.Table, group.FieldID, id),
  2838. sqlgraph.To(account.Table, account.FieldID),
  2839. sqlgraph.Edge(sqlgraph.M2M, true, group.AccountsTable, group.AccountsPrimaryKey...),
  2840. )
  2841. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  2842. return fromV, nil
  2843. }
  2844. return query
  2845. }
  2846. // QueryAllowedUsers queries the allowed_users edge of a Group.
  2847. func (c *GroupClient) QueryAllowedUsers(_m *Group) *UserQuery {
  2848. query := (&UserClient{config: c.config}).Query()
  2849. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  2850. id := _m.ID
  2851. step := sqlgraph.NewStep(
  2852. sqlgraph.From(group.Table, group.FieldID, id),
  2853. sqlgraph.To(user.Table, user.FieldID),
  2854. sqlgraph.Edge(sqlgraph.M2M, true, group.AllowedUsersTable, group.AllowedUsersPrimaryKey...),
  2855. )
  2856. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  2857. return fromV, nil
  2858. }
  2859. return query
  2860. }
  2861. // QueryAccountGroups queries the account_groups edge of a Group.
  2862. func (c *GroupClient) QueryAccountGroups(_m *Group) *AccountGroupQuery {
  2863. query := (&AccountGroupClient{config: c.config}).Query()
  2864. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  2865. id := _m.ID
  2866. step := sqlgraph.NewStep(
  2867. sqlgraph.From(group.Table, group.FieldID, id),
  2868. sqlgraph.To(accountgroup.Table, accountgroup.GroupColumn),
  2869. sqlgraph.Edge(sqlgraph.O2M, true, group.AccountGroupsTable, group.AccountGroupsColumn),
  2870. )
  2871. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  2872. return fromV, nil
  2873. }
  2874. return query
  2875. }
  2876. // QueryUserAllowedGroups queries the user_allowed_groups edge of a Group.
  2877. func (c *GroupClient) QueryUserAllowedGroups(_m *Group) *UserAllowedGroupQuery {
  2878. query := (&UserAllowedGroupClient{config: c.config}).Query()
  2879. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  2880. id := _m.ID
  2881. step := sqlgraph.NewStep(
  2882. sqlgraph.From(group.Table, group.FieldID, id),
  2883. sqlgraph.To(userallowedgroup.Table, userallowedgroup.GroupColumn),
  2884. sqlgraph.Edge(sqlgraph.O2M, true, group.UserAllowedGroupsTable, group.UserAllowedGroupsColumn),
  2885. )
  2886. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  2887. return fromV, nil
  2888. }
  2889. return query
  2890. }
  2891. // Hooks returns the client hooks.
  2892. func (c *GroupClient) Hooks() []Hook {
  2893. hooks := c.hooks.Group
  2894. return append(hooks[:len(hooks):len(hooks)], group.Hooks[:]...)
  2895. }
  2896. // Interceptors returns the client interceptors.
  2897. func (c *GroupClient) Interceptors() []Interceptor {
  2898. inters := c.inters.Group
  2899. return append(inters[:len(inters):len(inters)], group.Interceptors[:]...)
  2900. }
  2901. func (c *GroupClient) mutate(ctx context.Context, m *GroupMutation) (Value, error) {
  2902. switch m.Op() {
  2903. case OpCreate:
  2904. return (&GroupCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2905. case OpUpdate:
  2906. return (&GroupUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2907. case OpUpdateOne:
  2908. return (&GroupUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2909. case OpDelete, OpDeleteOne:
  2910. return (&GroupDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  2911. default:
  2912. return nil, fmt.Errorf("ent: unknown Group mutation op: %q", m.Op())
  2913. }
  2914. }
  2915. // IdempotencyRecordClient is a client for the IdempotencyRecord schema.
  2916. type IdempotencyRecordClient struct {
  2917. config
  2918. }
  2919. // NewIdempotencyRecordClient returns a client for the IdempotencyRecord from the given config.
  2920. func NewIdempotencyRecordClient(c config) *IdempotencyRecordClient {
  2921. return &IdempotencyRecordClient{config: c}
  2922. }
  2923. // Use adds a list of mutation hooks to the hooks stack.
  2924. // A call to `Use(f, g, h)` equals to `idempotencyrecord.Hooks(f(g(h())))`.
  2925. func (c *IdempotencyRecordClient) Use(hooks ...Hook) {
  2926. c.hooks.IdempotencyRecord = append(c.hooks.IdempotencyRecord, hooks...)
  2927. }
  2928. // Intercept adds a list of query interceptors to the interceptors stack.
  2929. // A call to `Intercept(f, g, h)` equals to `idempotencyrecord.Intercept(f(g(h())))`.
  2930. func (c *IdempotencyRecordClient) Intercept(interceptors ...Interceptor) {
  2931. c.inters.IdempotencyRecord = append(c.inters.IdempotencyRecord, interceptors...)
  2932. }
  2933. // Create returns a builder for creating a IdempotencyRecord entity.
  2934. func (c *IdempotencyRecordClient) Create() *IdempotencyRecordCreate {
  2935. mutation := newIdempotencyRecordMutation(c.config, OpCreate)
  2936. return &IdempotencyRecordCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2937. }
  2938. // CreateBulk returns a builder for creating a bulk of IdempotencyRecord entities.
  2939. func (c *IdempotencyRecordClient) CreateBulk(builders ...*IdempotencyRecordCreate) *IdempotencyRecordCreateBulk {
  2940. return &IdempotencyRecordCreateBulk{config: c.config, builders: builders}
  2941. }
  2942. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  2943. // a builder and applies setFunc on it.
  2944. func (c *IdempotencyRecordClient) MapCreateBulk(slice any, setFunc func(*IdempotencyRecordCreate, int)) *IdempotencyRecordCreateBulk {
  2945. rv := reflect.ValueOf(slice)
  2946. if rv.Kind() != reflect.Slice {
  2947. return &IdempotencyRecordCreateBulk{err: fmt.Errorf("calling to IdempotencyRecordClient.MapCreateBulk with wrong type %T, need slice", slice)}
  2948. }
  2949. builders := make([]*IdempotencyRecordCreate, rv.Len())
  2950. for i := 0; i < rv.Len(); i++ {
  2951. builders[i] = c.Create()
  2952. setFunc(builders[i], i)
  2953. }
  2954. return &IdempotencyRecordCreateBulk{config: c.config, builders: builders}
  2955. }
  2956. // Update returns an update builder for IdempotencyRecord.
  2957. func (c *IdempotencyRecordClient) Update() *IdempotencyRecordUpdate {
  2958. mutation := newIdempotencyRecordMutation(c.config, OpUpdate)
  2959. return &IdempotencyRecordUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2960. }
  2961. // UpdateOne returns an update builder for the given entity.
  2962. func (c *IdempotencyRecordClient) UpdateOne(_m *IdempotencyRecord) *IdempotencyRecordUpdateOne {
  2963. mutation := newIdempotencyRecordMutation(c.config, OpUpdateOne, withIdempotencyRecord(_m))
  2964. return &IdempotencyRecordUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2965. }
  2966. // UpdateOneID returns an update builder for the given id.
  2967. func (c *IdempotencyRecordClient) UpdateOneID(id int64) *IdempotencyRecordUpdateOne {
  2968. mutation := newIdempotencyRecordMutation(c.config, OpUpdateOne, withIdempotencyRecordID(id))
  2969. return &IdempotencyRecordUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2970. }
  2971. // Delete returns a delete builder for IdempotencyRecord.
  2972. func (c *IdempotencyRecordClient) Delete() *IdempotencyRecordDelete {
  2973. mutation := newIdempotencyRecordMutation(c.config, OpDelete)
  2974. return &IdempotencyRecordDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2975. }
  2976. // DeleteOne returns a builder for deleting the given entity.
  2977. func (c *IdempotencyRecordClient) DeleteOne(_m *IdempotencyRecord) *IdempotencyRecordDeleteOne {
  2978. return c.DeleteOneID(_m.ID)
  2979. }
  2980. // DeleteOneID returns a builder for deleting the given entity by its id.
  2981. func (c *IdempotencyRecordClient) DeleteOneID(id int64) *IdempotencyRecordDeleteOne {
  2982. builder := c.Delete().Where(idempotencyrecord.ID(id))
  2983. builder.mutation.id = &id
  2984. builder.mutation.op = OpDeleteOne
  2985. return &IdempotencyRecordDeleteOne{builder}
  2986. }
  2987. // Query returns a query builder for IdempotencyRecord.
  2988. func (c *IdempotencyRecordClient) Query() *IdempotencyRecordQuery {
  2989. return &IdempotencyRecordQuery{
  2990. config: c.config,
  2991. ctx: &QueryContext{Type: TypeIdempotencyRecord},
  2992. inters: c.Interceptors(),
  2993. }
  2994. }
  2995. // Get returns a IdempotencyRecord entity by its id.
  2996. func (c *IdempotencyRecordClient) Get(ctx context.Context, id int64) (*IdempotencyRecord, error) {
  2997. return c.Query().Where(idempotencyrecord.ID(id)).Only(ctx)
  2998. }
  2999. // GetX is like Get, but panics if an error occurs.
  3000. func (c *IdempotencyRecordClient) GetX(ctx context.Context, id int64) *IdempotencyRecord {
  3001. obj, err := c.Get(ctx, id)
  3002. if err != nil {
  3003. panic(err)
  3004. }
  3005. return obj
  3006. }
  3007. // Hooks returns the client hooks.
  3008. func (c *IdempotencyRecordClient) Hooks() []Hook {
  3009. return c.hooks.IdempotencyRecord
  3010. }
  3011. // Interceptors returns the client interceptors.
  3012. func (c *IdempotencyRecordClient) Interceptors() []Interceptor {
  3013. return c.inters.IdempotencyRecord
  3014. }
  3015. func (c *IdempotencyRecordClient) mutate(ctx context.Context, m *IdempotencyRecordMutation) (Value, error) {
  3016. switch m.Op() {
  3017. case OpCreate:
  3018. return (&IdempotencyRecordCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3019. case OpUpdate:
  3020. return (&IdempotencyRecordUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3021. case OpUpdateOne:
  3022. return (&IdempotencyRecordUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3023. case OpDelete, OpDeleteOne:
  3024. return (&IdempotencyRecordDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  3025. default:
  3026. return nil, fmt.Errorf("ent: unknown IdempotencyRecord mutation op: %q", m.Op())
  3027. }
  3028. }
  3029. // IdentityAdoptionDecisionClient is a client for the IdentityAdoptionDecision schema.
  3030. type IdentityAdoptionDecisionClient struct {
  3031. config
  3032. }
  3033. // NewIdentityAdoptionDecisionClient returns a client for the IdentityAdoptionDecision from the given config.
  3034. func NewIdentityAdoptionDecisionClient(c config) *IdentityAdoptionDecisionClient {
  3035. return &IdentityAdoptionDecisionClient{config: c}
  3036. }
  3037. // Use adds a list of mutation hooks to the hooks stack.
  3038. // A call to `Use(f, g, h)` equals to `identityadoptiondecision.Hooks(f(g(h())))`.
  3039. func (c *IdentityAdoptionDecisionClient) Use(hooks ...Hook) {
  3040. c.hooks.IdentityAdoptionDecision = append(c.hooks.IdentityAdoptionDecision, hooks...)
  3041. }
  3042. // Intercept adds a list of query interceptors to the interceptors stack.
  3043. // A call to `Intercept(f, g, h)` equals to `identityadoptiondecision.Intercept(f(g(h())))`.
  3044. func (c *IdentityAdoptionDecisionClient) Intercept(interceptors ...Interceptor) {
  3045. c.inters.IdentityAdoptionDecision = append(c.inters.IdentityAdoptionDecision, interceptors...)
  3046. }
  3047. // Create returns a builder for creating a IdentityAdoptionDecision entity.
  3048. func (c *IdentityAdoptionDecisionClient) Create() *IdentityAdoptionDecisionCreate {
  3049. mutation := newIdentityAdoptionDecisionMutation(c.config, OpCreate)
  3050. return &IdentityAdoptionDecisionCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3051. }
  3052. // CreateBulk returns a builder for creating a bulk of IdentityAdoptionDecision entities.
  3053. func (c *IdentityAdoptionDecisionClient) CreateBulk(builders ...*IdentityAdoptionDecisionCreate) *IdentityAdoptionDecisionCreateBulk {
  3054. return &IdentityAdoptionDecisionCreateBulk{config: c.config, builders: builders}
  3055. }
  3056. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  3057. // a builder and applies setFunc on it.
  3058. func (c *IdentityAdoptionDecisionClient) MapCreateBulk(slice any, setFunc func(*IdentityAdoptionDecisionCreate, int)) *IdentityAdoptionDecisionCreateBulk {
  3059. rv := reflect.ValueOf(slice)
  3060. if rv.Kind() != reflect.Slice {
  3061. return &IdentityAdoptionDecisionCreateBulk{err: fmt.Errorf("calling to IdentityAdoptionDecisionClient.MapCreateBulk with wrong type %T, need slice", slice)}
  3062. }
  3063. builders := make([]*IdentityAdoptionDecisionCreate, rv.Len())
  3064. for i := 0; i < rv.Len(); i++ {
  3065. builders[i] = c.Create()
  3066. setFunc(builders[i], i)
  3067. }
  3068. return &IdentityAdoptionDecisionCreateBulk{config: c.config, builders: builders}
  3069. }
  3070. // Update returns an update builder for IdentityAdoptionDecision.
  3071. func (c *IdentityAdoptionDecisionClient) Update() *IdentityAdoptionDecisionUpdate {
  3072. mutation := newIdentityAdoptionDecisionMutation(c.config, OpUpdate)
  3073. return &IdentityAdoptionDecisionUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3074. }
  3075. // UpdateOne returns an update builder for the given entity.
  3076. func (c *IdentityAdoptionDecisionClient) UpdateOne(_m *IdentityAdoptionDecision) *IdentityAdoptionDecisionUpdateOne {
  3077. mutation := newIdentityAdoptionDecisionMutation(c.config, OpUpdateOne, withIdentityAdoptionDecision(_m))
  3078. return &IdentityAdoptionDecisionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3079. }
  3080. // UpdateOneID returns an update builder for the given id.
  3081. func (c *IdentityAdoptionDecisionClient) UpdateOneID(id int64) *IdentityAdoptionDecisionUpdateOne {
  3082. mutation := newIdentityAdoptionDecisionMutation(c.config, OpUpdateOne, withIdentityAdoptionDecisionID(id))
  3083. return &IdentityAdoptionDecisionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3084. }
  3085. // Delete returns a delete builder for IdentityAdoptionDecision.
  3086. func (c *IdentityAdoptionDecisionClient) Delete() *IdentityAdoptionDecisionDelete {
  3087. mutation := newIdentityAdoptionDecisionMutation(c.config, OpDelete)
  3088. return &IdentityAdoptionDecisionDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3089. }
  3090. // DeleteOne returns a builder for deleting the given entity.
  3091. func (c *IdentityAdoptionDecisionClient) DeleteOne(_m *IdentityAdoptionDecision) *IdentityAdoptionDecisionDeleteOne {
  3092. return c.DeleteOneID(_m.ID)
  3093. }
  3094. // DeleteOneID returns a builder for deleting the given entity by its id.
  3095. func (c *IdentityAdoptionDecisionClient) DeleteOneID(id int64) *IdentityAdoptionDecisionDeleteOne {
  3096. builder := c.Delete().Where(identityadoptiondecision.ID(id))
  3097. builder.mutation.id = &id
  3098. builder.mutation.op = OpDeleteOne
  3099. return &IdentityAdoptionDecisionDeleteOne{builder}
  3100. }
  3101. // Query returns a query builder for IdentityAdoptionDecision.
  3102. func (c *IdentityAdoptionDecisionClient) Query() *IdentityAdoptionDecisionQuery {
  3103. return &IdentityAdoptionDecisionQuery{
  3104. config: c.config,
  3105. ctx: &QueryContext{Type: TypeIdentityAdoptionDecision},
  3106. inters: c.Interceptors(),
  3107. }
  3108. }
  3109. // Get returns a IdentityAdoptionDecision entity by its id.
  3110. func (c *IdentityAdoptionDecisionClient) Get(ctx context.Context, id int64) (*IdentityAdoptionDecision, error) {
  3111. return c.Query().Where(identityadoptiondecision.ID(id)).Only(ctx)
  3112. }
  3113. // GetX is like Get, but panics if an error occurs.
  3114. func (c *IdentityAdoptionDecisionClient) GetX(ctx context.Context, id int64) *IdentityAdoptionDecision {
  3115. obj, err := c.Get(ctx, id)
  3116. if err != nil {
  3117. panic(err)
  3118. }
  3119. return obj
  3120. }
  3121. // QueryPendingAuthSession queries the pending_auth_session edge of a IdentityAdoptionDecision.
  3122. func (c *IdentityAdoptionDecisionClient) QueryPendingAuthSession(_m *IdentityAdoptionDecision) *PendingAuthSessionQuery {
  3123. query := (&PendingAuthSessionClient{config: c.config}).Query()
  3124. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  3125. id := _m.ID
  3126. step := sqlgraph.NewStep(
  3127. sqlgraph.From(identityadoptiondecision.Table, identityadoptiondecision.FieldID, id),
  3128. sqlgraph.To(pendingauthsession.Table, pendingauthsession.FieldID),
  3129. sqlgraph.Edge(sqlgraph.O2O, true, identityadoptiondecision.PendingAuthSessionTable, identityadoptiondecision.PendingAuthSessionColumn),
  3130. )
  3131. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  3132. return fromV, nil
  3133. }
  3134. return query
  3135. }
  3136. // QueryIdentity queries the identity edge of a IdentityAdoptionDecision.
  3137. func (c *IdentityAdoptionDecisionClient) QueryIdentity(_m *IdentityAdoptionDecision) *AuthIdentityQuery {
  3138. query := (&AuthIdentityClient{config: c.config}).Query()
  3139. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  3140. id := _m.ID
  3141. step := sqlgraph.NewStep(
  3142. sqlgraph.From(identityadoptiondecision.Table, identityadoptiondecision.FieldID, id),
  3143. sqlgraph.To(authidentity.Table, authidentity.FieldID),
  3144. sqlgraph.Edge(sqlgraph.M2O, true, identityadoptiondecision.IdentityTable, identityadoptiondecision.IdentityColumn),
  3145. )
  3146. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  3147. return fromV, nil
  3148. }
  3149. return query
  3150. }
  3151. // Hooks returns the client hooks.
  3152. func (c *IdentityAdoptionDecisionClient) Hooks() []Hook {
  3153. return c.hooks.IdentityAdoptionDecision
  3154. }
  3155. // Interceptors returns the client interceptors.
  3156. func (c *IdentityAdoptionDecisionClient) Interceptors() []Interceptor {
  3157. return c.inters.IdentityAdoptionDecision
  3158. }
  3159. func (c *IdentityAdoptionDecisionClient) mutate(ctx context.Context, m *IdentityAdoptionDecisionMutation) (Value, error) {
  3160. switch m.Op() {
  3161. case OpCreate:
  3162. return (&IdentityAdoptionDecisionCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3163. case OpUpdate:
  3164. return (&IdentityAdoptionDecisionUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3165. case OpUpdateOne:
  3166. return (&IdentityAdoptionDecisionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3167. case OpDelete, OpDeleteOne:
  3168. return (&IdentityAdoptionDecisionDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  3169. default:
  3170. return nil, fmt.Errorf("ent: unknown IdentityAdoptionDecision mutation op: %q", m.Op())
  3171. }
  3172. }
  3173. // PaymentAuditLogClient is a client for the PaymentAuditLog schema.
  3174. type PaymentAuditLogClient struct {
  3175. config
  3176. }
  3177. // NewPaymentAuditLogClient returns a client for the PaymentAuditLog from the given config.
  3178. func NewPaymentAuditLogClient(c config) *PaymentAuditLogClient {
  3179. return &PaymentAuditLogClient{config: c}
  3180. }
  3181. // Use adds a list of mutation hooks to the hooks stack.
  3182. // A call to `Use(f, g, h)` equals to `paymentauditlog.Hooks(f(g(h())))`.
  3183. func (c *PaymentAuditLogClient) Use(hooks ...Hook) {
  3184. c.hooks.PaymentAuditLog = append(c.hooks.PaymentAuditLog, hooks...)
  3185. }
  3186. // Intercept adds a list of query interceptors to the interceptors stack.
  3187. // A call to `Intercept(f, g, h)` equals to `paymentauditlog.Intercept(f(g(h())))`.
  3188. func (c *PaymentAuditLogClient) Intercept(interceptors ...Interceptor) {
  3189. c.inters.PaymentAuditLog = append(c.inters.PaymentAuditLog, interceptors...)
  3190. }
  3191. // Create returns a builder for creating a PaymentAuditLog entity.
  3192. func (c *PaymentAuditLogClient) Create() *PaymentAuditLogCreate {
  3193. mutation := newPaymentAuditLogMutation(c.config, OpCreate)
  3194. return &PaymentAuditLogCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3195. }
  3196. // CreateBulk returns a builder for creating a bulk of PaymentAuditLog entities.
  3197. func (c *PaymentAuditLogClient) CreateBulk(builders ...*PaymentAuditLogCreate) *PaymentAuditLogCreateBulk {
  3198. return &PaymentAuditLogCreateBulk{config: c.config, builders: builders}
  3199. }
  3200. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  3201. // a builder and applies setFunc on it.
  3202. func (c *PaymentAuditLogClient) MapCreateBulk(slice any, setFunc func(*PaymentAuditLogCreate, int)) *PaymentAuditLogCreateBulk {
  3203. rv := reflect.ValueOf(slice)
  3204. if rv.Kind() != reflect.Slice {
  3205. return &PaymentAuditLogCreateBulk{err: fmt.Errorf("calling to PaymentAuditLogClient.MapCreateBulk with wrong type %T, need slice", slice)}
  3206. }
  3207. builders := make([]*PaymentAuditLogCreate, rv.Len())
  3208. for i := 0; i < rv.Len(); i++ {
  3209. builders[i] = c.Create()
  3210. setFunc(builders[i], i)
  3211. }
  3212. return &PaymentAuditLogCreateBulk{config: c.config, builders: builders}
  3213. }
  3214. // Update returns an update builder for PaymentAuditLog.
  3215. func (c *PaymentAuditLogClient) Update() *PaymentAuditLogUpdate {
  3216. mutation := newPaymentAuditLogMutation(c.config, OpUpdate)
  3217. return &PaymentAuditLogUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3218. }
  3219. // UpdateOne returns an update builder for the given entity.
  3220. func (c *PaymentAuditLogClient) UpdateOne(_m *PaymentAuditLog) *PaymentAuditLogUpdateOne {
  3221. mutation := newPaymentAuditLogMutation(c.config, OpUpdateOne, withPaymentAuditLog(_m))
  3222. return &PaymentAuditLogUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3223. }
  3224. // UpdateOneID returns an update builder for the given id.
  3225. func (c *PaymentAuditLogClient) UpdateOneID(id int64) *PaymentAuditLogUpdateOne {
  3226. mutation := newPaymentAuditLogMutation(c.config, OpUpdateOne, withPaymentAuditLogID(id))
  3227. return &PaymentAuditLogUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3228. }
  3229. // Delete returns a delete builder for PaymentAuditLog.
  3230. func (c *PaymentAuditLogClient) Delete() *PaymentAuditLogDelete {
  3231. mutation := newPaymentAuditLogMutation(c.config, OpDelete)
  3232. return &PaymentAuditLogDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3233. }
  3234. // DeleteOne returns a builder for deleting the given entity.
  3235. func (c *PaymentAuditLogClient) DeleteOne(_m *PaymentAuditLog) *PaymentAuditLogDeleteOne {
  3236. return c.DeleteOneID(_m.ID)
  3237. }
  3238. // DeleteOneID returns a builder for deleting the given entity by its id.
  3239. func (c *PaymentAuditLogClient) DeleteOneID(id int64) *PaymentAuditLogDeleteOne {
  3240. builder := c.Delete().Where(paymentauditlog.ID(id))
  3241. builder.mutation.id = &id
  3242. builder.mutation.op = OpDeleteOne
  3243. return &PaymentAuditLogDeleteOne{builder}
  3244. }
  3245. // Query returns a query builder for PaymentAuditLog.
  3246. func (c *PaymentAuditLogClient) Query() *PaymentAuditLogQuery {
  3247. return &PaymentAuditLogQuery{
  3248. config: c.config,
  3249. ctx: &QueryContext{Type: TypePaymentAuditLog},
  3250. inters: c.Interceptors(),
  3251. }
  3252. }
  3253. // Get returns a PaymentAuditLog entity by its id.
  3254. func (c *PaymentAuditLogClient) Get(ctx context.Context, id int64) (*PaymentAuditLog, error) {
  3255. return c.Query().Where(paymentauditlog.ID(id)).Only(ctx)
  3256. }
  3257. // GetX is like Get, but panics if an error occurs.
  3258. func (c *PaymentAuditLogClient) GetX(ctx context.Context, id int64) *PaymentAuditLog {
  3259. obj, err := c.Get(ctx, id)
  3260. if err != nil {
  3261. panic(err)
  3262. }
  3263. return obj
  3264. }
  3265. // Hooks returns the client hooks.
  3266. func (c *PaymentAuditLogClient) Hooks() []Hook {
  3267. return c.hooks.PaymentAuditLog
  3268. }
  3269. // Interceptors returns the client interceptors.
  3270. func (c *PaymentAuditLogClient) Interceptors() []Interceptor {
  3271. return c.inters.PaymentAuditLog
  3272. }
  3273. func (c *PaymentAuditLogClient) mutate(ctx context.Context, m *PaymentAuditLogMutation) (Value, error) {
  3274. switch m.Op() {
  3275. case OpCreate:
  3276. return (&PaymentAuditLogCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3277. case OpUpdate:
  3278. return (&PaymentAuditLogUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3279. case OpUpdateOne:
  3280. return (&PaymentAuditLogUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3281. case OpDelete, OpDeleteOne:
  3282. return (&PaymentAuditLogDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  3283. default:
  3284. return nil, fmt.Errorf("ent: unknown PaymentAuditLog mutation op: %q", m.Op())
  3285. }
  3286. }
  3287. // PaymentOrderClient is a client for the PaymentOrder schema.
  3288. type PaymentOrderClient struct {
  3289. config
  3290. }
  3291. // NewPaymentOrderClient returns a client for the PaymentOrder from the given config.
  3292. func NewPaymentOrderClient(c config) *PaymentOrderClient {
  3293. return &PaymentOrderClient{config: c}
  3294. }
  3295. // Use adds a list of mutation hooks to the hooks stack.
  3296. // A call to `Use(f, g, h)` equals to `paymentorder.Hooks(f(g(h())))`.
  3297. func (c *PaymentOrderClient) Use(hooks ...Hook) {
  3298. c.hooks.PaymentOrder = append(c.hooks.PaymentOrder, hooks...)
  3299. }
  3300. // Intercept adds a list of query interceptors to the interceptors stack.
  3301. // A call to `Intercept(f, g, h)` equals to `paymentorder.Intercept(f(g(h())))`.
  3302. func (c *PaymentOrderClient) Intercept(interceptors ...Interceptor) {
  3303. c.inters.PaymentOrder = append(c.inters.PaymentOrder, interceptors...)
  3304. }
  3305. // Create returns a builder for creating a PaymentOrder entity.
  3306. func (c *PaymentOrderClient) Create() *PaymentOrderCreate {
  3307. mutation := newPaymentOrderMutation(c.config, OpCreate)
  3308. return &PaymentOrderCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3309. }
  3310. // CreateBulk returns a builder for creating a bulk of PaymentOrder entities.
  3311. func (c *PaymentOrderClient) CreateBulk(builders ...*PaymentOrderCreate) *PaymentOrderCreateBulk {
  3312. return &PaymentOrderCreateBulk{config: c.config, builders: builders}
  3313. }
  3314. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  3315. // a builder and applies setFunc on it.
  3316. func (c *PaymentOrderClient) MapCreateBulk(slice any, setFunc func(*PaymentOrderCreate, int)) *PaymentOrderCreateBulk {
  3317. rv := reflect.ValueOf(slice)
  3318. if rv.Kind() != reflect.Slice {
  3319. return &PaymentOrderCreateBulk{err: fmt.Errorf("calling to PaymentOrderClient.MapCreateBulk with wrong type %T, need slice", slice)}
  3320. }
  3321. builders := make([]*PaymentOrderCreate, rv.Len())
  3322. for i := 0; i < rv.Len(); i++ {
  3323. builders[i] = c.Create()
  3324. setFunc(builders[i], i)
  3325. }
  3326. return &PaymentOrderCreateBulk{config: c.config, builders: builders}
  3327. }
  3328. // Update returns an update builder for PaymentOrder.
  3329. func (c *PaymentOrderClient) Update() *PaymentOrderUpdate {
  3330. mutation := newPaymentOrderMutation(c.config, OpUpdate)
  3331. return &PaymentOrderUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3332. }
  3333. // UpdateOne returns an update builder for the given entity.
  3334. func (c *PaymentOrderClient) UpdateOne(_m *PaymentOrder) *PaymentOrderUpdateOne {
  3335. mutation := newPaymentOrderMutation(c.config, OpUpdateOne, withPaymentOrder(_m))
  3336. return &PaymentOrderUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3337. }
  3338. // UpdateOneID returns an update builder for the given id.
  3339. func (c *PaymentOrderClient) UpdateOneID(id int64) *PaymentOrderUpdateOne {
  3340. mutation := newPaymentOrderMutation(c.config, OpUpdateOne, withPaymentOrderID(id))
  3341. return &PaymentOrderUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3342. }
  3343. // Delete returns a delete builder for PaymentOrder.
  3344. func (c *PaymentOrderClient) Delete() *PaymentOrderDelete {
  3345. mutation := newPaymentOrderMutation(c.config, OpDelete)
  3346. return &PaymentOrderDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3347. }
  3348. // DeleteOne returns a builder for deleting the given entity.
  3349. func (c *PaymentOrderClient) DeleteOne(_m *PaymentOrder) *PaymentOrderDeleteOne {
  3350. return c.DeleteOneID(_m.ID)
  3351. }
  3352. // DeleteOneID returns a builder for deleting the given entity by its id.
  3353. func (c *PaymentOrderClient) DeleteOneID(id int64) *PaymentOrderDeleteOne {
  3354. builder := c.Delete().Where(paymentorder.ID(id))
  3355. builder.mutation.id = &id
  3356. builder.mutation.op = OpDeleteOne
  3357. return &PaymentOrderDeleteOne{builder}
  3358. }
  3359. // Query returns a query builder for PaymentOrder.
  3360. func (c *PaymentOrderClient) Query() *PaymentOrderQuery {
  3361. return &PaymentOrderQuery{
  3362. config: c.config,
  3363. ctx: &QueryContext{Type: TypePaymentOrder},
  3364. inters: c.Interceptors(),
  3365. }
  3366. }
  3367. // Get returns a PaymentOrder entity by its id.
  3368. func (c *PaymentOrderClient) Get(ctx context.Context, id int64) (*PaymentOrder, error) {
  3369. return c.Query().Where(paymentorder.ID(id)).Only(ctx)
  3370. }
  3371. // GetX is like Get, but panics if an error occurs.
  3372. func (c *PaymentOrderClient) GetX(ctx context.Context, id int64) *PaymentOrder {
  3373. obj, err := c.Get(ctx, id)
  3374. if err != nil {
  3375. panic(err)
  3376. }
  3377. return obj
  3378. }
  3379. // QueryUser queries the user edge of a PaymentOrder.
  3380. func (c *PaymentOrderClient) QueryUser(_m *PaymentOrder) *UserQuery {
  3381. query := (&UserClient{config: c.config}).Query()
  3382. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  3383. id := _m.ID
  3384. step := sqlgraph.NewStep(
  3385. sqlgraph.From(paymentorder.Table, paymentorder.FieldID, id),
  3386. sqlgraph.To(user.Table, user.FieldID),
  3387. sqlgraph.Edge(sqlgraph.M2O, true, paymentorder.UserTable, paymentorder.UserColumn),
  3388. )
  3389. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  3390. return fromV, nil
  3391. }
  3392. return query
  3393. }
  3394. // Hooks returns the client hooks.
  3395. func (c *PaymentOrderClient) Hooks() []Hook {
  3396. return c.hooks.PaymentOrder
  3397. }
  3398. // Interceptors returns the client interceptors.
  3399. func (c *PaymentOrderClient) Interceptors() []Interceptor {
  3400. return c.inters.PaymentOrder
  3401. }
  3402. func (c *PaymentOrderClient) mutate(ctx context.Context, m *PaymentOrderMutation) (Value, error) {
  3403. switch m.Op() {
  3404. case OpCreate:
  3405. return (&PaymentOrderCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3406. case OpUpdate:
  3407. return (&PaymentOrderUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3408. case OpUpdateOne:
  3409. return (&PaymentOrderUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3410. case OpDelete, OpDeleteOne:
  3411. return (&PaymentOrderDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  3412. default:
  3413. return nil, fmt.Errorf("ent: unknown PaymentOrder mutation op: %q", m.Op())
  3414. }
  3415. }
  3416. // PaymentProviderInstanceClient is a client for the PaymentProviderInstance schema.
  3417. type PaymentProviderInstanceClient struct {
  3418. config
  3419. }
  3420. // NewPaymentProviderInstanceClient returns a client for the PaymentProviderInstance from the given config.
  3421. func NewPaymentProviderInstanceClient(c config) *PaymentProviderInstanceClient {
  3422. return &PaymentProviderInstanceClient{config: c}
  3423. }
  3424. // Use adds a list of mutation hooks to the hooks stack.
  3425. // A call to `Use(f, g, h)` equals to `paymentproviderinstance.Hooks(f(g(h())))`.
  3426. func (c *PaymentProviderInstanceClient) Use(hooks ...Hook) {
  3427. c.hooks.PaymentProviderInstance = append(c.hooks.PaymentProviderInstance, hooks...)
  3428. }
  3429. // Intercept adds a list of query interceptors to the interceptors stack.
  3430. // A call to `Intercept(f, g, h)` equals to `paymentproviderinstance.Intercept(f(g(h())))`.
  3431. func (c *PaymentProviderInstanceClient) Intercept(interceptors ...Interceptor) {
  3432. c.inters.PaymentProviderInstance = append(c.inters.PaymentProviderInstance, interceptors...)
  3433. }
  3434. // Create returns a builder for creating a PaymentProviderInstance entity.
  3435. func (c *PaymentProviderInstanceClient) Create() *PaymentProviderInstanceCreate {
  3436. mutation := newPaymentProviderInstanceMutation(c.config, OpCreate)
  3437. return &PaymentProviderInstanceCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3438. }
  3439. // CreateBulk returns a builder for creating a bulk of PaymentProviderInstance entities.
  3440. func (c *PaymentProviderInstanceClient) CreateBulk(builders ...*PaymentProviderInstanceCreate) *PaymentProviderInstanceCreateBulk {
  3441. return &PaymentProviderInstanceCreateBulk{config: c.config, builders: builders}
  3442. }
  3443. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  3444. // a builder and applies setFunc on it.
  3445. func (c *PaymentProviderInstanceClient) MapCreateBulk(slice any, setFunc func(*PaymentProviderInstanceCreate, int)) *PaymentProviderInstanceCreateBulk {
  3446. rv := reflect.ValueOf(slice)
  3447. if rv.Kind() != reflect.Slice {
  3448. return &PaymentProviderInstanceCreateBulk{err: fmt.Errorf("calling to PaymentProviderInstanceClient.MapCreateBulk with wrong type %T, need slice", slice)}
  3449. }
  3450. builders := make([]*PaymentProviderInstanceCreate, rv.Len())
  3451. for i := 0; i < rv.Len(); i++ {
  3452. builders[i] = c.Create()
  3453. setFunc(builders[i], i)
  3454. }
  3455. return &PaymentProviderInstanceCreateBulk{config: c.config, builders: builders}
  3456. }
  3457. // Update returns an update builder for PaymentProviderInstance.
  3458. func (c *PaymentProviderInstanceClient) Update() *PaymentProviderInstanceUpdate {
  3459. mutation := newPaymentProviderInstanceMutation(c.config, OpUpdate)
  3460. return &PaymentProviderInstanceUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3461. }
  3462. // UpdateOne returns an update builder for the given entity.
  3463. func (c *PaymentProviderInstanceClient) UpdateOne(_m *PaymentProviderInstance) *PaymentProviderInstanceUpdateOne {
  3464. mutation := newPaymentProviderInstanceMutation(c.config, OpUpdateOne, withPaymentProviderInstance(_m))
  3465. return &PaymentProviderInstanceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3466. }
  3467. // UpdateOneID returns an update builder for the given id.
  3468. func (c *PaymentProviderInstanceClient) UpdateOneID(id int64) *PaymentProviderInstanceUpdateOne {
  3469. mutation := newPaymentProviderInstanceMutation(c.config, OpUpdateOne, withPaymentProviderInstanceID(id))
  3470. return &PaymentProviderInstanceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3471. }
  3472. // Delete returns a delete builder for PaymentProviderInstance.
  3473. func (c *PaymentProviderInstanceClient) Delete() *PaymentProviderInstanceDelete {
  3474. mutation := newPaymentProviderInstanceMutation(c.config, OpDelete)
  3475. return &PaymentProviderInstanceDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3476. }
  3477. // DeleteOne returns a builder for deleting the given entity.
  3478. func (c *PaymentProviderInstanceClient) DeleteOne(_m *PaymentProviderInstance) *PaymentProviderInstanceDeleteOne {
  3479. return c.DeleteOneID(_m.ID)
  3480. }
  3481. // DeleteOneID returns a builder for deleting the given entity by its id.
  3482. func (c *PaymentProviderInstanceClient) DeleteOneID(id int64) *PaymentProviderInstanceDeleteOne {
  3483. builder := c.Delete().Where(paymentproviderinstance.ID(id))
  3484. builder.mutation.id = &id
  3485. builder.mutation.op = OpDeleteOne
  3486. return &PaymentProviderInstanceDeleteOne{builder}
  3487. }
  3488. // Query returns a query builder for PaymentProviderInstance.
  3489. func (c *PaymentProviderInstanceClient) Query() *PaymentProviderInstanceQuery {
  3490. return &PaymentProviderInstanceQuery{
  3491. config: c.config,
  3492. ctx: &QueryContext{Type: TypePaymentProviderInstance},
  3493. inters: c.Interceptors(),
  3494. }
  3495. }
  3496. // Get returns a PaymentProviderInstance entity by its id.
  3497. func (c *PaymentProviderInstanceClient) Get(ctx context.Context, id int64) (*PaymentProviderInstance, error) {
  3498. return c.Query().Where(paymentproviderinstance.ID(id)).Only(ctx)
  3499. }
  3500. // GetX is like Get, but panics if an error occurs.
  3501. func (c *PaymentProviderInstanceClient) GetX(ctx context.Context, id int64) *PaymentProviderInstance {
  3502. obj, err := c.Get(ctx, id)
  3503. if err != nil {
  3504. panic(err)
  3505. }
  3506. return obj
  3507. }
  3508. // Hooks returns the client hooks.
  3509. func (c *PaymentProviderInstanceClient) Hooks() []Hook {
  3510. return c.hooks.PaymentProviderInstance
  3511. }
  3512. // Interceptors returns the client interceptors.
  3513. func (c *PaymentProviderInstanceClient) Interceptors() []Interceptor {
  3514. return c.inters.PaymentProviderInstance
  3515. }
  3516. func (c *PaymentProviderInstanceClient) mutate(ctx context.Context, m *PaymentProviderInstanceMutation) (Value, error) {
  3517. switch m.Op() {
  3518. case OpCreate:
  3519. return (&PaymentProviderInstanceCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3520. case OpUpdate:
  3521. return (&PaymentProviderInstanceUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3522. case OpUpdateOne:
  3523. return (&PaymentProviderInstanceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3524. case OpDelete, OpDeleteOne:
  3525. return (&PaymentProviderInstanceDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  3526. default:
  3527. return nil, fmt.Errorf("ent: unknown PaymentProviderInstance mutation op: %q", m.Op())
  3528. }
  3529. }
  3530. // PendingAuthSessionClient is a client for the PendingAuthSession schema.
  3531. type PendingAuthSessionClient struct {
  3532. config
  3533. }
  3534. // NewPendingAuthSessionClient returns a client for the PendingAuthSession from the given config.
  3535. func NewPendingAuthSessionClient(c config) *PendingAuthSessionClient {
  3536. return &PendingAuthSessionClient{config: c}
  3537. }
  3538. // Use adds a list of mutation hooks to the hooks stack.
  3539. // A call to `Use(f, g, h)` equals to `pendingauthsession.Hooks(f(g(h())))`.
  3540. func (c *PendingAuthSessionClient) Use(hooks ...Hook) {
  3541. c.hooks.PendingAuthSession = append(c.hooks.PendingAuthSession, hooks...)
  3542. }
  3543. // Intercept adds a list of query interceptors to the interceptors stack.
  3544. // A call to `Intercept(f, g, h)` equals to `pendingauthsession.Intercept(f(g(h())))`.
  3545. func (c *PendingAuthSessionClient) Intercept(interceptors ...Interceptor) {
  3546. c.inters.PendingAuthSession = append(c.inters.PendingAuthSession, interceptors...)
  3547. }
  3548. // Create returns a builder for creating a PendingAuthSession entity.
  3549. func (c *PendingAuthSessionClient) Create() *PendingAuthSessionCreate {
  3550. mutation := newPendingAuthSessionMutation(c.config, OpCreate)
  3551. return &PendingAuthSessionCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3552. }
  3553. // CreateBulk returns a builder for creating a bulk of PendingAuthSession entities.
  3554. func (c *PendingAuthSessionClient) CreateBulk(builders ...*PendingAuthSessionCreate) *PendingAuthSessionCreateBulk {
  3555. return &PendingAuthSessionCreateBulk{config: c.config, builders: builders}
  3556. }
  3557. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  3558. // a builder and applies setFunc on it.
  3559. func (c *PendingAuthSessionClient) MapCreateBulk(slice any, setFunc func(*PendingAuthSessionCreate, int)) *PendingAuthSessionCreateBulk {
  3560. rv := reflect.ValueOf(slice)
  3561. if rv.Kind() != reflect.Slice {
  3562. return &PendingAuthSessionCreateBulk{err: fmt.Errorf("calling to PendingAuthSessionClient.MapCreateBulk with wrong type %T, need slice", slice)}
  3563. }
  3564. builders := make([]*PendingAuthSessionCreate, rv.Len())
  3565. for i := 0; i < rv.Len(); i++ {
  3566. builders[i] = c.Create()
  3567. setFunc(builders[i], i)
  3568. }
  3569. return &PendingAuthSessionCreateBulk{config: c.config, builders: builders}
  3570. }
  3571. // Update returns an update builder for PendingAuthSession.
  3572. func (c *PendingAuthSessionClient) Update() *PendingAuthSessionUpdate {
  3573. mutation := newPendingAuthSessionMutation(c.config, OpUpdate)
  3574. return &PendingAuthSessionUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3575. }
  3576. // UpdateOne returns an update builder for the given entity.
  3577. func (c *PendingAuthSessionClient) UpdateOne(_m *PendingAuthSession) *PendingAuthSessionUpdateOne {
  3578. mutation := newPendingAuthSessionMutation(c.config, OpUpdateOne, withPendingAuthSession(_m))
  3579. return &PendingAuthSessionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3580. }
  3581. // UpdateOneID returns an update builder for the given id.
  3582. func (c *PendingAuthSessionClient) UpdateOneID(id int64) *PendingAuthSessionUpdateOne {
  3583. mutation := newPendingAuthSessionMutation(c.config, OpUpdateOne, withPendingAuthSessionID(id))
  3584. return &PendingAuthSessionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3585. }
  3586. // Delete returns a delete builder for PendingAuthSession.
  3587. func (c *PendingAuthSessionClient) Delete() *PendingAuthSessionDelete {
  3588. mutation := newPendingAuthSessionMutation(c.config, OpDelete)
  3589. return &PendingAuthSessionDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3590. }
  3591. // DeleteOne returns a builder for deleting the given entity.
  3592. func (c *PendingAuthSessionClient) DeleteOne(_m *PendingAuthSession) *PendingAuthSessionDeleteOne {
  3593. return c.DeleteOneID(_m.ID)
  3594. }
  3595. // DeleteOneID returns a builder for deleting the given entity by its id.
  3596. func (c *PendingAuthSessionClient) DeleteOneID(id int64) *PendingAuthSessionDeleteOne {
  3597. builder := c.Delete().Where(pendingauthsession.ID(id))
  3598. builder.mutation.id = &id
  3599. builder.mutation.op = OpDeleteOne
  3600. return &PendingAuthSessionDeleteOne{builder}
  3601. }
  3602. // Query returns a query builder for PendingAuthSession.
  3603. func (c *PendingAuthSessionClient) Query() *PendingAuthSessionQuery {
  3604. return &PendingAuthSessionQuery{
  3605. config: c.config,
  3606. ctx: &QueryContext{Type: TypePendingAuthSession},
  3607. inters: c.Interceptors(),
  3608. }
  3609. }
  3610. // Get returns a PendingAuthSession entity by its id.
  3611. func (c *PendingAuthSessionClient) Get(ctx context.Context, id int64) (*PendingAuthSession, error) {
  3612. return c.Query().Where(pendingauthsession.ID(id)).Only(ctx)
  3613. }
  3614. // GetX is like Get, but panics if an error occurs.
  3615. func (c *PendingAuthSessionClient) GetX(ctx context.Context, id int64) *PendingAuthSession {
  3616. obj, err := c.Get(ctx, id)
  3617. if err != nil {
  3618. panic(err)
  3619. }
  3620. return obj
  3621. }
  3622. // QueryTargetUser queries the target_user edge of a PendingAuthSession.
  3623. func (c *PendingAuthSessionClient) QueryTargetUser(_m *PendingAuthSession) *UserQuery {
  3624. query := (&UserClient{config: c.config}).Query()
  3625. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  3626. id := _m.ID
  3627. step := sqlgraph.NewStep(
  3628. sqlgraph.From(pendingauthsession.Table, pendingauthsession.FieldID, id),
  3629. sqlgraph.To(user.Table, user.FieldID),
  3630. sqlgraph.Edge(sqlgraph.M2O, true, pendingauthsession.TargetUserTable, pendingauthsession.TargetUserColumn),
  3631. )
  3632. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  3633. return fromV, nil
  3634. }
  3635. return query
  3636. }
  3637. // QueryAdoptionDecision queries the adoption_decision edge of a PendingAuthSession.
  3638. func (c *PendingAuthSessionClient) QueryAdoptionDecision(_m *PendingAuthSession) *IdentityAdoptionDecisionQuery {
  3639. query := (&IdentityAdoptionDecisionClient{config: c.config}).Query()
  3640. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  3641. id := _m.ID
  3642. step := sqlgraph.NewStep(
  3643. sqlgraph.From(pendingauthsession.Table, pendingauthsession.FieldID, id),
  3644. sqlgraph.To(identityadoptiondecision.Table, identityadoptiondecision.FieldID),
  3645. sqlgraph.Edge(sqlgraph.O2O, false, pendingauthsession.AdoptionDecisionTable, pendingauthsession.AdoptionDecisionColumn),
  3646. )
  3647. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  3648. return fromV, nil
  3649. }
  3650. return query
  3651. }
  3652. // Hooks returns the client hooks.
  3653. func (c *PendingAuthSessionClient) Hooks() []Hook {
  3654. return c.hooks.PendingAuthSession
  3655. }
  3656. // Interceptors returns the client interceptors.
  3657. func (c *PendingAuthSessionClient) Interceptors() []Interceptor {
  3658. return c.inters.PendingAuthSession
  3659. }
  3660. func (c *PendingAuthSessionClient) mutate(ctx context.Context, m *PendingAuthSessionMutation) (Value, error) {
  3661. switch m.Op() {
  3662. case OpCreate:
  3663. return (&PendingAuthSessionCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3664. case OpUpdate:
  3665. return (&PendingAuthSessionUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3666. case OpUpdateOne:
  3667. return (&PendingAuthSessionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3668. case OpDelete, OpDeleteOne:
  3669. return (&PendingAuthSessionDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  3670. default:
  3671. return nil, fmt.Errorf("ent: unknown PendingAuthSession mutation op: %q", m.Op())
  3672. }
  3673. }
  3674. // PromoCodeClient is a client for the PromoCode schema.
  3675. type PromoCodeClient struct {
  3676. config
  3677. }
  3678. // NewPromoCodeClient returns a client for the PromoCode from the given config.
  3679. func NewPromoCodeClient(c config) *PromoCodeClient {
  3680. return &PromoCodeClient{config: c}
  3681. }
  3682. // Use adds a list of mutation hooks to the hooks stack.
  3683. // A call to `Use(f, g, h)` equals to `promocode.Hooks(f(g(h())))`.
  3684. func (c *PromoCodeClient) Use(hooks ...Hook) {
  3685. c.hooks.PromoCode = append(c.hooks.PromoCode, hooks...)
  3686. }
  3687. // Intercept adds a list of query interceptors to the interceptors stack.
  3688. // A call to `Intercept(f, g, h)` equals to `promocode.Intercept(f(g(h())))`.
  3689. func (c *PromoCodeClient) Intercept(interceptors ...Interceptor) {
  3690. c.inters.PromoCode = append(c.inters.PromoCode, interceptors...)
  3691. }
  3692. // Create returns a builder for creating a PromoCode entity.
  3693. func (c *PromoCodeClient) Create() *PromoCodeCreate {
  3694. mutation := newPromoCodeMutation(c.config, OpCreate)
  3695. return &PromoCodeCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3696. }
  3697. // CreateBulk returns a builder for creating a bulk of PromoCode entities.
  3698. func (c *PromoCodeClient) CreateBulk(builders ...*PromoCodeCreate) *PromoCodeCreateBulk {
  3699. return &PromoCodeCreateBulk{config: c.config, builders: builders}
  3700. }
  3701. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  3702. // a builder and applies setFunc on it.
  3703. func (c *PromoCodeClient) MapCreateBulk(slice any, setFunc func(*PromoCodeCreate, int)) *PromoCodeCreateBulk {
  3704. rv := reflect.ValueOf(slice)
  3705. if rv.Kind() != reflect.Slice {
  3706. return &PromoCodeCreateBulk{err: fmt.Errorf("calling to PromoCodeClient.MapCreateBulk with wrong type %T, need slice", slice)}
  3707. }
  3708. builders := make([]*PromoCodeCreate, rv.Len())
  3709. for i := 0; i < rv.Len(); i++ {
  3710. builders[i] = c.Create()
  3711. setFunc(builders[i], i)
  3712. }
  3713. return &PromoCodeCreateBulk{config: c.config, builders: builders}
  3714. }
  3715. // Update returns an update builder for PromoCode.
  3716. func (c *PromoCodeClient) Update() *PromoCodeUpdate {
  3717. mutation := newPromoCodeMutation(c.config, OpUpdate)
  3718. return &PromoCodeUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3719. }
  3720. // UpdateOne returns an update builder for the given entity.
  3721. func (c *PromoCodeClient) UpdateOne(_m *PromoCode) *PromoCodeUpdateOne {
  3722. mutation := newPromoCodeMutation(c.config, OpUpdateOne, withPromoCode(_m))
  3723. return &PromoCodeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3724. }
  3725. // UpdateOneID returns an update builder for the given id.
  3726. func (c *PromoCodeClient) UpdateOneID(id int64) *PromoCodeUpdateOne {
  3727. mutation := newPromoCodeMutation(c.config, OpUpdateOne, withPromoCodeID(id))
  3728. return &PromoCodeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3729. }
  3730. // Delete returns a delete builder for PromoCode.
  3731. func (c *PromoCodeClient) Delete() *PromoCodeDelete {
  3732. mutation := newPromoCodeMutation(c.config, OpDelete)
  3733. return &PromoCodeDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3734. }
  3735. // DeleteOne returns a builder for deleting the given entity.
  3736. func (c *PromoCodeClient) DeleteOne(_m *PromoCode) *PromoCodeDeleteOne {
  3737. return c.DeleteOneID(_m.ID)
  3738. }
  3739. // DeleteOneID returns a builder for deleting the given entity by its id.
  3740. func (c *PromoCodeClient) DeleteOneID(id int64) *PromoCodeDeleteOne {
  3741. builder := c.Delete().Where(promocode.ID(id))
  3742. builder.mutation.id = &id
  3743. builder.mutation.op = OpDeleteOne
  3744. return &PromoCodeDeleteOne{builder}
  3745. }
  3746. // Query returns a query builder for PromoCode.
  3747. func (c *PromoCodeClient) Query() *PromoCodeQuery {
  3748. return &PromoCodeQuery{
  3749. config: c.config,
  3750. ctx: &QueryContext{Type: TypePromoCode},
  3751. inters: c.Interceptors(),
  3752. }
  3753. }
  3754. // Get returns a PromoCode entity by its id.
  3755. func (c *PromoCodeClient) Get(ctx context.Context, id int64) (*PromoCode, error) {
  3756. return c.Query().Where(promocode.ID(id)).Only(ctx)
  3757. }
  3758. // GetX is like Get, but panics if an error occurs.
  3759. func (c *PromoCodeClient) GetX(ctx context.Context, id int64) *PromoCode {
  3760. obj, err := c.Get(ctx, id)
  3761. if err != nil {
  3762. panic(err)
  3763. }
  3764. return obj
  3765. }
  3766. // QueryUsageRecords queries the usage_records edge of a PromoCode.
  3767. func (c *PromoCodeClient) QueryUsageRecords(_m *PromoCode) *PromoCodeUsageQuery {
  3768. query := (&PromoCodeUsageClient{config: c.config}).Query()
  3769. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  3770. id := _m.ID
  3771. step := sqlgraph.NewStep(
  3772. sqlgraph.From(promocode.Table, promocode.FieldID, id),
  3773. sqlgraph.To(promocodeusage.Table, promocodeusage.FieldID),
  3774. sqlgraph.Edge(sqlgraph.O2M, false, promocode.UsageRecordsTable, promocode.UsageRecordsColumn),
  3775. )
  3776. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  3777. return fromV, nil
  3778. }
  3779. return query
  3780. }
  3781. // Hooks returns the client hooks.
  3782. func (c *PromoCodeClient) Hooks() []Hook {
  3783. return c.hooks.PromoCode
  3784. }
  3785. // Interceptors returns the client interceptors.
  3786. func (c *PromoCodeClient) Interceptors() []Interceptor {
  3787. return c.inters.PromoCode
  3788. }
  3789. func (c *PromoCodeClient) mutate(ctx context.Context, m *PromoCodeMutation) (Value, error) {
  3790. switch m.Op() {
  3791. case OpCreate:
  3792. return (&PromoCodeCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3793. case OpUpdate:
  3794. return (&PromoCodeUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3795. case OpUpdateOne:
  3796. return (&PromoCodeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3797. case OpDelete, OpDeleteOne:
  3798. return (&PromoCodeDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  3799. default:
  3800. return nil, fmt.Errorf("ent: unknown PromoCode mutation op: %q", m.Op())
  3801. }
  3802. }
  3803. // PromoCodeUsageClient is a client for the PromoCodeUsage schema.
  3804. type PromoCodeUsageClient struct {
  3805. config
  3806. }
  3807. // NewPromoCodeUsageClient returns a client for the PromoCodeUsage from the given config.
  3808. func NewPromoCodeUsageClient(c config) *PromoCodeUsageClient {
  3809. return &PromoCodeUsageClient{config: c}
  3810. }
  3811. // Use adds a list of mutation hooks to the hooks stack.
  3812. // A call to `Use(f, g, h)` equals to `promocodeusage.Hooks(f(g(h())))`.
  3813. func (c *PromoCodeUsageClient) Use(hooks ...Hook) {
  3814. c.hooks.PromoCodeUsage = append(c.hooks.PromoCodeUsage, hooks...)
  3815. }
  3816. // Intercept adds a list of query interceptors to the interceptors stack.
  3817. // A call to `Intercept(f, g, h)` equals to `promocodeusage.Intercept(f(g(h())))`.
  3818. func (c *PromoCodeUsageClient) Intercept(interceptors ...Interceptor) {
  3819. c.inters.PromoCodeUsage = append(c.inters.PromoCodeUsage, interceptors...)
  3820. }
  3821. // Create returns a builder for creating a PromoCodeUsage entity.
  3822. func (c *PromoCodeUsageClient) Create() *PromoCodeUsageCreate {
  3823. mutation := newPromoCodeUsageMutation(c.config, OpCreate)
  3824. return &PromoCodeUsageCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3825. }
  3826. // CreateBulk returns a builder for creating a bulk of PromoCodeUsage entities.
  3827. func (c *PromoCodeUsageClient) CreateBulk(builders ...*PromoCodeUsageCreate) *PromoCodeUsageCreateBulk {
  3828. return &PromoCodeUsageCreateBulk{config: c.config, builders: builders}
  3829. }
  3830. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  3831. // a builder and applies setFunc on it.
  3832. func (c *PromoCodeUsageClient) MapCreateBulk(slice any, setFunc func(*PromoCodeUsageCreate, int)) *PromoCodeUsageCreateBulk {
  3833. rv := reflect.ValueOf(slice)
  3834. if rv.Kind() != reflect.Slice {
  3835. return &PromoCodeUsageCreateBulk{err: fmt.Errorf("calling to PromoCodeUsageClient.MapCreateBulk with wrong type %T, need slice", slice)}
  3836. }
  3837. builders := make([]*PromoCodeUsageCreate, rv.Len())
  3838. for i := 0; i < rv.Len(); i++ {
  3839. builders[i] = c.Create()
  3840. setFunc(builders[i], i)
  3841. }
  3842. return &PromoCodeUsageCreateBulk{config: c.config, builders: builders}
  3843. }
  3844. // Update returns an update builder for PromoCodeUsage.
  3845. func (c *PromoCodeUsageClient) Update() *PromoCodeUsageUpdate {
  3846. mutation := newPromoCodeUsageMutation(c.config, OpUpdate)
  3847. return &PromoCodeUsageUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3848. }
  3849. // UpdateOne returns an update builder for the given entity.
  3850. func (c *PromoCodeUsageClient) UpdateOne(_m *PromoCodeUsage) *PromoCodeUsageUpdateOne {
  3851. mutation := newPromoCodeUsageMutation(c.config, OpUpdateOne, withPromoCodeUsage(_m))
  3852. return &PromoCodeUsageUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3853. }
  3854. // UpdateOneID returns an update builder for the given id.
  3855. func (c *PromoCodeUsageClient) UpdateOneID(id int64) *PromoCodeUsageUpdateOne {
  3856. mutation := newPromoCodeUsageMutation(c.config, OpUpdateOne, withPromoCodeUsageID(id))
  3857. return &PromoCodeUsageUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3858. }
  3859. // Delete returns a delete builder for PromoCodeUsage.
  3860. func (c *PromoCodeUsageClient) Delete() *PromoCodeUsageDelete {
  3861. mutation := newPromoCodeUsageMutation(c.config, OpDelete)
  3862. return &PromoCodeUsageDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3863. }
  3864. // DeleteOne returns a builder for deleting the given entity.
  3865. func (c *PromoCodeUsageClient) DeleteOne(_m *PromoCodeUsage) *PromoCodeUsageDeleteOne {
  3866. return c.DeleteOneID(_m.ID)
  3867. }
  3868. // DeleteOneID returns a builder for deleting the given entity by its id.
  3869. func (c *PromoCodeUsageClient) DeleteOneID(id int64) *PromoCodeUsageDeleteOne {
  3870. builder := c.Delete().Where(promocodeusage.ID(id))
  3871. builder.mutation.id = &id
  3872. builder.mutation.op = OpDeleteOne
  3873. return &PromoCodeUsageDeleteOne{builder}
  3874. }
  3875. // Query returns a query builder for PromoCodeUsage.
  3876. func (c *PromoCodeUsageClient) Query() *PromoCodeUsageQuery {
  3877. return &PromoCodeUsageQuery{
  3878. config: c.config,
  3879. ctx: &QueryContext{Type: TypePromoCodeUsage},
  3880. inters: c.Interceptors(),
  3881. }
  3882. }
  3883. // Get returns a PromoCodeUsage entity by its id.
  3884. func (c *PromoCodeUsageClient) Get(ctx context.Context, id int64) (*PromoCodeUsage, error) {
  3885. return c.Query().Where(promocodeusage.ID(id)).Only(ctx)
  3886. }
  3887. // GetX is like Get, but panics if an error occurs.
  3888. func (c *PromoCodeUsageClient) GetX(ctx context.Context, id int64) *PromoCodeUsage {
  3889. obj, err := c.Get(ctx, id)
  3890. if err != nil {
  3891. panic(err)
  3892. }
  3893. return obj
  3894. }
  3895. // QueryPromoCode queries the promo_code edge of a PromoCodeUsage.
  3896. func (c *PromoCodeUsageClient) QueryPromoCode(_m *PromoCodeUsage) *PromoCodeQuery {
  3897. query := (&PromoCodeClient{config: c.config}).Query()
  3898. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  3899. id := _m.ID
  3900. step := sqlgraph.NewStep(
  3901. sqlgraph.From(promocodeusage.Table, promocodeusage.FieldID, id),
  3902. sqlgraph.To(promocode.Table, promocode.FieldID),
  3903. sqlgraph.Edge(sqlgraph.M2O, true, promocodeusage.PromoCodeTable, promocodeusage.PromoCodeColumn),
  3904. )
  3905. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  3906. return fromV, nil
  3907. }
  3908. return query
  3909. }
  3910. // QueryUser queries the user edge of a PromoCodeUsage.
  3911. func (c *PromoCodeUsageClient) QueryUser(_m *PromoCodeUsage) *UserQuery {
  3912. query := (&UserClient{config: c.config}).Query()
  3913. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  3914. id := _m.ID
  3915. step := sqlgraph.NewStep(
  3916. sqlgraph.From(promocodeusage.Table, promocodeusage.FieldID, id),
  3917. sqlgraph.To(user.Table, user.FieldID),
  3918. sqlgraph.Edge(sqlgraph.M2O, true, promocodeusage.UserTable, promocodeusage.UserColumn),
  3919. )
  3920. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  3921. return fromV, nil
  3922. }
  3923. return query
  3924. }
  3925. // Hooks returns the client hooks.
  3926. func (c *PromoCodeUsageClient) Hooks() []Hook {
  3927. return c.hooks.PromoCodeUsage
  3928. }
  3929. // Interceptors returns the client interceptors.
  3930. func (c *PromoCodeUsageClient) Interceptors() []Interceptor {
  3931. return c.inters.PromoCodeUsage
  3932. }
  3933. func (c *PromoCodeUsageClient) mutate(ctx context.Context, m *PromoCodeUsageMutation) (Value, error) {
  3934. switch m.Op() {
  3935. case OpCreate:
  3936. return (&PromoCodeUsageCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3937. case OpUpdate:
  3938. return (&PromoCodeUsageUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3939. case OpUpdateOne:
  3940. return (&PromoCodeUsageUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3941. case OpDelete, OpDeleteOne:
  3942. return (&PromoCodeUsageDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  3943. default:
  3944. return nil, fmt.Errorf("ent: unknown PromoCodeUsage mutation op: %q", m.Op())
  3945. }
  3946. }
  3947. // ProxyClient is a client for the Proxy schema.
  3948. type ProxyClient struct {
  3949. config
  3950. }
  3951. // NewProxyClient returns a client for the Proxy from the given config.
  3952. func NewProxyClient(c config) *ProxyClient {
  3953. return &ProxyClient{config: c}
  3954. }
  3955. // Use adds a list of mutation hooks to the hooks stack.
  3956. // A call to `Use(f, g, h)` equals to `proxy.Hooks(f(g(h())))`.
  3957. func (c *ProxyClient) Use(hooks ...Hook) {
  3958. c.hooks.Proxy = append(c.hooks.Proxy, hooks...)
  3959. }
  3960. // Intercept adds a list of query interceptors to the interceptors stack.
  3961. // A call to `Intercept(f, g, h)` equals to `proxy.Intercept(f(g(h())))`.
  3962. func (c *ProxyClient) Intercept(interceptors ...Interceptor) {
  3963. c.inters.Proxy = append(c.inters.Proxy, interceptors...)
  3964. }
  3965. // Create returns a builder for creating a Proxy entity.
  3966. func (c *ProxyClient) Create() *ProxyCreate {
  3967. mutation := newProxyMutation(c.config, OpCreate)
  3968. return &ProxyCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3969. }
  3970. // CreateBulk returns a builder for creating a bulk of Proxy entities.
  3971. func (c *ProxyClient) CreateBulk(builders ...*ProxyCreate) *ProxyCreateBulk {
  3972. return &ProxyCreateBulk{config: c.config, builders: builders}
  3973. }
  3974. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  3975. // a builder and applies setFunc on it.
  3976. func (c *ProxyClient) MapCreateBulk(slice any, setFunc func(*ProxyCreate, int)) *ProxyCreateBulk {
  3977. rv := reflect.ValueOf(slice)
  3978. if rv.Kind() != reflect.Slice {
  3979. return &ProxyCreateBulk{err: fmt.Errorf("calling to ProxyClient.MapCreateBulk with wrong type %T, need slice", slice)}
  3980. }
  3981. builders := make([]*ProxyCreate, rv.Len())
  3982. for i := 0; i < rv.Len(); i++ {
  3983. builders[i] = c.Create()
  3984. setFunc(builders[i], i)
  3985. }
  3986. return &ProxyCreateBulk{config: c.config, builders: builders}
  3987. }
  3988. // Update returns an update builder for Proxy.
  3989. func (c *ProxyClient) Update() *ProxyUpdate {
  3990. mutation := newProxyMutation(c.config, OpUpdate)
  3991. return &ProxyUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3992. }
  3993. // UpdateOne returns an update builder for the given entity.
  3994. func (c *ProxyClient) UpdateOne(_m *Proxy) *ProxyUpdateOne {
  3995. mutation := newProxyMutation(c.config, OpUpdateOne, withProxy(_m))
  3996. return &ProxyUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3997. }
  3998. // UpdateOneID returns an update builder for the given id.
  3999. func (c *ProxyClient) UpdateOneID(id int64) *ProxyUpdateOne {
  4000. mutation := newProxyMutation(c.config, OpUpdateOne, withProxyID(id))
  4001. return &ProxyUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4002. }
  4003. // Delete returns a delete builder for Proxy.
  4004. func (c *ProxyClient) Delete() *ProxyDelete {
  4005. mutation := newProxyMutation(c.config, OpDelete)
  4006. return &ProxyDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4007. }
  4008. // DeleteOne returns a builder for deleting the given entity.
  4009. func (c *ProxyClient) DeleteOne(_m *Proxy) *ProxyDeleteOne {
  4010. return c.DeleteOneID(_m.ID)
  4011. }
  4012. // DeleteOneID returns a builder for deleting the given entity by its id.
  4013. func (c *ProxyClient) DeleteOneID(id int64) *ProxyDeleteOne {
  4014. builder := c.Delete().Where(proxy.ID(id))
  4015. builder.mutation.id = &id
  4016. builder.mutation.op = OpDeleteOne
  4017. return &ProxyDeleteOne{builder}
  4018. }
  4019. // Query returns a query builder for Proxy.
  4020. func (c *ProxyClient) Query() *ProxyQuery {
  4021. return &ProxyQuery{
  4022. config: c.config,
  4023. ctx: &QueryContext{Type: TypeProxy},
  4024. inters: c.Interceptors(),
  4025. }
  4026. }
  4027. // Get returns a Proxy entity by its id.
  4028. func (c *ProxyClient) Get(ctx context.Context, id int64) (*Proxy, error) {
  4029. return c.Query().Where(proxy.ID(id)).Only(ctx)
  4030. }
  4031. // GetX is like Get, but panics if an error occurs.
  4032. func (c *ProxyClient) GetX(ctx context.Context, id int64) *Proxy {
  4033. obj, err := c.Get(ctx, id)
  4034. if err != nil {
  4035. panic(err)
  4036. }
  4037. return obj
  4038. }
  4039. // QueryAccounts queries the accounts edge of a Proxy.
  4040. func (c *ProxyClient) QueryAccounts(_m *Proxy) *AccountQuery {
  4041. query := (&AccountClient{config: c.config}).Query()
  4042. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  4043. id := _m.ID
  4044. step := sqlgraph.NewStep(
  4045. sqlgraph.From(proxy.Table, proxy.FieldID, id),
  4046. sqlgraph.To(account.Table, account.FieldID),
  4047. sqlgraph.Edge(sqlgraph.O2M, true, proxy.AccountsTable, proxy.AccountsColumn),
  4048. )
  4049. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  4050. return fromV, nil
  4051. }
  4052. return query
  4053. }
  4054. // QueryPrimaryProxies queries the primary_proxies edge of a Proxy.
  4055. func (c *ProxyClient) QueryPrimaryProxies(_m *Proxy) *ProxyQuery {
  4056. query := (&ProxyClient{config: c.config}).Query()
  4057. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  4058. id := _m.ID
  4059. step := sqlgraph.NewStep(
  4060. sqlgraph.From(proxy.Table, proxy.FieldID, id),
  4061. sqlgraph.To(proxy.Table, proxy.FieldID),
  4062. sqlgraph.Edge(sqlgraph.O2M, true, proxy.PrimaryProxiesTable, proxy.PrimaryProxiesColumn),
  4063. )
  4064. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  4065. return fromV, nil
  4066. }
  4067. return query
  4068. }
  4069. // QueryBackupProxy queries the backup_proxy edge of a Proxy.
  4070. func (c *ProxyClient) QueryBackupProxy(_m *Proxy) *ProxyQuery {
  4071. query := (&ProxyClient{config: c.config}).Query()
  4072. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  4073. id := _m.ID
  4074. step := sqlgraph.NewStep(
  4075. sqlgraph.From(proxy.Table, proxy.FieldID, id),
  4076. sqlgraph.To(proxy.Table, proxy.FieldID),
  4077. sqlgraph.Edge(sqlgraph.M2O, false, proxy.BackupProxyTable, proxy.BackupProxyColumn),
  4078. )
  4079. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  4080. return fromV, nil
  4081. }
  4082. return query
  4083. }
  4084. // Hooks returns the client hooks.
  4085. func (c *ProxyClient) Hooks() []Hook {
  4086. hooks := c.hooks.Proxy
  4087. return append(hooks[:len(hooks):len(hooks)], proxy.Hooks[:]...)
  4088. }
  4089. // Interceptors returns the client interceptors.
  4090. func (c *ProxyClient) Interceptors() []Interceptor {
  4091. inters := c.inters.Proxy
  4092. return append(inters[:len(inters):len(inters)], proxy.Interceptors[:]...)
  4093. }
  4094. func (c *ProxyClient) mutate(ctx context.Context, m *ProxyMutation) (Value, error) {
  4095. switch m.Op() {
  4096. case OpCreate:
  4097. return (&ProxyCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4098. case OpUpdate:
  4099. return (&ProxyUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4100. case OpUpdateOne:
  4101. return (&ProxyUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4102. case OpDelete, OpDeleteOne:
  4103. return (&ProxyDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  4104. default:
  4105. return nil, fmt.Errorf("ent: unknown Proxy mutation op: %q", m.Op())
  4106. }
  4107. }
  4108. // RedeemCodeClient is a client for the RedeemCode schema.
  4109. type RedeemCodeClient struct {
  4110. config
  4111. }
  4112. // NewRedeemCodeClient returns a client for the RedeemCode from the given config.
  4113. func NewRedeemCodeClient(c config) *RedeemCodeClient {
  4114. return &RedeemCodeClient{config: c}
  4115. }
  4116. // Use adds a list of mutation hooks to the hooks stack.
  4117. // A call to `Use(f, g, h)` equals to `redeemcode.Hooks(f(g(h())))`.
  4118. func (c *RedeemCodeClient) Use(hooks ...Hook) {
  4119. c.hooks.RedeemCode = append(c.hooks.RedeemCode, hooks...)
  4120. }
  4121. // Intercept adds a list of query interceptors to the interceptors stack.
  4122. // A call to `Intercept(f, g, h)` equals to `redeemcode.Intercept(f(g(h())))`.
  4123. func (c *RedeemCodeClient) Intercept(interceptors ...Interceptor) {
  4124. c.inters.RedeemCode = append(c.inters.RedeemCode, interceptors...)
  4125. }
  4126. // Create returns a builder for creating a RedeemCode entity.
  4127. func (c *RedeemCodeClient) Create() *RedeemCodeCreate {
  4128. mutation := newRedeemCodeMutation(c.config, OpCreate)
  4129. return &RedeemCodeCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4130. }
  4131. // CreateBulk returns a builder for creating a bulk of RedeemCode entities.
  4132. func (c *RedeemCodeClient) CreateBulk(builders ...*RedeemCodeCreate) *RedeemCodeCreateBulk {
  4133. return &RedeemCodeCreateBulk{config: c.config, builders: builders}
  4134. }
  4135. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  4136. // a builder and applies setFunc on it.
  4137. func (c *RedeemCodeClient) MapCreateBulk(slice any, setFunc func(*RedeemCodeCreate, int)) *RedeemCodeCreateBulk {
  4138. rv := reflect.ValueOf(slice)
  4139. if rv.Kind() != reflect.Slice {
  4140. return &RedeemCodeCreateBulk{err: fmt.Errorf("calling to RedeemCodeClient.MapCreateBulk with wrong type %T, need slice", slice)}
  4141. }
  4142. builders := make([]*RedeemCodeCreate, rv.Len())
  4143. for i := 0; i < rv.Len(); i++ {
  4144. builders[i] = c.Create()
  4145. setFunc(builders[i], i)
  4146. }
  4147. return &RedeemCodeCreateBulk{config: c.config, builders: builders}
  4148. }
  4149. // Update returns an update builder for RedeemCode.
  4150. func (c *RedeemCodeClient) Update() *RedeemCodeUpdate {
  4151. mutation := newRedeemCodeMutation(c.config, OpUpdate)
  4152. return &RedeemCodeUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4153. }
  4154. // UpdateOne returns an update builder for the given entity.
  4155. func (c *RedeemCodeClient) UpdateOne(_m *RedeemCode) *RedeemCodeUpdateOne {
  4156. mutation := newRedeemCodeMutation(c.config, OpUpdateOne, withRedeemCode(_m))
  4157. return &RedeemCodeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4158. }
  4159. // UpdateOneID returns an update builder for the given id.
  4160. func (c *RedeemCodeClient) UpdateOneID(id int64) *RedeemCodeUpdateOne {
  4161. mutation := newRedeemCodeMutation(c.config, OpUpdateOne, withRedeemCodeID(id))
  4162. return &RedeemCodeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4163. }
  4164. // Delete returns a delete builder for RedeemCode.
  4165. func (c *RedeemCodeClient) Delete() *RedeemCodeDelete {
  4166. mutation := newRedeemCodeMutation(c.config, OpDelete)
  4167. return &RedeemCodeDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4168. }
  4169. // DeleteOne returns a builder for deleting the given entity.
  4170. func (c *RedeemCodeClient) DeleteOne(_m *RedeemCode) *RedeemCodeDeleteOne {
  4171. return c.DeleteOneID(_m.ID)
  4172. }
  4173. // DeleteOneID returns a builder for deleting the given entity by its id.
  4174. func (c *RedeemCodeClient) DeleteOneID(id int64) *RedeemCodeDeleteOne {
  4175. builder := c.Delete().Where(redeemcode.ID(id))
  4176. builder.mutation.id = &id
  4177. builder.mutation.op = OpDeleteOne
  4178. return &RedeemCodeDeleteOne{builder}
  4179. }
  4180. // Query returns a query builder for RedeemCode.
  4181. func (c *RedeemCodeClient) Query() *RedeemCodeQuery {
  4182. return &RedeemCodeQuery{
  4183. config: c.config,
  4184. ctx: &QueryContext{Type: TypeRedeemCode},
  4185. inters: c.Interceptors(),
  4186. }
  4187. }
  4188. // Get returns a RedeemCode entity by its id.
  4189. func (c *RedeemCodeClient) Get(ctx context.Context, id int64) (*RedeemCode, error) {
  4190. return c.Query().Where(redeemcode.ID(id)).Only(ctx)
  4191. }
  4192. // GetX is like Get, but panics if an error occurs.
  4193. func (c *RedeemCodeClient) GetX(ctx context.Context, id int64) *RedeemCode {
  4194. obj, err := c.Get(ctx, id)
  4195. if err != nil {
  4196. panic(err)
  4197. }
  4198. return obj
  4199. }
  4200. // QueryUser queries the user edge of a RedeemCode.
  4201. func (c *RedeemCodeClient) QueryUser(_m *RedeemCode) *UserQuery {
  4202. query := (&UserClient{config: c.config}).Query()
  4203. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  4204. id := _m.ID
  4205. step := sqlgraph.NewStep(
  4206. sqlgraph.From(redeemcode.Table, redeemcode.FieldID, id),
  4207. sqlgraph.To(user.Table, user.FieldID),
  4208. sqlgraph.Edge(sqlgraph.M2O, true, redeemcode.UserTable, redeemcode.UserColumn),
  4209. )
  4210. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  4211. return fromV, nil
  4212. }
  4213. return query
  4214. }
  4215. // QueryGroup queries the group edge of a RedeemCode.
  4216. func (c *RedeemCodeClient) QueryGroup(_m *RedeemCode) *GroupQuery {
  4217. query := (&GroupClient{config: c.config}).Query()
  4218. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  4219. id := _m.ID
  4220. step := sqlgraph.NewStep(
  4221. sqlgraph.From(redeemcode.Table, redeemcode.FieldID, id),
  4222. sqlgraph.To(group.Table, group.FieldID),
  4223. sqlgraph.Edge(sqlgraph.M2O, true, redeemcode.GroupTable, redeemcode.GroupColumn),
  4224. )
  4225. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  4226. return fromV, nil
  4227. }
  4228. return query
  4229. }
  4230. // Hooks returns the client hooks.
  4231. func (c *RedeemCodeClient) Hooks() []Hook {
  4232. return c.hooks.RedeemCode
  4233. }
  4234. // Interceptors returns the client interceptors.
  4235. func (c *RedeemCodeClient) Interceptors() []Interceptor {
  4236. return c.inters.RedeemCode
  4237. }
  4238. func (c *RedeemCodeClient) mutate(ctx context.Context, m *RedeemCodeMutation) (Value, error) {
  4239. switch m.Op() {
  4240. case OpCreate:
  4241. return (&RedeemCodeCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4242. case OpUpdate:
  4243. return (&RedeemCodeUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4244. case OpUpdateOne:
  4245. return (&RedeemCodeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4246. case OpDelete, OpDeleteOne:
  4247. return (&RedeemCodeDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  4248. default:
  4249. return nil, fmt.Errorf("ent: unknown RedeemCode mutation op: %q", m.Op())
  4250. }
  4251. }
  4252. // SecurityPolicyKeywordClient is a client for the SecurityPolicyKeyword schema.
  4253. type SecurityPolicyKeywordClient struct {
  4254. config
  4255. }
  4256. // NewSecurityPolicyKeywordClient returns a client for the SecurityPolicyKeyword from the given config.
  4257. func NewSecurityPolicyKeywordClient(c config) *SecurityPolicyKeywordClient {
  4258. return &SecurityPolicyKeywordClient{config: c}
  4259. }
  4260. // Use adds a list of mutation hooks to the hooks stack.
  4261. // A call to `Use(f, g, h)` equals to `securitypolicykeyword.Hooks(f(g(h())))`.
  4262. func (c *SecurityPolicyKeywordClient) Use(hooks ...Hook) {
  4263. c.hooks.SecurityPolicyKeyword = append(c.hooks.SecurityPolicyKeyword, hooks...)
  4264. }
  4265. // Intercept adds a list of query interceptors to the interceptors stack.
  4266. // A call to `Intercept(f, g, h)` equals to `securitypolicykeyword.Intercept(f(g(h())))`.
  4267. func (c *SecurityPolicyKeywordClient) Intercept(interceptors ...Interceptor) {
  4268. c.inters.SecurityPolicyKeyword = append(c.inters.SecurityPolicyKeyword, interceptors...)
  4269. }
  4270. // Create returns a builder for creating a SecurityPolicyKeyword entity.
  4271. func (c *SecurityPolicyKeywordClient) Create() *SecurityPolicyKeywordCreate {
  4272. mutation := newSecurityPolicyKeywordMutation(c.config, OpCreate)
  4273. return &SecurityPolicyKeywordCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4274. }
  4275. // CreateBulk returns a builder for creating a bulk of SecurityPolicyKeyword entities.
  4276. func (c *SecurityPolicyKeywordClient) CreateBulk(builders ...*SecurityPolicyKeywordCreate) *SecurityPolicyKeywordCreateBulk {
  4277. return &SecurityPolicyKeywordCreateBulk{config: c.config, builders: builders}
  4278. }
  4279. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  4280. // a builder and applies setFunc on it.
  4281. func (c *SecurityPolicyKeywordClient) MapCreateBulk(slice any, setFunc func(*SecurityPolicyKeywordCreate, int)) *SecurityPolicyKeywordCreateBulk {
  4282. rv := reflect.ValueOf(slice)
  4283. if rv.Kind() != reflect.Slice {
  4284. return &SecurityPolicyKeywordCreateBulk{err: fmt.Errorf("calling to SecurityPolicyKeywordClient.MapCreateBulk with wrong type %T, need slice", slice)}
  4285. }
  4286. builders := make([]*SecurityPolicyKeywordCreate, rv.Len())
  4287. for i := 0; i < rv.Len(); i++ {
  4288. builders[i] = c.Create()
  4289. setFunc(builders[i], i)
  4290. }
  4291. return &SecurityPolicyKeywordCreateBulk{config: c.config, builders: builders}
  4292. }
  4293. // Update returns an update builder for SecurityPolicyKeyword.
  4294. func (c *SecurityPolicyKeywordClient) Update() *SecurityPolicyKeywordUpdate {
  4295. mutation := newSecurityPolicyKeywordMutation(c.config, OpUpdate)
  4296. return &SecurityPolicyKeywordUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4297. }
  4298. // UpdateOne returns an update builder for the given entity.
  4299. func (c *SecurityPolicyKeywordClient) UpdateOne(_m *SecurityPolicyKeyword) *SecurityPolicyKeywordUpdateOne {
  4300. mutation := newSecurityPolicyKeywordMutation(c.config, OpUpdateOne, withSecurityPolicyKeyword(_m))
  4301. return &SecurityPolicyKeywordUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4302. }
  4303. // UpdateOneID returns an update builder for the given id.
  4304. func (c *SecurityPolicyKeywordClient) UpdateOneID(id int64) *SecurityPolicyKeywordUpdateOne {
  4305. mutation := newSecurityPolicyKeywordMutation(c.config, OpUpdateOne, withSecurityPolicyKeywordID(id))
  4306. return &SecurityPolicyKeywordUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4307. }
  4308. // Delete returns a delete builder for SecurityPolicyKeyword.
  4309. func (c *SecurityPolicyKeywordClient) Delete() *SecurityPolicyKeywordDelete {
  4310. mutation := newSecurityPolicyKeywordMutation(c.config, OpDelete)
  4311. return &SecurityPolicyKeywordDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4312. }
  4313. // DeleteOne returns a builder for deleting the given entity.
  4314. func (c *SecurityPolicyKeywordClient) DeleteOne(_m *SecurityPolicyKeyword) *SecurityPolicyKeywordDeleteOne {
  4315. return c.DeleteOneID(_m.ID)
  4316. }
  4317. // DeleteOneID returns a builder for deleting the given entity by its id.
  4318. func (c *SecurityPolicyKeywordClient) DeleteOneID(id int64) *SecurityPolicyKeywordDeleteOne {
  4319. builder := c.Delete().Where(securitypolicykeyword.ID(id))
  4320. builder.mutation.id = &id
  4321. builder.mutation.op = OpDeleteOne
  4322. return &SecurityPolicyKeywordDeleteOne{builder}
  4323. }
  4324. // Query returns a query builder for SecurityPolicyKeyword.
  4325. func (c *SecurityPolicyKeywordClient) Query() *SecurityPolicyKeywordQuery {
  4326. return &SecurityPolicyKeywordQuery{
  4327. config: c.config,
  4328. ctx: &QueryContext{Type: TypeSecurityPolicyKeyword},
  4329. inters: c.Interceptors(),
  4330. }
  4331. }
  4332. // Get returns a SecurityPolicyKeyword entity by its id.
  4333. func (c *SecurityPolicyKeywordClient) Get(ctx context.Context, id int64) (*SecurityPolicyKeyword, error) {
  4334. return c.Query().Where(securitypolicykeyword.ID(id)).Only(ctx)
  4335. }
  4336. // GetX is like Get, but panics if an error occurs.
  4337. func (c *SecurityPolicyKeywordClient) GetX(ctx context.Context, id int64) *SecurityPolicyKeyword {
  4338. obj, err := c.Get(ctx, id)
  4339. if err != nil {
  4340. panic(err)
  4341. }
  4342. return obj
  4343. }
  4344. // QueryGroup queries the group edge of a SecurityPolicyKeyword.
  4345. func (c *SecurityPolicyKeywordClient) QueryGroup(_m *SecurityPolicyKeyword) *GroupQuery {
  4346. query := (&GroupClient{config: c.config}).Query()
  4347. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  4348. id := _m.ID
  4349. step := sqlgraph.NewStep(
  4350. sqlgraph.From(securitypolicykeyword.Table, securitypolicykeyword.FieldID, id),
  4351. sqlgraph.To(group.Table, group.FieldID),
  4352. sqlgraph.Edge(sqlgraph.M2O, false, securitypolicykeyword.GroupTable, securitypolicykeyword.GroupColumn),
  4353. )
  4354. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  4355. return fromV, nil
  4356. }
  4357. return query
  4358. }
  4359. // Hooks returns the client hooks.
  4360. func (c *SecurityPolicyKeywordClient) Hooks() []Hook {
  4361. hooks := c.hooks.SecurityPolicyKeyword
  4362. return append(hooks[:len(hooks):len(hooks)], securitypolicykeyword.Hooks[:]...)
  4363. }
  4364. // Interceptors returns the client interceptors.
  4365. func (c *SecurityPolicyKeywordClient) Interceptors() []Interceptor {
  4366. inters := c.inters.SecurityPolicyKeyword
  4367. return append(inters[:len(inters):len(inters)], securitypolicykeyword.Interceptors[:]...)
  4368. }
  4369. func (c *SecurityPolicyKeywordClient) mutate(ctx context.Context, m *SecurityPolicyKeywordMutation) (Value, error) {
  4370. switch m.Op() {
  4371. case OpCreate:
  4372. return (&SecurityPolicyKeywordCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4373. case OpUpdate:
  4374. return (&SecurityPolicyKeywordUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4375. case OpUpdateOne:
  4376. return (&SecurityPolicyKeywordUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4377. case OpDelete, OpDeleteOne:
  4378. return (&SecurityPolicyKeywordDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  4379. default:
  4380. return nil, fmt.Errorf("ent: unknown SecurityPolicyKeyword mutation op: %q", m.Op())
  4381. }
  4382. }
  4383. // SecuritySecretClient is a client for the SecuritySecret schema.
  4384. type SecuritySecretClient struct {
  4385. config
  4386. }
  4387. // NewSecuritySecretClient returns a client for the SecuritySecret from the given config.
  4388. func NewSecuritySecretClient(c config) *SecuritySecretClient {
  4389. return &SecuritySecretClient{config: c}
  4390. }
  4391. // Use adds a list of mutation hooks to the hooks stack.
  4392. // A call to `Use(f, g, h)` equals to `securitysecret.Hooks(f(g(h())))`.
  4393. func (c *SecuritySecretClient) Use(hooks ...Hook) {
  4394. c.hooks.SecuritySecret = append(c.hooks.SecuritySecret, hooks...)
  4395. }
  4396. // Intercept adds a list of query interceptors to the interceptors stack.
  4397. // A call to `Intercept(f, g, h)` equals to `securitysecret.Intercept(f(g(h())))`.
  4398. func (c *SecuritySecretClient) Intercept(interceptors ...Interceptor) {
  4399. c.inters.SecuritySecret = append(c.inters.SecuritySecret, interceptors...)
  4400. }
  4401. // Create returns a builder for creating a SecuritySecret entity.
  4402. func (c *SecuritySecretClient) Create() *SecuritySecretCreate {
  4403. mutation := newSecuritySecretMutation(c.config, OpCreate)
  4404. return &SecuritySecretCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4405. }
  4406. // CreateBulk returns a builder for creating a bulk of SecuritySecret entities.
  4407. func (c *SecuritySecretClient) CreateBulk(builders ...*SecuritySecretCreate) *SecuritySecretCreateBulk {
  4408. return &SecuritySecretCreateBulk{config: c.config, builders: builders}
  4409. }
  4410. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  4411. // a builder and applies setFunc on it.
  4412. func (c *SecuritySecretClient) MapCreateBulk(slice any, setFunc func(*SecuritySecretCreate, int)) *SecuritySecretCreateBulk {
  4413. rv := reflect.ValueOf(slice)
  4414. if rv.Kind() != reflect.Slice {
  4415. return &SecuritySecretCreateBulk{err: fmt.Errorf("calling to SecuritySecretClient.MapCreateBulk with wrong type %T, need slice", slice)}
  4416. }
  4417. builders := make([]*SecuritySecretCreate, rv.Len())
  4418. for i := 0; i < rv.Len(); i++ {
  4419. builders[i] = c.Create()
  4420. setFunc(builders[i], i)
  4421. }
  4422. return &SecuritySecretCreateBulk{config: c.config, builders: builders}
  4423. }
  4424. // Update returns an update builder for SecuritySecret.
  4425. func (c *SecuritySecretClient) Update() *SecuritySecretUpdate {
  4426. mutation := newSecuritySecretMutation(c.config, OpUpdate)
  4427. return &SecuritySecretUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4428. }
  4429. // UpdateOne returns an update builder for the given entity.
  4430. func (c *SecuritySecretClient) UpdateOne(_m *SecuritySecret) *SecuritySecretUpdateOne {
  4431. mutation := newSecuritySecretMutation(c.config, OpUpdateOne, withSecuritySecret(_m))
  4432. return &SecuritySecretUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4433. }
  4434. // UpdateOneID returns an update builder for the given id.
  4435. func (c *SecuritySecretClient) UpdateOneID(id int64) *SecuritySecretUpdateOne {
  4436. mutation := newSecuritySecretMutation(c.config, OpUpdateOne, withSecuritySecretID(id))
  4437. return &SecuritySecretUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4438. }
  4439. // Delete returns a delete builder for SecuritySecret.
  4440. func (c *SecuritySecretClient) Delete() *SecuritySecretDelete {
  4441. mutation := newSecuritySecretMutation(c.config, OpDelete)
  4442. return &SecuritySecretDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4443. }
  4444. // DeleteOne returns a builder for deleting the given entity.
  4445. func (c *SecuritySecretClient) DeleteOne(_m *SecuritySecret) *SecuritySecretDeleteOne {
  4446. return c.DeleteOneID(_m.ID)
  4447. }
  4448. // DeleteOneID returns a builder for deleting the given entity by its id.
  4449. func (c *SecuritySecretClient) DeleteOneID(id int64) *SecuritySecretDeleteOne {
  4450. builder := c.Delete().Where(securitysecret.ID(id))
  4451. builder.mutation.id = &id
  4452. builder.mutation.op = OpDeleteOne
  4453. return &SecuritySecretDeleteOne{builder}
  4454. }
  4455. // Query returns a query builder for SecuritySecret.
  4456. func (c *SecuritySecretClient) Query() *SecuritySecretQuery {
  4457. return &SecuritySecretQuery{
  4458. config: c.config,
  4459. ctx: &QueryContext{Type: TypeSecuritySecret},
  4460. inters: c.Interceptors(),
  4461. }
  4462. }
  4463. // Get returns a SecuritySecret entity by its id.
  4464. func (c *SecuritySecretClient) Get(ctx context.Context, id int64) (*SecuritySecret, error) {
  4465. return c.Query().Where(securitysecret.ID(id)).Only(ctx)
  4466. }
  4467. // GetX is like Get, but panics if an error occurs.
  4468. func (c *SecuritySecretClient) GetX(ctx context.Context, id int64) *SecuritySecret {
  4469. obj, err := c.Get(ctx, id)
  4470. if err != nil {
  4471. panic(err)
  4472. }
  4473. return obj
  4474. }
  4475. // Hooks returns the client hooks.
  4476. func (c *SecuritySecretClient) Hooks() []Hook {
  4477. return c.hooks.SecuritySecret
  4478. }
  4479. // Interceptors returns the client interceptors.
  4480. func (c *SecuritySecretClient) Interceptors() []Interceptor {
  4481. return c.inters.SecuritySecret
  4482. }
  4483. func (c *SecuritySecretClient) mutate(ctx context.Context, m *SecuritySecretMutation) (Value, error) {
  4484. switch m.Op() {
  4485. case OpCreate:
  4486. return (&SecuritySecretCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4487. case OpUpdate:
  4488. return (&SecuritySecretUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4489. case OpUpdateOne:
  4490. return (&SecuritySecretUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4491. case OpDelete, OpDeleteOne:
  4492. return (&SecuritySecretDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  4493. default:
  4494. return nil, fmt.Errorf("ent: unknown SecuritySecret mutation op: %q", m.Op())
  4495. }
  4496. }
  4497. // SettingClient is a client for the Setting schema.
  4498. type SettingClient struct {
  4499. config
  4500. }
  4501. // NewSettingClient returns a client for the Setting from the given config.
  4502. func NewSettingClient(c config) *SettingClient {
  4503. return &SettingClient{config: c}
  4504. }
  4505. // Use adds a list of mutation hooks to the hooks stack.
  4506. // A call to `Use(f, g, h)` equals to `setting.Hooks(f(g(h())))`.
  4507. func (c *SettingClient) Use(hooks ...Hook) {
  4508. c.hooks.Setting = append(c.hooks.Setting, hooks...)
  4509. }
  4510. // Intercept adds a list of query interceptors to the interceptors stack.
  4511. // A call to `Intercept(f, g, h)` equals to `setting.Intercept(f(g(h())))`.
  4512. func (c *SettingClient) Intercept(interceptors ...Interceptor) {
  4513. c.inters.Setting = append(c.inters.Setting, interceptors...)
  4514. }
  4515. // Create returns a builder for creating a Setting entity.
  4516. func (c *SettingClient) Create() *SettingCreate {
  4517. mutation := newSettingMutation(c.config, OpCreate)
  4518. return &SettingCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4519. }
  4520. // CreateBulk returns a builder for creating a bulk of Setting entities.
  4521. func (c *SettingClient) CreateBulk(builders ...*SettingCreate) *SettingCreateBulk {
  4522. return &SettingCreateBulk{config: c.config, builders: builders}
  4523. }
  4524. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  4525. // a builder and applies setFunc on it.
  4526. func (c *SettingClient) MapCreateBulk(slice any, setFunc func(*SettingCreate, int)) *SettingCreateBulk {
  4527. rv := reflect.ValueOf(slice)
  4528. if rv.Kind() != reflect.Slice {
  4529. return &SettingCreateBulk{err: fmt.Errorf("calling to SettingClient.MapCreateBulk with wrong type %T, need slice", slice)}
  4530. }
  4531. builders := make([]*SettingCreate, rv.Len())
  4532. for i := 0; i < rv.Len(); i++ {
  4533. builders[i] = c.Create()
  4534. setFunc(builders[i], i)
  4535. }
  4536. return &SettingCreateBulk{config: c.config, builders: builders}
  4537. }
  4538. // Update returns an update builder for Setting.
  4539. func (c *SettingClient) Update() *SettingUpdate {
  4540. mutation := newSettingMutation(c.config, OpUpdate)
  4541. return &SettingUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4542. }
  4543. // UpdateOne returns an update builder for the given entity.
  4544. func (c *SettingClient) UpdateOne(_m *Setting) *SettingUpdateOne {
  4545. mutation := newSettingMutation(c.config, OpUpdateOne, withSetting(_m))
  4546. return &SettingUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4547. }
  4548. // UpdateOneID returns an update builder for the given id.
  4549. func (c *SettingClient) UpdateOneID(id int64) *SettingUpdateOne {
  4550. mutation := newSettingMutation(c.config, OpUpdateOne, withSettingID(id))
  4551. return &SettingUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4552. }
  4553. // Delete returns a delete builder for Setting.
  4554. func (c *SettingClient) Delete() *SettingDelete {
  4555. mutation := newSettingMutation(c.config, OpDelete)
  4556. return &SettingDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4557. }
  4558. // DeleteOne returns a builder for deleting the given entity.
  4559. func (c *SettingClient) DeleteOne(_m *Setting) *SettingDeleteOne {
  4560. return c.DeleteOneID(_m.ID)
  4561. }
  4562. // DeleteOneID returns a builder for deleting the given entity by its id.
  4563. func (c *SettingClient) DeleteOneID(id int64) *SettingDeleteOne {
  4564. builder := c.Delete().Where(setting.ID(id))
  4565. builder.mutation.id = &id
  4566. builder.mutation.op = OpDeleteOne
  4567. return &SettingDeleteOne{builder}
  4568. }
  4569. // Query returns a query builder for Setting.
  4570. func (c *SettingClient) Query() *SettingQuery {
  4571. return &SettingQuery{
  4572. config: c.config,
  4573. ctx: &QueryContext{Type: TypeSetting},
  4574. inters: c.Interceptors(),
  4575. }
  4576. }
  4577. // Get returns a Setting entity by its id.
  4578. func (c *SettingClient) Get(ctx context.Context, id int64) (*Setting, error) {
  4579. return c.Query().Where(setting.ID(id)).Only(ctx)
  4580. }
  4581. // GetX is like Get, but panics if an error occurs.
  4582. func (c *SettingClient) GetX(ctx context.Context, id int64) *Setting {
  4583. obj, err := c.Get(ctx, id)
  4584. if err != nil {
  4585. panic(err)
  4586. }
  4587. return obj
  4588. }
  4589. // Hooks returns the client hooks.
  4590. func (c *SettingClient) Hooks() []Hook {
  4591. return c.hooks.Setting
  4592. }
  4593. // Interceptors returns the client interceptors.
  4594. func (c *SettingClient) Interceptors() []Interceptor {
  4595. return c.inters.Setting
  4596. }
  4597. func (c *SettingClient) mutate(ctx context.Context, m *SettingMutation) (Value, error) {
  4598. switch m.Op() {
  4599. case OpCreate:
  4600. return (&SettingCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4601. case OpUpdate:
  4602. return (&SettingUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4603. case OpUpdateOne:
  4604. return (&SettingUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4605. case OpDelete, OpDeleteOne:
  4606. return (&SettingDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  4607. default:
  4608. return nil, fmt.Errorf("ent: unknown Setting mutation op: %q", m.Op())
  4609. }
  4610. }
  4611. // SubscriptionPlanClient is a client for the SubscriptionPlan schema.
  4612. type SubscriptionPlanClient struct {
  4613. config
  4614. }
  4615. // NewSubscriptionPlanClient returns a client for the SubscriptionPlan from the given config.
  4616. func NewSubscriptionPlanClient(c config) *SubscriptionPlanClient {
  4617. return &SubscriptionPlanClient{config: c}
  4618. }
  4619. // Use adds a list of mutation hooks to the hooks stack.
  4620. // A call to `Use(f, g, h)` equals to `subscriptionplan.Hooks(f(g(h())))`.
  4621. func (c *SubscriptionPlanClient) Use(hooks ...Hook) {
  4622. c.hooks.SubscriptionPlan = append(c.hooks.SubscriptionPlan, hooks...)
  4623. }
  4624. // Intercept adds a list of query interceptors to the interceptors stack.
  4625. // A call to `Intercept(f, g, h)` equals to `subscriptionplan.Intercept(f(g(h())))`.
  4626. func (c *SubscriptionPlanClient) Intercept(interceptors ...Interceptor) {
  4627. c.inters.SubscriptionPlan = append(c.inters.SubscriptionPlan, interceptors...)
  4628. }
  4629. // Create returns a builder for creating a SubscriptionPlan entity.
  4630. func (c *SubscriptionPlanClient) Create() *SubscriptionPlanCreate {
  4631. mutation := newSubscriptionPlanMutation(c.config, OpCreate)
  4632. return &SubscriptionPlanCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4633. }
  4634. // CreateBulk returns a builder for creating a bulk of SubscriptionPlan entities.
  4635. func (c *SubscriptionPlanClient) CreateBulk(builders ...*SubscriptionPlanCreate) *SubscriptionPlanCreateBulk {
  4636. return &SubscriptionPlanCreateBulk{config: c.config, builders: builders}
  4637. }
  4638. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  4639. // a builder and applies setFunc on it.
  4640. func (c *SubscriptionPlanClient) MapCreateBulk(slice any, setFunc func(*SubscriptionPlanCreate, int)) *SubscriptionPlanCreateBulk {
  4641. rv := reflect.ValueOf(slice)
  4642. if rv.Kind() != reflect.Slice {
  4643. return &SubscriptionPlanCreateBulk{err: fmt.Errorf("calling to SubscriptionPlanClient.MapCreateBulk with wrong type %T, need slice", slice)}
  4644. }
  4645. builders := make([]*SubscriptionPlanCreate, rv.Len())
  4646. for i := 0; i < rv.Len(); i++ {
  4647. builders[i] = c.Create()
  4648. setFunc(builders[i], i)
  4649. }
  4650. return &SubscriptionPlanCreateBulk{config: c.config, builders: builders}
  4651. }
  4652. // Update returns an update builder for SubscriptionPlan.
  4653. func (c *SubscriptionPlanClient) Update() *SubscriptionPlanUpdate {
  4654. mutation := newSubscriptionPlanMutation(c.config, OpUpdate)
  4655. return &SubscriptionPlanUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4656. }
  4657. // UpdateOne returns an update builder for the given entity.
  4658. func (c *SubscriptionPlanClient) UpdateOne(_m *SubscriptionPlan) *SubscriptionPlanUpdateOne {
  4659. mutation := newSubscriptionPlanMutation(c.config, OpUpdateOne, withSubscriptionPlan(_m))
  4660. return &SubscriptionPlanUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4661. }
  4662. // UpdateOneID returns an update builder for the given id.
  4663. func (c *SubscriptionPlanClient) UpdateOneID(id int64) *SubscriptionPlanUpdateOne {
  4664. mutation := newSubscriptionPlanMutation(c.config, OpUpdateOne, withSubscriptionPlanID(id))
  4665. return &SubscriptionPlanUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4666. }
  4667. // Delete returns a delete builder for SubscriptionPlan.
  4668. func (c *SubscriptionPlanClient) Delete() *SubscriptionPlanDelete {
  4669. mutation := newSubscriptionPlanMutation(c.config, OpDelete)
  4670. return &SubscriptionPlanDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4671. }
  4672. // DeleteOne returns a builder for deleting the given entity.
  4673. func (c *SubscriptionPlanClient) DeleteOne(_m *SubscriptionPlan) *SubscriptionPlanDeleteOne {
  4674. return c.DeleteOneID(_m.ID)
  4675. }
  4676. // DeleteOneID returns a builder for deleting the given entity by its id.
  4677. func (c *SubscriptionPlanClient) DeleteOneID(id int64) *SubscriptionPlanDeleteOne {
  4678. builder := c.Delete().Where(subscriptionplan.ID(id))
  4679. builder.mutation.id = &id
  4680. builder.mutation.op = OpDeleteOne
  4681. return &SubscriptionPlanDeleteOne{builder}
  4682. }
  4683. // Query returns a query builder for SubscriptionPlan.
  4684. func (c *SubscriptionPlanClient) Query() *SubscriptionPlanQuery {
  4685. return &SubscriptionPlanQuery{
  4686. config: c.config,
  4687. ctx: &QueryContext{Type: TypeSubscriptionPlan},
  4688. inters: c.Interceptors(),
  4689. }
  4690. }
  4691. // Get returns a SubscriptionPlan entity by its id.
  4692. func (c *SubscriptionPlanClient) Get(ctx context.Context, id int64) (*SubscriptionPlan, error) {
  4693. return c.Query().Where(subscriptionplan.ID(id)).Only(ctx)
  4694. }
  4695. // GetX is like Get, but panics if an error occurs.
  4696. func (c *SubscriptionPlanClient) GetX(ctx context.Context, id int64) *SubscriptionPlan {
  4697. obj, err := c.Get(ctx, id)
  4698. if err != nil {
  4699. panic(err)
  4700. }
  4701. return obj
  4702. }
  4703. // Hooks returns the client hooks.
  4704. func (c *SubscriptionPlanClient) Hooks() []Hook {
  4705. return c.hooks.SubscriptionPlan
  4706. }
  4707. // Interceptors returns the client interceptors.
  4708. func (c *SubscriptionPlanClient) Interceptors() []Interceptor {
  4709. return c.inters.SubscriptionPlan
  4710. }
  4711. func (c *SubscriptionPlanClient) mutate(ctx context.Context, m *SubscriptionPlanMutation) (Value, error) {
  4712. switch m.Op() {
  4713. case OpCreate:
  4714. return (&SubscriptionPlanCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4715. case OpUpdate:
  4716. return (&SubscriptionPlanUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4717. case OpUpdateOne:
  4718. return (&SubscriptionPlanUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4719. case OpDelete, OpDeleteOne:
  4720. return (&SubscriptionPlanDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  4721. default:
  4722. return nil, fmt.Errorf("ent: unknown SubscriptionPlan mutation op: %q", m.Op())
  4723. }
  4724. }
  4725. // TLSFingerprintProfileClient is a client for the TLSFingerprintProfile schema.
  4726. type TLSFingerprintProfileClient struct {
  4727. config
  4728. }
  4729. // NewTLSFingerprintProfileClient returns a client for the TLSFingerprintProfile from the given config.
  4730. func NewTLSFingerprintProfileClient(c config) *TLSFingerprintProfileClient {
  4731. return &TLSFingerprintProfileClient{config: c}
  4732. }
  4733. // Use adds a list of mutation hooks to the hooks stack.
  4734. // A call to `Use(f, g, h)` equals to `tlsfingerprintprofile.Hooks(f(g(h())))`.
  4735. func (c *TLSFingerprintProfileClient) Use(hooks ...Hook) {
  4736. c.hooks.TLSFingerprintProfile = append(c.hooks.TLSFingerprintProfile, hooks...)
  4737. }
  4738. // Intercept adds a list of query interceptors to the interceptors stack.
  4739. // A call to `Intercept(f, g, h)` equals to `tlsfingerprintprofile.Intercept(f(g(h())))`.
  4740. func (c *TLSFingerprintProfileClient) Intercept(interceptors ...Interceptor) {
  4741. c.inters.TLSFingerprintProfile = append(c.inters.TLSFingerprintProfile, interceptors...)
  4742. }
  4743. // Create returns a builder for creating a TLSFingerprintProfile entity.
  4744. func (c *TLSFingerprintProfileClient) Create() *TLSFingerprintProfileCreate {
  4745. mutation := newTLSFingerprintProfileMutation(c.config, OpCreate)
  4746. return &TLSFingerprintProfileCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4747. }
  4748. // CreateBulk returns a builder for creating a bulk of TLSFingerprintProfile entities.
  4749. func (c *TLSFingerprintProfileClient) CreateBulk(builders ...*TLSFingerprintProfileCreate) *TLSFingerprintProfileCreateBulk {
  4750. return &TLSFingerprintProfileCreateBulk{config: c.config, builders: builders}
  4751. }
  4752. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  4753. // a builder and applies setFunc on it.
  4754. func (c *TLSFingerprintProfileClient) MapCreateBulk(slice any, setFunc func(*TLSFingerprintProfileCreate, int)) *TLSFingerprintProfileCreateBulk {
  4755. rv := reflect.ValueOf(slice)
  4756. if rv.Kind() != reflect.Slice {
  4757. return &TLSFingerprintProfileCreateBulk{err: fmt.Errorf("calling to TLSFingerprintProfileClient.MapCreateBulk with wrong type %T, need slice", slice)}
  4758. }
  4759. builders := make([]*TLSFingerprintProfileCreate, rv.Len())
  4760. for i := 0; i < rv.Len(); i++ {
  4761. builders[i] = c.Create()
  4762. setFunc(builders[i], i)
  4763. }
  4764. return &TLSFingerprintProfileCreateBulk{config: c.config, builders: builders}
  4765. }
  4766. // Update returns an update builder for TLSFingerprintProfile.
  4767. func (c *TLSFingerprintProfileClient) Update() *TLSFingerprintProfileUpdate {
  4768. mutation := newTLSFingerprintProfileMutation(c.config, OpUpdate)
  4769. return &TLSFingerprintProfileUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4770. }
  4771. // UpdateOne returns an update builder for the given entity.
  4772. func (c *TLSFingerprintProfileClient) UpdateOne(_m *TLSFingerprintProfile) *TLSFingerprintProfileUpdateOne {
  4773. mutation := newTLSFingerprintProfileMutation(c.config, OpUpdateOne, withTLSFingerprintProfile(_m))
  4774. return &TLSFingerprintProfileUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4775. }
  4776. // UpdateOneID returns an update builder for the given id.
  4777. func (c *TLSFingerprintProfileClient) UpdateOneID(id int64) *TLSFingerprintProfileUpdateOne {
  4778. mutation := newTLSFingerprintProfileMutation(c.config, OpUpdateOne, withTLSFingerprintProfileID(id))
  4779. return &TLSFingerprintProfileUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4780. }
  4781. // Delete returns a delete builder for TLSFingerprintProfile.
  4782. func (c *TLSFingerprintProfileClient) Delete() *TLSFingerprintProfileDelete {
  4783. mutation := newTLSFingerprintProfileMutation(c.config, OpDelete)
  4784. return &TLSFingerprintProfileDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4785. }
  4786. // DeleteOne returns a builder for deleting the given entity.
  4787. func (c *TLSFingerprintProfileClient) DeleteOne(_m *TLSFingerprintProfile) *TLSFingerprintProfileDeleteOne {
  4788. return c.DeleteOneID(_m.ID)
  4789. }
  4790. // DeleteOneID returns a builder for deleting the given entity by its id.
  4791. func (c *TLSFingerprintProfileClient) DeleteOneID(id int64) *TLSFingerprintProfileDeleteOne {
  4792. builder := c.Delete().Where(tlsfingerprintprofile.ID(id))
  4793. builder.mutation.id = &id
  4794. builder.mutation.op = OpDeleteOne
  4795. return &TLSFingerprintProfileDeleteOne{builder}
  4796. }
  4797. // Query returns a query builder for TLSFingerprintProfile.
  4798. func (c *TLSFingerprintProfileClient) Query() *TLSFingerprintProfileQuery {
  4799. return &TLSFingerprintProfileQuery{
  4800. config: c.config,
  4801. ctx: &QueryContext{Type: TypeTLSFingerprintProfile},
  4802. inters: c.Interceptors(),
  4803. }
  4804. }
  4805. // Get returns a TLSFingerprintProfile entity by its id.
  4806. func (c *TLSFingerprintProfileClient) Get(ctx context.Context, id int64) (*TLSFingerprintProfile, error) {
  4807. return c.Query().Where(tlsfingerprintprofile.ID(id)).Only(ctx)
  4808. }
  4809. // GetX is like Get, but panics if an error occurs.
  4810. func (c *TLSFingerprintProfileClient) GetX(ctx context.Context, id int64) *TLSFingerprintProfile {
  4811. obj, err := c.Get(ctx, id)
  4812. if err != nil {
  4813. panic(err)
  4814. }
  4815. return obj
  4816. }
  4817. // Hooks returns the client hooks.
  4818. func (c *TLSFingerprintProfileClient) Hooks() []Hook {
  4819. return c.hooks.TLSFingerprintProfile
  4820. }
  4821. // Interceptors returns the client interceptors.
  4822. func (c *TLSFingerprintProfileClient) Interceptors() []Interceptor {
  4823. return c.inters.TLSFingerprintProfile
  4824. }
  4825. func (c *TLSFingerprintProfileClient) mutate(ctx context.Context, m *TLSFingerprintProfileMutation) (Value, error) {
  4826. switch m.Op() {
  4827. case OpCreate:
  4828. return (&TLSFingerprintProfileCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4829. case OpUpdate:
  4830. return (&TLSFingerprintProfileUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4831. case OpUpdateOne:
  4832. return (&TLSFingerprintProfileUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4833. case OpDelete, OpDeleteOne:
  4834. return (&TLSFingerprintProfileDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  4835. default:
  4836. return nil, fmt.Errorf("ent: unknown TLSFingerprintProfile mutation op: %q", m.Op())
  4837. }
  4838. }
  4839. // UsageCleanupTaskClient is a client for the UsageCleanupTask schema.
  4840. type UsageCleanupTaskClient struct {
  4841. config
  4842. }
  4843. // NewUsageCleanupTaskClient returns a client for the UsageCleanupTask from the given config.
  4844. func NewUsageCleanupTaskClient(c config) *UsageCleanupTaskClient {
  4845. return &UsageCleanupTaskClient{config: c}
  4846. }
  4847. // Use adds a list of mutation hooks to the hooks stack.
  4848. // A call to `Use(f, g, h)` equals to `usagecleanuptask.Hooks(f(g(h())))`.
  4849. func (c *UsageCleanupTaskClient) Use(hooks ...Hook) {
  4850. c.hooks.UsageCleanupTask = append(c.hooks.UsageCleanupTask, hooks...)
  4851. }
  4852. // Intercept adds a list of query interceptors to the interceptors stack.
  4853. // A call to `Intercept(f, g, h)` equals to `usagecleanuptask.Intercept(f(g(h())))`.
  4854. func (c *UsageCleanupTaskClient) Intercept(interceptors ...Interceptor) {
  4855. c.inters.UsageCleanupTask = append(c.inters.UsageCleanupTask, interceptors...)
  4856. }
  4857. // Create returns a builder for creating a UsageCleanupTask entity.
  4858. func (c *UsageCleanupTaskClient) Create() *UsageCleanupTaskCreate {
  4859. mutation := newUsageCleanupTaskMutation(c.config, OpCreate)
  4860. return &UsageCleanupTaskCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4861. }
  4862. // CreateBulk returns a builder for creating a bulk of UsageCleanupTask entities.
  4863. func (c *UsageCleanupTaskClient) CreateBulk(builders ...*UsageCleanupTaskCreate) *UsageCleanupTaskCreateBulk {
  4864. return &UsageCleanupTaskCreateBulk{config: c.config, builders: builders}
  4865. }
  4866. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  4867. // a builder and applies setFunc on it.
  4868. func (c *UsageCleanupTaskClient) MapCreateBulk(slice any, setFunc func(*UsageCleanupTaskCreate, int)) *UsageCleanupTaskCreateBulk {
  4869. rv := reflect.ValueOf(slice)
  4870. if rv.Kind() != reflect.Slice {
  4871. return &UsageCleanupTaskCreateBulk{err: fmt.Errorf("calling to UsageCleanupTaskClient.MapCreateBulk with wrong type %T, need slice", slice)}
  4872. }
  4873. builders := make([]*UsageCleanupTaskCreate, rv.Len())
  4874. for i := 0; i < rv.Len(); i++ {
  4875. builders[i] = c.Create()
  4876. setFunc(builders[i], i)
  4877. }
  4878. return &UsageCleanupTaskCreateBulk{config: c.config, builders: builders}
  4879. }
  4880. // Update returns an update builder for UsageCleanupTask.
  4881. func (c *UsageCleanupTaskClient) Update() *UsageCleanupTaskUpdate {
  4882. mutation := newUsageCleanupTaskMutation(c.config, OpUpdate)
  4883. return &UsageCleanupTaskUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4884. }
  4885. // UpdateOne returns an update builder for the given entity.
  4886. func (c *UsageCleanupTaskClient) UpdateOne(_m *UsageCleanupTask) *UsageCleanupTaskUpdateOne {
  4887. mutation := newUsageCleanupTaskMutation(c.config, OpUpdateOne, withUsageCleanupTask(_m))
  4888. return &UsageCleanupTaskUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4889. }
  4890. // UpdateOneID returns an update builder for the given id.
  4891. func (c *UsageCleanupTaskClient) UpdateOneID(id int64) *UsageCleanupTaskUpdateOne {
  4892. mutation := newUsageCleanupTaskMutation(c.config, OpUpdateOne, withUsageCleanupTaskID(id))
  4893. return &UsageCleanupTaskUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4894. }
  4895. // Delete returns a delete builder for UsageCleanupTask.
  4896. func (c *UsageCleanupTaskClient) Delete() *UsageCleanupTaskDelete {
  4897. mutation := newUsageCleanupTaskMutation(c.config, OpDelete)
  4898. return &UsageCleanupTaskDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4899. }
  4900. // DeleteOne returns a builder for deleting the given entity.
  4901. func (c *UsageCleanupTaskClient) DeleteOne(_m *UsageCleanupTask) *UsageCleanupTaskDeleteOne {
  4902. return c.DeleteOneID(_m.ID)
  4903. }
  4904. // DeleteOneID returns a builder for deleting the given entity by its id.
  4905. func (c *UsageCleanupTaskClient) DeleteOneID(id int64) *UsageCleanupTaskDeleteOne {
  4906. builder := c.Delete().Where(usagecleanuptask.ID(id))
  4907. builder.mutation.id = &id
  4908. builder.mutation.op = OpDeleteOne
  4909. return &UsageCleanupTaskDeleteOne{builder}
  4910. }
  4911. // Query returns a query builder for UsageCleanupTask.
  4912. func (c *UsageCleanupTaskClient) Query() *UsageCleanupTaskQuery {
  4913. return &UsageCleanupTaskQuery{
  4914. config: c.config,
  4915. ctx: &QueryContext{Type: TypeUsageCleanupTask},
  4916. inters: c.Interceptors(),
  4917. }
  4918. }
  4919. // Get returns a UsageCleanupTask entity by its id.
  4920. func (c *UsageCleanupTaskClient) Get(ctx context.Context, id int64) (*UsageCleanupTask, error) {
  4921. return c.Query().Where(usagecleanuptask.ID(id)).Only(ctx)
  4922. }
  4923. // GetX is like Get, but panics if an error occurs.
  4924. func (c *UsageCleanupTaskClient) GetX(ctx context.Context, id int64) *UsageCleanupTask {
  4925. obj, err := c.Get(ctx, id)
  4926. if err != nil {
  4927. panic(err)
  4928. }
  4929. return obj
  4930. }
  4931. // Hooks returns the client hooks.
  4932. func (c *UsageCleanupTaskClient) Hooks() []Hook {
  4933. return c.hooks.UsageCleanupTask
  4934. }
  4935. // Interceptors returns the client interceptors.
  4936. func (c *UsageCleanupTaskClient) Interceptors() []Interceptor {
  4937. return c.inters.UsageCleanupTask
  4938. }
  4939. func (c *UsageCleanupTaskClient) mutate(ctx context.Context, m *UsageCleanupTaskMutation) (Value, error) {
  4940. switch m.Op() {
  4941. case OpCreate:
  4942. return (&UsageCleanupTaskCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4943. case OpUpdate:
  4944. return (&UsageCleanupTaskUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4945. case OpUpdateOne:
  4946. return (&UsageCleanupTaskUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4947. case OpDelete, OpDeleteOne:
  4948. return (&UsageCleanupTaskDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  4949. default:
  4950. return nil, fmt.Errorf("ent: unknown UsageCleanupTask mutation op: %q", m.Op())
  4951. }
  4952. }
  4953. // UsageLogClient is a client for the UsageLog schema.
  4954. type UsageLogClient struct {
  4955. config
  4956. }
  4957. // NewUsageLogClient returns a client for the UsageLog from the given config.
  4958. func NewUsageLogClient(c config) *UsageLogClient {
  4959. return &UsageLogClient{config: c}
  4960. }
  4961. // Use adds a list of mutation hooks to the hooks stack.
  4962. // A call to `Use(f, g, h)` equals to `usagelog.Hooks(f(g(h())))`.
  4963. func (c *UsageLogClient) Use(hooks ...Hook) {
  4964. c.hooks.UsageLog = append(c.hooks.UsageLog, hooks...)
  4965. }
  4966. // Intercept adds a list of query interceptors to the interceptors stack.
  4967. // A call to `Intercept(f, g, h)` equals to `usagelog.Intercept(f(g(h())))`.
  4968. func (c *UsageLogClient) Intercept(interceptors ...Interceptor) {
  4969. c.inters.UsageLog = append(c.inters.UsageLog, interceptors...)
  4970. }
  4971. // Create returns a builder for creating a UsageLog entity.
  4972. func (c *UsageLogClient) Create() *UsageLogCreate {
  4973. mutation := newUsageLogMutation(c.config, OpCreate)
  4974. return &UsageLogCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4975. }
  4976. // CreateBulk returns a builder for creating a bulk of UsageLog entities.
  4977. func (c *UsageLogClient) CreateBulk(builders ...*UsageLogCreate) *UsageLogCreateBulk {
  4978. return &UsageLogCreateBulk{config: c.config, builders: builders}
  4979. }
  4980. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  4981. // a builder and applies setFunc on it.
  4982. func (c *UsageLogClient) MapCreateBulk(slice any, setFunc func(*UsageLogCreate, int)) *UsageLogCreateBulk {
  4983. rv := reflect.ValueOf(slice)
  4984. if rv.Kind() != reflect.Slice {
  4985. return &UsageLogCreateBulk{err: fmt.Errorf("calling to UsageLogClient.MapCreateBulk with wrong type %T, need slice", slice)}
  4986. }
  4987. builders := make([]*UsageLogCreate, rv.Len())
  4988. for i := 0; i < rv.Len(); i++ {
  4989. builders[i] = c.Create()
  4990. setFunc(builders[i], i)
  4991. }
  4992. return &UsageLogCreateBulk{config: c.config, builders: builders}
  4993. }
  4994. // Update returns an update builder for UsageLog.
  4995. func (c *UsageLogClient) Update() *UsageLogUpdate {
  4996. mutation := newUsageLogMutation(c.config, OpUpdate)
  4997. return &UsageLogUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4998. }
  4999. // UpdateOne returns an update builder for the given entity.
  5000. func (c *UsageLogClient) UpdateOne(_m *UsageLog) *UsageLogUpdateOne {
  5001. mutation := newUsageLogMutation(c.config, OpUpdateOne, withUsageLog(_m))
  5002. return &UsageLogUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  5003. }
  5004. // UpdateOneID returns an update builder for the given id.
  5005. func (c *UsageLogClient) UpdateOneID(id int64) *UsageLogUpdateOne {
  5006. mutation := newUsageLogMutation(c.config, OpUpdateOne, withUsageLogID(id))
  5007. return &UsageLogUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  5008. }
  5009. // Delete returns a delete builder for UsageLog.
  5010. func (c *UsageLogClient) Delete() *UsageLogDelete {
  5011. mutation := newUsageLogMutation(c.config, OpDelete)
  5012. return &UsageLogDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  5013. }
  5014. // DeleteOne returns a builder for deleting the given entity.
  5015. func (c *UsageLogClient) DeleteOne(_m *UsageLog) *UsageLogDeleteOne {
  5016. return c.DeleteOneID(_m.ID)
  5017. }
  5018. // DeleteOneID returns a builder for deleting the given entity by its id.
  5019. func (c *UsageLogClient) DeleteOneID(id int64) *UsageLogDeleteOne {
  5020. builder := c.Delete().Where(usagelog.ID(id))
  5021. builder.mutation.id = &id
  5022. builder.mutation.op = OpDeleteOne
  5023. return &UsageLogDeleteOne{builder}
  5024. }
  5025. // Query returns a query builder for UsageLog.
  5026. func (c *UsageLogClient) Query() *UsageLogQuery {
  5027. return &UsageLogQuery{
  5028. config: c.config,
  5029. ctx: &QueryContext{Type: TypeUsageLog},
  5030. inters: c.Interceptors(),
  5031. }
  5032. }
  5033. // Get returns a UsageLog entity by its id.
  5034. func (c *UsageLogClient) Get(ctx context.Context, id int64) (*UsageLog, error) {
  5035. return c.Query().Where(usagelog.ID(id)).Only(ctx)
  5036. }
  5037. // GetX is like Get, but panics if an error occurs.
  5038. func (c *UsageLogClient) GetX(ctx context.Context, id int64) *UsageLog {
  5039. obj, err := c.Get(ctx, id)
  5040. if err != nil {
  5041. panic(err)
  5042. }
  5043. return obj
  5044. }
  5045. // QueryUser queries the user edge of a UsageLog.
  5046. func (c *UsageLogClient) QueryUser(_m *UsageLog) *UserQuery {
  5047. query := (&UserClient{config: c.config}).Query()
  5048. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  5049. id := _m.ID
  5050. step := sqlgraph.NewStep(
  5051. sqlgraph.From(usagelog.Table, usagelog.FieldID, id),
  5052. sqlgraph.To(user.Table, user.FieldID),
  5053. sqlgraph.Edge(sqlgraph.M2O, true, usagelog.UserTable, usagelog.UserColumn),
  5054. )
  5055. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  5056. return fromV, nil
  5057. }
  5058. return query
  5059. }
  5060. // QueryAPIKey queries the api_key edge of a UsageLog.
  5061. func (c *UsageLogClient) QueryAPIKey(_m *UsageLog) *APIKeyQuery {
  5062. query := (&APIKeyClient{config: c.config}).Query()
  5063. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  5064. id := _m.ID
  5065. step := sqlgraph.NewStep(
  5066. sqlgraph.From(usagelog.Table, usagelog.FieldID, id),
  5067. sqlgraph.To(apikey.Table, apikey.FieldID),
  5068. sqlgraph.Edge(sqlgraph.M2O, true, usagelog.APIKeyTable, usagelog.APIKeyColumn),
  5069. )
  5070. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  5071. return fromV, nil
  5072. }
  5073. return query
  5074. }
  5075. // QueryAccount queries the account edge of a UsageLog.
  5076. func (c *UsageLogClient) QueryAccount(_m *UsageLog) *AccountQuery {
  5077. query := (&AccountClient{config: c.config}).Query()
  5078. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  5079. id := _m.ID
  5080. step := sqlgraph.NewStep(
  5081. sqlgraph.From(usagelog.Table, usagelog.FieldID, id),
  5082. sqlgraph.To(account.Table, account.FieldID),
  5083. sqlgraph.Edge(sqlgraph.M2O, true, usagelog.AccountTable, usagelog.AccountColumn),
  5084. )
  5085. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  5086. return fromV, nil
  5087. }
  5088. return query
  5089. }
  5090. // QueryGroup queries the group edge of a UsageLog.
  5091. func (c *UsageLogClient) QueryGroup(_m *UsageLog) *GroupQuery {
  5092. query := (&GroupClient{config: c.config}).Query()
  5093. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  5094. id := _m.ID
  5095. step := sqlgraph.NewStep(
  5096. sqlgraph.From(usagelog.Table, usagelog.FieldID, id),
  5097. sqlgraph.To(group.Table, group.FieldID),
  5098. sqlgraph.Edge(sqlgraph.M2O, true, usagelog.GroupTable, usagelog.GroupColumn),
  5099. )
  5100. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  5101. return fromV, nil
  5102. }
  5103. return query
  5104. }
  5105. // QuerySubscription queries the subscription edge of a UsageLog.
  5106. func (c *UsageLogClient) QuerySubscription(_m *UsageLog) *UserSubscriptionQuery {
  5107. query := (&UserSubscriptionClient{config: c.config}).Query()
  5108. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  5109. id := _m.ID
  5110. step := sqlgraph.NewStep(
  5111. sqlgraph.From(usagelog.Table, usagelog.FieldID, id),
  5112. sqlgraph.To(usersubscription.Table, usersubscription.FieldID),
  5113. sqlgraph.Edge(sqlgraph.M2O, true, usagelog.SubscriptionTable, usagelog.SubscriptionColumn),
  5114. )
  5115. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  5116. return fromV, nil
  5117. }
  5118. return query
  5119. }
  5120. // Hooks returns the client hooks.
  5121. func (c *UsageLogClient) Hooks() []Hook {
  5122. return c.hooks.UsageLog
  5123. }
  5124. // Interceptors returns the client interceptors.
  5125. func (c *UsageLogClient) Interceptors() []Interceptor {
  5126. return c.inters.UsageLog
  5127. }
  5128. func (c *UsageLogClient) mutate(ctx context.Context, m *UsageLogMutation) (Value, error) {
  5129. switch m.Op() {
  5130. case OpCreate:
  5131. return (&UsageLogCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  5132. case OpUpdate:
  5133. return (&UsageLogUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  5134. case OpUpdateOne:
  5135. return (&UsageLogUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  5136. case OpDelete, OpDeleteOne:
  5137. return (&UsageLogDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  5138. default:
  5139. return nil, fmt.Errorf("ent: unknown UsageLog mutation op: %q", m.Op())
  5140. }
  5141. }
  5142. // UserClient is a client for the User schema.
  5143. type UserClient struct {
  5144. config
  5145. }
  5146. // NewUserClient returns a client for the User from the given config.
  5147. func NewUserClient(c config) *UserClient {
  5148. return &UserClient{config: c}
  5149. }
  5150. // Use adds a list of mutation hooks to the hooks stack.
  5151. // A call to `Use(f, g, h)` equals to `user.Hooks(f(g(h())))`.
  5152. func (c *UserClient) Use(hooks ...Hook) {
  5153. c.hooks.User = append(c.hooks.User, hooks...)
  5154. }
  5155. // Intercept adds a list of query interceptors to the interceptors stack.
  5156. // A call to `Intercept(f, g, h)` equals to `user.Intercept(f(g(h())))`.
  5157. func (c *UserClient) Intercept(interceptors ...Interceptor) {
  5158. c.inters.User = append(c.inters.User, interceptors...)
  5159. }
  5160. // Create returns a builder for creating a User entity.
  5161. func (c *UserClient) Create() *UserCreate {
  5162. mutation := newUserMutation(c.config, OpCreate)
  5163. return &UserCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  5164. }
  5165. // CreateBulk returns a builder for creating a bulk of User entities.
  5166. func (c *UserClient) CreateBulk(builders ...*UserCreate) *UserCreateBulk {
  5167. return &UserCreateBulk{config: c.config, builders: builders}
  5168. }
  5169. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  5170. // a builder and applies setFunc on it.
  5171. func (c *UserClient) MapCreateBulk(slice any, setFunc func(*UserCreate, int)) *UserCreateBulk {
  5172. rv := reflect.ValueOf(slice)
  5173. if rv.Kind() != reflect.Slice {
  5174. return &UserCreateBulk{err: fmt.Errorf("calling to UserClient.MapCreateBulk with wrong type %T, need slice", slice)}
  5175. }
  5176. builders := make([]*UserCreate, rv.Len())
  5177. for i := 0; i < rv.Len(); i++ {
  5178. builders[i] = c.Create()
  5179. setFunc(builders[i], i)
  5180. }
  5181. return &UserCreateBulk{config: c.config, builders: builders}
  5182. }
  5183. // Update returns an update builder for User.
  5184. func (c *UserClient) Update() *UserUpdate {
  5185. mutation := newUserMutation(c.config, OpUpdate)
  5186. return &UserUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  5187. }
  5188. // UpdateOne returns an update builder for the given entity.
  5189. func (c *UserClient) UpdateOne(_m *User) *UserUpdateOne {
  5190. mutation := newUserMutation(c.config, OpUpdateOne, withUser(_m))
  5191. return &UserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  5192. }
  5193. // UpdateOneID returns an update builder for the given id.
  5194. func (c *UserClient) UpdateOneID(id int64) *UserUpdateOne {
  5195. mutation := newUserMutation(c.config, OpUpdateOne, withUserID(id))
  5196. return &UserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  5197. }
  5198. // Delete returns a delete builder for User.
  5199. func (c *UserClient) Delete() *UserDelete {
  5200. mutation := newUserMutation(c.config, OpDelete)
  5201. return &UserDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  5202. }
  5203. // DeleteOne returns a builder for deleting the given entity.
  5204. func (c *UserClient) DeleteOne(_m *User) *UserDeleteOne {
  5205. return c.DeleteOneID(_m.ID)
  5206. }
  5207. // DeleteOneID returns a builder for deleting the given entity by its id.
  5208. func (c *UserClient) DeleteOneID(id int64) *UserDeleteOne {
  5209. builder := c.Delete().Where(user.ID(id))
  5210. builder.mutation.id = &id
  5211. builder.mutation.op = OpDeleteOne
  5212. return &UserDeleteOne{builder}
  5213. }
  5214. // Query returns a query builder for User.
  5215. func (c *UserClient) Query() *UserQuery {
  5216. return &UserQuery{
  5217. config: c.config,
  5218. ctx: &QueryContext{Type: TypeUser},
  5219. inters: c.Interceptors(),
  5220. }
  5221. }
  5222. // Get returns a User entity by its id.
  5223. func (c *UserClient) Get(ctx context.Context, id int64) (*User, error) {
  5224. return c.Query().Where(user.ID(id)).Only(ctx)
  5225. }
  5226. // GetX is like Get, but panics if an error occurs.
  5227. func (c *UserClient) GetX(ctx context.Context, id int64) *User {
  5228. obj, err := c.Get(ctx, id)
  5229. if err != nil {
  5230. panic(err)
  5231. }
  5232. return obj
  5233. }
  5234. // QueryAPIKeys queries the api_keys edge of a User.
  5235. func (c *UserClient) QueryAPIKeys(_m *User) *APIKeyQuery {
  5236. query := (&APIKeyClient{config: c.config}).Query()
  5237. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  5238. id := _m.ID
  5239. step := sqlgraph.NewStep(
  5240. sqlgraph.From(user.Table, user.FieldID, id),
  5241. sqlgraph.To(apikey.Table, apikey.FieldID),
  5242. sqlgraph.Edge(sqlgraph.O2M, false, user.APIKeysTable, user.APIKeysColumn),
  5243. )
  5244. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  5245. return fromV, nil
  5246. }
  5247. return query
  5248. }
  5249. // QueryRedeemCodes queries the redeem_codes edge of a User.
  5250. func (c *UserClient) QueryRedeemCodes(_m *User) *RedeemCodeQuery {
  5251. query := (&RedeemCodeClient{config: c.config}).Query()
  5252. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  5253. id := _m.ID
  5254. step := sqlgraph.NewStep(
  5255. sqlgraph.From(user.Table, user.FieldID, id),
  5256. sqlgraph.To(redeemcode.Table, redeemcode.FieldID),
  5257. sqlgraph.Edge(sqlgraph.O2M, false, user.RedeemCodesTable, user.RedeemCodesColumn),
  5258. )
  5259. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  5260. return fromV, nil
  5261. }
  5262. return query
  5263. }
  5264. // QuerySubscriptions queries the subscriptions edge of a User.
  5265. func (c *UserClient) QuerySubscriptions(_m *User) *UserSubscriptionQuery {
  5266. query := (&UserSubscriptionClient{config: c.config}).Query()
  5267. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  5268. id := _m.ID
  5269. step := sqlgraph.NewStep(
  5270. sqlgraph.From(user.Table, user.FieldID, id),
  5271. sqlgraph.To(usersubscription.Table, usersubscription.FieldID),
  5272. sqlgraph.Edge(sqlgraph.O2M, false, user.SubscriptionsTable, user.SubscriptionsColumn),
  5273. )
  5274. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  5275. return fromV, nil
  5276. }
  5277. return query
  5278. }
  5279. // QueryAssignedSubscriptions queries the assigned_subscriptions edge of a User.
  5280. func (c *UserClient) QueryAssignedSubscriptions(_m *User) *UserSubscriptionQuery {
  5281. query := (&UserSubscriptionClient{config: c.config}).Query()
  5282. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  5283. id := _m.ID
  5284. step := sqlgraph.NewStep(
  5285. sqlgraph.From(user.Table, user.FieldID, id),
  5286. sqlgraph.To(usersubscription.Table, usersubscription.FieldID),
  5287. sqlgraph.Edge(sqlgraph.O2M, false, user.AssignedSubscriptionsTable, user.AssignedSubscriptionsColumn),
  5288. )
  5289. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  5290. return fromV, nil
  5291. }
  5292. return query
  5293. }
  5294. // QueryAnnouncementReads queries the announcement_reads edge of a User.
  5295. func (c *UserClient) QueryAnnouncementReads(_m *User) *AnnouncementReadQuery {
  5296. query := (&AnnouncementReadClient{config: c.config}).Query()
  5297. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  5298. id := _m.ID
  5299. step := sqlgraph.NewStep(
  5300. sqlgraph.From(user.Table, user.FieldID, id),
  5301. sqlgraph.To(announcementread.Table, announcementread.FieldID),
  5302. sqlgraph.Edge(sqlgraph.O2M, false, user.AnnouncementReadsTable, user.AnnouncementReadsColumn),
  5303. )
  5304. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  5305. return fromV, nil
  5306. }
  5307. return query
  5308. }
  5309. // QueryAllowedGroups queries the allowed_groups edge of a User.
  5310. func (c *UserClient) QueryAllowedGroups(_m *User) *GroupQuery {
  5311. query := (&GroupClient{config: c.config}).Query()
  5312. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  5313. id := _m.ID
  5314. step := sqlgraph.NewStep(
  5315. sqlgraph.From(user.Table, user.FieldID, id),
  5316. sqlgraph.To(group.Table, group.FieldID),
  5317. sqlgraph.Edge(sqlgraph.M2M, false, user.AllowedGroupsTable, user.AllowedGroupsPrimaryKey...),
  5318. )
  5319. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  5320. return fromV, nil
  5321. }
  5322. return query
  5323. }
  5324. // QueryUsageLogs queries the usage_logs edge of a User.
  5325. func (c *UserClient) QueryUsageLogs(_m *User) *UsageLogQuery {
  5326. query := (&UsageLogClient{config: c.config}).Query()
  5327. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  5328. id := _m.ID
  5329. step := sqlgraph.NewStep(
  5330. sqlgraph.From(user.Table, user.FieldID, id),
  5331. sqlgraph.To(usagelog.Table, usagelog.FieldID),
  5332. sqlgraph.Edge(sqlgraph.O2M, false, user.UsageLogsTable, user.UsageLogsColumn),
  5333. )
  5334. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  5335. return fromV, nil
  5336. }
  5337. return query
  5338. }
  5339. // QueryAttributeValues queries the attribute_values edge of a User.
  5340. func (c *UserClient) QueryAttributeValues(_m *User) *UserAttributeValueQuery {
  5341. query := (&UserAttributeValueClient{config: c.config}).Query()
  5342. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  5343. id := _m.ID
  5344. step := sqlgraph.NewStep(
  5345. sqlgraph.From(user.Table, user.FieldID, id),
  5346. sqlgraph.To(userattributevalue.Table, userattributevalue.FieldID),
  5347. sqlgraph.Edge(sqlgraph.O2M, false, user.AttributeValuesTable, user.AttributeValuesColumn),
  5348. )
  5349. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  5350. return fromV, nil
  5351. }
  5352. return query
  5353. }
  5354. // QueryPromoCodeUsages queries the promo_code_usages edge of a User.
  5355. func (c *UserClient) QueryPromoCodeUsages(_m *User) *PromoCodeUsageQuery {
  5356. query := (&PromoCodeUsageClient{config: c.config}).Query()
  5357. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  5358. id := _m.ID
  5359. step := sqlgraph.NewStep(
  5360. sqlgraph.From(user.Table, user.FieldID, id),
  5361. sqlgraph.To(promocodeusage.Table, promocodeusage.FieldID),
  5362. sqlgraph.Edge(sqlgraph.O2M, false, user.PromoCodeUsagesTable, user.PromoCodeUsagesColumn),
  5363. )
  5364. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  5365. return fromV, nil
  5366. }
  5367. return query
  5368. }
  5369. // QueryPaymentOrders queries the payment_orders edge of a User.
  5370. func (c *UserClient) QueryPaymentOrders(_m *User) *PaymentOrderQuery {
  5371. query := (&PaymentOrderClient{config: c.config}).Query()
  5372. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  5373. id := _m.ID
  5374. step := sqlgraph.NewStep(
  5375. sqlgraph.From(user.Table, user.FieldID, id),
  5376. sqlgraph.To(paymentorder.Table, paymentorder.FieldID),
  5377. sqlgraph.Edge(sqlgraph.O2M, false, user.PaymentOrdersTable, user.PaymentOrdersColumn),
  5378. )
  5379. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  5380. return fromV, nil
  5381. }
  5382. return query
  5383. }
  5384. // QueryAuthIdentities queries the auth_identities edge of a User.
  5385. func (c *UserClient) QueryAuthIdentities(_m *User) *AuthIdentityQuery {
  5386. query := (&AuthIdentityClient{config: c.config}).Query()
  5387. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  5388. id := _m.ID
  5389. step := sqlgraph.NewStep(
  5390. sqlgraph.From(user.Table, user.FieldID, id),
  5391. sqlgraph.To(authidentity.Table, authidentity.FieldID),
  5392. sqlgraph.Edge(sqlgraph.O2M, false, user.AuthIdentitiesTable, user.AuthIdentitiesColumn),
  5393. )
  5394. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  5395. return fromV, nil
  5396. }
  5397. return query
  5398. }
  5399. // QueryPendingAuthSessions queries the pending_auth_sessions edge of a User.
  5400. func (c *UserClient) QueryPendingAuthSessions(_m *User) *PendingAuthSessionQuery {
  5401. query := (&PendingAuthSessionClient{config: c.config}).Query()
  5402. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  5403. id := _m.ID
  5404. step := sqlgraph.NewStep(
  5405. sqlgraph.From(user.Table, user.FieldID, id),
  5406. sqlgraph.To(pendingauthsession.Table, pendingauthsession.FieldID),
  5407. sqlgraph.Edge(sqlgraph.O2M, false, user.PendingAuthSessionsTable, user.PendingAuthSessionsColumn),
  5408. )
  5409. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  5410. return fromV, nil
  5411. }
  5412. return query
  5413. }
  5414. // QueryPlatformQuotas queries the platform_quotas edge of a User.
  5415. func (c *UserClient) QueryPlatformQuotas(_m *User) *UserPlatformQuotaQuery {
  5416. query := (&UserPlatformQuotaClient{config: c.config}).Query()
  5417. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  5418. id := _m.ID
  5419. step := sqlgraph.NewStep(
  5420. sqlgraph.From(user.Table, user.FieldID, id),
  5421. sqlgraph.To(userplatformquota.Table, userplatformquota.FieldID),
  5422. sqlgraph.Edge(sqlgraph.O2M, false, user.PlatformQuotasTable, user.PlatformQuotasColumn),
  5423. )
  5424. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  5425. return fromV, nil
  5426. }
  5427. return query
  5428. }
  5429. // QueryUserAllowedGroups queries the user_allowed_groups edge of a User.
  5430. func (c *UserClient) QueryUserAllowedGroups(_m *User) *UserAllowedGroupQuery {
  5431. query := (&UserAllowedGroupClient{config: c.config}).Query()
  5432. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  5433. id := _m.ID
  5434. step := sqlgraph.NewStep(
  5435. sqlgraph.From(user.Table, user.FieldID, id),
  5436. sqlgraph.To(userallowedgroup.Table, userallowedgroup.UserColumn),
  5437. sqlgraph.Edge(sqlgraph.O2M, true, user.UserAllowedGroupsTable, user.UserAllowedGroupsColumn),
  5438. )
  5439. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  5440. return fromV, nil
  5441. }
  5442. return query
  5443. }
  5444. // Hooks returns the client hooks.
  5445. func (c *UserClient) Hooks() []Hook {
  5446. hooks := c.hooks.User
  5447. return append(hooks[:len(hooks):len(hooks)], user.Hooks[:]...)
  5448. }
  5449. // Interceptors returns the client interceptors.
  5450. func (c *UserClient) Interceptors() []Interceptor {
  5451. inters := c.inters.User
  5452. return append(inters[:len(inters):len(inters)], user.Interceptors[:]...)
  5453. }
  5454. func (c *UserClient) mutate(ctx context.Context, m *UserMutation) (Value, error) {
  5455. switch m.Op() {
  5456. case OpCreate:
  5457. return (&UserCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  5458. case OpUpdate:
  5459. return (&UserUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  5460. case OpUpdateOne:
  5461. return (&UserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  5462. case OpDelete, OpDeleteOne:
  5463. return (&UserDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  5464. default:
  5465. return nil, fmt.Errorf("ent: unknown User mutation op: %q", m.Op())
  5466. }
  5467. }
  5468. // UserAllowedGroupClient is a client for the UserAllowedGroup schema.
  5469. type UserAllowedGroupClient struct {
  5470. config
  5471. }
  5472. // NewUserAllowedGroupClient returns a client for the UserAllowedGroup from the given config.
  5473. func NewUserAllowedGroupClient(c config) *UserAllowedGroupClient {
  5474. return &UserAllowedGroupClient{config: c}
  5475. }
  5476. // Use adds a list of mutation hooks to the hooks stack.
  5477. // A call to `Use(f, g, h)` equals to `userallowedgroup.Hooks(f(g(h())))`.
  5478. func (c *UserAllowedGroupClient) Use(hooks ...Hook) {
  5479. c.hooks.UserAllowedGroup = append(c.hooks.UserAllowedGroup, hooks...)
  5480. }
  5481. // Intercept adds a list of query interceptors to the interceptors stack.
  5482. // A call to `Intercept(f, g, h)` equals to `userallowedgroup.Intercept(f(g(h())))`.
  5483. func (c *UserAllowedGroupClient) Intercept(interceptors ...Interceptor) {
  5484. c.inters.UserAllowedGroup = append(c.inters.UserAllowedGroup, interceptors...)
  5485. }
  5486. // Create returns a builder for creating a UserAllowedGroup entity.
  5487. func (c *UserAllowedGroupClient) Create() *UserAllowedGroupCreate {
  5488. mutation := newUserAllowedGroupMutation(c.config, OpCreate)
  5489. return &UserAllowedGroupCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  5490. }
  5491. // CreateBulk returns a builder for creating a bulk of UserAllowedGroup entities.
  5492. func (c *UserAllowedGroupClient) CreateBulk(builders ...*UserAllowedGroupCreate) *UserAllowedGroupCreateBulk {
  5493. return &UserAllowedGroupCreateBulk{config: c.config, builders: builders}
  5494. }
  5495. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  5496. // a builder and applies setFunc on it.
  5497. func (c *UserAllowedGroupClient) MapCreateBulk(slice any, setFunc func(*UserAllowedGroupCreate, int)) *UserAllowedGroupCreateBulk {
  5498. rv := reflect.ValueOf(slice)
  5499. if rv.Kind() != reflect.Slice {
  5500. return &UserAllowedGroupCreateBulk{err: fmt.Errorf("calling to UserAllowedGroupClient.MapCreateBulk with wrong type %T, need slice", slice)}
  5501. }
  5502. builders := make([]*UserAllowedGroupCreate, rv.Len())
  5503. for i := 0; i < rv.Len(); i++ {
  5504. builders[i] = c.Create()
  5505. setFunc(builders[i], i)
  5506. }
  5507. return &UserAllowedGroupCreateBulk{config: c.config, builders: builders}
  5508. }
  5509. // Update returns an update builder for UserAllowedGroup.
  5510. func (c *UserAllowedGroupClient) Update() *UserAllowedGroupUpdate {
  5511. mutation := newUserAllowedGroupMutation(c.config, OpUpdate)
  5512. return &UserAllowedGroupUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  5513. }
  5514. // UpdateOne returns an update builder for the given entity.
  5515. func (c *UserAllowedGroupClient) UpdateOne(_m *UserAllowedGroup) *UserAllowedGroupUpdateOne {
  5516. mutation := newUserAllowedGroupMutation(c.config, OpUpdateOne)
  5517. mutation.user = &_m.UserID
  5518. mutation.group = &_m.GroupID
  5519. return &UserAllowedGroupUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  5520. }
  5521. // Delete returns a delete builder for UserAllowedGroup.
  5522. func (c *UserAllowedGroupClient) Delete() *UserAllowedGroupDelete {
  5523. mutation := newUserAllowedGroupMutation(c.config, OpDelete)
  5524. return &UserAllowedGroupDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  5525. }
  5526. // Query returns a query builder for UserAllowedGroup.
  5527. func (c *UserAllowedGroupClient) Query() *UserAllowedGroupQuery {
  5528. return &UserAllowedGroupQuery{
  5529. config: c.config,
  5530. ctx: &QueryContext{Type: TypeUserAllowedGroup},
  5531. inters: c.Interceptors(),
  5532. }
  5533. }
  5534. // QueryUser queries the user edge of a UserAllowedGroup.
  5535. func (c *UserAllowedGroupClient) QueryUser(_m *UserAllowedGroup) *UserQuery {
  5536. return c.Query().
  5537. Where(userallowedgroup.UserID(_m.UserID), userallowedgroup.GroupID(_m.GroupID)).
  5538. QueryUser()
  5539. }
  5540. // QueryGroup queries the group edge of a UserAllowedGroup.
  5541. func (c *UserAllowedGroupClient) QueryGroup(_m *UserAllowedGroup) *GroupQuery {
  5542. return c.Query().
  5543. Where(userallowedgroup.UserID(_m.UserID), userallowedgroup.GroupID(_m.GroupID)).
  5544. QueryGroup()
  5545. }
  5546. // Hooks returns the client hooks.
  5547. func (c *UserAllowedGroupClient) Hooks() []Hook {
  5548. return c.hooks.UserAllowedGroup
  5549. }
  5550. // Interceptors returns the client interceptors.
  5551. func (c *UserAllowedGroupClient) Interceptors() []Interceptor {
  5552. return c.inters.UserAllowedGroup
  5553. }
  5554. func (c *UserAllowedGroupClient) mutate(ctx context.Context, m *UserAllowedGroupMutation) (Value, error) {
  5555. switch m.Op() {
  5556. case OpCreate:
  5557. return (&UserAllowedGroupCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  5558. case OpUpdate:
  5559. return (&UserAllowedGroupUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  5560. case OpUpdateOne:
  5561. return (&UserAllowedGroupUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  5562. case OpDelete, OpDeleteOne:
  5563. return (&UserAllowedGroupDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  5564. default:
  5565. return nil, fmt.Errorf("ent: unknown UserAllowedGroup mutation op: %q", m.Op())
  5566. }
  5567. }
  5568. // UserAttributeDefinitionClient is a client for the UserAttributeDefinition schema.
  5569. type UserAttributeDefinitionClient struct {
  5570. config
  5571. }
  5572. // NewUserAttributeDefinitionClient returns a client for the UserAttributeDefinition from the given config.
  5573. func NewUserAttributeDefinitionClient(c config) *UserAttributeDefinitionClient {
  5574. return &UserAttributeDefinitionClient{config: c}
  5575. }
  5576. // Use adds a list of mutation hooks to the hooks stack.
  5577. // A call to `Use(f, g, h)` equals to `userattributedefinition.Hooks(f(g(h())))`.
  5578. func (c *UserAttributeDefinitionClient) Use(hooks ...Hook) {
  5579. c.hooks.UserAttributeDefinition = append(c.hooks.UserAttributeDefinition, hooks...)
  5580. }
  5581. // Intercept adds a list of query interceptors to the interceptors stack.
  5582. // A call to `Intercept(f, g, h)` equals to `userattributedefinition.Intercept(f(g(h())))`.
  5583. func (c *UserAttributeDefinitionClient) Intercept(interceptors ...Interceptor) {
  5584. c.inters.UserAttributeDefinition = append(c.inters.UserAttributeDefinition, interceptors...)
  5585. }
  5586. // Create returns a builder for creating a UserAttributeDefinition entity.
  5587. func (c *UserAttributeDefinitionClient) Create() *UserAttributeDefinitionCreate {
  5588. mutation := newUserAttributeDefinitionMutation(c.config, OpCreate)
  5589. return &UserAttributeDefinitionCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  5590. }
  5591. // CreateBulk returns a builder for creating a bulk of UserAttributeDefinition entities.
  5592. func (c *UserAttributeDefinitionClient) CreateBulk(builders ...*UserAttributeDefinitionCreate) *UserAttributeDefinitionCreateBulk {
  5593. return &UserAttributeDefinitionCreateBulk{config: c.config, builders: builders}
  5594. }
  5595. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  5596. // a builder and applies setFunc on it.
  5597. func (c *UserAttributeDefinitionClient) MapCreateBulk(slice any, setFunc func(*UserAttributeDefinitionCreate, int)) *UserAttributeDefinitionCreateBulk {
  5598. rv := reflect.ValueOf(slice)
  5599. if rv.Kind() != reflect.Slice {
  5600. return &UserAttributeDefinitionCreateBulk{err: fmt.Errorf("calling to UserAttributeDefinitionClient.MapCreateBulk with wrong type %T, need slice", slice)}
  5601. }
  5602. builders := make([]*UserAttributeDefinitionCreate, rv.Len())
  5603. for i := 0; i < rv.Len(); i++ {
  5604. builders[i] = c.Create()
  5605. setFunc(builders[i], i)
  5606. }
  5607. return &UserAttributeDefinitionCreateBulk{config: c.config, builders: builders}
  5608. }
  5609. // Update returns an update builder for UserAttributeDefinition.
  5610. func (c *UserAttributeDefinitionClient) Update() *UserAttributeDefinitionUpdate {
  5611. mutation := newUserAttributeDefinitionMutation(c.config, OpUpdate)
  5612. return &UserAttributeDefinitionUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  5613. }
  5614. // UpdateOne returns an update builder for the given entity.
  5615. func (c *UserAttributeDefinitionClient) UpdateOne(_m *UserAttributeDefinition) *UserAttributeDefinitionUpdateOne {
  5616. mutation := newUserAttributeDefinitionMutation(c.config, OpUpdateOne, withUserAttributeDefinition(_m))
  5617. return &UserAttributeDefinitionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  5618. }
  5619. // UpdateOneID returns an update builder for the given id.
  5620. func (c *UserAttributeDefinitionClient) UpdateOneID(id int64) *UserAttributeDefinitionUpdateOne {
  5621. mutation := newUserAttributeDefinitionMutation(c.config, OpUpdateOne, withUserAttributeDefinitionID(id))
  5622. return &UserAttributeDefinitionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  5623. }
  5624. // Delete returns a delete builder for UserAttributeDefinition.
  5625. func (c *UserAttributeDefinitionClient) Delete() *UserAttributeDefinitionDelete {
  5626. mutation := newUserAttributeDefinitionMutation(c.config, OpDelete)
  5627. return &UserAttributeDefinitionDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  5628. }
  5629. // DeleteOne returns a builder for deleting the given entity.
  5630. func (c *UserAttributeDefinitionClient) DeleteOne(_m *UserAttributeDefinition) *UserAttributeDefinitionDeleteOne {
  5631. return c.DeleteOneID(_m.ID)
  5632. }
  5633. // DeleteOneID returns a builder for deleting the given entity by its id.
  5634. func (c *UserAttributeDefinitionClient) DeleteOneID(id int64) *UserAttributeDefinitionDeleteOne {
  5635. builder := c.Delete().Where(userattributedefinition.ID(id))
  5636. builder.mutation.id = &id
  5637. builder.mutation.op = OpDeleteOne
  5638. return &UserAttributeDefinitionDeleteOne{builder}
  5639. }
  5640. // Query returns a query builder for UserAttributeDefinition.
  5641. func (c *UserAttributeDefinitionClient) Query() *UserAttributeDefinitionQuery {
  5642. return &UserAttributeDefinitionQuery{
  5643. config: c.config,
  5644. ctx: &QueryContext{Type: TypeUserAttributeDefinition},
  5645. inters: c.Interceptors(),
  5646. }
  5647. }
  5648. // Get returns a UserAttributeDefinition entity by its id.
  5649. func (c *UserAttributeDefinitionClient) Get(ctx context.Context, id int64) (*UserAttributeDefinition, error) {
  5650. return c.Query().Where(userattributedefinition.ID(id)).Only(ctx)
  5651. }
  5652. // GetX is like Get, but panics if an error occurs.
  5653. func (c *UserAttributeDefinitionClient) GetX(ctx context.Context, id int64) *UserAttributeDefinition {
  5654. obj, err := c.Get(ctx, id)
  5655. if err != nil {
  5656. panic(err)
  5657. }
  5658. return obj
  5659. }
  5660. // QueryValues queries the values edge of a UserAttributeDefinition.
  5661. func (c *UserAttributeDefinitionClient) QueryValues(_m *UserAttributeDefinition) *UserAttributeValueQuery {
  5662. query := (&UserAttributeValueClient{config: c.config}).Query()
  5663. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  5664. id := _m.ID
  5665. step := sqlgraph.NewStep(
  5666. sqlgraph.From(userattributedefinition.Table, userattributedefinition.FieldID, id),
  5667. sqlgraph.To(userattributevalue.Table, userattributevalue.FieldID),
  5668. sqlgraph.Edge(sqlgraph.O2M, false, userattributedefinition.ValuesTable, userattributedefinition.ValuesColumn),
  5669. )
  5670. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  5671. return fromV, nil
  5672. }
  5673. return query
  5674. }
  5675. // Hooks returns the client hooks.
  5676. func (c *UserAttributeDefinitionClient) Hooks() []Hook {
  5677. hooks := c.hooks.UserAttributeDefinition
  5678. return append(hooks[:len(hooks):len(hooks)], userattributedefinition.Hooks[:]...)
  5679. }
  5680. // Interceptors returns the client interceptors.
  5681. func (c *UserAttributeDefinitionClient) Interceptors() []Interceptor {
  5682. inters := c.inters.UserAttributeDefinition
  5683. return append(inters[:len(inters):len(inters)], userattributedefinition.Interceptors[:]...)
  5684. }
  5685. func (c *UserAttributeDefinitionClient) mutate(ctx context.Context, m *UserAttributeDefinitionMutation) (Value, error) {
  5686. switch m.Op() {
  5687. case OpCreate:
  5688. return (&UserAttributeDefinitionCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  5689. case OpUpdate:
  5690. return (&UserAttributeDefinitionUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  5691. case OpUpdateOne:
  5692. return (&UserAttributeDefinitionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  5693. case OpDelete, OpDeleteOne:
  5694. return (&UserAttributeDefinitionDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  5695. default:
  5696. return nil, fmt.Errorf("ent: unknown UserAttributeDefinition mutation op: %q", m.Op())
  5697. }
  5698. }
  5699. // UserAttributeValueClient is a client for the UserAttributeValue schema.
  5700. type UserAttributeValueClient struct {
  5701. config
  5702. }
  5703. // NewUserAttributeValueClient returns a client for the UserAttributeValue from the given config.
  5704. func NewUserAttributeValueClient(c config) *UserAttributeValueClient {
  5705. return &UserAttributeValueClient{config: c}
  5706. }
  5707. // Use adds a list of mutation hooks to the hooks stack.
  5708. // A call to `Use(f, g, h)` equals to `userattributevalue.Hooks(f(g(h())))`.
  5709. func (c *UserAttributeValueClient) Use(hooks ...Hook) {
  5710. c.hooks.UserAttributeValue = append(c.hooks.UserAttributeValue, hooks...)
  5711. }
  5712. // Intercept adds a list of query interceptors to the interceptors stack.
  5713. // A call to `Intercept(f, g, h)` equals to `userattributevalue.Intercept(f(g(h())))`.
  5714. func (c *UserAttributeValueClient) Intercept(interceptors ...Interceptor) {
  5715. c.inters.UserAttributeValue = append(c.inters.UserAttributeValue, interceptors...)
  5716. }
  5717. // Create returns a builder for creating a UserAttributeValue entity.
  5718. func (c *UserAttributeValueClient) Create() *UserAttributeValueCreate {
  5719. mutation := newUserAttributeValueMutation(c.config, OpCreate)
  5720. return &UserAttributeValueCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  5721. }
  5722. // CreateBulk returns a builder for creating a bulk of UserAttributeValue entities.
  5723. func (c *UserAttributeValueClient) CreateBulk(builders ...*UserAttributeValueCreate) *UserAttributeValueCreateBulk {
  5724. return &UserAttributeValueCreateBulk{config: c.config, builders: builders}
  5725. }
  5726. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  5727. // a builder and applies setFunc on it.
  5728. func (c *UserAttributeValueClient) MapCreateBulk(slice any, setFunc func(*UserAttributeValueCreate, int)) *UserAttributeValueCreateBulk {
  5729. rv := reflect.ValueOf(slice)
  5730. if rv.Kind() != reflect.Slice {
  5731. return &UserAttributeValueCreateBulk{err: fmt.Errorf("calling to UserAttributeValueClient.MapCreateBulk with wrong type %T, need slice", slice)}
  5732. }
  5733. builders := make([]*UserAttributeValueCreate, rv.Len())
  5734. for i := 0; i < rv.Len(); i++ {
  5735. builders[i] = c.Create()
  5736. setFunc(builders[i], i)
  5737. }
  5738. return &UserAttributeValueCreateBulk{config: c.config, builders: builders}
  5739. }
  5740. // Update returns an update builder for UserAttributeValue.
  5741. func (c *UserAttributeValueClient) Update() *UserAttributeValueUpdate {
  5742. mutation := newUserAttributeValueMutation(c.config, OpUpdate)
  5743. return &UserAttributeValueUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  5744. }
  5745. // UpdateOne returns an update builder for the given entity.
  5746. func (c *UserAttributeValueClient) UpdateOne(_m *UserAttributeValue) *UserAttributeValueUpdateOne {
  5747. mutation := newUserAttributeValueMutation(c.config, OpUpdateOne, withUserAttributeValue(_m))
  5748. return &UserAttributeValueUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  5749. }
  5750. // UpdateOneID returns an update builder for the given id.
  5751. func (c *UserAttributeValueClient) UpdateOneID(id int64) *UserAttributeValueUpdateOne {
  5752. mutation := newUserAttributeValueMutation(c.config, OpUpdateOne, withUserAttributeValueID(id))
  5753. return &UserAttributeValueUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  5754. }
  5755. // Delete returns a delete builder for UserAttributeValue.
  5756. func (c *UserAttributeValueClient) Delete() *UserAttributeValueDelete {
  5757. mutation := newUserAttributeValueMutation(c.config, OpDelete)
  5758. return &UserAttributeValueDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  5759. }
  5760. // DeleteOne returns a builder for deleting the given entity.
  5761. func (c *UserAttributeValueClient) DeleteOne(_m *UserAttributeValue) *UserAttributeValueDeleteOne {
  5762. return c.DeleteOneID(_m.ID)
  5763. }
  5764. // DeleteOneID returns a builder for deleting the given entity by its id.
  5765. func (c *UserAttributeValueClient) DeleteOneID(id int64) *UserAttributeValueDeleteOne {
  5766. builder := c.Delete().Where(userattributevalue.ID(id))
  5767. builder.mutation.id = &id
  5768. builder.mutation.op = OpDeleteOne
  5769. return &UserAttributeValueDeleteOne{builder}
  5770. }
  5771. // Query returns a query builder for UserAttributeValue.
  5772. func (c *UserAttributeValueClient) Query() *UserAttributeValueQuery {
  5773. return &UserAttributeValueQuery{
  5774. config: c.config,
  5775. ctx: &QueryContext{Type: TypeUserAttributeValue},
  5776. inters: c.Interceptors(),
  5777. }
  5778. }
  5779. // Get returns a UserAttributeValue entity by its id.
  5780. func (c *UserAttributeValueClient) Get(ctx context.Context, id int64) (*UserAttributeValue, error) {
  5781. return c.Query().Where(userattributevalue.ID(id)).Only(ctx)
  5782. }
  5783. // GetX is like Get, but panics if an error occurs.
  5784. func (c *UserAttributeValueClient) GetX(ctx context.Context, id int64) *UserAttributeValue {
  5785. obj, err := c.Get(ctx, id)
  5786. if err != nil {
  5787. panic(err)
  5788. }
  5789. return obj
  5790. }
  5791. // QueryUser queries the user edge of a UserAttributeValue.
  5792. func (c *UserAttributeValueClient) QueryUser(_m *UserAttributeValue) *UserQuery {
  5793. query := (&UserClient{config: c.config}).Query()
  5794. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  5795. id := _m.ID
  5796. step := sqlgraph.NewStep(
  5797. sqlgraph.From(userattributevalue.Table, userattributevalue.FieldID, id),
  5798. sqlgraph.To(user.Table, user.FieldID),
  5799. sqlgraph.Edge(sqlgraph.M2O, true, userattributevalue.UserTable, userattributevalue.UserColumn),
  5800. )
  5801. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  5802. return fromV, nil
  5803. }
  5804. return query
  5805. }
  5806. // QueryDefinition queries the definition edge of a UserAttributeValue.
  5807. func (c *UserAttributeValueClient) QueryDefinition(_m *UserAttributeValue) *UserAttributeDefinitionQuery {
  5808. query := (&UserAttributeDefinitionClient{config: c.config}).Query()
  5809. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  5810. id := _m.ID
  5811. step := sqlgraph.NewStep(
  5812. sqlgraph.From(userattributevalue.Table, userattributevalue.FieldID, id),
  5813. sqlgraph.To(userattributedefinition.Table, userattributedefinition.FieldID),
  5814. sqlgraph.Edge(sqlgraph.M2O, true, userattributevalue.DefinitionTable, userattributevalue.DefinitionColumn),
  5815. )
  5816. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  5817. return fromV, nil
  5818. }
  5819. return query
  5820. }
  5821. // Hooks returns the client hooks.
  5822. func (c *UserAttributeValueClient) Hooks() []Hook {
  5823. return c.hooks.UserAttributeValue
  5824. }
  5825. // Interceptors returns the client interceptors.
  5826. func (c *UserAttributeValueClient) Interceptors() []Interceptor {
  5827. return c.inters.UserAttributeValue
  5828. }
  5829. func (c *UserAttributeValueClient) mutate(ctx context.Context, m *UserAttributeValueMutation) (Value, error) {
  5830. switch m.Op() {
  5831. case OpCreate:
  5832. return (&UserAttributeValueCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  5833. case OpUpdate:
  5834. return (&UserAttributeValueUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  5835. case OpUpdateOne:
  5836. return (&UserAttributeValueUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  5837. case OpDelete, OpDeleteOne:
  5838. return (&UserAttributeValueDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  5839. default:
  5840. return nil, fmt.Errorf("ent: unknown UserAttributeValue mutation op: %q", m.Op())
  5841. }
  5842. }
  5843. // UserPlatformQuotaClient is a client for the UserPlatformQuota schema.
  5844. type UserPlatformQuotaClient struct {
  5845. config
  5846. }
  5847. // NewUserPlatformQuotaClient returns a client for the UserPlatformQuota from the given config.
  5848. func NewUserPlatformQuotaClient(c config) *UserPlatformQuotaClient {
  5849. return &UserPlatformQuotaClient{config: c}
  5850. }
  5851. // Use adds a list of mutation hooks to the hooks stack.
  5852. // A call to `Use(f, g, h)` equals to `userplatformquota.Hooks(f(g(h())))`.
  5853. func (c *UserPlatformQuotaClient) Use(hooks ...Hook) {
  5854. c.hooks.UserPlatformQuota = append(c.hooks.UserPlatformQuota, hooks...)
  5855. }
  5856. // Intercept adds a list of query interceptors to the interceptors stack.
  5857. // A call to `Intercept(f, g, h)` equals to `userplatformquota.Intercept(f(g(h())))`.
  5858. func (c *UserPlatformQuotaClient) Intercept(interceptors ...Interceptor) {
  5859. c.inters.UserPlatformQuota = append(c.inters.UserPlatformQuota, interceptors...)
  5860. }
  5861. // Create returns a builder for creating a UserPlatformQuota entity.
  5862. func (c *UserPlatformQuotaClient) Create() *UserPlatformQuotaCreate {
  5863. mutation := newUserPlatformQuotaMutation(c.config, OpCreate)
  5864. return &UserPlatformQuotaCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  5865. }
  5866. // CreateBulk returns a builder for creating a bulk of UserPlatformQuota entities.
  5867. func (c *UserPlatformQuotaClient) CreateBulk(builders ...*UserPlatformQuotaCreate) *UserPlatformQuotaCreateBulk {
  5868. return &UserPlatformQuotaCreateBulk{config: c.config, builders: builders}
  5869. }
  5870. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  5871. // a builder and applies setFunc on it.
  5872. func (c *UserPlatformQuotaClient) MapCreateBulk(slice any, setFunc func(*UserPlatformQuotaCreate, int)) *UserPlatformQuotaCreateBulk {
  5873. rv := reflect.ValueOf(slice)
  5874. if rv.Kind() != reflect.Slice {
  5875. return &UserPlatformQuotaCreateBulk{err: fmt.Errorf("calling to UserPlatformQuotaClient.MapCreateBulk with wrong type %T, need slice", slice)}
  5876. }
  5877. builders := make([]*UserPlatformQuotaCreate, rv.Len())
  5878. for i := 0; i < rv.Len(); i++ {
  5879. builders[i] = c.Create()
  5880. setFunc(builders[i], i)
  5881. }
  5882. return &UserPlatformQuotaCreateBulk{config: c.config, builders: builders}
  5883. }
  5884. // Update returns an update builder for UserPlatformQuota.
  5885. func (c *UserPlatformQuotaClient) Update() *UserPlatformQuotaUpdate {
  5886. mutation := newUserPlatformQuotaMutation(c.config, OpUpdate)
  5887. return &UserPlatformQuotaUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  5888. }
  5889. // UpdateOne returns an update builder for the given entity.
  5890. func (c *UserPlatformQuotaClient) UpdateOne(_m *UserPlatformQuota) *UserPlatformQuotaUpdateOne {
  5891. mutation := newUserPlatformQuotaMutation(c.config, OpUpdateOne, withUserPlatformQuota(_m))
  5892. return &UserPlatformQuotaUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  5893. }
  5894. // UpdateOneID returns an update builder for the given id.
  5895. func (c *UserPlatformQuotaClient) UpdateOneID(id int64) *UserPlatformQuotaUpdateOne {
  5896. mutation := newUserPlatformQuotaMutation(c.config, OpUpdateOne, withUserPlatformQuotaID(id))
  5897. return &UserPlatformQuotaUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  5898. }
  5899. // Delete returns a delete builder for UserPlatformQuota.
  5900. func (c *UserPlatformQuotaClient) Delete() *UserPlatformQuotaDelete {
  5901. mutation := newUserPlatformQuotaMutation(c.config, OpDelete)
  5902. return &UserPlatformQuotaDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  5903. }
  5904. // DeleteOne returns a builder for deleting the given entity.
  5905. func (c *UserPlatformQuotaClient) DeleteOne(_m *UserPlatformQuota) *UserPlatformQuotaDeleteOne {
  5906. return c.DeleteOneID(_m.ID)
  5907. }
  5908. // DeleteOneID returns a builder for deleting the given entity by its id.
  5909. func (c *UserPlatformQuotaClient) DeleteOneID(id int64) *UserPlatformQuotaDeleteOne {
  5910. builder := c.Delete().Where(userplatformquota.ID(id))
  5911. builder.mutation.id = &id
  5912. builder.mutation.op = OpDeleteOne
  5913. return &UserPlatformQuotaDeleteOne{builder}
  5914. }
  5915. // Query returns a query builder for UserPlatformQuota.
  5916. func (c *UserPlatformQuotaClient) Query() *UserPlatformQuotaQuery {
  5917. return &UserPlatformQuotaQuery{
  5918. config: c.config,
  5919. ctx: &QueryContext{Type: TypeUserPlatformQuota},
  5920. inters: c.Interceptors(),
  5921. }
  5922. }
  5923. // Get returns a UserPlatformQuota entity by its id.
  5924. func (c *UserPlatformQuotaClient) Get(ctx context.Context, id int64) (*UserPlatformQuota, error) {
  5925. return c.Query().Where(userplatformquota.ID(id)).Only(ctx)
  5926. }
  5927. // GetX is like Get, but panics if an error occurs.
  5928. func (c *UserPlatformQuotaClient) GetX(ctx context.Context, id int64) *UserPlatformQuota {
  5929. obj, err := c.Get(ctx, id)
  5930. if err != nil {
  5931. panic(err)
  5932. }
  5933. return obj
  5934. }
  5935. // QueryUser queries the user edge of a UserPlatformQuota.
  5936. func (c *UserPlatformQuotaClient) QueryUser(_m *UserPlatformQuota) *UserQuery {
  5937. query := (&UserClient{config: c.config}).Query()
  5938. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  5939. id := _m.ID
  5940. step := sqlgraph.NewStep(
  5941. sqlgraph.From(userplatformquota.Table, userplatformquota.FieldID, id),
  5942. sqlgraph.To(user.Table, user.FieldID),
  5943. sqlgraph.Edge(sqlgraph.M2O, true, userplatformquota.UserTable, userplatformquota.UserColumn),
  5944. )
  5945. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  5946. return fromV, nil
  5947. }
  5948. return query
  5949. }
  5950. // Hooks returns the client hooks.
  5951. func (c *UserPlatformQuotaClient) Hooks() []Hook {
  5952. hooks := c.hooks.UserPlatformQuota
  5953. return append(hooks[:len(hooks):len(hooks)], userplatformquota.Hooks[:]...)
  5954. }
  5955. // Interceptors returns the client interceptors.
  5956. func (c *UserPlatformQuotaClient) Interceptors() []Interceptor {
  5957. inters := c.inters.UserPlatformQuota
  5958. return append(inters[:len(inters):len(inters)], userplatformquota.Interceptors[:]...)
  5959. }
  5960. func (c *UserPlatformQuotaClient) mutate(ctx context.Context, m *UserPlatformQuotaMutation) (Value, error) {
  5961. switch m.Op() {
  5962. case OpCreate:
  5963. return (&UserPlatformQuotaCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  5964. case OpUpdate:
  5965. return (&UserPlatformQuotaUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  5966. case OpUpdateOne:
  5967. return (&UserPlatformQuotaUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  5968. case OpDelete, OpDeleteOne:
  5969. return (&UserPlatformQuotaDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  5970. default:
  5971. return nil, fmt.Errorf("ent: unknown UserPlatformQuota mutation op: %q", m.Op())
  5972. }
  5973. }
  5974. // UserSubscriptionClient is a client for the UserSubscription schema.
  5975. type UserSubscriptionClient struct {
  5976. config
  5977. }
  5978. // NewUserSubscriptionClient returns a client for the UserSubscription from the given config.
  5979. func NewUserSubscriptionClient(c config) *UserSubscriptionClient {
  5980. return &UserSubscriptionClient{config: c}
  5981. }
  5982. // Use adds a list of mutation hooks to the hooks stack.
  5983. // A call to `Use(f, g, h)` equals to `usersubscription.Hooks(f(g(h())))`.
  5984. func (c *UserSubscriptionClient) Use(hooks ...Hook) {
  5985. c.hooks.UserSubscription = append(c.hooks.UserSubscription, hooks...)
  5986. }
  5987. // Intercept adds a list of query interceptors to the interceptors stack.
  5988. // A call to `Intercept(f, g, h)` equals to `usersubscription.Intercept(f(g(h())))`.
  5989. func (c *UserSubscriptionClient) Intercept(interceptors ...Interceptor) {
  5990. c.inters.UserSubscription = append(c.inters.UserSubscription, interceptors...)
  5991. }
  5992. // Create returns a builder for creating a UserSubscription entity.
  5993. func (c *UserSubscriptionClient) Create() *UserSubscriptionCreate {
  5994. mutation := newUserSubscriptionMutation(c.config, OpCreate)
  5995. return &UserSubscriptionCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  5996. }
  5997. // CreateBulk returns a builder for creating a bulk of UserSubscription entities.
  5998. func (c *UserSubscriptionClient) CreateBulk(builders ...*UserSubscriptionCreate) *UserSubscriptionCreateBulk {
  5999. return &UserSubscriptionCreateBulk{config: c.config, builders: builders}
  6000. }
  6001. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  6002. // a builder and applies setFunc on it.
  6003. func (c *UserSubscriptionClient) MapCreateBulk(slice any, setFunc func(*UserSubscriptionCreate, int)) *UserSubscriptionCreateBulk {
  6004. rv := reflect.ValueOf(slice)
  6005. if rv.Kind() != reflect.Slice {
  6006. return &UserSubscriptionCreateBulk{err: fmt.Errorf("calling to UserSubscriptionClient.MapCreateBulk with wrong type %T, need slice", slice)}
  6007. }
  6008. builders := make([]*UserSubscriptionCreate, rv.Len())
  6009. for i := 0; i < rv.Len(); i++ {
  6010. builders[i] = c.Create()
  6011. setFunc(builders[i], i)
  6012. }
  6013. return &UserSubscriptionCreateBulk{config: c.config, builders: builders}
  6014. }
  6015. // Update returns an update builder for UserSubscription.
  6016. func (c *UserSubscriptionClient) Update() *UserSubscriptionUpdate {
  6017. mutation := newUserSubscriptionMutation(c.config, OpUpdate)
  6018. return &UserSubscriptionUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  6019. }
  6020. // UpdateOne returns an update builder for the given entity.
  6021. func (c *UserSubscriptionClient) UpdateOne(_m *UserSubscription) *UserSubscriptionUpdateOne {
  6022. mutation := newUserSubscriptionMutation(c.config, OpUpdateOne, withUserSubscription(_m))
  6023. return &UserSubscriptionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  6024. }
  6025. // UpdateOneID returns an update builder for the given id.
  6026. func (c *UserSubscriptionClient) UpdateOneID(id int64) *UserSubscriptionUpdateOne {
  6027. mutation := newUserSubscriptionMutation(c.config, OpUpdateOne, withUserSubscriptionID(id))
  6028. return &UserSubscriptionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  6029. }
  6030. // Delete returns a delete builder for UserSubscription.
  6031. func (c *UserSubscriptionClient) Delete() *UserSubscriptionDelete {
  6032. mutation := newUserSubscriptionMutation(c.config, OpDelete)
  6033. return &UserSubscriptionDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  6034. }
  6035. // DeleteOne returns a builder for deleting the given entity.
  6036. func (c *UserSubscriptionClient) DeleteOne(_m *UserSubscription) *UserSubscriptionDeleteOne {
  6037. return c.DeleteOneID(_m.ID)
  6038. }
  6039. // DeleteOneID returns a builder for deleting the given entity by its id.
  6040. func (c *UserSubscriptionClient) DeleteOneID(id int64) *UserSubscriptionDeleteOne {
  6041. builder := c.Delete().Where(usersubscription.ID(id))
  6042. builder.mutation.id = &id
  6043. builder.mutation.op = OpDeleteOne
  6044. return &UserSubscriptionDeleteOne{builder}
  6045. }
  6046. // Query returns a query builder for UserSubscription.
  6047. func (c *UserSubscriptionClient) Query() *UserSubscriptionQuery {
  6048. return &UserSubscriptionQuery{
  6049. config: c.config,
  6050. ctx: &QueryContext{Type: TypeUserSubscription},
  6051. inters: c.Interceptors(),
  6052. }
  6053. }
  6054. // Get returns a UserSubscription entity by its id.
  6055. func (c *UserSubscriptionClient) Get(ctx context.Context, id int64) (*UserSubscription, error) {
  6056. return c.Query().Where(usersubscription.ID(id)).Only(ctx)
  6057. }
  6058. // GetX is like Get, but panics if an error occurs.
  6059. func (c *UserSubscriptionClient) GetX(ctx context.Context, id int64) *UserSubscription {
  6060. obj, err := c.Get(ctx, id)
  6061. if err != nil {
  6062. panic(err)
  6063. }
  6064. return obj
  6065. }
  6066. // QueryUser queries the user edge of a UserSubscription.
  6067. func (c *UserSubscriptionClient) QueryUser(_m *UserSubscription) *UserQuery {
  6068. query := (&UserClient{config: c.config}).Query()
  6069. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  6070. id := _m.ID
  6071. step := sqlgraph.NewStep(
  6072. sqlgraph.From(usersubscription.Table, usersubscription.FieldID, id),
  6073. sqlgraph.To(user.Table, user.FieldID),
  6074. sqlgraph.Edge(sqlgraph.M2O, true, usersubscription.UserTable, usersubscription.UserColumn),
  6075. )
  6076. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  6077. return fromV, nil
  6078. }
  6079. return query
  6080. }
  6081. // QueryGroup queries the group edge of a UserSubscription.
  6082. func (c *UserSubscriptionClient) QueryGroup(_m *UserSubscription) *GroupQuery {
  6083. query := (&GroupClient{config: c.config}).Query()
  6084. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  6085. id := _m.ID
  6086. step := sqlgraph.NewStep(
  6087. sqlgraph.From(usersubscription.Table, usersubscription.FieldID, id),
  6088. sqlgraph.To(group.Table, group.FieldID),
  6089. sqlgraph.Edge(sqlgraph.M2O, true, usersubscription.GroupTable, usersubscription.GroupColumn),
  6090. )
  6091. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  6092. return fromV, nil
  6093. }
  6094. return query
  6095. }
  6096. // QueryAssignedByUser queries the assigned_by_user edge of a UserSubscription.
  6097. func (c *UserSubscriptionClient) QueryAssignedByUser(_m *UserSubscription) *UserQuery {
  6098. query := (&UserClient{config: c.config}).Query()
  6099. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  6100. id := _m.ID
  6101. step := sqlgraph.NewStep(
  6102. sqlgraph.From(usersubscription.Table, usersubscription.FieldID, id),
  6103. sqlgraph.To(user.Table, user.FieldID),
  6104. sqlgraph.Edge(sqlgraph.M2O, true, usersubscription.AssignedByUserTable, usersubscription.AssignedByUserColumn),
  6105. )
  6106. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  6107. return fromV, nil
  6108. }
  6109. return query
  6110. }
  6111. // QueryUsageLogs queries the usage_logs edge of a UserSubscription.
  6112. func (c *UserSubscriptionClient) QueryUsageLogs(_m *UserSubscription) *UsageLogQuery {
  6113. query := (&UsageLogClient{config: c.config}).Query()
  6114. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  6115. id := _m.ID
  6116. step := sqlgraph.NewStep(
  6117. sqlgraph.From(usersubscription.Table, usersubscription.FieldID, id),
  6118. sqlgraph.To(usagelog.Table, usagelog.FieldID),
  6119. sqlgraph.Edge(sqlgraph.O2M, false, usersubscription.UsageLogsTable, usersubscription.UsageLogsColumn),
  6120. )
  6121. fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
  6122. return fromV, nil
  6123. }
  6124. return query
  6125. }
  6126. // Hooks returns the client hooks.
  6127. func (c *UserSubscriptionClient) Hooks() []Hook {
  6128. hooks := c.hooks.UserSubscription
  6129. return append(hooks[:len(hooks):len(hooks)], usersubscription.Hooks[:]...)
  6130. }
  6131. // Interceptors returns the client interceptors.
  6132. func (c *UserSubscriptionClient) Interceptors() []Interceptor {
  6133. inters := c.inters.UserSubscription
  6134. return append(inters[:len(inters):len(inters)], usersubscription.Interceptors[:]...)
  6135. }
  6136. func (c *UserSubscriptionClient) mutate(ctx context.Context, m *UserSubscriptionMutation) (Value, error) {
  6137. switch m.Op() {
  6138. case OpCreate:
  6139. return (&UserSubscriptionCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  6140. case OpUpdate:
  6141. return (&UserSubscriptionUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  6142. case OpUpdateOne:
  6143. return (&UserSubscriptionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  6144. case OpDelete, OpDeleteOne:
  6145. return (&UserSubscriptionDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  6146. default:
  6147. return nil, fmt.Errorf("ent: unknown UserSubscription mutation op: %q", m.Op())
  6148. }
  6149. }
  6150. // hooks and interceptors per client, for fast access.
  6151. type (
  6152. hooks struct {
  6153. APIKey, Account, AccountGroup, Announcement, AnnouncementRead, AuthIdentity,
  6154. AuthIdentityChannel, BatchImageEvent, BatchImageItem, BatchImageJob,
  6155. ChannelMonitor, ChannelMonitorDailyRollup, ChannelMonitorHistory,
  6156. ChannelMonitorRequestTemplate, CompositeModelRoute, ErrorPassthroughRule,
  6157. Group, IdempotencyRecord, IdentityAdoptionDecision, PaymentAuditLog,
  6158. PaymentOrder, PaymentProviderInstance, PendingAuthSession, PromoCode,
  6159. PromoCodeUsage, Proxy, RedeemCode, SecurityPolicyKeyword, SecuritySecret,
  6160. Setting, SubscriptionPlan, TLSFingerprintProfile, UsageCleanupTask, UsageLog,
  6161. User, UserAllowedGroup, UserAttributeDefinition, UserAttributeValue,
  6162. UserPlatformQuota, UserSubscription []ent.Hook
  6163. }
  6164. inters struct {
  6165. APIKey, Account, AccountGroup, Announcement, AnnouncementRead, AuthIdentity,
  6166. AuthIdentityChannel, BatchImageEvent, BatchImageItem, BatchImageJob,
  6167. ChannelMonitor, ChannelMonitorDailyRollup, ChannelMonitorHistory,
  6168. ChannelMonitorRequestTemplate, CompositeModelRoute, ErrorPassthroughRule,
  6169. Group, IdempotencyRecord, IdentityAdoptionDecision, PaymentAuditLog,
  6170. PaymentOrder, PaymentProviderInstance, PendingAuthSession, PromoCode,
  6171. PromoCodeUsage, Proxy, RedeemCode, SecurityPolicyKeyword, SecuritySecret,
  6172. Setting, SubscriptionPlan, TLSFingerprintProfile, UsageCleanupTask, UsageLog,
  6173. User, UserAllowedGroup, UserAttributeDefinition, UserAttributeValue,
  6174. UserPlatformQuota, UserSubscription []ent.Interceptor
  6175. }
  6176. )
  6177. // ExecContext allows calling the underlying ExecContext method of the driver if it is supported by it.
  6178. // See, database/sql#DB.ExecContext for more information.
  6179. func (c *config) ExecContext(ctx context.Context, query string, args ...any) (stdsql.Result, error) {
  6180. ex, ok := c.driver.(interface {
  6181. ExecContext(context.Context, string, ...any) (stdsql.Result, error)
  6182. })
  6183. if !ok {
  6184. return nil, fmt.Errorf("Driver.ExecContext is not supported")
  6185. }
  6186. return ex.ExecContext(ctx, query, args...)
  6187. }
  6188. // QueryContext allows calling the underlying QueryContext method of the driver if it is supported by it.
  6189. // See, database/sql#DB.QueryContext for more information.
  6190. func (c *config) QueryContext(ctx context.Context, query string, args ...any) (*stdsql.Rows, error) {
  6191. q, ok := c.driver.(interface {
  6192. QueryContext(context.Context, string, ...any) (*stdsql.Rows, error)
  6193. })
  6194. if !ok {
  6195. return nil, fmt.Errorf("Driver.QueryContext is not supported")
  6196. }
  6197. return q.QueryContext(ctx, query, args...)
  6198. }