client.go 245 KB

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