client.go 258 KB

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