client.go 205 KB

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