client.go 260 KB

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