client.go 271 KB

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