client.go 228 KB

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