client.go 265 KB

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