client.go 170 KB

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