client.go 200 KB

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