client.go 199 KB

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