client.go 289 KB

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