client.go 211 KB

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