client.go 258 KB

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