client.go 222 KB

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