client.go 258 KB

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