client.go 246 KB

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