client.go 240 KB

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