client.go 283 KB

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