client.go 282 KB

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