client.go 271 KB

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