client.go 228 KB

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