client.go 233 KB

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