client.go 282 KB

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