client.go 181 KB

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