client.go 289 KB

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