client.go 288 KB

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