client.go 205 KB

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