client.go 228 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077
  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,
  388. c.Message, c.MessageRecords, c.Msg, c.PayRecharge, c.Server, c.SopNode,
  389. c.SopStage, 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,
  403. c.Message, c.MessageRecords, c.Msg, c.PayRecharge, c.Server, c.SopNode,
  404. c.SopStage, 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. hooks := c.hooks.LabelRelationship
  2359. return append(hooks[:len(hooks):len(hooks)], labelrelationship.Hooks[:]...)
  2360. }
  2361. // Interceptors returns the client interceptors.
  2362. func (c *LabelRelationshipClient) Interceptors() []Interceptor {
  2363. inters := c.inters.LabelRelationship
  2364. return append(inters[:len(inters):len(inters)], labelrelationship.Interceptors[:]...)
  2365. }
  2366. func (c *LabelRelationshipClient) mutate(ctx context.Context, m *LabelRelationshipMutation) (Value, error) {
  2367. switch m.Op() {
  2368. case OpCreate:
  2369. return (&LabelRelationshipCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2370. case OpUpdate:
  2371. return (&LabelRelationshipUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2372. case OpUpdateOne:
  2373. return (&LabelRelationshipUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2374. case OpDelete, OpDeleteOne:
  2375. return (&LabelRelationshipDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  2376. default:
  2377. return nil, fmt.Errorf("ent: unknown LabelRelationship mutation op: %q", m.Op())
  2378. }
  2379. }
  2380. // LabelTaggingClient is a client for the LabelTagging schema.
  2381. type LabelTaggingClient struct {
  2382. config
  2383. }
  2384. // NewLabelTaggingClient returns a client for the LabelTagging from the given config.
  2385. func NewLabelTaggingClient(c config) *LabelTaggingClient {
  2386. return &LabelTaggingClient{config: c}
  2387. }
  2388. // Use adds a list of mutation hooks to the hooks stack.
  2389. // A call to `Use(f, g, h)` equals to `labeltagging.Hooks(f(g(h())))`.
  2390. func (c *LabelTaggingClient) Use(hooks ...Hook) {
  2391. c.hooks.LabelTagging = append(c.hooks.LabelTagging, hooks...)
  2392. }
  2393. // Intercept adds a list of query interceptors to the interceptors stack.
  2394. // A call to `Intercept(f, g, h)` equals to `labeltagging.Intercept(f(g(h())))`.
  2395. func (c *LabelTaggingClient) Intercept(interceptors ...Interceptor) {
  2396. c.inters.LabelTagging = append(c.inters.LabelTagging, interceptors...)
  2397. }
  2398. // Create returns a builder for creating a LabelTagging entity.
  2399. func (c *LabelTaggingClient) Create() *LabelTaggingCreate {
  2400. mutation := newLabelTaggingMutation(c.config, OpCreate)
  2401. return &LabelTaggingCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2402. }
  2403. // CreateBulk returns a builder for creating a bulk of LabelTagging entities.
  2404. func (c *LabelTaggingClient) CreateBulk(builders ...*LabelTaggingCreate) *LabelTaggingCreateBulk {
  2405. return &LabelTaggingCreateBulk{config: c.config, builders: builders}
  2406. }
  2407. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  2408. // a builder and applies setFunc on it.
  2409. func (c *LabelTaggingClient) MapCreateBulk(slice any, setFunc func(*LabelTaggingCreate, int)) *LabelTaggingCreateBulk {
  2410. rv := reflect.ValueOf(slice)
  2411. if rv.Kind() != reflect.Slice {
  2412. return &LabelTaggingCreateBulk{err: fmt.Errorf("calling to LabelTaggingClient.MapCreateBulk with wrong type %T, need slice", slice)}
  2413. }
  2414. builders := make([]*LabelTaggingCreate, rv.Len())
  2415. for i := 0; i < rv.Len(); i++ {
  2416. builders[i] = c.Create()
  2417. setFunc(builders[i], i)
  2418. }
  2419. return &LabelTaggingCreateBulk{config: c.config, builders: builders}
  2420. }
  2421. // Update returns an update builder for LabelTagging.
  2422. func (c *LabelTaggingClient) Update() *LabelTaggingUpdate {
  2423. mutation := newLabelTaggingMutation(c.config, OpUpdate)
  2424. return &LabelTaggingUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2425. }
  2426. // UpdateOne returns an update builder for the given entity.
  2427. func (c *LabelTaggingClient) UpdateOne(lt *LabelTagging) *LabelTaggingUpdateOne {
  2428. mutation := newLabelTaggingMutation(c.config, OpUpdateOne, withLabelTagging(lt))
  2429. return &LabelTaggingUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2430. }
  2431. // UpdateOneID returns an update builder for the given id.
  2432. func (c *LabelTaggingClient) UpdateOneID(id uint64) *LabelTaggingUpdateOne {
  2433. mutation := newLabelTaggingMutation(c.config, OpUpdateOne, withLabelTaggingID(id))
  2434. return &LabelTaggingUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2435. }
  2436. // Delete returns a delete builder for LabelTagging.
  2437. func (c *LabelTaggingClient) Delete() *LabelTaggingDelete {
  2438. mutation := newLabelTaggingMutation(c.config, OpDelete)
  2439. return &LabelTaggingDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2440. }
  2441. // DeleteOne returns a builder for deleting the given entity.
  2442. func (c *LabelTaggingClient) DeleteOne(lt *LabelTagging) *LabelTaggingDeleteOne {
  2443. return c.DeleteOneID(lt.ID)
  2444. }
  2445. // DeleteOneID returns a builder for deleting the given entity by its id.
  2446. func (c *LabelTaggingClient) DeleteOneID(id uint64) *LabelTaggingDeleteOne {
  2447. builder := c.Delete().Where(labeltagging.ID(id))
  2448. builder.mutation.id = &id
  2449. builder.mutation.op = OpDeleteOne
  2450. return &LabelTaggingDeleteOne{builder}
  2451. }
  2452. // Query returns a query builder for LabelTagging.
  2453. func (c *LabelTaggingClient) Query() *LabelTaggingQuery {
  2454. return &LabelTaggingQuery{
  2455. config: c.config,
  2456. ctx: &QueryContext{Type: TypeLabelTagging},
  2457. inters: c.Interceptors(),
  2458. }
  2459. }
  2460. // Get returns a LabelTagging entity by its id.
  2461. func (c *LabelTaggingClient) Get(ctx context.Context, id uint64) (*LabelTagging, error) {
  2462. return c.Query().Where(labeltagging.ID(id)).Only(ctx)
  2463. }
  2464. // GetX is like Get, but panics if an error occurs.
  2465. func (c *LabelTaggingClient) GetX(ctx context.Context, id uint64) *LabelTagging {
  2466. obj, err := c.Get(ctx, id)
  2467. if err != nil {
  2468. panic(err)
  2469. }
  2470. return obj
  2471. }
  2472. // Hooks returns the client hooks.
  2473. func (c *LabelTaggingClient) Hooks() []Hook {
  2474. hooks := c.hooks.LabelTagging
  2475. return append(hooks[:len(hooks):len(hooks)], labeltagging.Hooks[:]...)
  2476. }
  2477. // Interceptors returns the client interceptors.
  2478. func (c *LabelTaggingClient) Interceptors() []Interceptor {
  2479. inters := c.inters.LabelTagging
  2480. return append(inters[:len(inters):len(inters)], labeltagging.Interceptors[:]...)
  2481. }
  2482. func (c *LabelTaggingClient) mutate(ctx context.Context, m *LabelTaggingMutation) (Value, error) {
  2483. switch m.Op() {
  2484. case OpCreate:
  2485. return (&LabelTaggingCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2486. case OpUpdate:
  2487. return (&LabelTaggingUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2488. case OpUpdateOne:
  2489. return (&LabelTaggingUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2490. case OpDelete, OpDeleteOne:
  2491. return (&LabelTaggingDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  2492. default:
  2493. return nil, fmt.Errorf("ent: unknown LabelTagging mutation op: %q", m.Op())
  2494. }
  2495. }
  2496. // MessageClient is a client for the Message schema.
  2497. type MessageClient struct {
  2498. config
  2499. }
  2500. // NewMessageClient returns a client for the Message from the given config.
  2501. func NewMessageClient(c config) *MessageClient {
  2502. return &MessageClient{config: c}
  2503. }
  2504. // Use adds a list of mutation hooks to the hooks stack.
  2505. // A call to `Use(f, g, h)` equals to `message.Hooks(f(g(h())))`.
  2506. func (c *MessageClient) Use(hooks ...Hook) {
  2507. c.hooks.Message = append(c.hooks.Message, hooks...)
  2508. }
  2509. // Intercept adds a list of query interceptors to the interceptors stack.
  2510. // A call to `Intercept(f, g, h)` equals to `message.Intercept(f(g(h())))`.
  2511. func (c *MessageClient) Intercept(interceptors ...Interceptor) {
  2512. c.inters.Message = append(c.inters.Message, interceptors...)
  2513. }
  2514. // Create returns a builder for creating a Message entity.
  2515. func (c *MessageClient) Create() *MessageCreate {
  2516. mutation := newMessageMutation(c.config, OpCreate)
  2517. return &MessageCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2518. }
  2519. // CreateBulk returns a builder for creating a bulk of Message entities.
  2520. func (c *MessageClient) CreateBulk(builders ...*MessageCreate) *MessageCreateBulk {
  2521. return &MessageCreateBulk{config: c.config, builders: builders}
  2522. }
  2523. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  2524. // a builder and applies setFunc on it.
  2525. func (c *MessageClient) MapCreateBulk(slice any, setFunc func(*MessageCreate, int)) *MessageCreateBulk {
  2526. rv := reflect.ValueOf(slice)
  2527. if rv.Kind() != reflect.Slice {
  2528. return &MessageCreateBulk{err: fmt.Errorf("calling to MessageClient.MapCreateBulk with wrong type %T, need slice", slice)}
  2529. }
  2530. builders := make([]*MessageCreate, rv.Len())
  2531. for i := 0; i < rv.Len(); i++ {
  2532. builders[i] = c.Create()
  2533. setFunc(builders[i], i)
  2534. }
  2535. return &MessageCreateBulk{config: c.config, builders: builders}
  2536. }
  2537. // Update returns an update builder for Message.
  2538. func (c *MessageClient) Update() *MessageUpdate {
  2539. mutation := newMessageMutation(c.config, OpUpdate)
  2540. return &MessageUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2541. }
  2542. // UpdateOne returns an update builder for the given entity.
  2543. func (c *MessageClient) UpdateOne(m *Message) *MessageUpdateOne {
  2544. mutation := newMessageMutation(c.config, OpUpdateOne, withMessage(m))
  2545. return &MessageUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2546. }
  2547. // UpdateOneID returns an update builder for the given id.
  2548. func (c *MessageClient) UpdateOneID(id int) *MessageUpdateOne {
  2549. mutation := newMessageMutation(c.config, OpUpdateOne, withMessageID(id))
  2550. return &MessageUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2551. }
  2552. // Delete returns a delete builder for Message.
  2553. func (c *MessageClient) Delete() *MessageDelete {
  2554. mutation := newMessageMutation(c.config, OpDelete)
  2555. return &MessageDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2556. }
  2557. // DeleteOne returns a builder for deleting the given entity.
  2558. func (c *MessageClient) DeleteOne(m *Message) *MessageDeleteOne {
  2559. return c.DeleteOneID(m.ID)
  2560. }
  2561. // DeleteOneID returns a builder for deleting the given entity by its id.
  2562. func (c *MessageClient) DeleteOneID(id int) *MessageDeleteOne {
  2563. builder := c.Delete().Where(message.ID(id))
  2564. builder.mutation.id = &id
  2565. builder.mutation.op = OpDeleteOne
  2566. return &MessageDeleteOne{builder}
  2567. }
  2568. // Query returns a query builder for Message.
  2569. func (c *MessageClient) Query() *MessageQuery {
  2570. return &MessageQuery{
  2571. config: c.config,
  2572. ctx: &QueryContext{Type: TypeMessage},
  2573. inters: c.Interceptors(),
  2574. }
  2575. }
  2576. // Get returns a Message entity by its id.
  2577. func (c *MessageClient) Get(ctx context.Context, id int) (*Message, error) {
  2578. return c.Query().Where(message.ID(id)).Only(ctx)
  2579. }
  2580. // GetX is like Get, but panics if an error occurs.
  2581. func (c *MessageClient) GetX(ctx context.Context, id int) *Message {
  2582. obj, err := c.Get(ctx, id)
  2583. if err != nil {
  2584. panic(err)
  2585. }
  2586. return obj
  2587. }
  2588. // Hooks returns the client hooks.
  2589. func (c *MessageClient) Hooks() []Hook {
  2590. return c.hooks.Message
  2591. }
  2592. // Interceptors returns the client interceptors.
  2593. func (c *MessageClient) Interceptors() []Interceptor {
  2594. return c.inters.Message
  2595. }
  2596. func (c *MessageClient) mutate(ctx context.Context, m *MessageMutation) (Value, error) {
  2597. switch m.Op() {
  2598. case OpCreate:
  2599. return (&MessageCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2600. case OpUpdate:
  2601. return (&MessageUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2602. case OpUpdateOne:
  2603. return (&MessageUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2604. case OpDelete, OpDeleteOne:
  2605. return (&MessageDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  2606. default:
  2607. return nil, fmt.Errorf("ent: unknown Message mutation op: %q", m.Op())
  2608. }
  2609. }
  2610. // MessageRecordsClient is a client for the MessageRecords schema.
  2611. type MessageRecordsClient struct {
  2612. config
  2613. }
  2614. // NewMessageRecordsClient returns a client for the MessageRecords from the given config.
  2615. func NewMessageRecordsClient(c config) *MessageRecordsClient {
  2616. return &MessageRecordsClient{config: c}
  2617. }
  2618. // Use adds a list of mutation hooks to the hooks stack.
  2619. // A call to `Use(f, g, h)` equals to `messagerecords.Hooks(f(g(h())))`.
  2620. func (c *MessageRecordsClient) Use(hooks ...Hook) {
  2621. c.hooks.MessageRecords = append(c.hooks.MessageRecords, hooks...)
  2622. }
  2623. // Intercept adds a list of query interceptors to the interceptors stack.
  2624. // A call to `Intercept(f, g, h)` equals to `messagerecords.Intercept(f(g(h())))`.
  2625. func (c *MessageRecordsClient) Intercept(interceptors ...Interceptor) {
  2626. c.inters.MessageRecords = append(c.inters.MessageRecords, interceptors...)
  2627. }
  2628. // Create returns a builder for creating a MessageRecords entity.
  2629. func (c *MessageRecordsClient) Create() *MessageRecordsCreate {
  2630. mutation := newMessageRecordsMutation(c.config, OpCreate)
  2631. return &MessageRecordsCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2632. }
  2633. // CreateBulk returns a builder for creating a bulk of MessageRecords entities.
  2634. func (c *MessageRecordsClient) CreateBulk(builders ...*MessageRecordsCreate) *MessageRecordsCreateBulk {
  2635. return &MessageRecordsCreateBulk{config: c.config, builders: builders}
  2636. }
  2637. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  2638. // a builder and applies setFunc on it.
  2639. func (c *MessageRecordsClient) MapCreateBulk(slice any, setFunc func(*MessageRecordsCreate, int)) *MessageRecordsCreateBulk {
  2640. rv := reflect.ValueOf(slice)
  2641. if rv.Kind() != reflect.Slice {
  2642. return &MessageRecordsCreateBulk{err: fmt.Errorf("calling to MessageRecordsClient.MapCreateBulk with wrong type %T, need slice", slice)}
  2643. }
  2644. builders := make([]*MessageRecordsCreate, rv.Len())
  2645. for i := 0; i < rv.Len(); i++ {
  2646. builders[i] = c.Create()
  2647. setFunc(builders[i], i)
  2648. }
  2649. return &MessageRecordsCreateBulk{config: c.config, builders: builders}
  2650. }
  2651. // Update returns an update builder for MessageRecords.
  2652. func (c *MessageRecordsClient) Update() *MessageRecordsUpdate {
  2653. mutation := newMessageRecordsMutation(c.config, OpUpdate)
  2654. return &MessageRecordsUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2655. }
  2656. // UpdateOne returns an update builder for the given entity.
  2657. func (c *MessageRecordsClient) UpdateOne(mr *MessageRecords) *MessageRecordsUpdateOne {
  2658. mutation := newMessageRecordsMutation(c.config, OpUpdateOne, withMessageRecords(mr))
  2659. return &MessageRecordsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2660. }
  2661. // UpdateOneID returns an update builder for the given id.
  2662. func (c *MessageRecordsClient) UpdateOneID(id uint64) *MessageRecordsUpdateOne {
  2663. mutation := newMessageRecordsMutation(c.config, OpUpdateOne, withMessageRecordsID(id))
  2664. return &MessageRecordsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2665. }
  2666. // Delete returns a delete builder for MessageRecords.
  2667. func (c *MessageRecordsClient) Delete() *MessageRecordsDelete {
  2668. mutation := newMessageRecordsMutation(c.config, OpDelete)
  2669. return &MessageRecordsDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2670. }
  2671. // DeleteOne returns a builder for deleting the given entity.
  2672. func (c *MessageRecordsClient) DeleteOne(mr *MessageRecords) *MessageRecordsDeleteOne {
  2673. return c.DeleteOneID(mr.ID)
  2674. }
  2675. // DeleteOneID returns a builder for deleting the given entity by its id.
  2676. func (c *MessageRecordsClient) DeleteOneID(id uint64) *MessageRecordsDeleteOne {
  2677. builder := c.Delete().Where(messagerecords.ID(id))
  2678. builder.mutation.id = &id
  2679. builder.mutation.op = OpDeleteOne
  2680. return &MessageRecordsDeleteOne{builder}
  2681. }
  2682. // Query returns a query builder for MessageRecords.
  2683. func (c *MessageRecordsClient) Query() *MessageRecordsQuery {
  2684. return &MessageRecordsQuery{
  2685. config: c.config,
  2686. ctx: &QueryContext{Type: TypeMessageRecords},
  2687. inters: c.Interceptors(),
  2688. }
  2689. }
  2690. // Get returns a MessageRecords entity by its id.
  2691. func (c *MessageRecordsClient) Get(ctx context.Context, id uint64) (*MessageRecords, error) {
  2692. return c.Query().Where(messagerecords.ID(id)).Only(ctx)
  2693. }
  2694. // GetX is like Get, but panics if an error occurs.
  2695. func (c *MessageRecordsClient) GetX(ctx context.Context, id uint64) *MessageRecords {
  2696. obj, err := c.Get(ctx, id)
  2697. if err != nil {
  2698. panic(err)
  2699. }
  2700. return obj
  2701. }
  2702. // QuerySopStage queries the sop_stage edge of a MessageRecords.
  2703. func (c *MessageRecordsClient) QuerySopStage(mr *MessageRecords) *SopStageQuery {
  2704. query := (&SopStageClient{config: c.config}).Query()
  2705. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  2706. id := mr.ID
  2707. step := sqlgraph.NewStep(
  2708. sqlgraph.From(messagerecords.Table, messagerecords.FieldID, id),
  2709. sqlgraph.To(sopstage.Table, sopstage.FieldID),
  2710. sqlgraph.Edge(sqlgraph.M2O, true, messagerecords.SopStageTable, messagerecords.SopStageColumn),
  2711. )
  2712. fromV = sqlgraph.Neighbors(mr.driver.Dialect(), step)
  2713. return fromV, nil
  2714. }
  2715. return query
  2716. }
  2717. // QuerySopNode queries the sop_node edge of a MessageRecords.
  2718. func (c *MessageRecordsClient) QuerySopNode(mr *MessageRecords) *SopNodeQuery {
  2719. query := (&SopNodeClient{config: c.config}).Query()
  2720. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  2721. id := mr.ID
  2722. step := sqlgraph.NewStep(
  2723. sqlgraph.From(messagerecords.Table, messagerecords.FieldID, id),
  2724. sqlgraph.To(sopnode.Table, sopnode.FieldID),
  2725. sqlgraph.Edge(sqlgraph.M2O, true, messagerecords.SopNodeTable, messagerecords.SopNodeColumn),
  2726. )
  2727. fromV = sqlgraph.Neighbors(mr.driver.Dialect(), step)
  2728. return fromV, nil
  2729. }
  2730. return query
  2731. }
  2732. // QueryMessageContact queries the message_contact edge of a MessageRecords.
  2733. func (c *MessageRecordsClient) QueryMessageContact(mr *MessageRecords) *ContactQuery {
  2734. query := (&ContactClient{config: c.config}).Query()
  2735. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  2736. id := mr.ID
  2737. step := sqlgraph.NewStep(
  2738. sqlgraph.From(messagerecords.Table, messagerecords.FieldID, id),
  2739. sqlgraph.To(contact.Table, contact.FieldID),
  2740. sqlgraph.Edge(sqlgraph.M2O, true, messagerecords.MessageContactTable, messagerecords.MessageContactColumn),
  2741. )
  2742. fromV = sqlgraph.Neighbors(mr.driver.Dialect(), step)
  2743. return fromV, nil
  2744. }
  2745. return query
  2746. }
  2747. // Hooks returns the client hooks.
  2748. func (c *MessageRecordsClient) Hooks() []Hook {
  2749. return c.hooks.MessageRecords
  2750. }
  2751. // Interceptors returns the client interceptors.
  2752. func (c *MessageRecordsClient) Interceptors() []Interceptor {
  2753. return c.inters.MessageRecords
  2754. }
  2755. func (c *MessageRecordsClient) mutate(ctx context.Context, m *MessageRecordsMutation) (Value, error) {
  2756. switch m.Op() {
  2757. case OpCreate:
  2758. return (&MessageRecordsCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2759. case OpUpdate:
  2760. return (&MessageRecordsUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2761. case OpUpdateOne:
  2762. return (&MessageRecordsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2763. case OpDelete, OpDeleteOne:
  2764. return (&MessageRecordsDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  2765. default:
  2766. return nil, fmt.Errorf("ent: unknown MessageRecords mutation op: %q", m.Op())
  2767. }
  2768. }
  2769. // MsgClient is a client for the Msg schema.
  2770. type MsgClient struct {
  2771. config
  2772. }
  2773. // NewMsgClient returns a client for the Msg from the given config.
  2774. func NewMsgClient(c config) *MsgClient {
  2775. return &MsgClient{config: c}
  2776. }
  2777. // Use adds a list of mutation hooks to the hooks stack.
  2778. // A call to `Use(f, g, h)` equals to `msg.Hooks(f(g(h())))`.
  2779. func (c *MsgClient) Use(hooks ...Hook) {
  2780. c.hooks.Msg = append(c.hooks.Msg, hooks...)
  2781. }
  2782. // Intercept adds a list of query interceptors to the interceptors stack.
  2783. // A call to `Intercept(f, g, h)` equals to `msg.Intercept(f(g(h())))`.
  2784. func (c *MsgClient) Intercept(interceptors ...Interceptor) {
  2785. c.inters.Msg = append(c.inters.Msg, interceptors...)
  2786. }
  2787. // Create returns a builder for creating a Msg entity.
  2788. func (c *MsgClient) Create() *MsgCreate {
  2789. mutation := newMsgMutation(c.config, OpCreate)
  2790. return &MsgCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2791. }
  2792. // CreateBulk returns a builder for creating a bulk of Msg entities.
  2793. func (c *MsgClient) CreateBulk(builders ...*MsgCreate) *MsgCreateBulk {
  2794. return &MsgCreateBulk{config: c.config, builders: builders}
  2795. }
  2796. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  2797. // a builder and applies setFunc on it.
  2798. func (c *MsgClient) MapCreateBulk(slice any, setFunc func(*MsgCreate, int)) *MsgCreateBulk {
  2799. rv := reflect.ValueOf(slice)
  2800. if rv.Kind() != reflect.Slice {
  2801. return &MsgCreateBulk{err: fmt.Errorf("calling to MsgClient.MapCreateBulk with wrong type %T, need slice", slice)}
  2802. }
  2803. builders := make([]*MsgCreate, rv.Len())
  2804. for i := 0; i < rv.Len(); i++ {
  2805. builders[i] = c.Create()
  2806. setFunc(builders[i], i)
  2807. }
  2808. return &MsgCreateBulk{config: c.config, builders: builders}
  2809. }
  2810. // Update returns an update builder for Msg.
  2811. func (c *MsgClient) Update() *MsgUpdate {
  2812. mutation := newMsgMutation(c.config, OpUpdate)
  2813. return &MsgUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2814. }
  2815. // UpdateOne returns an update builder for the given entity.
  2816. func (c *MsgClient) UpdateOne(m *Msg) *MsgUpdateOne {
  2817. mutation := newMsgMutation(c.config, OpUpdateOne, withMsg(m))
  2818. return &MsgUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2819. }
  2820. // UpdateOneID returns an update builder for the given id.
  2821. func (c *MsgClient) UpdateOneID(id uint64) *MsgUpdateOne {
  2822. mutation := newMsgMutation(c.config, OpUpdateOne, withMsgID(id))
  2823. return &MsgUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2824. }
  2825. // Delete returns a delete builder for Msg.
  2826. func (c *MsgClient) Delete() *MsgDelete {
  2827. mutation := newMsgMutation(c.config, OpDelete)
  2828. return &MsgDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2829. }
  2830. // DeleteOne returns a builder for deleting the given entity.
  2831. func (c *MsgClient) DeleteOne(m *Msg) *MsgDeleteOne {
  2832. return c.DeleteOneID(m.ID)
  2833. }
  2834. // DeleteOneID returns a builder for deleting the given entity by its id.
  2835. func (c *MsgClient) DeleteOneID(id uint64) *MsgDeleteOne {
  2836. builder := c.Delete().Where(msg.ID(id))
  2837. builder.mutation.id = &id
  2838. builder.mutation.op = OpDeleteOne
  2839. return &MsgDeleteOne{builder}
  2840. }
  2841. // Query returns a query builder for Msg.
  2842. func (c *MsgClient) Query() *MsgQuery {
  2843. return &MsgQuery{
  2844. config: c.config,
  2845. ctx: &QueryContext{Type: TypeMsg},
  2846. inters: c.Interceptors(),
  2847. }
  2848. }
  2849. // Get returns a Msg entity by its id.
  2850. func (c *MsgClient) Get(ctx context.Context, id uint64) (*Msg, error) {
  2851. return c.Query().Where(msg.ID(id)).Only(ctx)
  2852. }
  2853. // GetX is like Get, but panics if an error occurs.
  2854. func (c *MsgClient) GetX(ctx context.Context, id uint64) *Msg {
  2855. obj, err := c.Get(ctx, id)
  2856. if err != nil {
  2857. panic(err)
  2858. }
  2859. return obj
  2860. }
  2861. // Hooks returns the client hooks.
  2862. func (c *MsgClient) Hooks() []Hook {
  2863. hooks := c.hooks.Msg
  2864. return append(hooks[:len(hooks):len(hooks)], msg.Hooks[:]...)
  2865. }
  2866. // Interceptors returns the client interceptors.
  2867. func (c *MsgClient) Interceptors() []Interceptor {
  2868. inters := c.inters.Msg
  2869. return append(inters[:len(inters):len(inters)], msg.Interceptors[:]...)
  2870. }
  2871. func (c *MsgClient) mutate(ctx context.Context, m *MsgMutation) (Value, error) {
  2872. switch m.Op() {
  2873. case OpCreate:
  2874. return (&MsgCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2875. case OpUpdate:
  2876. return (&MsgUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2877. case OpUpdateOne:
  2878. return (&MsgUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2879. case OpDelete, OpDeleteOne:
  2880. return (&MsgDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  2881. default:
  2882. return nil, fmt.Errorf("ent: unknown Msg mutation op: %q", m.Op())
  2883. }
  2884. }
  2885. // PayRechargeClient is a client for the PayRecharge schema.
  2886. type PayRechargeClient struct {
  2887. config
  2888. }
  2889. // NewPayRechargeClient returns a client for the PayRecharge from the given config.
  2890. func NewPayRechargeClient(c config) *PayRechargeClient {
  2891. return &PayRechargeClient{config: c}
  2892. }
  2893. // Use adds a list of mutation hooks to the hooks stack.
  2894. // A call to `Use(f, g, h)` equals to `payrecharge.Hooks(f(g(h())))`.
  2895. func (c *PayRechargeClient) Use(hooks ...Hook) {
  2896. c.hooks.PayRecharge = append(c.hooks.PayRecharge, hooks...)
  2897. }
  2898. // Intercept adds a list of query interceptors to the interceptors stack.
  2899. // A call to `Intercept(f, g, h)` equals to `payrecharge.Intercept(f(g(h())))`.
  2900. func (c *PayRechargeClient) Intercept(interceptors ...Interceptor) {
  2901. c.inters.PayRecharge = append(c.inters.PayRecharge, interceptors...)
  2902. }
  2903. // Create returns a builder for creating a PayRecharge entity.
  2904. func (c *PayRechargeClient) Create() *PayRechargeCreate {
  2905. mutation := newPayRechargeMutation(c.config, OpCreate)
  2906. return &PayRechargeCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2907. }
  2908. // CreateBulk returns a builder for creating a bulk of PayRecharge entities.
  2909. func (c *PayRechargeClient) CreateBulk(builders ...*PayRechargeCreate) *PayRechargeCreateBulk {
  2910. return &PayRechargeCreateBulk{config: c.config, builders: builders}
  2911. }
  2912. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  2913. // a builder and applies setFunc on it.
  2914. func (c *PayRechargeClient) MapCreateBulk(slice any, setFunc func(*PayRechargeCreate, int)) *PayRechargeCreateBulk {
  2915. rv := reflect.ValueOf(slice)
  2916. if rv.Kind() != reflect.Slice {
  2917. return &PayRechargeCreateBulk{err: fmt.Errorf("calling to PayRechargeClient.MapCreateBulk with wrong type %T, need slice", slice)}
  2918. }
  2919. builders := make([]*PayRechargeCreate, rv.Len())
  2920. for i := 0; i < rv.Len(); i++ {
  2921. builders[i] = c.Create()
  2922. setFunc(builders[i], i)
  2923. }
  2924. return &PayRechargeCreateBulk{config: c.config, builders: builders}
  2925. }
  2926. // Update returns an update builder for PayRecharge.
  2927. func (c *PayRechargeClient) Update() *PayRechargeUpdate {
  2928. mutation := newPayRechargeMutation(c.config, OpUpdate)
  2929. return &PayRechargeUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2930. }
  2931. // UpdateOne returns an update builder for the given entity.
  2932. func (c *PayRechargeClient) UpdateOne(pr *PayRecharge) *PayRechargeUpdateOne {
  2933. mutation := newPayRechargeMutation(c.config, OpUpdateOne, withPayRecharge(pr))
  2934. return &PayRechargeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2935. }
  2936. // UpdateOneID returns an update builder for the given id.
  2937. func (c *PayRechargeClient) UpdateOneID(id uint64) *PayRechargeUpdateOne {
  2938. mutation := newPayRechargeMutation(c.config, OpUpdateOne, withPayRechargeID(id))
  2939. return &PayRechargeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2940. }
  2941. // Delete returns a delete builder for PayRecharge.
  2942. func (c *PayRechargeClient) Delete() *PayRechargeDelete {
  2943. mutation := newPayRechargeMutation(c.config, OpDelete)
  2944. return &PayRechargeDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  2945. }
  2946. // DeleteOne returns a builder for deleting the given entity.
  2947. func (c *PayRechargeClient) DeleteOne(pr *PayRecharge) *PayRechargeDeleteOne {
  2948. return c.DeleteOneID(pr.ID)
  2949. }
  2950. // DeleteOneID returns a builder for deleting the given entity by its id.
  2951. func (c *PayRechargeClient) DeleteOneID(id uint64) *PayRechargeDeleteOne {
  2952. builder := c.Delete().Where(payrecharge.ID(id))
  2953. builder.mutation.id = &id
  2954. builder.mutation.op = OpDeleteOne
  2955. return &PayRechargeDeleteOne{builder}
  2956. }
  2957. // Query returns a query builder for PayRecharge.
  2958. func (c *PayRechargeClient) Query() *PayRechargeQuery {
  2959. return &PayRechargeQuery{
  2960. config: c.config,
  2961. ctx: &QueryContext{Type: TypePayRecharge},
  2962. inters: c.Interceptors(),
  2963. }
  2964. }
  2965. // Get returns a PayRecharge entity by its id.
  2966. func (c *PayRechargeClient) Get(ctx context.Context, id uint64) (*PayRecharge, error) {
  2967. return c.Query().Where(payrecharge.ID(id)).Only(ctx)
  2968. }
  2969. // GetX is like Get, but panics if an error occurs.
  2970. func (c *PayRechargeClient) GetX(ctx context.Context, id uint64) *PayRecharge {
  2971. obj, err := c.Get(ctx, id)
  2972. if err != nil {
  2973. panic(err)
  2974. }
  2975. return obj
  2976. }
  2977. // Hooks returns the client hooks.
  2978. func (c *PayRechargeClient) Hooks() []Hook {
  2979. hooks := c.hooks.PayRecharge
  2980. return append(hooks[:len(hooks):len(hooks)], payrecharge.Hooks[:]...)
  2981. }
  2982. // Interceptors returns the client interceptors.
  2983. func (c *PayRechargeClient) Interceptors() []Interceptor {
  2984. inters := c.inters.PayRecharge
  2985. return append(inters[:len(inters):len(inters)], payrecharge.Interceptors[:]...)
  2986. }
  2987. func (c *PayRechargeClient) mutate(ctx context.Context, m *PayRechargeMutation) (Value, error) {
  2988. switch m.Op() {
  2989. case OpCreate:
  2990. return (&PayRechargeCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2991. case OpUpdate:
  2992. return (&PayRechargeUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2993. case OpUpdateOne:
  2994. return (&PayRechargeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  2995. case OpDelete, OpDeleteOne:
  2996. return (&PayRechargeDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  2997. default:
  2998. return nil, fmt.Errorf("ent: unknown PayRecharge mutation op: %q", m.Op())
  2999. }
  3000. }
  3001. // ServerClient is a client for the Server schema.
  3002. type ServerClient struct {
  3003. config
  3004. }
  3005. // NewServerClient returns a client for the Server from the given config.
  3006. func NewServerClient(c config) *ServerClient {
  3007. return &ServerClient{config: c}
  3008. }
  3009. // Use adds a list of mutation hooks to the hooks stack.
  3010. // A call to `Use(f, g, h)` equals to `server.Hooks(f(g(h())))`.
  3011. func (c *ServerClient) Use(hooks ...Hook) {
  3012. c.hooks.Server = append(c.hooks.Server, hooks...)
  3013. }
  3014. // Intercept adds a list of query interceptors to the interceptors stack.
  3015. // A call to `Intercept(f, g, h)` equals to `server.Intercept(f(g(h())))`.
  3016. func (c *ServerClient) Intercept(interceptors ...Interceptor) {
  3017. c.inters.Server = append(c.inters.Server, interceptors...)
  3018. }
  3019. // Create returns a builder for creating a Server entity.
  3020. func (c *ServerClient) Create() *ServerCreate {
  3021. mutation := newServerMutation(c.config, OpCreate)
  3022. return &ServerCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3023. }
  3024. // CreateBulk returns a builder for creating a bulk of Server entities.
  3025. func (c *ServerClient) CreateBulk(builders ...*ServerCreate) *ServerCreateBulk {
  3026. return &ServerCreateBulk{config: c.config, builders: builders}
  3027. }
  3028. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  3029. // a builder and applies setFunc on it.
  3030. func (c *ServerClient) MapCreateBulk(slice any, setFunc func(*ServerCreate, int)) *ServerCreateBulk {
  3031. rv := reflect.ValueOf(slice)
  3032. if rv.Kind() != reflect.Slice {
  3033. return &ServerCreateBulk{err: fmt.Errorf("calling to ServerClient.MapCreateBulk with wrong type %T, need slice", slice)}
  3034. }
  3035. builders := make([]*ServerCreate, rv.Len())
  3036. for i := 0; i < rv.Len(); i++ {
  3037. builders[i] = c.Create()
  3038. setFunc(builders[i], i)
  3039. }
  3040. return &ServerCreateBulk{config: c.config, builders: builders}
  3041. }
  3042. // Update returns an update builder for Server.
  3043. func (c *ServerClient) Update() *ServerUpdate {
  3044. mutation := newServerMutation(c.config, OpUpdate)
  3045. return &ServerUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3046. }
  3047. // UpdateOne returns an update builder for the given entity.
  3048. func (c *ServerClient) UpdateOne(s *Server) *ServerUpdateOne {
  3049. mutation := newServerMutation(c.config, OpUpdateOne, withServer(s))
  3050. return &ServerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3051. }
  3052. // UpdateOneID returns an update builder for the given id.
  3053. func (c *ServerClient) UpdateOneID(id uint64) *ServerUpdateOne {
  3054. mutation := newServerMutation(c.config, OpUpdateOne, withServerID(id))
  3055. return &ServerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3056. }
  3057. // Delete returns a delete builder for Server.
  3058. func (c *ServerClient) Delete() *ServerDelete {
  3059. mutation := newServerMutation(c.config, OpDelete)
  3060. return &ServerDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3061. }
  3062. // DeleteOne returns a builder for deleting the given entity.
  3063. func (c *ServerClient) DeleteOne(s *Server) *ServerDeleteOne {
  3064. return c.DeleteOneID(s.ID)
  3065. }
  3066. // DeleteOneID returns a builder for deleting the given entity by its id.
  3067. func (c *ServerClient) DeleteOneID(id uint64) *ServerDeleteOne {
  3068. builder := c.Delete().Where(server.ID(id))
  3069. builder.mutation.id = &id
  3070. builder.mutation.op = OpDeleteOne
  3071. return &ServerDeleteOne{builder}
  3072. }
  3073. // Query returns a query builder for Server.
  3074. func (c *ServerClient) Query() *ServerQuery {
  3075. return &ServerQuery{
  3076. config: c.config,
  3077. ctx: &QueryContext{Type: TypeServer},
  3078. inters: c.Interceptors(),
  3079. }
  3080. }
  3081. // Get returns a Server entity by its id.
  3082. func (c *ServerClient) Get(ctx context.Context, id uint64) (*Server, error) {
  3083. return c.Query().Where(server.ID(id)).Only(ctx)
  3084. }
  3085. // GetX is like Get, but panics if an error occurs.
  3086. func (c *ServerClient) GetX(ctx context.Context, id uint64) *Server {
  3087. obj, err := c.Get(ctx, id)
  3088. if err != nil {
  3089. panic(err)
  3090. }
  3091. return obj
  3092. }
  3093. // QueryWxs queries the wxs edge of a Server.
  3094. func (c *ServerClient) QueryWxs(s *Server) *WxQuery {
  3095. query := (&WxClient{config: c.config}).Query()
  3096. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  3097. id := s.ID
  3098. step := sqlgraph.NewStep(
  3099. sqlgraph.From(server.Table, server.FieldID, id),
  3100. sqlgraph.To(wx.Table, wx.FieldID),
  3101. sqlgraph.Edge(sqlgraph.O2M, false, server.WxsTable, server.WxsColumn),
  3102. )
  3103. fromV = sqlgraph.Neighbors(s.driver.Dialect(), step)
  3104. return fromV, nil
  3105. }
  3106. return query
  3107. }
  3108. // Hooks returns the client hooks.
  3109. func (c *ServerClient) Hooks() []Hook {
  3110. hooks := c.hooks.Server
  3111. return append(hooks[:len(hooks):len(hooks)], server.Hooks[:]...)
  3112. }
  3113. // Interceptors returns the client interceptors.
  3114. func (c *ServerClient) Interceptors() []Interceptor {
  3115. inters := c.inters.Server
  3116. return append(inters[:len(inters):len(inters)], server.Interceptors[:]...)
  3117. }
  3118. func (c *ServerClient) mutate(ctx context.Context, m *ServerMutation) (Value, error) {
  3119. switch m.Op() {
  3120. case OpCreate:
  3121. return (&ServerCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3122. case OpUpdate:
  3123. return (&ServerUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3124. case OpUpdateOne:
  3125. return (&ServerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3126. case OpDelete, OpDeleteOne:
  3127. return (&ServerDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  3128. default:
  3129. return nil, fmt.Errorf("ent: unknown Server mutation op: %q", m.Op())
  3130. }
  3131. }
  3132. // SopNodeClient is a client for the SopNode schema.
  3133. type SopNodeClient struct {
  3134. config
  3135. }
  3136. // NewSopNodeClient returns a client for the SopNode from the given config.
  3137. func NewSopNodeClient(c config) *SopNodeClient {
  3138. return &SopNodeClient{config: c}
  3139. }
  3140. // Use adds a list of mutation hooks to the hooks stack.
  3141. // A call to `Use(f, g, h)` equals to `sopnode.Hooks(f(g(h())))`.
  3142. func (c *SopNodeClient) Use(hooks ...Hook) {
  3143. c.hooks.SopNode = append(c.hooks.SopNode, hooks...)
  3144. }
  3145. // Intercept adds a list of query interceptors to the interceptors stack.
  3146. // A call to `Intercept(f, g, h)` equals to `sopnode.Intercept(f(g(h())))`.
  3147. func (c *SopNodeClient) Intercept(interceptors ...Interceptor) {
  3148. c.inters.SopNode = append(c.inters.SopNode, interceptors...)
  3149. }
  3150. // Create returns a builder for creating a SopNode entity.
  3151. func (c *SopNodeClient) Create() *SopNodeCreate {
  3152. mutation := newSopNodeMutation(c.config, OpCreate)
  3153. return &SopNodeCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3154. }
  3155. // CreateBulk returns a builder for creating a bulk of SopNode entities.
  3156. func (c *SopNodeClient) CreateBulk(builders ...*SopNodeCreate) *SopNodeCreateBulk {
  3157. return &SopNodeCreateBulk{config: c.config, builders: builders}
  3158. }
  3159. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  3160. // a builder and applies setFunc on it.
  3161. func (c *SopNodeClient) MapCreateBulk(slice any, setFunc func(*SopNodeCreate, int)) *SopNodeCreateBulk {
  3162. rv := reflect.ValueOf(slice)
  3163. if rv.Kind() != reflect.Slice {
  3164. return &SopNodeCreateBulk{err: fmt.Errorf("calling to SopNodeClient.MapCreateBulk with wrong type %T, need slice", slice)}
  3165. }
  3166. builders := make([]*SopNodeCreate, rv.Len())
  3167. for i := 0; i < rv.Len(); i++ {
  3168. builders[i] = c.Create()
  3169. setFunc(builders[i], i)
  3170. }
  3171. return &SopNodeCreateBulk{config: c.config, builders: builders}
  3172. }
  3173. // Update returns an update builder for SopNode.
  3174. func (c *SopNodeClient) Update() *SopNodeUpdate {
  3175. mutation := newSopNodeMutation(c.config, OpUpdate)
  3176. return &SopNodeUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3177. }
  3178. // UpdateOne returns an update builder for the given entity.
  3179. func (c *SopNodeClient) UpdateOne(sn *SopNode) *SopNodeUpdateOne {
  3180. mutation := newSopNodeMutation(c.config, OpUpdateOne, withSopNode(sn))
  3181. return &SopNodeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3182. }
  3183. // UpdateOneID returns an update builder for the given id.
  3184. func (c *SopNodeClient) UpdateOneID(id uint64) *SopNodeUpdateOne {
  3185. mutation := newSopNodeMutation(c.config, OpUpdateOne, withSopNodeID(id))
  3186. return &SopNodeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3187. }
  3188. // Delete returns a delete builder for SopNode.
  3189. func (c *SopNodeClient) Delete() *SopNodeDelete {
  3190. mutation := newSopNodeMutation(c.config, OpDelete)
  3191. return &SopNodeDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3192. }
  3193. // DeleteOne returns a builder for deleting the given entity.
  3194. func (c *SopNodeClient) DeleteOne(sn *SopNode) *SopNodeDeleteOne {
  3195. return c.DeleteOneID(sn.ID)
  3196. }
  3197. // DeleteOneID returns a builder for deleting the given entity by its id.
  3198. func (c *SopNodeClient) DeleteOneID(id uint64) *SopNodeDeleteOne {
  3199. builder := c.Delete().Where(sopnode.ID(id))
  3200. builder.mutation.id = &id
  3201. builder.mutation.op = OpDeleteOne
  3202. return &SopNodeDeleteOne{builder}
  3203. }
  3204. // Query returns a query builder for SopNode.
  3205. func (c *SopNodeClient) Query() *SopNodeQuery {
  3206. return &SopNodeQuery{
  3207. config: c.config,
  3208. ctx: &QueryContext{Type: TypeSopNode},
  3209. inters: c.Interceptors(),
  3210. }
  3211. }
  3212. // Get returns a SopNode entity by its id.
  3213. func (c *SopNodeClient) Get(ctx context.Context, id uint64) (*SopNode, error) {
  3214. return c.Query().Where(sopnode.ID(id)).Only(ctx)
  3215. }
  3216. // GetX is like Get, but panics if an error occurs.
  3217. func (c *SopNodeClient) GetX(ctx context.Context, id uint64) *SopNode {
  3218. obj, err := c.Get(ctx, id)
  3219. if err != nil {
  3220. panic(err)
  3221. }
  3222. return obj
  3223. }
  3224. // QuerySopStage queries the sop_stage edge of a SopNode.
  3225. func (c *SopNodeClient) QuerySopStage(sn *SopNode) *SopStageQuery {
  3226. query := (&SopStageClient{config: c.config}).Query()
  3227. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  3228. id := sn.ID
  3229. step := sqlgraph.NewStep(
  3230. sqlgraph.From(sopnode.Table, sopnode.FieldID, id),
  3231. sqlgraph.To(sopstage.Table, sopstage.FieldID),
  3232. sqlgraph.Edge(sqlgraph.M2O, true, sopnode.SopStageTable, sopnode.SopStageColumn),
  3233. )
  3234. fromV = sqlgraph.Neighbors(sn.driver.Dialect(), step)
  3235. return fromV, nil
  3236. }
  3237. return query
  3238. }
  3239. // QueryNodeMessages queries the node_messages edge of a SopNode.
  3240. func (c *SopNodeClient) QueryNodeMessages(sn *SopNode) *MessageRecordsQuery {
  3241. query := (&MessageRecordsClient{config: c.config}).Query()
  3242. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  3243. id := sn.ID
  3244. step := sqlgraph.NewStep(
  3245. sqlgraph.From(sopnode.Table, sopnode.FieldID, id),
  3246. sqlgraph.To(messagerecords.Table, messagerecords.FieldID),
  3247. sqlgraph.Edge(sqlgraph.O2M, false, sopnode.NodeMessagesTable, sopnode.NodeMessagesColumn),
  3248. )
  3249. fromV = sqlgraph.Neighbors(sn.driver.Dialect(), step)
  3250. return fromV, nil
  3251. }
  3252. return query
  3253. }
  3254. // Hooks returns the client hooks.
  3255. func (c *SopNodeClient) Hooks() []Hook {
  3256. hooks := c.hooks.SopNode
  3257. return append(hooks[:len(hooks):len(hooks)], sopnode.Hooks[:]...)
  3258. }
  3259. // Interceptors returns the client interceptors.
  3260. func (c *SopNodeClient) Interceptors() []Interceptor {
  3261. inters := c.inters.SopNode
  3262. return append(inters[:len(inters):len(inters)], sopnode.Interceptors[:]...)
  3263. }
  3264. func (c *SopNodeClient) mutate(ctx context.Context, m *SopNodeMutation) (Value, error) {
  3265. switch m.Op() {
  3266. case OpCreate:
  3267. return (&SopNodeCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3268. case OpUpdate:
  3269. return (&SopNodeUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3270. case OpUpdateOne:
  3271. return (&SopNodeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3272. case OpDelete, OpDeleteOne:
  3273. return (&SopNodeDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  3274. default:
  3275. return nil, fmt.Errorf("ent: unknown SopNode mutation op: %q", m.Op())
  3276. }
  3277. }
  3278. // SopStageClient is a client for the SopStage schema.
  3279. type SopStageClient struct {
  3280. config
  3281. }
  3282. // NewSopStageClient returns a client for the SopStage from the given config.
  3283. func NewSopStageClient(c config) *SopStageClient {
  3284. return &SopStageClient{config: c}
  3285. }
  3286. // Use adds a list of mutation hooks to the hooks stack.
  3287. // A call to `Use(f, g, h)` equals to `sopstage.Hooks(f(g(h())))`.
  3288. func (c *SopStageClient) Use(hooks ...Hook) {
  3289. c.hooks.SopStage = append(c.hooks.SopStage, hooks...)
  3290. }
  3291. // Intercept adds a list of query interceptors to the interceptors stack.
  3292. // A call to `Intercept(f, g, h)` equals to `sopstage.Intercept(f(g(h())))`.
  3293. func (c *SopStageClient) Intercept(interceptors ...Interceptor) {
  3294. c.inters.SopStage = append(c.inters.SopStage, interceptors...)
  3295. }
  3296. // Create returns a builder for creating a SopStage entity.
  3297. func (c *SopStageClient) Create() *SopStageCreate {
  3298. mutation := newSopStageMutation(c.config, OpCreate)
  3299. return &SopStageCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3300. }
  3301. // CreateBulk returns a builder for creating a bulk of SopStage entities.
  3302. func (c *SopStageClient) CreateBulk(builders ...*SopStageCreate) *SopStageCreateBulk {
  3303. return &SopStageCreateBulk{config: c.config, builders: builders}
  3304. }
  3305. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  3306. // a builder and applies setFunc on it.
  3307. func (c *SopStageClient) MapCreateBulk(slice any, setFunc func(*SopStageCreate, int)) *SopStageCreateBulk {
  3308. rv := reflect.ValueOf(slice)
  3309. if rv.Kind() != reflect.Slice {
  3310. return &SopStageCreateBulk{err: fmt.Errorf("calling to SopStageClient.MapCreateBulk with wrong type %T, need slice", slice)}
  3311. }
  3312. builders := make([]*SopStageCreate, rv.Len())
  3313. for i := 0; i < rv.Len(); i++ {
  3314. builders[i] = c.Create()
  3315. setFunc(builders[i], i)
  3316. }
  3317. return &SopStageCreateBulk{config: c.config, builders: builders}
  3318. }
  3319. // Update returns an update builder for SopStage.
  3320. func (c *SopStageClient) Update() *SopStageUpdate {
  3321. mutation := newSopStageMutation(c.config, OpUpdate)
  3322. return &SopStageUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3323. }
  3324. // UpdateOne returns an update builder for the given entity.
  3325. func (c *SopStageClient) UpdateOne(ss *SopStage) *SopStageUpdateOne {
  3326. mutation := newSopStageMutation(c.config, OpUpdateOne, withSopStage(ss))
  3327. return &SopStageUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3328. }
  3329. // UpdateOneID returns an update builder for the given id.
  3330. func (c *SopStageClient) UpdateOneID(id uint64) *SopStageUpdateOne {
  3331. mutation := newSopStageMutation(c.config, OpUpdateOne, withSopStageID(id))
  3332. return &SopStageUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3333. }
  3334. // Delete returns a delete builder for SopStage.
  3335. func (c *SopStageClient) Delete() *SopStageDelete {
  3336. mutation := newSopStageMutation(c.config, OpDelete)
  3337. return &SopStageDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3338. }
  3339. // DeleteOne returns a builder for deleting the given entity.
  3340. func (c *SopStageClient) DeleteOne(ss *SopStage) *SopStageDeleteOne {
  3341. return c.DeleteOneID(ss.ID)
  3342. }
  3343. // DeleteOneID returns a builder for deleting the given entity by its id.
  3344. func (c *SopStageClient) DeleteOneID(id uint64) *SopStageDeleteOne {
  3345. builder := c.Delete().Where(sopstage.ID(id))
  3346. builder.mutation.id = &id
  3347. builder.mutation.op = OpDeleteOne
  3348. return &SopStageDeleteOne{builder}
  3349. }
  3350. // Query returns a query builder for SopStage.
  3351. func (c *SopStageClient) Query() *SopStageQuery {
  3352. return &SopStageQuery{
  3353. config: c.config,
  3354. ctx: &QueryContext{Type: TypeSopStage},
  3355. inters: c.Interceptors(),
  3356. }
  3357. }
  3358. // Get returns a SopStage entity by its id.
  3359. func (c *SopStageClient) Get(ctx context.Context, id uint64) (*SopStage, error) {
  3360. return c.Query().Where(sopstage.ID(id)).Only(ctx)
  3361. }
  3362. // GetX is like Get, but panics if an error occurs.
  3363. func (c *SopStageClient) GetX(ctx context.Context, id uint64) *SopStage {
  3364. obj, err := c.Get(ctx, id)
  3365. if err != nil {
  3366. panic(err)
  3367. }
  3368. return obj
  3369. }
  3370. // QuerySopTask queries the sop_task edge of a SopStage.
  3371. func (c *SopStageClient) QuerySopTask(ss *SopStage) *SopTaskQuery {
  3372. query := (&SopTaskClient{config: c.config}).Query()
  3373. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  3374. id := ss.ID
  3375. step := sqlgraph.NewStep(
  3376. sqlgraph.From(sopstage.Table, sopstage.FieldID, id),
  3377. sqlgraph.To(soptask.Table, soptask.FieldID),
  3378. sqlgraph.Edge(sqlgraph.M2O, true, sopstage.SopTaskTable, sopstage.SopTaskColumn),
  3379. )
  3380. fromV = sqlgraph.Neighbors(ss.driver.Dialect(), step)
  3381. return fromV, nil
  3382. }
  3383. return query
  3384. }
  3385. // QueryStageNodes queries the stage_nodes edge of a SopStage.
  3386. func (c *SopStageClient) QueryStageNodes(ss *SopStage) *SopNodeQuery {
  3387. query := (&SopNodeClient{config: c.config}).Query()
  3388. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  3389. id := ss.ID
  3390. step := sqlgraph.NewStep(
  3391. sqlgraph.From(sopstage.Table, sopstage.FieldID, id),
  3392. sqlgraph.To(sopnode.Table, sopnode.FieldID),
  3393. sqlgraph.Edge(sqlgraph.O2M, false, sopstage.StageNodesTable, sopstage.StageNodesColumn),
  3394. )
  3395. fromV = sqlgraph.Neighbors(ss.driver.Dialect(), step)
  3396. return fromV, nil
  3397. }
  3398. return query
  3399. }
  3400. // QueryStageMessages queries the stage_messages edge of a SopStage.
  3401. func (c *SopStageClient) QueryStageMessages(ss *SopStage) *MessageRecordsQuery {
  3402. query := (&MessageRecordsClient{config: c.config}).Query()
  3403. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  3404. id := ss.ID
  3405. step := sqlgraph.NewStep(
  3406. sqlgraph.From(sopstage.Table, sopstage.FieldID, id),
  3407. sqlgraph.To(messagerecords.Table, messagerecords.FieldID),
  3408. sqlgraph.Edge(sqlgraph.O2M, false, sopstage.StageMessagesTable, sopstage.StageMessagesColumn),
  3409. )
  3410. fromV = sqlgraph.Neighbors(ss.driver.Dialect(), step)
  3411. return fromV, nil
  3412. }
  3413. return query
  3414. }
  3415. // Hooks returns the client hooks.
  3416. func (c *SopStageClient) Hooks() []Hook {
  3417. hooks := c.hooks.SopStage
  3418. return append(hooks[:len(hooks):len(hooks)], sopstage.Hooks[:]...)
  3419. }
  3420. // Interceptors returns the client interceptors.
  3421. func (c *SopStageClient) Interceptors() []Interceptor {
  3422. inters := c.inters.SopStage
  3423. return append(inters[:len(inters):len(inters)], sopstage.Interceptors[:]...)
  3424. }
  3425. func (c *SopStageClient) mutate(ctx context.Context, m *SopStageMutation) (Value, error) {
  3426. switch m.Op() {
  3427. case OpCreate:
  3428. return (&SopStageCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3429. case OpUpdate:
  3430. return (&SopStageUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3431. case OpUpdateOne:
  3432. return (&SopStageUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3433. case OpDelete, OpDeleteOne:
  3434. return (&SopStageDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  3435. default:
  3436. return nil, fmt.Errorf("ent: unknown SopStage mutation op: %q", m.Op())
  3437. }
  3438. }
  3439. // SopTaskClient is a client for the SopTask schema.
  3440. type SopTaskClient struct {
  3441. config
  3442. }
  3443. // NewSopTaskClient returns a client for the SopTask from the given config.
  3444. func NewSopTaskClient(c config) *SopTaskClient {
  3445. return &SopTaskClient{config: c}
  3446. }
  3447. // Use adds a list of mutation hooks to the hooks stack.
  3448. // A call to `Use(f, g, h)` equals to `soptask.Hooks(f(g(h())))`.
  3449. func (c *SopTaskClient) Use(hooks ...Hook) {
  3450. c.hooks.SopTask = append(c.hooks.SopTask, hooks...)
  3451. }
  3452. // Intercept adds a list of query interceptors to the interceptors stack.
  3453. // A call to `Intercept(f, g, h)` equals to `soptask.Intercept(f(g(h())))`.
  3454. func (c *SopTaskClient) Intercept(interceptors ...Interceptor) {
  3455. c.inters.SopTask = append(c.inters.SopTask, interceptors...)
  3456. }
  3457. // Create returns a builder for creating a SopTask entity.
  3458. func (c *SopTaskClient) Create() *SopTaskCreate {
  3459. mutation := newSopTaskMutation(c.config, OpCreate)
  3460. return &SopTaskCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3461. }
  3462. // CreateBulk returns a builder for creating a bulk of SopTask entities.
  3463. func (c *SopTaskClient) CreateBulk(builders ...*SopTaskCreate) *SopTaskCreateBulk {
  3464. return &SopTaskCreateBulk{config: c.config, builders: builders}
  3465. }
  3466. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  3467. // a builder and applies setFunc on it.
  3468. func (c *SopTaskClient) MapCreateBulk(slice any, setFunc func(*SopTaskCreate, int)) *SopTaskCreateBulk {
  3469. rv := reflect.ValueOf(slice)
  3470. if rv.Kind() != reflect.Slice {
  3471. return &SopTaskCreateBulk{err: fmt.Errorf("calling to SopTaskClient.MapCreateBulk with wrong type %T, need slice", slice)}
  3472. }
  3473. builders := make([]*SopTaskCreate, rv.Len())
  3474. for i := 0; i < rv.Len(); i++ {
  3475. builders[i] = c.Create()
  3476. setFunc(builders[i], i)
  3477. }
  3478. return &SopTaskCreateBulk{config: c.config, builders: builders}
  3479. }
  3480. // Update returns an update builder for SopTask.
  3481. func (c *SopTaskClient) Update() *SopTaskUpdate {
  3482. mutation := newSopTaskMutation(c.config, OpUpdate)
  3483. return &SopTaskUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3484. }
  3485. // UpdateOne returns an update builder for the given entity.
  3486. func (c *SopTaskClient) UpdateOne(st *SopTask) *SopTaskUpdateOne {
  3487. mutation := newSopTaskMutation(c.config, OpUpdateOne, withSopTask(st))
  3488. return &SopTaskUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3489. }
  3490. // UpdateOneID returns an update builder for the given id.
  3491. func (c *SopTaskClient) UpdateOneID(id uint64) *SopTaskUpdateOne {
  3492. mutation := newSopTaskMutation(c.config, OpUpdateOne, withSopTaskID(id))
  3493. return &SopTaskUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3494. }
  3495. // Delete returns a delete builder for SopTask.
  3496. func (c *SopTaskClient) Delete() *SopTaskDelete {
  3497. mutation := newSopTaskMutation(c.config, OpDelete)
  3498. return &SopTaskDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3499. }
  3500. // DeleteOne returns a builder for deleting the given entity.
  3501. func (c *SopTaskClient) DeleteOne(st *SopTask) *SopTaskDeleteOne {
  3502. return c.DeleteOneID(st.ID)
  3503. }
  3504. // DeleteOneID returns a builder for deleting the given entity by its id.
  3505. func (c *SopTaskClient) DeleteOneID(id uint64) *SopTaskDeleteOne {
  3506. builder := c.Delete().Where(soptask.ID(id))
  3507. builder.mutation.id = &id
  3508. builder.mutation.op = OpDeleteOne
  3509. return &SopTaskDeleteOne{builder}
  3510. }
  3511. // Query returns a query builder for SopTask.
  3512. func (c *SopTaskClient) Query() *SopTaskQuery {
  3513. return &SopTaskQuery{
  3514. config: c.config,
  3515. ctx: &QueryContext{Type: TypeSopTask},
  3516. inters: c.Interceptors(),
  3517. }
  3518. }
  3519. // Get returns a SopTask entity by its id.
  3520. func (c *SopTaskClient) Get(ctx context.Context, id uint64) (*SopTask, error) {
  3521. return c.Query().Where(soptask.ID(id)).Only(ctx)
  3522. }
  3523. // GetX is like Get, but panics if an error occurs.
  3524. func (c *SopTaskClient) GetX(ctx context.Context, id uint64) *SopTask {
  3525. obj, err := c.Get(ctx, id)
  3526. if err != nil {
  3527. panic(err)
  3528. }
  3529. return obj
  3530. }
  3531. // QueryTaskStages queries the task_stages edge of a SopTask.
  3532. func (c *SopTaskClient) QueryTaskStages(st *SopTask) *SopStageQuery {
  3533. query := (&SopStageClient{config: c.config}).Query()
  3534. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  3535. id := st.ID
  3536. step := sqlgraph.NewStep(
  3537. sqlgraph.From(soptask.Table, soptask.FieldID, id),
  3538. sqlgraph.To(sopstage.Table, sopstage.FieldID),
  3539. sqlgraph.Edge(sqlgraph.O2M, false, soptask.TaskStagesTable, soptask.TaskStagesColumn),
  3540. )
  3541. fromV = sqlgraph.Neighbors(st.driver.Dialect(), step)
  3542. return fromV, nil
  3543. }
  3544. return query
  3545. }
  3546. // Hooks returns the client hooks.
  3547. func (c *SopTaskClient) Hooks() []Hook {
  3548. hooks := c.hooks.SopTask
  3549. return append(hooks[:len(hooks):len(hooks)], soptask.Hooks[:]...)
  3550. }
  3551. // Interceptors returns the client interceptors.
  3552. func (c *SopTaskClient) Interceptors() []Interceptor {
  3553. inters := c.inters.SopTask
  3554. return append(inters[:len(inters):len(inters)], soptask.Interceptors[:]...)
  3555. }
  3556. func (c *SopTaskClient) mutate(ctx context.Context, m *SopTaskMutation) (Value, error) {
  3557. switch m.Op() {
  3558. case OpCreate:
  3559. return (&SopTaskCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3560. case OpUpdate:
  3561. return (&SopTaskUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3562. case OpUpdateOne:
  3563. return (&SopTaskUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3564. case OpDelete, OpDeleteOne:
  3565. return (&SopTaskDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  3566. default:
  3567. return nil, fmt.Errorf("ent: unknown SopTask mutation op: %q", m.Op())
  3568. }
  3569. }
  3570. // TokenClient is a client for the Token schema.
  3571. type TokenClient struct {
  3572. config
  3573. }
  3574. // NewTokenClient returns a client for the Token from the given config.
  3575. func NewTokenClient(c config) *TokenClient {
  3576. return &TokenClient{config: c}
  3577. }
  3578. // Use adds a list of mutation hooks to the hooks stack.
  3579. // A call to `Use(f, g, h)` equals to `token.Hooks(f(g(h())))`.
  3580. func (c *TokenClient) Use(hooks ...Hook) {
  3581. c.hooks.Token = append(c.hooks.Token, hooks...)
  3582. }
  3583. // Intercept adds a list of query interceptors to the interceptors stack.
  3584. // A call to `Intercept(f, g, h)` equals to `token.Intercept(f(g(h())))`.
  3585. func (c *TokenClient) Intercept(interceptors ...Interceptor) {
  3586. c.inters.Token = append(c.inters.Token, interceptors...)
  3587. }
  3588. // Create returns a builder for creating a Token entity.
  3589. func (c *TokenClient) Create() *TokenCreate {
  3590. mutation := newTokenMutation(c.config, OpCreate)
  3591. return &TokenCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3592. }
  3593. // CreateBulk returns a builder for creating a bulk of Token entities.
  3594. func (c *TokenClient) CreateBulk(builders ...*TokenCreate) *TokenCreateBulk {
  3595. return &TokenCreateBulk{config: c.config, builders: builders}
  3596. }
  3597. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  3598. // a builder and applies setFunc on it.
  3599. func (c *TokenClient) MapCreateBulk(slice any, setFunc func(*TokenCreate, int)) *TokenCreateBulk {
  3600. rv := reflect.ValueOf(slice)
  3601. if rv.Kind() != reflect.Slice {
  3602. return &TokenCreateBulk{err: fmt.Errorf("calling to TokenClient.MapCreateBulk with wrong type %T, need slice", slice)}
  3603. }
  3604. builders := make([]*TokenCreate, rv.Len())
  3605. for i := 0; i < rv.Len(); i++ {
  3606. builders[i] = c.Create()
  3607. setFunc(builders[i], i)
  3608. }
  3609. return &TokenCreateBulk{config: c.config, builders: builders}
  3610. }
  3611. // Update returns an update builder for Token.
  3612. func (c *TokenClient) Update() *TokenUpdate {
  3613. mutation := newTokenMutation(c.config, OpUpdate)
  3614. return &TokenUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3615. }
  3616. // UpdateOne returns an update builder for the given entity.
  3617. func (c *TokenClient) UpdateOne(t *Token) *TokenUpdateOne {
  3618. mutation := newTokenMutation(c.config, OpUpdateOne, withToken(t))
  3619. return &TokenUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3620. }
  3621. // UpdateOneID returns an update builder for the given id.
  3622. func (c *TokenClient) UpdateOneID(id uint64) *TokenUpdateOne {
  3623. mutation := newTokenMutation(c.config, OpUpdateOne, withTokenID(id))
  3624. return &TokenUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3625. }
  3626. // Delete returns a delete builder for Token.
  3627. func (c *TokenClient) Delete() *TokenDelete {
  3628. mutation := newTokenMutation(c.config, OpDelete)
  3629. return &TokenDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3630. }
  3631. // DeleteOne returns a builder for deleting the given entity.
  3632. func (c *TokenClient) DeleteOne(t *Token) *TokenDeleteOne {
  3633. return c.DeleteOneID(t.ID)
  3634. }
  3635. // DeleteOneID returns a builder for deleting the given entity by its id.
  3636. func (c *TokenClient) DeleteOneID(id uint64) *TokenDeleteOne {
  3637. builder := c.Delete().Where(token.ID(id))
  3638. builder.mutation.id = &id
  3639. builder.mutation.op = OpDeleteOne
  3640. return &TokenDeleteOne{builder}
  3641. }
  3642. // Query returns a query builder for Token.
  3643. func (c *TokenClient) Query() *TokenQuery {
  3644. return &TokenQuery{
  3645. config: c.config,
  3646. ctx: &QueryContext{Type: TypeToken},
  3647. inters: c.Interceptors(),
  3648. }
  3649. }
  3650. // Get returns a Token entity by its id.
  3651. func (c *TokenClient) Get(ctx context.Context, id uint64) (*Token, error) {
  3652. return c.Query().Where(token.ID(id)).Only(ctx)
  3653. }
  3654. // GetX is like Get, but panics if an error occurs.
  3655. func (c *TokenClient) GetX(ctx context.Context, id uint64) *Token {
  3656. obj, err := c.Get(ctx, id)
  3657. if err != nil {
  3658. panic(err)
  3659. }
  3660. return obj
  3661. }
  3662. // QueryAgent queries the agent edge of a Token.
  3663. func (c *TokenClient) QueryAgent(t *Token) *AgentQuery {
  3664. query := (&AgentClient{config: c.config}).Query()
  3665. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  3666. id := t.ID
  3667. step := sqlgraph.NewStep(
  3668. sqlgraph.From(token.Table, token.FieldID, id),
  3669. sqlgraph.To(agent.Table, agent.FieldID),
  3670. sqlgraph.Edge(sqlgraph.M2O, true, token.AgentTable, token.AgentColumn),
  3671. )
  3672. fromV = sqlgraph.Neighbors(t.driver.Dialect(), step)
  3673. return fromV, nil
  3674. }
  3675. return query
  3676. }
  3677. // Hooks returns the client hooks.
  3678. func (c *TokenClient) Hooks() []Hook {
  3679. hooks := c.hooks.Token
  3680. return append(hooks[:len(hooks):len(hooks)], token.Hooks[:]...)
  3681. }
  3682. // Interceptors returns the client interceptors.
  3683. func (c *TokenClient) Interceptors() []Interceptor {
  3684. inters := c.inters.Token
  3685. return append(inters[:len(inters):len(inters)], token.Interceptors[:]...)
  3686. }
  3687. func (c *TokenClient) mutate(ctx context.Context, m *TokenMutation) (Value, error) {
  3688. switch m.Op() {
  3689. case OpCreate:
  3690. return (&TokenCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3691. case OpUpdate:
  3692. return (&TokenUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3693. case OpUpdateOne:
  3694. return (&TokenUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3695. case OpDelete, OpDeleteOne:
  3696. return (&TokenDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  3697. default:
  3698. return nil, fmt.Errorf("ent: unknown Token mutation op: %q", m.Op())
  3699. }
  3700. }
  3701. // TutorialClient is a client for the Tutorial schema.
  3702. type TutorialClient struct {
  3703. config
  3704. }
  3705. // NewTutorialClient returns a client for the Tutorial from the given config.
  3706. func NewTutorialClient(c config) *TutorialClient {
  3707. return &TutorialClient{config: c}
  3708. }
  3709. // Use adds a list of mutation hooks to the hooks stack.
  3710. // A call to `Use(f, g, h)` equals to `tutorial.Hooks(f(g(h())))`.
  3711. func (c *TutorialClient) Use(hooks ...Hook) {
  3712. c.hooks.Tutorial = append(c.hooks.Tutorial, hooks...)
  3713. }
  3714. // Intercept adds a list of query interceptors to the interceptors stack.
  3715. // A call to `Intercept(f, g, h)` equals to `tutorial.Intercept(f(g(h())))`.
  3716. func (c *TutorialClient) Intercept(interceptors ...Interceptor) {
  3717. c.inters.Tutorial = append(c.inters.Tutorial, interceptors...)
  3718. }
  3719. // Create returns a builder for creating a Tutorial entity.
  3720. func (c *TutorialClient) Create() *TutorialCreate {
  3721. mutation := newTutorialMutation(c.config, OpCreate)
  3722. return &TutorialCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3723. }
  3724. // CreateBulk returns a builder for creating a bulk of Tutorial entities.
  3725. func (c *TutorialClient) CreateBulk(builders ...*TutorialCreate) *TutorialCreateBulk {
  3726. return &TutorialCreateBulk{config: c.config, builders: builders}
  3727. }
  3728. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  3729. // a builder and applies setFunc on it.
  3730. func (c *TutorialClient) MapCreateBulk(slice any, setFunc func(*TutorialCreate, int)) *TutorialCreateBulk {
  3731. rv := reflect.ValueOf(slice)
  3732. if rv.Kind() != reflect.Slice {
  3733. return &TutorialCreateBulk{err: fmt.Errorf("calling to TutorialClient.MapCreateBulk with wrong type %T, need slice", slice)}
  3734. }
  3735. builders := make([]*TutorialCreate, rv.Len())
  3736. for i := 0; i < rv.Len(); i++ {
  3737. builders[i] = c.Create()
  3738. setFunc(builders[i], i)
  3739. }
  3740. return &TutorialCreateBulk{config: c.config, builders: builders}
  3741. }
  3742. // Update returns an update builder for Tutorial.
  3743. func (c *TutorialClient) Update() *TutorialUpdate {
  3744. mutation := newTutorialMutation(c.config, OpUpdate)
  3745. return &TutorialUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3746. }
  3747. // UpdateOne returns an update builder for the given entity.
  3748. func (c *TutorialClient) UpdateOne(t *Tutorial) *TutorialUpdateOne {
  3749. mutation := newTutorialMutation(c.config, OpUpdateOne, withTutorial(t))
  3750. return &TutorialUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3751. }
  3752. // UpdateOneID returns an update builder for the given id.
  3753. func (c *TutorialClient) UpdateOneID(id uint64) *TutorialUpdateOne {
  3754. mutation := newTutorialMutation(c.config, OpUpdateOne, withTutorialID(id))
  3755. return &TutorialUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3756. }
  3757. // Delete returns a delete builder for Tutorial.
  3758. func (c *TutorialClient) Delete() *TutorialDelete {
  3759. mutation := newTutorialMutation(c.config, OpDelete)
  3760. return &TutorialDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3761. }
  3762. // DeleteOne returns a builder for deleting the given entity.
  3763. func (c *TutorialClient) DeleteOne(t *Tutorial) *TutorialDeleteOne {
  3764. return c.DeleteOneID(t.ID)
  3765. }
  3766. // DeleteOneID returns a builder for deleting the given entity by its id.
  3767. func (c *TutorialClient) DeleteOneID(id uint64) *TutorialDeleteOne {
  3768. builder := c.Delete().Where(tutorial.ID(id))
  3769. builder.mutation.id = &id
  3770. builder.mutation.op = OpDeleteOne
  3771. return &TutorialDeleteOne{builder}
  3772. }
  3773. // Query returns a query builder for Tutorial.
  3774. func (c *TutorialClient) Query() *TutorialQuery {
  3775. return &TutorialQuery{
  3776. config: c.config,
  3777. ctx: &QueryContext{Type: TypeTutorial},
  3778. inters: c.Interceptors(),
  3779. }
  3780. }
  3781. // Get returns a Tutorial entity by its id.
  3782. func (c *TutorialClient) Get(ctx context.Context, id uint64) (*Tutorial, error) {
  3783. return c.Query().Where(tutorial.ID(id)).Only(ctx)
  3784. }
  3785. // GetX is like Get, but panics if an error occurs.
  3786. func (c *TutorialClient) GetX(ctx context.Context, id uint64) *Tutorial {
  3787. obj, err := c.Get(ctx, id)
  3788. if err != nil {
  3789. panic(err)
  3790. }
  3791. return obj
  3792. }
  3793. // QueryEmployee queries the employee edge of a Tutorial.
  3794. func (c *TutorialClient) QueryEmployee(t *Tutorial) *EmployeeQuery {
  3795. query := (&EmployeeClient{config: c.config}).Query()
  3796. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  3797. id := t.ID
  3798. step := sqlgraph.NewStep(
  3799. sqlgraph.From(tutorial.Table, tutorial.FieldID, id),
  3800. sqlgraph.To(employee.Table, employee.FieldID),
  3801. sqlgraph.Edge(sqlgraph.M2O, true, tutorial.EmployeeTable, tutorial.EmployeeColumn),
  3802. )
  3803. fromV = sqlgraph.Neighbors(t.driver.Dialect(), step)
  3804. return fromV, nil
  3805. }
  3806. return query
  3807. }
  3808. // Hooks returns the client hooks.
  3809. func (c *TutorialClient) Hooks() []Hook {
  3810. hooks := c.hooks.Tutorial
  3811. return append(hooks[:len(hooks):len(hooks)], tutorial.Hooks[:]...)
  3812. }
  3813. // Interceptors returns the client interceptors.
  3814. func (c *TutorialClient) Interceptors() []Interceptor {
  3815. inters := c.inters.Tutorial
  3816. return append(inters[:len(inters):len(inters)], tutorial.Interceptors[:]...)
  3817. }
  3818. func (c *TutorialClient) mutate(ctx context.Context, m *TutorialMutation) (Value, error) {
  3819. switch m.Op() {
  3820. case OpCreate:
  3821. return (&TutorialCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3822. case OpUpdate:
  3823. return (&TutorialUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3824. case OpUpdateOne:
  3825. return (&TutorialUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3826. case OpDelete, OpDeleteOne:
  3827. return (&TutorialDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  3828. default:
  3829. return nil, fmt.Errorf("ent: unknown Tutorial mutation op: %q", m.Op())
  3830. }
  3831. }
  3832. // UsageDetailClient is a client for the UsageDetail schema.
  3833. type UsageDetailClient struct {
  3834. config
  3835. }
  3836. // NewUsageDetailClient returns a client for the UsageDetail from the given config.
  3837. func NewUsageDetailClient(c config) *UsageDetailClient {
  3838. return &UsageDetailClient{config: c}
  3839. }
  3840. // Use adds a list of mutation hooks to the hooks stack.
  3841. // A call to `Use(f, g, h)` equals to `usagedetail.Hooks(f(g(h())))`.
  3842. func (c *UsageDetailClient) Use(hooks ...Hook) {
  3843. c.hooks.UsageDetail = append(c.hooks.UsageDetail, hooks...)
  3844. }
  3845. // Intercept adds a list of query interceptors to the interceptors stack.
  3846. // A call to `Intercept(f, g, h)` equals to `usagedetail.Intercept(f(g(h())))`.
  3847. func (c *UsageDetailClient) Intercept(interceptors ...Interceptor) {
  3848. c.inters.UsageDetail = append(c.inters.UsageDetail, interceptors...)
  3849. }
  3850. // Create returns a builder for creating a UsageDetail entity.
  3851. func (c *UsageDetailClient) Create() *UsageDetailCreate {
  3852. mutation := newUsageDetailMutation(c.config, OpCreate)
  3853. return &UsageDetailCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3854. }
  3855. // CreateBulk returns a builder for creating a bulk of UsageDetail entities.
  3856. func (c *UsageDetailClient) CreateBulk(builders ...*UsageDetailCreate) *UsageDetailCreateBulk {
  3857. return &UsageDetailCreateBulk{config: c.config, builders: builders}
  3858. }
  3859. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  3860. // a builder and applies setFunc on it.
  3861. func (c *UsageDetailClient) MapCreateBulk(slice any, setFunc func(*UsageDetailCreate, int)) *UsageDetailCreateBulk {
  3862. rv := reflect.ValueOf(slice)
  3863. if rv.Kind() != reflect.Slice {
  3864. return &UsageDetailCreateBulk{err: fmt.Errorf("calling to UsageDetailClient.MapCreateBulk with wrong type %T, need slice", slice)}
  3865. }
  3866. builders := make([]*UsageDetailCreate, rv.Len())
  3867. for i := 0; i < rv.Len(); i++ {
  3868. builders[i] = c.Create()
  3869. setFunc(builders[i], i)
  3870. }
  3871. return &UsageDetailCreateBulk{config: c.config, builders: builders}
  3872. }
  3873. // Update returns an update builder for UsageDetail.
  3874. func (c *UsageDetailClient) Update() *UsageDetailUpdate {
  3875. mutation := newUsageDetailMutation(c.config, OpUpdate)
  3876. return &UsageDetailUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3877. }
  3878. // UpdateOne returns an update builder for the given entity.
  3879. func (c *UsageDetailClient) UpdateOne(ud *UsageDetail) *UsageDetailUpdateOne {
  3880. mutation := newUsageDetailMutation(c.config, OpUpdateOne, withUsageDetail(ud))
  3881. return &UsageDetailUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3882. }
  3883. // UpdateOneID returns an update builder for the given id.
  3884. func (c *UsageDetailClient) UpdateOneID(id uint64) *UsageDetailUpdateOne {
  3885. mutation := newUsageDetailMutation(c.config, OpUpdateOne, withUsageDetailID(id))
  3886. return &UsageDetailUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3887. }
  3888. // Delete returns a delete builder for UsageDetail.
  3889. func (c *UsageDetailClient) Delete() *UsageDetailDelete {
  3890. mutation := newUsageDetailMutation(c.config, OpDelete)
  3891. return &UsageDetailDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3892. }
  3893. // DeleteOne returns a builder for deleting the given entity.
  3894. func (c *UsageDetailClient) DeleteOne(ud *UsageDetail) *UsageDetailDeleteOne {
  3895. return c.DeleteOneID(ud.ID)
  3896. }
  3897. // DeleteOneID returns a builder for deleting the given entity by its id.
  3898. func (c *UsageDetailClient) DeleteOneID(id uint64) *UsageDetailDeleteOne {
  3899. builder := c.Delete().Where(usagedetail.ID(id))
  3900. builder.mutation.id = &id
  3901. builder.mutation.op = OpDeleteOne
  3902. return &UsageDetailDeleteOne{builder}
  3903. }
  3904. // Query returns a query builder for UsageDetail.
  3905. func (c *UsageDetailClient) Query() *UsageDetailQuery {
  3906. return &UsageDetailQuery{
  3907. config: c.config,
  3908. ctx: &QueryContext{Type: TypeUsageDetail},
  3909. inters: c.Interceptors(),
  3910. }
  3911. }
  3912. // Get returns a UsageDetail entity by its id.
  3913. func (c *UsageDetailClient) Get(ctx context.Context, id uint64) (*UsageDetail, error) {
  3914. return c.Query().Where(usagedetail.ID(id)).Only(ctx)
  3915. }
  3916. // GetX is like Get, but panics if an error occurs.
  3917. func (c *UsageDetailClient) GetX(ctx context.Context, id uint64) *UsageDetail {
  3918. obj, err := c.Get(ctx, id)
  3919. if err != nil {
  3920. panic(err)
  3921. }
  3922. return obj
  3923. }
  3924. // Hooks returns the client hooks.
  3925. func (c *UsageDetailClient) Hooks() []Hook {
  3926. return c.hooks.UsageDetail
  3927. }
  3928. // Interceptors returns the client interceptors.
  3929. func (c *UsageDetailClient) Interceptors() []Interceptor {
  3930. return c.inters.UsageDetail
  3931. }
  3932. func (c *UsageDetailClient) mutate(ctx context.Context, m *UsageDetailMutation) (Value, error) {
  3933. switch m.Op() {
  3934. case OpCreate:
  3935. return (&UsageDetailCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3936. case OpUpdate:
  3937. return (&UsageDetailUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3938. case OpUpdateOne:
  3939. return (&UsageDetailUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  3940. case OpDelete, OpDeleteOne:
  3941. return (&UsageDetailDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  3942. default:
  3943. return nil, fmt.Errorf("ent: unknown UsageDetail mutation op: %q", m.Op())
  3944. }
  3945. }
  3946. // UsageStatisticDayClient is a client for the UsageStatisticDay schema.
  3947. type UsageStatisticDayClient struct {
  3948. config
  3949. }
  3950. // NewUsageStatisticDayClient returns a client for the UsageStatisticDay from the given config.
  3951. func NewUsageStatisticDayClient(c config) *UsageStatisticDayClient {
  3952. return &UsageStatisticDayClient{config: c}
  3953. }
  3954. // Use adds a list of mutation hooks to the hooks stack.
  3955. // A call to `Use(f, g, h)` equals to `usagestatisticday.Hooks(f(g(h())))`.
  3956. func (c *UsageStatisticDayClient) Use(hooks ...Hook) {
  3957. c.hooks.UsageStatisticDay = append(c.hooks.UsageStatisticDay, hooks...)
  3958. }
  3959. // Intercept adds a list of query interceptors to the interceptors stack.
  3960. // A call to `Intercept(f, g, h)` equals to `usagestatisticday.Intercept(f(g(h())))`.
  3961. func (c *UsageStatisticDayClient) Intercept(interceptors ...Interceptor) {
  3962. c.inters.UsageStatisticDay = append(c.inters.UsageStatisticDay, interceptors...)
  3963. }
  3964. // Create returns a builder for creating a UsageStatisticDay entity.
  3965. func (c *UsageStatisticDayClient) Create() *UsageStatisticDayCreate {
  3966. mutation := newUsageStatisticDayMutation(c.config, OpCreate)
  3967. return &UsageStatisticDayCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3968. }
  3969. // CreateBulk returns a builder for creating a bulk of UsageStatisticDay entities.
  3970. func (c *UsageStatisticDayClient) CreateBulk(builders ...*UsageStatisticDayCreate) *UsageStatisticDayCreateBulk {
  3971. return &UsageStatisticDayCreateBulk{config: c.config, builders: builders}
  3972. }
  3973. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  3974. // a builder and applies setFunc on it.
  3975. func (c *UsageStatisticDayClient) MapCreateBulk(slice any, setFunc func(*UsageStatisticDayCreate, int)) *UsageStatisticDayCreateBulk {
  3976. rv := reflect.ValueOf(slice)
  3977. if rv.Kind() != reflect.Slice {
  3978. return &UsageStatisticDayCreateBulk{err: fmt.Errorf("calling to UsageStatisticDayClient.MapCreateBulk with wrong type %T, need slice", slice)}
  3979. }
  3980. builders := make([]*UsageStatisticDayCreate, rv.Len())
  3981. for i := 0; i < rv.Len(); i++ {
  3982. builders[i] = c.Create()
  3983. setFunc(builders[i], i)
  3984. }
  3985. return &UsageStatisticDayCreateBulk{config: c.config, builders: builders}
  3986. }
  3987. // Update returns an update builder for UsageStatisticDay.
  3988. func (c *UsageStatisticDayClient) Update() *UsageStatisticDayUpdate {
  3989. mutation := newUsageStatisticDayMutation(c.config, OpUpdate)
  3990. return &UsageStatisticDayUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3991. }
  3992. // UpdateOne returns an update builder for the given entity.
  3993. func (c *UsageStatisticDayClient) UpdateOne(usd *UsageStatisticDay) *UsageStatisticDayUpdateOne {
  3994. mutation := newUsageStatisticDayMutation(c.config, OpUpdateOne, withUsageStatisticDay(usd))
  3995. return &UsageStatisticDayUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  3996. }
  3997. // UpdateOneID returns an update builder for the given id.
  3998. func (c *UsageStatisticDayClient) UpdateOneID(id uint64) *UsageStatisticDayUpdateOne {
  3999. mutation := newUsageStatisticDayMutation(c.config, OpUpdateOne, withUsageStatisticDayID(id))
  4000. return &UsageStatisticDayUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4001. }
  4002. // Delete returns a delete builder for UsageStatisticDay.
  4003. func (c *UsageStatisticDayClient) Delete() *UsageStatisticDayDelete {
  4004. mutation := newUsageStatisticDayMutation(c.config, OpDelete)
  4005. return &UsageStatisticDayDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4006. }
  4007. // DeleteOne returns a builder for deleting the given entity.
  4008. func (c *UsageStatisticDayClient) DeleteOne(usd *UsageStatisticDay) *UsageStatisticDayDeleteOne {
  4009. return c.DeleteOneID(usd.ID)
  4010. }
  4011. // DeleteOneID returns a builder for deleting the given entity by its id.
  4012. func (c *UsageStatisticDayClient) DeleteOneID(id uint64) *UsageStatisticDayDeleteOne {
  4013. builder := c.Delete().Where(usagestatisticday.ID(id))
  4014. builder.mutation.id = &id
  4015. builder.mutation.op = OpDeleteOne
  4016. return &UsageStatisticDayDeleteOne{builder}
  4017. }
  4018. // Query returns a query builder for UsageStatisticDay.
  4019. func (c *UsageStatisticDayClient) Query() *UsageStatisticDayQuery {
  4020. return &UsageStatisticDayQuery{
  4021. config: c.config,
  4022. ctx: &QueryContext{Type: TypeUsageStatisticDay},
  4023. inters: c.Interceptors(),
  4024. }
  4025. }
  4026. // Get returns a UsageStatisticDay entity by its id.
  4027. func (c *UsageStatisticDayClient) Get(ctx context.Context, id uint64) (*UsageStatisticDay, error) {
  4028. return c.Query().Where(usagestatisticday.ID(id)).Only(ctx)
  4029. }
  4030. // GetX is like Get, but panics if an error occurs.
  4031. func (c *UsageStatisticDayClient) GetX(ctx context.Context, id uint64) *UsageStatisticDay {
  4032. obj, err := c.Get(ctx, id)
  4033. if err != nil {
  4034. panic(err)
  4035. }
  4036. return obj
  4037. }
  4038. // Hooks returns the client hooks.
  4039. func (c *UsageStatisticDayClient) Hooks() []Hook {
  4040. hooks := c.hooks.UsageStatisticDay
  4041. return append(hooks[:len(hooks):len(hooks)], usagestatisticday.Hooks[:]...)
  4042. }
  4043. // Interceptors returns the client interceptors.
  4044. func (c *UsageStatisticDayClient) Interceptors() []Interceptor {
  4045. inters := c.inters.UsageStatisticDay
  4046. return append(inters[:len(inters):len(inters)], usagestatisticday.Interceptors[:]...)
  4047. }
  4048. func (c *UsageStatisticDayClient) mutate(ctx context.Context, m *UsageStatisticDayMutation) (Value, error) {
  4049. switch m.Op() {
  4050. case OpCreate:
  4051. return (&UsageStatisticDayCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4052. case OpUpdate:
  4053. return (&UsageStatisticDayUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4054. case OpUpdateOne:
  4055. return (&UsageStatisticDayUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4056. case OpDelete, OpDeleteOne:
  4057. return (&UsageStatisticDayDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  4058. default:
  4059. return nil, fmt.Errorf("ent: unknown UsageStatisticDay mutation op: %q", m.Op())
  4060. }
  4061. }
  4062. // UsageStatisticHourClient is a client for the UsageStatisticHour schema.
  4063. type UsageStatisticHourClient struct {
  4064. config
  4065. }
  4066. // NewUsageStatisticHourClient returns a client for the UsageStatisticHour from the given config.
  4067. func NewUsageStatisticHourClient(c config) *UsageStatisticHourClient {
  4068. return &UsageStatisticHourClient{config: c}
  4069. }
  4070. // Use adds a list of mutation hooks to the hooks stack.
  4071. // A call to `Use(f, g, h)` equals to `usagestatistichour.Hooks(f(g(h())))`.
  4072. func (c *UsageStatisticHourClient) Use(hooks ...Hook) {
  4073. c.hooks.UsageStatisticHour = append(c.hooks.UsageStatisticHour, hooks...)
  4074. }
  4075. // Intercept adds a list of query interceptors to the interceptors stack.
  4076. // A call to `Intercept(f, g, h)` equals to `usagestatistichour.Intercept(f(g(h())))`.
  4077. func (c *UsageStatisticHourClient) Intercept(interceptors ...Interceptor) {
  4078. c.inters.UsageStatisticHour = append(c.inters.UsageStatisticHour, interceptors...)
  4079. }
  4080. // Create returns a builder for creating a UsageStatisticHour entity.
  4081. func (c *UsageStatisticHourClient) Create() *UsageStatisticHourCreate {
  4082. mutation := newUsageStatisticHourMutation(c.config, OpCreate)
  4083. return &UsageStatisticHourCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4084. }
  4085. // CreateBulk returns a builder for creating a bulk of UsageStatisticHour entities.
  4086. func (c *UsageStatisticHourClient) CreateBulk(builders ...*UsageStatisticHourCreate) *UsageStatisticHourCreateBulk {
  4087. return &UsageStatisticHourCreateBulk{config: c.config, builders: builders}
  4088. }
  4089. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  4090. // a builder and applies setFunc on it.
  4091. func (c *UsageStatisticHourClient) MapCreateBulk(slice any, setFunc func(*UsageStatisticHourCreate, int)) *UsageStatisticHourCreateBulk {
  4092. rv := reflect.ValueOf(slice)
  4093. if rv.Kind() != reflect.Slice {
  4094. return &UsageStatisticHourCreateBulk{err: fmt.Errorf("calling to UsageStatisticHourClient.MapCreateBulk with wrong type %T, need slice", slice)}
  4095. }
  4096. builders := make([]*UsageStatisticHourCreate, rv.Len())
  4097. for i := 0; i < rv.Len(); i++ {
  4098. builders[i] = c.Create()
  4099. setFunc(builders[i], i)
  4100. }
  4101. return &UsageStatisticHourCreateBulk{config: c.config, builders: builders}
  4102. }
  4103. // Update returns an update builder for UsageStatisticHour.
  4104. func (c *UsageStatisticHourClient) Update() *UsageStatisticHourUpdate {
  4105. mutation := newUsageStatisticHourMutation(c.config, OpUpdate)
  4106. return &UsageStatisticHourUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4107. }
  4108. // UpdateOne returns an update builder for the given entity.
  4109. func (c *UsageStatisticHourClient) UpdateOne(ush *UsageStatisticHour) *UsageStatisticHourUpdateOne {
  4110. mutation := newUsageStatisticHourMutation(c.config, OpUpdateOne, withUsageStatisticHour(ush))
  4111. return &UsageStatisticHourUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4112. }
  4113. // UpdateOneID returns an update builder for the given id.
  4114. func (c *UsageStatisticHourClient) UpdateOneID(id uint64) *UsageStatisticHourUpdateOne {
  4115. mutation := newUsageStatisticHourMutation(c.config, OpUpdateOne, withUsageStatisticHourID(id))
  4116. return &UsageStatisticHourUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4117. }
  4118. // Delete returns a delete builder for UsageStatisticHour.
  4119. func (c *UsageStatisticHourClient) Delete() *UsageStatisticHourDelete {
  4120. mutation := newUsageStatisticHourMutation(c.config, OpDelete)
  4121. return &UsageStatisticHourDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4122. }
  4123. // DeleteOne returns a builder for deleting the given entity.
  4124. func (c *UsageStatisticHourClient) DeleteOne(ush *UsageStatisticHour) *UsageStatisticHourDeleteOne {
  4125. return c.DeleteOneID(ush.ID)
  4126. }
  4127. // DeleteOneID returns a builder for deleting the given entity by its id.
  4128. func (c *UsageStatisticHourClient) DeleteOneID(id uint64) *UsageStatisticHourDeleteOne {
  4129. builder := c.Delete().Where(usagestatistichour.ID(id))
  4130. builder.mutation.id = &id
  4131. builder.mutation.op = OpDeleteOne
  4132. return &UsageStatisticHourDeleteOne{builder}
  4133. }
  4134. // Query returns a query builder for UsageStatisticHour.
  4135. func (c *UsageStatisticHourClient) Query() *UsageStatisticHourQuery {
  4136. return &UsageStatisticHourQuery{
  4137. config: c.config,
  4138. ctx: &QueryContext{Type: TypeUsageStatisticHour},
  4139. inters: c.Interceptors(),
  4140. }
  4141. }
  4142. // Get returns a UsageStatisticHour entity by its id.
  4143. func (c *UsageStatisticHourClient) Get(ctx context.Context, id uint64) (*UsageStatisticHour, error) {
  4144. return c.Query().Where(usagestatistichour.ID(id)).Only(ctx)
  4145. }
  4146. // GetX is like Get, but panics if an error occurs.
  4147. func (c *UsageStatisticHourClient) GetX(ctx context.Context, id uint64) *UsageStatisticHour {
  4148. obj, err := c.Get(ctx, id)
  4149. if err != nil {
  4150. panic(err)
  4151. }
  4152. return obj
  4153. }
  4154. // Hooks returns the client hooks.
  4155. func (c *UsageStatisticHourClient) Hooks() []Hook {
  4156. hooks := c.hooks.UsageStatisticHour
  4157. return append(hooks[:len(hooks):len(hooks)], usagestatistichour.Hooks[:]...)
  4158. }
  4159. // Interceptors returns the client interceptors.
  4160. func (c *UsageStatisticHourClient) Interceptors() []Interceptor {
  4161. inters := c.inters.UsageStatisticHour
  4162. return append(inters[:len(inters):len(inters)], usagestatistichour.Interceptors[:]...)
  4163. }
  4164. func (c *UsageStatisticHourClient) mutate(ctx context.Context, m *UsageStatisticHourMutation) (Value, error) {
  4165. switch m.Op() {
  4166. case OpCreate:
  4167. return (&UsageStatisticHourCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4168. case OpUpdate:
  4169. return (&UsageStatisticHourUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4170. case OpUpdateOne:
  4171. return (&UsageStatisticHourUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4172. case OpDelete, OpDeleteOne:
  4173. return (&UsageStatisticHourDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  4174. default:
  4175. return nil, fmt.Errorf("ent: unknown UsageStatisticHour mutation op: %q", m.Op())
  4176. }
  4177. }
  4178. // UsageStatisticMonthClient is a client for the UsageStatisticMonth schema.
  4179. type UsageStatisticMonthClient struct {
  4180. config
  4181. }
  4182. // NewUsageStatisticMonthClient returns a client for the UsageStatisticMonth from the given config.
  4183. func NewUsageStatisticMonthClient(c config) *UsageStatisticMonthClient {
  4184. return &UsageStatisticMonthClient{config: c}
  4185. }
  4186. // Use adds a list of mutation hooks to the hooks stack.
  4187. // A call to `Use(f, g, h)` equals to `usagestatisticmonth.Hooks(f(g(h())))`.
  4188. func (c *UsageStatisticMonthClient) Use(hooks ...Hook) {
  4189. c.hooks.UsageStatisticMonth = append(c.hooks.UsageStatisticMonth, hooks...)
  4190. }
  4191. // Intercept adds a list of query interceptors to the interceptors stack.
  4192. // A call to `Intercept(f, g, h)` equals to `usagestatisticmonth.Intercept(f(g(h())))`.
  4193. func (c *UsageStatisticMonthClient) Intercept(interceptors ...Interceptor) {
  4194. c.inters.UsageStatisticMonth = append(c.inters.UsageStatisticMonth, interceptors...)
  4195. }
  4196. // Create returns a builder for creating a UsageStatisticMonth entity.
  4197. func (c *UsageStatisticMonthClient) Create() *UsageStatisticMonthCreate {
  4198. mutation := newUsageStatisticMonthMutation(c.config, OpCreate)
  4199. return &UsageStatisticMonthCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4200. }
  4201. // CreateBulk returns a builder for creating a bulk of UsageStatisticMonth entities.
  4202. func (c *UsageStatisticMonthClient) CreateBulk(builders ...*UsageStatisticMonthCreate) *UsageStatisticMonthCreateBulk {
  4203. return &UsageStatisticMonthCreateBulk{config: c.config, builders: builders}
  4204. }
  4205. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  4206. // a builder and applies setFunc on it.
  4207. func (c *UsageStatisticMonthClient) MapCreateBulk(slice any, setFunc func(*UsageStatisticMonthCreate, int)) *UsageStatisticMonthCreateBulk {
  4208. rv := reflect.ValueOf(slice)
  4209. if rv.Kind() != reflect.Slice {
  4210. return &UsageStatisticMonthCreateBulk{err: fmt.Errorf("calling to UsageStatisticMonthClient.MapCreateBulk with wrong type %T, need slice", slice)}
  4211. }
  4212. builders := make([]*UsageStatisticMonthCreate, rv.Len())
  4213. for i := 0; i < rv.Len(); i++ {
  4214. builders[i] = c.Create()
  4215. setFunc(builders[i], i)
  4216. }
  4217. return &UsageStatisticMonthCreateBulk{config: c.config, builders: builders}
  4218. }
  4219. // Update returns an update builder for UsageStatisticMonth.
  4220. func (c *UsageStatisticMonthClient) Update() *UsageStatisticMonthUpdate {
  4221. mutation := newUsageStatisticMonthMutation(c.config, OpUpdate)
  4222. return &UsageStatisticMonthUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4223. }
  4224. // UpdateOne returns an update builder for the given entity.
  4225. func (c *UsageStatisticMonthClient) UpdateOne(usm *UsageStatisticMonth) *UsageStatisticMonthUpdateOne {
  4226. mutation := newUsageStatisticMonthMutation(c.config, OpUpdateOne, withUsageStatisticMonth(usm))
  4227. return &UsageStatisticMonthUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4228. }
  4229. // UpdateOneID returns an update builder for the given id.
  4230. func (c *UsageStatisticMonthClient) UpdateOneID(id uint64) *UsageStatisticMonthUpdateOne {
  4231. mutation := newUsageStatisticMonthMutation(c.config, OpUpdateOne, withUsageStatisticMonthID(id))
  4232. return &UsageStatisticMonthUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4233. }
  4234. // Delete returns a delete builder for UsageStatisticMonth.
  4235. func (c *UsageStatisticMonthClient) Delete() *UsageStatisticMonthDelete {
  4236. mutation := newUsageStatisticMonthMutation(c.config, OpDelete)
  4237. return &UsageStatisticMonthDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4238. }
  4239. // DeleteOne returns a builder for deleting the given entity.
  4240. func (c *UsageStatisticMonthClient) DeleteOne(usm *UsageStatisticMonth) *UsageStatisticMonthDeleteOne {
  4241. return c.DeleteOneID(usm.ID)
  4242. }
  4243. // DeleteOneID returns a builder for deleting the given entity by its id.
  4244. func (c *UsageStatisticMonthClient) DeleteOneID(id uint64) *UsageStatisticMonthDeleteOne {
  4245. builder := c.Delete().Where(usagestatisticmonth.ID(id))
  4246. builder.mutation.id = &id
  4247. builder.mutation.op = OpDeleteOne
  4248. return &UsageStatisticMonthDeleteOne{builder}
  4249. }
  4250. // Query returns a query builder for UsageStatisticMonth.
  4251. func (c *UsageStatisticMonthClient) Query() *UsageStatisticMonthQuery {
  4252. return &UsageStatisticMonthQuery{
  4253. config: c.config,
  4254. ctx: &QueryContext{Type: TypeUsageStatisticMonth},
  4255. inters: c.Interceptors(),
  4256. }
  4257. }
  4258. // Get returns a UsageStatisticMonth entity by its id.
  4259. func (c *UsageStatisticMonthClient) Get(ctx context.Context, id uint64) (*UsageStatisticMonth, error) {
  4260. return c.Query().Where(usagestatisticmonth.ID(id)).Only(ctx)
  4261. }
  4262. // GetX is like Get, but panics if an error occurs.
  4263. func (c *UsageStatisticMonthClient) GetX(ctx context.Context, id uint64) *UsageStatisticMonth {
  4264. obj, err := c.Get(ctx, id)
  4265. if err != nil {
  4266. panic(err)
  4267. }
  4268. return obj
  4269. }
  4270. // Hooks returns the client hooks.
  4271. func (c *UsageStatisticMonthClient) Hooks() []Hook {
  4272. hooks := c.hooks.UsageStatisticMonth
  4273. return append(hooks[:len(hooks):len(hooks)], usagestatisticmonth.Hooks[:]...)
  4274. }
  4275. // Interceptors returns the client interceptors.
  4276. func (c *UsageStatisticMonthClient) Interceptors() []Interceptor {
  4277. inters := c.inters.UsageStatisticMonth
  4278. return append(inters[:len(inters):len(inters)], usagestatisticmonth.Interceptors[:]...)
  4279. }
  4280. func (c *UsageStatisticMonthClient) mutate(ctx context.Context, m *UsageStatisticMonthMutation) (Value, error) {
  4281. switch m.Op() {
  4282. case OpCreate:
  4283. return (&UsageStatisticMonthCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4284. case OpUpdate:
  4285. return (&UsageStatisticMonthUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4286. case OpUpdateOne:
  4287. return (&UsageStatisticMonthUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4288. case OpDelete, OpDeleteOne:
  4289. return (&UsageStatisticMonthDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  4290. default:
  4291. return nil, fmt.Errorf("ent: unknown UsageStatisticMonth mutation op: %q", m.Op())
  4292. }
  4293. }
  4294. // UsageTotalClient is a client for the UsageTotal schema.
  4295. type UsageTotalClient struct {
  4296. config
  4297. }
  4298. // NewUsageTotalClient returns a client for the UsageTotal from the given config.
  4299. func NewUsageTotalClient(c config) *UsageTotalClient {
  4300. return &UsageTotalClient{config: c}
  4301. }
  4302. // Use adds a list of mutation hooks to the hooks stack.
  4303. // A call to `Use(f, g, h)` equals to `usagetotal.Hooks(f(g(h())))`.
  4304. func (c *UsageTotalClient) Use(hooks ...Hook) {
  4305. c.hooks.UsageTotal = append(c.hooks.UsageTotal, hooks...)
  4306. }
  4307. // Intercept adds a list of query interceptors to the interceptors stack.
  4308. // A call to `Intercept(f, g, h)` equals to `usagetotal.Intercept(f(g(h())))`.
  4309. func (c *UsageTotalClient) Intercept(interceptors ...Interceptor) {
  4310. c.inters.UsageTotal = append(c.inters.UsageTotal, interceptors...)
  4311. }
  4312. // Create returns a builder for creating a UsageTotal entity.
  4313. func (c *UsageTotalClient) Create() *UsageTotalCreate {
  4314. mutation := newUsageTotalMutation(c.config, OpCreate)
  4315. return &UsageTotalCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4316. }
  4317. // CreateBulk returns a builder for creating a bulk of UsageTotal entities.
  4318. func (c *UsageTotalClient) CreateBulk(builders ...*UsageTotalCreate) *UsageTotalCreateBulk {
  4319. return &UsageTotalCreateBulk{config: c.config, builders: builders}
  4320. }
  4321. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  4322. // a builder and applies setFunc on it.
  4323. func (c *UsageTotalClient) MapCreateBulk(slice any, setFunc func(*UsageTotalCreate, int)) *UsageTotalCreateBulk {
  4324. rv := reflect.ValueOf(slice)
  4325. if rv.Kind() != reflect.Slice {
  4326. return &UsageTotalCreateBulk{err: fmt.Errorf("calling to UsageTotalClient.MapCreateBulk with wrong type %T, need slice", slice)}
  4327. }
  4328. builders := make([]*UsageTotalCreate, rv.Len())
  4329. for i := 0; i < rv.Len(); i++ {
  4330. builders[i] = c.Create()
  4331. setFunc(builders[i], i)
  4332. }
  4333. return &UsageTotalCreateBulk{config: c.config, builders: builders}
  4334. }
  4335. // Update returns an update builder for UsageTotal.
  4336. func (c *UsageTotalClient) Update() *UsageTotalUpdate {
  4337. mutation := newUsageTotalMutation(c.config, OpUpdate)
  4338. return &UsageTotalUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4339. }
  4340. // UpdateOne returns an update builder for the given entity.
  4341. func (c *UsageTotalClient) UpdateOne(ut *UsageTotal) *UsageTotalUpdateOne {
  4342. mutation := newUsageTotalMutation(c.config, OpUpdateOne, withUsageTotal(ut))
  4343. return &UsageTotalUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4344. }
  4345. // UpdateOneID returns an update builder for the given id.
  4346. func (c *UsageTotalClient) UpdateOneID(id uint64) *UsageTotalUpdateOne {
  4347. mutation := newUsageTotalMutation(c.config, OpUpdateOne, withUsageTotalID(id))
  4348. return &UsageTotalUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4349. }
  4350. // Delete returns a delete builder for UsageTotal.
  4351. func (c *UsageTotalClient) Delete() *UsageTotalDelete {
  4352. mutation := newUsageTotalMutation(c.config, OpDelete)
  4353. return &UsageTotalDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4354. }
  4355. // DeleteOne returns a builder for deleting the given entity.
  4356. func (c *UsageTotalClient) DeleteOne(ut *UsageTotal) *UsageTotalDeleteOne {
  4357. return c.DeleteOneID(ut.ID)
  4358. }
  4359. // DeleteOneID returns a builder for deleting the given entity by its id.
  4360. func (c *UsageTotalClient) DeleteOneID(id uint64) *UsageTotalDeleteOne {
  4361. builder := c.Delete().Where(usagetotal.ID(id))
  4362. builder.mutation.id = &id
  4363. builder.mutation.op = OpDeleteOne
  4364. return &UsageTotalDeleteOne{builder}
  4365. }
  4366. // Query returns a query builder for UsageTotal.
  4367. func (c *UsageTotalClient) Query() *UsageTotalQuery {
  4368. return &UsageTotalQuery{
  4369. config: c.config,
  4370. ctx: &QueryContext{Type: TypeUsageTotal},
  4371. inters: c.Interceptors(),
  4372. }
  4373. }
  4374. // Get returns a UsageTotal entity by its id.
  4375. func (c *UsageTotalClient) Get(ctx context.Context, id uint64) (*UsageTotal, error) {
  4376. return c.Query().Where(usagetotal.ID(id)).Only(ctx)
  4377. }
  4378. // GetX is like Get, but panics if an error occurs.
  4379. func (c *UsageTotalClient) GetX(ctx context.Context, id uint64) *UsageTotal {
  4380. obj, err := c.Get(ctx, id)
  4381. if err != nil {
  4382. panic(err)
  4383. }
  4384. return obj
  4385. }
  4386. // Hooks returns the client hooks.
  4387. func (c *UsageTotalClient) Hooks() []Hook {
  4388. return c.hooks.UsageTotal
  4389. }
  4390. // Interceptors returns the client interceptors.
  4391. func (c *UsageTotalClient) Interceptors() []Interceptor {
  4392. return c.inters.UsageTotal
  4393. }
  4394. func (c *UsageTotalClient) mutate(ctx context.Context, m *UsageTotalMutation) (Value, error) {
  4395. switch m.Op() {
  4396. case OpCreate:
  4397. return (&UsageTotalCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4398. case OpUpdate:
  4399. return (&UsageTotalUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4400. case OpUpdateOne:
  4401. return (&UsageTotalUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4402. case OpDelete, OpDeleteOne:
  4403. return (&UsageTotalDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  4404. default:
  4405. return nil, fmt.Errorf("ent: unknown UsageTotal mutation op: %q", m.Op())
  4406. }
  4407. }
  4408. // WorkExperienceClient is a client for the WorkExperience schema.
  4409. type WorkExperienceClient struct {
  4410. config
  4411. }
  4412. // NewWorkExperienceClient returns a client for the WorkExperience from the given config.
  4413. func NewWorkExperienceClient(c config) *WorkExperienceClient {
  4414. return &WorkExperienceClient{config: c}
  4415. }
  4416. // Use adds a list of mutation hooks to the hooks stack.
  4417. // A call to `Use(f, g, h)` equals to `workexperience.Hooks(f(g(h())))`.
  4418. func (c *WorkExperienceClient) Use(hooks ...Hook) {
  4419. c.hooks.WorkExperience = append(c.hooks.WorkExperience, hooks...)
  4420. }
  4421. // Intercept adds a list of query interceptors to the interceptors stack.
  4422. // A call to `Intercept(f, g, h)` equals to `workexperience.Intercept(f(g(h())))`.
  4423. func (c *WorkExperienceClient) Intercept(interceptors ...Interceptor) {
  4424. c.inters.WorkExperience = append(c.inters.WorkExperience, interceptors...)
  4425. }
  4426. // Create returns a builder for creating a WorkExperience entity.
  4427. func (c *WorkExperienceClient) Create() *WorkExperienceCreate {
  4428. mutation := newWorkExperienceMutation(c.config, OpCreate)
  4429. return &WorkExperienceCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4430. }
  4431. // CreateBulk returns a builder for creating a bulk of WorkExperience entities.
  4432. func (c *WorkExperienceClient) CreateBulk(builders ...*WorkExperienceCreate) *WorkExperienceCreateBulk {
  4433. return &WorkExperienceCreateBulk{config: c.config, builders: builders}
  4434. }
  4435. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  4436. // a builder and applies setFunc on it.
  4437. func (c *WorkExperienceClient) MapCreateBulk(slice any, setFunc func(*WorkExperienceCreate, int)) *WorkExperienceCreateBulk {
  4438. rv := reflect.ValueOf(slice)
  4439. if rv.Kind() != reflect.Slice {
  4440. return &WorkExperienceCreateBulk{err: fmt.Errorf("calling to WorkExperienceClient.MapCreateBulk with wrong type %T, need slice", slice)}
  4441. }
  4442. builders := make([]*WorkExperienceCreate, rv.Len())
  4443. for i := 0; i < rv.Len(); i++ {
  4444. builders[i] = c.Create()
  4445. setFunc(builders[i], i)
  4446. }
  4447. return &WorkExperienceCreateBulk{config: c.config, builders: builders}
  4448. }
  4449. // Update returns an update builder for WorkExperience.
  4450. func (c *WorkExperienceClient) Update() *WorkExperienceUpdate {
  4451. mutation := newWorkExperienceMutation(c.config, OpUpdate)
  4452. return &WorkExperienceUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4453. }
  4454. // UpdateOne returns an update builder for the given entity.
  4455. func (c *WorkExperienceClient) UpdateOne(we *WorkExperience) *WorkExperienceUpdateOne {
  4456. mutation := newWorkExperienceMutation(c.config, OpUpdateOne, withWorkExperience(we))
  4457. return &WorkExperienceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4458. }
  4459. // UpdateOneID returns an update builder for the given id.
  4460. func (c *WorkExperienceClient) UpdateOneID(id uint64) *WorkExperienceUpdateOne {
  4461. mutation := newWorkExperienceMutation(c.config, OpUpdateOne, withWorkExperienceID(id))
  4462. return &WorkExperienceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4463. }
  4464. // Delete returns a delete builder for WorkExperience.
  4465. func (c *WorkExperienceClient) Delete() *WorkExperienceDelete {
  4466. mutation := newWorkExperienceMutation(c.config, OpDelete)
  4467. return &WorkExperienceDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4468. }
  4469. // DeleteOne returns a builder for deleting the given entity.
  4470. func (c *WorkExperienceClient) DeleteOne(we *WorkExperience) *WorkExperienceDeleteOne {
  4471. return c.DeleteOneID(we.ID)
  4472. }
  4473. // DeleteOneID returns a builder for deleting the given entity by its id.
  4474. func (c *WorkExperienceClient) DeleteOneID(id uint64) *WorkExperienceDeleteOne {
  4475. builder := c.Delete().Where(workexperience.ID(id))
  4476. builder.mutation.id = &id
  4477. builder.mutation.op = OpDeleteOne
  4478. return &WorkExperienceDeleteOne{builder}
  4479. }
  4480. // Query returns a query builder for WorkExperience.
  4481. func (c *WorkExperienceClient) Query() *WorkExperienceQuery {
  4482. return &WorkExperienceQuery{
  4483. config: c.config,
  4484. ctx: &QueryContext{Type: TypeWorkExperience},
  4485. inters: c.Interceptors(),
  4486. }
  4487. }
  4488. // Get returns a WorkExperience entity by its id.
  4489. func (c *WorkExperienceClient) Get(ctx context.Context, id uint64) (*WorkExperience, error) {
  4490. return c.Query().Where(workexperience.ID(id)).Only(ctx)
  4491. }
  4492. // GetX is like Get, but panics if an error occurs.
  4493. func (c *WorkExperienceClient) GetX(ctx context.Context, id uint64) *WorkExperience {
  4494. obj, err := c.Get(ctx, id)
  4495. if err != nil {
  4496. panic(err)
  4497. }
  4498. return obj
  4499. }
  4500. // QueryEmployee queries the employee edge of a WorkExperience.
  4501. func (c *WorkExperienceClient) QueryEmployee(we *WorkExperience) *EmployeeQuery {
  4502. query := (&EmployeeClient{config: c.config}).Query()
  4503. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  4504. id := we.ID
  4505. step := sqlgraph.NewStep(
  4506. sqlgraph.From(workexperience.Table, workexperience.FieldID, id),
  4507. sqlgraph.To(employee.Table, employee.FieldID),
  4508. sqlgraph.Edge(sqlgraph.M2O, true, workexperience.EmployeeTable, workexperience.EmployeeColumn),
  4509. )
  4510. fromV = sqlgraph.Neighbors(we.driver.Dialect(), step)
  4511. return fromV, nil
  4512. }
  4513. return query
  4514. }
  4515. // Hooks returns the client hooks.
  4516. func (c *WorkExperienceClient) Hooks() []Hook {
  4517. hooks := c.hooks.WorkExperience
  4518. return append(hooks[:len(hooks):len(hooks)], workexperience.Hooks[:]...)
  4519. }
  4520. // Interceptors returns the client interceptors.
  4521. func (c *WorkExperienceClient) Interceptors() []Interceptor {
  4522. inters := c.inters.WorkExperience
  4523. return append(inters[:len(inters):len(inters)], workexperience.Interceptors[:]...)
  4524. }
  4525. func (c *WorkExperienceClient) mutate(ctx context.Context, m *WorkExperienceMutation) (Value, error) {
  4526. switch m.Op() {
  4527. case OpCreate:
  4528. return (&WorkExperienceCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4529. case OpUpdate:
  4530. return (&WorkExperienceUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4531. case OpUpdateOne:
  4532. return (&WorkExperienceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4533. case OpDelete, OpDeleteOne:
  4534. return (&WorkExperienceDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  4535. default:
  4536. return nil, fmt.Errorf("ent: unknown WorkExperience mutation op: %q", m.Op())
  4537. }
  4538. }
  4539. // WpChatroomClient is a client for the WpChatroom schema.
  4540. type WpChatroomClient struct {
  4541. config
  4542. }
  4543. // NewWpChatroomClient returns a client for the WpChatroom from the given config.
  4544. func NewWpChatroomClient(c config) *WpChatroomClient {
  4545. return &WpChatroomClient{config: c}
  4546. }
  4547. // Use adds a list of mutation hooks to the hooks stack.
  4548. // A call to `Use(f, g, h)` equals to `wpchatroom.Hooks(f(g(h())))`.
  4549. func (c *WpChatroomClient) Use(hooks ...Hook) {
  4550. c.hooks.WpChatroom = append(c.hooks.WpChatroom, hooks...)
  4551. }
  4552. // Intercept adds a list of query interceptors to the interceptors stack.
  4553. // A call to `Intercept(f, g, h)` equals to `wpchatroom.Intercept(f(g(h())))`.
  4554. func (c *WpChatroomClient) Intercept(interceptors ...Interceptor) {
  4555. c.inters.WpChatroom = append(c.inters.WpChatroom, interceptors...)
  4556. }
  4557. // Create returns a builder for creating a WpChatroom entity.
  4558. func (c *WpChatroomClient) Create() *WpChatroomCreate {
  4559. mutation := newWpChatroomMutation(c.config, OpCreate)
  4560. return &WpChatroomCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4561. }
  4562. // CreateBulk returns a builder for creating a bulk of WpChatroom entities.
  4563. func (c *WpChatroomClient) CreateBulk(builders ...*WpChatroomCreate) *WpChatroomCreateBulk {
  4564. return &WpChatroomCreateBulk{config: c.config, builders: builders}
  4565. }
  4566. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  4567. // a builder and applies setFunc on it.
  4568. func (c *WpChatroomClient) MapCreateBulk(slice any, setFunc func(*WpChatroomCreate, int)) *WpChatroomCreateBulk {
  4569. rv := reflect.ValueOf(slice)
  4570. if rv.Kind() != reflect.Slice {
  4571. return &WpChatroomCreateBulk{err: fmt.Errorf("calling to WpChatroomClient.MapCreateBulk with wrong type %T, need slice", slice)}
  4572. }
  4573. builders := make([]*WpChatroomCreate, rv.Len())
  4574. for i := 0; i < rv.Len(); i++ {
  4575. builders[i] = c.Create()
  4576. setFunc(builders[i], i)
  4577. }
  4578. return &WpChatroomCreateBulk{config: c.config, builders: builders}
  4579. }
  4580. // Update returns an update builder for WpChatroom.
  4581. func (c *WpChatroomClient) Update() *WpChatroomUpdate {
  4582. mutation := newWpChatroomMutation(c.config, OpUpdate)
  4583. return &WpChatroomUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4584. }
  4585. // UpdateOne returns an update builder for the given entity.
  4586. func (c *WpChatroomClient) UpdateOne(wc *WpChatroom) *WpChatroomUpdateOne {
  4587. mutation := newWpChatroomMutation(c.config, OpUpdateOne, withWpChatroom(wc))
  4588. return &WpChatroomUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4589. }
  4590. // UpdateOneID returns an update builder for the given id.
  4591. func (c *WpChatroomClient) UpdateOneID(id uint64) *WpChatroomUpdateOne {
  4592. mutation := newWpChatroomMutation(c.config, OpUpdateOne, withWpChatroomID(id))
  4593. return &WpChatroomUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4594. }
  4595. // Delete returns a delete builder for WpChatroom.
  4596. func (c *WpChatroomClient) Delete() *WpChatroomDelete {
  4597. mutation := newWpChatroomMutation(c.config, OpDelete)
  4598. return &WpChatroomDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4599. }
  4600. // DeleteOne returns a builder for deleting the given entity.
  4601. func (c *WpChatroomClient) DeleteOne(wc *WpChatroom) *WpChatroomDeleteOne {
  4602. return c.DeleteOneID(wc.ID)
  4603. }
  4604. // DeleteOneID returns a builder for deleting the given entity by its id.
  4605. func (c *WpChatroomClient) DeleteOneID(id uint64) *WpChatroomDeleteOne {
  4606. builder := c.Delete().Where(wpchatroom.ID(id))
  4607. builder.mutation.id = &id
  4608. builder.mutation.op = OpDeleteOne
  4609. return &WpChatroomDeleteOne{builder}
  4610. }
  4611. // Query returns a query builder for WpChatroom.
  4612. func (c *WpChatroomClient) Query() *WpChatroomQuery {
  4613. return &WpChatroomQuery{
  4614. config: c.config,
  4615. ctx: &QueryContext{Type: TypeWpChatroom},
  4616. inters: c.Interceptors(),
  4617. }
  4618. }
  4619. // Get returns a WpChatroom entity by its id.
  4620. func (c *WpChatroomClient) Get(ctx context.Context, id uint64) (*WpChatroom, error) {
  4621. return c.Query().Where(wpchatroom.ID(id)).Only(ctx)
  4622. }
  4623. // GetX is like Get, but panics if an error occurs.
  4624. func (c *WpChatroomClient) GetX(ctx context.Context, id uint64) *WpChatroom {
  4625. obj, err := c.Get(ctx, id)
  4626. if err != nil {
  4627. panic(err)
  4628. }
  4629. return obj
  4630. }
  4631. // Hooks returns the client hooks.
  4632. func (c *WpChatroomClient) Hooks() []Hook {
  4633. return c.hooks.WpChatroom
  4634. }
  4635. // Interceptors returns the client interceptors.
  4636. func (c *WpChatroomClient) Interceptors() []Interceptor {
  4637. return c.inters.WpChatroom
  4638. }
  4639. func (c *WpChatroomClient) mutate(ctx context.Context, m *WpChatroomMutation) (Value, error) {
  4640. switch m.Op() {
  4641. case OpCreate:
  4642. return (&WpChatroomCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4643. case OpUpdate:
  4644. return (&WpChatroomUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4645. case OpUpdateOne:
  4646. return (&WpChatroomUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4647. case OpDelete, OpDeleteOne:
  4648. return (&WpChatroomDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  4649. default:
  4650. return nil, fmt.Errorf("ent: unknown WpChatroom mutation op: %q", m.Op())
  4651. }
  4652. }
  4653. // WpChatroomMemberClient is a client for the WpChatroomMember schema.
  4654. type WpChatroomMemberClient struct {
  4655. config
  4656. }
  4657. // NewWpChatroomMemberClient returns a client for the WpChatroomMember from the given config.
  4658. func NewWpChatroomMemberClient(c config) *WpChatroomMemberClient {
  4659. return &WpChatroomMemberClient{config: c}
  4660. }
  4661. // Use adds a list of mutation hooks to the hooks stack.
  4662. // A call to `Use(f, g, h)` equals to `wpchatroommember.Hooks(f(g(h())))`.
  4663. func (c *WpChatroomMemberClient) Use(hooks ...Hook) {
  4664. c.hooks.WpChatroomMember = append(c.hooks.WpChatroomMember, hooks...)
  4665. }
  4666. // Intercept adds a list of query interceptors to the interceptors stack.
  4667. // A call to `Intercept(f, g, h)` equals to `wpchatroommember.Intercept(f(g(h())))`.
  4668. func (c *WpChatroomMemberClient) Intercept(interceptors ...Interceptor) {
  4669. c.inters.WpChatroomMember = append(c.inters.WpChatroomMember, interceptors...)
  4670. }
  4671. // Create returns a builder for creating a WpChatroomMember entity.
  4672. func (c *WpChatroomMemberClient) Create() *WpChatroomMemberCreate {
  4673. mutation := newWpChatroomMemberMutation(c.config, OpCreate)
  4674. return &WpChatroomMemberCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4675. }
  4676. // CreateBulk returns a builder for creating a bulk of WpChatroomMember entities.
  4677. func (c *WpChatroomMemberClient) CreateBulk(builders ...*WpChatroomMemberCreate) *WpChatroomMemberCreateBulk {
  4678. return &WpChatroomMemberCreateBulk{config: c.config, builders: builders}
  4679. }
  4680. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  4681. // a builder and applies setFunc on it.
  4682. func (c *WpChatroomMemberClient) MapCreateBulk(slice any, setFunc func(*WpChatroomMemberCreate, int)) *WpChatroomMemberCreateBulk {
  4683. rv := reflect.ValueOf(slice)
  4684. if rv.Kind() != reflect.Slice {
  4685. return &WpChatroomMemberCreateBulk{err: fmt.Errorf("calling to WpChatroomMemberClient.MapCreateBulk with wrong type %T, need slice", slice)}
  4686. }
  4687. builders := make([]*WpChatroomMemberCreate, rv.Len())
  4688. for i := 0; i < rv.Len(); i++ {
  4689. builders[i] = c.Create()
  4690. setFunc(builders[i], i)
  4691. }
  4692. return &WpChatroomMemberCreateBulk{config: c.config, builders: builders}
  4693. }
  4694. // Update returns an update builder for WpChatroomMember.
  4695. func (c *WpChatroomMemberClient) Update() *WpChatroomMemberUpdate {
  4696. mutation := newWpChatroomMemberMutation(c.config, OpUpdate)
  4697. return &WpChatroomMemberUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4698. }
  4699. // UpdateOne returns an update builder for the given entity.
  4700. func (c *WpChatroomMemberClient) UpdateOne(wcm *WpChatroomMember) *WpChatroomMemberUpdateOne {
  4701. mutation := newWpChatroomMemberMutation(c.config, OpUpdateOne, withWpChatroomMember(wcm))
  4702. return &WpChatroomMemberUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4703. }
  4704. // UpdateOneID returns an update builder for the given id.
  4705. func (c *WpChatroomMemberClient) UpdateOneID(id uint64) *WpChatroomMemberUpdateOne {
  4706. mutation := newWpChatroomMemberMutation(c.config, OpUpdateOne, withWpChatroomMemberID(id))
  4707. return &WpChatroomMemberUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4708. }
  4709. // Delete returns a delete builder for WpChatroomMember.
  4710. func (c *WpChatroomMemberClient) Delete() *WpChatroomMemberDelete {
  4711. mutation := newWpChatroomMemberMutation(c.config, OpDelete)
  4712. return &WpChatroomMemberDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4713. }
  4714. // DeleteOne returns a builder for deleting the given entity.
  4715. func (c *WpChatroomMemberClient) DeleteOne(wcm *WpChatroomMember) *WpChatroomMemberDeleteOne {
  4716. return c.DeleteOneID(wcm.ID)
  4717. }
  4718. // DeleteOneID returns a builder for deleting the given entity by its id.
  4719. func (c *WpChatroomMemberClient) DeleteOneID(id uint64) *WpChatroomMemberDeleteOne {
  4720. builder := c.Delete().Where(wpchatroommember.ID(id))
  4721. builder.mutation.id = &id
  4722. builder.mutation.op = OpDeleteOne
  4723. return &WpChatroomMemberDeleteOne{builder}
  4724. }
  4725. // Query returns a query builder for WpChatroomMember.
  4726. func (c *WpChatroomMemberClient) Query() *WpChatroomMemberQuery {
  4727. return &WpChatroomMemberQuery{
  4728. config: c.config,
  4729. ctx: &QueryContext{Type: TypeWpChatroomMember},
  4730. inters: c.Interceptors(),
  4731. }
  4732. }
  4733. // Get returns a WpChatroomMember entity by its id.
  4734. func (c *WpChatroomMemberClient) Get(ctx context.Context, id uint64) (*WpChatroomMember, error) {
  4735. return c.Query().Where(wpchatroommember.ID(id)).Only(ctx)
  4736. }
  4737. // GetX is like Get, but panics if an error occurs.
  4738. func (c *WpChatroomMemberClient) GetX(ctx context.Context, id uint64) *WpChatroomMember {
  4739. obj, err := c.Get(ctx, id)
  4740. if err != nil {
  4741. panic(err)
  4742. }
  4743. return obj
  4744. }
  4745. // Hooks returns the client hooks.
  4746. func (c *WpChatroomMemberClient) Hooks() []Hook {
  4747. return c.hooks.WpChatroomMember
  4748. }
  4749. // Interceptors returns the client interceptors.
  4750. func (c *WpChatroomMemberClient) Interceptors() []Interceptor {
  4751. return c.inters.WpChatroomMember
  4752. }
  4753. func (c *WpChatroomMemberClient) mutate(ctx context.Context, m *WpChatroomMemberMutation) (Value, error) {
  4754. switch m.Op() {
  4755. case OpCreate:
  4756. return (&WpChatroomMemberCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4757. case OpUpdate:
  4758. return (&WpChatroomMemberUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4759. case OpUpdateOne:
  4760. return (&WpChatroomMemberUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4761. case OpDelete, OpDeleteOne:
  4762. return (&WpChatroomMemberDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  4763. default:
  4764. return nil, fmt.Errorf("ent: unknown WpChatroomMember mutation op: %q", m.Op())
  4765. }
  4766. }
  4767. // WxClient is a client for the Wx schema.
  4768. type WxClient struct {
  4769. config
  4770. }
  4771. // NewWxClient returns a client for the Wx from the given config.
  4772. func NewWxClient(c config) *WxClient {
  4773. return &WxClient{config: c}
  4774. }
  4775. // Use adds a list of mutation hooks to the hooks stack.
  4776. // A call to `Use(f, g, h)` equals to `wx.Hooks(f(g(h())))`.
  4777. func (c *WxClient) Use(hooks ...Hook) {
  4778. c.hooks.Wx = append(c.hooks.Wx, hooks...)
  4779. }
  4780. // Intercept adds a list of query interceptors to the interceptors stack.
  4781. // A call to `Intercept(f, g, h)` equals to `wx.Intercept(f(g(h())))`.
  4782. func (c *WxClient) Intercept(interceptors ...Interceptor) {
  4783. c.inters.Wx = append(c.inters.Wx, interceptors...)
  4784. }
  4785. // Create returns a builder for creating a Wx entity.
  4786. func (c *WxClient) Create() *WxCreate {
  4787. mutation := newWxMutation(c.config, OpCreate)
  4788. return &WxCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4789. }
  4790. // CreateBulk returns a builder for creating a bulk of Wx entities.
  4791. func (c *WxClient) CreateBulk(builders ...*WxCreate) *WxCreateBulk {
  4792. return &WxCreateBulk{config: c.config, builders: builders}
  4793. }
  4794. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  4795. // a builder and applies setFunc on it.
  4796. func (c *WxClient) MapCreateBulk(slice any, setFunc func(*WxCreate, int)) *WxCreateBulk {
  4797. rv := reflect.ValueOf(slice)
  4798. if rv.Kind() != reflect.Slice {
  4799. return &WxCreateBulk{err: fmt.Errorf("calling to WxClient.MapCreateBulk with wrong type %T, need slice", slice)}
  4800. }
  4801. builders := make([]*WxCreate, rv.Len())
  4802. for i := 0; i < rv.Len(); i++ {
  4803. builders[i] = c.Create()
  4804. setFunc(builders[i], i)
  4805. }
  4806. return &WxCreateBulk{config: c.config, builders: builders}
  4807. }
  4808. // Update returns an update builder for Wx.
  4809. func (c *WxClient) Update() *WxUpdate {
  4810. mutation := newWxMutation(c.config, OpUpdate)
  4811. return &WxUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4812. }
  4813. // UpdateOne returns an update builder for the given entity.
  4814. func (c *WxClient) UpdateOne(w *Wx) *WxUpdateOne {
  4815. mutation := newWxMutation(c.config, OpUpdateOne, withWx(w))
  4816. return &WxUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4817. }
  4818. // UpdateOneID returns an update builder for the given id.
  4819. func (c *WxClient) UpdateOneID(id uint64) *WxUpdateOne {
  4820. mutation := newWxMutation(c.config, OpUpdateOne, withWxID(id))
  4821. return &WxUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4822. }
  4823. // Delete returns a delete builder for Wx.
  4824. func (c *WxClient) Delete() *WxDelete {
  4825. mutation := newWxMutation(c.config, OpDelete)
  4826. return &WxDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4827. }
  4828. // DeleteOne returns a builder for deleting the given entity.
  4829. func (c *WxClient) DeleteOne(w *Wx) *WxDeleteOne {
  4830. return c.DeleteOneID(w.ID)
  4831. }
  4832. // DeleteOneID returns a builder for deleting the given entity by its id.
  4833. func (c *WxClient) DeleteOneID(id uint64) *WxDeleteOne {
  4834. builder := c.Delete().Where(wx.ID(id))
  4835. builder.mutation.id = &id
  4836. builder.mutation.op = OpDeleteOne
  4837. return &WxDeleteOne{builder}
  4838. }
  4839. // Query returns a query builder for Wx.
  4840. func (c *WxClient) Query() *WxQuery {
  4841. return &WxQuery{
  4842. config: c.config,
  4843. ctx: &QueryContext{Type: TypeWx},
  4844. inters: c.Interceptors(),
  4845. }
  4846. }
  4847. // Get returns a Wx entity by its id.
  4848. func (c *WxClient) Get(ctx context.Context, id uint64) (*Wx, error) {
  4849. return c.Query().Where(wx.ID(id)).Only(ctx)
  4850. }
  4851. // GetX is like Get, but panics if an error occurs.
  4852. func (c *WxClient) GetX(ctx context.Context, id uint64) *Wx {
  4853. obj, err := c.Get(ctx, id)
  4854. if err != nil {
  4855. panic(err)
  4856. }
  4857. return obj
  4858. }
  4859. // QueryServer queries the server edge of a Wx.
  4860. func (c *WxClient) QueryServer(w *Wx) *ServerQuery {
  4861. query := (&ServerClient{config: c.config}).Query()
  4862. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  4863. id := w.ID
  4864. step := sqlgraph.NewStep(
  4865. sqlgraph.From(wx.Table, wx.FieldID, id),
  4866. sqlgraph.To(server.Table, server.FieldID),
  4867. sqlgraph.Edge(sqlgraph.M2O, true, wx.ServerTable, wx.ServerColumn),
  4868. )
  4869. fromV = sqlgraph.Neighbors(w.driver.Dialect(), step)
  4870. return fromV, nil
  4871. }
  4872. return query
  4873. }
  4874. // QueryAgent queries the agent edge of a Wx.
  4875. func (c *WxClient) QueryAgent(w *Wx) *AgentQuery {
  4876. query := (&AgentClient{config: c.config}).Query()
  4877. query.path = func(context.Context) (fromV *sql.Selector, _ error) {
  4878. id := w.ID
  4879. step := sqlgraph.NewStep(
  4880. sqlgraph.From(wx.Table, wx.FieldID, id),
  4881. sqlgraph.To(agent.Table, agent.FieldID),
  4882. sqlgraph.Edge(sqlgraph.M2O, true, wx.AgentTable, wx.AgentColumn),
  4883. )
  4884. fromV = sqlgraph.Neighbors(w.driver.Dialect(), step)
  4885. return fromV, nil
  4886. }
  4887. return query
  4888. }
  4889. // Hooks returns the client hooks.
  4890. func (c *WxClient) Hooks() []Hook {
  4891. hooks := c.hooks.Wx
  4892. return append(hooks[:len(hooks):len(hooks)], wx.Hooks[:]...)
  4893. }
  4894. // Interceptors returns the client interceptors.
  4895. func (c *WxClient) Interceptors() []Interceptor {
  4896. inters := c.inters.Wx
  4897. return append(inters[:len(inters):len(inters)], wx.Interceptors[:]...)
  4898. }
  4899. func (c *WxClient) mutate(ctx context.Context, m *WxMutation) (Value, error) {
  4900. switch m.Op() {
  4901. case OpCreate:
  4902. return (&WxCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4903. case OpUpdate:
  4904. return (&WxUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4905. case OpUpdateOne:
  4906. return (&WxUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  4907. case OpDelete, OpDeleteOne:
  4908. return (&WxDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  4909. default:
  4910. return nil, fmt.Errorf("ent: unknown Wx mutation op: %q", m.Op())
  4911. }
  4912. }
  4913. // WxCardClient is a client for the WxCard schema.
  4914. type WxCardClient struct {
  4915. config
  4916. }
  4917. // NewWxCardClient returns a client for the WxCard from the given config.
  4918. func NewWxCardClient(c config) *WxCardClient {
  4919. return &WxCardClient{config: c}
  4920. }
  4921. // Use adds a list of mutation hooks to the hooks stack.
  4922. // A call to `Use(f, g, h)` equals to `wxcard.Hooks(f(g(h())))`.
  4923. func (c *WxCardClient) Use(hooks ...Hook) {
  4924. c.hooks.WxCard = append(c.hooks.WxCard, hooks...)
  4925. }
  4926. // Intercept adds a list of query interceptors to the interceptors stack.
  4927. // A call to `Intercept(f, g, h)` equals to `wxcard.Intercept(f(g(h())))`.
  4928. func (c *WxCardClient) Intercept(interceptors ...Interceptor) {
  4929. c.inters.WxCard = append(c.inters.WxCard, interceptors...)
  4930. }
  4931. // Create returns a builder for creating a WxCard entity.
  4932. func (c *WxCardClient) Create() *WxCardCreate {
  4933. mutation := newWxCardMutation(c.config, OpCreate)
  4934. return &WxCardCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4935. }
  4936. // CreateBulk returns a builder for creating a bulk of WxCard entities.
  4937. func (c *WxCardClient) CreateBulk(builders ...*WxCardCreate) *WxCardCreateBulk {
  4938. return &WxCardCreateBulk{config: c.config, builders: builders}
  4939. }
  4940. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  4941. // a builder and applies setFunc on it.
  4942. func (c *WxCardClient) MapCreateBulk(slice any, setFunc func(*WxCardCreate, int)) *WxCardCreateBulk {
  4943. rv := reflect.ValueOf(slice)
  4944. if rv.Kind() != reflect.Slice {
  4945. return &WxCardCreateBulk{err: fmt.Errorf("calling to WxCardClient.MapCreateBulk with wrong type %T, need slice", slice)}
  4946. }
  4947. builders := make([]*WxCardCreate, rv.Len())
  4948. for i := 0; i < rv.Len(); i++ {
  4949. builders[i] = c.Create()
  4950. setFunc(builders[i], i)
  4951. }
  4952. return &WxCardCreateBulk{config: c.config, builders: builders}
  4953. }
  4954. // Update returns an update builder for WxCard.
  4955. func (c *WxCardClient) Update() *WxCardUpdate {
  4956. mutation := newWxCardMutation(c.config, OpUpdate)
  4957. return &WxCardUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4958. }
  4959. // UpdateOne returns an update builder for the given entity.
  4960. func (c *WxCardClient) UpdateOne(wc *WxCard) *WxCardUpdateOne {
  4961. mutation := newWxCardMutation(c.config, OpUpdateOne, withWxCard(wc))
  4962. return &WxCardUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4963. }
  4964. // UpdateOneID returns an update builder for the given id.
  4965. func (c *WxCardClient) UpdateOneID(id uint64) *WxCardUpdateOne {
  4966. mutation := newWxCardMutation(c.config, OpUpdateOne, withWxCardID(id))
  4967. return &WxCardUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4968. }
  4969. // Delete returns a delete builder for WxCard.
  4970. func (c *WxCardClient) Delete() *WxCardDelete {
  4971. mutation := newWxCardMutation(c.config, OpDelete)
  4972. return &WxCardDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  4973. }
  4974. // DeleteOne returns a builder for deleting the given entity.
  4975. func (c *WxCardClient) DeleteOne(wc *WxCard) *WxCardDeleteOne {
  4976. return c.DeleteOneID(wc.ID)
  4977. }
  4978. // DeleteOneID returns a builder for deleting the given entity by its id.
  4979. func (c *WxCardClient) DeleteOneID(id uint64) *WxCardDeleteOne {
  4980. builder := c.Delete().Where(wxcard.ID(id))
  4981. builder.mutation.id = &id
  4982. builder.mutation.op = OpDeleteOne
  4983. return &WxCardDeleteOne{builder}
  4984. }
  4985. // Query returns a query builder for WxCard.
  4986. func (c *WxCardClient) Query() *WxCardQuery {
  4987. return &WxCardQuery{
  4988. config: c.config,
  4989. ctx: &QueryContext{Type: TypeWxCard},
  4990. inters: c.Interceptors(),
  4991. }
  4992. }
  4993. // Get returns a WxCard entity by its id.
  4994. func (c *WxCardClient) Get(ctx context.Context, id uint64) (*WxCard, error) {
  4995. return c.Query().Where(wxcard.ID(id)).Only(ctx)
  4996. }
  4997. // GetX is like Get, but panics if an error occurs.
  4998. func (c *WxCardClient) GetX(ctx context.Context, id uint64) *WxCard {
  4999. obj, err := c.Get(ctx, id)
  5000. if err != nil {
  5001. panic(err)
  5002. }
  5003. return obj
  5004. }
  5005. // Hooks returns the client hooks.
  5006. func (c *WxCardClient) Hooks() []Hook {
  5007. hooks := c.hooks.WxCard
  5008. return append(hooks[:len(hooks):len(hooks)], wxcard.Hooks[:]...)
  5009. }
  5010. // Interceptors returns the client interceptors.
  5011. func (c *WxCardClient) Interceptors() []Interceptor {
  5012. inters := c.inters.WxCard
  5013. return append(inters[:len(inters):len(inters)], wxcard.Interceptors[:]...)
  5014. }
  5015. func (c *WxCardClient) mutate(ctx context.Context, m *WxCardMutation) (Value, error) {
  5016. switch m.Op() {
  5017. case OpCreate:
  5018. return (&WxCardCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  5019. case OpUpdate:
  5020. return (&WxCardUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  5021. case OpUpdateOne:
  5022. return (&WxCardUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  5023. case OpDelete, OpDeleteOne:
  5024. return (&WxCardDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  5025. default:
  5026. return nil, fmt.Errorf("ent: unknown WxCard mutation op: %q", m.Op())
  5027. }
  5028. }
  5029. // WxCardUserClient is a client for the WxCardUser schema.
  5030. type WxCardUserClient struct {
  5031. config
  5032. }
  5033. // NewWxCardUserClient returns a client for the WxCardUser from the given config.
  5034. func NewWxCardUserClient(c config) *WxCardUserClient {
  5035. return &WxCardUserClient{config: c}
  5036. }
  5037. // Use adds a list of mutation hooks to the hooks stack.
  5038. // A call to `Use(f, g, h)` equals to `wxcarduser.Hooks(f(g(h())))`.
  5039. func (c *WxCardUserClient) Use(hooks ...Hook) {
  5040. c.hooks.WxCardUser = append(c.hooks.WxCardUser, hooks...)
  5041. }
  5042. // Intercept adds a list of query interceptors to the interceptors stack.
  5043. // A call to `Intercept(f, g, h)` equals to `wxcarduser.Intercept(f(g(h())))`.
  5044. func (c *WxCardUserClient) Intercept(interceptors ...Interceptor) {
  5045. c.inters.WxCardUser = append(c.inters.WxCardUser, interceptors...)
  5046. }
  5047. // Create returns a builder for creating a WxCardUser entity.
  5048. func (c *WxCardUserClient) Create() *WxCardUserCreate {
  5049. mutation := newWxCardUserMutation(c.config, OpCreate)
  5050. return &WxCardUserCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  5051. }
  5052. // CreateBulk returns a builder for creating a bulk of WxCardUser entities.
  5053. func (c *WxCardUserClient) CreateBulk(builders ...*WxCardUserCreate) *WxCardUserCreateBulk {
  5054. return &WxCardUserCreateBulk{config: c.config, builders: builders}
  5055. }
  5056. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  5057. // a builder and applies setFunc on it.
  5058. func (c *WxCardUserClient) MapCreateBulk(slice any, setFunc func(*WxCardUserCreate, int)) *WxCardUserCreateBulk {
  5059. rv := reflect.ValueOf(slice)
  5060. if rv.Kind() != reflect.Slice {
  5061. return &WxCardUserCreateBulk{err: fmt.Errorf("calling to WxCardUserClient.MapCreateBulk with wrong type %T, need slice", slice)}
  5062. }
  5063. builders := make([]*WxCardUserCreate, rv.Len())
  5064. for i := 0; i < rv.Len(); i++ {
  5065. builders[i] = c.Create()
  5066. setFunc(builders[i], i)
  5067. }
  5068. return &WxCardUserCreateBulk{config: c.config, builders: builders}
  5069. }
  5070. // Update returns an update builder for WxCardUser.
  5071. func (c *WxCardUserClient) Update() *WxCardUserUpdate {
  5072. mutation := newWxCardUserMutation(c.config, OpUpdate)
  5073. return &WxCardUserUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  5074. }
  5075. // UpdateOne returns an update builder for the given entity.
  5076. func (c *WxCardUserClient) UpdateOne(wcu *WxCardUser) *WxCardUserUpdateOne {
  5077. mutation := newWxCardUserMutation(c.config, OpUpdateOne, withWxCardUser(wcu))
  5078. return &WxCardUserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  5079. }
  5080. // UpdateOneID returns an update builder for the given id.
  5081. func (c *WxCardUserClient) UpdateOneID(id uint64) *WxCardUserUpdateOne {
  5082. mutation := newWxCardUserMutation(c.config, OpUpdateOne, withWxCardUserID(id))
  5083. return &WxCardUserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  5084. }
  5085. // Delete returns a delete builder for WxCardUser.
  5086. func (c *WxCardUserClient) Delete() *WxCardUserDelete {
  5087. mutation := newWxCardUserMutation(c.config, OpDelete)
  5088. return &WxCardUserDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  5089. }
  5090. // DeleteOne returns a builder for deleting the given entity.
  5091. func (c *WxCardUserClient) DeleteOne(wcu *WxCardUser) *WxCardUserDeleteOne {
  5092. return c.DeleteOneID(wcu.ID)
  5093. }
  5094. // DeleteOneID returns a builder for deleting the given entity by its id.
  5095. func (c *WxCardUserClient) DeleteOneID(id uint64) *WxCardUserDeleteOne {
  5096. builder := c.Delete().Where(wxcarduser.ID(id))
  5097. builder.mutation.id = &id
  5098. builder.mutation.op = OpDeleteOne
  5099. return &WxCardUserDeleteOne{builder}
  5100. }
  5101. // Query returns a query builder for WxCardUser.
  5102. func (c *WxCardUserClient) Query() *WxCardUserQuery {
  5103. return &WxCardUserQuery{
  5104. config: c.config,
  5105. ctx: &QueryContext{Type: TypeWxCardUser},
  5106. inters: c.Interceptors(),
  5107. }
  5108. }
  5109. // Get returns a WxCardUser entity by its id.
  5110. func (c *WxCardUserClient) Get(ctx context.Context, id uint64) (*WxCardUser, error) {
  5111. return c.Query().Where(wxcarduser.ID(id)).Only(ctx)
  5112. }
  5113. // GetX is like Get, but panics if an error occurs.
  5114. func (c *WxCardUserClient) GetX(ctx context.Context, id uint64) *WxCardUser {
  5115. obj, err := c.Get(ctx, id)
  5116. if err != nil {
  5117. panic(err)
  5118. }
  5119. return obj
  5120. }
  5121. // Hooks returns the client hooks.
  5122. func (c *WxCardUserClient) Hooks() []Hook {
  5123. hooks := c.hooks.WxCardUser
  5124. return append(hooks[:len(hooks):len(hooks)], wxcarduser.Hooks[:]...)
  5125. }
  5126. // Interceptors returns the client interceptors.
  5127. func (c *WxCardUserClient) Interceptors() []Interceptor {
  5128. inters := c.inters.WxCardUser
  5129. return append(inters[:len(inters):len(inters)], wxcarduser.Interceptors[:]...)
  5130. }
  5131. func (c *WxCardUserClient) mutate(ctx context.Context, m *WxCardUserMutation) (Value, error) {
  5132. switch m.Op() {
  5133. case OpCreate:
  5134. return (&WxCardUserCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  5135. case OpUpdate:
  5136. return (&WxCardUserUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  5137. case OpUpdateOne:
  5138. return (&WxCardUserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  5139. case OpDelete, OpDeleteOne:
  5140. return (&WxCardUserDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  5141. default:
  5142. return nil, fmt.Errorf("ent: unknown WxCardUser mutation op: %q", m.Op())
  5143. }
  5144. }
  5145. // WxCardVisitClient is a client for the WxCardVisit schema.
  5146. type WxCardVisitClient struct {
  5147. config
  5148. }
  5149. // NewWxCardVisitClient returns a client for the WxCardVisit from the given config.
  5150. func NewWxCardVisitClient(c config) *WxCardVisitClient {
  5151. return &WxCardVisitClient{config: c}
  5152. }
  5153. // Use adds a list of mutation hooks to the hooks stack.
  5154. // A call to `Use(f, g, h)` equals to `wxcardvisit.Hooks(f(g(h())))`.
  5155. func (c *WxCardVisitClient) Use(hooks ...Hook) {
  5156. c.hooks.WxCardVisit = append(c.hooks.WxCardVisit, hooks...)
  5157. }
  5158. // Intercept adds a list of query interceptors to the interceptors stack.
  5159. // A call to `Intercept(f, g, h)` equals to `wxcardvisit.Intercept(f(g(h())))`.
  5160. func (c *WxCardVisitClient) Intercept(interceptors ...Interceptor) {
  5161. c.inters.WxCardVisit = append(c.inters.WxCardVisit, interceptors...)
  5162. }
  5163. // Create returns a builder for creating a WxCardVisit entity.
  5164. func (c *WxCardVisitClient) Create() *WxCardVisitCreate {
  5165. mutation := newWxCardVisitMutation(c.config, OpCreate)
  5166. return &WxCardVisitCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  5167. }
  5168. // CreateBulk returns a builder for creating a bulk of WxCardVisit entities.
  5169. func (c *WxCardVisitClient) CreateBulk(builders ...*WxCardVisitCreate) *WxCardVisitCreateBulk {
  5170. return &WxCardVisitCreateBulk{config: c.config, builders: builders}
  5171. }
  5172. // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
  5173. // a builder and applies setFunc on it.
  5174. func (c *WxCardVisitClient) MapCreateBulk(slice any, setFunc func(*WxCardVisitCreate, int)) *WxCardVisitCreateBulk {
  5175. rv := reflect.ValueOf(slice)
  5176. if rv.Kind() != reflect.Slice {
  5177. return &WxCardVisitCreateBulk{err: fmt.Errorf("calling to WxCardVisitClient.MapCreateBulk with wrong type %T, need slice", slice)}
  5178. }
  5179. builders := make([]*WxCardVisitCreate, rv.Len())
  5180. for i := 0; i < rv.Len(); i++ {
  5181. builders[i] = c.Create()
  5182. setFunc(builders[i], i)
  5183. }
  5184. return &WxCardVisitCreateBulk{config: c.config, builders: builders}
  5185. }
  5186. // Update returns an update builder for WxCardVisit.
  5187. func (c *WxCardVisitClient) Update() *WxCardVisitUpdate {
  5188. mutation := newWxCardVisitMutation(c.config, OpUpdate)
  5189. return &WxCardVisitUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
  5190. }
  5191. // UpdateOne returns an update builder for the given entity.
  5192. func (c *WxCardVisitClient) UpdateOne(wcv *WxCardVisit) *WxCardVisitUpdateOne {
  5193. mutation := newWxCardVisitMutation(c.config, OpUpdateOne, withWxCardVisit(wcv))
  5194. return &WxCardVisitUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  5195. }
  5196. // UpdateOneID returns an update builder for the given id.
  5197. func (c *WxCardVisitClient) UpdateOneID(id uint64) *WxCardVisitUpdateOne {
  5198. mutation := newWxCardVisitMutation(c.config, OpUpdateOne, withWxCardVisitID(id))
  5199. return &WxCardVisitUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
  5200. }
  5201. // Delete returns a delete builder for WxCardVisit.
  5202. func (c *WxCardVisitClient) Delete() *WxCardVisitDelete {
  5203. mutation := newWxCardVisitMutation(c.config, OpDelete)
  5204. return &WxCardVisitDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
  5205. }
  5206. // DeleteOne returns a builder for deleting the given entity.
  5207. func (c *WxCardVisitClient) DeleteOne(wcv *WxCardVisit) *WxCardVisitDeleteOne {
  5208. return c.DeleteOneID(wcv.ID)
  5209. }
  5210. // DeleteOneID returns a builder for deleting the given entity by its id.
  5211. func (c *WxCardVisitClient) DeleteOneID(id uint64) *WxCardVisitDeleteOne {
  5212. builder := c.Delete().Where(wxcardvisit.ID(id))
  5213. builder.mutation.id = &id
  5214. builder.mutation.op = OpDeleteOne
  5215. return &WxCardVisitDeleteOne{builder}
  5216. }
  5217. // Query returns a query builder for WxCardVisit.
  5218. func (c *WxCardVisitClient) Query() *WxCardVisitQuery {
  5219. return &WxCardVisitQuery{
  5220. config: c.config,
  5221. ctx: &QueryContext{Type: TypeWxCardVisit},
  5222. inters: c.Interceptors(),
  5223. }
  5224. }
  5225. // Get returns a WxCardVisit entity by its id.
  5226. func (c *WxCardVisitClient) Get(ctx context.Context, id uint64) (*WxCardVisit, error) {
  5227. return c.Query().Where(wxcardvisit.ID(id)).Only(ctx)
  5228. }
  5229. // GetX is like Get, but panics if an error occurs.
  5230. func (c *WxCardVisitClient) GetX(ctx context.Context, id uint64) *WxCardVisit {
  5231. obj, err := c.Get(ctx, id)
  5232. if err != nil {
  5233. panic(err)
  5234. }
  5235. return obj
  5236. }
  5237. // Hooks returns the client hooks.
  5238. func (c *WxCardVisitClient) Hooks() []Hook {
  5239. hooks := c.hooks.WxCardVisit
  5240. return append(hooks[:len(hooks):len(hooks)], wxcardvisit.Hooks[:]...)
  5241. }
  5242. // Interceptors returns the client interceptors.
  5243. func (c *WxCardVisitClient) Interceptors() []Interceptor {
  5244. inters := c.inters.WxCardVisit
  5245. return append(inters[:len(inters):len(inters)], wxcardvisit.Interceptors[:]...)
  5246. }
  5247. func (c *WxCardVisitClient) mutate(ctx context.Context, m *WxCardVisitMutation) (Value, error) {
  5248. switch m.Op() {
  5249. case OpCreate:
  5250. return (&WxCardVisitCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  5251. case OpUpdate:
  5252. return (&WxCardVisitUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  5253. case OpUpdateOne:
  5254. return (&WxCardVisitUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
  5255. case OpDelete, OpDeleteOne:
  5256. return (&WxCardVisitDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
  5257. default:
  5258. return nil, fmt.Errorf("ent: unknown WxCardVisit mutation op: %q", m.Op())
  5259. }
  5260. }
  5261. // hooks and interceptors per client, for fast access.
  5262. type (
  5263. hooks struct {
  5264. Agent, AgentBase, AliyunAvatar, AllocAgent, BatchMsg, Category, ChatRecords,
  5265. ChatSession, Contact, CreditBalance, CreditUsage, Employee, EmployeeConfig,
  5266. Label, LabelRelationship, LabelTagging, Message, MessageRecords, Msg,
  5267. PayRecharge, Server, SopNode, SopStage, SopTask, Token, Tutorial, UsageDetail,
  5268. UsageStatisticDay, UsageStatisticHour, UsageStatisticMonth, UsageTotal,
  5269. WorkExperience, WpChatroom, WpChatroomMember, Wx, WxCard, WxCardUser,
  5270. WxCardVisit []ent.Hook
  5271. }
  5272. inters struct {
  5273. Agent, AgentBase, AliyunAvatar, AllocAgent, BatchMsg, Category, ChatRecords,
  5274. ChatSession, Contact, CreditBalance, CreditUsage, Employee, EmployeeConfig,
  5275. Label, LabelRelationship, LabelTagging, Message, MessageRecords, Msg,
  5276. PayRecharge, Server, SopNode, SopStage, SopTask, Token, Tutorial, UsageDetail,
  5277. UsageStatisticDay, UsageStatisticHour, UsageStatisticMonth, UsageTotal,
  5278. WorkExperience, WpChatroom, WpChatroomMember, Wx, WxCard, WxCardUser,
  5279. WxCardVisit []ent.Interceptor
  5280. }
  5281. )
  5282. // ExecContext allows calling the underlying ExecContext method of the driver if it is supported by it.
  5283. // See, database/sql#DB.ExecContext for more information.
  5284. func (c *config) ExecContext(ctx context.Context, query string, args ...any) (stdsql.Result, error) {
  5285. ex, ok := c.driver.(interface {
  5286. ExecContext(context.Context, string, ...any) (stdsql.Result, error)
  5287. })
  5288. if !ok {
  5289. return nil, fmt.Errorf("Driver.ExecContext is not supported")
  5290. }
  5291. return ex.ExecContext(ctx, query, args...)
  5292. }
  5293. // QueryContext allows calling the underlying QueryContext method of the driver if it is supported by it.
  5294. // See, database/sql#DB.QueryContext for more information.
  5295. func (c *config) QueryContext(ctx context.Context, query string, args ...any) (*stdsql.Rows, error) {
  5296. q, ok := c.driver.(interface {
  5297. QueryContext(context.Context, string, ...any) (*stdsql.Rows, error)
  5298. })
  5299. if !ok {
  5300. return nil, fmt.Errorf("Driver.QueryContext is not supported")
  5301. }
  5302. return q.QueryContext(ctx, query, args...)
  5303. }