client.go 277 KB

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