client.go 271 KB

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