mutation.go 1018 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "sync"
  8. "time"
  9. "wechat-api/ent/agent"
  10. "wechat-api/ent/agentbase"
  11. "wechat-api/ent/aliyunavatar"
  12. "wechat-api/ent/batchmsg"
  13. "wechat-api/ent/category"
  14. "wechat-api/ent/chatrecords"
  15. "wechat-api/ent/chatsession"
  16. "wechat-api/ent/contact"
  17. "wechat-api/ent/custom_types"
  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/predicate"
  26. "wechat-api/ent/server"
  27. "wechat-api/ent/sopnode"
  28. "wechat-api/ent/sopstage"
  29. "wechat-api/ent/soptask"
  30. "wechat-api/ent/token"
  31. "wechat-api/ent/tutorial"
  32. "wechat-api/ent/usagedetail"
  33. "wechat-api/ent/usagetotal"
  34. "wechat-api/ent/workexperience"
  35. "wechat-api/ent/wpchatroom"
  36. "wechat-api/ent/wpchatroommember"
  37. "wechat-api/ent/wx"
  38. "wechat-api/ent/wxcard"
  39. "wechat-api/ent/wxcarduser"
  40. "wechat-api/ent/wxcardvisit"
  41. "entgo.io/ent"
  42. "entgo.io/ent/dialect/sql"
  43. )
  44. const (
  45. // Operation types.
  46. OpCreate = ent.OpCreate
  47. OpDelete = ent.OpDelete
  48. OpDeleteOne = ent.OpDeleteOne
  49. OpUpdate = ent.OpUpdate
  50. OpUpdateOne = ent.OpUpdateOne
  51. // Node types.
  52. TypeAgent = "Agent"
  53. TypeAgentBase = "AgentBase"
  54. TypeAliyunAvatar = "AliyunAvatar"
  55. TypeBatchMsg = "BatchMsg"
  56. TypeCategory = "Category"
  57. TypeChatRecords = "ChatRecords"
  58. TypeChatSession = "ChatSession"
  59. TypeContact = "Contact"
  60. TypeEmployee = "Employee"
  61. TypeEmployeeConfig = "EmployeeConfig"
  62. TypeLabel = "Label"
  63. TypeLabelRelationship = "LabelRelationship"
  64. TypeMessage = "Message"
  65. TypeMessageRecords = "MessageRecords"
  66. TypeMsg = "Msg"
  67. TypeServer = "Server"
  68. TypeSopNode = "SopNode"
  69. TypeSopStage = "SopStage"
  70. TypeSopTask = "SopTask"
  71. TypeToken = "Token"
  72. TypeTutorial = "Tutorial"
  73. TypeUsageDetail = "UsageDetail"
  74. TypeUsageTotal = "UsageTotal"
  75. TypeWorkExperience = "WorkExperience"
  76. TypeWpChatroom = "WpChatroom"
  77. TypeWpChatroomMember = "WpChatroomMember"
  78. TypeWx = "Wx"
  79. TypeWxCard = "WxCard"
  80. TypeWxCardUser = "WxCardUser"
  81. TypeWxCardVisit = "WxCardVisit"
  82. )
  83. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  84. type AgentMutation struct {
  85. config
  86. op Op
  87. typ string
  88. id *uint64
  89. created_at *time.Time
  90. updated_at *time.Time
  91. deleted_at *time.Time
  92. name *string
  93. role *string
  94. status *int
  95. addstatus *int
  96. background *string
  97. examples *string
  98. organization_id *uint64
  99. addorganization_id *int64
  100. dataset_id *string
  101. collection_id *string
  102. clearedFields map[string]struct{}
  103. wx_agent map[uint64]struct{}
  104. removedwx_agent map[uint64]struct{}
  105. clearedwx_agent bool
  106. token_agent map[uint64]struct{}
  107. removedtoken_agent map[uint64]struct{}
  108. clearedtoken_agent bool
  109. done bool
  110. oldValue func(context.Context) (*Agent, error)
  111. predicates []predicate.Agent
  112. }
  113. var _ ent.Mutation = (*AgentMutation)(nil)
  114. // agentOption allows management of the mutation configuration using functional options.
  115. type agentOption func(*AgentMutation)
  116. // newAgentMutation creates new mutation for the Agent entity.
  117. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  118. m := &AgentMutation{
  119. config: c,
  120. op: op,
  121. typ: TypeAgent,
  122. clearedFields: make(map[string]struct{}),
  123. }
  124. for _, opt := range opts {
  125. opt(m)
  126. }
  127. return m
  128. }
  129. // withAgentID sets the ID field of the mutation.
  130. func withAgentID(id uint64) agentOption {
  131. return func(m *AgentMutation) {
  132. var (
  133. err error
  134. once sync.Once
  135. value *Agent
  136. )
  137. m.oldValue = func(ctx context.Context) (*Agent, error) {
  138. once.Do(func() {
  139. if m.done {
  140. err = errors.New("querying old values post mutation is not allowed")
  141. } else {
  142. value, err = m.Client().Agent.Get(ctx, id)
  143. }
  144. })
  145. return value, err
  146. }
  147. m.id = &id
  148. }
  149. }
  150. // withAgent sets the old Agent of the mutation.
  151. func withAgent(node *Agent) agentOption {
  152. return func(m *AgentMutation) {
  153. m.oldValue = func(context.Context) (*Agent, error) {
  154. return node, nil
  155. }
  156. m.id = &node.ID
  157. }
  158. }
  159. // Client returns a new `ent.Client` from the mutation. If the mutation was
  160. // executed in a transaction (ent.Tx), a transactional client is returned.
  161. func (m AgentMutation) Client() *Client {
  162. client := &Client{config: m.config}
  163. client.init()
  164. return client
  165. }
  166. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  167. // it returns an error otherwise.
  168. func (m AgentMutation) Tx() (*Tx, error) {
  169. if _, ok := m.driver.(*txDriver); !ok {
  170. return nil, errors.New("ent: mutation is not running in a transaction")
  171. }
  172. tx := &Tx{config: m.config}
  173. tx.init()
  174. return tx, nil
  175. }
  176. // SetID sets the value of the id field. Note that this
  177. // operation is only accepted on creation of Agent entities.
  178. func (m *AgentMutation) SetID(id uint64) {
  179. m.id = &id
  180. }
  181. // ID returns the ID value in the mutation. Note that the ID is only available
  182. // if it was provided to the builder or after it was returned from the database.
  183. func (m *AgentMutation) ID() (id uint64, exists bool) {
  184. if m.id == nil {
  185. return
  186. }
  187. return *m.id, true
  188. }
  189. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  190. // That means, if the mutation is applied within a transaction with an isolation level such
  191. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  192. // or updated by the mutation.
  193. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  194. switch {
  195. case m.op.Is(OpUpdateOne | OpDeleteOne):
  196. id, exists := m.ID()
  197. if exists {
  198. return []uint64{id}, nil
  199. }
  200. fallthrough
  201. case m.op.Is(OpUpdate | OpDelete):
  202. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  203. default:
  204. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  205. }
  206. }
  207. // SetCreatedAt sets the "created_at" field.
  208. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  209. m.created_at = &t
  210. }
  211. // CreatedAt returns the value of the "created_at" field in the mutation.
  212. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  213. v := m.created_at
  214. if v == nil {
  215. return
  216. }
  217. return *v, true
  218. }
  219. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  220. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  222. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  223. if !m.op.Is(OpUpdateOne) {
  224. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  225. }
  226. if m.id == nil || m.oldValue == nil {
  227. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  228. }
  229. oldValue, err := m.oldValue(ctx)
  230. if err != nil {
  231. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  232. }
  233. return oldValue.CreatedAt, nil
  234. }
  235. // ResetCreatedAt resets all changes to the "created_at" field.
  236. func (m *AgentMutation) ResetCreatedAt() {
  237. m.created_at = nil
  238. }
  239. // SetUpdatedAt sets the "updated_at" field.
  240. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  241. m.updated_at = &t
  242. }
  243. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  244. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  245. v := m.updated_at
  246. if v == nil {
  247. return
  248. }
  249. return *v, true
  250. }
  251. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  252. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  253. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  254. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  255. if !m.op.Is(OpUpdateOne) {
  256. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  257. }
  258. if m.id == nil || m.oldValue == nil {
  259. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  260. }
  261. oldValue, err := m.oldValue(ctx)
  262. if err != nil {
  263. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  264. }
  265. return oldValue.UpdatedAt, nil
  266. }
  267. // ResetUpdatedAt resets all changes to the "updated_at" field.
  268. func (m *AgentMutation) ResetUpdatedAt() {
  269. m.updated_at = nil
  270. }
  271. // SetDeletedAt sets the "deleted_at" field.
  272. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  273. m.deleted_at = &t
  274. }
  275. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  276. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  277. v := m.deleted_at
  278. if v == nil {
  279. return
  280. }
  281. return *v, true
  282. }
  283. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  284. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  285. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  286. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  287. if !m.op.Is(OpUpdateOne) {
  288. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  289. }
  290. if m.id == nil || m.oldValue == nil {
  291. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  292. }
  293. oldValue, err := m.oldValue(ctx)
  294. if err != nil {
  295. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  296. }
  297. return oldValue.DeletedAt, nil
  298. }
  299. // ClearDeletedAt clears the value of the "deleted_at" field.
  300. func (m *AgentMutation) ClearDeletedAt() {
  301. m.deleted_at = nil
  302. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  303. }
  304. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  305. func (m *AgentMutation) DeletedAtCleared() bool {
  306. _, ok := m.clearedFields[agent.FieldDeletedAt]
  307. return ok
  308. }
  309. // ResetDeletedAt resets all changes to the "deleted_at" field.
  310. func (m *AgentMutation) ResetDeletedAt() {
  311. m.deleted_at = nil
  312. delete(m.clearedFields, agent.FieldDeletedAt)
  313. }
  314. // SetName sets the "name" field.
  315. func (m *AgentMutation) SetName(s string) {
  316. m.name = &s
  317. }
  318. // Name returns the value of the "name" field in the mutation.
  319. func (m *AgentMutation) Name() (r string, exists bool) {
  320. v := m.name
  321. if v == nil {
  322. return
  323. }
  324. return *v, true
  325. }
  326. // OldName returns the old "name" field's value of the Agent entity.
  327. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  329. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  330. if !m.op.Is(OpUpdateOne) {
  331. return v, errors.New("OldName is only allowed on UpdateOne operations")
  332. }
  333. if m.id == nil || m.oldValue == nil {
  334. return v, errors.New("OldName requires an ID field in the mutation")
  335. }
  336. oldValue, err := m.oldValue(ctx)
  337. if err != nil {
  338. return v, fmt.Errorf("querying old value for OldName: %w", err)
  339. }
  340. return oldValue.Name, nil
  341. }
  342. // ResetName resets all changes to the "name" field.
  343. func (m *AgentMutation) ResetName() {
  344. m.name = nil
  345. }
  346. // SetRole sets the "role" field.
  347. func (m *AgentMutation) SetRole(s string) {
  348. m.role = &s
  349. }
  350. // Role returns the value of the "role" field in the mutation.
  351. func (m *AgentMutation) Role() (r string, exists bool) {
  352. v := m.role
  353. if v == nil {
  354. return
  355. }
  356. return *v, true
  357. }
  358. // OldRole returns the old "role" field's value of the Agent entity.
  359. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  360. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  361. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  362. if !m.op.Is(OpUpdateOne) {
  363. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  364. }
  365. if m.id == nil || m.oldValue == nil {
  366. return v, errors.New("OldRole requires an ID field in the mutation")
  367. }
  368. oldValue, err := m.oldValue(ctx)
  369. if err != nil {
  370. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  371. }
  372. return oldValue.Role, nil
  373. }
  374. // ResetRole resets all changes to the "role" field.
  375. func (m *AgentMutation) ResetRole() {
  376. m.role = nil
  377. }
  378. // SetStatus sets the "status" field.
  379. func (m *AgentMutation) SetStatus(i int) {
  380. m.status = &i
  381. m.addstatus = nil
  382. }
  383. // Status returns the value of the "status" field in the mutation.
  384. func (m *AgentMutation) Status() (r int, exists bool) {
  385. v := m.status
  386. if v == nil {
  387. return
  388. }
  389. return *v, true
  390. }
  391. // OldStatus returns the old "status" field's value of the Agent entity.
  392. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  394. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  395. if !m.op.Is(OpUpdateOne) {
  396. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  397. }
  398. if m.id == nil || m.oldValue == nil {
  399. return v, errors.New("OldStatus requires an ID field in the mutation")
  400. }
  401. oldValue, err := m.oldValue(ctx)
  402. if err != nil {
  403. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  404. }
  405. return oldValue.Status, nil
  406. }
  407. // AddStatus adds i to the "status" field.
  408. func (m *AgentMutation) AddStatus(i int) {
  409. if m.addstatus != nil {
  410. *m.addstatus += i
  411. } else {
  412. m.addstatus = &i
  413. }
  414. }
  415. // AddedStatus returns the value that was added to the "status" field in this mutation.
  416. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  417. v := m.addstatus
  418. if v == nil {
  419. return
  420. }
  421. return *v, true
  422. }
  423. // ClearStatus clears the value of the "status" field.
  424. func (m *AgentMutation) ClearStatus() {
  425. m.status = nil
  426. m.addstatus = nil
  427. m.clearedFields[agent.FieldStatus] = struct{}{}
  428. }
  429. // StatusCleared returns if the "status" field was cleared in this mutation.
  430. func (m *AgentMutation) StatusCleared() bool {
  431. _, ok := m.clearedFields[agent.FieldStatus]
  432. return ok
  433. }
  434. // ResetStatus resets all changes to the "status" field.
  435. func (m *AgentMutation) ResetStatus() {
  436. m.status = nil
  437. m.addstatus = nil
  438. delete(m.clearedFields, agent.FieldStatus)
  439. }
  440. // SetBackground sets the "background" field.
  441. func (m *AgentMutation) SetBackground(s string) {
  442. m.background = &s
  443. }
  444. // Background returns the value of the "background" field in the mutation.
  445. func (m *AgentMutation) Background() (r string, exists bool) {
  446. v := m.background
  447. if v == nil {
  448. return
  449. }
  450. return *v, true
  451. }
  452. // OldBackground returns the old "background" field's value of the Agent entity.
  453. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  454. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  455. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  456. if !m.op.Is(OpUpdateOne) {
  457. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  458. }
  459. if m.id == nil || m.oldValue == nil {
  460. return v, errors.New("OldBackground requires an ID field in the mutation")
  461. }
  462. oldValue, err := m.oldValue(ctx)
  463. if err != nil {
  464. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  465. }
  466. return oldValue.Background, nil
  467. }
  468. // ClearBackground clears the value of the "background" field.
  469. func (m *AgentMutation) ClearBackground() {
  470. m.background = nil
  471. m.clearedFields[agent.FieldBackground] = struct{}{}
  472. }
  473. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  474. func (m *AgentMutation) BackgroundCleared() bool {
  475. _, ok := m.clearedFields[agent.FieldBackground]
  476. return ok
  477. }
  478. // ResetBackground resets all changes to the "background" field.
  479. func (m *AgentMutation) ResetBackground() {
  480. m.background = nil
  481. delete(m.clearedFields, agent.FieldBackground)
  482. }
  483. // SetExamples sets the "examples" field.
  484. func (m *AgentMutation) SetExamples(s string) {
  485. m.examples = &s
  486. }
  487. // Examples returns the value of the "examples" field in the mutation.
  488. func (m *AgentMutation) Examples() (r string, exists bool) {
  489. v := m.examples
  490. if v == nil {
  491. return
  492. }
  493. return *v, true
  494. }
  495. // OldExamples returns the old "examples" field's value of the Agent entity.
  496. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  497. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  498. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  499. if !m.op.Is(OpUpdateOne) {
  500. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  501. }
  502. if m.id == nil || m.oldValue == nil {
  503. return v, errors.New("OldExamples requires an ID field in the mutation")
  504. }
  505. oldValue, err := m.oldValue(ctx)
  506. if err != nil {
  507. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  508. }
  509. return oldValue.Examples, nil
  510. }
  511. // ClearExamples clears the value of the "examples" field.
  512. func (m *AgentMutation) ClearExamples() {
  513. m.examples = nil
  514. m.clearedFields[agent.FieldExamples] = struct{}{}
  515. }
  516. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  517. func (m *AgentMutation) ExamplesCleared() bool {
  518. _, ok := m.clearedFields[agent.FieldExamples]
  519. return ok
  520. }
  521. // ResetExamples resets all changes to the "examples" field.
  522. func (m *AgentMutation) ResetExamples() {
  523. m.examples = nil
  524. delete(m.clearedFields, agent.FieldExamples)
  525. }
  526. // SetOrganizationID sets the "organization_id" field.
  527. func (m *AgentMutation) SetOrganizationID(u uint64) {
  528. m.organization_id = &u
  529. m.addorganization_id = nil
  530. }
  531. // OrganizationID returns the value of the "organization_id" field in the mutation.
  532. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  533. v := m.organization_id
  534. if v == nil {
  535. return
  536. }
  537. return *v, true
  538. }
  539. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  540. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  541. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  542. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  543. if !m.op.Is(OpUpdateOne) {
  544. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  545. }
  546. if m.id == nil || m.oldValue == nil {
  547. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  548. }
  549. oldValue, err := m.oldValue(ctx)
  550. if err != nil {
  551. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  552. }
  553. return oldValue.OrganizationID, nil
  554. }
  555. // AddOrganizationID adds u to the "organization_id" field.
  556. func (m *AgentMutation) AddOrganizationID(u int64) {
  557. if m.addorganization_id != nil {
  558. *m.addorganization_id += u
  559. } else {
  560. m.addorganization_id = &u
  561. }
  562. }
  563. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  564. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  565. v := m.addorganization_id
  566. if v == nil {
  567. return
  568. }
  569. return *v, true
  570. }
  571. // ResetOrganizationID resets all changes to the "organization_id" field.
  572. func (m *AgentMutation) ResetOrganizationID() {
  573. m.organization_id = nil
  574. m.addorganization_id = nil
  575. }
  576. // SetDatasetID sets the "dataset_id" field.
  577. func (m *AgentMutation) SetDatasetID(s string) {
  578. m.dataset_id = &s
  579. }
  580. // DatasetID returns the value of the "dataset_id" field in the mutation.
  581. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  582. v := m.dataset_id
  583. if v == nil {
  584. return
  585. }
  586. return *v, true
  587. }
  588. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  589. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  590. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  591. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  592. if !m.op.Is(OpUpdateOne) {
  593. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  594. }
  595. if m.id == nil || m.oldValue == nil {
  596. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  597. }
  598. oldValue, err := m.oldValue(ctx)
  599. if err != nil {
  600. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  601. }
  602. return oldValue.DatasetID, nil
  603. }
  604. // ResetDatasetID resets all changes to the "dataset_id" field.
  605. func (m *AgentMutation) ResetDatasetID() {
  606. m.dataset_id = nil
  607. }
  608. // SetCollectionID sets the "collection_id" field.
  609. func (m *AgentMutation) SetCollectionID(s string) {
  610. m.collection_id = &s
  611. }
  612. // CollectionID returns the value of the "collection_id" field in the mutation.
  613. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  614. v := m.collection_id
  615. if v == nil {
  616. return
  617. }
  618. return *v, true
  619. }
  620. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  621. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  622. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  623. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  624. if !m.op.Is(OpUpdateOne) {
  625. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  626. }
  627. if m.id == nil || m.oldValue == nil {
  628. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  629. }
  630. oldValue, err := m.oldValue(ctx)
  631. if err != nil {
  632. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  633. }
  634. return oldValue.CollectionID, nil
  635. }
  636. // ResetCollectionID resets all changes to the "collection_id" field.
  637. func (m *AgentMutation) ResetCollectionID() {
  638. m.collection_id = nil
  639. }
  640. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  641. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  642. if m.wx_agent == nil {
  643. m.wx_agent = make(map[uint64]struct{})
  644. }
  645. for i := range ids {
  646. m.wx_agent[ids[i]] = struct{}{}
  647. }
  648. }
  649. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  650. func (m *AgentMutation) ClearWxAgent() {
  651. m.clearedwx_agent = true
  652. }
  653. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  654. func (m *AgentMutation) WxAgentCleared() bool {
  655. return m.clearedwx_agent
  656. }
  657. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  658. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  659. if m.removedwx_agent == nil {
  660. m.removedwx_agent = make(map[uint64]struct{})
  661. }
  662. for i := range ids {
  663. delete(m.wx_agent, ids[i])
  664. m.removedwx_agent[ids[i]] = struct{}{}
  665. }
  666. }
  667. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  668. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  669. for id := range m.removedwx_agent {
  670. ids = append(ids, id)
  671. }
  672. return
  673. }
  674. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  675. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  676. for id := range m.wx_agent {
  677. ids = append(ids, id)
  678. }
  679. return
  680. }
  681. // ResetWxAgent resets all changes to the "wx_agent" edge.
  682. func (m *AgentMutation) ResetWxAgent() {
  683. m.wx_agent = nil
  684. m.clearedwx_agent = false
  685. m.removedwx_agent = nil
  686. }
  687. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  688. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  689. if m.token_agent == nil {
  690. m.token_agent = make(map[uint64]struct{})
  691. }
  692. for i := range ids {
  693. m.token_agent[ids[i]] = struct{}{}
  694. }
  695. }
  696. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  697. func (m *AgentMutation) ClearTokenAgent() {
  698. m.clearedtoken_agent = true
  699. }
  700. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  701. func (m *AgentMutation) TokenAgentCleared() bool {
  702. return m.clearedtoken_agent
  703. }
  704. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  705. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  706. if m.removedtoken_agent == nil {
  707. m.removedtoken_agent = make(map[uint64]struct{})
  708. }
  709. for i := range ids {
  710. delete(m.token_agent, ids[i])
  711. m.removedtoken_agent[ids[i]] = struct{}{}
  712. }
  713. }
  714. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  715. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  716. for id := range m.removedtoken_agent {
  717. ids = append(ids, id)
  718. }
  719. return
  720. }
  721. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  722. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  723. for id := range m.token_agent {
  724. ids = append(ids, id)
  725. }
  726. return
  727. }
  728. // ResetTokenAgent resets all changes to the "token_agent" edge.
  729. func (m *AgentMutation) ResetTokenAgent() {
  730. m.token_agent = nil
  731. m.clearedtoken_agent = false
  732. m.removedtoken_agent = nil
  733. }
  734. // Where appends a list predicates to the AgentMutation builder.
  735. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  736. m.predicates = append(m.predicates, ps...)
  737. }
  738. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  739. // users can use type-assertion to append predicates that do not depend on any generated package.
  740. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  741. p := make([]predicate.Agent, len(ps))
  742. for i := range ps {
  743. p[i] = ps[i]
  744. }
  745. m.Where(p...)
  746. }
  747. // Op returns the operation name.
  748. func (m *AgentMutation) Op() Op {
  749. return m.op
  750. }
  751. // SetOp allows setting the mutation operation.
  752. func (m *AgentMutation) SetOp(op Op) {
  753. m.op = op
  754. }
  755. // Type returns the node type of this mutation (Agent).
  756. func (m *AgentMutation) Type() string {
  757. return m.typ
  758. }
  759. // Fields returns all fields that were changed during this mutation. Note that in
  760. // order to get all numeric fields that were incremented/decremented, call
  761. // AddedFields().
  762. func (m *AgentMutation) Fields() []string {
  763. fields := make([]string, 0, 11)
  764. if m.created_at != nil {
  765. fields = append(fields, agent.FieldCreatedAt)
  766. }
  767. if m.updated_at != nil {
  768. fields = append(fields, agent.FieldUpdatedAt)
  769. }
  770. if m.deleted_at != nil {
  771. fields = append(fields, agent.FieldDeletedAt)
  772. }
  773. if m.name != nil {
  774. fields = append(fields, agent.FieldName)
  775. }
  776. if m.role != nil {
  777. fields = append(fields, agent.FieldRole)
  778. }
  779. if m.status != nil {
  780. fields = append(fields, agent.FieldStatus)
  781. }
  782. if m.background != nil {
  783. fields = append(fields, agent.FieldBackground)
  784. }
  785. if m.examples != nil {
  786. fields = append(fields, agent.FieldExamples)
  787. }
  788. if m.organization_id != nil {
  789. fields = append(fields, agent.FieldOrganizationID)
  790. }
  791. if m.dataset_id != nil {
  792. fields = append(fields, agent.FieldDatasetID)
  793. }
  794. if m.collection_id != nil {
  795. fields = append(fields, agent.FieldCollectionID)
  796. }
  797. return fields
  798. }
  799. // Field returns the value of a field with the given name. The second boolean
  800. // return value indicates that this field was not set, or was not defined in the
  801. // schema.
  802. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  803. switch name {
  804. case agent.FieldCreatedAt:
  805. return m.CreatedAt()
  806. case agent.FieldUpdatedAt:
  807. return m.UpdatedAt()
  808. case agent.FieldDeletedAt:
  809. return m.DeletedAt()
  810. case agent.FieldName:
  811. return m.Name()
  812. case agent.FieldRole:
  813. return m.Role()
  814. case agent.FieldStatus:
  815. return m.Status()
  816. case agent.FieldBackground:
  817. return m.Background()
  818. case agent.FieldExamples:
  819. return m.Examples()
  820. case agent.FieldOrganizationID:
  821. return m.OrganizationID()
  822. case agent.FieldDatasetID:
  823. return m.DatasetID()
  824. case agent.FieldCollectionID:
  825. return m.CollectionID()
  826. }
  827. return nil, false
  828. }
  829. // OldField returns the old value of the field from the database. An error is
  830. // returned if the mutation operation is not UpdateOne, or the query to the
  831. // database failed.
  832. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  833. switch name {
  834. case agent.FieldCreatedAt:
  835. return m.OldCreatedAt(ctx)
  836. case agent.FieldUpdatedAt:
  837. return m.OldUpdatedAt(ctx)
  838. case agent.FieldDeletedAt:
  839. return m.OldDeletedAt(ctx)
  840. case agent.FieldName:
  841. return m.OldName(ctx)
  842. case agent.FieldRole:
  843. return m.OldRole(ctx)
  844. case agent.FieldStatus:
  845. return m.OldStatus(ctx)
  846. case agent.FieldBackground:
  847. return m.OldBackground(ctx)
  848. case agent.FieldExamples:
  849. return m.OldExamples(ctx)
  850. case agent.FieldOrganizationID:
  851. return m.OldOrganizationID(ctx)
  852. case agent.FieldDatasetID:
  853. return m.OldDatasetID(ctx)
  854. case agent.FieldCollectionID:
  855. return m.OldCollectionID(ctx)
  856. }
  857. return nil, fmt.Errorf("unknown Agent field %s", name)
  858. }
  859. // SetField sets the value of a field with the given name. It returns an error if
  860. // the field is not defined in the schema, or if the type mismatched the field
  861. // type.
  862. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  863. switch name {
  864. case agent.FieldCreatedAt:
  865. v, ok := value.(time.Time)
  866. if !ok {
  867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  868. }
  869. m.SetCreatedAt(v)
  870. return nil
  871. case agent.FieldUpdatedAt:
  872. v, ok := value.(time.Time)
  873. if !ok {
  874. return fmt.Errorf("unexpected type %T for field %s", value, name)
  875. }
  876. m.SetUpdatedAt(v)
  877. return nil
  878. case agent.FieldDeletedAt:
  879. v, ok := value.(time.Time)
  880. if !ok {
  881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  882. }
  883. m.SetDeletedAt(v)
  884. return nil
  885. case agent.FieldName:
  886. v, ok := value.(string)
  887. if !ok {
  888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  889. }
  890. m.SetName(v)
  891. return nil
  892. case agent.FieldRole:
  893. v, ok := value.(string)
  894. if !ok {
  895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  896. }
  897. m.SetRole(v)
  898. return nil
  899. case agent.FieldStatus:
  900. v, ok := value.(int)
  901. if !ok {
  902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  903. }
  904. m.SetStatus(v)
  905. return nil
  906. case agent.FieldBackground:
  907. v, ok := value.(string)
  908. if !ok {
  909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  910. }
  911. m.SetBackground(v)
  912. return nil
  913. case agent.FieldExamples:
  914. v, ok := value.(string)
  915. if !ok {
  916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  917. }
  918. m.SetExamples(v)
  919. return nil
  920. case agent.FieldOrganizationID:
  921. v, ok := value.(uint64)
  922. if !ok {
  923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  924. }
  925. m.SetOrganizationID(v)
  926. return nil
  927. case agent.FieldDatasetID:
  928. v, ok := value.(string)
  929. if !ok {
  930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  931. }
  932. m.SetDatasetID(v)
  933. return nil
  934. case agent.FieldCollectionID:
  935. v, ok := value.(string)
  936. if !ok {
  937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  938. }
  939. m.SetCollectionID(v)
  940. return nil
  941. }
  942. return fmt.Errorf("unknown Agent field %s", name)
  943. }
  944. // AddedFields returns all numeric fields that were incremented/decremented during
  945. // this mutation.
  946. func (m *AgentMutation) AddedFields() []string {
  947. var fields []string
  948. if m.addstatus != nil {
  949. fields = append(fields, agent.FieldStatus)
  950. }
  951. if m.addorganization_id != nil {
  952. fields = append(fields, agent.FieldOrganizationID)
  953. }
  954. return fields
  955. }
  956. // AddedField returns the numeric value that was incremented/decremented on a field
  957. // with the given name. The second boolean return value indicates that this field
  958. // was not set, or was not defined in the schema.
  959. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  960. switch name {
  961. case agent.FieldStatus:
  962. return m.AddedStatus()
  963. case agent.FieldOrganizationID:
  964. return m.AddedOrganizationID()
  965. }
  966. return nil, false
  967. }
  968. // AddField adds the value to the field with the given name. It returns an error if
  969. // the field is not defined in the schema, or if the type mismatched the field
  970. // type.
  971. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  972. switch name {
  973. case agent.FieldStatus:
  974. v, ok := value.(int)
  975. if !ok {
  976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  977. }
  978. m.AddStatus(v)
  979. return nil
  980. case agent.FieldOrganizationID:
  981. v, ok := value.(int64)
  982. if !ok {
  983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  984. }
  985. m.AddOrganizationID(v)
  986. return nil
  987. }
  988. return fmt.Errorf("unknown Agent numeric field %s", name)
  989. }
  990. // ClearedFields returns all nullable fields that were cleared during this
  991. // mutation.
  992. func (m *AgentMutation) ClearedFields() []string {
  993. var fields []string
  994. if m.FieldCleared(agent.FieldDeletedAt) {
  995. fields = append(fields, agent.FieldDeletedAt)
  996. }
  997. if m.FieldCleared(agent.FieldStatus) {
  998. fields = append(fields, agent.FieldStatus)
  999. }
  1000. if m.FieldCleared(agent.FieldBackground) {
  1001. fields = append(fields, agent.FieldBackground)
  1002. }
  1003. if m.FieldCleared(agent.FieldExamples) {
  1004. fields = append(fields, agent.FieldExamples)
  1005. }
  1006. return fields
  1007. }
  1008. // FieldCleared returns a boolean indicating if a field with the given name was
  1009. // cleared in this mutation.
  1010. func (m *AgentMutation) FieldCleared(name string) bool {
  1011. _, ok := m.clearedFields[name]
  1012. return ok
  1013. }
  1014. // ClearField clears the value of the field with the given name. It returns an
  1015. // error if the field is not defined in the schema.
  1016. func (m *AgentMutation) ClearField(name string) error {
  1017. switch name {
  1018. case agent.FieldDeletedAt:
  1019. m.ClearDeletedAt()
  1020. return nil
  1021. case agent.FieldStatus:
  1022. m.ClearStatus()
  1023. return nil
  1024. case agent.FieldBackground:
  1025. m.ClearBackground()
  1026. return nil
  1027. case agent.FieldExamples:
  1028. m.ClearExamples()
  1029. return nil
  1030. }
  1031. return fmt.Errorf("unknown Agent nullable field %s", name)
  1032. }
  1033. // ResetField resets all changes in the mutation for the field with the given name.
  1034. // It returns an error if the field is not defined in the schema.
  1035. func (m *AgentMutation) ResetField(name string) error {
  1036. switch name {
  1037. case agent.FieldCreatedAt:
  1038. m.ResetCreatedAt()
  1039. return nil
  1040. case agent.FieldUpdatedAt:
  1041. m.ResetUpdatedAt()
  1042. return nil
  1043. case agent.FieldDeletedAt:
  1044. m.ResetDeletedAt()
  1045. return nil
  1046. case agent.FieldName:
  1047. m.ResetName()
  1048. return nil
  1049. case agent.FieldRole:
  1050. m.ResetRole()
  1051. return nil
  1052. case agent.FieldStatus:
  1053. m.ResetStatus()
  1054. return nil
  1055. case agent.FieldBackground:
  1056. m.ResetBackground()
  1057. return nil
  1058. case agent.FieldExamples:
  1059. m.ResetExamples()
  1060. return nil
  1061. case agent.FieldOrganizationID:
  1062. m.ResetOrganizationID()
  1063. return nil
  1064. case agent.FieldDatasetID:
  1065. m.ResetDatasetID()
  1066. return nil
  1067. case agent.FieldCollectionID:
  1068. m.ResetCollectionID()
  1069. return nil
  1070. }
  1071. return fmt.Errorf("unknown Agent field %s", name)
  1072. }
  1073. // AddedEdges returns all edge names that were set/added in this mutation.
  1074. func (m *AgentMutation) AddedEdges() []string {
  1075. edges := make([]string, 0, 2)
  1076. if m.wx_agent != nil {
  1077. edges = append(edges, agent.EdgeWxAgent)
  1078. }
  1079. if m.token_agent != nil {
  1080. edges = append(edges, agent.EdgeTokenAgent)
  1081. }
  1082. return edges
  1083. }
  1084. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1085. // name in this mutation.
  1086. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1087. switch name {
  1088. case agent.EdgeWxAgent:
  1089. ids := make([]ent.Value, 0, len(m.wx_agent))
  1090. for id := range m.wx_agent {
  1091. ids = append(ids, id)
  1092. }
  1093. return ids
  1094. case agent.EdgeTokenAgent:
  1095. ids := make([]ent.Value, 0, len(m.token_agent))
  1096. for id := range m.token_agent {
  1097. ids = append(ids, id)
  1098. }
  1099. return ids
  1100. }
  1101. return nil
  1102. }
  1103. // RemovedEdges returns all edge names that were removed in this mutation.
  1104. func (m *AgentMutation) RemovedEdges() []string {
  1105. edges := make([]string, 0, 2)
  1106. if m.removedwx_agent != nil {
  1107. edges = append(edges, agent.EdgeWxAgent)
  1108. }
  1109. if m.removedtoken_agent != nil {
  1110. edges = append(edges, agent.EdgeTokenAgent)
  1111. }
  1112. return edges
  1113. }
  1114. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1115. // the given name in this mutation.
  1116. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1117. switch name {
  1118. case agent.EdgeWxAgent:
  1119. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1120. for id := range m.removedwx_agent {
  1121. ids = append(ids, id)
  1122. }
  1123. return ids
  1124. case agent.EdgeTokenAgent:
  1125. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1126. for id := range m.removedtoken_agent {
  1127. ids = append(ids, id)
  1128. }
  1129. return ids
  1130. }
  1131. return nil
  1132. }
  1133. // ClearedEdges returns all edge names that were cleared in this mutation.
  1134. func (m *AgentMutation) ClearedEdges() []string {
  1135. edges := make([]string, 0, 2)
  1136. if m.clearedwx_agent {
  1137. edges = append(edges, agent.EdgeWxAgent)
  1138. }
  1139. if m.clearedtoken_agent {
  1140. edges = append(edges, agent.EdgeTokenAgent)
  1141. }
  1142. return edges
  1143. }
  1144. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1145. // was cleared in this mutation.
  1146. func (m *AgentMutation) EdgeCleared(name string) bool {
  1147. switch name {
  1148. case agent.EdgeWxAgent:
  1149. return m.clearedwx_agent
  1150. case agent.EdgeTokenAgent:
  1151. return m.clearedtoken_agent
  1152. }
  1153. return false
  1154. }
  1155. // ClearEdge clears the value of the edge with the given name. It returns an error
  1156. // if that edge is not defined in the schema.
  1157. func (m *AgentMutation) ClearEdge(name string) error {
  1158. switch name {
  1159. }
  1160. return fmt.Errorf("unknown Agent unique edge %s", name)
  1161. }
  1162. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1163. // It returns an error if the edge is not defined in the schema.
  1164. func (m *AgentMutation) ResetEdge(name string) error {
  1165. switch name {
  1166. case agent.EdgeWxAgent:
  1167. m.ResetWxAgent()
  1168. return nil
  1169. case agent.EdgeTokenAgent:
  1170. m.ResetTokenAgent()
  1171. return nil
  1172. }
  1173. return fmt.Errorf("unknown Agent edge %s", name)
  1174. }
  1175. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1176. type AgentBaseMutation struct {
  1177. config
  1178. op Op
  1179. typ string
  1180. id *string
  1181. q *string
  1182. a *string
  1183. chunk_index *uint64
  1184. addchunk_index *int64
  1185. indexes *[]string
  1186. appendindexes []string
  1187. dataset_id *string
  1188. collection_id *string
  1189. source_name *string
  1190. can_write *[]bool
  1191. appendcan_write []bool
  1192. is_owner *[]bool
  1193. appendis_owner []bool
  1194. clearedFields map[string]struct{}
  1195. wx_agent map[uint64]struct{}
  1196. removedwx_agent map[uint64]struct{}
  1197. clearedwx_agent bool
  1198. done bool
  1199. oldValue func(context.Context) (*AgentBase, error)
  1200. predicates []predicate.AgentBase
  1201. }
  1202. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1203. // agentbaseOption allows management of the mutation configuration using functional options.
  1204. type agentbaseOption func(*AgentBaseMutation)
  1205. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1206. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1207. m := &AgentBaseMutation{
  1208. config: c,
  1209. op: op,
  1210. typ: TypeAgentBase,
  1211. clearedFields: make(map[string]struct{}),
  1212. }
  1213. for _, opt := range opts {
  1214. opt(m)
  1215. }
  1216. return m
  1217. }
  1218. // withAgentBaseID sets the ID field of the mutation.
  1219. func withAgentBaseID(id string) agentbaseOption {
  1220. return func(m *AgentBaseMutation) {
  1221. var (
  1222. err error
  1223. once sync.Once
  1224. value *AgentBase
  1225. )
  1226. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1227. once.Do(func() {
  1228. if m.done {
  1229. err = errors.New("querying old values post mutation is not allowed")
  1230. } else {
  1231. value, err = m.Client().AgentBase.Get(ctx, id)
  1232. }
  1233. })
  1234. return value, err
  1235. }
  1236. m.id = &id
  1237. }
  1238. }
  1239. // withAgentBase sets the old AgentBase of the mutation.
  1240. func withAgentBase(node *AgentBase) agentbaseOption {
  1241. return func(m *AgentBaseMutation) {
  1242. m.oldValue = func(context.Context) (*AgentBase, error) {
  1243. return node, nil
  1244. }
  1245. m.id = &node.ID
  1246. }
  1247. }
  1248. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1249. // executed in a transaction (ent.Tx), a transactional client is returned.
  1250. func (m AgentBaseMutation) Client() *Client {
  1251. client := &Client{config: m.config}
  1252. client.init()
  1253. return client
  1254. }
  1255. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1256. // it returns an error otherwise.
  1257. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1258. if _, ok := m.driver.(*txDriver); !ok {
  1259. return nil, errors.New("ent: mutation is not running in a transaction")
  1260. }
  1261. tx := &Tx{config: m.config}
  1262. tx.init()
  1263. return tx, nil
  1264. }
  1265. // SetID sets the value of the id field. Note that this
  1266. // operation is only accepted on creation of AgentBase entities.
  1267. func (m *AgentBaseMutation) SetID(id string) {
  1268. m.id = &id
  1269. }
  1270. // ID returns the ID value in the mutation. Note that the ID is only available
  1271. // if it was provided to the builder or after it was returned from the database.
  1272. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1273. if m.id == nil {
  1274. return
  1275. }
  1276. return *m.id, true
  1277. }
  1278. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1279. // That means, if the mutation is applied within a transaction with an isolation level such
  1280. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1281. // or updated by the mutation.
  1282. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1283. switch {
  1284. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1285. id, exists := m.ID()
  1286. if exists {
  1287. return []string{id}, nil
  1288. }
  1289. fallthrough
  1290. case m.op.Is(OpUpdate | OpDelete):
  1291. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1292. default:
  1293. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1294. }
  1295. }
  1296. // SetQ sets the "q" field.
  1297. func (m *AgentBaseMutation) SetQ(s string) {
  1298. m.q = &s
  1299. }
  1300. // Q returns the value of the "q" field in the mutation.
  1301. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1302. v := m.q
  1303. if v == nil {
  1304. return
  1305. }
  1306. return *v, true
  1307. }
  1308. // OldQ returns the old "q" field's value of the AgentBase entity.
  1309. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1310. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1311. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1312. if !m.op.Is(OpUpdateOne) {
  1313. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1314. }
  1315. if m.id == nil || m.oldValue == nil {
  1316. return v, errors.New("OldQ requires an ID field in the mutation")
  1317. }
  1318. oldValue, err := m.oldValue(ctx)
  1319. if err != nil {
  1320. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1321. }
  1322. return oldValue.Q, nil
  1323. }
  1324. // ClearQ clears the value of the "q" field.
  1325. func (m *AgentBaseMutation) ClearQ() {
  1326. m.q = nil
  1327. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1328. }
  1329. // QCleared returns if the "q" field was cleared in this mutation.
  1330. func (m *AgentBaseMutation) QCleared() bool {
  1331. _, ok := m.clearedFields[agentbase.FieldQ]
  1332. return ok
  1333. }
  1334. // ResetQ resets all changes to the "q" field.
  1335. func (m *AgentBaseMutation) ResetQ() {
  1336. m.q = nil
  1337. delete(m.clearedFields, agentbase.FieldQ)
  1338. }
  1339. // SetA sets the "a" field.
  1340. func (m *AgentBaseMutation) SetA(s string) {
  1341. m.a = &s
  1342. }
  1343. // A returns the value of the "a" field in the mutation.
  1344. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1345. v := m.a
  1346. if v == nil {
  1347. return
  1348. }
  1349. return *v, true
  1350. }
  1351. // OldA returns the old "a" field's value of the AgentBase entity.
  1352. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1353. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1354. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1355. if !m.op.Is(OpUpdateOne) {
  1356. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1357. }
  1358. if m.id == nil || m.oldValue == nil {
  1359. return v, errors.New("OldA requires an ID field in the mutation")
  1360. }
  1361. oldValue, err := m.oldValue(ctx)
  1362. if err != nil {
  1363. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1364. }
  1365. return oldValue.A, nil
  1366. }
  1367. // ClearA clears the value of the "a" field.
  1368. func (m *AgentBaseMutation) ClearA() {
  1369. m.a = nil
  1370. m.clearedFields[agentbase.FieldA] = struct{}{}
  1371. }
  1372. // ACleared returns if the "a" field was cleared in this mutation.
  1373. func (m *AgentBaseMutation) ACleared() bool {
  1374. _, ok := m.clearedFields[agentbase.FieldA]
  1375. return ok
  1376. }
  1377. // ResetA resets all changes to the "a" field.
  1378. func (m *AgentBaseMutation) ResetA() {
  1379. m.a = nil
  1380. delete(m.clearedFields, agentbase.FieldA)
  1381. }
  1382. // SetChunkIndex sets the "chunk_index" field.
  1383. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1384. m.chunk_index = &u
  1385. m.addchunk_index = nil
  1386. }
  1387. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1388. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1389. v := m.chunk_index
  1390. if v == nil {
  1391. return
  1392. }
  1393. return *v, true
  1394. }
  1395. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1396. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1397. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1398. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1399. if !m.op.Is(OpUpdateOne) {
  1400. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1401. }
  1402. if m.id == nil || m.oldValue == nil {
  1403. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1404. }
  1405. oldValue, err := m.oldValue(ctx)
  1406. if err != nil {
  1407. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1408. }
  1409. return oldValue.ChunkIndex, nil
  1410. }
  1411. // AddChunkIndex adds u to the "chunk_index" field.
  1412. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1413. if m.addchunk_index != nil {
  1414. *m.addchunk_index += u
  1415. } else {
  1416. m.addchunk_index = &u
  1417. }
  1418. }
  1419. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1420. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1421. v := m.addchunk_index
  1422. if v == nil {
  1423. return
  1424. }
  1425. return *v, true
  1426. }
  1427. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1428. func (m *AgentBaseMutation) ResetChunkIndex() {
  1429. m.chunk_index = nil
  1430. m.addchunk_index = nil
  1431. }
  1432. // SetIndexes sets the "indexes" field.
  1433. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1434. m.indexes = &s
  1435. m.appendindexes = nil
  1436. }
  1437. // Indexes returns the value of the "indexes" field in the mutation.
  1438. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1439. v := m.indexes
  1440. if v == nil {
  1441. return
  1442. }
  1443. return *v, true
  1444. }
  1445. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1446. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1447. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1448. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1449. if !m.op.Is(OpUpdateOne) {
  1450. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1451. }
  1452. if m.id == nil || m.oldValue == nil {
  1453. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1454. }
  1455. oldValue, err := m.oldValue(ctx)
  1456. if err != nil {
  1457. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1458. }
  1459. return oldValue.Indexes, nil
  1460. }
  1461. // AppendIndexes adds s to the "indexes" field.
  1462. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1463. m.appendindexes = append(m.appendindexes, s...)
  1464. }
  1465. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1466. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1467. if len(m.appendindexes) == 0 {
  1468. return nil, false
  1469. }
  1470. return m.appendindexes, true
  1471. }
  1472. // ClearIndexes clears the value of the "indexes" field.
  1473. func (m *AgentBaseMutation) ClearIndexes() {
  1474. m.indexes = nil
  1475. m.appendindexes = nil
  1476. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1477. }
  1478. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1479. func (m *AgentBaseMutation) IndexesCleared() bool {
  1480. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1481. return ok
  1482. }
  1483. // ResetIndexes resets all changes to the "indexes" field.
  1484. func (m *AgentBaseMutation) ResetIndexes() {
  1485. m.indexes = nil
  1486. m.appendindexes = nil
  1487. delete(m.clearedFields, agentbase.FieldIndexes)
  1488. }
  1489. // SetDatasetID sets the "dataset_id" field.
  1490. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1491. m.dataset_id = &s
  1492. }
  1493. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1494. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1495. v := m.dataset_id
  1496. if v == nil {
  1497. return
  1498. }
  1499. return *v, true
  1500. }
  1501. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1502. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1503. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1504. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1505. if !m.op.Is(OpUpdateOne) {
  1506. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1507. }
  1508. if m.id == nil || m.oldValue == nil {
  1509. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1510. }
  1511. oldValue, err := m.oldValue(ctx)
  1512. if err != nil {
  1513. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1514. }
  1515. return oldValue.DatasetID, nil
  1516. }
  1517. // ClearDatasetID clears the value of the "dataset_id" field.
  1518. func (m *AgentBaseMutation) ClearDatasetID() {
  1519. m.dataset_id = nil
  1520. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1521. }
  1522. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1523. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1524. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1525. return ok
  1526. }
  1527. // ResetDatasetID resets all changes to the "dataset_id" field.
  1528. func (m *AgentBaseMutation) ResetDatasetID() {
  1529. m.dataset_id = nil
  1530. delete(m.clearedFields, agentbase.FieldDatasetID)
  1531. }
  1532. // SetCollectionID sets the "collection_id" field.
  1533. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1534. m.collection_id = &s
  1535. }
  1536. // CollectionID returns the value of the "collection_id" field in the mutation.
  1537. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1538. v := m.collection_id
  1539. if v == nil {
  1540. return
  1541. }
  1542. return *v, true
  1543. }
  1544. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1545. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1546. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1547. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1548. if !m.op.Is(OpUpdateOne) {
  1549. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1550. }
  1551. if m.id == nil || m.oldValue == nil {
  1552. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1553. }
  1554. oldValue, err := m.oldValue(ctx)
  1555. if err != nil {
  1556. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1557. }
  1558. return oldValue.CollectionID, nil
  1559. }
  1560. // ClearCollectionID clears the value of the "collection_id" field.
  1561. func (m *AgentBaseMutation) ClearCollectionID() {
  1562. m.collection_id = nil
  1563. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1564. }
  1565. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1566. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1567. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1568. return ok
  1569. }
  1570. // ResetCollectionID resets all changes to the "collection_id" field.
  1571. func (m *AgentBaseMutation) ResetCollectionID() {
  1572. m.collection_id = nil
  1573. delete(m.clearedFields, agentbase.FieldCollectionID)
  1574. }
  1575. // SetSourceName sets the "source_name" field.
  1576. func (m *AgentBaseMutation) SetSourceName(s string) {
  1577. m.source_name = &s
  1578. }
  1579. // SourceName returns the value of the "source_name" field in the mutation.
  1580. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1581. v := m.source_name
  1582. if v == nil {
  1583. return
  1584. }
  1585. return *v, true
  1586. }
  1587. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1588. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1589. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1590. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1591. if !m.op.Is(OpUpdateOne) {
  1592. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1593. }
  1594. if m.id == nil || m.oldValue == nil {
  1595. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1596. }
  1597. oldValue, err := m.oldValue(ctx)
  1598. if err != nil {
  1599. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1600. }
  1601. return oldValue.SourceName, nil
  1602. }
  1603. // ClearSourceName clears the value of the "source_name" field.
  1604. func (m *AgentBaseMutation) ClearSourceName() {
  1605. m.source_name = nil
  1606. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1607. }
  1608. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1609. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1610. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1611. return ok
  1612. }
  1613. // ResetSourceName resets all changes to the "source_name" field.
  1614. func (m *AgentBaseMutation) ResetSourceName() {
  1615. m.source_name = nil
  1616. delete(m.clearedFields, agentbase.FieldSourceName)
  1617. }
  1618. // SetCanWrite sets the "can_write" field.
  1619. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1620. m.can_write = &b
  1621. m.appendcan_write = nil
  1622. }
  1623. // CanWrite returns the value of the "can_write" field in the mutation.
  1624. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1625. v := m.can_write
  1626. if v == nil {
  1627. return
  1628. }
  1629. return *v, true
  1630. }
  1631. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1632. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1633. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1634. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1635. if !m.op.Is(OpUpdateOne) {
  1636. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1637. }
  1638. if m.id == nil || m.oldValue == nil {
  1639. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1640. }
  1641. oldValue, err := m.oldValue(ctx)
  1642. if err != nil {
  1643. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1644. }
  1645. return oldValue.CanWrite, nil
  1646. }
  1647. // AppendCanWrite adds b to the "can_write" field.
  1648. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1649. m.appendcan_write = append(m.appendcan_write, b...)
  1650. }
  1651. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1652. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1653. if len(m.appendcan_write) == 0 {
  1654. return nil, false
  1655. }
  1656. return m.appendcan_write, true
  1657. }
  1658. // ClearCanWrite clears the value of the "can_write" field.
  1659. func (m *AgentBaseMutation) ClearCanWrite() {
  1660. m.can_write = nil
  1661. m.appendcan_write = nil
  1662. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1663. }
  1664. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1665. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1666. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1667. return ok
  1668. }
  1669. // ResetCanWrite resets all changes to the "can_write" field.
  1670. func (m *AgentBaseMutation) ResetCanWrite() {
  1671. m.can_write = nil
  1672. m.appendcan_write = nil
  1673. delete(m.clearedFields, agentbase.FieldCanWrite)
  1674. }
  1675. // SetIsOwner sets the "is_owner" field.
  1676. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1677. m.is_owner = &b
  1678. m.appendis_owner = nil
  1679. }
  1680. // IsOwner returns the value of the "is_owner" field in the mutation.
  1681. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1682. v := m.is_owner
  1683. if v == nil {
  1684. return
  1685. }
  1686. return *v, true
  1687. }
  1688. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1689. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1690. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1691. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1692. if !m.op.Is(OpUpdateOne) {
  1693. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1694. }
  1695. if m.id == nil || m.oldValue == nil {
  1696. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1697. }
  1698. oldValue, err := m.oldValue(ctx)
  1699. if err != nil {
  1700. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1701. }
  1702. return oldValue.IsOwner, nil
  1703. }
  1704. // AppendIsOwner adds b to the "is_owner" field.
  1705. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1706. m.appendis_owner = append(m.appendis_owner, b...)
  1707. }
  1708. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1709. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1710. if len(m.appendis_owner) == 0 {
  1711. return nil, false
  1712. }
  1713. return m.appendis_owner, true
  1714. }
  1715. // ClearIsOwner clears the value of the "is_owner" field.
  1716. func (m *AgentBaseMutation) ClearIsOwner() {
  1717. m.is_owner = nil
  1718. m.appendis_owner = nil
  1719. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1720. }
  1721. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1722. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1723. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1724. return ok
  1725. }
  1726. // ResetIsOwner resets all changes to the "is_owner" field.
  1727. func (m *AgentBaseMutation) ResetIsOwner() {
  1728. m.is_owner = nil
  1729. m.appendis_owner = nil
  1730. delete(m.clearedFields, agentbase.FieldIsOwner)
  1731. }
  1732. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1733. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1734. if m.wx_agent == nil {
  1735. m.wx_agent = make(map[uint64]struct{})
  1736. }
  1737. for i := range ids {
  1738. m.wx_agent[ids[i]] = struct{}{}
  1739. }
  1740. }
  1741. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1742. func (m *AgentBaseMutation) ClearWxAgent() {
  1743. m.clearedwx_agent = true
  1744. }
  1745. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  1746. func (m *AgentBaseMutation) WxAgentCleared() bool {
  1747. return m.clearedwx_agent
  1748. }
  1749. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  1750. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  1751. if m.removedwx_agent == nil {
  1752. m.removedwx_agent = make(map[uint64]struct{})
  1753. }
  1754. for i := range ids {
  1755. delete(m.wx_agent, ids[i])
  1756. m.removedwx_agent[ids[i]] = struct{}{}
  1757. }
  1758. }
  1759. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  1760. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  1761. for id := range m.removedwx_agent {
  1762. ids = append(ids, id)
  1763. }
  1764. return
  1765. }
  1766. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  1767. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  1768. for id := range m.wx_agent {
  1769. ids = append(ids, id)
  1770. }
  1771. return
  1772. }
  1773. // ResetWxAgent resets all changes to the "wx_agent" edge.
  1774. func (m *AgentBaseMutation) ResetWxAgent() {
  1775. m.wx_agent = nil
  1776. m.clearedwx_agent = false
  1777. m.removedwx_agent = nil
  1778. }
  1779. // Where appends a list predicates to the AgentBaseMutation builder.
  1780. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  1781. m.predicates = append(m.predicates, ps...)
  1782. }
  1783. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  1784. // users can use type-assertion to append predicates that do not depend on any generated package.
  1785. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  1786. p := make([]predicate.AgentBase, len(ps))
  1787. for i := range ps {
  1788. p[i] = ps[i]
  1789. }
  1790. m.Where(p...)
  1791. }
  1792. // Op returns the operation name.
  1793. func (m *AgentBaseMutation) Op() Op {
  1794. return m.op
  1795. }
  1796. // SetOp allows setting the mutation operation.
  1797. func (m *AgentBaseMutation) SetOp(op Op) {
  1798. m.op = op
  1799. }
  1800. // Type returns the node type of this mutation (AgentBase).
  1801. func (m *AgentBaseMutation) Type() string {
  1802. return m.typ
  1803. }
  1804. // Fields returns all fields that were changed during this mutation. Note that in
  1805. // order to get all numeric fields that were incremented/decremented, call
  1806. // AddedFields().
  1807. func (m *AgentBaseMutation) Fields() []string {
  1808. fields := make([]string, 0, 9)
  1809. if m.q != nil {
  1810. fields = append(fields, agentbase.FieldQ)
  1811. }
  1812. if m.a != nil {
  1813. fields = append(fields, agentbase.FieldA)
  1814. }
  1815. if m.chunk_index != nil {
  1816. fields = append(fields, agentbase.FieldChunkIndex)
  1817. }
  1818. if m.indexes != nil {
  1819. fields = append(fields, agentbase.FieldIndexes)
  1820. }
  1821. if m.dataset_id != nil {
  1822. fields = append(fields, agentbase.FieldDatasetID)
  1823. }
  1824. if m.collection_id != nil {
  1825. fields = append(fields, agentbase.FieldCollectionID)
  1826. }
  1827. if m.source_name != nil {
  1828. fields = append(fields, agentbase.FieldSourceName)
  1829. }
  1830. if m.can_write != nil {
  1831. fields = append(fields, agentbase.FieldCanWrite)
  1832. }
  1833. if m.is_owner != nil {
  1834. fields = append(fields, agentbase.FieldIsOwner)
  1835. }
  1836. return fields
  1837. }
  1838. // Field returns the value of a field with the given name. The second boolean
  1839. // return value indicates that this field was not set, or was not defined in the
  1840. // schema.
  1841. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  1842. switch name {
  1843. case agentbase.FieldQ:
  1844. return m.Q()
  1845. case agentbase.FieldA:
  1846. return m.A()
  1847. case agentbase.FieldChunkIndex:
  1848. return m.ChunkIndex()
  1849. case agentbase.FieldIndexes:
  1850. return m.Indexes()
  1851. case agentbase.FieldDatasetID:
  1852. return m.DatasetID()
  1853. case agentbase.FieldCollectionID:
  1854. return m.CollectionID()
  1855. case agentbase.FieldSourceName:
  1856. return m.SourceName()
  1857. case agentbase.FieldCanWrite:
  1858. return m.CanWrite()
  1859. case agentbase.FieldIsOwner:
  1860. return m.IsOwner()
  1861. }
  1862. return nil, false
  1863. }
  1864. // OldField returns the old value of the field from the database. An error is
  1865. // returned if the mutation operation is not UpdateOne, or the query to the
  1866. // database failed.
  1867. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1868. switch name {
  1869. case agentbase.FieldQ:
  1870. return m.OldQ(ctx)
  1871. case agentbase.FieldA:
  1872. return m.OldA(ctx)
  1873. case agentbase.FieldChunkIndex:
  1874. return m.OldChunkIndex(ctx)
  1875. case agentbase.FieldIndexes:
  1876. return m.OldIndexes(ctx)
  1877. case agentbase.FieldDatasetID:
  1878. return m.OldDatasetID(ctx)
  1879. case agentbase.FieldCollectionID:
  1880. return m.OldCollectionID(ctx)
  1881. case agentbase.FieldSourceName:
  1882. return m.OldSourceName(ctx)
  1883. case agentbase.FieldCanWrite:
  1884. return m.OldCanWrite(ctx)
  1885. case agentbase.FieldIsOwner:
  1886. return m.OldIsOwner(ctx)
  1887. }
  1888. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  1889. }
  1890. // SetField sets the value of a field with the given name. It returns an error if
  1891. // the field is not defined in the schema, or if the type mismatched the field
  1892. // type.
  1893. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  1894. switch name {
  1895. case agentbase.FieldQ:
  1896. v, ok := value.(string)
  1897. if !ok {
  1898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1899. }
  1900. m.SetQ(v)
  1901. return nil
  1902. case agentbase.FieldA:
  1903. v, ok := value.(string)
  1904. if !ok {
  1905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1906. }
  1907. m.SetA(v)
  1908. return nil
  1909. case agentbase.FieldChunkIndex:
  1910. v, ok := value.(uint64)
  1911. if !ok {
  1912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1913. }
  1914. m.SetChunkIndex(v)
  1915. return nil
  1916. case agentbase.FieldIndexes:
  1917. v, ok := value.([]string)
  1918. if !ok {
  1919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1920. }
  1921. m.SetIndexes(v)
  1922. return nil
  1923. case agentbase.FieldDatasetID:
  1924. v, ok := value.(string)
  1925. if !ok {
  1926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1927. }
  1928. m.SetDatasetID(v)
  1929. return nil
  1930. case agentbase.FieldCollectionID:
  1931. v, ok := value.(string)
  1932. if !ok {
  1933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1934. }
  1935. m.SetCollectionID(v)
  1936. return nil
  1937. case agentbase.FieldSourceName:
  1938. v, ok := value.(string)
  1939. if !ok {
  1940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1941. }
  1942. m.SetSourceName(v)
  1943. return nil
  1944. case agentbase.FieldCanWrite:
  1945. v, ok := value.([]bool)
  1946. if !ok {
  1947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1948. }
  1949. m.SetCanWrite(v)
  1950. return nil
  1951. case agentbase.FieldIsOwner:
  1952. v, ok := value.([]bool)
  1953. if !ok {
  1954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1955. }
  1956. m.SetIsOwner(v)
  1957. return nil
  1958. }
  1959. return fmt.Errorf("unknown AgentBase field %s", name)
  1960. }
  1961. // AddedFields returns all numeric fields that were incremented/decremented during
  1962. // this mutation.
  1963. func (m *AgentBaseMutation) AddedFields() []string {
  1964. var fields []string
  1965. if m.addchunk_index != nil {
  1966. fields = append(fields, agentbase.FieldChunkIndex)
  1967. }
  1968. return fields
  1969. }
  1970. // AddedField returns the numeric value that was incremented/decremented on a field
  1971. // with the given name. The second boolean return value indicates that this field
  1972. // was not set, or was not defined in the schema.
  1973. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  1974. switch name {
  1975. case agentbase.FieldChunkIndex:
  1976. return m.AddedChunkIndex()
  1977. }
  1978. return nil, false
  1979. }
  1980. // AddField adds the value to the field with the given name. It returns an error if
  1981. // the field is not defined in the schema, or if the type mismatched the field
  1982. // type.
  1983. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  1984. switch name {
  1985. case agentbase.FieldChunkIndex:
  1986. v, ok := value.(int64)
  1987. if !ok {
  1988. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1989. }
  1990. m.AddChunkIndex(v)
  1991. return nil
  1992. }
  1993. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  1994. }
  1995. // ClearedFields returns all nullable fields that were cleared during this
  1996. // mutation.
  1997. func (m *AgentBaseMutation) ClearedFields() []string {
  1998. var fields []string
  1999. if m.FieldCleared(agentbase.FieldQ) {
  2000. fields = append(fields, agentbase.FieldQ)
  2001. }
  2002. if m.FieldCleared(agentbase.FieldA) {
  2003. fields = append(fields, agentbase.FieldA)
  2004. }
  2005. if m.FieldCleared(agentbase.FieldIndexes) {
  2006. fields = append(fields, agentbase.FieldIndexes)
  2007. }
  2008. if m.FieldCleared(agentbase.FieldDatasetID) {
  2009. fields = append(fields, agentbase.FieldDatasetID)
  2010. }
  2011. if m.FieldCleared(agentbase.FieldCollectionID) {
  2012. fields = append(fields, agentbase.FieldCollectionID)
  2013. }
  2014. if m.FieldCleared(agentbase.FieldSourceName) {
  2015. fields = append(fields, agentbase.FieldSourceName)
  2016. }
  2017. if m.FieldCleared(agentbase.FieldCanWrite) {
  2018. fields = append(fields, agentbase.FieldCanWrite)
  2019. }
  2020. if m.FieldCleared(agentbase.FieldIsOwner) {
  2021. fields = append(fields, agentbase.FieldIsOwner)
  2022. }
  2023. return fields
  2024. }
  2025. // FieldCleared returns a boolean indicating if a field with the given name was
  2026. // cleared in this mutation.
  2027. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2028. _, ok := m.clearedFields[name]
  2029. return ok
  2030. }
  2031. // ClearField clears the value of the field with the given name. It returns an
  2032. // error if the field is not defined in the schema.
  2033. func (m *AgentBaseMutation) ClearField(name string) error {
  2034. switch name {
  2035. case agentbase.FieldQ:
  2036. m.ClearQ()
  2037. return nil
  2038. case agentbase.FieldA:
  2039. m.ClearA()
  2040. return nil
  2041. case agentbase.FieldIndexes:
  2042. m.ClearIndexes()
  2043. return nil
  2044. case agentbase.FieldDatasetID:
  2045. m.ClearDatasetID()
  2046. return nil
  2047. case agentbase.FieldCollectionID:
  2048. m.ClearCollectionID()
  2049. return nil
  2050. case agentbase.FieldSourceName:
  2051. m.ClearSourceName()
  2052. return nil
  2053. case agentbase.FieldCanWrite:
  2054. m.ClearCanWrite()
  2055. return nil
  2056. case agentbase.FieldIsOwner:
  2057. m.ClearIsOwner()
  2058. return nil
  2059. }
  2060. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2061. }
  2062. // ResetField resets all changes in the mutation for the field with the given name.
  2063. // It returns an error if the field is not defined in the schema.
  2064. func (m *AgentBaseMutation) ResetField(name string) error {
  2065. switch name {
  2066. case agentbase.FieldQ:
  2067. m.ResetQ()
  2068. return nil
  2069. case agentbase.FieldA:
  2070. m.ResetA()
  2071. return nil
  2072. case agentbase.FieldChunkIndex:
  2073. m.ResetChunkIndex()
  2074. return nil
  2075. case agentbase.FieldIndexes:
  2076. m.ResetIndexes()
  2077. return nil
  2078. case agentbase.FieldDatasetID:
  2079. m.ResetDatasetID()
  2080. return nil
  2081. case agentbase.FieldCollectionID:
  2082. m.ResetCollectionID()
  2083. return nil
  2084. case agentbase.FieldSourceName:
  2085. m.ResetSourceName()
  2086. return nil
  2087. case agentbase.FieldCanWrite:
  2088. m.ResetCanWrite()
  2089. return nil
  2090. case agentbase.FieldIsOwner:
  2091. m.ResetIsOwner()
  2092. return nil
  2093. }
  2094. return fmt.Errorf("unknown AgentBase field %s", name)
  2095. }
  2096. // AddedEdges returns all edge names that were set/added in this mutation.
  2097. func (m *AgentBaseMutation) AddedEdges() []string {
  2098. edges := make([]string, 0, 1)
  2099. if m.wx_agent != nil {
  2100. edges = append(edges, agentbase.EdgeWxAgent)
  2101. }
  2102. return edges
  2103. }
  2104. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2105. // name in this mutation.
  2106. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2107. switch name {
  2108. case agentbase.EdgeWxAgent:
  2109. ids := make([]ent.Value, 0, len(m.wx_agent))
  2110. for id := range m.wx_agent {
  2111. ids = append(ids, id)
  2112. }
  2113. return ids
  2114. }
  2115. return nil
  2116. }
  2117. // RemovedEdges returns all edge names that were removed in this mutation.
  2118. func (m *AgentBaseMutation) RemovedEdges() []string {
  2119. edges := make([]string, 0, 1)
  2120. if m.removedwx_agent != nil {
  2121. edges = append(edges, agentbase.EdgeWxAgent)
  2122. }
  2123. return edges
  2124. }
  2125. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2126. // the given name in this mutation.
  2127. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2128. switch name {
  2129. case agentbase.EdgeWxAgent:
  2130. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2131. for id := range m.removedwx_agent {
  2132. ids = append(ids, id)
  2133. }
  2134. return ids
  2135. }
  2136. return nil
  2137. }
  2138. // ClearedEdges returns all edge names that were cleared in this mutation.
  2139. func (m *AgentBaseMutation) ClearedEdges() []string {
  2140. edges := make([]string, 0, 1)
  2141. if m.clearedwx_agent {
  2142. edges = append(edges, agentbase.EdgeWxAgent)
  2143. }
  2144. return edges
  2145. }
  2146. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2147. // was cleared in this mutation.
  2148. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2149. switch name {
  2150. case agentbase.EdgeWxAgent:
  2151. return m.clearedwx_agent
  2152. }
  2153. return false
  2154. }
  2155. // ClearEdge clears the value of the edge with the given name. It returns an error
  2156. // if that edge is not defined in the schema.
  2157. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2158. switch name {
  2159. }
  2160. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2161. }
  2162. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2163. // It returns an error if the edge is not defined in the schema.
  2164. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2165. switch name {
  2166. case agentbase.EdgeWxAgent:
  2167. m.ResetWxAgent()
  2168. return nil
  2169. }
  2170. return fmt.Errorf("unknown AgentBase edge %s", name)
  2171. }
  2172. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2173. type AliyunAvatarMutation struct {
  2174. config
  2175. op Op
  2176. typ string
  2177. id *uint64
  2178. created_at *time.Time
  2179. updated_at *time.Time
  2180. deleted_at *time.Time
  2181. user_id *uint64
  2182. adduser_id *int64
  2183. biz_id *string
  2184. access_key_id *string
  2185. access_key_secret *string
  2186. app_id *string
  2187. tenant_id *uint64
  2188. addtenant_id *int64
  2189. response *string
  2190. token *string
  2191. session_id *string
  2192. clearedFields map[string]struct{}
  2193. done bool
  2194. oldValue func(context.Context) (*AliyunAvatar, error)
  2195. predicates []predicate.AliyunAvatar
  2196. }
  2197. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2198. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2199. type aliyunavatarOption func(*AliyunAvatarMutation)
  2200. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2201. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2202. m := &AliyunAvatarMutation{
  2203. config: c,
  2204. op: op,
  2205. typ: TypeAliyunAvatar,
  2206. clearedFields: make(map[string]struct{}),
  2207. }
  2208. for _, opt := range opts {
  2209. opt(m)
  2210. }
  2211. return m
  2212. }
  2213. // withAliyunAvatarID sets the ID field of the mutation.
  2214. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2215. return func(m *AliyunAvatarMutation) {
  2216. var (
  2217. err error
  2218. once sync.Once
  2219. value *AliyunAvatar
  2220. )
  2221. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2222. once.Do(func() {
  2223. if m.done {
  2224. err = errors.New("querying old values post mutation is not allowed")
  2225. } else {
  2226. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2227. }
  2228. })
  2229. return value, err
  2230. }
  2231. m.id = &id
  2232. }
  2233. }
  2234. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2235. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2236. return func(m *AliyunAvatarMutation) {
  2237. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2238. return node, nil
  2239. }
  2240. m.id = &node.ID
  2241. }
  2242. }
  2243. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2244. // executed in a transaction (ent.Tx), a transactional client is returned.
  2245. func (m AliyunAvatarMutation) Client() *Client {
  2246. client := &Client{config: m.config}
  2247. client.init()
  2248. return client
  2249. }
  2250. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2251. // it returns an error otherwise.
  2252. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2253. if _, ok := m.driver.(*txDriver); !ok {
  2254. return nil, errors.New("ent: mutation is not running in a transaction")
  2255. }
  2256. tx := &Tx{config: m.config}
  2257. tx.init()
  2258. return tx, nil
  2259. }
  2260. // SetID sets the value of the id field. Note that this
  2261. // operation is only accepted on creation of AliyunAvatar entities.
  2262. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2263. m.id = &id
  2264. }
  2265. // ID returns the ID value in the mutation. Note that the ID is only available
  2266. // if it was provided to the builder or after it was returned from the database.
  2267. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2268. if m.id == nil {
  2269. return
  2270. }
  2271. return *m.id, true
  2272. }
  2273. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2274. // That means, if the mutation is applied within a transaction with an isolation level such
  2275. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2276. // or updated by the mutation.
  2277. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2278. switch {
  2279. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2280. id, exists := m.ID()
  2281. if exists {
  2282. return []uint64{id}, nil
  2283. }
  2284. fallthrough
  2285. case m.op.Is(OpUpdate | OpDelete):
  2286. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2287. default:
  2288. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2289. }
  2290. }
  2291. // SetCreatedAt sets the "created_at" field.
  2292. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2293. m.created_at = &t
  2294. }
  2295. // CreatedAt returns the value of the "created_at" field in the mutation.
  2296. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2297. v := m.created_at
  2298. if v == nil {
  2299. return
  2300. }
  2301. return *v, true
  2302. }
  2303. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2304. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2305. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2306. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2307. if !m.op.Is(OpUpdateOne) {
  2308. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2309. }
  2310. if m.id == nil || m.oldValue == nil {
  2311. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2312. }
  2313. oldValue, err := m.oldValue(ctx)
  2314. if err != nil {
  2315. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2316. }
  2317. return oldValue.CreatedAt, nil
  2318. }
  2319. // ResetCreatedAt resets all changes to the "created_at" field.
  2320. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2321. m.created_at = nil
  2322. }
  2323. // SetUpdatedAt sets the "updated_at" field.
  2324. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2325. m.updated_at = &t
  2326. }
  2327. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2328. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2329. v := m.updated_at
  2330. if v == nil {
  2331. return
  2332. }
  2333. return *v, true
  2334. }
  2335. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2336. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2337. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2338. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2339. if !m.op.Is(OpUpdateOne) {
  2340. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2341. }
  2342. if m.id == nil || m.oldValue == nil {
  2343. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2344. }
  2345. oldValue, err := m.oldValue(ctx)
  2346. if err != nil {
  2347. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2348. }
  2349. return oldValue.UpdatedAt, nil
  2350. }
  2351. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2352. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2353. m.updated_at = nil
  2354. }
  2355. // SetDeletedAt sets the "deleted_at" field.
  2356. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2357. m.deleted_at = &t
  2358. }
  2359. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2360. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2361. v := m.deleted_at
  2362. if v == nil {
  2363. return
  2364. }
  2365. return *v, true
  2366. }
  2367. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2368. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2369. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2370. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2371. if !m.op.Is(OpUpdateOne) {
  2372. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2373. }
  2374. if m.id == nil || m.oldValue == nil {
  2375. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2376. }
  2377. oldValue, err := m.oldValue(ctx)
  2378. if err != nil {
  2379. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2380. }
  2381. return oldValue.DeletedAt, nil
  2382. }
  2383. // ClearDeletedAt clears the value of the "deleted_at" field.
  2384. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2385. m.deleted_at = nil
  2386. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2387. }
  2388. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2389. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2390. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2391. return ok
  2392. }
  2393. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2394. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2395. m.deleted_at = nil
  2396. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2397. }
  2398. // SetUserID sets the "user_id" field.
  2399. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2400. m.user_id = &u
  2401. m.adduser_id = nil
  2402. }
  2403. // UserID returns the value of the "user_id" field in the mutation.
  2404. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2405. v := m.user_id
  2406. if v == nil {
  2407. return
  2408. }
  2409. return *v, true
  2410. }
  2411. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2412. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2413. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2414. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2415. if !m.op.Is(OpUpdateOne) {
  2416. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2417. }
  2418. if m.id == nil || m.oldValue == nil {
  2419. return v, errors.New("OldUserID requires an ID field in the mutation")
  2420. }
  2421. oldValue, err := m.oldValue(ctx)
  2422. if err != nil {
  2423. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2424. }
  2425. return oldValue.UserID, nil
  2426. }
  2427. // AddUserID adds u to the "user_id" field.
  2428. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2429. if m.adduser_id != nil {
  2430. *m.adduser_id += u
  2431. } else {
  2432. m.adduser_id = &u
  2433. }
  2434. }
  2435. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2436. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2437. v := m.adduser_id
  2438. if v == nil {
  2439. return
  2440. }
  2441. return *v, true
  2442. }
  2443. // ResetUserID resets all changes to the "user_id" field.
  2444. func (m *AliyunAvatarMutation) ResetUserID() {
  2445. m.user_id = nil
  2446. m.adduser_id = nil
  2447. }
  2448. // SetBizID sets the "biz_id" field.
  2449. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2450. m.biz_id = &s
  2451. }
  2452. // BizID returns the value of the "biz_id" field in the mutation.
  2453. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2454. v := m.biz_id
  2455. if v == nil {
  2456. return
  2457. }
  2458. return *v, true
  2459. }
  2460. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2461. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2462. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2463. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2464. if !m.op.Is(OpUpdateOne) {
  2465. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2466. }
  2467. if m.id == nil || m.oldValue == nil {
  2468. return v, errors.New("OldBizID requires an ID field in the mutation")
  2469. }
  2470. oldValue, err := m.oldValue(ctx)
  2471. if err != nil {
  2472. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2473. }
  2474. return oldValue.BizID, nil
  2475. }
  2476. // ResetBizID resets all changes to the "biz_id" field.
  2477. func (m *AliyunAvatarMutation) ResetBizID() {
  2478. m.biz_id = nil
  2479. }
  2480. // SetAccessKeyID sets the "access_key_id" field.
  2481. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2482. m.access_key_id = &s
  2483. }
  2484. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2485. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2486. v := m.access_key_id
  2487. if v == nil {
  2488. return
  2489. }
  2490. return *v, true
  2491. }
  2492. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2493. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2494. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2495. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2496. if !m.op.Is(OpUpdateOne) {
  2497. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2498. }
  2499. if m.id == nil || m.oldValue == nil {
  2500. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2501. }
  2502. oldValue, err := m.oldValue(ctx)
  2503. if err != nil {
  2504. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2505. }
  2506. return oldValue.AccessKeyID, nil
  2507. }
  2508. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2509. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2510. m.access_key_id = nil
  2511. }
  2512. // SetAccessKeySecret sets the "access_key_secret" field.
  2513. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2514. m.access_key_secret = &s
  2515. }
  2516. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2517. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2518. v := m.access_key_secret
  2519. if v == nil {
  2520. return
  2521. }
  2522. return *v, true
  2523. }
  2524. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2525. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2526. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2527. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2528. if !m.op.Is(OpUpdateOne) {
  2529. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2530. }
  2531. if m.id == nil || m.oldValue == nil {
  2532. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2533. }
  2534. oldValue, err := m.oldValue(ctx)
  2535. if err != nil {
  2536. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2537. }
  2538. return oldValue.AccessKeySecret, nil
  2539. }
  2540. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2541. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2542. m.access_key_secret = nil
  2543. }
  2544. // SetAppID sets the "app_id" field.
  2545. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2546. m.app_id = &s
  2547. }
  2548. // AppID returns the value of the "app_id" field in the mutation.
  2549. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2550. v := m.app_id
  2551. if v == nil {
  2552. return
  2553. }
  2554. return *v, true
  2555. }
  2556. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2557. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2558. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2559. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2560. if !m.op.Is(OpUpdateOne) {
  2561. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2562. }
  2563. if m.id == nil || m.oldValue == nil {
  2564. return v, errors.New("OldAppID requires an ID field in the mutation")
  2565. }
  2566. oldValue, err := m.oldValue(ctx)
  2567. if err != nil {
  2568. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2569. }
  2570. return oldValue.AppID, nil
  2571. }
  2572. // ClearAppID clears the value of the "app_id" field.
  2573. func (m *AliyunAvatarMutation) ClearAppID() {
  2574. m.app_id = nil
  2575. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2576. }
  2577. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2578. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2579. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2580. return ok
  2581. }
  2582. // ResetAppID resets all changes to the "app_id" field.
  2583. func (m *AliyunAvatarMutation) ResetAppID() {
  2584. m.app_id = nil
  2585. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2586. }
  2587. // SetTenantID sets the "tenant_id" field.
  2588. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2589. m.tenant_id = &u
  2590. m.addtenant_id = nil
  2591. }
  2592. // TenantID returns the value of the "tenant_id" field in the mutation.
  2593. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2594. v := m.tenant_id
  2595. if v == nil {
  2596. return
  2597. }
  2598. return *v, true
  2599. }
  2600. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  2601. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2602. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2603. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  2604. if !m.op.Is(OpUpdateOne) {
  2605. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2606. }
  2607. if m.id == nil || m.oldValue == nil {
  2608. return v, errors.New("OldTenantID requires an ID field in the mutation")
  2609. }
  2610. oldValue, err := m.oldValue(ctx)
  2611. if err != nil {
  2612. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  2613. }
  2614. return oldValue.TenantID, nil
  2615. }
  2616. // AddTenantID adds u to the "tenant_id" field.
  2617. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2618. if m.addtenant_id != nil {
  2619. *m.addtenant_id += u
  2620. } else {
  2621. m.addtenant_id = &u
  2622. }
  2623. }
  2624. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2625. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2626. v := m.addtenant_id
  2627. if v == nil {
  2628. return
  2629. }
  2630. return *v, true
  2631. }
  2632. // ResetTenantID resets all changes to the "tenant_id" field.
  2633. func (m *AliyunAvatarMutation) ResetTenantID() {
  2634. m.tenant_id = nil
  2635. m.addtenant_id = nil
  2636. }
  2637. // SetResponse sets the "response" field.
  2638. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2639. m.response = &s
  2640. }
  2641. // Response returns the value of the "response" field in the mutation.
  2642. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2643. v := m.response
  2644. if v == nil {
  2645. return
  2646. }
  2647. return *v, true
  2648. }
  2649. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2650. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2652. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2653. if !m.op.Is(OpUpdateOne) {
  2654. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2655. }
  2656. if m.id == nil || m.oldValue == nil {
  2657. return v, errors.New("OldResponse requires an ID field in the mutation")
  2658. }
  2659. oldValue, err := m.oldValue(ctx)
  2660. if err != nil {
  2661. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2662. }
  2663. return oldValue.Response, nil
  2664. }
  2665. // ResetResponse resets all changes to the "response" field.
  2666. func (m *AliyunAvatarMutation) ResetResponse() {
  2667. m.response = nil
  2668. }
  2669. // SetToken sets the "token" field.
  2670. func (m *AliyunAvatarMutation) SetToken(s string) {
  2671. m.token = &s
  2672. }
  2673. // Token returns the value of the "token" field in the mutation.
  2674. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  2675. v := m.token
  2676. if v == nil {
  2677. return
  2678. }
  2679. return *v, true
  2680. }
  2681. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  2682. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2683. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2684. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  2685. if !m.op.Is(OpUpdateOne) {
  2686. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  2687. }
  2688. if m.id == nil || m.oldValue == nil {
  2689. return v, errors.New("OldToken requires an ID field in the mutation")
  2690. }
  2691. oldValue, err := m.oldValue(ctx)
  2692. if err != nil {
  2693. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  2694. }
  2695. return oldValue.Token, nil
  2696. }
  2697. // ResetToken resets all changes to the "token" field.
  2698. func (m *AliyunAvatarMutation) ResetToken() {
  2699. m.token = nil
  2700. }
  2701. // SetSessionID sets the "session_id" field.
  2702. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  2703. m.session_id = &s
  2704. }
  2705. // SessionID returns the value of the "session_id" field in the mutation.
  2706. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  2707. v := m.session_id
  2708. if v == nil {
  2709. return
  2710. }
  2711. return *v, true
  2712. }
  2713. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  2714. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2715. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2716. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  2717. if !m.op.Is(OpUpdateOne) {
  2718. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  2719. }
  2720. if m.id == nil || m.oldValue == nil {
  2721. return v, errors.New("OldSessionID requires an ID field in the mutation")
  2722. }
  2723. oldValue, err := m.oldValue(ctx)
  2724. if err != nil {
  2725. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  2726. }
  2727. return oldValue.SessionID, nil
  2728. }
  2729. // ResetSessionID resets all changes to the "session_id" field.
  2730. func (m *AliyunAvatarMutation) ResetSessionID() {
  2731. m.session_id = nil
  2732. }
  2733. // Where appends a list predicates to the AliyunAvatarMutation builder.
  2734. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  2735. m.predicates = append(m.predicates, ps...)
  2736. }
  2737. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  2738. // users can use type-assertion to append predicates that do not depend on any generated package.
  2739. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  2740. p := make([]predicate.AliyunAvatar, len(ps))
  2741. for i := range ps {
  2742. p[i] = ps[i]
  2743. }
  2744. m.Where(p...)
  2745. }
  2746. // Op returns the operation name.
  2747. func (m *AliyunAvatarMutation) Op() Op {
  2748. return m.op
  2749. }
  2750. // SetOp allows setting the mutation operation.
  2751. func (m *AliyunAvatarMutation) SetOp(op Op) {
  2752. m.op = op
  2753. }
  2754. // Type returns the node type of this mutation (AliyunAvatar).
  2755. func (m *AliyunAvatarMutation) Type() string {
  2756. return m.typ
  2757. }
  2758. // Fields returns all fields that were changed during this mutation. Note that in
  2759. // order to get all numeric fields that were incremented/decremented, call
  2760. // AddedFields().
  2761. func (m *AliyunAvatarMutation) Fields() []string {
  2762. fields := make([]string, 0, 12)
  2763. if m.created_at != nil {
  2764. fields = append(fields, aliyunavatar.FieldCreatedAt)
  2765. }
  2766. if m.updated_at != nil {
  2767. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  2768. }
  2769. if m.deleted_at != nil {
  2770. fields = append(fields, aliyunavatar.FieldDeletedAt)
  2771. }
  2772. if m.user_id != nil {
  2773. fields = append(fields, aliyunavatar.FieldUserID)
  2774. }
  2775. if m.biz_id != nil {
  2776. fields = append(fields, aliyunavatar.FieldBizID)
  2777. }
  2778. if m.access_key_id != nil {
  2779. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  2780. }
  2781. if m.access_key_secret != nil {
  2782. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  2783. }
  2784. if m.app_id != nil {
  2785. fields = append(fields, aliyunavatar.FieldAppID)
  2786. }
  2787. if m.tenant_id != nil {
  2788. fields = append(fields, aliyunavatar.FieldTenantID)
  2789. }
  2790. if m.response != nil {
  2791. fields = append(fields, aliyunavatar.FieldResponse)
  2792. }
  2793. if m.token != nil {
  2794. fields = append(fields, aliyunavatar.FieldToken)
  2795. }
  2796. if m.session_id != nil {
  2797. fields = append(fields, aliyunavatar.FieldSessionID)
  2798. }
  2799. return fields
  2800. }
  2801. // Field returns the value of a field with the given name. The second boolean
  2802. // return value indicates that this field was not set, or was not defined in the
  2803. // schema.
  2804. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  2805. switch name {
  2806. case aliyunavatar.FieldCreatedAt:
  2807. return m.CreatedAt()
  2808. case aliyunavatar.FieldUpdatedAt:
  2809. return m.UpdatedAt()
  2810. case aliyunavatar.FieldDeletedAt:
  2811. return m.DeletedAt()
  2812. case aliyunavatar.FieldUserID:
  2813. return m.UserID()
  2814. case aliyunavatar.FieldBizID:
  2815. return m.BizID()
  2816. case aliyunavatar.FieldAccessKeyID:
  2817. return m.AccessKeyID()
  2818. case aliyunavatar.FieldAccessKeySecret:
  2819. return m.AccessKeySecret()
  2820. case aliyunavatar.FieldAppID:
  2821. return m.AppID()
  2822. case aliyunavatar.FieldTenantID:
  2823. return m.TenantID()
  2824. case aliyunavatar.FieldResponse:
  2825. return m.Response()
  2826. case aliyunavatar.FieldToken:
  2827. return m.Token()
  2828. case aliyunavatar.FieldSessionID:
  2829. return m.SessionID()
  2830. }
  2831. return nil, false
  2832. }
  2833. // OldField returns the old value of the field from the database. An error is
  2834. // returned if the mutation operation is not UpdateOne, or the query to the
  2835. // database failed.
  2836. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2837. switch name {
  2838. case aliyunavatar.FieldCreatedAt:
  2839. return m.OldCreatedAt(ctx)
  2840. case aliyunavatar.FieldUpdatedAt:
  2841. return m.OldUpdatedAt(ctx)
  2842. case aliyunavatar.FieldDeletedAt:
  2843. return m.OldDeletedAt(ctx)
  2844. case aliyunavatar.FieldUserID:
  2845. return m.OldUserID(ctx)
  2846. case aliyunavatar.FieldBizID:
  2847. return m.OldBizID(ctx)
  2848. case aliyunavatar.FieldAccessKeyID:
  2849. return m.OldAccessKeyID(ctx)
  2850. case aliyunavatar.FieldAccessKeySecret:
  2851. return m.OldAccessKeySecret(ctx)
  2852. case aliyunavatar.FieldAppID:
  2853. return m.OldAppID(ctx)
  2854. case aliyunavatar.FieldTenantID:
  2855. return m.OldTenantID(ctx)
  2856. case aliyunavatar.FieldResponse:
  2857. return m.OldResponse(ctx)
  2858. case aliyunavatar.FieldToken:
  2859. return m.OldToken(ctx)
  2860. case aliyunavatar.FieldSessionID:
  2861. return m.OldSessionID(ctx)
  2862. }
  2863. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  2864. }
  2865. // SetField sets the value of a field with the given name. It returns an error if
  2866. // the field is not defined in the schema, or if the type mismatched the field
  2867. // type.
  2868. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  2869. switch name {
  2870. case aliyunavatar.FieldCreatedAt:
  2871. v, ok := value.(time.Time)
  2872. if !ok {
  2873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2874. }
  2875. m.SetCreatedAt(v)
  2876. return nil
  2877. case aliyunavatar.FieldUpdatedAt:
  2878. v, ok := value.(time.Time)
  2879. if !ok {
  2880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2881. }
  2882. m.SetUpdatedAt(v)
  2883. return nil
  2884. case aliyunavatar.FieldDeletedAt:
  2885. v, ok := value.(time.Time)
  2886. if !ok {
  2887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2888. }
  2889. m.SetDeletedAt(v)
  2890. return nil
  2891. case aliyunavatar.FieldUserID:
  2892. v, ok := value.(uint64)
  2893. if !ok {
  2894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2895. }
  2896. m.SetUserID(v)
  2897. return nil
  2898. case aliyunavatar.FieldBizID:
  2899. v, ok := value.(string)
  2900. if !ok {
  2901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2902. }
  2903. m.SetBizID(v)
  2904. return nil
  2905. case aliyunavatar.FieldAccessKeyID:
  2906. v, ok := value.(string)
  2907. if !ok {
  2908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2909. }
  2910. m.SetAccessKeyID(v)
  2911. return nil
  2912. case aliyunavatar.FieldAccessKeySecret:
  2913. v, ok := value.(string)
  2914. if !ok {
  2915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2916. }
  2917. m.SetAccessKeySecret(v)
  2918. return nil
  2919. case aliyunavatar.FieldAppID:
  2920. v, ok := value.(string)
  2921. if !ok {
  2922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2923. }
  2924. m.SetAppID(v)
  2925. return nil
  2926. case aliyunavatar.FieldTenantID:
  2927. v, ok := value.(uint64)
  2928. if !ok {
  2929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2930. }
  2931. m.SetTenantID(v)
  2932. return nil
  2933. case aliyunavatar.FieldResponse:
  2934. v, ok := value.(string)
  2935. if !ok {
  2936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2937. }
  2938. m.SetResponse(v)
  2939. return nil
  2940. case aliyunavatar.FieldToken:
  2941. v, ok := value.(string)
  2942. if !ok {
  2943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2944. }
  2945. m.SetToken(v)
  2946. return nil
  2947. case aliyunavatar.FieldSessionID:
  2948. v, ok := value.(string)
  2949. if !ok {
  2950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2951. }
  2952. m.SetSessionID(v)
  2953. return nil
  2954. }
  2955. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  2956. }
  2957. // AddedFields returns all numeric fields that were incremented/decremented during
  2958. // this mutation.
  2959. func (m *AliyunAvatarMutation) AddedFields() []string {
  2960. var fields []string
  2961. if m.adduser_id != nil {
  2962. fields = append(fields, aliyunavatar.FieldUserID)
  2963. }
  2964. if m.addtenant_id != nil {
  2965. fields = append(fields, aliyunavatar.FieldTenantID)
  2966. }
  2967. return fields
  2968. }
  2969. // AddedField returns the numeric value that was incremented/decremented on a field
  2970. // with the given name. The second boolean return value indicates that this field
  2971. // was not set, or was not defined in the schema.
  2972. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  2973. switch name {
  2974. case aliyunavatar.FieldUserID:
  2975. return m.AddedUserID()
  2976. case aliyunavatar.FieldTenantID:
  2977. return m.AddedTenantID()
  2978. }
  2979. return nil, false
  2980. }
  2981. // AddField adds the value to the field with the given name. It returns an error if
  2982. // the field is not defined in the schema, or if the type mismatched the field
  2983. // type.
  2984. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  2985. switch name {
  2986. case aliyunavatar.FieldUserID:
  2987. v, ok := value.(int64)
  2988. if !ok {
  2989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2990. }
  2991. m.AddUserID(v)
  2992. return nil
  2993. case aliyunavatar.FieldTenantID:
  2994. v, ok := value.(int64)
  2995. if !ok {
  2996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2997. }
  2998. m.AddTenantID(v)
  2999. return nil
  3000. }
  3001. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3002. }
  3003. // ClearedFields returns all nullable fields that were cleared during this
  3004. // mutation.
  3005. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3006. var fields []string
  3007. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3008. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3009. }
  3010. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3011. fields = append(fields, aliyunavatar.FieldAppID)
  3012. }
  3013. return fields
  3014. }
  3015. // FieldCleared returns a boolean indicating if a field with the given name was
  3016. // cleared in this mutation.
  3017. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3018. _, ok := m.clearedFields[name]
  3019. return ok
  3020. }
  3021. // ClearField clears the value of the field with the given name. It returns an
  3022. // error if the field is not defined in the schema.
  3023. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3024. switch name {
  3025. case aliyunavatar.FieldDeletedAt:
  3026. m.ClearDeletedAt()
  3027. return nil
  3028. case aliyunavatar.FieldAppID:
  3029. m.ClearAppID()
  3030. return nil
  3031. }
  3032. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3033. }
  3034. // ResetField resets all changes in the mutation for the field with the given name.
  3035. // It returns an error if the field is not defined in the schema.
  3036. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3037. switch name {
  3038. case aliyunavatar.FieldCreatedAt:
  3039. m.ResetCreatedAt()
  3040. return nil
  3041. case aliyunavatar.FieldUpdatedAt:
  3042. m.ResetUpdatedAt()
  3043. return nil
  3044. case aliyunavatar.FieldDeletedAt:
  3045. m.ResetDeletedAt()
  3046. return nil
  3047. case aliyunavatar.FieldUserID:
  3048. m.ResetUserID()
  3049. return nil
  3050. case aliyunavatar.FieldBizID:
  3051. m.ResetBizID()
  3052. return nil
  3053. case aliyunavatar.FieldAccessKeyID:
  3054. m.ResetAccessKeyID()
  3055. return nil
  3056. case aliyunavatar.FieldAccessKeySecret:
  3057. m.ResetAccessKeySecret()
  3058. return nil
  3059. case aliyunavatar.FieldAppID:
  3060. m.ResetAppID()
  3061. return nil
  3062. case aliyunavatar.FieldTenantID:
  3063. m.ResetTenantID()
  3064. return nil
  3065. case aliyunavatar.FieldResponse:
  3066. m.ResetResponse()
  3067. return nil
  3068. case aliyunavatar.FieldToken:
  3069. m.ResetToken()
  3070. return nil
  3071. case aliyunavatar.FieldSessionID:
  3072. m.ResetSessionID()
  3073. return nil
  3074. }
  3075. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3076. }
  3077. // AddedEdges returns all edge names that were set/added in this mutation.
  3078. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3079. edges := make([]string, 0, 0)
  3080. return edges
  3081. }
  3082. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3083. // name in this mutation.
  3084. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3085. return nil
  3086. }
  3087. // RemovedEdges returns all edge names that were removed in this mutation.
  3088. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3089. edges := make([]string, 0, 0)
  3090. return edges
  3091. }
  3092. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3093. // the given name in this mutation.
  3094. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3095. return nil
  3096. }
  3097. // ClearedEdges returns all edge names that were cleared in this mutation.
  3098. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3099. edges := make([]string, 0, 0)
  3100. return edges
  3101. }
  3102. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3103. // was cleared in this mutation.
  3104. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3105. return false
  3106. }
  3107. // ClearEdge clears the value of the edge with the given name. It returns an error
  3108. // if that edge is not defined in the schema.
  3109. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3110. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3111. }
  3112. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3113. // It returns an error if the edge is not defined in the schema.
  3114. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3115. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3116. }
  3117. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  3118. type BatchMsgMutation struct {
  3119. config
  3120. op Op
  3121. typ string
  3122. id *uint64
  3123. created_at *time.Time
  3124. updated_at *time.Time
  3125. deleted_at *time.Time
  3126. status *uint8
  3127. addstatus *int8
  3128. batch_no *string
  3129. task_name *string
  3130. fromwxid *string
  3131. msg *string
  3132. tag *string
  3133. tagids *string
  3134. total *int32
  3135. addtotal *int32
  3136. success *int32
  3137. addsuccess *int32
  3138. fail *int32
  3139. addfail *int32
  3140. start_time *time.Time
  3141. stop_time *time.Time
  3142. send_time *time.Time
  3143. _type *int32
  3144. add_type *int32
  3145. organization_id *uint64
  3146. addorganization_id *int64
  3147. clearedFields map[string]struct{}
  3148. done bool
  3149. oldValue func(context.Context) (*BatchMsg, error)
  3150. predicates []predicate.BatchMsg
  3151. }
  3152. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  3153. // batchmsgOption allows management of the mutation configuration using functional options.
  3154. type batchmsgOption func(*BatchMsgMutation)
  3155. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  3156. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  3157. m := &BatchMsgMutation{
  3158. config: c,
  3159. op: op,
  3160. typ: TypeBatchMsg,
  3161. clearedFields: make(map[string]struct{}),
  3162. }
  3163. for _, opt := range opts {
  3164. opt(m)
  3165. }
  3166. return m
  3167. }
  3168. // withBatchMsgID sets the ID field of the mutation.
  3169. func withBatchMsgID(id uint64) batchmsgOption {
  3170. return func(m *BatchMsgMutation) {
  3171. var (
  3172. err error
  3173. once sync.Once
  3174. value *BatchMsg
  3175. )
  3176. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  3177. once.Do(func() {
  3178. if m.done {
  3179. err = errors.New("querying old values post mutation is not allowed")
  3180. } else {
  3181. value, err = m.Client().BatchMsg.Get(ctx, id)
  3182. }
  3183. })
  3184. return value, err
  3185. }
  3186. m.id = &id
  3187. }
  3188. }
  3189. // withBatchMsg sets the old BatchMsg of the mutation.
  3190. func withBatchMsg(node *BatchMsg) batchmsgOption {
  3191. return func(m *BatchMsgMutation) {
  3192. m.oldValue = func(context.Context) (*BatchMsg, error) {
  3193. return node, nil
  3194. }
  3195. m.id = &node.ID
  3196. }
  3197. }
  3198. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3199. // executed in a transaction (ent.Tx), a transactional client is returned.
  3200. func (m BatchMsgMutation) Client() *Client {
  3201. client := &Client{config: m.config}
  3202. client.init()
  3203. return client
  3204. }
  3205. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3206. // it returns an error otherwise.
  3207. func (m BatchMsgMutation) Tx() (*Tx, error) {
  3208. if _, ok := m.driver.(*txDriver); !ok {
  3209. return nil, errors.New("ent: mutation is not running in a transaction")
  3210. }
  3211. tx := &Tx{config: m.config}
  3212. tx.init()
  3213. return tx, nil
  3214. }
  3215. // SetID sets the value of the id field. Note that this
  3216. // operation is only accepted on creation of BatchMsg entities.
  3217. func (m *BatchMsgMutation) SetID(id uint64) {
  3218. m.id = &id
  3219. }
  3220. // ID returns the ID value in the mutation. Note that the ID is only available
  3221. // if it was provided to the builder or after it was returned from the database.
  3222. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  3223. if m.id == nil {
  3224. return
  3225. }
  3226. return *m.id, true
  3227. }
  3228. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3229. // That means, if the mutation is applied within a transaction with an isolation level such
  3230. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3231. // or updated by the mutation.
  3232. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  3233. switch {
  3234. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3235. id, exists := m.ID()
  3236. if exists {
  3237. return []uint64{id}, nil
  3238. }
  3239. fallthrough
  3240. case m.op.Is(OpUpdate | OpDelete):
  3241. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  3242. default:
  3243. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3244. }
  3245. }
  3246. // SetCreatedAt sets the "created_at" field.
  3247. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  3248. m.created_at = &t
  3249. }
  3250. // CreatedAt returns the value of the "created_at" field in the mutation.
  3251. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  3252. v := m.created_at
  3253. if v == nil {
  3254. return
  3255. }
  3256. return *v, true
  3257. }
  3258. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  3259. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3261. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3262. if !m.op.Is(OpUpdateOne) {
  3263. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3264. }
  3265. if m.id == nil || m.oldValue == nil {
  3266. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3267. }
  3268. oldValue, err := m.oldValue(ctx)
  3269. if err != nil {
  3270. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3271. }
  3272. return oldValue.CreatedAt, nil
  3273. }
  3274. // ResetCreatedAt resets all changes to the "created_at" field.
  3275. func (m *BatchMsgMutation) ResetCreatedAt() {
  3276. m.created_at = nil
  3277. }
  3278. // SetUpdatedAt sets the "updated_at" field.
  3279. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  3280. m.updated_at = &t
  3281. }
  3282. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3283. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  3284. v := m.updated_at
  3285. if v == nil {
  3286. return
  3287. }
  3288. return *v, true
  3289. }
  3290. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  3291. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3292. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3293. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3294. if !m.op.Is(OpUpdateOne) {
  3295. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3296. }
  3297. if m.id == nil || m.oldValue == nil {
  3298. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3299. }
  3300. oldValue, err := m.oldValue(ctx)
  3301. if err != nil {
  3302. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3303. }
  3304. return oldValue.UpdatedAt, nil
  3305. }
  3306. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3307. func (m *BatchMsgMutation) ResetUpdatedAt() {
  3308. m.updated_at = nil
  3309. }
  3310. // SetDeletedAt sets the "deleted_at" field.
  3311. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  3312. m.deleted_at = &t
  3313. }
  3314. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3315. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  3316. v := m.deleted_at
  3317. if v == nil {
  3318. return
  3319. }
  3320. return *v, true
  3321. }
  3322. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  3323. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3324. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3325. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3326. if !m.op.Is(OpUpdateOne) {
  3327. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3328. }
  3329. if m.id == nil || m.oldValue == nil {
  3330. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3331. }
  3332. oldValue, err := m.oldValue(ctx)
  3333. if err != nil {
  3334. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3335. }
  3336. return oldValue.DeletedAt, nil
  3337. }
  3338. // ClearDeletedAt clears the value of the "deleted_at" field.
  3339. func (m *BatchMsgMutation) ClearDeletedAt() {
  3340. m.deleted_at = nil
  3341. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  3342. }
  3343. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3344. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  3345. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  3346. return ok
  3347. }
  3348. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3349. func (m *BatchMsgMutation) ResetDeletedAt() {
  3350. m.deleted_at = nil
  3351. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  3352. }
  3353. // SetStatus sets the "status" field.
  3354. func (m *BatchMsgMutation) SetStatus(u uint8) {
  3355. m.status = &u
  3356. m.addstatus = nil
  3357. }
  3358. // Status returns the value of the "status" field in the mutation.
  3359. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  3360. v := m.status
  3361. if v == nil {
  3362. return
  3363. }
  3364. return *v, true
  3365. }
  3366. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  3367. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3368. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3369. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  3370. if !m.op.Is(OpUpdateOne) {
  3371. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3372. }
  3373. if m.id == nil || m.oldValue == nil {
  3374. return v, errors.New("OldStatus requires an ID field in the mutation")
  3375. }
  3376. oldValue, err := m.oldValue(ctx)
  3377. if err != nil {
  3378. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3379. }
  3380. return oldValue.Status, nil
  3381. }
  3382. // AddStatus adds u to the "status" field.
  3383. func (m *BatchMsgMutation) AddStatus(u int8) {
  3384. if m.addstatus != nil {
  3385. *m.addstatus += u
  3386. } else {
  3387. m.addstatus = &u
  3388. }
  3389. }
  3390. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3391. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  3392. v := m.addstatus
  3393. if v == nil {
  3394. return
  3395. }
  3396. return *v, true
  3397. }
  3398. // ClearStatus clears the value of the "status" field.
  3399. func (m *BatchMsgMutation) ClearStatus() {
  3400. m.status = nil
  3401. m.addstatus = nil
  3402. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  3403. }
  3404. // StatusCleared returns if the "status" field was cleared in this mutation.
  3405. func (m *BatchMsgMutation) StatusCleared() bool {
  3406. _, ok := m.clearedFields[batchmsg.FieldStatus]
  3407. return ok
  3408. }
  3409. // ResetStatus resets all changes to the "status" field.
  3410. func (m *BatchMsgMutation) ResetStatus() {
  3411. m.status = nil
  3412. m.addstatus = nil
  3413. delete(m.clearedFields, batchmsg.FieldStatus)
  3414. }
  3415. // SetBatchNo sets the "batch_no" field.
  3416. func (m *BatchMsgMutation) SetBatchNo(s string) {
  3417. m.batch_no = &s
  3418. }
  3419. // BatchNo returns the value of the "batch_no" field in the mutation.
  3420. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  3421. v := m.batch_no
  3422. if v == nil {
  3423. return
  3424. }
  3425. return *v, true
  3426. }
  3427. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  3428. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3430. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  3431. if !m.op.Is(OpUpdateOne) {
  3432. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  3433. }
  3434. if m.id == nil || m.oldValue == nil {
  3435. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  3436. }
  3437. oldValue, err := m.oldValue(ctx)
  3438. if err != nil {
  3439. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  3440. }
  3441. return oldValue.BatchNo, nil
  3442. }
  3443. // ClearBatchNo clears the value of the "batch_no" field.
  3444. func (m *BatchMsgMutation) ClearBatchNo() {
  3445. m.batch_no = nil
  3446. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  3447. }
  3448. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  3449. func (m *BatchMsgMutation) BatchNoCleared() bool {
  3450. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  3451. return ok
  3452. }
  3453. // ResetBatchNo resets all changes to the "batch_no" field.
  3454. func (m *BatchMsgMutation) ResetBatchNo() {
  3455. m.batch_no = nil
  3456. delete(m.clearedFields, batchmsg.FieldBatchNo)
  3457. }
  3458. // SetTaskName sets the "task_name" field.
  3459. func (m *BatchMsgMutation) SetTaskName(s string) {
  3460. m.task_name = &s
  3461. }
  3462. // TaskName returns the value of the "task_name" field in the mutation.
  3463. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  3464. v := m.task_name
  3465. if v == nil {
  3466. return
  3467. }
  3468. return *v, true
  3469. }
  3470. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  3471. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3473. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  3474. if !m.op.Is(OpUpdateOne) {
  3475. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  3476. }
  3477. if m.id == nil || m.oldValue == nil {
  3478. return v, errors.New("OldTaskName requires an ID field in the mutation")
  3479. }
  3480. oldValue, err := m.oldValue(ctx)
  3481. if err != nil {
  3482. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  3483. }
  3484. return oldValue.TaskName, nil
  3485. }
  3486. // ClearTaskName clears the value of the "task_name" field.
  3487. func (m *BatchMsgMutation) ClearTaskName() {
  3488. m.task_name = nil
  3489. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  3490. }
  3491. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  3492. func (m *BatchMsgMutation) TaskNameCleared() bool {
  3493. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  3494. return ok
  3495. }
  3496. // ResetTaskName resets all changes to the "task_name" field.
  3497. func (m *BatchMsgMutation) ResetTaskName() {
  3498. m.task_name = nil
  3499. delete(m.clearedFields, batchmsg.FieldTaskName)
  3500. }
  3501. // SetFromwxid sets the "fromwxid" field.
  3502. func (m *BatchMsgMutation) SetFromwxid(s string) {
  3503. m.fromwxid = &s
  3504. }
  3505. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  3506. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  3507. v := m.fromwxid
  3508. if v == nil {
  3509. return
  3510. }
  3511. return *v, true
  3512. }
  3513. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  3514. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3515. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3516. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  3517. if !m.op.Is(OpUpdateOne) {
  3518. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  3519. }
  3520. if m.id == nil || m.oldValue == nil {
  3521. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  3522. }
  3523. oldValue, err := m.oldValue(ctx)
  3524. if err != nil {
  3525. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  3526. }
  3527. return oldValue.Fromwxid, nil
  3528. }
  3529. // ClearFromwxid clears the value of the "fromwxid" field.
  3530. func (m *BatchMsgMutation) ClearFromwxid() {
  3531. m.fromwxid = nil
  3532. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  3533. }
  3534. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  3535. func (m *BatchMsgMutation) FromwxidCleared() bool {
  3536. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  3537. return ok
  3538. }
  3539. // ResetFromwxid resets all changes to the "fromwxid" field.
  3540. func (m *BatchMsgMutation) ResetFromwxid() {
  3541. m.fromwxid = nil
  3542. delete(m.clearedFields, batchmsg.FieldFromwxid)
  3543. }
  3544. // SetMsg sets the "msg" field.
  3545. func (m *BatchMsgMutation) SetMsg(s string) {
  3546. m.msg = &s
  3547. }
  3548. // Msg returns the value of the "msg" field in the mutation.
  3549. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  3550. v := m.msg
  3551. if v == nil {
  3552. return
  3553. }
  3554. return *v, true
  3555. }
  3556. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  3557. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3558. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3559. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  3560. if !m.op.Is(OpUpdateOne) {
  3561. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  3562. }
  3563. if m.id == nil || m.oldValue == nil {
  3564. return v, errors.New("OldMsg requires an ID field in the mutation")
  3565. }
  3566. oldValue, err := m.oldValue(ctx)
  3567. if err != nil {
  3568. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  3569. }
  3570. return oldValue.Msg, nil
  3571. }
  3572. // ClearMsg clears the value of the "msg" field.
  3573. func (m *BatchMsgMutation) ClearMsg() {
  3574. m.msg = nil
  3575. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  3576. }
  3577. // MsgCleared returns if the "msg" field was cleared in this mutation.
  3578. func (m *BatchMsgMutation) MsgCleared() bool {
  3579. _, ok := m.clearedFields[batchmsg.FieldMsg]
  3580. return ok
  3581. }
  3582. // ResetMsg resets all changes to the "msg" field.
  3583. func (m *BatchMsgMutation) ResetMsg() {
  3584. m.msg = nil
  3585. delete(m.clearedFields, batchmsg.FieldMsg)
  3586. }
  3587. // SetTag sets the "tag" field.
  3588. func (m *BatchMsgMutation) SetTag(s string) {
  3589. m.tag = &s
  3590. }
  3591. // Tag returns the value of the "tag" field in the mutation.
  3592. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  3593. v := m.tag
  3594. if v == nil {
  3595. return
  3596. }
  3597. return *v, true
  3598. }
  3599. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  3600. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3601. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3602. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  3603. if !m.op.Is(OpUpdateOne) {
  3604. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  3605. }
  3606. if m.id == nil || m.oldValue == nil {
  3607. return v, errors.New("OldTag requires an ID field in the mutation")
  3608. }
  3609. oldValue, err := m.oldValue(ctx)
  3610. if err != nil {
  3611. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  3612. }
  3613. return oldValue.Tag, nil
  3614. }
  3615. // ClearTag clears the value of the "tag" field.
  3616. func (m *BatchMsgMutation) ClearTag() {
  3617. m.tag = nil
  3618. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  3619. }
  3620. // TagCleared returns if the "tag" field was cleared in this mutation.
  3621. func (m *BatchMsgMutation) TagCleared() bool {
  3622. _, ok := m.clearedFields[batchmsg.FieldTag]
  3623. return ok
  3624. }
  3625. // ResetTag resets all changes to the "tag" field.
  3626. func (m *BatchMsgMutation) ResetTag() {
  3627. m.tag = nil
  3628. delete(m.clearedFields, batchmsg.FieldTag)
  3629. }
  3630. // SetTagids sets the "tagids" field.
  3631. func (m *BatchMsgMutation) SetTagids(s string) {
  3632. m.tagids = &s
  3633. }
  3634. // Tagids returns the value of the "tagids" field in the mutation.
  3635. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  3636. v := m.tagids
  3637. if v == nil {
  3638. return
  3639. }
  3640. return *v, true
  3641. }
  3642. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  3643. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3644. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3645. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  3646. if !m.op.Is(OpUpdateOne) {
  3647. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  3648. }
  3649. if m.id == nil || m.oldValue == nil {
  3650. return v, errors.New("OldTagids requires an ID field in the mutation")
  3651. }
  3652. oldValue, err := m.oldValue(ctx)
  3653. if err != nil {
  3654. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  3655. }
  3656. return oldValue.Tagids, nil
  3657. }
  3658. // ClearTagids clears the value of the "tagids" field.
  3659. func (m *BatchMsgMutation) ClearTagids() {
  3660. m.tagids = nil
  3661. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  3662. }
  3663. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  3664. func (m *BatchMsgMutation) TagidsCleared() bool {
  3665. _, ok := m.clearedFields[batchmsg.FieldTagids]
  3666. return ok
  3667. }
  3668. // ResetTagids resets all changes to the "tagids" field.
  3669. func (m *BatchMsgMutation) ResetTagids() {
  3670. m.tagids = nil
  3671. delete(m.clearedFields, batchmsg.FieldTagids)
  3672. }
  3673. // SetTotal sets the "total" field.
  3674. func (m *BatchMsgMutation) SetTotal(i int32) {
  3675. m.total = &i
  3676. m.addtotal = nil
  3677. }
  3678. // Total returns the value of the "total" field in the mutation.
  3679. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  3680. v := m.total
  3681. if v == nil {
  3682. return
  3683. }
  3684. return *v, true
  3685. }
  3686. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  3687. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3688. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3689. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  3690. if !m.op.Is(OpUpdateOne) {
  3691. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  3692. }
  3693. if m.id == nil || m.oldValue == nil {
  3694. return v, errors.New("OldTotal requires an ID field in the mutation")
  3695. }
  3696. oldValue, err := m.oldValue(ctx)
  3697. if err != nil {
  3698. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  3699. }
  3700. return oldValue.Total, nil
  3701. }
  3702. // AddTotal adds i to the "total" field.
  3703. func (m *BatchMsgMutation) AddTotal(i int32) {
  3704. if m.addtotal != nil {
  3705. *m.addtotal += i
  3706. } else {
  3707. m.addtotal = &i
  3708. }
  3709. }
  3710. // AddedTotal returns the value that was added to the "total" field in this mutation.
  3711. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  3712. v := m.addtotal
  3713. if v == nil {
  3714. return
  3715. }
  3716. return *v, true
  3717. }
  3718. // ClearTotal clears the value of the "total" field.
  3719. func (m *BatchMsgMutation) ClearTotal() {
  3720. m.total = nil
  3721. m.addtotal = nil
  3722. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  3723. }
  3724. // TotalCleared returns if the "total" field was cleared in this mutation.
  3725. func (m *BatchMsgMutation) TotalCleared() bool {
  3726. _, ok := m.clearedFields[batchmsg.FieldTotal]
  3727. return ok
  3728. }
  3729. // ResetTotal resets all changes to the "total" field.
  3730. func (m *BatchMsgMutation) ResetTotal() {
  3731. m.total = nil
  3732. m.addtotal = nil
  3733. delete(m.clearedFields, batchmsg.FieldTotal)
  3734. }
  3735. // SetSuccess sets the "success" field.
  3736. func (m *BatchMsgMutation) SetSuccess(i int32) {
  3737. m.success = &i
  3738. m.addsuccess = nil
  3739. }
  3740. // Success returns the value of the "success" field in the mutation.
  3741. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  3742. v := m.success
  3743. if v == nil {
  3744. return
  3745. }
  3746. return *v, true
  3747. }
  3748. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  3749. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3750. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3751. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  3752. if !m.op.Is(OpUpdateOne) {
  3753. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  3754. }
  3755. if m.id == nil || m.oldValue == nil {
  3756. return v, errors.New("OldSuccess requires an ID field in the mutation")
  3757. }
  3758. oldValue, err := m.oldValue(ctx)
  3759. if err != nil {
  3760. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  3761. }
  3762. return oldValue.Success, nil
  3763. }
  3764. // AddSuccess adds i to the "success" field.
  3765. func (m *BatchMsgMutation) AddSuccess(i int32) {
  3766. if m.addsuccess != nil {
  3767. *m.addsuccess += i
  3768. } else {
  3769. m.addsuccess = &i
  3770. }
  3771. }
  3772. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  3773. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  3774. v := m.addsuccess
  3775. if v == nil {
  3776. return
  3777. }
  3778. return *v, true
  3779. }
  3780. // ClearSuccess clears the value of the "success" field.
  3781. func (m *BatchMsgMutation) ClearSuccess() {
  3782. m.success = nil
  3783. m.addsuccess = nil
  3784. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  3785. }
  3786. // SuccessCleared returns if the "success" field was cleared in this mutation.
  3787. func (m *BatchMsgMutation) SuccessCleared() bool {
  3788. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  3789. return ok
  3790. }
  3791. // ResetSuccess resets all changes to the "success" field.
  3792. func (m *BatchMsgMutation) ResetSuccess() {
  3793. m.success = nil
  3794. m.addsuccess = nil
  3795. delete(m.clearedFields, batchmsg.FieldSuccess)
  3796. }
  3797. // SetFail sets the "fail" field.
  3798. func (m *BatchMsgMutation) SetFail(i int32) {
  3799. m.fail = &i
  3800. m.addfail = nil
  3801. }
  3802. // Fail returns the value of the "fail" field in the mutation.
  3803. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  3804. v := m.fail
  3805. if v == nil {
  3806. return
  3807. }
  3808. return *v, true
  3809. }
  3810. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  3811. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3812. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3813. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  3814. if !m.op.Is(OpUpdateOne) {
  3815. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  3816. }
  3817. if m.id == nil || m.oldValue == nil {
  3818. return v, errors.New("OldFail requires an ID field in the mutation")
  3819. }
  3820. oldValue, err := m.oldValue(ctx)
  3821. if err != nil {
  3822. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  3823. }
  3824. return oldValue.Fail, nil
  3825. }
  3826. // AddFail adds i to the "fail" field.
  3827. func (m *BatchMsgMutation) AddFail(i int32) {
  3828. if m.addfail != nil {
  3829. *m.addfail += i
  3830. } else {
  3831. m.addfail = &i
  3832. }
  3833. }
  3834. // AddedFail returns the value that was added to the "fail" field in this mutation.
  3835. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  3836. v := m.addfail
  3837. if v == nil {
  3838. return
  3839. }
  3840. return *v, true
  3841. }
  3842. // ClearFail clears the value of the "fail" field.
  3843. func (m *BatchMsgMutation) ClearFail() {
  3844. m.fail = nil
  3845. m.addfail = nil
  3846. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  3847. }
  3848. // FailCleared returns if the "fail" field was cleared in this mutation.
  3849. func (m *BatchMsgMutation) FailCleared() bool {
  3850. _, ok := m.clearedFields[batchmsg.FieldFail]
  3851. return ok
  3852. }
  3853. // ResetFail resets all changes to the "fail" field.
  3854. func (m *BatchMsgMutation) ResetFail() {
  3855. m.fail = nil
  3856. m.addfail = nil
  3857. delete(m.clearedFields, batchmsg.FieldFail)
  3858. }
  3859. // SetStartTime sets the "start_time" field.
  3860. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  3861. m.start_time = &t
  3862. }
  3863. // StartTime returns the value of the "start_time" field in the mutation.
  3864. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  3865. v := m.start_time
  3866. if v == nil {
  3867. return
  3868. }
  3869. return *v, true
  3870. }
  3871. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  3872. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3873. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3874. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  3875. if !m.op.Is(OpUpdateOne) {
  3876. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  3877. }
  3878. if m.id == nil || m.oldValue == nil {
  3879. return v, errors.New("OldStartTime requires an ID field in the mutation")
  3880. }
  3881. oldValue, err := m.oldValue(ctx)
  3882. if err != nil {
  3883. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  3884. }
  3885. return oldValue.StartTime, nil
  3886. }
  3887. // ClearStartTime clears the value of the "start_time" field.
  3888. func (m *BatchMsgMutation) ClearStartTime() {
  3889. m.start_time = nil
  3890. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  3891. }
  3892. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  3893. func (m *BatchMsgMutation) StartTimeCleared() bool {
  3894. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  3895. return ok
  3896. }
  3897. // ResetStartTime resets all changes to the "start_time" field.
  3898. func (m *BatchMsgMutation) ResetStartTime() {
  3899. m.start_time = nil
  3900. delete(m.clearedFields, batchmsg.FieldStartTime)
  3901. }
  3902. // SetStopTime sets the "stop_time" field.
  3903. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  3904. m.stop_time = &t
  3905. }
  3906. // StopTime returns the value of the "stop_time" field in the mutation.
  3907. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  3908. v := m.stop_time
  3909. if v == nil {
  3910. return
  3911. }
  3912. return *v, true
  3913. }
  3914. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  3915. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3916. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3917. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  3918. if !m.op.Is(OpUpdateOne) {
  3919. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  3920. }
  3921. if m.id == nil || m.oldValue == nil {
  3922. return v, errors.New("OldStopTime requires an ID field in the mutation")
  3923. }
  3924. oldValue, err := m.oldValue(ctx)
  3925. if err != nil {
  3926. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  3927. }
  3928. return oldValue.StopTime, nil
  3929. }
  3930. // ClearStopTime clears the value of the "stop_time" field.
  3931. func (m *BatchMsgMutation) ClearStopTime() {
  3932. m.stop_time = nil
  3933. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  3934. }
  3935. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  3936. func (m *BatchMsgMutation) StopTimeCleared() bool {
  3937. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  3938. return ok
  3939. }
  3940. // ResetStopTime resets all changes to the "stop_time" field.
  3941. func (m *BatchMsgMutation) ResetStopTime() {
  3942. m.stop_time = nil
  3943. delete(m.clearedFields, batchmsg.FieldStopTime)
  3944. }
  3945. // SetSendTime sets the "send_time" field.
  3946. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  3947. m.send_time = &t
  3948. }
  3949. // SendTime returns the value of the "send_time" field in the mutation.
  3950. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  3951. v := m.send_time
  3952. if v == nil {
  3953. return
  3954. }
  3955. return *v, true
  3956. }
  3957. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  3958. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3959. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3960. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  3961. if !m.op.Is(OpUpdateOne) {
  3962. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  3963. }
  3964. if m.id == nil || m.oldValue == nil {
  3965. return v, errors.New("OldSendTime requires an ID field in the mutation")
  3966. }
  3967. oldValue, err := m.oldValue(ctx)
  3968. if err != nil {
  3969. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  3970. }
  3971. return oldValue.SendTime, nil
  3972. }
  3973. // ClearSendTime clears the value of the "send_time" field.
  3974. func (m *BatchMsgMutation) ClearSendTime() {
  3975. m.send_time = nil
  3976. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  3977. }
  3978. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  3979. func (m *BatchMsgMutation) SendTimeCleared() bool {
  3980. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  3981. return ok
  3982. }
  3983. // ResetSendTime resets all changes to the "send_time" field.
  3984. func (m *BatchMsgMutation) ResetSendTime() {
  3985. m.send_time = nil
  3986. delete(m.clearedFields, batchmsg.FieldSendTime)
  3987. }
  3988. // SetType sets the "type" field.
  3989. func (m *BatchMsgMutation) SetType(i int32) {
  3990. m._type = &i
  3991. m.add_type = nil
  3992. }
  3993. // GetType returns the value of the "type" field in the mutation.
  3994. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  3995. v := m._type
  3996. if v == nil {
  3997. return
  3998. }
  3999. return *v, true
  4000. }
  4001. // OldType returns the old "type" field's value of the BatchMsg entity.
  4002. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4003. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4004. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  4005. if !m.op.Is(OpUpdateOne) {
  4006. return v, errors.New("OldType is only allowed on UpdateOne operations")
  4007. }
  4008. if m.id == nil || m.oldValue == nil {
  4009. return v, errors.New("OldType requires an ID field in the mutation")
  4010. }
  4011. oldValue, err := m.oldValue(ctx)
  4012. if err != nil {
  4013. return v, fmt.Errorf("querying old value for OldType: %w", err)
  4014. }
  4015. return oldValue.Type, nil
  4016. }
  4017. // AddType adds i to the "type" field.
  4018. func (m *BatchMsgMutation) AddType(i int32) {
  4019. if m.add_type != nil {
  4020. *m.add_type += i
  4021. } else {
  4022. m.add_type = &i
  4023. }
  4024. }
  4025. // AddedType returns the value that was added to the "type" field in this mutation.
  4026. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  4027. v := m.add_type
  4028. if v == nil {
  4029. return
  4030. }
  4031. return *v, true
  4032. }
  4033. // ClearType clears the value of the "type" field.
  4034. func (m *BatchMsgMutation) ClearType() {
  4035. m._type = nil
  4036. m.add_type = nil
  4037. m.clearedFields[batchmsg.FieldType] = struct{}{}
  4038. }
  4039. // TypeCleared returns if the "type" field was cleared in this mutation.
  4040. func (m *BatchMsgMutation) TypeCleared() bool {
  4041. _, ok := m.clearedFields[batchmsg.FieldType]
  4042. return ok
  4043. }
  4044. // ResetType resets all changes to the "type" field.
  4045. func (m *BatchMsgMutation) ResetType() {
  4046. m._type = nil
  4047. m.add_type = nil
  4048. delete(m.clearedFields, batchmsg.FieldType)
  4049. }
  4050. // SetOrganizationID sets the "organization_id" field.
  4051. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  4052. m.organization_id = &u
  4053. m.addorganization_id = nil
  4054. }
  4055. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4056. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  4057. v := m.organization_id
  4058. if v == nil {
  4059. return
  4060. }
  4061. return *v, true
  4062. }
  4063. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  4064. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4065. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4066. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4067. if !m.op.Is(OpUpdateOne) {
  4068. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4069. }
  4070. if m.id == nil || m.oldValue == nil {
  4071. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4072. }
  4073. oldValue, err := m.oldValue(ctx)
  4074. if err != nil {
  4075. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4076. }
  4077. return oldValue.OrganizationID, nil
  4078. }
  4079. // AddOrganizationID adds u to the "organization_id" field.
  4080. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  4081. if m.addorganization_id != nil {
  4082. *m.addorganization_id += u
  4083. } else {
  4084. m.addorganization_id = &u
  4085. }
  4086. }
  4087. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4088. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  4089. v := m.addorganization_id
  4090. if v == nil {
  4091. return
  4092. }
  4093. return *v, true
  4094. }
  4095. // ResetOrganizationID resets all changes to the "organization_id" field.
  4096. func (m *BatchMsgMutation) ResetOrganizationID() {
  4097. m.organization_id = nil
  4098. m.addorganization_id = nil
  4099. }
  4100. // Where appends a list predicates to the BatchMsgMutation builder.
  4101. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  4102. m.predicates = append(m.predicates, ps...)
  4103. }
  4104. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  4105. // users can use type-assertion to append predicates that do not depend on any generated package.
  4106. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  4107. p := make([]predicate.BatchMsg, len(ps))
  4108. for i := range ps {
  4109. p[i] = ps[i]
  4110. }
  4111. m.Where(p...)
  4112. }
  4113. // Op returns the operation name.
  4114. func (m *BatchMsgMutation) Op() Op {
  4115. return m.op
  4116. }
  4117. // SetOp allows setting the mutation operation.
  4118. func (m *BatchMsgMutation) SetOp(op Op) {
  4119. m.op = op
  4120. }
  4121. // Type returns the node type of this mutation (BatchMsg).
  4122. func (m *BatchMsgMutation) Type() string {
  4123. return m.typ
  4124. }
  4125. // Fields returns all fields that were changed during this mutation. Note that in
  4126. // order to get all numeric fields that were incremented/decremented, call
  4127. // AddedFields().
  4128. func (m *BatchMsgMutation) Fields() []string {
  4129. fields := make([]string, 0, 18)
  4130. if m.created_at != nil {
  4131. fields = append(fields, batchmsg.FieldCreatedAt)
  4132. }
  4133. if m.updated_at != nil {
  4134. fields = append(fields, batchmsg.FieldUpdatedAt)
  4135. }
  4136. if m.deleted_at != nil {
  4137. fields = append(fields, batchmsg.FieldDeletedAt)
  4138. }
  4139. if m.status != nil {
  4140. fields = append(fields, batchmsg.FieldStatus)
  4141. }
  4142. if m.batch_no != nil {
  4143. fields = append(fields, batchmsg.FieldBatchNo)
  4144. }
  4145. if m.task_name != nil {
  4146. fields = append(fields, batchmsg.FieldTaskName)
  4147. }
  4148. if m.fromwxid != nil {
  4149. fields = append(fields, batchmsg.FieldFromwxid)
  4150. }
  4151. if m.msg != nil {
  4152. fields = append(fields, batchmsg.FieldMsg)
  4153. }
  4154. if m.tag != nil {
  4155. fields = append(fields, batchmsg.FieldTag)
  4156. }
  4157. if m.tagids != nil {
  4158. fields = append(fields, batchmsg.FieldTagids)
  4159. }
  4160. if m.total != nil {
  4161. fields = append(fields, batchmsg.FieldTotal)
  4162. }
  4163. if m.success != nil {
  4164. fields = append(fields, batchmsg.FieldSuccess)
  4165. }
  4166. if m.fail != nil {
  4167. fields = append(fields, batchmsg.FieldFail)
  4168. }
  4169. if m.start_time != nil {
  4170. fields = append(fields, batchmsg.FieldStartTime)
  4171. }
  4172. if m.stop_time != nil {
  4173. fields = append(fields, batchmsg.FieldStopTime)
  4174. }
  4175. if m.send_time != nil {
  4176. fields = append(fields, batchmsg.FieldSendTime)
  4177. }
  4178. if m._type != nil {
  4179. fields = append(fields, batchmsg.FieldType)
  4180. }
  4181. if m.organization_id != nil {
  4182. fields = append(fields, batchmsg.FieldOrganizationID)
  4183. }
  4184. return fields
  4185. }
  4186. // Field returns the value of a field with the given name. The second boolean
  4187. // return value indicates that this field was not set, or was not defined in the
  4188. // schema.
  4189. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  4190. switch name {
  4191. case batchmsg.FieldCreatedAt:
  4192. return m.CreatedAt()
  4193. case batchmsg.FieldUpdatedAt:
  4194. return m.UpdatedAt()
  4195. case batchmsg.FieldDeletedAt:
  4196. return m.DeletedAt()
  4197. case batchmsg.FieldStatus:
  4198. return m.Status()
  4199. case batchmsg.FieldBatchNo:
  4200. return m.BatchNo()
  4201. case batchmsg.FieldTaskName:
  4202. return m.TaskName()
  4203. case batchmsg.FieldFromwxid:
  4204. return m.Fromwxid()
  4205. case batchmsg.FieldMsg:
  4206. return m.Msg()
  4207. case batchmsg.FieldTag:
  4208. return m.Tag()
  4209. case batchmsg.FieldTagids:
  4210. return m.Tagids()
  4211. case batchmsg.FieldTotal:
  4212. return m.Total()
  4213. case batchmsg.FieldSuccess:
  4214. return m.Success()
  4215. case batchmsg.FieldFail:
  4216. return m.Fail()
  4217. case batchmsg.FieldStartTime:
  4218. return m.StartTime()
  4219. case batchmsg.FieldStopTime:
  4220. return m.StopTime()
  4221. case batchmsg.FieldSendTime:
  4222. return m.SendTime()
  4223. case batchmsg.FieldType:
  4224. return m.GetType()
  4225. case batchmsg.FieldOrganizationID:
  4226. return m.OrganizationID()
  4227. }
  4228. return nil, false
  4229. }
  4230. // OldField returns the old value of the field from the database. An error is
  4231. // returned if the mutation operation is not UpdateOne, or the query to the
  4232. // database failed.
  4233. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4234. switch name {
  4235. case batchmsg.FieldCreatedAt:
  4236. return m.OldCreatedAt(ctx)
  4237. case batchmsg.FieldUpdatedAt:
  4238. return m.OldUpdatedAt(ctx)
  4239. case batchmsg.FieldDeletedAt:
  4240. return m.OldDeletedAt(ctx)
  4241. case batchmsg.FieldStatus:
  4242. return m.OldStatus(ctx)
  4243. case batchmsg.FieldBatchNo:
  4244. return m.OldBatchNo(ctx)
  4245. case batchmsg.FieldTaskName:
  4246. return m.OldTaskName(ctx)
  4247. case batchmsg.FieldFromwxid:
  4248. return m.OldFromwxid(ctx)
  4249. case batchmsg.FieldMsg:
  4250. return m.OldMsg(ctx)
  4251. case batchmsg.FieldTag:
  4252. return m.OldTag(ctx)
  4253. case batchmsg.FieldTagids:
  4254. return m.OldTagids(ctx)
  4255. case batchmsg.FieldTotal:
  4256. return m.OldTotal(ctx)
  4257. case batchmsg.FieldSuccess:
  4258. return m.OldSuccess(ctx)
  4259. case batchmsg.FieldFail:
  4260. return m.OldFail(ctx)
  4261. case batchmsg.FieldStartTime:
  4262. return m.OldStartTime(ctx)
  4263. case batchmsg.FieldStopTime:
  4264. return m.OldStopTime(ctx)
  4265. case batchmsg.FieldSendTime:
  4266. return m.OldSendTime(ctx)
  4267. case batchmsg.FieldType:
  4268. return m.OldType(ctx)
  4269. case batchmsg.FieldOrganizationID:
  4270. return m.OldOrganizationID(ctx)
  4271. }
  4272. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  4273. }
  4274. // SetField sets the value of a field with the given name. It returns an error if
  4275. // the field is not defined in the schema, or if the type mismatched the field
  4276. // type.
  4277. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  4278. switch name {
  4279. case batchmsg.FieldCreatedAt:
  4280. v, ok := value.(time.Time)
  4281. if !ok {
  4282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4283. }
  4284. m.SetCreatedAt(v)
  4285. return nil
  4286. case batchmsg.FieldUpdatedAt:
  4287. v, ok := value.(time.Time)
  4288. if !ok {
  4289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4290. }
  4291. m.SetUpdatedAt(v)
  4292. return nil
  4293. case batchmsg.FieldDeletedAt:
  4294. v, ok := value.(time.Time)
  4295. if !ok {
  4296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4297. }
  4298. m.SetDeletedAt(v)
  4299. return nil
  4300. case batchmsg.FieldStatus:
  4301. v, ok := value.(uint8)
  4302. if !ok {
  4303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4304. }
  4305. m.SetStatus(v)
  4306. return nil
  4307. case batchmsg.FieldBatchNo:
  4308. v, ok := value.(string)
  4309. if !ok {
  4310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4311. }
  4312. m.SetBatchNo(v)
  4313. return nil
  4314. case batchmsg.FieldTaskName:
  4315. v, ok := value.(string)
  4316. if !ok {
  4317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4318. }
  4319. m.SetTaskName(v)
  4320. return nil
  4321. case batchmsg.FieldFromwxid:
  4322. v, ok := value.(string)
  4323. if !ok {
  4324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4325. }
  4326. m.SetFromwxid(v)
  4327. return nil
  4328. case batchmsg.FieldMsg:
  4329. v, ok := value.(string)
  4330. if !ok {
  4331. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4332. }
  4333. m.SetMsg(v)
  4334. return nil
  4335. case batchmsg.FieldTag:
  4336. v, ok := value.(string)
  4337. if !ok {
  4338. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4339. }
  4340. m.SetTag(v)
  4341. return nil
  4342. case batchmsg.FieldTagids:
  4343. v, ok := value.(string)
  4344. if !ok {
  4345. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4346. }
  4347. m.SetTagids(v)
  4348. return nil
  4349. case batchmsg.FieldTotal:
  4350. v, ok := value.(int32)
  4351. if !ok {
  4352. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4353. }
  4354. m.SetTotal(v)
  4355. return nil
  4356. case batchmsg.FieldSuccess:
  4357. v, ok := value.(int32)
  4358. if !ok {
  4359. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4360. }
  4361. m.SetSuccess(v)
  4362. return nil
  4363. case batchmsg.FieldFail:
  4364. v, ok := value.(int32)
  4365. if !ok {
  4366. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4367. }
  4368. m.SetFail(v)
  4369. return nil
  4370. case batchmsg.FieldStartTime:
  4371. v, ok := value.(time.Time)
  4372. if !ok {
  4373. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4374. }
  4375. m.SetStartTime(v)
  4376. return nil
  4377. case batchmsg.FieldStopTime:
  4378. v, ok := value.(time.Time)
  4379. if !ok {
  4380. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4381. }
  4382. m.SetStopTime(v)
  4383. return nil
  4384. case batchmsg.FieldSendTime:
  4385. v, ok := value.(time.Time)
  4386. if !ok {
  4387. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4388. }
  4389. m.SetSendTime(v)
  4390. return nil
  4391. case batchmsg.FieldType:
  4392. v, ok := value.(int32)
  4393. if !ok {
  4394. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4395. }
  4396. m.SetType(v)
  4397. return nil
  4398. case batchmsg.FieldOrganizationID:
  4399. v, ok := value.(uint64)
  4400. if !ok {
  4401. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4402. }
  4403. m.SetOrganizationID(v)
  4404. return nil
  4405. }
  4406. return fmt.Errorf("unknown BatchMsg field %s", name)
  4407. }
  4408. // AddedFields returns all numeric fields that were incremented/decremented during
  4409. // this mutation.
  4410. func (m *BatchMsgMutation) AddedFields() []string {
  4411. var fields []string
  4412. if m.addstatus != nil {
  4413. fields = append(fields, batchmsg.FieldStatus)
  4414. }
  4415. if m.addtotal != nil {
  4416. fields = append(fields, batchmsg.FieldTotal)
  4417. }
  4418. if m.addsuccess != nil {
  4419. fields = append(fields, batchmsg.FieldSuccess)
  4420. }
  4421. if m.addfail != nil {
  4422. fields = append(fields, batchmsg.FieldFail)
  4423. }
  4424. if m.add_type != nil {
  4425. fields = append(fields, batchmsg.FieldType)
  4426. }
  4427. if m.addorganization_id != nil {
  4428. fields = append(fields, batchmsg.FieldOrganizationID)
  4429. }
  4430. return fields
  4431. }
  4432. // AddedField returns the numeric value that was incremented/decremented on a field
  4433. // with the given name. The second boolean return value indicates that this field
  4434. // was not set, or was not defined in the schema.
  4435. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  4436. switch name {
  4437. case batchmsg.FieldStatus:
  4438. return m.AddedStatus()
  4439. case batchmsg.FieldTotal:
  4440. return m.AddedTotal()
  4441. case batchmsg.FieldSuccess:
  4442. return m.AddedSuccess()
  4443. case batchmsg.FieldFail:
  4444. return m.AddedFail()
  4445. case batchmsg.FieldType:
  4446. return m.AddedType()
  4447. case batchmsg.FieldOrganizationID:
  4448. return m.AddedOrganizationID()
  4449. }
  4450. return nil, false
  4451. }
  4452. // AddField adds the value to the field with the given name. It returns an error if
  4453. // the field is not defined in the schema, or if the type mismatched the field
  4454. // type.
  4455. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  4456. switch name {
  4457. case batchmsg.FieldStatus:
  4458. v, ok := value.(int8)
  4459. if !ok {
  4460. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4461. }
  4462. m.AddStatus(v)
  4463. return nil
  4464. case batchmsg.FieldTotal:
  4465. v, ok := value.(int32)
  4466. if !ok {
  4467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4468. }
  4469. m.AddTotal(v)
  4470. return nil
  4471. case batchmsg.FieldSuccess:
  4472. v, ok := value.(int32)
  4473. if !ok {
  4474. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4475. }
  4476. m.AddSuccess(v)
  4477. return nil
  4478. case batchmsg.FieldFail:
  4479. v, ok := value.(int32)
  4480. if !ok {
  4481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4482. }
  4483. m.AddFail(v)
  4484. return nil
  4485. case batchmsg.FieldType:
  4486. v, ok := value.(int32)
  4487. if !ok {
  4488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4489. }
  4490. m.AddType(v)
  4491. return nil
  4492. case batchmsg.FieldOrganizationID:
  4493. v, ok := value.(int64)
  4494. if !ok {
  4495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4496. }
  4497. m.AddOrganizationID(v)
  4498. return nil
  4499. }
  4500. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  4501. }
  4502. // ClearedFields returns all nullable fields that were cleared during this
  4503. // mutation.
  4504. func (m *BatchMsgMutation) ClearedFields() []string {
  4505. var fields []string
  4506. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  4507. fields = append(fields, batchmsg.FieldDeletedAt)
  4508. }
  4509. if m.FieldCleared(batchmsg.FieldStatus) {
  4510. fields = append(fields, batchmsg.FieldStatus)
  4511. }
  4512. if m.FieldCleared(batchmsg.FieldBatchNo) {
  4513. fields = append(fields, batchmsg.FieldBatchNo)
  4514. }
  4515. if m.FieldCleared(batchmsg.FieldTaskName) {
  4516. fields = append(fields, batchmsg.FieldTaskName)
  4517. }
  4518. if m.FieldCleared(batchmsg.FieldFromwxid) {
  4519. fields = append(fields, batchmsg.FieldFromwxid)
  4520. }
  4521. if m.FieldCleared(batchmsg.FieldMsg) {
  4522. fields = append(fields, batchmsg.FieldMsg)
  4523. }
  4524. if m.FieldCleared(batchmsg.FieldTag) {
  4525. fields = append(fields, batchmsg.FieldTag)
  4526. }
  4527. if m.FieldCleared(batchmsg.FieldTagids) {
  4528. fields = append(fields, batchmsg.FieldTagids)
  4529. }
  4530. if m.FieldCleared(batchmsg.FieldTotal) {
  4531. fields = append(fields, batchmsg.FieldTotal)
  4532. }
  4533. if m.FieldCleared(batchmsg.FieldSuccess) {
  4534. fields = append(fields, batchmsg.FieldSuccess)
  4535. }
  4536. if m.FieldCleared(batchmsg.FieldFail) {
  4537. fields = append(fields, batchmsg.FieldFail)
  4538. }
  4539. if m.FieldCleared(batchmsg.FieldStartTime) {
  4540. fields = append(fields, batchmsg.FieldStartTime)
  4541. }
  4542. if m.FieldCleared(batchmsg.FieldStopTime) {
  4543. fields = append(fields, batchmsg.FieldStopTime)
  4544. }
  4545. if m.FieldCleared(batchmsg.FieldSendTime) {
  4546. fields = append(fields, batchmsg.FieldSendTime)
  4547. }
  4548. if m.FieldCleared(batchmsg.FieldType) {
  4549. fields = append(fields, batchmsg.FieldType)
  4550. }
  4551. return fields
  4552. }
  4553. // FieldCleared returns a boolean indicating if a field with the given name was
  4554. // cleared in this mutation.
  4555. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  4556. _, ok := m.clearedFields[name]
  4557. return ok
  4558. }
  4559. // ClearField clears the value of the field with the given name. It returns an
  4560. // error if the field is not defined in the schema.
  4561. func (m *BatchMsgMutation) ClearField(name string) error {
  4562. switch name {
  4563. case batchmsg.FieldDeletedAt:
  4564. m.ClearDeletedAt()
  4565. return nil
  4566. case batchmsg.FieldStatus:
  4567. m.ClearStatus()
  4568. return nil
  4569. case batchmsg.FieldBatchNo:
  4570. m.ClearBatchNo()
  4571. return nil
  4572. case batchmsg.FieldTaskName:
  4573. m.ClearTaskName()
  4574. return nil
  4575. case batchmsg.FieldFromwxid:
  4576. m.ClearFromwxid()
  4577. return nil
  4578. case batchmsg.FieldMsg:
  4579. m.ClearMsg()
  4580. return nil
  4581. case batchmsg.FieldTag:
  4582. m.ClearTag()
  4583. return nil
  4584. case batchmsg.FieldTagids:
  4585. m.ClearTagids()
  4586. return nil
  4587. case batchmsg.FieldTotal:
  4588. m.ClearTotal()
  4589. return nil
  4590. case batchmsg.FieldSuccess:
  4591. m.ClearSuccess()
  4592. return nil
  4593. case batchmsg.FieldFail:
  4594. m.ClearFail()
  4595. return nil
  4596. case batchmsg.FieldStartTime:
  4597. m.ClearStartTime()
  4598. return nil
  4599. case batchmsg.FieldStopTime:
  4600. m.ClearStopTime()
  4601. return nil
  4602. case batchmsg.FieldSendTime:
  4603. m.ClearSendTime()
  4604. return nil
  4605. case batchmsg.FieldType:
  4606. m.ClearType()
  4607. return nil
  4608. }
  4609. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  4610. }
  4611. // ResetField resets all changes in the mutation for the field with the given name.
  4612. // It returns an error if the field is not defined in the schema.
  4613. func (m *BatchMsgMutation) ResetField(name string) error {
  4614. switch name {
  4615. case batchmsg.FieldCreatedAt:
  4616. m.ResetCreatedAt()
  4617. return nil
  4618. case batchmsg.FieldUpdatedAt:
  4619. m.ResetUpdatedAt()
  4620. return nil
  4621. case batchmsg.FieldDeletedAt:
  4622. m.ResetDeletedAt()
  4623. return nil
  4624. case batchmsg.FieldStatus:
  4625. m.ResetStatus()
  4626. return nil
  4627. case batchmsg.FieldBatchNo:
  4628. m.ResetBatchNo()
  4629. return nil
  4630. case batchmsg.FieldTaskName:
  4631. m.ResetTaskName()
  4632. return nil
  4633. case batchmsg.FieldFromwxid:
  4634. m.ResetFromwxid()
  4635. return nil
  4636. case batchmsg.FieldMsg:
  4637. m.ResetMsg()
  4638. return nil
  4639. case batchmsg.FieldTag:
  4640. m.ResetTag()
  4641. return nil
  4642. case batchmsg.FieldTagids:
  4643. m.ResetTagids()
  4644. return nil
  4645. case batchmsg.FieldTotal:
  4646. m.ResetTotal()
  4647. return nil
  4648. case batchmsg.FieldSuccess:
  4649. m.ResetSuccess()
  4650. return nil
  4651. case batchmsg.FieldFail:
  4652. m.ResetFail()
  4653. return nil
  4654. case batchmsg.FieldStartTime:
  4655. m.ResetStartTime()
  4656. return nil
  4657. case batchmsg.FieldStopTime:
  4658. m.ResetStopTime()
  4659. return nil
  4660. case batchmsg.FieldSendTime:
  4661. m.ResetSendTime()
  4662. return nil
  4663. case batchmsg.FieldType:
  4664. m.ResetType()
  4665. return nil
  4666. case batchmsg.FieldOrganizationID:
  4667. m.ResetOrganizationID()
  4668. return nil
  4669. }
  4670. return fmt.Errorf("unknown BatchMsg field %s", name)
  4671. }
  4672. // AddedEdges returns all edge names that were set/added in this mutation.
  4673. func (m *BatchMsgMutation) AddedEdges() []string {
  4674. edges := make([]string, 0, 0)
  4675. return edges
  4676. }
  4677. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4678. // name in this mutation.
  4679. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  4680. return nil
  4681. }
  4682. // RemovedEdges returns all edge names that were removed in this mutation.
  4683. func (m *BatchMsgMutation) RemovedEdges() []string {
  4684. edges := make([]string, 0, 0)
  4685. return edges
  4686. }
  4687. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4688. // the given name in this mutation.
  4689. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  4690. return nil
  4691. }
  4692. // ClearedEdges returns all edge names that were cleared in this mutation.
  4693. func (m *BatchMsgMutation) ClearedEdges() []string {
  4694. edges := make([]string, 0, 0)
  4695. return edges
  4696. }
  4697. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4698. // was cleared in this mutation.
  4699. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  4700. return false
  4701. }
  4702. // ClearEdge clears the value of the edge with the given name. It returns an error
  4703. // if that edge is not defined in the schema.
  4704. func (m *BatchMsgMutation) ClearEdge(name string) error {
  4705. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  4706. }
  4707. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4708. // It returns an error if the edge is not defined in the schema.
  4709. func (m *BatchMsgMutation) ResetEdge(name string) error {
  4710. return fmt.Errorf("unknown BatchMsg edge %s", name)
  4711. }
  4712. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  4713. type CategoryMutation struct {
  4714. config
  4715. op Op
  4716. typ string
  4717. id *uint64
  4718. created_at *time.Time
  4719. updated_at *time.Time
  4720. deleted_at *time.Time
  4721. name *string
  4722. organization_id *uint64
  4723. addorganization_id *int64
  4724. clearedFields map[string]struct{}
  4725. done bool
  4726. oldValue func(context.Context) (*Category, error)
  4727. predicates []predicate.Category
  4728. }
  4729. var _ ent.Mutation = (*CategoryMutation)(nil)
  4730. // categoryOption allows management of the mutation configuration using functional options.
  4731. type categoryOption func(*CategoryMutation)
  4732. // newCategoryMutation creates new mutation for the Category entity.
  4733. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  4734. m := &CategoryMutation{
  4735. config: c,
  4736. op: op,
  4737. typ: TypeCategory,
  4738. clearedFields: make(map[string]struct{}),
  4739. }
  4740. for _, opt := range opts {
  4741. opt(m)
  4742. }
  4743. return m
  4744. }
  4745. // withCategoryID sets the ID field of the mutation.
  4746. func withCategoryID(id uint64) categoryOption {
  4747. return func(m *CategoryMutation) {
  4748. var (
  4749. err error
  4750. once sync.Once
  4751. value *Category
  4752. )
  4753. m.oldValue = func(ctx context.Context) (*Category, error) {
  4754. once.Do(func() {
  4755. if m.done {
  4756. err = errors.New("querying old values post mutation is not allowed")
  4757. } else {
  4758. value, err = m.Client().Category.Get(ctx, id)
  4759. }
  4760. })
  4761. return value, err
  4762. }
  4763. m.id = &id
  4764. }
  4765. }
  4766. // withCategory sets the old Category of the mutation.
  4767. func withCategory(node *Category) categoryOption {
  4768. return func(m *CategoryMutation) {
  4769. m.oldValue = func(context.Context) (*Category, error) {
  4770. return node, nil
  4771. }
  4772. m.id = &node.ID
  4773. }
  4774. }
  4775. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4776. // executed in a transaction (ent.Tx), a transactional client is returned.
  4777. func (m CategoryMutation) Client() *Client {
  4778. client := &Client{config: m.config}
  4779. client.init()
  4780. return client
  4781. }
  4782. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4783. // it returns an error otherwise.
  4784. func (m CategoryMutation) Tx() (*Tx, error) {
  4785. if _, ok := m.driver.(*txDriver); !ok {
  4786. return nil, errors.New("ent: mutation is not running in a transaction")
  4787. }
  4788. tx := &Tx{config: m.config}
  4789. tx.init()
  4790. return tx, nil
  4791. }
  4792. // SetID sets the value of the id field. Note that this
  4793. // operation is only accepted on creation of Category entities.
  4794. func (m *CategoryMutation) SetID(id uint64) {
  4795. m.id = &id
  4796. }
  4797. // ID returns the ID value in the mutation. Note that the ID is only available
  4798. // if it was provided to the builder or after it was returned from the database.
  4799. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  4800. if m.id == nil {
  4801. return
  4802. }
  4803. return *m.id, true
  4804. }
  4805. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4806. // That means, if the mutation is applied within a transaction with an isolation level such
  4807. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4808. // or updated by the mutation.
  4809. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  4810. switch {
  4811. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4812. id, exists := m.ID()
  4813. if exists {
  4814. return []uint64{id}, nil
  4815. }
  4816. fallthrough
  4817. case m.op.Is(OpUpdate | OpDelete):
  4818. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  4819. default:
  4820. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4821. }
  4822. }
  4823. // SetCreatedAt sets the "created_at" field.
  4824. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  4825. m.created_at = &t
  4826. }
  4827. // CreatedAt returns the value of the "created_at" field in the mutation.
  4828. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  4829. v := m.created_at
  4830. if v == nil {
  4831. return
  4832. }
  4833. return *v, true
  4834. }
  4835. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  4836. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4837. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4838. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4839. if !m.op.Is(OpUpdateOne) {
  4840. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4841. }
  4842. if m.id == nil || m.oldValue == nil {
  4843. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4844. }
  4845. oldValue, err := m.oldValue(ctx)
  4846. if err != nil {
  4847. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4848. }
  4849. return oldValue.CreatedAt, nil
  4850. }
  4851. // ResetCreatedAt resets all changes to the "created_at" field.
  4852. func (m *CategoryMutation) ResetCreatedAt() {
  4853. m.created_at = nil
  4854. }
  4855. // SetUpdatedAt sets the "updated_at" field.
  4856. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  4857. m.updated_at = &t
  4858. }
  4859. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4860. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  4861. v := m.updated_at
  4862. if v == nil {
  4863. return
  4864. }
  4865. return *v, true
  4866. }
  4867. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  4868. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4870. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4871. if !m.op.Is(OpUpdateOne) {
  4872. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4873. }
  4874. if m.id == nil || m.oldValue == nil {
  4875. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4876. }
  4877. oldValue, err := m.oldValue(ctx)
  4878. if err != nil {
  4879. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4880. }
  4881. return oldValue.UpdatedAt, nil
  4882. }
  4883. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4884. func (m *CategoryMutation) ResetUpdatedAt() {
  4885. m.updated_at = nil
  4886. }
  4887. // SetDeletedAt sets the "deleted_at" field.
  4888. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  4889. m.deleted_at = &t
  4890. }
  4891. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4892. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  4893. v := m.deleted_at
  4894. if v == nil {
  4895. return
  4896. }
  4897. return *v, true
  4898. }
  4899. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  4900. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4901. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4902. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4903. if !m.op.Is(OpUpdateOne) {
  4904. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4905. }
  4906. if m.id == nil || m.oldValue == nil {
  4907. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4908. }
  4909. oldValue, err := m.oldValue(ctx)
  4910. if err != nil {
  4911. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4912. }
  4913. return oldValue.DeletedAt, nil
  4914. }
  4915. // ClearDeletedAt clears the value of the "deleted_at" field.
  4916. func (m *CategoryMutation) ClearDeletedAt() {
  4917. m.deleted_at = nil
  4918. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  4919. }
  4920. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4921. func (m *CategoryMutation) DeletedAtCleared() bool {
  4922. _, ok := m.clearedFields[category.FieldDeletedAt]
  4923. return ok
  4924. }
  4925. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4926. func (m *CategoryMutation) ResetDeletedAt() {
  4927. m.deleted_at = nil
  4928. delete(m.clearedFields, category.FieldDeletedAt)
  4929. }
  4930. // SetName sets the "name" field.
  4931. func (m *CategoryMutation) SetName(s string) {
  4932. m.name = &s
  4933. }
  4934. // Name returns the value of the "name" field in the mutation.
  4935. func (m *CategoryMutation) Name() (r string, exists bool) {
  4936. v := m.name
  4937. if v == nil {
  4938. return
  4939. }
  4940. return *v, true
  4941. }
  4942. // OldName returns the old "name" field's value of the Category entity.
  4943. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4945. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  4946. if !m.op.Is(OpUpdateOne) {
  4947. return v, errors.New("OldName is only allowed on UpdateOne operations")
  4948. }
  4949. if m.id == nil || m.oldValue == nil {
  4950. return v, errors.New("OldName requires an ID field in the mutation")
  4951. }
  4952. oldValue, err := m.oldValue(ctx)
  4953. if err != nil {
  4954. return v, fmt.Errorf("querying old value for OldName: %w", err)
  4955. }
  4956. return oldValue.Name, nil
  4957. }
  4958. // ResetName resets all changes to the "name" field.
  4959. func (m *CategoryMutation) ResetName() {
  4960. m.name = nil
  4961. }
  4962. // SetOrganizationID sets the "organization_id" field.
  4963. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  4964. m.organization_id = &u
  4965. m.addorganization_id = nil
  4966. }
  4967. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4968. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  4969. v := m.organization_id
  4970. if v == nil {
  4971. return
  4972. }
  4973. return *v, true
  4974. }
  4975. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  4976. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4977. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4978. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4979. if !m.op.Is(OpUpdateOne) {
  4980. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4981. }
  4982. if m.id == nil || m.oldValue == nil {
  4983. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4984. }
  4985. oldValue, err := m.oldValue(ctx)
  4986. if err != nil {
  4987. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4988. }
  4989. return oldValue.OrganizationID, nil
  4990. }
  4991. // AddOrganizationID adds u to the "organization_id" field.
  4992. func (m *CategoryMutation) AddOrganizationID(u int64) {
  4993. if m.addorganization_id != nil {
  4994. *m.addorganization_id += u
  4995. } else {
  4996. m.addorganization_id = &u
  4997. }
  4998. }
  4999. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5000. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  5001. v := m.addorganization_id
  5002. if v == nil {
  5003. return
  5004. }
  5005. return *v, true
  5006. }
  5007. // ResetOrganizationID resets all changes to the "organization_id" field.
  5008. func (m *CategoryMutation) ResetOrganizationID() {
  5009. m.organization_id = nil
  5010. m.addorganization_id = nil
  5011. }
  5012. // Where appends a list predicates to the CategoryMutation builder.
  5013. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  5014. m.predicates = append(m.predicates, ps...)
  5015. }
  5016. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  5017. // users can use type-assertion to append predicates that do not depend on any generated package.
  5018. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  5019. p := make([]predicate.Category, len(ps))
  5020. for i := range ps {
  5021. p[i] = ps[i]
  5022. }
  5023. m.Where(p...)
  5024. }
  5025. // Op returns the operation name.
  5026. func (m *CategoryMutation) Op() Op {
  5027. return m.op
  5028. }
  5029. // SetOp allows setting the mutation operation.
  5030. func (m *CategoryMutation) SetOp(op Op) {
  5031. m.op = op
  5032. }
  5033. // Type returns the node type of this mutation (Category).
  5034. func (m *CategoryMutation) Type() string {
  5035. return m.typ
  5036. }
  5037. // Fields returns all fields that were changed during this mutation. Note that in
  5038. // order to get all numeric fields that were incremented/decremented, call
  5039. // AddedFields().
  5040. func (m *CategoryMutation) Fields() []string {
  5041. fields := make([]string, 0, 5)
  5042. if m.created_at != nil {
  5043. fields = append(fields, category.FieldCreatedAt)
  5044. }
  5045. if m.updated_at != nil {
  5046. fields = append(fields, category.FieldUpdatedAt)
  5047. }
  5048. if m.deleted_at != nil {
  5049. fields = append(fields, category.FieldDeletedAt)
  5050. }
  5051. if m.name != nil {
  5052. fields = append(fields, category.FieldName)
  5053. }
  5054. if m.organization_id != nil {
  5055. fields = append(fields, category.FieldOrganizationID)
  5056. }
  5057. return fields
  5058. }
  5059. // Field returns the value of a field with the given name. The second boolean
  5060. // return value indicates that this field was not set, or was not defined in the
  5061. // schema.
  5062. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  5063. switch name {
  5064. case category.FieldCreatedAt:
  5065. return m.CreatedAt()
  5066. case category.FieldUpdatedAt:
  5067. return m.UpdatedAt()
  5068. case category.FieldDeletedAt:
  5069. return m.DeletedAt()
  5070. case category.FieldName:
  5071. return m.Name()
  5072. case category.FieldOrganizationID:
  5073. return m.OrganizationID()
  5074. }
  5075. return nil, false
  5076. }
  5077. // OldField returns the old value of the field from the database. An error is
  5078. // returned if the mutation operation is not UpdateOne, or the query to the
  5079. // database failed.
  5080. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5081. switch name {
  5082. case category.FieldCreatedAt:
  5083. return m.OldCreatedAt(ctx)
  5084. case category.FieldUpdatedAt:
  5085. return m.OldUpdatedAt(ctx)
  5086. case category.FieldDeletedAt:
  5087. return m.OldDeletedAt(ctx)
  5088. case category.FieldName:
  5089. return m.OldName(ctx)
  5090. case category.FieldOrganizationID:
  5091. return m.OldOrganizationID(ctx)
  5092. }
  5093. return nil, fmt.Errorf("unknown Category field %s", name)
  5094. }
  5095. // SetField sets the value of a field with the given name. It returns an error if
  5096. // the field is not defined in the schema, or if the type mismatched the field
  5097. // type.
  5098. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  5099. switch name {
  5100. case category.FieldCreatedAt:
  5101. v, ok := value.(time.Time)
  5102. if !ok {
  5103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5104. }
  5105. m.SetCreatedAt(v)
  5106. return nil
  5107. case category.FieldUpdatedAt:
  5108. v, ok := value.(time.Time)
  5109. if !ok {
  5110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5111. }
  5112. m.SetUpdatedAt(v)
  5113. return nil
  5114. case category.FieldDeletedAt:
  5115. v, ok := value.(time.Time)
  5116. if !ok {
  5117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5118. }
  5119. m.SetDeletedAt(v)
  5120. return nil
  5121. case category.FieldName:
  5122. v, ok := value.(string)
  5123. if !ok {
  5124. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5125. }
  5126. m.SetName(v)
  5127. return nil
  5128. case category.FieldOrganizationID:
  5129. v, ok := value.(uint64)
  5130. if !ok {
  5131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5132. }
  5133. m.SetOrganizationID(v)
  5134. return nil
  5135. }
  5136. return fmt.Errorf("unknown Category field %s", name)
  5137. }
  5138. // AddedFields returns all numeric fields that were incremented/decremented during
  5139. // this mutation.
  5140. func (m *CategoryMutation) AddedFields() []string {
  5141. var fields []string
  5142. if m.addorganization_id != nil {
  5143. fields = append(fields, category.FieldOrganizationID)
  5144. }
  5145. return fields
  5146. }
  5147. // AddedField returns the numeric value that was incremented/decremented on a field
  5148. // with the given name. The second boolean return value indicates that this field
  5149. // was not set, or was not defined in the schema.
  5150. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  5151. switch name {
  5152. case category.FieldOrganizationID:
  5153. return m.AddedOrganizationID()
  5154. }
  5155. return nil, false
  5156. }
  5157. // AddField adds the value to the field with the given name. It returns an error if
  5158. // the field is not defined in the schema, or if the type mismatched the field
  5159. // type.
  5160. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  5161. switch name {
  5162. case category.FieldOrganizationID:
  5163. v, ok := value.(int64)
  5164. if !ok {
  5165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5166. }
  5167. m.AddOrganizationID(v)
  5168. return nil
  5169. }
  5170. return fmt.Errorf("unknown Category numeric field %s", name)
  5171. }
  5172. // ClearedFields returns all nullable fields that were cleared during this
  5173. // mutation.
  5174. func (m *CategoryMutation) ClearedFields() []string {
  5175. var fields []string
  5176. if m.FieldCleared(category.FieldDeletedAt) {
  5177. fields = append(fields, category.FieldDeletedAt)
  5178. }
  5179. return fields
  5180. }
  5181. // FieldCleared returns a boolean indicating if a field with the given name was
  5182. // cleared in this mutation.
  5183. func (m *CategoryMutation) FieldCleared(name string) bool {
  5184. _, ok := m.clearedFields[name]
  5185. return ok
  5186. }
  5187. // ClearField clears the value of the field with the given name. It returns an
  5188. // error if the field is not defined in the schema.
  5189. func (m *CategoryMutation) ClearField(name string) error {
  5190. switch name {
  5191. case category.FieldDeletedAt:
  5192. m.ClearDeletedAt()
  5193. return nil
  5194. }
  5195. return fmt.Errorf("unknown Category nullable field %s", name)
  5196. }
  5197. // ResetField resets all changes in the mutation for the field with the given name.
  5198. // It returns an error if the field is not defined in the schema.
  5199. func (m *CategoryMutation) ResetField(name string) error {
  5200. switch name {
  5201. case category.FieldCreatedAt:
  5202. m.ResetCreatedAt()
  5203. return nil
  5204. case category.FieldUpdatedAt:
  5205. m.ResetUpdatedAt()
  5206. return nil
  5207. case category.FieldDeletedAt:
  5208. m.ResetDeletedAt()
  5209. return nil
  5210. case category.FieldName:
  5211. m.ResetName()
  5212. return nil
  5213. case category.FieldOrganizationID:
  5214. m.ResetOrganizationID()
  5215. return nil
  5216. }
  5217. return fmt.Errorf("unknown Category field %s", name)
  5218. }
  5219. // AddedEdges returns all edge names that were set/added in this mutation.
  5220. func (m *CategoryMutation) AddedEdges() []string {
  5221. edges := make([]string, 0, 0)
  5222. return edges
  5223. }
  5224. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5225. // name in this mutation.
  5226. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  5227. return nil
  5228. }
  5229. // RemovedEdges returns all edge names that were removed in this mutation.
  5230. func (m *CategoryMutation) RemovedEdges() []string {
  5231. edges := make([]string, 0, 0)
  5232. return edges
  5233. }
  5234. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5235. // the given name in this mutation.
  5236. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  5237. return nil
  5238. }
  5239. // ClearedEdges returns all edge names that were cleared in this mutation.
  5240. func (m *CategoryMutation) ClearedEdges() []string {
  5241. edges := make([]string, 0, 0)
  5242. return edges
  5243. }
  5244. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5245. // was cleared in this mutation.
  5246. func (m *CategoryMutation) EdgeCleared(name string) bool {
  5247. return false
  5248. }
  5249. // ClearEdge clears the value of the edge with the given name. It returns an error
  5250. // if that edge is not defined in the schema.
  5251. func (m *CategoryMutation) ClearEdge(name string) error {
  5252. return fmt.Errorf("unknown Category unique edge %s", name)
  5253. }
  5254. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5255. // It returns an error if the edge is not defined in the schema.
  5256. func (m *CategoryMutation) ResetEdge(name string) error {
  5257. return fmt.Errorf("unknown Category edge %s", name)
  5258. }
  5259. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  5260. type ChatRecordsMutation struct {
  5261. config
  5262. op Op
  5263. typ string
  5264. id *uint64
  5265. created_at *time.Time
  5266. updated_at *time.Time
  5267. deleted_at *time.Time
  5268. content *string
  5269. content_type *uint8
  5270. addcontent_type *int8
  5271. session_id *uint64
  5272. addsession_id *int64
  5273. user_id *uint64
  5274. adduser_id *int64
  5275. bot_id *uint64
  5276. addbot_id *int64
  5277. bot_type *uint8
  5278. addbot_type *int8
  5279. clearedFields map[string]struct{}
  5280. done bool
  5281. oldValue func(context.Context) (*ChatRecords, error)
  5282. predicates []predicate.ChatRecords
  5283. }
  5284. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  5285. // chatrecordsOption allows management of the mutation configuration using functional options.
  5286. type chatrecordsOption func(*ChatRecordsMutation)
  5287. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  5288. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  5289. m := &ChatRecordsMutation{
  5290. config: c,
  5291. op: op,
  5292. typ: TypeChatRecords,
  5293. clearedFields: make(map[string]struct{}),
  5294. }
  5295. for _, opt := range opts {
  5296. opt(m)
  5297. }
  5298. return m
  5299. }
  5300. // withChatRecordsID sets the ID field of the mutation.
  5301. func withChatRecordsID(id uint64) chatrecordsOption {
  5302. return func(m *ChatRecordsMutation) {
  5303. var (
  5304. err error
  5305. once sync.Once
  5306. value *ChatRecords
  5307. )
  5308. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  5309. once.Do(func() {
  5310. if m.done {
  5311. err = errors.New("querying old values post mutation is not allowed")
  5312. } else {
  5313. value, err = m.Client().ChatRecords.Get(ctx, id)
  5314. }
  5315. })
  5316. return value, err
  5317. }
  5318. m.id = &id
  5319. }
  5320. }
  5321. // withChatRecords sets the old ChatRecords of the mutation.
  5322. func withChatRecords(node *ChatRecords) chatrecordsOption {
  5323. return func(m *ChatRecordsMutation) {
  5324. m.oldValue = func(context.Context) (*ChatRecords, error) {
  5325. return node, nil
  5326. }
  5327. m.id = &node.ID
  5328. }
  5329. }
  5330. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5331. // executed in a transaction (ent.Tx), a transactional client is returned.
  5332. func (m ChatRecordsMutation) Client() *Client {
  5333. client := &Client{config: m.config}
  5334. client.init()
  5335. return client
  5336. }
  5337. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5338. // it returns an error otherwise.
  5339. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  5340. if _, ok := m.driver.(*txDriver); !ok {
  5341. return nil, errors.New("ent: mutation is not running in a transaction")
  5342. }
  5343. tx := &Tx{config: m.config}
  5344. tx.init()
  5345. return tx, nil
  5346. }
  5347. // SetID sets the value of the id field. Note that this
  5348. // operation is only accepted on creation of ChatRecords entities.
  5349. func (m *ChatRecordsMutation) SetID(id uint64) {
  5350. m.id = &id
  5351. }
  5352. // ID returns the ID value in the mutation. Note that the ID is only available
  5353. // if it was provided to the builder or after it was returned from the database.
  5354. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  5355. if m.id == nil {
  5356. return
  5357. }
  5358. return *m.id, true
  5359. }
  5360. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5361. // That means, if the mutation is applied within a transaction with an isolation level such
  5362. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5363. // or updated by the mutation.
  5364. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  5365. switch {
  5366. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5367. id, exists := m.ID()
  5368. if exists {
  5369. return []uint64{id}, nil
  5370. }
  5371. fallthrough
  5372. case m.op.Is(OpUpdate | OpDelete):
  5373. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  5374. default:
  5375. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5376. }
  5377. }
  5378. // SetCreatedAt sets the "created_at" field.
  5379. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  5380. m.created_at = &t
  5381. }
  5382. // CreatedAt returns the value of the "created_at" field in the mutation.
  5383. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  5384. v := m.created_at
  5385. if v == nil {
  5386. return
  5387. }
  5388. return *v, true
  5389. }
  5390. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  5391. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5392. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5393. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5394. if !m.op.Is(OpUpdateOne) {
  5395. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5396. }
  5397. if m.id == nil || m.oldValue == nil {
  5398. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5399. }
  5400. oldValue, err := m.oldValue(ctx)
  5401. if err != nil {
  5402. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5403. }
  5404. return oldValue.CreatedAt, nil
  5405. }
  5406. // ResetCreatedAt resets all changes to the "created_at" field.
  5407. func (m *ChatRecordsMutation) ResetCreatedAt() {
  5408. m.created_at = nil
  5409. }
  5410. // SetUpdatedAt sets the "updated_at" field.
  5411. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  5412. m.updated_at = &t
  5413. }
  5414. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5415. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  5416. v := m.updated_at
  5417. if v == nil {
  5418. return
  5419. }
  5420. return *v, true
  5421. }
  5422. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  5423. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5424. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5425. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5426. if !m.op.Is(OpUpdateOne) {
  5427. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5428. }
  5429. if m.id == nil || m.oldValue == nil {
  5430. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5431. }
  5432. oldValue, err := m.oldValue(ctx)
  5433. if err != nil {
  5434. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5435. }
  5436. return oldValue.UpdatedAt, nil
  5437. }
  5438. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5439. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  5440. m.updated_at = nil
  5441. }
  5442. // SetDeletedAt sets the "deleted_at" field.
  5443. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  5444. m.deleted_at = &t
  5445. }
  5446. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5447. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  5448. v := m.deleted_at
  5449. if v == nil {
  5450. return
  5451. }
  5452. return *v, true
  5453. }
  5454. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  5455. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5456. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5457. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5458. if !m.op.Is(OpUpdateOne) {
  5459. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5460. }
  5461. if m.id == nil || m.oldValue == nil {
  5462. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5463. }
  5464. oldValue, err := m.oldValue(ctx)
  5465. if err != nil {
  5466. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5467. }
  5468. return oldValue.DeletedAt, nil
  5469. }
  5470. // ClearDeletedAt clears the value of the "deleted_at" field.
  5471. func (m *ChatRecordsMutation) ClearDeletedAt() {
  5472. m.deleted_at = nil
  5473. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  5474. }
  5475. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5476. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  5477. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  5478. return ok
  5479. }
  5480. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5481. func (m *ChatRecordsMutation) ResetDeletedAt() {
  5482. m.deleted_at = nil
  5483. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  5484. }
  5485. // SetContent sets the "content" field.
  5486. func (m *ChatRecordsMutation) SetContent(s string) {
  5487. m.content = &s
  5488. }
  5489. // Content returns the value of the "content" field in the mutation.
  5490. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  5491. v := m.content
  5492. if v == nil {
  5493. return
  5494. }
  5495. return *v, true
  5496. }
  5497. // OldContent returns the old "content" field's value of the ChatRecords entity.
  5498. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5499. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5500. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  5501. if !m.op.Is(OpUpdateOne) {
  5502. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  5503. }
  5504. if m.id == nil || m.oldValue == nil {
  5505. return v, errors.New("OldContent requires an ID field in the mutation")
  5506. }
  5507. oldValue, err := m.oldValue(ctx)
  5508. if err != nil {
  5509. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  5510. }
  5511. return oldValue.Content, nil
  5512. }
  5513. // ResetContent resets all changes to the "content" field.
  5514. func (m *ChatRecordsMutation) ResetContent() {
  5515. m.content = nil
  5516. }
  5517. // SetContentType sets the "content_type" field.
  5518. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  5519. m.content_type = &u
  5520. m.addcontent_type = nil
  5521. }
  5522. // ContentType returns the value of the "content_type" field in the mutation.
  5523. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  5524. v := m.content_type
  5525. if v == nil {
  5526. return
  5527. }
  5528. return *v, true
  5529. }
  5530. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  5531. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5533. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  5534. if !m.op.Is(OpUpdateOne) {
  5535. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  5536. }
  5537. if m.id == nil || m.oldValue == nil {
  5538. return v, errors.New("OldContentType requires an ID field in the mutation")
  5539. }
  5540. oldValue, err := m.oldValue(ctx)
  5541. if err != nil {
  5542. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  5543. }
  5544. return oldValue.ContentType, nil
  5545. }
  5546. // AddContentType adds u to the "content_type" field.
  5547. func (m *ChatRecordsMutation) AddContentType(u int8) {
  5548. if m.addcontent_type != nil {
  5549. *m.addcontent_type += u
  5550. } else {
  5551. m.addcontent_type = &u
  5552. }
  5553. }
  5554. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  5555. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  5556. v := m.addcontent_type
  5557. if v == nil {
  5558. return
  5559. }
  5560. return *v, true
  5561. }
  5562. // ResetContentType resets all changes to the "content_type" field.
  5563. func (m *ChatRecordsMutation) ResetContentType() {
  5564. m.content_type = nil
  5565. m.addcontent_type = nil
  5566. }
  5567. // SetSessionID sets the "session_id" field.
  5568. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  5569. m.session_id = &u
  5570. m.addsession_id = nil
  5571. }
  5572. // SessionID returns the value of the "session_id" field in the mutation.
  5573. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  5574. v := m.session_id
  5575. if v == nil {
  5576. return
  5577. }
  5578. return *v, true
  5579. }
  5580. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  5581. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5582. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5583. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  5584. if !m.op.Is(OpUpdateOne) {
  5585. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  5586. }
  5587. if m.id == nil || m.oldValue == nil {
  5588. return v, errors.New("OldSessionID requires an ID field in the mutation")
  5589. }
  5590. oldValue, err := m.oldValue(ctx)
  5591. if err != nil {
  5592. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  5593. }
  5594. return oldValue.SessionID, nil
  5595. }
  5596. // AddSessionID adds u to the "session_id" field.
  5597. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  5598. if m.addsession_id != nil {
  5599. *m.addsession_id += u
  5600. } else {
  5601. m.addsession_id = &u
  5602. }
  5603. }
  5604. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  5605. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  5606. v := m.addsession_id
  5607. if v == nil {
  5608. return
  5609. }
  5610. return *v, true
  5611. }
  5612. // ResetSessionID resets all changes to the "session_id" field.
  5613. func (m *ChatRecordsMutation) ResetSessionID() {
  5614. m.session_id = nil
  5615. m.addsession_id = nil
  5616. }
  5617. // SetUserID sets the "user_id" field.
  5618. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  5619. m.user_id = &u
  5620. m.adduser_id = nil
  5621. }
  5622. // UserID returns the value of the "user_id" field in the mutation.
  5623. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  5624. v := m.user_id
  5625. if v == nil {
  5626. return
  5627. }
  5628. return *v, true
  5629. }
  5630. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  5631. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5632. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5633. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  5634. if !m.op.Is(OpUpdateOne) {
  5635. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  5636. }
  5637. if m.id == nil || m.oldValue == nil {
  5638. return v, errors.New("OldUserID requires an ID field in the mutation")
  5639. }
  5640. oldValue, err := m.oldValue(ctx)
  5641. if err != nil {
  5642. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  5643. }
  5644. return oldValue.UserID, nil
  5645. }
  5646. // AddUserID adds u to the "user_id" field.
  5647. func (m *ChatRecordsMutation) AddUserID(u int64) {
  5648. if m.adduser_id != nil {
  5649. *m.adduser_id += u
  5650. } else {
  5651. m.adduser_id = &u
  5652. }
  5653. }
  5654. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  5655. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  5656. v := m.adduser_id
  5657. if v == nil {
  5658. return
  5659. }
  5660. return *v, true
  5661. }
  5662. // ResetUserID resets all changes to the "user_id" field.
  5663. func (m *ChatRecordsMutation) ResetUserID() {
  5664. m.user_id = nil
  5665. m.adduser_id = nil
  5666. }
  5667. // SetBotID sets the "bot_id" field.
  5668. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  5669. m.bot_id = &u
  5670. m.addbot_id = nil
  5671. }
  5672. // BotID returns the value of the "bot_id" field in the mutation.
  5673. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  5674. v := m.bot_id
  5675. if v == nil {
  5676. return
  5677. }
  5678. return *v, true
  5679. }
  5680. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  5681. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5682. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5683. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  5684. if !m.op.Is(OpUpdateOne) {
  5685. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  5686. }
  5687. if m.id == nil || m.oldValue == nil {
  5688. return v, errors.New("OldBotID requires an ID field in the mutation")
  5689. }
  5690. oldValue, err := m.oldValue(ctx)
  5691. if err != nil {
  5692. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  5693. }
  5694. return oldValue.BotID, nil
  5695. }
  5696. // AddBotID adds u to the "bot_id" field.
  5697. func (m *ChatRecordsMutation) AddBotID(u int64) {
  5698. if m.addbot_id != nil {
  5699. *m.addbot_id += u
  5700. } else {
  5701. m.addbot_id = &u
  5702. }
  5703. }
  5704. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  5705. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  5706. v := m.addbot_id
  5707. if v == nil {
  5708. return
  5709. }
  5710. return *v, true
  5711. }
  5712. // ResetBotID resets all changes to the "bot_id" field.
  5713. func (m *ChatRecordsMutation) ResetBotID() {
  5714. m.bot_id = nil
  5715. m.addbot_id = nil
  5716. }
  5717. // SetBotType sets the "bot_type" field.
  5718. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  5719. m.bot_type = &u
  5720. m.addbot_type = nil
  5721. }
  5722. // BotType returns the value of the "bot_type" field in the mutation.
  5723. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  5724. v := m.bot_type
  5725. if v == nil {
  5726. return
  5727. }
  5728. return *v, true
  5729. }
  5730. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  5731. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5732. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5733. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  5734. if !m.op.Is(OpUpdateOne) {
  5735. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  5736. }
  5737. if m.id == nil || m.oldValue == nil {
  5738. return v, errors.New("OldBotType requires an ID field in the mutation")
  5739. }
  5740. oldValue, err := m.oldValue(ctx)
  5741. if err != nil {
  5742. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  5743. }
  5744. return oldValue.BotType, nil
  5745. }
  5746. // AddBotType adds u to the "bot_type" field.
  5747. func (m *ChatRecordsMutation) AddBotType(u int8) {
  5748. if m.addbot_type != nil {
  5749. *m.addbot_type += u
  5750. } else {
  5751. m.addbot_type = &u
  5752. }
  5753. }
  5754. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  5755. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  5756. v := m.addbot_type
  5757. if v == nil {
  5758. return
  5759. }
  5760. return *v, true
  5761. }
  5762. // ResetBotType resets all changes to the "bot_type" field.
  5763. func (m *ChatRecordsMutation) ResetBotType() {
  5764. m.bot_type = nil
  5765. m.addbot_type = nil
  5766. }
  5767. // Where appends a list predicates to the ChatRecordsMutation builder.
  5768. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  5769. m.predicates = append(m.predicates, ps...)
  5770. }
  5771. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  5772. // users can use type-assertion to append predicates that do not depend on any generated package.
  5773. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  5774. p := make([]predicate.ChatRecords, len(ps))
  5775. for i := range ps {
  5776. p[i] = ps[i]
  5777. }
  5778. m.Where(p...)
  5779. }
  5780. // Op returns the operation name.
  5781. func (m *ChatRecordsMutation) Op() Op {
  5782. return m.op
  5783. }
  5784. // SetOp allows setting the mutation operation.
  5785. func (m *ChatRecordsMutation) SetOp(op Op) {
  5786. m.op = op
  5787. }
  5788. // Type returns the node type of this mutation (ChatRecords).
  5789. func (m *ChatRecordsMutation) Type() string {
  5790. return m.typ
  5791. }
  5792. // Fields returns all fields that were changed during this mutation. Note that in
  5793. // order to get all numeric fields that were incremented/decremented, call
  5794. // AddedFields().
  5795. func (m *ChatRecordsMutation) Fields() []string {
  5796. fields := make([]string, 0, 9)
  5797. if m.created_at != nil {
  5798. fields = append(fields, chatrecords.FieldCreatedAt)
  5799. }
  5800. if m.updated_at != nil {
  5801. fields = append(fields, chatrecords.FieldUpdatedAt)
  5802. }
  5803. if m.deleted_at != nil {
  5804. fields = append(fields, chatrecords.FieldDeletedAt)
  5805. }
  5806. if m.content != nil {
  5807. fields = append(fields, chatrecords.FieldContent)
  5808. }
  5809. if m.content_type != nil {
  5810. fields = append(fields, chatrecords.FieldContentType)
  5811. }
  5812. if m.session_id != nil {
  5813. fields = append(fields, chatrecords.FieldSessionID)
  5814. }
  5815. if m.user_id != nil {
  5816. fields = append(fields, chatrecords.FieldUserID)
  5817. }
  5818. if m.bot_id != nil {
  5819. fields = append(fields, chatrecords.FieldBotID)
  5820. }
  5821. if m.bot_type != nil {
  5822. fields = append(fields, chatrecords.FieldBotType)
  5823. }
  5824. return fields
  5825. }
  5826. // Field returns the value of a field with the given name. The second boolean
  5827. // return value indicates that this field was not set, or was not defined in the
  5828. // schema.
  5829. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  5830. switch name {
  5831. case chatrecords.FieldCreatedAt:
  5832. return m.CreatedAt()
  5833. case chatrecords.FieldUpdatedAt:
  5834. return m.UpdatedAt()
  5835. case chatrecords.FieldDeletedAt:
  5836. return m.DeletedAt()
  5837. case chatrecords.FieldContent:
  5838. return m.Content()
  5839. case chatrecords.FieldContentType:
  5840. return m.ContentType()
  5841. case chatrecords.FieldSessionID:
  5842. return m.SessionID()
  5843. case chatrecords.FieldUserID:
  5844. return m.UserID()
  5845. case chatrecords.FieldBotID:
  5846. return m.BotID()
  5847. case chatrecords.FieldBotType:
  5848. return m.BotType()
  5849. }
  5850. return nil, false
  5851. }
  5852. // OldField returns the old value of the field from the database. An error is
  5853. // returned if the mutation operation is not UpdateOne, or the query to the
  5854. // database failed.
  5855. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5856. switch name {
  5857. case chatrecords.FieldCreatedAt:
  5858. return m.OldCreatedAt(ctx)
  5859. case chatrecords.FieldUpdatedAt:
  5860. return m.OldUpdatedAt(ctx)
  5861. case chatrecords.FieldDeletedAt:
  5862. return m.OldDeletedAt(ctx)
  5863. case chatrecords.FieldContent:
  5864. return m.OldContent(ctx)
  5865. case chatrecords.FieldContentType:
  5866. return m.OldContentType(ctx)
  5867. case chatrecords.FieldSessionID:
  5868. return m.OldSessionID(ctx)
  5869. case chatrecords.FieldUserID:
  5870. return m.OldUserID(ctx)
  5871. case chatrecords.FieldBotID:
  5872. return m.OldBotID(ctx)
  5873. case chatrecords.FieldBotType:
  5874. return m.OldBotType(ctx)
  5875. }
  5876. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  5877. }
  5878. // SetField sets the value of a field with the given name. It returns an error if
  5879. // the field is not defined in the schema, or if the type mismatched the field
  5880. // type.
  5881. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  5882. switch name {
  5883. case chatrecords.FieldCreatedAt:
  5884. v, ok := value.(time.Time)
  5885. if !ok {
  5886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5887. }
  5888. m.SetCreatedAt(v)
  5889. return nil
  5890. case chatrecords.FieldUpdatedAt:
  5891. v, ok := value.(time.Time)
  5892. if !ok {
  5893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5894. }
  5895. m.SetUpdatedAt(v)
  5896. return nil
  5897. case chatrecords.FieldDeletedAt:
  5898. v, ok := value.(time.Time)
  5899. if !ok {
  5900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5901. }
  5902. m.SetDeletedAt(v)
  5903. return nil
  5904. case chatrecords.FieldContent:
  5905. v, ok := value.(string)
  5906. if !ok {
  5907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5908. }
  5909. m.SetContent(v)
  5910. return nil
  5911. case chatrecords.FieldContentType:
  5912. v, ok := value.(uint8)
  5913. if !ok {
  5914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5915. }
  5916. m.SetContentType(v)
  5917. return nil
  5918. case chatrecords.FieldSessionID:
  5919. v, ok := value.(uint64)
  5920. if !ok {
  5921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5922. }
  5923. m.SetSessionID(v)
  5924. return nil
  5925. case chatrecords.FieldUserID:
  5926. v, ok := value.(uint64)
  5927. if !ok {
  5928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5929. }
  5930. m.SetUserID(v)
  5931. return nil
  5932. case chatrecords.FieldBotID:
  5933. v, ok := value.(uint64)
  5934. if !ok {
  5935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5936. }
  5937. m.SetBotID(v)
  5938. return nil
  5939. case chatrecords.FieldBotType:
  5940. v, ok := value.(uint8)
  5941. if !ok {
  5942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5943. }
  5944. m.SetBotType(v)
  5945. return nil
  5946. }
  5947. return fmt.Errorf("unknown ChatRecords field %s", name)
  5948. }
  5949. // AddedFields returns all numeric fields that were incremented/decremented during
  5950. // this mutation.
  5951. func (m *ChatRecordsMutation) AddedFields() []string {
  5952. var fields []string
  5953. if m.addcontent_type != nil {
  5954. fields = append(fields, chatrecords.FieldContentType)
  5955. }
  5956. if m.addsession_id != nil {
  5957. fields = append(fields, chatrecords.FieldSessionID)
  5958. }
  5959. if m.adduser_id != nil {
  5960. fields = append(fields, chatrecords.FieldUserID)
  5961. }
  5962. if m.addbot_id != nil {
  5963. fields = append(fields, chatrecords.FieldBotID)
  5964. }
  5965. if m.addbot_type != nil {
  5966. fields = append(fields, chatrecords.FieldBotType)
  5967. }
  5968. return fields
  5969. }
  5970. // AddedField returns the numeric value that was incremented/decremented on a field
  5971. // with the given name. The second boolean return value indicates that this field
  5972. // was not set, or was not defined in the schema.
  5973. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  5974. switch name {
  5975. case chatrecords.FieldContentType:
  5976. return m.AddedContentType()
  5977. case chatrecords.FieldSessionID:
  5978. return m.AddedSessionID()
  5979. case chatrecords.FieldUserID:
  5980. return m.AddedUserID()
  5981. case chatrecords.FieldBotID:
  5982. return m.AddedBotID()
  5983. case chatrecords.FieldBotType:
  5984. return m.AddedBotType()
  5985. }
  5986. return nil, false
  5987. }
  5988. // AddField adds the value to the field with the given name. It returns an error if
  5989. // the field is not defined in the schema, or if the type mismatched the field
  5990. // type.
  5991. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  5992. switch name {
  5993. case chatrecords.FieldContentType:
  5994. v, ok := value.(int8)
  5995. if !ok {
  5996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5997. }
  5998. m.AddContentType(v)
  5999. return nil
  6000. case chatrecords.FieldSessionID:
  6001. v, ok := value.(int64)
  6002. if !ok {
  6003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6004. }
  6005. m.AddSessionID(v)
  6006. return nil
  6007. case chatrecords.FieldUserID:
  6008. v, ok := value.(int64)
  6009. if !ok {
  6010. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6011. }
  6012. m.AddUserID(v)
  6013. return nil
  6014. case chatrecords.FieldBotID:
  6015. v, ok := value.(int64)
  6016. if !ok {
  6017. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6018. }
  6019. m.AddBotID(v)
  6020. return nil
  6021. case chatrecords.FieldBotType:
  6022. v, ok := value.(int8)
  6023. if !ok {
  6024. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6025. }
  6026. m.AddBotType(v)
  6027. return nil
  6028. }
  6029. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  6030. }
  6031. // ClearedFields returns all nullable fields that were cleared during this
  6032. // mutation.
  6033. func (m *ChatRecordsMutation) ClearedFields() []string {
  6034. var fields []string
  6035. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  6036. fields = append(fields, chatrecords.FieldDeletedAt)
  6037. }
  6038. return fields
  6039. }
  6040. // FieldCleared returns a boolean indicating if a field with the given name was
  6041. // cleared in this mutation.
  6042. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  6043. _, ok := m.clearedFields[name]
  6044. return ok
  6045. }
  6046. // ClearField clears the value of the field with the given name. It returns an
  6047. // error if the field is not defined in the schema.
  6048. func (m *ChatRecordsMutation) ClearField(name string) error {
  6049. switch name {
  6050. case chatrecords.FieldDeletedAt:
  6051. m.ClearDeletedAt()
  6052. return nil
  6053. }
  6054. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  6055. }
  6056. // ResetField resets all changes in the mutation for the field with the given name.
  6057. // It returns an error if the field is not defined in the schema.
  6058. func (m *ChatRecordsMutation) ResetField(name string) error {
  6059. switch name {
  6060. case chatrecords.FieldCreatedAt:
  6061. m.ResetCreatedAt()
  6062. return nil
  6063. case chatrecords.FieldUpdatedAt:
  6064. m.ResetUpdatedAt()
  6065. return nil
  6066. case chatrecords.FieldDeletedAt:
  6067. m.ResetDeletedAt()
  6068. return nil
  6069. case chatrecords.FieldContent:
  6070. m.ResetContent()
  6071. return nil
  6072. case chatrecords.FieldContentType:
  6073. m.ResetContentType()
  6074. return nil
  6075. case chatrecords.FieldSessionID:
  6076. m.ResetSessionID()
  6077. return nil
  6078. case chatrecords.FieldUserID:
  6079. m.ResetUserID()
  6080. return nil
  6081. case chatrecords.FieldBotID:
  6082. m.ResetBotID()
  6083. return nil
  6084. case chatrecords.FieldBotType:
  6085. m.ResetBotType()
  6086. return nil
  6087. }
  6088. return fmt.Errorf("unknown ChatRecords field %s", name)
  6089. }
  6090. // AddedEdges returns all edge names that were set/added in this mutation.
  6091. func (m *ChatRecordsMutation) AddedEdges() []string {
  6092. edges := make([]string, 0, 0)
  6093. return edges
  6094. }
  6095. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6096. // name in this mutation.
  6097. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  6098. return nil
  6099. }
  6100. // RemovedEdges returns all edge names that were removed in this mutation.
  6101. func (m *ChatRecordsMutation) RemovedEdges() []string {
  6102. edges := make([]string, 0, 0)
  6103. return edges
  6104. }
  6105. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6106. // the given name in this mutation.
  6107. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  6108. return nil
  6109. }
  6110. // ClearedEdges returns all edge names that were cleared in this mutation.
  6111. func (m *ChatRecordsMutation) ClearedEdges() []string {
  6112. edges := make([]string, 0, 0)
  6113. return edges
  6114. }
  6115. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6116. // was cleared in this mutation.
  6117. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  6118. return false
  6119. }
  6120. // ClearEdge clears the value of the edge with the given name. It returns an error
  6121. // if that edge is not defined in the schema.
  6122. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  6123. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  6124. }
  6125. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6126. // It returns an error if the edge is not defined in the schema.
  6127. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  6128. return fmt.Errorf("unknown ChatRecords edge %s", name)
  6129. }
  6130. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  6131. type ChatSessionMutation struct {
  6132. config
  6133. op Op
  6134. typ string
  6135. id *uint64
  6136. created_at *time.Time
  6137. updated_at *time.Time
  6138. deleted_at *time.Time
  6139. name *string
  6140. user_id *uint64
  6141. adduser_id *int64
  6142. bot_id *uint64
  6143. addbot_id *int64
  6144. bot_type *uint8
  6145. addbot_type *int8
  6146. clearedFields map[string]struct{}
  6147. done bool
  6148. oldValue func(context.Context) (*ChatSession, error)
  6149. predicates []predicate.ChatSession
  6150. }
  6151. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  6152. // chatsessionOption allows management of the mutation configuration using functional options.
  6153. type chatsessionOption func(*ChatSessionMutation)
  6154. // newChatSessionMutation creates new mutation for the ChatSession entity.
  6155. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  6156. m := &ChatSessionMutation{
  6157. config: c,
  6158. op: op,
  6159. typ: TypeChatSession,
  6160. clearedFields: make(map[string]struct{}),
  6161. }
  6162. for _, opt := range opts {
  6163. opt(m)
  6164. }
  6165. return m
  6166. }
  6167. // withChatSessionID sets the ID field of the mutation.
  6168. func withChatSessionID(id uint64) chatsessionOption {
  6169. return func(m *ChatSessionMutation) {
  6170. var (
  6171. err error
  6172. once sync.Once
  6173. value *ChatSession
  6174. )
  6175. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  6176. once.Do(func() {
  6177. if m.done {
  6178. err = errors.New("querying old values post mutation is not allowed")
  6179. } else {
  6180. value, err = m.Client().ChatSession.Get(ctx, id)
  6181. }
  6182. })
  6183. return value, err
  6184. }
  6185. m.id = &id
  6186. }
  6187. }
  6188. // withChatSession sets the old ChatSession of the mutation.
  6189. func withChatSession(node *ChatSession) chatsessionOption {
  6190. return func(m *ChatSessionMutation) {
  6191. m.oldValue = func(context.Context) (*ChatSession, error) {
  6192. return node, nil
  6193. }
  6194. m.id = &node.ID
  6195. }
  6196. }
  6197. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6198. // executed in a transaction (ent.Tx), a transactional client is returned.
  6199. func (m ChatSessionMutation) Client() *Client {
  6200. client := &Client{config: m.config}
  6201. client.init()
  6202. return client
  6203. }
  6204. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6205. // it returns an error otherwise.
  6206. func (m ChatSessionMutation) Tx() (*Tx, error) {
  6207. if _, ok := m.driver.(*txDriver); !ok {
  6208. return nil, errors.New("ent: mutation is not running in a transaction")
  6209. }
  6210. tx := &Tx{config: m.config}
  6211. tx.init()
  6212. return tx, nil
  6213. }
  6214. // SetID sets the value of the id field. Note that this
  6215. // operation is only accepted on creation of ChatSession entities.
  6216. func (m *ChatSessionMutation) SetID(id uint64) {
  6217. m.id = &id
  6218. }
  6219. // ID returns the ID value in the mutation. Note that the ID is only available
  6220. // if it was provided to the builder or after it was returned from the database.
  6221. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  6222. if m.id == nil {
  6223. return
  6224. }
  6225. return *m.id, true
  6226. }
  6227. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6228. // That means, if the mutation is applied within a transaction with an isolation level such
  6229. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6230. // or updated by the mutation.
  6231. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  6232. switch {
  6233. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6234. id, exists := m.ID()
  6235. if exists {
  6236. return []uint64{id}, nil
  6237. }
  6238. fallthrough
  6239. case m.op.Is(OpUpdate | OpDelete):
  6240. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  6241. default:
  6242. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6243. }
  6244. }
  6245. // SetCreatedAt sets the "created_at" field.
  6246. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  6247. m.created_at = &t
  6248. }
  6249. // CreatedAt returns the value of the "created_at" field in the mutation.
  6250. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  6251. v := m.created_at
  6252. if v == nil {
  6253. return
  6254. }
  6255. return *v, true
  6256. }
  6257. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  6258. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6259. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6260. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6261. if !m.op.Is(OpUpdateOne) {
  6262. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6263. }
  6264. if m.id == nil || m.oldValue == nil {
  6265. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6266. }
  6267. oldValue, err := m.oldValue(ctx)
  6268. if err != nil {
  6269. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6270. }
  6271. return oldValue.CreatedAt, nil
  6272. }
  6273. // ResetCreatedAt resets all changes to the "created_at" field.
  6274. func (m *ChatSessionMutation) ResetCreatedAt() {
  6275. m.created_at = nil
  6276. }
  6277. // SetUpdatedAt sets the "updated_at" field.
  6278. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  6279. m.updated_at = &t
  6280. }
  6281. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6282. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  6283. v := m.updated_at
  6284. if v == nil {
  6285. return
  6286. }
  6287. return *v, true
  6288. }
  6289. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  6290. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6291. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6292. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6293. if !m.op.Is(OpUpdateOne) {
  6294. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6295. }
  6296. if m.id == nil || m.oldValue == nil {
  6297. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6298. }
  6299. oldValue, err := m.oldValue(ctx)
  6300. if err != nil {
  6301. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6302. }
  6303. return oldValue.UpdatedAt, nil
  6304. }
  6305. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6306. func (m *ChatSessionMutation) ResetUpdatedAt() {
  6307. m.updated_at = nil
  6308. }
  6309. // SetDeletedAt sets the "deleted_at" field.
  6310. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  6311. m.deleted_at = &t
  6312. }
  6313. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6314. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  6315. v := m.deleted_at
  6316. if v == nil {
  6317. return
  6318. }
  6319. return *v, true
  6320. }
  6321. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  6322. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6323. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6324. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6325. if !m.op.Is(OpUpdateOne) {
  6326. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6327. }
  6328. if m.id == nil || m.oldValue == nil {
  6329. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6330. }
  6331. oldValue, err := m.oldValue(ctx)
  6332. if err != nil {
  6333. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6334. }
  6335. return oldValue.DeletedAt, nil
  6336. }
  6337. // ClearDeletedAt clears the value of the "deleted_at" field.
  6338. func (m *ChatSessionMutation) ClearDeletedAt() {
  6339. m.deleted_at = nil
  6340. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  6341. }
  6342. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6343. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  6344. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  6345. return ok
  6346. }
  6347. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6348. func (m *ChatSessionMutation) ResetDeletedAt() {
  6349. m.deleted_at = nil
  6350. delete(m.clearedFields, chatsession.FieldDeletedAt)
  6351. }
  6352. // SetName sets the "name" field.
  6353. func (m *ChatSessionMutation) SetName(s string) {
  6354. m.name = &s
  6355. }
  6356. // Name returns the value of the "name" field in the mutation.
  6357. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  6358. v := m.name
  6359. if v == nil {
  6360. return
  6361. }
  6362. return *v, true
  6363. }
  6364. // OldName returns the old "name" field's value of the ChatSession entity.
  6365. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6366. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6367. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  6368. if !m.op.Is(OpUpdateOne) {
  6369. return v, errors.New("OldName is only allowed on UpdateOne operations")
  6370. }
  6371. if m.id == nil || m.oldValue == nil {
  6372. return v, errors.New("OldName requires an ID field in the mutation")
  6373. }
  6374. oldValue, err := m.oldValue(ctx)
  6375. if err != nil {
  6376. return v, fmt.Errorf("querying old value for OldName: %w", err)
  6377. }
  6378. return oldValue.Name, nil
  6379. }
  6380. // ResetName resets all changes to the "name" field.
  6381. func (m *ChatSessionMutation) ResetName() {
  6382. m.name = nil
  6383. }
  6384. // SetUserID sets the "user_id" field.
  6385. func (m *ChatSessionMutation) SetUserID(u uint64) {
  6386. m.user_id = &u
  6387. m.adduser_id = nil
  6388. }
  6389. // UserID returns the value of the "user_id" field in the mutation.
  6390. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  6391. v := m.user_id
  6392. if v == nil {
  6393. return
  6394. }
  6395. return *v, true
  6396. }
  6397. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  6398. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6400. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  6401. if !m.op.Is(OpUpdateOne) {
  6402. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  6403. }
  6404. if m.id == nil || m.oldValue == nil {
  6405. return v, errors.New("OldUserID requires an ID field in the mutation")
  6406. }
  6407. oldValue, err := m.oldValue(ctx)
  6408. if err != nil {
  6409. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  6410. }
  6411. return oldValue.UserID, nil
  6412. }
  6413. // AddUserID adds u to the "user_id" field.
  6414. func (m *ChatSessionMutation) AddUserID(u int64) {
  6415. if m.adduser_id != nil {
  6416. *m.adduser_id += u
  6417. } else {
  6418. m.adduser_id = &u
  6419. }
  6420. }
  6421. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  6422. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  6423. v := m.adduser_id
  6424. if v == nil {
  6425. return
  6426. }
  6427. return *v, true
  6428. }
  6429. // ResetUserID resets all changes to the "user_id" field.
  6430. func (m *ChatSessionMutation) ResetUserID() {
  6431. m.user_id = nil
  6432. m.adduser_id = nil
  6433. }
  6434. // SetBotID sets the "bot_id" field.
  6435. func (m *ChatSessionMutation) SetBotID(u uint64) {
  6436. m.bot_id = &u
  6437. m.addbot_id = nil
  6438. }
  6439. // BotID returns the value of the "bot_id" field in the mutation.
  6440. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  6441. v := m.bot_id
  6442. if v == nil {
  6443. return
  6444. }
  6445. return *v, true
  6446. }
  6447. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  6448. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6450. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  6451. if !m.op.Is(OpUpdateOne) {
  6452. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  6453. }
  6454. if m.id == nil || m.oldValue == nil {
  6455. return v, errors.New("OldBotID requires an ID field in the mutation")
  6456. }
  6457. oldValue, err := m.oldValue(ctx)
  6458. if err != nil {
  6459. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  6460. }
  6461. return oldValue.BotID, nil
  6462. }
  6463. // AddBotID adds u to the "bot_id" field.
  6464. func (m *ChatSessionMutation) AddBotID(u int64) {
  6465. if m.addbot_id != nil {
  6466. *m.addbot_id += u
  6467. } else {
  6468. m.addbot_id = &u
  6469. }
  6470. }
  6471. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  6472. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  6473. v := m.addbot_id
  6474. if v == nil {
  6475. return
  6476. }
  6477. return *v, true
  6478. }
  6479. // ResetBotID resets all changes to the "bot_id" field.
  6480. func (m *ChatSessionMutation) ResetBotID() {
  6481. m.bot_id = nil
  6482. m.addbot_id = nil
  6483. }
  6484. // SetBotType sets the "bot_type" field.
  6485. func (m *ChatSessionMutation) SetBotType(u uint8) {
  6486. m.bot_type = &u
  6487. m.addbot_type = nil
  6488. }
  6489. // BotType returns the value of the "bot_type" field in the mutation.
  6490. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  6491. v := m.bot_type
  6492. if v == nil {
  6493. return
  6494. }
  6495. return *v, true
  6496. }
  6497. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  6498. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6499. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6500. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  6501. if !m.op.Is(OpUpdateOne) {
  6502. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  6503. }
  6504. if m.id == nil || m.oldValue == nil {
  6505. return v, errors.New("OldBotType requires an ID field in the mutation")
  6506. }
  6507. oldValue, err := m.oldValue(ctx)
  6508. if err != nil {
  6509. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  6510. }
  6511. return oldValue.BotType, nil
  6512. }
  6513. // AddBotType adds u to the "bot_type" field.
  6514. func (m *ChatSessionMutation) AddBotType(u int8) {
  6515. if m.addbot_type != nil {
  6516. *m.addbot_type += u
  6517. } else {
  6518. m.addbot_type = &u
  6519. }
  6520. }
  6521. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  6522. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  6523. v := m.addbot_type
  6524. if v == nil {
  6525. return
  6526. }
  6527. return *v, true
  6528. }
  6529. // ResetBotType resets all changes to the "bot_type" field.
  6530. func (m *ChatSessionMutation) ResetBotType() {
  6531. m.bot_type = nil
  6532. m.addbot_type = nil
  6533. }
  6534. // Where appends a list predicates to the ChatSessionMutation builder.
  6535. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  6536. m.predicates = append(m.predicates, ps...)
  6537. }
  6538. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  6539. // users can use type-assertion to append predicates that do not depend on any generated package.
  6540. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  6541. p := make([]predicate.ChatSession, len(ps))
  6542. for i := range ps {
  6543. p[i] = ps[i]
  6544. }
  6545. m.Where(p...)
  6546. }
  6547. // Op returns the operation name.
  6548. func (m *ChatSessionMutation) Op() Op {
  6549. return m.op
  6550. }
  6551. // SetOp allows setting the mutation operation.
  6552. func (m *ChatSessionMutation) SetOp(op Op) {
  6553. m.op = op
  6554. }
  6555. // Type returns the node type of this mutation (ChatSession).
  6556. func (m *ChatSessionMutation) Type() string {
  6557. return m.typ
  6558. }
  6559. // Fields returns all fields that were changed during this mutation. Note that in
  6560. // order to get all numeric fields that were incremented/decremented, call
  6561. // AddedFields().
  6562. func (m *ChatSessionMutation) Fields() []string {
  6563. fields := make([]string, 0, 7)
  6564. if m.created_at != nil {
  6565. fields = append(fields, chatsession.FieldCreatedAt)
  6566. }
  6567. if m.updated_at != nil {
  6568. fields = append(fields, chatsession.FieldUpdatedAt)
  6569. }
  6570. if m.deleted_at != nil {
  6571. fields = append(fields, chatsession.FieldDeletedAt)
  6572. }
  6573. if m.name != nil {
  6574. fields = append(fields, chatsession.FieldName)
  6575. }
  6576. if m.user_id != nil {
  6577. fields = append(fields, chatsession.FieldUserID)
  6578. }
  6579. if m.bot_id != nil {
  6580. fields = append(fields, chatsession.FieldBotID)
  6581. }
  6582. if m.bot_type != nil {
  6583. fields = append(fields, chatsession.FieldBotType)
  6584. }
  6585. return fields
  6586. }
  6587. // Field returns the value of a field with the given name. The second boolean
  6588. // return value indicates that this field was not set, or was not defined in the
  6589. // schema.
  6590. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  6591. switch name {
  6592. case chatsession.FieldCreatedAt:
  6593. return m.CreatedAt()
  6594. case chatsession.FieldUpdatedAt:
  6595. return m.UpdatedAt()
  6596. case chatsession.FieldDeletedAt:
  6597. return m.DeletedAt()
  6598. case chatsession.FieldName:
  6599. return m.Name()
  6600. case chatsession.FieldUserID:
  6601. return m.UserID()
  6602. case chatsession.FieldBotID:
  6603. return m.BotID()
  6604. case chatsession.FieldBotType:
  6605. return m.BotType()
  6606. }
  6607. return nil, false
  6608. }
  6609. // OldField returns the old value of the field from the database. An error is
  6610. // returned if the mutation operation is not UpdateOne, or the query to the
  6611. // database failed.
  6612. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6613. switch name {
  6614. case chatsession.FieldCreatedAt:
  6615. return m.OldCreatedAt(ctx)
  6616. case chatsession.FieldUpdatedAt:
  6617. return m.OldUpdatedAt(ctx)
  6618. case chatsession.FieldDeletedAt:
  6619. return m.OldDeletedAt(ctx)
  6620. case chatsession.FieldName:
  6621. return m.OldName(ctx)
  6622. case chatsession.FieldUserID:
  6623. return m.OldUserID(ctx)
  6624. case chatsession.FieldBotID:
  6625. return m.OldBotID(ctx)
  6626. case chatsession.FieldBotType:
  6627. return m.OldBotType(ctx)
  6628. }
  6629. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  6630. }
  6631. // SetField sets the value of a field with the given name. It returns an error if
  6632. // the field is not defined in the schema, or if the type mismatched the field
  6633. // type.
  6634. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  6635. switch name {
  6636. case chatsession.FieldCreatedAt:
  6637. v, ok := value.(time.Time)
  6638. if !ok {
  6639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6640. }
  6641. m.SetCreatedAt(v)
  6642. return nil
  6643. case chatsession.FieldUpdatedAt:
  6644. v, ok := value.(time.Time)
  6645. if !ok {
  6646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6647. }
  6648. m.SetUpdatedAt(v)
  6649. return nil
  6650. case chatsession.FieldDeletedAt:
  6651. v, ok := value.(time.Time)
  6652. if !ok {
  6653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6654. }
  6655. m.SetDeletedAt(v)
  6656. return nil
  6657. case chatsession.FieldName:
  6658. v, ok := value.(string)
  6659. if !ok {
  6660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6661. }
  6662. m.SetName(v)
  6663. return nil
  6664. case chatsession.FieldUserID:
  6665. v, ok := value.(uint64)
  6666. if !ok {
  6667. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6668. }
  6669. m.SetUserID(v)
  6670. return nil
  6671. case chatsession.FieldBotID:
  6672. v, ok := value.(uint64)
  6673. if !ok {
  6674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6675. }
  6676. m.SetBotID(v)
  6677. return nil
  6678. case chatsession.FieldBotType:
  6679. v, ok := value.(uint8)
  6680. if !ok {
  6681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6682. }
  6683. m.SetBotType(v)
  6684. return nil
  6685. }
  6686. return fmt.Errorf("unknown ChatSession field %s", name)
  6687. }
  6688. // AddedFields returns all numeric fields that were incremented/decremented during
  6689. // this mutation.
  6690. func (m *ChatSessionMutation) AddedFields() []string {
  6691. var fields []string
  6692. if m.adduser_id != nil {
  6693. fields = append(fields, chatsession.FieldUserID)
  6694. }
  6695. if m.addbot_id != nil {
  6696. fields = append(fields, chatsession.FieldBotID)
  6697. }
  6698. if m.addbot_type != nil {
  6699. fields = append(fields, chatsession.FieldBotType)
  6700. }
  6701. return fields
  6702. }
  6703. // AddedField returns the numeric value that was incremented/decremented on a field
  6704. // with the given name. The second boolean return value indicates that this field
  6705. // was not set, or was not defined in the schema.
  6706. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  6707. switch name {
  6708. case chatsession.FieldUserID:
  6709. return m.AddedUserID()
  6710. case chatsession.FieldBotID:
  6711. return m.AddedBotID()
  6712. case chatsession.FieldBotType:
  6713. return m.AddedBotType()
  6714. }
  6715. return nil, false
  6716. }
  6717. // AddField adds the value to the field with the given name. It returns an error if
  6718. // the field is not defined in the schema, or if the type mismatched the field
  6719. // type.
  6720. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  6721. switch name {
  6722. case chatsession.FieldUserID:
  6723. v, ok := value.(int64)
  6724. if !ok {
  6725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6726. }
  6727. m.AddUserID(v)
  6728. return nil
  6729. case chatsession.FieldBotID:
  6730. v, ok := value.(int64)
  6731. if !ok {
  6732. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6733. }
  6734. m.AddBotID(v)
  6735. return nil
  6736. case chatsession.FieldBotType:
  6737. v, ok := value.(int8)
  6738. if !ok {
  6739. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6740. }
  6741. m.AddBotType(v)
  6742. return nil
  6743. }
  6744. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  6745. }
  6746. // ClearedFields returns all nullable fields that were cleared during this
  6747. // mutation.
  6748. func (m *ChatSessionMutation) ClearedFields() []string {
  6749. var fields []string
  6750. if m.FieldCleared(chatsession.FieldDeletedAt) {
  6751. fields = append(fields, chatsession.FieldDeletedAt)
  6752. }
  6753. return fields
  6754. }
  6755. // FieldCleared returns a boolean indicating if a field with the given name was
  6756. // cleared in this mutation.
  6757. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  6758. _, ok := m.clearedFields[name]
  6759. return ok
  6760. }
  6761. // ClearField clears the value of the field with the given name. It returns an
  6762. // error if the field is not defined in the schema.
  6763. func (m *ChatSessionMutation) ClearField(name string) error {
  6764. switch name {
  6765. case chatsession.FieldDeletedAt:
  6766. m.ClearDeletedAt()
  6767. return nil
  6768. }
  6769. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  6770. }
  6771. // ResetField resets all changes in the mutation for the field with the given name.
  6772. // It returns an error if the field is not defined in the schema.
  6773. func (m *ChatSessionMutation) ResetField(name string) error {
  6774. switch name {
  6775. case chatsession.FieldCreatedAt:
  6776. m.ResetCreatedAt()
  6777. return nil
  6778. case chatsession.FieldUpdatedAt:
  6779. m.ResetUpdatedAt()
  6780. return nil
  6781. case chatsession.FieldDeletedAt:
  6782. m.ResetDeletedAt()
  6783. return nil
  6784. case chatsession.FieldName:
  6785. m.ResetName()
  6786. return nil
  6787. case chatsession.FieldUserID:
  6788. m.ResetUserID()
  6789. return nil
  6790. case chatsession.FieldBotID:
  6791. m.ResetBotID()
  6792. return nil
  6793. case chatsession.FieldBotType:
  6794. m.ResetBotType()
  6795. return nil
  6796. }
  6797. return fmt.Errorf("unknown ChatSession field %s", name)
  6798. }
  6799. // AddedEdges returns all edge names that were set/added in this mutation.
  6800. func (m *ChatSessionMutation) AddedEdges() []string {
  6801. edges := make([]string, 0, 0)
  6802. return edges
  6803. }
  6804. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6805. // name in this mutation.
  6806. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  6807. return nil
  6808. }
  6809. // RemovedEdges returns all edge names that were removed in this mutation.
  6810. func (m *ChatSessionMutation) RemovedEdges() []string {
  6811. edges := make([]string, 0, 0)
  6812. return edges
  6813. }
  6814. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6815. // the given name in this mutation.
  6816. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  6817. return nil
  6818. }
  6819. // ClearedEdges returns all edge names that were cleared in this mutation.
  6820. func (m *ChatSessionMutation) ClearedEdges() []string {
  6821. edges := make([]string, 0, 0)
  6822. return edges
  6823. }
  6824. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6825. // was cleared in this mutation.
  6826. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  6827. return false
  6828. }
  6829. // ClearEdge clears the value of the edge with the given name. It returns an error
  6830. // if that edge is not defined in the schema.
  6831. func (m *ChatSessionMutation) ClearEdge(name string) error {
  6832. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  6833. }
  6834. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6835. // It returns an error if the edge is not defined in the schema.
  6836. func (m *ChatSessionMutation) ResetEdge(name string) error {
  6837. return fmt.Errorf("unknown ChatSession edge %s", name)
  6838. }
  6839. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  6840. type ContactMutation struct {
  6841. config
  6842. op Op
  6843. typ string
  6844. id *uint64
  6845. created_at *time.Time
  6846. updated_at *time.Time
  6847. status *uint8
  6848. addstatus *int8
  6849. deleted_at *time.Time
  6850. wx_wxid *string
  6851. _type *int
  6852. add_type *int
  6853. wxid *string
  6854. account *string
  6855. nickname *string
  6856. markname *string
  6857. headimg *string
  6858. sex *int
  6859. addsex *int
  6860. starrole *string
  6861. dontseeit *int
  6862. adddontseeit *int
  6863. dontseeme *int
  6864. adddontseeme *int
  6865. lag *string
  6866. gid *string
  6867. gname *string
  6868. v3 *string
  6869. organization_id *uint64
  6870. addorganization_id *int64
  6871. clearedFields map[string]struct{}
  6872. contact_relationships map[uint64]struct{}
  6873. removedcontact_relationships map[uint64]struct{}
  6874. clearedcontact_relationships bool
  6875. contact_messages map[uint64]struct{}
  6876. removedcontact_messages map[uint64]struct{}
  6877. clearedcontact_messages bool
  6878. done bool
  6879. oldValue func(context.Context) (*Contact, error)
  6880. predicates []predicate.Contact
  6881. }
  6882. var _ ent.Mutation = (*ContactMutation)(nil)
  6883. // contactOption allows management of the mutation configuration using functional options.
  6884. type contactOption func(*ContactMutation)
  6885. // newContactMutation creates new mutation for the Contact entity.
  6886. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  6887. m := &ContactMutation{
  6888. config: c,
  6889. op: op,
  6890. typ: TypeContact,
  6891. clearedFields: make(map[string]struct{}),
  6892. }
  6893. for _, opt := range opts {
  6894. opt(m)
  6895. }
  6896. return m
  6897. }
  6898. // withContactID sets the ID field of the mutation.
  6899. func withContactID(id uint64) contactOption {
  6900. return func(m *ContactMutation) {
  6901. var (
  6902. err error
  6903. once sync.Once
  6904. value *Contact
  6905. )
  6906. m.oldValue = func(ctx context.Context) (*Contact, error) {
  6907. once.Do(func() {
  6908. if m.done {
  6909. err = errors.New("querying old values post mutation is not allowed")
  6910. } else {
  6911. value, err = m.Client().Contact.Get(ctx, id)
  6912. }
  6913. })
  6914. return value, err
  6915. }
  6916. m.id = &id
  6917. }
  6918. }
  6919. // withContact sets the old Contact of the mutation.
  6920. func withContact(node *Contact) contactOption {
  6921. return func(m *ContactMutation) {
  6922. m.oldValue = func(context.Context) (*Contact, error) {
  6923. return node, nil
  6924. }
  6925. m.id = &node.ID
  6926. }
  6927. }
  6928. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6929. // executed in a transaction (ent.Tx), a transactional client is returned.
  6930. func (m ContactMutation) Client() *Client {
  6931. client := &Client{config: m.config}
  6932. client.init()
  6933. return client
  6934. }
  6935. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6936. // it returns an error otherwise.
  6937. func (m ContactMutation) Tx() (*Tx, error) {
  6938. if _, ok := m.driver.(*txDriver); !ok {
  6939. return nil, errors.New("ent: mutation is not running in a transaction")
  6940. }
  6941. tx := &Tx{config: m.config}
  6942. tx.init()
  6943. return tx, nil
  6944. }
  6945. // SetID sets the value of the id field. Note that this
  6946. // operation is only accepted on creation of Contact entities.
  6947. func (m *ContactMutation) SetID(id uint64) {
  6948. m.id = &id
  6949. }
  6950. // ID returns the ID value in the mutation. Note that the ID is only available
  6951. // if it was provided to the builder or after it was returned from the database.
  6952. func (m *ContactMutation) ID() (id uint64, exists bool) {
  6953. if m.id == nil {
  6954. return
  6955. }
  6956. return *m.id, true
  6957. }
  6958. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6959. // That means, if the mutation is applied within a transaction with an isolation level such
  6960. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6961. // or updated by the mutation.
  6962. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  6963. switch {
  6964. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6965. id, exists := m.ID()
  6966. if exists {
  6967. return []uint64{id}, nil
  6968. }
  6969. fallthrough
  6970. case m.op.Is(OpUpdate | OpDelete):
  6971. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  6972. default:
  6973. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6974. }
  6975. }
  6976. // SetCreatedAt sets the "created_at" field.
  6977. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  6978. m.created_at = &t
  6979. }
  6980. // CreatedAt returns the value of the "created_at" field in the mutation.
  6981. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  6982. v := m.created_at
  6983. if v == nil {
  6984. return
  6985. }
  6986. return *v, true
  6987. }
  6988. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  6989. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6990. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6991. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6992. if !m.op.Is(OpUpdateOne) {
  6993. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6994. }
  6995. if m.id == nil || m.oldValue == nil {
  6996. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6997. }
  6998. oldValue, err := m.oldValue(ctx)
  6999. if err != nil {
  7000. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7001. }
  7002. return oldValue.CreatedAt, nil
  7003. }
  7004. // ResetCreatedAt resets all changes to the "created_at" field.
  7005. func (m *ContactMutation) ResetCreatedAt() {
  7006. m.created_at = nil
  7007. }
  7008. // SetUpdatedAt sets the "updated_at" field.
  7009. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  7010. m.updated_at = &t
  7011. }
  7012. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7013. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  7014. v := m.updated_at
  7015. if v == nil {
  7016. return
  7017. }
  7018. return *v, true
  7019. }
  7020. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  7021. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7022. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7023. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7024. if !m.op.Is(OpUpdateOne) {
  7025. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7026. }
  7027. if m.id == nil || m.oldValue == nil {
  7028. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7029. }
  7030. oldValue, err := m.oldValue(ctx)
  7031. if err != nil {
  7032. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7033. }
  7034. return oldValue.UpdatedAt, nil
  7035. }
  7036. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7037. func (m *ContactMutation) ResetUpdatedAt() {
  7038. m.updated_at = nil
  7039. }
  7040. // SetStatus sets the "status" field.
  7041. func (m *ContactMutation) SetStatus(u uint8) {
  7042. m.status = &u
  7043. m.addstatus = nil
  7044. }
  7045. // Status returns the value of the "status" field in the mutation.
  7046. func (m *ContactMutation) Status() (r uint8, exists bool) {
  7047. v := m.status
  7048. if v == nil {
  7049. return
  7050. }
  7051. return *v, true
  7052. }
  7053. // OldStatus returns the old "status" field's value of the Contact entity.
  7054. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7055. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7056. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7057. if !m.op.Is(OpUpdateOne) {
  7058. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7059. }
  7060. if m.id == nil || m.oldValue == nil {
  7061. return v, errors.New("OldStatus requires an ID field in the mutation")
  7062. }
  7063. oldValue, err := m.oldValue(ctx)
  7064. if err != nil {
  7065. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7066. }
  7067. return oldValue.Status, nil
  7068. }
  7069. // AddStatus adds u to the "status" field.
  7070. func (m *ContactMutation) AddStatus(u int8) {
  7071. if m.addstatus != nil {
  7072. *m.addstatus += u
  7073. } else {
  7074. m.addstatus = &u
  7075. }
  7076. }
  7077. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7078. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  7079. v := m.addstatus
  7080. if v == nil {
  7081. return
  7082. }
  7083. return *v, true
  7084. }
  7085. // ClearStatus clears the value of the "status" field.
  7086. func (m *ContactMutation) ClearStatus() {
  7087. m.status = nil
  7088. m.addstatus = nil
  7089. m.clearedFields[contact.FieldStatus] = struct{}{}
  7090. }
  7091. // StatusCleared returns if the "status" field was cleared in this mutation.
  7092. func (m *ContactMutation) StatusCleared() bool {
  7093. _, ok := m.clearedFields[contact.FieldStatus]
  7094. return ok
  7095. }
  7096. // ResetStatus resets all changes to the "status" field.
  7097. func (m *ContactMutation) ResetStatus() {
  7098. m.status = nil
  7099. m.addstatus = nil
  7100. delete(m.clearedFields, contact.FieldStatus)
  7101. }
  7102. // SetDeletedAt sets the "deleted_at" field.
  7103. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  7104. m.deleted_at = &t
  7105. }
  7106. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7107. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  7108. v := m.deleted_at
  7109. if v == nil {
  7110. return
  7111. }
  7112. return *v, true
  7113. }
  7114. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  7115. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7116. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7117. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7118. if !m.op.Is(OpUpdateOne) {
  7119. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7120. }
  7121. if m.id == nil || m.oldValue == nil {
  7122. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7123. }
  7124. oldValue, err := m.oldValue(ctx)
  7125. if err != nil {
  7126. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7127. }
  7128. return oldValue.DeletedAt, nil
  7129. }
  7130. // ClearDeletedAt clears the value of the "deleted_at" field.
  7131. func (m *ContactMutation) ClearDeletedAt() {
  7132. m.deleted_at = nil
  7133. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  7134. }
  7135. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7136. func (m *ContactMutation) DeletedAtCleared() bool {
  7137. _, ok := m.clearedFields[contact.FieldDeletedAt]
  7138. return ok
  7139. }
  7140. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7141. func (m *ContactMutation) ResetDeletedAt() {
  7142. m.deleted_at = nil
  7143. delete(m.clearedFields, contact.FieldDeletedAt)
  7144. }
  7145. // SetWxWxid sets the "wx_wxid" field.
  7146. func (m *ContactMutation) SetWxWxid(s string) {
  7147. m.wx_wxid = &s
  7148. }
  7149. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  7150. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  7151. v := m.wx_wxid
  7152. if v == nil {
  7153. return
  7154. }
  7155. return *v, true
  7156. }
  7157. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  7158. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7160. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  7161. if !m.op.Is(OpUpdateOne) {
  7162. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  7163. }
  7164. if m.id == nil || m.oldValue == nil {
  7165. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  7166. }
  7167. oldValue, err := m.oldValue(ctx)
  7168. if err != nil {
  7169. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  7170. }
  7171. return oldValue.WxWxid, nil
  7172. }
  7173. // ResetWxWxid resets all changes to the "wx_wxid" field.
  7174. func (m *ContactMutation) ResetWxWxid() {
  7175. m.wx_wxid = nil
  7176. }
  7177. // SetType sets the "type" field.
  7178. func (m *ContactMutation) SetType(i int) {
  7179. m._type = &i
  7180. m.add_type = nil
  7181. }
  7182. // GetType returns the value of the "type" field in the mutation.
  7183. func (m *ContactMutation) GetType() (r int, exists bool) {
  7184. v := m._type
  7185. if v == nil {
  7186. return
  7187. }
  7188. return *v, true
  7189. }
  7190. // OldType returns the old "type" field's value of the Contact entity.
  7191. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7192. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7193. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  7194. if !m.op.Is(OpUpdateOne) {
  7195. return v, errors.New("OldType is only allowed on UpdateOne operations")
  7196. }
  7197. if m.id == nil || m.oldValue == nil {
  7198. return v, errors.New("OldType requires an ID field in the mutation")
  7199. }
  7200. oldValue, err := m.oldValue(ctx)
  7201. if err != nil {
  7202. return v, fmt.Errorf("querying old value for OldType: %w", err)
  7203. }
  7204. return oldValue.Type, nil
  7205. }
  7206. // AddType adds i to the "type" field.
  7207. func (m *ContactMutation) AddType(i int) {
  7208. if m.add_type != nil {
  7209. *m.add_type += i
  7210. } else {
  7211. m.add_type = &i
  7212. }
  7213. }
  7214. // AddedType returns the value that was added to the "type" field in this mutation.
  7215. func (m *ContactMutation) AddedType() (r int, exists bool) {
  7216. v := m.add_type
  7217. if v == nil {
  7218. return
  7219. }
  7220. return *v, true
  7221. }
  7222. // ClearType clears the value of the "type" field.
  7223. func (m *ContactMutation) ClearType() {
  7224. m._type = nil
  7225. m.add_type = nil
  7226. m.clearedFields[contact.FieldType] = struct{}{}
  7227. }
  7228. // TypeCleared returns if the "type" field was cleared in this mutation.
  7229. func (m *ContactMutation) TypeCleared() bool {
  7230. _, ok := m.clearedFields[contact.FieldType]
  7231. return ok
  7232. }
  7233. // ResetType resets all changes to the "type" field.
  7234. func (m *ContactMutation) ResetType() {
  7235. m._type = nil
  7236. m.add_type = nil
  7237. delete(m.clearedFields, contact.FieldType)
  7238. }
  7239. // SetWxid sets the "wxid" field.
  7240. func (m *ContactMutation) SetWxid(s string) {
  7241. m.wxid = &s
  7242. }
  7243. // Wxid returns the value of the "wxid" field in the mutation.
  7244. func (m *ContactMutation) Wxid() (r string, exists bool) {
  7245. v := m.wxid
  7246. if v == nil {
  7247. return
  7248. }
  7249. return *v, true
  7250. }
  7251. // OldWxid returns the old "wxid" field's value of the Contact entity.
  7252. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7253. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7254. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  7255. if !m.op.Is(OpUpdateOne) {
  7256. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  7257. }
  7258. if m.id == nil || m.oldValue == nil {
  7259. return v, errors.New("OldWxid requires an ID field in the mutation")
  7260. }
  7261. oldValue, err := m.oldValue(ctx)
  7262. if err != nil {
  7263. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  7264. }
  7265. return oldValue.Wxid, nil
  7266. }
  7267. // ResetWxid resets all changes to the "wxid" field.
  7268. func (m *ContactMutation) ResetWxid() {
  7269. m.wxid = nil
  7270. }
  7271. // SetAccount sets the "account" field.
  7272. func (m *ContactMutation) SetAccount(s string) {
  7273. m.account = &s
  7274. }
  7275. // Account returns the value of the "account" field in the mutation.
  7276. func (m *ContactMutation) Account() (r string, exists bool) {
  7277. v := m.account
  7278. if v == nil {
  7279. return
  7280. }
  7281. return *v, true
  7282. }
  7283. // OldAccount returns the old "account" field's value of the Contact entity.
  7284. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7285. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7286. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  7287. if !m.op.Is(OpUpdateOne) {
  7288. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  7289. }
  7290. if m.id == nil || m.oldValue == nil {
  7291. return v, errors.New("OldAccount requires an ID field in the mutation")
  7292. }
  7293. oldValue, err := m.oldValue(ctx)
  7294. if err != nil {
  7295. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  7296. }
  7297. return oldValue.Account, nil
  7298. }
  7299. // ResetAccount resets all changes to the "account" field.
  7300. func (m *ContactMutation) ResetAccount() {
  7301. m.account = nil
  7302. }
  7303. // SetNickname sets the "nickname" field.
  7304. func (m *ContactMutation) SetNickname(s string) {
  7305. m.nickname = &s
  7306. }
  7307. // Nickname returns the value of the "nickname" field in the mutation.
  7308. func (m *ContactMutation) Nickname() (r string, exists bool) {
  7309. v := m.nickname
  7310. if v == nil {
  7311. return
  7312. }
  7313. return *v, true
  7314. }
  7315. // OldNickname returns the old "nickname" field's value of the Contact entity.
  7316. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7318. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  7319. if !m.op.Is(OpUpdateOne) {
  7320. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  7321. }
  7322. if m.id == nil || m.oldValue == nil {
  7323. return v, errors.New("OldNickname requires an ID field in the mutation")
  7324. }
  7325. oldValue, err := m.oldValue(ctx)
  7326. if err != nil {
  7327. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  7328. }
  7329. return oldValue.Nickname, nil
  7330. }
  7331. // ResetNickname resets all changes to the "nickname" field.
  7332. func (m *ContactMutation) ResetNickname() {
  7333. m.nickname = nil
  7334. }
  7335. // SetMarkname sets the "markname" field.
  7336. func (m *ContactMutation) SetMarkname(s string) {
  7337. m.markname = &s
  7338. }
  7339. // Markname returns the value of the "markname" field in the mutation.
  7340. func (m *ContactMutation) Markname() (r string, exists bool) {
  7341. v := m.markname
  7342. if v == nil {
  7343. return
  7344. }
  7345. return *v, true
  7346. }
  7347. // OldMarkname returns the old "markname" field's value of the Contact entity.
  7348. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7350. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  7351. if !m.op.Is(OpUpdateOne) {
  7352. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  7353. }
  7354. if m.id == nil || m.oldValue == nil {
  7355. return v, errors.New("OldMarkname requires an ID field in the mutation")
  7356. }
  7357. oldValue, err := m.oldValue(ctx)
  7358. if err != nil {
  7359. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  7360. }
  7361. return oldValue.Markname, nil
  7362. }
  7363. // ResetMarkname resets all changes to the "markname" field.
  7364. func (m *ContactMutation) ResetMarkname() {
  7365. m.markname = nil
  7366. }
  7367. // SetHeadimg sets the "headimg" field.
  7368. func (m *ContactMutation) SetHeadimg(s string) {
  7369. m.headimg = &s
  7370. }
  7371. // Headimg returns the value of the "headimg" field in the mutation.
  7372. func (m *ContactMutation) Headimg() (r string, exists bool) {
  7373. v := m.headimg
  7374. if v == nil {
  7375. return
  7376. }
  7377. return *v, true
  7378. }
  7379. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  7380. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7381. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7382. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  7383. if !m.op.Is(OpUpdateOne) {
  7384. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  7385. }
  7386. if m.id == nil || m.oldValue == nil {
  7387. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  7388. }
  7389. oldValue, err := m.oldValue(ctx)
  7390. if err != nil {
  7391. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  7392. }
  7393. return oldValue.Headimg, nil
  7394. }
  7395. // ResetHeadimg resets all changes to the "headimg" field.
  7396. func (m *ContactMutation) ResetHeadimg() {
  7397. m.headimg = nil
  7398. }
  7399. // SetSex sets the "sex" field.
  7400. func (m *ContactMutation) SetSex(i int) {
  7401. m.sex = &i
  7402. m.addsex = nil
  7403. }
  7404. // Sex returns the value of the "sex" field in the mutation.
  7405. func (m *ContactMutation) Sex() (r int, exists bool) {
  7406. v := m.sex
  7407. if v == nil {
  7408. return
  7409. }
  7410. return *v, true
  7411. }
  7412. // OldSex returns the old "sex" field's value of the Contact entity.
  7413. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7414. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7415. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  7416. if !m.op.Is(OpUpdateOne) {
  7417. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  7418. }
  7419. if m.id == nil || m.oldValue == nil {
  7420. return v, errors.New("OldSex requires an ID field in the mutation")
  7421. }
  7422. oldValue, err := m.oldValue(ctx)
  7423. if err != nil {
  7424. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  7425. }
  7426. return oldValue.Sex, nil
  7427. }
  7428. // AddSex adds i to the "sex" field.
  7429. func (m *ContactMutation) AddSex(i int) {
  7430. if m.addsex != nil {
  7431. *m.addsex += i
  7432. } else {
  7433. m.addsex = &i
  7434. }
  7435. }
  7436. // AddedSex returns the value that was added to the "sex" field in this mutation.
  7437. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  7438. v := m.addsex
  7439. if v == nil {
  7440. return
  7441. }
  7442. return *v, true
  7443. }
  7444. // ResetSex resets all changes to the "sex" field.
  7445. func (m *ContactMutation) ResetSex() {
  7446. m.sex = nil
  7447. m.addsex = nil
  7448. }
  7449. // SetStarrole sets the "starrole" field.
  7450. func (m *ContactMutation) SetStarrole(s string) {
  7451. m.starrole = &s
  7452. }
  7453. // Starrole returns the value of the "starrole" field in the mutation.
  7454. func (m *ContactMutation) Starrole() (r string, exists bool) {
  7455. v := m.starrole
  7456. if v == nil {
  7457. return
  7458. }
  7459. return *v, true
  7460. }
  7461. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  7462. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7463. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7464. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  7465. if !m.op.Is(OpUpdateOne) {
  7466. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  7467. }
  7468. if m.id == nil || m.oldValue == nil {
  7469. return v, errors.New("OldStarrole requires an ID field in the mutation")
  7470. }
  7471. oldValue, err := m.oldValue(ctx)
  7472. if err != nil {
  7473. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  7474. }
  7475. return oldValue.Starrole, nil
  7476. }
  7477. // ResetStarrole resets all changes to the "starrole" field.
  7478. func (m *ContactMutation) ResetStarrole() {
  7479. m.starrole = nil
  7480. }
  7481. // SetDontseeit sets the "dontseeit" field.
  7482. func (m *ContactMutation) SetDontseeit(i int) {
  7483. m.dontseeit = &i
  7484. m.adddontseeit = nil
  7485. }
  7486. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  7487. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  7488. v := m.dontseeit
  7489. if v == nil {
  7490. return
  7491. }
  7492. return *v, true
  7493. }
  7494. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  7495. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7496. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7497. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  7498. if !m.op.Is(OpUpdateOne) {
  7499. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  7500. }
  7501. if m.id == nil || m.oldValue == nil {
  7502. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  7503. }
  7504. oldValue, err := m.oldValue(ctx)
  7505. if err != nil {
  7506. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  7507. }
  7508. return oldValue.Dontseeit, nil
  7509. }
  7510. // AddDontseeit adds i to the "dontseeit" field.
  7511. func (m *ContactMutation) AddDontseeit(i int) {
  7512. if m.adddontseeit != nil {
  7513. *m.adddontseeit += i
  7514. } else {
  7515. m.adddontseeit = &i
  7516. }
  7517. }
  7518. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  7519. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  7520. v := m.adddontseeit
  7521. if v == nil {
  7522. return
  7523. }
  7524. return *v, true
  7525. }
  7526. // ResetDontseeit resets all changes to the "dontseeit" field.
  7527. func (m *ContactMutation) ResetDontseeit() {
  7528. m.dontseeit = nil
  7529. m.adddontseeit = nil
  7530. }
  7531. // SetDontseeme sets the "dontseeme" field.
  7532. func (m *ContactMutation) SetDontseeme(i int) {
  7533. m.dontseeme = &i
  7534. m.adddontseeme = nil
  7535. }
  7536. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  7537. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  7538. v := m.dontseeme
  7539. if v == nil {
  7540. return
  7541. }
  7542. return *v, true
  7543. }
  7544. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  7545. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7546. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7547. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  7548. if !m.op.Is(OpUpdateOne) {
  7549. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  7550. }
  7551. if m.id == nil || m.oldValue == nil {
  7552. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  7553. }
  7554. oldValue, err := m.oldValue(ctx)
  7555. if err != nil {
  7556. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  7557. }
  7558. return oldValue.Dontseeme, nil
  7559. }
  7560. // AddDontseeme adds i to the "dontseeme" field.
  7561. func (m *ContactMutation) AddDontseeme(i int) {
  7562. if m.adddontseeme != nil {
  7563. *m.adddontseeme += i
  7564. } else {
  7565. m.adddontseeme = &i
  7566. }
  7567. }
  7568. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  7569. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  7570. v := m.adddontseeme
  7571. if v == nil {
  7572. return
  7573. }
  7574. return *v, true
  7575. }
  7576. // ResetDontseeme resets all changes to the "dontseeme" field.
  7577. func (m *ContactMutation) ResetDontseeme() {
  7578. m.dontseeme = nil
  7579. m.adddontseeme = nil
  7580. }
  7581. // SetLag sets the "lag" field.
  7582. func (m *ContactMutation) SetLag(s string) {
  7583. m.lag = &s
  7584. }
  7585. // Lag returns the value of the "lag" field in the mutation.
  7586. func (m *ContactMutation) Lag() (r string, exists bool) {
  7587. v := m.lag
  7588. if v == nil {
  7589. return
  7590. }
  7591. return *v, true
  7592. }
  7593. // OldLag returns the old "lag" field's value of the Contact entity.
  7594. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7595. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7596. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  7597. if !m.op.Is(OpUpdateOne) {
  7598. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  7599. }
  7600. if m.id == nil || m.oldValue == nil {
  7601. return v, errors.New("OldLag requires an ID field in the mutation")
  7602. }
  7603. oldValue, err := m.oldValue(ctx)
  7604. if err != nil {
  7605. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  7606. }
  7607. return oldValue.Lag, nil
  7608. }
  7609. // ResetLag resets all changes to the "lag" field.
  7610. func (m *ContactMutation) ResetLag() {
  7611. m.lag = nil
  7612. }
  7613. // SetGid sets the "gid" field.
  7614. func (m *ContactMutation) SetGid(s string) {
  7615. m.gid = &s
  7616. }
  7617. // Gid returns the value of the "gid" field in the mutation.
  7618. func (m *ContactMutation) Gid() (r string, exists bool) {
  7619. v := m.gid
  7620. if v == nil {
  7621. return
  7622. }
  7623. return *v, true
  7624. }
  7625. // OldGid returns the old "gid" field's value of the Contact entity.
  7626. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7627. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7628. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  7629. if !m.op.Is(OpUpdateOne) {
  7630. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  7631. }
  7632. if m.id == nil || m.oldValue == nil {
  7633. return v, errors.New("OldGid requires an ID field in the mutation")
  7634. }
  7635. oldValue, err := m.oldValue(ctx)
  7636. if err != nil {
  7637. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  7638. }
  7639. return oldValue.Gid, nil
  7640. }
  7641. // ResetGid resets all changes to the "gid" field.
  7642. func (m *ContactMutation) ResetGid() {
  7643. m.gid = nil
  7644. }
  7645. // SetGname sets the "gname" field.
  7646. func (m *ContactMutation) SetGname(s string) {
  7647. m.gname = &s
  7648. }
  7649. // Gname returns the value of the "gname" field in the mutation.
  7650. func (m *ContactMutation) Gname() (r string, exists bool) {
  7651. v := m.gname
  7652. if v == nil {
  7653. return
  7654. }
  7655. return *v, true
  7656. }
  7657. // OldGname returns the old "gname" field's value of the Contact entity.
  7658. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7659. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7660. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  7661. if !m.op.Is(OpUpdateOne) {
  7662. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  7663. }
  7664. if m.id == nil || m.oldValue == nil {
  7665. return v, errors.New("OldGname requires an ID field in the mutation")
  7666. }
  7667. oldValue, err := m.oldValue(ctx)
  7668. if err != nil {
  7669. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  7670. }
  7671. return oldValue.Gname, nil
  7672. }
  7673. // ResetGname resets all changes to the "gname" field.
  7674. func (m *ContactMutation) ResetGname() {
  7675. m.gname = nil
  7676. }
  7677. // SetV3 sets the "v3" field.
  7678. func (m *ContactMutation) SetV3(s string) {
  7679. m.v3 = &s
  7680. }
  7681. // V3 returns the value of the "v3" field in the mutation.
  7682. func (m *ContactMutation) V3() (r string, exists bool) {
  7683. v := m.v3
  7684. if v == nil {
  7685. return
  7686. }
  7687. return *v, true
  7688. }
  7689. // OldV3 returns the old "v3" field's value of the Contact entity.
  7690. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7691. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7692. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  7693. if !m.op.Is(OpUpdateOne) {
  7694. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  7695. }
  7696. if m.id == nil || m.oldValue == nil {
  7697. return v, errors.New("OldV3 requires an ID field in the mutation")
  7698. }
  7699. oldValue, err := m.oldValue(ctx)
  7700. if err != nil {
  7701. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  7702. }
  7703. return oldValue.V3, nil
  7704. }
  7705. // ResetV3 resets all changes to the "v3" field.
  7706. func (m *ContactMutation) ResetV3() {
  7707. m.v3 = nil
  7708. }
  7709. // SetOrganizationID sets the "organization_id" field.
  7710. func (m *ContactMutation) SetOrganizationID(u uint64) {
  7711. m.organization_id = &u
  7712. m.addorganization_id = nil
  7713. }
  7714. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7715. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  7716. v := m.organization_id
  7717. if v == nil {
  7718. return
  7719. }
  7720. return *v, true
  7721. }
  7722. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  7723. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7724. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7725. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7726. if !m.op.Is(OpUpdateOne) {
  7727. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7728. }
  7729. if m.id == nil || m.oldValue == nil {
  7730. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7731. }
  7732. oldValue, err := m.oldValue(ctx)
  7733. if err != nil {
  7734. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7735. }
  7736. return oldValue.OrganizationID, nil
  7737. }
  7738. // AddOrganizationID adds u to the "organization_id" field.
  7739. func (m *ContactMutation) AddOrganizationID(u int64) {
  7740. if m.addorganization_id != nil {
  7741. *m.addorganization_id += u
  7742. } else {
  7743. m.addorganization_id = &u
  7744. }
  7745. }
  7746. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7747. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  7748. v := m.addorganization_id
  7749. if v == nil {
  7750. return
  7751. }
  7752. return *v, true
  7753. }
  7754. // ClearOrganizationID clears the value of the "organization_id" field.
  7755. func (m *ContactMutation) ClearOrganizationID() {
  7756. m.organization_id = nil
  7757. m.addorganization_id = nil
  7758. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  7759. }
  7760. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  7761. func (m *ContactMutation) OrganizationIDCleared() bool {
  7762. _, ok := m.clearedFields[contact.FieldOrganizationID]
  7763. return ok
  7764. }
  7765. // ResetOrganizationID resets all changes to the "organization_id" field.
  7766. func (m *ContactMutation) ResetOrganizationID() {
  7767. m.organization_id = nil
  7768. m.addorganization_id = nil
  7769. delete(m.clearedFields, contact.FieldOrganizationID)
  7770. }
  7771. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  7772. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  7773. if m.contact_relationships == nil {
  7774. m.contact_relationships = make(map[uint64]struct{})
  7775. }
  7776. for i := range ids {
  7777. m.contact_relationships[ids[i]] = struct{}{}
  7778. }
  7779. }
  7780. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  7781. func (m *ContactMutation) ClearContactRelationships() {
  7782. m.clearedcontact_relationships = true
  7783. }
  7784. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  7785. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  7786. return m.clearedcontact_relationships
  7787. }
  7788. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  7789. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  7790. if m.removedcontact_relationships == nil {
  7791. m.removedcontact_relationships = make(map[uint64]struct{})
  7792. }
  7793. for i := range ids {
  7794. delete(m.contact_relationships, ids[i])
  7795. m.removedcontact_relationships[ids[i]] = struct{}{}
  7796. }
  7797. }
  7798. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  7799. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  7800. for id := range m.removedcontact_relationships {
  7801. ids = append(ids, id)
  7802. }
  7803. return
  7804. }
  7805. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  7806. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  7807. for id := range m.contact_relationships {
  7808. ids = append(ids, id)
  7809. }
  7810. return
  7811. }
  7812. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  7813. func (m *ContactMutation) ResetContactRelationships() {
  7814. m.contact_relationships = nil
  7815. m.clearedcontact_relationships = false
  7816. m.removedcontact_relationships = nil
  7817. }
  7818. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  7819. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  7820. if m.contact_messages == nil {
  7821. m.contact_messages = make(map[uint64]struct{})
  7822. }
  7823. for i := range ids {
  7824. m.contact_messages[ids[i]] = struct{}{}
  7825. }
  7826. }
  7827. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  7828. func (m *ContactMutation) ClearContactMessages() {
  7829. m.clearedcontact_messages = true
  7830. }
  7831. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  7832. func (m *ContactMutation) ContactMessagesCleared() bool {
  7833. return m.clearedcontact_messages
  7834. }
  7835. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  7836. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  7837. if m.removedcontact_messages == nil {
  7838. m.removedcontact_messages = make(map[uint64]struct{})
  7839. }
  7840. for i := range ids {
  7841. delete(m.contact_messages, ids[i])
  7842. m.removedcontact_messages[ids[i]] = struct{}{}
  7843. }
  7844. }
  7845. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  7846. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  7847. for id := range m.removedcontact_messages {
  7848. ids = append(ids, id)
  7849. }
  7850. return
  7851. }
  7852. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  7853. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  7854. for id := range m.contact_messages {
  7855. ids = append(ids, id)
  7856. }
  7857. return
  7858. }
  7859. // ResetContactMessages resets all changes to the "contact_messages" edge.
  7860. func (m *ContactMutation) ResetContactMessages() {
  7861. m.contact_messages = nil
  7862. m.clearedcontact_messages = false
  7863. m.removedcontact_messages = nil
  7864. }
  7865. // Where appends a list predicates to the ContactMutation builder.
  7866. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  7867. m.predicates = append(m.predicates, ps...)
  7868. }
  7869. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  7870. // users can use type-assertion to append predicates that do not depend on any generated package.
  7871. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  7872. p := make([]predicate.Contact, len(ps))
  7873. for i := range ps {
  7874. p[i] = ps[i]
  7875. }
  7876. m.Where(p...)
  7877. }
  7878. // Op returns the operation name.
  7879. func (m *ContactMutation) Op() Op {
  7880. return m.op
  7881. }
  7882. // SetOp allows setting the mutation operation.
  7883. func (m *ContactMutation) SetOp(op Op) {
  7884. m.op = op
  7885. }
  7886. // Type returns the node type of this mutation (Contact).
  7887. func (m *ContactMutation) Type() string {
  7888. return m.typ
  7889. }
  7890. // Fields returns all fields that were changed during this mutation. Note that in
  7891. // order to get all numeric fields that were incremented/decremented, call
  7892. // AddedFields().
  7893. func (m *ContactMutation) Fields() []string {
  7894. fields := make([]string, 0, 20)
  7895. if m.created_at != nil {
  7896. fields = append(fields, contact.FieldCreatedAt)
  7897. }
  7898. if m.updated_at != nil {
  7899. fields = append(fields, contact.FieldUpdatedAt)
  7900. }
  7901. if m.status != nil {
  7902. fields = append(fields, contact.FieldStatus)
  7903. }
  7904. if m.deleted_at != nil {
  7905. fields = append(fields, contact.FieldDeletedAt)
  7906. }
  7907. if m.wx_wxid != nil {
  7908. fields = append(fields, contact.FieldWxWxid)
  7909. }
  7910. if m._type != nil {
  7911. fields = append(fields, contact.FieldType)
  7912. }
  7913. if m.wxid != nil {
  7914. fields = append(fields, contact.FieldWxid)
  7915. }
  7916. if m.account != nil {
  7917. fields = append(fields, contact.FieldAccount)
  7918. }
  7919. if m.nickname != nil {
  7920. fields = append(fields, contact.FieldNickname)
  7921. }
  7922. if m.markname != nil {
  7923. fields = append(fields, contact.FieldMarkname)
  7924. }
  7925. if m.headimg != nil {
  7926. fields = append(fields, contact.FieldHeadimg)
  7927. }
  7928. if m.sex != nil {
  7929. fields = append(fields, contact.FieldSex)
  7930. }
  7931. if m.starrole != nil {
  7932. fields = append(fields, contact.FieldStarrole)
  7933. }
  7934. if m.dontseeit != nil {
  7935. fields = append(fields, contact.FieldDontseeit)
  7936. }
  7937. if m.dontseeme != nil {
  7938. fields = append(fields, contact.FieldDontseeme)
  7939. }
  7940. if m.lag != nil {
  7941. fields = append(fields, contact.FieldLag)
  7942. }
  7943. if m.gid != nil {
  7944. fields = append(fields, contact.FieldGid)
  7945. }
  7946. if m.gname != nil {
  7947. fields = append(fields, contact.FieldGname)
  7948. }
  7949. if m.v3 != nil {
  7950. fields = append(fields, contact.FieldV3)
  7951. }
  7952. if m.organization_id != nil {
  7953. fields = append(fields, contact.FieldOrganizationID)
  7954. }
  7955. return fields
  7956. }
  7957. // Field returns the value of a field with the given name. The second boolean
  7958. // return value indicates that this field was not set, or was not defined in the
  7959. // schema.
  7960. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  7961. switch name {
  7962. case contact.FieldCreatedAt:
  7963. return m.CreatedAt()
  7964. case contact.FieldUpdatedAt:
  7965. return m.UpdatedAt()
  7966. case contact.FieldStatus:
  7967. return m.Status()
  7968. case contact.FieldDeletedAt:
  7969. return m.DeletedAt()
  7970. case contact.FieldWxWxid:
  7971. return m.WxWxid()
  7972. case contact.FieldType:
  7973. return m.GetType()
  7974. case contact.FieldWxid:
  7975. return m.Wxid()
  7976. case contact.FieldAccount:
  7977. return m.Account()
  7978. case contact.FieldNickname:
  7979. return m.Nickname()
  7980. case contact.FieldMarkname:
  7981. return m.Markname()
  7982. case contact.FieldHeadimg:
  7983. return m.Headimg()
  7984. case contact.FieldSex:
  7985. return m.Sex()
  7986. case contact.FieldStarrole:
  7987. return m.Starrole()
  7988. case contact.FieldDontseeit:
  7989. return m.Dontseeit()
  7990. case contact.FieldDontseeme:
  7991. return m.Dontseeme()
  7992. case contact.FieldLag:
  7993. return m.Lag()
  7994. case contact.FieldGid:
  7995. return m.Gid()
  7996. case contact.FieldGname:
  7997. return m.Gname()
  7998. case contact.FieldV3:
  7999. return m.V3()
  8000. case contact.FieldOrganizationID:
  8001. return m.OrganizationID()
  8002. }
  8003. return nil, false
  8004. }
  8005. // OldField returns the old value of the field from the database. An error is
  8006. // returned if the mutation operation is not UpdateOne, or the query to the
  8007. // database failed.
  8008. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8009. switch name {
  8010. case contact.FieldCreatedAt:
  8011. return m.OldCreatedAt(ctx)
  8012. case contact.FieldUpdatedAt:
  8013. return m.OldUpdatedAt(ctx)
  8014. case contact.FieldStatus:
  8015. return m.OldStatus(ctx)
  8016. case contact.FieldDeletedAt:
  8017. return m.OldDeletedAt(ctx)
  8018. case contact.FieldWxWxid:
  8019. return m.OldWxWxid(ctx)
  8020. case contact.FieldType:
  8021. return m.OldType(ctx)
  8022. case contact.FieldWxid:
  8023. return m.OldWxid(ctx)
  8024. case contact.FieldAccount:
  8025. return m.OldAccount(ctx)
  8026. case contact.FieldNickname:
  8027. return m.OldNickname(ctx)
  8028. case contact.FieldMarkname:
  8029. return m.OldMarkname(ctx)
  8030. case contact.FieldHeadimg:
  8031. return m.OldHeadimg(ctx)
  8032. case contact.FieldSex:
  8033. return m.OldSex(ctx)
  8034. case contact.FieldStarrole:
  8035. return m.OldStarrole(ctx)
  8036. case contact.FieldDontseeit:
  8037. return m.OldDontseeit(ctx)
  8038. case contact.FieldDontseeme:
  8039. return m.OldDontseeme(ctx)
  8040. case contact.FieldLag:
  8041. return m.OldLag(ctx)
  8042. case contact.FieldGid:
  8043. return m.OldGid(ctx)
  8044. case contact.FieldGname:
  8045. return m.OldGname(ctx)
  8046. case contact.FieldV3:
  8047. return m.OldV3(ctx)
  8048. case contact.FieldOrganizationID:
  8049. return m.OldOrganizationID(ctx)
  8050. }
  8051. return nil, fmt.Errorf("unknown Contact field %s", name)
  8052. }
  8053. // SetField sets the value of a field with the given name. It returns an error if
  8054. // the field is not defined in the schema, or if the type mismatched the field
  8055. // type.
  8056. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  8057. switch name {
  8058. case contact.FieldCreatedAt:
  8059. v, ok := value.(time.Time)
  8060. if !ok {
  8061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8062. }
  8063. m.SetCreatedAt(v)
  8064. return nil
  8065. case contact.FieldUpdatedAt:
  8066. v, ok := value.(time.Time)
  8067. if !ok {
  8068. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8069. }
  8070. m.SetUpdatedAt(v)
  8071. return nil
  8072. case contact.FieldStatus:
  8073. v, ok := value.(uint8)
  8074. if !ok {
  8075. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8076. }
  8077. m.SetStatus(v)
  8078. return nil
  8079. case contact.FieldDeletedAt:
  8080. v, ok := value.(time.Time)
  8081. if !ok {
  8082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8083. }
  8084. m.SetDeletedAt(v)
  8085. return nil
  8086. case contact.FieldWxWxid:
  8087. v, ok := value.(string)
  8088. if !ok {
  8089. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8090. }
  8091. m.SetWxWxid(v)
  8092. return nil
  8093. case contact.FieldType:
  8094. v, ok := value.(int)
  8095. if !ok {
  8096. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8097. }
  8098. m.SetType(v)
  8099. return nil
  8100. case contact.FieldWxid:
  8101. v, ok := value.(string)
  8102. if !ok {
  8103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8104. }
  8105. m.SetWxid(v)
  8106. return nil
  8107. case contact.FieldAccount:
  8108. v, ok := value.(string)
  8109. if !ok {
  8110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8111. }
  8112. m.SetAccount(v)
  8113. return nil
  8114. case contact.FieldNickname:
  8115. v, ok := value.(string)
  8116. if !ok {
  8117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8118. }
  8119. m.SetNickname(v)
  8120. return nil
  8121. case contact.FieldMarkname:
  8122. v, ok := value.(string)
  8123. if !ok {
  8124. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8125. }
  8126. m.SetMarkname(v)
  8127. return nil
  8128. case contact.FieldHeadimg:
  8129. v, ok := value.(string)
  8130. if !ok {
  8131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8132. }
  8133. m.SetHeadimg(v)
  8134. return nil
  8135. case contact.FieldSex:
  8136. v, ok := value.(int)
  8137. if !ok {
  8138. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8139. }
  8140. m.SetSex(v)
  8141. return nil
  8142. case contact.FieldStarrole:
  8143. v, ok := value.(string)
  8144. if !ok {
  8145. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8146. }
  8147. m.SetStarrole(v)
  8148. return nil
  8149. case contact.FieldDontseeit:
  8150. v, ok := value.(int)
  8151. if !ok {
  8152. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8153. }
  8154. m.SetDontseeit(v)
  8155. return nil
  8156. case contact.FieldDontseeme:
  8157. v, ok := value.(int)
  8158. if !ok {
  8159. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8160. }
  8161. m.SetDontseeme(v)
  8162. return nil
  8163. case contact.FieldLag:
  8164. v, ok := value.(string)
  8165. if !ok {
  8166. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8167. }
  8168. m.SetLag(v)
  8169. return nil
  8170. case contact.FieldGid:
  8171. v, ok := value.(string)
  8172. if !ok {
  8173. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8174. }
  8175. m.SetGid(v)
  8176. return nil
  8177. case contact.FieldGname:
  8178. v, ok := value.(string)
  8179. if !ok {
  8180. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8181. }
  8182. m.SetGname(v)
  8183. return nil
  8184. case contact.FieldV3:
  8185. v, ok := value.(string)
  8186. if !ok {
  8187. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8188. }
  8189. m.SetV3(v)
  8190. return nil
  8191. case contact.FieldOrganizationID:
  8192. v, ok := value.(uint64)
  8193. if !ok {
  8194. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8195. }
  8196. m.SetOrganizationID(v)
  8197. return nil
  8198. }
  8199. return fmt.Errorf("unknown Contact field %s", name)
  8200. }
  8201. // AddedFields returns all numeric fields that were incremented/decremented during
  8202. // this mutation.
  8203. func (m *ContactMutation) AddedFields() []string {
  8204. var fields []string
  8205. if m.addstatus != nil {
  8206. fields = append(fields, contact.FieldStatus)
  8207. }
  8208. if m.add_type != nil {
  8209. fields = append(fields, contact.FieldType)
  8210. }
  8211. if m.addsex != nil {
  8212. fields = append(fields, contact.FieldSex)
  8213. }
  8214. if m.adddontseeit != nil {
  8215. fields = append(fields, contact.FieldDontseeit)
  8216. }
  8217. if m.adddontseeme != nil {
  8218. fields = append(fields, contact.FieldDontseeme)
  8219. }
  8220. if m.addorganization_id != nil {
  8221. fields = append(fields, contact.FieldOrganizationID)
  8222. }
  8223. return fields
  8224. }
  8225. // AddedField returns the numeric value that was incremented/decremented on a field
  8226. // with the given name. The second boolean return value indicates that this field
  8227. // was not set, or was not defined in the schema.
  8228. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  8229. switch name {
  8230. case contact.FieldStatus:
  8231. return m.AddedStatus()
  8232. case contact.FieldType:
  8233. return m.AddedType()
  8234. case contact.FieldSex:
  8235. return m.AddedSex()
  8236. case contact.FieldDontseeit:
  8237. return m.AddedDontseeit()
  8238. case contact.FieldDontseeme:
  8239. return m.AddedDontseeme()
  8240. case contact.FieldOrganizationID:
  8241. return m.AddedOrganizationID()
  8242. }
  8243. return nil, false
  8244. }
  8245. // AddField adds the value to the field with the given name. It returns an error if
  8246. // the field is not defined in the schema, or if the type mismatched the field
  8247. // type.
  8248. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  8249. switch name {
  8250. case contact.FieldStatus:
  8251. v, ok := value.(int8)
  8252. if !ok {
  8253. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8254. }
  8255. m.AddStatus(v)
  8256. return nil
  8257. case contact.FieldType:
  8258. v, ok := value.(int)
  8259. if !ok {
  8260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8261. }
  8262. m.AddType(v)
  8263. return nil
  8264. case contact.FieldSex:
  8265. v, ok := value.(int)
  8266. if !ok {
  8267. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8268. }
  8269. m.AddSex(v)
  8270. return nil
  8271. case contact.FieldDontseeit:
  8272. v, ok := value.(int)
  8273. if !ok {
  8274. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8275. }
  8276. m.AddDontseeit(v)
  8277. return nil
  8278. case contact.FieldDontseeme:
  8279. v, ok := value.(int)
  8280. if !ok {
  8281. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8282. }
  8283. m.AddDontseeme(v)
  8284. return nil
  8285. case contact.FieldOrganizationID:
  8286. v, ok := value.(int64)
  8287. if !ok {
  8288. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8289. }
  8290. m.AddOrganizationID(v)
  8291. return nil
  8292. }
  8293. return fmt.Errorf("unknown Contact numeric field %s", name)
  8294. }
  8295. // ClearedFields returns all nullable fields that were cleared during this
  8296. // mutation.
  8297. func (m *ContactMutation) ClearedFields() []string {
  8298. var fields []string
  8299. if m.FieldCleared(contact.FieldStatus) {
  8300. fields = append(fields, contact.FieldStatus)
  8301. }
  8302. if m.FieldCleared(contact.FieldDeletedAt) {
  8303. fields = append(fields, contact.FieldDeletedAt)
  8304. }
  8305. if m.FieldCleared(contact.FieldType) {
  8306. fields = append(fields, contact.FieldType)
  8307. }
  8308. if m.FieldCleared(contact.FieldOrganizationID) {
  8309. fields = append(fields, contact.FieldOrganizationID)
  8310. }
  8311. return fields
  8312. }
  8313. // FieldCleared returns a boolean indicating if a field with the given name was
  8314. // cleared in this mutation.
  8315. func (m *ContactMutation) FieldCleared(name string) bool {
  8316. _, ok := m.clearedFields[name]
  8317. return ok
  8318. }
  8319. // ClearField clears the value of the field with the given name. It returns an
  8320. // error if the field is not defined in the schema.
  8321. func (m *ContactMutation) ClearField(name string) error {
  8322. switch name {
  8323. case contact.FieldStatus:
  8324. m.ClearStatus()
  8325. return nil
  8326. case contact.FieldDeletedAt:
  8327. m.ClearDeletedAt()
  8328. return nil
  8329. case contact.FieldType:
  8330. m.ClearType()
  8331. return nil
  8332. case contact.FieldOrganizationID:
  8333. m.ClearOrganizationID()
  8334. return nil
  8335. }
  8336. return fmt.Errorf("unknown Contact nullable field %s", name)
  8337. }
  8338. // ResetField resets all changes in the mutation for the field with the given name.
  8339. // It returns an error if the field is not defined in the schema.
  8340. func (m *ContactMutation) ResetField(name string) error {
  8341. switch name {
  8342. case contact.FieldCreatedAt:
  8343. m.ResetCreatedAt()
  8344. return nil
  8345. case contact.FieldUpdatedAt:
  8346. m.ResetUpdatedAt()
  8347. return nil
  8348. case contact.FieldStatus:
  8349. m.ResetStatus()
  8350. return nil
  8351. case contact.FieldDeletedAt:
  8352. m.ResetDeletedAt()
  8353. return nil
  8354. case contact.FieldWxWxid:
  8355. m.ResetWxWxid()
  8356. return nil
  8357. case contact.FieldType:
  8358. m.ResetType()
  8359. return nil
  8360. case contact.FieldWxid:
  8361. m.ResetWxid()
  8362. return nil
  8363. case contact.FieldAccount:
  8364. m.ResetAccount()
  8365. return nil
  8366. case contact.FieldNickname:
  8367. m.ResetNickname()
  8368. return nil
  8369. case contact.FieldMarkname:
  8370. m.ResetMarkname()
  8371. return nil
  8372. case contact.FieldHeadimg:
  8373. m.ResetHeadimg()
  8374. return nil
  8375. case contact.FieldSex:
  8376. m.ResetSex()
  8377. return nil
  8378. case contact.FieldStarrole:
  8379. m.ResetStarrole()
  8380. return nil
  8381. case contact.FieldDontseeit:
  8382. m.ResetDontseeit()
  8383. return nil
  8384. case contact.FieldDontseeme:
  8385. m.ResetDontseeme()
  8386. return nil
  8387. case contact.FieldLag:
  8388. m.ResetLag()
  8389. return nil
  8390. case contact.FieldGid:
  8391. m.ResetGid()
  8392. return nil
  8393. case contact.FieldGname:
  8394. m.ResetGname()
  8395. return nil
  8396. case contact.FieldV3:
  8397. m.ResetV3()
  8398. return nil
  8399. case contact.FieldOrganizationID:
  8400. m.ResetOrganizationID()
  8401. return nil
  8402. }
  8403. return fmt.Errorf("unknown Contact field %s", name)
  8404. }
  8405. // AddedEdges returns all edge names that were set/added in this mutation.
  8406. func (m *ContactMutation) AddedEdges() []string {
  8407. edges := make([]string, 0, 2)
  8408. if m.contact_relationships != nil {
  8409. edges = append(edges, contact.EdgeContactRelationships)
  8410. }
  8411. if m.contact_messages != nil {
  8412. edges = append(edges, contact.EdgeContactMessages)
  8413. }
  8414. return edges
  8415. }
  8416. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8417. // name in this mutation.
  8418. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  8419. switch name {
  8420. case contact.EdgeContactRelationships:
  8421. ids := make([]ent.Value, 0, len(m.contact_relationships))
  8422. for id := range m.contact_relationships {
  8423. ids = append(ids, id)
  8424. }
  8425. return ids
  8426. case contact.EdgeContactMessages:
  8427. ids := make([]ent.Value, 0, len(m.contact_messages))
  8428. for id := range m.contact_messages {
  8429. ids = append(ids, id)
  8430. }
  8431. return ids
  8432. }
  8433. return nil
  8434. }
  8435. // RemovedEdges returns all edge names that were removed in this mutation.
  8436. func (m *ContactMutation) RemovedEdges() []string {
  8437. edges := make([]string, 0, 2)
  8438. if m.removedcontact_relationships != nil {
  8439. edges = append(edges, contact.EdgeContactRelationships)
  8440. }
  8441. if m.removedcontact_messages != nil {
  8442. edges = append(edges, contact.EdgeContactMessages)
  8443. }
  8444. return edges
  8445. }
  8446. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8447. // the given name in this mutation.
  8448. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  8449. switch name {
  8450. case contact.EdgeContactRelationships:
  8451. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  8452. for id := range m.removedcontact_relationships {
  8453. ids = append(ids, id)
  8454. }
  8455. return ids
  8456. case contact.EdgeContactMessages:
  8457. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  8458. for id := range m.removedcontact_messages {
  8459. ids = append(ids, id)
  8460. }
  8461. return ids
  8462. }
  8463. return nil
  8464. }
  8465. // ClearedEdges returns all edge names that were cleared in this mutation.
  8466. func (m *ContactMutation) ClearedEdges() []string {
  8467. edges := make([]string, 0, 2)
  8468. if m.clearedcontact_relationships {
  8469. edges = append(edges, contact.EdgeContactRelationships)
  8470. }
  8471. if m.clearedcontact_messages {
  8472. edges = append(edges, contact.EdgeContactMessages)
  8473. }
  8474. return edges
  8475. }
  8476. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8477. // was cleared in this mutation.
  8478. func (m *ContactMutation) EdgeCleared(name string) bool {
  8479. switch name {
  8480. case contact.EdgeContactRelationships:
  8481. return m.clearedcontact_relationships
  8482. case contact.EdgeContactMessages:
  8483. return m.clearedcontact_messages
  8484. }
  8485. return false
  8486. }
  8487. // ClearEdge clears the value of the edge with the given name. It returns an error
  8488. // if that edge is not defined in the schema.
  8489. func (m *ContactMutation) ClearEdge(name string) error {
  8490. switch name {
  8491. }
  8492. return fmt.Errorf("unknown Contact unique edge %s", name)
  8493. }
  8494. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8495. // It returns an error if the edge is not defined in the schema.
  8496. func (m *ContactMutation) ResetEdge(name string) error {
  8497. switch name {
  8498. case contact.EdgeContactRelationships:
  8499. m.ResetContactRelationships()
  8500. return nil
  8501. case contact.EdgeContactMessages:
  8502. m.ResetContactMessages()
  8503. return nil
  8504. }
  8505. return fmt.Errorf("unknown Contact edge %s", name)
  8506. }
  8507. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  8508. type EmployeeMutation struct {
  8509. config
  8510. op Op
  8511. typ string
  8512. id *uint64
  8513. created_at *time.Time
  8514. updated_at *time.Time
  8515. deleted_at *time.Time
  8516. title *string
  8517. avatar *string
  8518. tags *string
  8519. hire_count *int
  8520. addhire_count *int
  8521. service_count *int
  8522. addservice_count *int
  8523. achievement_count *int
  8524. addachievement_count *int
  8525. intro *string
  8526. estimate *string
  8527. skill *string
  8528. ability_type *string
  8529. scene *string
  8530. switch_in *string
  8531. video_url *string
  8532. organization_id *uint64
  8533. addorganization_id *int64
  8534. category_id *uint64
  8535. addcategory_id *int64
  8536. api_base *string
  8537. api_key *string
  8538. ai_info *string
  8539. is_vip *int
  8540. addis_vip *int
  8541. chat_url *string
  8542. clearedFields map[string]struct{}
  8543. em_work_experiences map[uint64]struct{}
  8544. removedem_work_experiences map[uint64]struct{}
  8545. clearedem_work_experiences bool
  8546. em_tutorial map[uint64]struct{}
  8547. removedem_tutorial map[uint64]struct{}
  8548. clearedem_tutorial bool
  8549. done bool
  8550. oldValue func(context.Context) (*Employee, error)
  8551. predicates []predicate.Employee
  8552. }
  8553. var _ ent.Mutation = (*EmployeeMutation)(nil)
  8554. // employeeOption allows management of the mutation configuration using functional options.
  8555. type employeeOption func(*EmployeeMutation)
  8556. // newEmployeeMutation creates new mutation for the Employee entity.
  8557. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  8558. m := &EmployeeMutation{
  8559. config: c,
  8560. op: op,
  8561. typ: TypeEmployee,
  8562. clearedFields: make(map[string]struct{}),
  8563. }
  8564. for _, opt := range opts {
  8565. opt(m)
  8566. }
  8567. return m
  8568. }
  8569. // withEmployeeID sets the ID field of the mutation.
  8570. func withEmployeeID(id uint64) employeeOption {
  8571. return func(m *EmployeeMutation) {
  8572. var (
  8573. err error
  8574. once sync.Once
  8575. value *Employee
  8576. )
  8577. m.oldValue = func(ctx context.Context) (*Employee, error) {
  8578. once.Do(func() {
  8579. if m.done {
  8580. err = errors.New("querying old values post mutation is not allowed")
  8581. } else {
  8582. value, err = m.Client().Employee.Get(ctx, id)
  8583. }
  8584. })
  8585. return value, err
  8586. }
  8587. m.id = &id
  8588. }
  8589. }
  8590. // withEmployee sets the old Employee of the mutation.
  8591. func withEmployee(node *Employee) employeeOption {
  8592. return func(m *EmployeeMutation) {
  8593. m.oldValue = func(context.Context) (*Employee, error) {
  8594. return node, nil
  8595. }
  8596. m.id = &node.ID
  8597. }
  8598. }
  8599. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8600. // executed in a transaction (ent.Tx), a transactional client is returned.
  8601. func (m EmployeeMutation) Client() *Client {
  8602. client := &Client{config: m.config}
  8603. client.init()
  8604. return client
  8605. }
  8606. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8607. // it returns an error otherwise.
  8608. func (m EmployeeMutation) Tx() (*Tx, error) {
  8609. if _, ok := m.driver.(*txDriver); !ok {
  8610. return nil, errors.New("ent: mutation is not running in a transaction")
  8611. }
  8612. tx := &Tx{config: m.config}
  8613. tx.init()
  8614. return tx, nil
  8615. }
  8616. // SetID sets the value of the id field. Note that this
  8617. // operation is only accepted on creation of Employee entities.
  8618. func (m *EmployeeMutation) SetID(id uint64) {
  8619. m.id = &id
  8620. }
  8621. // ID returns the ID value in the mutation. Note that the ID is only available
  8622. // if it was provided to the builder or after it was returned from the database.
  8623. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  8624. if m.id == nil {
  8625. return
  8626. }
  8627. return *m.id, true
  8628. }
  8629. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8630. // That means, if the mutation is applied within a transaction with an isolation level such
  8631. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8632. // or updated by the mutation.
  8633. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  8634. switch {
  8635. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8636. id, exists := m.ID()
  8637. if exists {
  8638. return []uint64{id}, nil
  8639. }
  8640. fallthrough
  8641. case m.op.Is(OpUpdate | OpDelete):
  8642. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  8643. default:
  8644. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8645. }
  8646. }
  8647. // SetCreatedAt sets the "created_at" field.
  8648. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  8649. m.created_at = &t
  8650. }
  8651. // CreatedAt returns the value of the "created_at" field in the mutation.
  8652. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  8653. v := m.created_at
  8654. if v == nil {
  8655. return
  8656. }
  8657. return *v, true
  8658. }
  8659. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  8660. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8661. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8662. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8663. if !m.op.Is(OpUpdateOne) {
  8664. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8665. }
  8666. if m.id == nil || m.oldValue == nil {
  8667. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8668. }
  8669. oldValue, err := m.oldValue(ctx)
  8670. if err != nil {
  8671. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8672. }
  8673. return oldValue.CreatedAt, nil
  8674. }
  8675. // ResetCreatedAt resets all changes to the "created_at" field.
  8676. func (m *EmployeeMutation) ResetCreatedAt() {
  8677. m.created_at = nil
  8678. }
  8679. // SetUpdatedAt sets the "updated_at" field.
  8680. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  8681. m.updated_at = &t
  8682. }
  8683. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8684. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  8685. v := m.updated_at
  8686. if v == nil {
  8687. return
  8688. }
  8689. return *v, true
  8690. }
  8691. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  8692. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8693. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8694. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8695. if !m.op.Is(OpUpdateOne) {
  8696. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8697. }
  8698. if m.id == nil || m.oldValue == nil {
  8699. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8700. }
  8701. oldValue, err := m.oldValue(ctx)
  8702. if err != nil {
  8703. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8704. }
  8705. return oldValue.UpdatedAt, nil
  8706. }
  8707. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8708. func (m *EmployeeMutation) ResetUpdatedAt() {
  8709. m.updated_at = nil
  8710. }
  8711. // SetDeletedAt sets the "deleted_at" field.
  8712. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  8713. m.deleted_at = &t
  8714. }
  8715. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8716. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  8717. v := m.deleted_at
  8718. if v == nil {
  8719. return
  8720. }
  8721. return *v, true
  8722. }
  8723. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  8724. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8725. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8726. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8727. if !m.op.Is(OpUpdateOne) {
  8728. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8729. }
  8730. if m.id == nil || m.oldValue == nil {
  8731. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8732. }
  8733. oldValue, err := m.oldValue(ctx)
  8734. if err != nil {
  8735. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8736. }
  8737. return oldValue.DeletedAt, nil
  8738. }
  8739. // ClearDeletedAt clears the value of the "deleted_at" field.
  8740. func (m *EmployeeMutation) ClearDeletedAt() {
  8741. m.deleted_at = nil
  8742. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  8743. }
  8744. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8745. func (m *EmployeeMutation) DeletedAtCleared() bool {
  8746. _, ok := m.clearedFields[employee.FieldDeletedAt]
  8747. return ok
  8748. }
  8749. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8750. func (m *EmployeeMutation) ResetDeletedAt() {
  8751. m.deleted_at = nil
  8752. delete(m.clearedFields, employee.FieldDeletedAt)
  8753. }
  8754. // SetTitle sets the "title" field.
  8755. func (m *EmployeeMutation) SetTitle(s string) {
  8756. m.title = &s
  8757. }
  8758. // Title returns the value of the "title" field in the mutation.
  8759. func (m *EmployeeMutation) Title() (r string, exists bool) {
  8760. v := m.title
  8761. if v == nil {
  8762. return
  8763. }
  8764. return *v, true
  8765. }
  8766. // OldTitle returns the old "title" field's value of the Employee entity.
  8767. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8768. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8769. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  8770. if !m.op.Is(OpUpdateOne) {
  8771. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  8772. }
  8773. if m.id == nil || m.oldValue == nil {
  8774. return v, errors.New("OldTitle requires an ID field in the mutation")
  8775. }
  8776. oldValue, err := m.oldValue(ctx)
  8777. if err != nil {
  8778. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  8779. }
  8780. return oldValue.Title, nil
  8781. }
  8782. // ResetTitle resets all changes to the "title" field.
  8783. func (m *EmployeeMutation) ResetTitle() {
  8784. m.title = nil
  8785. }
  8786. // SetAvatar sets the "avatar" field.
  8787. func (m *EmployeeMutation) SetAvatar(s string) {
  8788. m.avatar = &s
  8789. }
  8790. // Avatar returns the value of the "avatar" field in the mutation.
  8791. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  8792. v := m.avatar
  8793. if v == nil {
  8794. return
  8795. }
  8796. return *v, true
  8797. }
  8798. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  8799. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8801. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  8802. if !m.op.Is(OpUpdateOne) {
  8803. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  8804. }
  8805. if m.id == nil || m.oldValue == nil {
  8806. return v, errors.New("OldAvatar requires an ID field in the mutation")
  8807. }
  8808. oldValue, err := m.oldValue(ctx)
  8809. if err != nil {
  8810. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  8811. }
  8812. return oldValue.Avatar, nil
  8813. }
  8814. // ResetAvatar resets all changes to the "avatar" field.
  8815. func (m *EmployeeMutation) ResetAvatar() {
  8816. m.avatar = nil
  8817. }
  8818. // SetTags sets the "tags" field.
  8819. func (m *EmployeeMutation) SetTags(s string) {
  8820. m.tags = &s
  8821. }
  8822. // Tags returns the value of the "tags" field in the mutation.
  8823. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  8824. v := m.tags
  8825. if v == nil {
  8826. return
  8827. }
  8828. return *v, true
  8829. }
  8830. // OldTags returns the old "tags" field's value of the Employee entity.
  8831. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8832. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8833. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  8834. if !m.op.Is(OpUpdateOne) {
  8835. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  8836. }
  8837. if m.id == nil || m.oldValue == nil {
  8838. return v, errors.New("OldTags requires an ID field in the mutation")
  8839. }
  8840. oldValue, err := m.oldValue(ctx)
  8841. if err != nil {
  8842. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  8843. }
  8844. return oldValue.Tags, nil
  8845. }
  8846. // ResetTags resets all changes to the "tags" field.
  8847. func (m *EmployeeMutation) ResetTags() {
  8848. m.tags = nil
  8849. }
  8850. // SetHireCount sets the "hire_count" field.
  8851. func (m *EmployeeMutation) SetHireCount(i int) {
  8852. m.hire_count = &i
  8853. m.addhire_count = nil
  8854. }
  8855. // HireCount returns the value of the "hire_count" field in the mutation.
  8856. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  8857. v := m.hire_count
  8858. if v == nil {
  8859. return
  8860. }
  8861. return *v, true
  8862. }
  8863. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  8864. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8865. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8866. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  8867. if !m.op.Is(OpUpdateOne) {
  8868. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  8869. }
  8870. if m.id == nil || m.oldValue == nil {
  8871. return v, errors.New("OldHireCount requires an ID field in the mutation")
  8872. }
  8873. oldValue, err := m.oldValue(ctx)
  8874. if err != nil {
  8875. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  8876. }
  8877. return oldValue.HireCount, nil
  8878. }
  8879. // AddHireCount adds i to the "hire_count" field.
  8880. func (m *EmployeeMutation) AddHireCount(i int) {
  8881. if m.addhire_count != nil {
  8882. *m.addhire_count += i
  8883. } else {
  8884. m.addhire_count = &i
  8885. }
  8886. }
  8887. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  8888. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  8889. v := m.addhire_count
  8890. if v == nil {
  8891. return
  8892. }
  8893. return *v, true
  8894. }
  8895. // ResetHireCount resets all changes to the "hire_count" field.
  8896. func (m *EmployeeMutation) ResetHireCount() {
  8897. m.hire_count = nil
  8898. m.addhire_count = nil
  8899. }
  8900. // SetServiceCount sets the "service_count" field.
  8901. func (m *EmployeeMutation) SetServiceCount(i int) {
  8902. m.service_count = &i
  8903. m.addservice_count = nil
  8904. }
  8905. // ServiceCount returns the value of the "service_count" field in the mutation.
  8906. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  8907. v := m.service_count
  8908. if v == nil {
  8909. return
  8910. }
  8911. return *v, true
  8912. }
  8913. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  8914. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8915. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8916. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  8917. if !m.op.Is(OpUpdateOne) {
  8918. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  8919. }
  8920. if m.id == nil || m.oldValue == nil {
  8921. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  8922. }
  8923. oldValue, err := m.oldValue(ctx)
  8924. if err != nil {
  8925. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  8926. }
  8927. return oldValue.ServiceCount, nil
  8928. }
  8929. // AddServiceCount adds i to the "service_count" field.
  8930. func (m *EmployeeMutation) AddServiceCount(i int) {
  8931. if m.addservice_count != nil {
  8932. *m.addservice_count += i
  8933. } else {
  8934. m.addservice_count = &i
  8935. }
  8936. }
  8937. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  8938. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  8939. v := m.addservice_count
  8940. if v == nil {
  8941. return
  8942. }
  8943. return *v, true
  8944. }
  8945. // ResetServiceCount resets all changes to the "service_count" field.
  8946. func (m *EmployeeMutation) ResetServiceCount() {
  8947. m.service_count = nil
  8948. m.addservice_count = nil
  8949. }
  8950. // SetAchievementCount sets the "achievement_count" field.
  8951. func (m *EmployeeMutation) SetAchievementCount(i int) {
  8952. m.achievement_count = &i
  8953. m.addachievement_count = nil
  8954. }
  8955. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  8956. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  8957. v := m.achievement_count
  8958. if v == nil {
  8959. return
  8960. }
  8961. return *v, true
  8962. }
  8963. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  8964. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8965. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8966. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  8967. if !m.op.Is(OpUpdateOne) {
  8968. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  8969. }
  8970. if m.id == nil || m.oldValue == nil {
  8971. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  8972. }
  8973. oldValue, err := m.oldValue(ctx)
  8974. if err != nil {
  8975. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  8976. }
  8977. return oldValue.AchievementCount, nil
  8978. }
  8979. // AddAchievementCount adds i to the "achievement_count" field.
  8980. func (m *EmployeeMutation) AddAchievementCount(i int) {
  8981. if m.addachievement_count != nil {
  8982. *m.addachievement_count += i
  8983. } else {
  8984. m.addachievement_count = &i
  8985. }
  8986. }
  8987. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  8988. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  8989. v := m.addachievement_count
  8990. if v == nil {
  8991. return
  8992. }
  8993. return *v, true
  8994. }
  8995. // ResetAchievementCount resets all changes to the "achievement_count" field.
  8996. func (m *EmployeeMutation) ResetAchievementCount() {
  8997. m.achievement_count = nil
  8998. m.addachievement_count = nil
  8999. }
  9000. // SetIntro sets the "intro" field.
  9001. func (m *EmployeeMutation) SetIntro(s string) {
  9002. m.intro = &s
  9003. }
  9004. // Intro returns the value of the "intro" field in the mutation.
  9005. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  9006. v := m.intro
  9007. if v == nil {
  9008. return
  9009. }
  9010. return *v, true
  9011. }
  9012. // OldIntro returns the old "intro" field's value of the Employee entity.
  9013. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9014. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9015. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  9016. if !m.op.Is(OpUpdateOne) {
  9017. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  9018. }
  9019. if m.id == nil || m.oldValue == nil {
  9020. return v, errors.New("OldIntro requires an ID field in the mutation")
  9021. }
  9022. oldValue, err := m.oldValue(ctx)
  9023. if err != nil {
  9024. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  9025. }
  9026. return oldValue.Intro, nil
  9027. }
  9028. // ResetIntro resets all changes to the "intro" field.
  9029. func (m *EmployeeMutation) ResetIntro() {
  9030. m.intro = nil
  9031. }
  9032. // SetEstimate sets the "estimate" field.
  9033. func (m *EmployeeMutation) SetEstimate(s string) {
  9034. m.estimate = &s
  9035. }
  9036. // Estimate returns the value of the "estimate" field in the mutation.
  9037. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  9038. v := m.estimate
  9039. if v == nil {
  9040. return
  9041. }
  9042. return *v, true
  9043. }
  9044. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  9045. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9046. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9047. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  9048. if !m.op.Is(OpUpdateOne) {
  9049. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  9050. }
  9051. if m.id == nil || m.oldValue == nil {
  9052. return v, errors.New("OldEstimate requires an ID field in the mutation")
  9053. }
  9054. oldValue, err := m.oldValue(ctx)
  9055. if err != nil {
  9056. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  9057. }
  9058. return oldValue.Estimate, nil
  9059. }
  9060. // ResetEstimate resets all changes to the "estimate" field.
  9061. func (m *EmployeeMutation) ResetEstimate() {
  9062. m.estimate = nil
  9063. }
  9064. // SetSkill sets the "skill" field.
  9065. func (m *EmployeeMutation) SetSkill(s string) {
  9066. m.skill = &s
  9067. }
  9068. // Skill returns the value of the "skill" field in the mutation.
  9069. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  9070. v := m.skill
  9071. if v == nil {
  9072. return
  9073. }
  9074. return *v, true
  9075. }
  9076. // OldSkill returns the old "skill" field's value of the Employee entity.
  9077. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9078. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9079. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  9080. if !m.op.Is(OpUpdateOne) {
  9081. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  9082. }
  9083. if m.id == nil || m.oldValue == nil {
  9084. return v, errors.New("OldSkill requires an ID field in the mutation")
  9085. }
  9086. oldValue, err := m.oldValue(ctx)
  9087. if err != nil {
  9088. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  9089. }
  9090. return oldValue.Skill, nil
  9091. }
  9092. // ResetSkill resets all changes to the "skill" field.
  9093. func (m *EmployeeMutation) ResetSkill() {
  9094. m.skill = nil
  9095. }
  9096. // SetAbilityType sets the "ability_type" field.
  9097. func (m *EmployeeMutation) SetAbilityType(s string) {
  9098. m.ability_type = &s
  9099. }
  9100. // AbilityType returns the value of the "ability_type" field in the mutation.
  9101. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  9102. v := m.ability_type
  9103. if v == nil {
  9104. return
  9105. }
  9106. return *v, true
  9107. }
  9108. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  9109. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9110. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9111. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  9112. if !m.op.Is(OpUpdateOne) {
  9113. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  9114. }
  9115. if m.id == nil || m.oldValue == nil {
  9116. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  9117. }
  9118. oldValue, err := m.oldValue(ctx)
  9119. if err != nil {
  9120. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  9121. }
  9122. return oldValue.AbilityType, nil
  9123. }
  9124. // ResetAbilityType resets all changes to the "ability_type" field.
  9125. func (m *EmployeeMutation) ResetAbilityType() {
  9126. m.ability_type = nil
  9127. }
  9128. // SetScene sets the "scene" field.
  9129. func (m *EmployeeMutation) SetScene(s string) {
  9130. m.scene = &s
  9131. }
  9132. // Scene returns the value of the "scene" field in the mutation.
  9133. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  9134. v := m.scene
  9135. if v == nil {
  9136. return
  9137. }
  9138. return *v, true
  9139. }
  9140. // OldScene returns the old "scene" field's value of the Employee entity.
  9141. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9142. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9143. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  9144. if !m.op.Is(OpUpdateOne) {
  9145. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  9146. }
  9147. if m.id == nil || m.oldValue == nil {
  9148. return v, errors.New("OldScene requires an ID field in the mutation")
  9149. }
  9150. oldValue, err := m.oldValue(ctx)
  9151. if err != nil {
  9152. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  9153. }
  9154. return oldValue.Scene, nil
  9155. }
  9156. // ResetScene resets all changes to the "scene" field.
  9157. func (m *EmployeeMutation) ResetScene() {
  9158. m.scene = nil
  9159. }
  9160. // SetSwitchIn sets the "switch_in" field.
  9161. func (m *EmployeeMutation) SetSwitchIn(s string) {
  9162. m.switch_in = &s
  9163. }
  9164. // SwitchIn returns the value of the "switch_in" field in the mutation.
  9165. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  9166. v := m.switch_in
  9167. if v == nil {
  9168. return
  9169. }
  9170. return *v, true
  9171. }
  9172. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  9173. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9174. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9175. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  9176. if !m.op.Is(OpUpdateOne) {
  9177. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  9178. }
  9179. if m.id == nil || m.oldValue == nil {
  9180. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  9181. }
  9182. oldValue, err := m.oldValue(ctx)
  9183. if err != nil {
  9184. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  9185. }
  9186. return oldValue.SwitchIn, nil
  9187. }
  9188. // ResetSwitchIn resets all changes to the "switch_in" field.
  9189. func (m *EmployeeMutation) ResetSwitchIn() {
  9190. m.switch_in = nil
  9191. }
  9192. // SetVideoURL sets the "video_url" field.
  9193. func (m *EmployeeMutation) SetVideoURL(s string) {
  9194. m.video_url = &s
  9195. }
  9196. // VideoURL returns the value of the "video_url" field in the mutation.
  9197. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  9198. v := m.video_url
  9199. if v == nil {
  9200. return
  9201. }
  9202. return *v, true
  9203. }
  9204. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  9205. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9206. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9207. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  9208. if !m.op.Is(OpUpdateOne) {
  9209. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  9210. }
  9211. if m.id == nil || m.oldValue == nil {
  9212. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  9213. }
  9214. oldValue, err := m.oldValue(ctx)
  9215. if err != nil {
  9216. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  9217. }
  9218. return oldValue.VideoURL, nil
  9219. }
  9220. // ResetVideoURL resets all changes to the "video_url" field.
  9221. func (m *EmployeeMutation) ResetVideoURL() {
  9222. m.video_url = nil
  9223. }
  9224. // SetOrganizationID sets the "organization_id" field.
  9225. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  9226. m.organization_id = &u
  9227. m.addorganization_id = nil
  9228. }
  9229. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9230. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  9231. v := m.organization_id
  9232. if v == nil {
  9233. return
  9234. }
  9235. return *v, true
  9236. }
  9237. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  9238. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9239. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9240. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9241. if !m.op.Is(OpUpdateOne) {
  9242. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9243. }
  9244. if m.id == nil || m.oldValue == nil {
  9245. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9246. }
  9247. oldValue, err := m.oldValue(ctx)
  9248. if err != nil {
  9249. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9250. }
  9251. return oldValue.OrganizationID, nil
  9252. }
  9253. // AddOrganizationID adds u to the "organization_id" field.
  9254. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  9255. if m.addorganization_id != nil {
  9256. *m.addorganization_id += u
  9257. } else {
  9258. m.addorganization_id = &u
  9259. }
  9260. }
  9261. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9262. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  9263. v := m.addorganization_id
  9264. if v == nil {
  9265. return
  9266. }
  9267. return *v, true
  9268. }
  9269. // ResetOrganizationID resets all changes to the "organization_id" field.
  9270. func (m *EmployeeMutation) ResetOrganizationID() {
  9271. m.organization_id = nil
  9272. m.addorganization_id = nil
  9273. }
  9274. // SetCategoryID sets the "category_id" field.
  9275. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  9276. m.category_id = &u
  9277. m.addcategory_id = nil
  9278. }
  9279. // CategoryID returns the value of the "category_id" field in the mutation.
  9280. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  9281. v := m.category_id
  9282. if v == nil {
  9283. return
  9284. }
  9285. return *v, true
  9286. }
  9287. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  9288. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9289. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9290. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  9291. if !m.op.Is(OpUpdateOne) {
  9292. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  9293. }
  9294. if m.id == nil || m.oldValue == nil {
  9295. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  9296. }
  9297. oldValue, err := m.oldValue(ctx)
  9298. if err != nil {
  9299. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  9300. }
  9301. return oldValue.CategoryID, nil
  9302. }
  9303. // AddCategoryID adds u to the "category_id" field.
  9304. func (m *EmployeeMutation) AddCategoryID(u int64) {
  9305. if m.addcategory_id != nil {
  9306. *m.addcategory_id += u
  9307. } else {
  9308. m.addcategory_id = &u
  9309. }
  9310. }
  9311. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  9312. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  9313. v := m.addcategory_id
  9314. if v == nil {
  9315. return
  9316. }
  9317. return *v, true
  9318. }
  9319. // ResetCategoryID resets all changes to the "category_id" field.
  9320. func (m *EmployeeMutation) ResetCategoryID() {
  9321. m.category_id = nil
  9322. m.addcategory_id = nil
  9323. }
  9324. // SetAPIBase sets the "api_base" field.
  9325. func (m *EmployeeMutation) SetAPIBase(s string) {
  9326. m.api_base = &s
  9327. }
  9328. // APIBase returns the value of the "api_base" field in the mutation.
  9329. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  9330. v := m.api_base
  9331. if v == nil {
  9332. return
  9333. }
  9334. return *v, true
  9335. }
  9336. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  9337. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9338. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9339. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  9340. if !m.op.Is(OpUpdateOne) {
  9341. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  9342. }
  9343. if m.id == nil || m.oldValue == nil {
  9344. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  9345. }
  9346. oldValue, err := m.oldValue(ctx)
  9347. if err != nil {
  9348. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  9349. }
  9350. return oldValue.APIBase, nil
  9351. }
  9352. // ResetAPIBase resets all changes to the "api_base" field.
  9353. func (m *EmployeeMutation) ResetAPIBase() {
  9354. m.api_base = nil
  9355. }
  9356. // SetAPIKey sets the "api_key" field.
  9357. func (m *EmployeeMutation) SetAPIKey(s string) {
  9358. m.api_key = &s
  9359. }
  9360. // APIKey returns the value of the "api_key" field in the mutation.
  9361. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  9362. v := m.api_key
  9363. if v == nil {
  9364. return
  9365. }
  9366. return *v, true
  9367. }
  9368. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  9369. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9370. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9371. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  9372. if !m.op.Is(OpUpdateOne) {
  9373. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  9374. }
  9375. if m.id == nil || m.oldValue == nil {
  9376. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  9377. }
  9378. oldValue, err := m.oldValue(ctx)
  9379. if err != nil {
  9380. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  9381. }
  9382. return oldValue.APIKey, nil
  9383. }
  9384. // ResetAPIKey resets all changes to the "api_key" field.
  9385. func (m *EmployeeMutation) ResetAPIKey() {
  9386. m.api_key = nil
  9387. }
  9388. // SetAiInfo sets the "ai_info" field.
  9389. func (m *EmployeeMutation) SetAiInfo(s string) {
  9390. m.ai_info = &s
  9391. }
  9392. // AiInfo returns the value of the "ai_info" field in the mutation.
  9393. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  9394. v := m.ai_info
  9395. if v == nil {
  9396. return
  9397. }
  9398. return *v, true
  9399. }
  9400. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  9401. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9402. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9403. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  9404. if !m.op.Is(OpUpdateOne) {
  9405. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  9406. }
  9407. if m.id == nil || m.oldValue == nil {
  9408. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  9409. }
  9410. oldValue, err := m.oldValue(ctx)
  9411. if err != nil {
  9412. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  9413. }
  9414. return oldValue.AiInfo, nil
  9415. }
  9416. // ClearAiInfo clears the value of the "ai_info" field.
  9417. func (m *EmployeeMutation) ClearAiInfo() {
  9418. m.ai_info = nil
  9419. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  9420. }
  9421. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  9422. func (m *EmployeeMutation) AiInfoCleared() bool {
  9423. _, ok := m.clearedFields[employee.FieldAiInfo]
  9424. return ok
  9425. }
  9426. // ResetAiInfo resets all changes to the "ai_info" field.
  9427. func (m *EmployeeMutation) ResetAiInfo() {
  9428. m.ai_info = nil
  9429. delete(m.clearedFields, employee.FieldAiInfo)
  9430. }
  9431. // SetIsVip sets the "is_vip" field.
  9432. func (m *EmployeeMutation) SetIsVip(i int) {
  9433. m.is_vip = &i
  9434. m.addis_vip = nil
  9435. }
  9436. // IsVip returns the value of the "is_vip" field in the mutation.
  9437. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  9438. v := m.is_vip
  9439. if v == nil {
  9440. return
  9441. }
  9442. return *v, true
  9443. }
  9444. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  9445. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9447. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  9448. if !m.op.Is(OpUpdateOne) {
  9449. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  9450. }
  9451. if m.id == nil || m.oldValue == nil {
  9452. return v, errors.New("OldIsVip requires an ID field in the mutation")
  9453. }
  9454. oldValue, err := m.oldValue(ctx)
  9455. if err != nil {
  9456. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  9457. }
  9458. return oldValue.IsVip, nil
  9459. }
  9460. // AddIsVip adds i to the "is_vip" field.
  9461. func (m *EmployeeMutation) AddIsVip(i int) {
  9462. if m.addis_vip != nil {
  9463. *m.addis_vip += i
  9464. } else {
  9465. m.addis_vip = &i
  9466. }
  9467. }
  9468. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  9469. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  9470. v := m.addis_vip
  9471. if v == nil {
  9472. return
  9473. }
  9474. return *v, true
  9475. }
  9476. // ResetIsVip resets all changes to the "is_vip" field.
  9477. func (m *EmployeeMutation) ResetIsVip() {
  9478. m.is_vip = nil
  9479. m.addis_vip = nil
  9480. }
  9481. // SetChatURL sets the "chat_url" field.
  9482. func (m *EmployeeMutation) SetChatURL(s string) {
  9483. m.chat_url = &s
  9484. }
  9485. // ChatURL returns the value of the "chat_url" field in the mutation.
  9486. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  9487. v := m.chat_url
  9488. if v == nil {
  9489. return
  9490. }
  9491. return *v, true
  9492. }
  9493. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  9494. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9496. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  9497. if !m.op.Is(OpUpdateOne) {
  9498. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  9499. }
  9500. if m.id == nil || m.oldValue == nil {
  9501. return v, errors.New("OldChatURL requires an ID field in the mutation")
  9502. }
  9503. oldValue, err := m.oldValue(ctx)
  9504. if err != nil {
  9505. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  9506. }
  9507. return oldValue.ChatURL, nil
  9508. }
  9509. // ResetChatURL resets all changes to the "chat_url" field.
  9510. func (m *EmployeeMutation) ResetChatURL() {
  9511. m.chat_url = nil
  9512. }
  9513. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  9514. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  9515. if m.em_work_experiences == nil {
  9516. m.em_work_experiences = make(map[uint64]struct{})
  9517. }
  9518. for i := range ids {
  9519. m.em_work_experiences[ids[i]] = struct{}{}
  9520. }
  9521. }
  9522. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  9523. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  9524. m.clearedem_work_experiences = true
  9525. }
  9526. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  9527. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  9528. return m.clearedem_work_experiences
  9529. }
  9530. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  9531. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  9532. if m.removedem_work_experiences == nil {
  9533. m.removedem_work_experiences = make(map[uint64]struct{})
  9534. }
  9535. for i := range ids {
  9536. delete(m.em_work_experiences, ids[i])
  9537. m.removedem_work_experiences[ids[i]] = struct{}{}
  9538. }
  9539. }
  9540. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  9541. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  9542. for id := range m.removedem_work_experiences {
  9543. ids = append(ids, id)
  9544. }
  9545. return
  9546. }
  9547. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  9548. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  9549. for id := range m.em_work_experiences {
  9550. ids = append(ids, id)
  9551. }
  9552. return
  9553. }
  9554. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  9555. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  9556. m.em_work_experiences = nil
  9557. m.clearedem_work_experiences = false
  9558. m.removedem_work_experiences = nil
  9559. }
  9560. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  9561. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  9562. if m.em_tutorial == nil {
  9563. m.em_tutorial = make(map[uint64]struct{})
  9564. }
  9565. for i := range ids {
  9566. m.em_tutorial[ids[i]] = struct{}{}
  9567. }
  9568. }
  9569. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  9570. func (m *EmployeeMutation) ClearEmTutorial() {
  9571. m.clearedem_tutorial = true
  9572. }
  9573. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  9574. func (m *EmployeeMutation) EmTutorialCleared() bool {
  9575. return m.clearedem_tutorial
  9576. }
  9577. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  9578. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  9579. if m.removedem_tutorial == nil {
  9580. m.removedem_tutorial = make(map[uint64]struct{})
  9581. }
  9582. for i := range ids {
  9583. delete(m.em_tutorial, ids[i])
  9584. m.removedem_tutorial[ids[i]] = struct{}{}
  9585. }
  9586. }
  9587. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  9588. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  9589. for id := range m.removedem_tutorial {
  9590. ids = append(ids, id)
  9591. }
  9592. return
  9593. }
  9594. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  9595. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  9596. for id := range m.em_tutorial {
  9597. ids = append(ids, id)
  9598. }
  9599. return
  9600. }
  9601. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  9602. func (m *EmployeeMutation) ResetEmTutorial() {
  9603. m.em_tutorial = nil
  9604. m.clearedem_tutorial = false
  9605. m.removedem_tutorial = nil
  9606. }
  9607. // Where appends a list predicates to the EmployeeMutation builder.
  9608. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  9609. m.predicates = append(m.predicates, ps...)
  9610. }
  9611. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  9612. // users can use type-assertion to append predicates that do not depend on any generated package.
  9613. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  9614. p := make([]predicate.Employee, len(ps))
  9615. for i := range ps {
  9616. p[i] = ps[i]
  9617. }
  9618. m.Where(p...)
  9619. }
  9620. // Op returns the operation name.
  9621. func (m *EmployeeMutation) Op() Op {
  9622. return m.op
  9623. }
  9624. // SetOp allows setting the mutation operation.
  9625. func (m *EmployeeMutation) SetOp(op Op) {
  9626. m.op = op
  9627. }
  9628. // Type returns the node type of this mutation (Employee).
  9629. func (m *EmployeeMutation) Type() string {
  9630. return m.typ
  9631. }
  9632. // Fields returns all fields that were changed during this mutation. Note that in
  9633. // order to get all numeric fields that were incremented/decremented, call
  9634. // AddedFields().
  9635. func (m *EmployeeMutation) Fields() []string {
  9636. fields := make([]string, 0, 23)
  9637. if m.created_at != nil {
  9638. fields = append(fields, employee.FieldCreatedAt)
  9639. }
  9640. if m.updated_at != nil {
  9641. fields = append(fields, employee.FieldUpdatedAt)
  9642. }
  9643. if m.deleted_at != nil {
  9644. fields = append(fields, employee.FieldDeletedAt)
  9645. }
  9646. if m.title != nil {
  9647. fields = append(fields, employee.FieldTitle)
  9648. }
  9649. if m.avatar != nil {
  9650. fields = append(fields, employee.FieldAvatar)
  9651. }
  9652. if m.tags != nil {
  9653. fields = append(fields, employee.FieldTags)
  9654. }
  9655. if m.hire_count != nil {
  9656. fields = append(fields, employee.FieldHireCount)
  9657. }
  9658. if m.service_count != nil {
  9659. fields = append(fields, employee.FieldServiceCount)
  9660. }
  9661. if m.achievement_count != nil {
  9662. fields = append(fields, employee.FieldAchievementCount)
  9663. }
  9664. if m.intro != nil {
  9665. fields = append(fields, employee.FieldIntro)
  9666. }
  9667. if m.estimate != nil {
  9668. fields = append(fields, employee.FieldEstimate)
  9669. }
  9670. if m.skill != nil {
  9671. fields = append(fields, employee.FieldSkill)
  9672. }
  9673. if m.ability_type != nil {
  9674. fields = append(fields, employee.FieldAbilityType)
  9675. }
  9676. if m.scene != nil {
  9677. fields = append(fields, employee.FieldScene)
  9678. }
  9679. if m.switch_in != nil {
  9680. fields = append(fields, employee.FieldSwitchIn)
  9681. }
  9682. if m.video_url != nil {
  9683. fields = append(fields, employee.FieldVideoURL)
  9684. }
  9685. if m.organization_id != nil {
  9686. fields = append(fields, employee.FieldOrganizationID)
  9687. }
  9688. if m.category_id != nil {
  9689. fields = append(fields, employee.FieldCategoryID)
  9690. }
  9691. if m.api_base != nil {
  9692. fields = append(fields, employee.FieldAPIBase)
  9693. }
  9694. if m.api_key != nil {
  9695. fields = append(fields, employee.FieldAPIKey)
  9696. }
  9697. if m.ai_info != nil {
  9698. fields = append(fields, employee.FieldAiInfo)
  9699. }
  9700. if m.is_vip != nil {
  9701. fields = append(fields, employee.FieldIsVip)
  9702. }
  9703. if m.chat_url != nil {
  9704. fields = append(fields, employee.FieldChatURL)
  9705. }
  9706. return fields
  9707. }
  9708. // Field returns the value of a field with the given name. The second boolean
  9709. // return value indicates that this field was not set, or was not defined in the
  9710. // schema.
  9711. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  9712. switch name {
  9713. case employee.FieldCreatedAt:
  9714. return m.CreatedAt()
  9715. case employee.FieldUpdatedAt:
  9716. return m.UpdatedAt()
  9717. case employee.FieldDeletedAt:
  9718. return m.DeletedAt()
  9719. case employee.FieldTitle:
  9720. return m.Title()
  9721. case employee.FieldAvatar:
  9722. return m.Avatar()
  9723. case employee.FieldTags:
  9724. return m.Tags()
  9725. case employee.FieldHireCount:
  9726. return m.HireCount()
  9727. case employee.FieldServiceCount:
  9728. return m.ServiceCount()
  9729. case employee.FieldAchievementCount:
  9730. return m.AchievementCount()
  9731. case employee.FieldIntro:
  9732. return m.Intro()
  9733. case employee.FieldEstimate:
  9734. return m.Estimate()
  9735. case employee.FieldSkill:
  9736. return m.Skill()
  9737. case employee.FieldAbilityType:
  9738. return m.AbilityType()
  9739. case employee.FieldScene:
  9740. return m.Scene()
  9741. case employee.FieldSwitchIn:
  9742. return m.SwitchIn()
  9743. case employee.FieldVideoURL:
  9744. return m.VideoURL()
  9745. case employee.FieldOrganizationID:
  9746. return m.OrganizationID()
  9747. case employee.FieldCategoryID:
  9748. return m.CategoryID()
  9749. case employee.FieldAPIBase:
  9750. return m.APIBase()
  9751. case employee.FieldAPIKey:
  9752. return m.APIKey()
  9753. case employee.FieldAiInfo:
  9754. return m.AiInfo()
  9755. case employee.FieldIsVip:
  9756. return m.IsVip()
  9757. case employee.FieldChatURL:
  9758. return m.ChatURL()
  9759. }
  9760. return nil, false
  9761. }
  9762. // OldField returns the old value of the field from the database. An error is
  9763. // returned if the mutation operation is not UpdateOne, or the query to the
  9764. // database failed.
  9765. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9766. switch name {
  9767. case employee.FieldCreatedAt:
  9768. return m.OldCreatedAt(ctx)
  9769. case employee.FieldUpdatedAt:
  9770. return m.OldUpdatedAt(ctx)
  9771. case employee.FieldDeletedAt:
  9772. return m.OldDeletedAt(ctx)
  9773. case employee.FieldTitle:
  9774. return m.OldTitle(ctx)
  9775. case employee.FieldAvatar:
  9776. return m.OldAvatar(ctx)
  9777. case employee.FieldTags:
  9778. return m.OldTags(ctx)
  9779. case employee.FieldHireCount:
  9780. return m.OldHireCount(ctx)
  9781. case employee.FieldServiceCount:
  9782. return m.OldServiceCount(ctx)
  9783. case employee.FieldAchievementCount:
  9784. return m.OldAchievementCount(ctx)
  9785. case employee.FieldIntro:
  9786. return m.OldIntro(ctx)
  9787. case employee.FieldEstimate:
  9788. return m.OldEstimate(ctx)
  9789. case employee.FieldSkill:
  9790. return m.OldSkill(ctx)
  9791. case employee.FieldAbilityType:
  9792. return m.OldAbilityType(ctx)
  9793. case employee.FieldScene:
  9794. return m.OldScene(ctx)
  9795. case employee.FieldSwitchIn:
  9796. return m.OldSwitchIn(ctx)
  9797. case employee.FieldVideoURL:
  9798. return m.OldVideoURL(ctx)
  9799. case employee.FieldOrganizationID:
  9800. return m.OldOrganizationID(ctx)
  9801. case employee.FieldCategoryID:
  9802. return m.OldCategoryID(ctx)
  9803. case employee.FieldAPIBase:
  9804. return m.OldAPIBase(ctx)
  9805. case employee.FieldAPIKey:
  9806. return m.OldAPIKey(ctx)
  9807. case employee.FieldAiInfo:
  9808. return m.OldAiInfo(ctx)
  9809. case employee.FieldIsVip:
  9810. return m.OldIsVip(ctx)
  9811. case employee.FieldChatURL:
  9812. return m.OldChatURL(ctx)
  9813. }
  9814. return nil, fmt.Errorf("unknown Employee field %s", name)
  9815. }
  9816. // SetField sets the value of a field with the given name. It returns an error if
  9817. // the field is not defined in the schema, or if the type mismatched the field
  9818. // type.
  9819. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  9820. switch name {
  9821. case employee.FieldCreatedAt:
  9822. v, ok := value.(time.Time)
  9823. if !ok {
  9824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9825. }
  9826. m.SetCreatedAt(v)
  9827. return nil
  9828. case employee.FieldUpdatedAt:
  9829. v, ok := value.(time.Time)
  9830. if !ok {
  9831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9832. }
  9833. m.SetUpdatedAt(v)
  9834. return nil
  9835. case employee.FieldDeletedAt:
  9836. v, ok := value.(time.Time)
  9837. if !ok {
  9838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9839. }
  9840. m.SetDeletedAt(v)
  9841. return nil
  9842. case employee.FieldTitle:
  9843. v, ok := value.(string)
  9844. if !ok {
  9845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9846. }
  9847. m.SetTitle(v)
  9848. return nil
  9849. case employee.FieldAvatar:
  9850. v, ok := value.(string)
  9851. if !ok {
  9852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9853. }
  9854. m.SetAvatar(v)
  9855. return nil
  9856. case employee.FieldTags:
  9857. v, ok := value.(string)
  9858. if !ok {
  9859. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9860. }
  9861. m.SetTags(v)
  9862. return nil
  9863. case employee.FieldHireCount:
  9864. v, ok := value.(int)
  9865. if !ok {
  9866. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9867. }
  9868. m.SetHireCount(v)
  9869. return nil
  9870. case employee.FieldServiceCount:
  9871. v, ok := value.(int)
  9872. if !ok {
  9873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9874. }
  9875. m.SetServiceCount(v)
  9876. return nil
  9877. case employee.FieldAchievementCount:
  9878. v, ok := value.(int)
  9879. if !ok {
  9880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9881. }
  9882. m.SetAchievementCount(v)
  9883. return nil
  9884. case employee.FieldIntro:
  9885. v, ok := value.(string)
  9886. if !ok {
  9887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9888. }
  9889. m.SetIntro(v)
  9890. return nil
  9891. case employee.FieldEstimate:
  9892. v, ok := value.(string)
  9893. if !ok {
  9894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9895. }
  9896. m.SetEstimate(v)
  9897. return nil
  9898. case employee.FieldSkill:
  9899. v, ok := value.(string)
  9900. if !ok {
  9901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9902. }
  9903. m.SetSkill(v)
  9904. return nil
  9905. case employee.FieldAbilityType:
  9906. v, ok := value.(string)
  9907. if !ok {
  9908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9909. }
  9910. m.SetAbilityType(v)
  9911. return nil
  9912. case employee.FieldScene:
  9913. v, ok := value.(string)
  9914. if !ok {
  9915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9916. }
  9917. m.SetScene(v)
  9918. return nil
  9919. case employee.FieldSwitchIn:
  9920. v, ok := value.(string)
  9921. if !ok {
  9922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9923. }
  9924. m.SetSwitchIn(v)
  9925. return nil
  9926. case employee.FieldVideoURL:
  9927. v, ok := value.(string)
  9928. if !ok {
  9929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9930. }
  9931. m.SetVideoURL(v)
  9932. return nil
  9933. case employee.FieldOrganizationID:
  9934. v, ok := value.(uint64)
  9935. if !ok {
  9936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9937. }
  9938. m.SetOrganizationID(v)
  9939. return nil
  9940. case employee.FieldCategoryID:
  9941. v, ok := value.(uint64)
  9942. if !ok {
  9943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9944. }
  9945. m.SetCategoryID(v)
  9946. return nil
  9947. case employee.FieldAPIBase:
  9948. v, ok := value.(string)
  9949. if !ok {
  9950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9951. }
  9952. m.SetAPIBase(v)
  9953. return nil
  9954. case employee.FieldAPIKey:
  9955. v, ok := value.(string)
  9956. if !ok {
  9957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9958. }
  9959. m.SetAPIKey(v)
  9960. return nil
  9961. case employee.FieldAiInfo:
  9962. v, ok := value.(string)
  9963. if !ok {
  9964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9965. }
  9966. m.SetAiInfo(v)
  9967. return nil
  9968. case employee.FieldIsVip:
  9969. v, ok := value.(int)
  9970. if !ok {
  9971. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9972. }
  9973. m.SetIsVip(v)
  9974. return nil
  9975. case employee.FieldChatURL:
  9976. v, ok := value.(string)
  9977. if !ok {
  9978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9979. }
  9980. m.SetChatURL(v)
  9981. return nil
  9982. }
  9983. return fmt.Errorf("unknown Employee field %s", name)
  9984. }
  9985. // AddedFields returns all numeric fields that were incremented/decremented during
  9986. // this mutation.
  9987. func (m *EmployeeMutation) AddedFields() []string {
  9988. var fields []string
  9989. if m.addhire_count != nil {
  9990. fields = append(fields, employee.FieldHireCount)
  9991. }
  9992. if m.addservice_count != nil {
  9993. fields = append(fields, employee.FieldServiceCount)
  9994. }
  9995. if m.addachievement_count != nil {
  9996. fields = append(fields, employee.FieldAchievementCount)
  9997. }
  9998. if m.addorganization_id != nil {
  9999. fields = append(fields, employee.FieldOrganizationID)
  10000. }
  10001. if m.addcategory_id != nil {
  10002. fields = append(fields, employee.FieldCategoryID)
  10003. }
  10004. if m.addis_vip != nil {
  10005. fields = append(fields, employee.FieldIsVip)
  10006. }
  10007. return fields
  10008. }
  10009. // AddedField returns the numeric value that was incremented/decremented on a field
  10010. // with the given name. The second boolean return value indicates that this field
  10011. // was not set, or was not defined in the schema.
  10012. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  10013. switch name {
  10014. case employee.FieldHireCount:
  10015. return m.AddedHireCount()
  10016. case employee.FieldServiceCount:
  10017. return m.AddedServiceCount()
  10018. case employee.FieldAchievementCount:
  10019. return m.AddedAchievementCount()
  10020. case employee.FieldOrganizationID:
  10021. return m.AddedOrganizationID()
  10022. case employee.FieldCategoryID:
  10023. return m.AddedCategoryID()
  10024. case employee.FieldIsVip:
  10025. return m.AddedIsVip()
  10026. }
  10027. return nil, false
  10028. }
  10029. // AddField adds the value to the field with the given name. It returns an error if
  10030. // the field is not defined in the schema, or if the type mismatched the field
  10031. // type.
  10032. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  10033. switch name {
  10034. case employee.FieldHireCount:
  10035. v, ok := value.(int)
  10036. if !ok {
  10037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10038. }
  10039. m.AddHireCount(v)
  10040. return nil
  10041. case employee.FieldServiceCount:
  10042. v, ok := value.(int)
  10043. if !ok {
  10044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10045. }
  10046. m.AddServiceCount(v)
  10047. return nil
  10048. case employee.FieldAchievementCount:
  10049. v, ok := value.(int)
  10050. if !ok {
  10051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10052. }
  10053. m.AddAchievementCount(v)
  10054. return nil
  10055. case employee.FieldOrganizationID:
  10056. v, ok := value.(int64)
  10057. if !ok {
  10058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10059. }
  10060. m.AddOrganizationID(v)
  10061. return nil
  10062. case employee.FieldCategoryID:
  10063. v, ok := value.(int64)
  10064. if !ok {
  10065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10066. }
  10067. m.AddCategoryID(v)
  10068. return nil
  10069. case employee.FieldIsVip:
  10070. v, ok := value.(int)
  10071. if !ok {
  10072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10073. }
  10074. m.AddIsVip(v)
  10075. return nil
  10076. }
  10077. return fmt.Errorf("unknown Employee numeric field %s", name)
  10078. }
  10079. // ClearedFields returns all nullable fields that were cleared during this
  10080. // mutation.
  10081. func (m *EmployeeMutation) ClearedFields() []string {
  10082. var fields []string
  10083. if m.FieldCleared(employee.FieldDeletedAt) {
  10084. fields = append(fields, employee.FieldDeletedAt)
  10085. }
  10086. if m.FieldCleared(employee.FieldAiInfo) {
  10087. fields = append(fields, employee.FieldAiInfo)
  10088. }
  10089. return fields
  10090. }
  10091. // FieldCleared returns a boolean indicating if a field with the given name was
  10092. // cleared in this mutation.
  10093. func (m *EmployeeMutation) FieldCleared(name string) bool {
  10094. _, ok := m.clearedFields[name]
  10095. return ok
  10096. }
  10097. // ClearField clears the value of the field with the given name. It returns an
  10098. // error if the field is not defined in the schema.
  10099. func (m *EmployeeMutation) ClearField(name string) error {
  10100. switch name {
  10101. case employee.FieldDeletedAt:
  10102. m.ClearDeletedAt()
  10103. return nil
  10104. case employee.FieldAiInfo:
  10105. m.ClearAiInfo()
  10106. return nil
  10107. }
  10108. return fmt.Errorf("unknown Employee nullable field %s", name)
  10109. }
  10110. // ResetField resets all changes in the mutation for the field with the given name.
  10111. // It returns an error if the field is not defined in the schema.
  10112. func (m *EmployeeMutation) ResetField(name string) error {
  10113. switch name {
  10114. case employee.FieldCreatedAt:
  10115. m.ResetCreatedAt()
  10116. return nil
  10117. case employee.FieldUpdatedAt:
  10118. m.ResetUpdatedAt()
  10119. return nil
  10120. case employee.FieldDeletedAt:
  10121. m.ResetDeletedAt()
  10122. return nil
  10123. case employee.FieldTitle:
  10124. m.ResetTitle()
  10125. return nil
  10126. case employee.FieldAvatar:
  10127. m.ResetAvatar()
  10128. return nil
  10129. case employee.FieldTags:
  10130. m.ResetTags()
  10131. return nil
  10132. case employee.FieldHireCount:
  10133. m.ResetHireCount()
  10134. return nil
  10135. case employee.FieldServiceCount:
  10136. m.ResetServiceCount()
  10137. return nil
  10138. case employee.FieldAchievementCount:
  10139. m.ResetAchievementCount()
  10140. return nil
  10141. case employee.FieldIntro:
  10142. m.ResetIntro()
  10143. return nil
  10144. case employee.FieldEstimate:
  10145. m.ResetEstimate()
  10146. return nil
  10147. case employee.FieldSkill:
  10148. m.ResetSkill()
  10149. return nil
  10150. case employee.FieldAbilityType:
  10151. m.ResetAbilityType()
  10152. return nil
  10153. case employee.FieldScene:
  10154. m.ResetScene()
  10155. return nil
  10156. case employee.FieldSwitchIn:
  10157. m.ResetSwitchIn()
  10158. return nil
  10159. case employee.FieldVideoURL:
  10160. m.ResetVideoURL()
  10161. return nil
  10162. case employee.FieldOrganizationID:
  10163. m.ResetOrganizationID()
  10164. return nil
  10165. case employee.FieldCategoryID:
  10166. m.ResetCategoryID()
  10167. return nil
  10168. case employee.FieldAPIBase:
  10169. m.ResetAPIBase()
  10170. return nil
  10171. case employee.FieldAPIKey:
  10172. m.ResetAPIKey()
  10173. return nil
  10174. case employee.FieldAiInfo:
  10175. m.ResetAiInfo()
  10176. return nil
  10177. case employee.FieldIsVip:
  10178. m.ResetIsVip()
  10179. return nil
  10180. case employee.FieldChatURL:
  10181. m.ResetChatURL()
  10182. return nil
  10183. }
  10184. return fmt.Errorf("unknown Employee field %s", name)
  10185. }
  10186. // AddedEdges returns all edge names that were set/added in this mutation.
  10187. func (m *EmployeeMutation) AddedEdges() []string {
  10188. edges := make([]string, 0, 2)
  10189. if m.em_work_experiences != nil {
  10190. edges = append(edges, employee.EdgeEmWorkExperiences)
  10191. }
  10192. if m.em_tutorial != nil {
  10193. edges = append(edges, employee.EdgeEmTutorial)
  10194. }
  10195. return edges
  10196. }
  10197. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10198. // name in this mutation.
  10199. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  10200. switch name {
  10201. case employee.EdgeEmWorkExperiences:
  10202. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  10203. for id := range m.em_work_experiences {
  10204. ids = append(ids, id)
  10205. }
  10206. return ids
  10207. case employee.EdgeEmTutorial:
  10208. ids := make([]ent.Value, 0, len(m.em_tutorial))
  10209. for id := range m.em_tutorial {
  10210. ids = append(ids, id)
  10211. }
  10212. return ids
  10213. }
  10214. return nil
  10215. }
  10216. // RemovedEdges returns all edge names that were removed in this mutation.
  10217. func (m *EmployeeMutation) RemovedEdges() []string {
  10218. edges := make([]string, 0, 2)
  10219. if m.removedem_work_experiences != nil {
  10220. edges = append(edges, employee.EdgeEmWorkExperiences)
  10221. }
  10222. if m.removedem_tutorial != nil {
  10223. edges = append(edges, employee.EdgeEmTutorial)
  10224. }
  10225. return edges
  10226. }
  10227. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10228. // the given name in this mutation.
  10229. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  10230. switch name {
  10231. case employee.EdgeEmWorkExperiences:
  10232. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  10233. for id := range m.removedem_work_experiences {
  10234. ids = append(ids, id)
  10235. }
  10236. return ids
  10237. case employee.EdgeEmTutorial:
  10238. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  10239. for id := range m.removedem_tutorial {
  10240. ids = append(ids, id)
  10241. }
  10242. return ids
  10243. }
  10244. return nil
  10245. }
  10246. // ClearedEdges returns all edge names that were cleared in this mutation.
  10247. func (m *EmployeeMutation) ClearedEdges() []string {
  10248. edges := make([]string, 0, 2)
  10249. if m.clearedem_work_experiences {
  10250. edges = append(edges, employee.EdgeEmWorkExperiences)
  10251. }
  10252. if m.clearedem_tutorial {
  10253. edges = append(edges, employee.EdgeEmTutorial)
  10254. }
  10255. return edges
  10256. }
  10257. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10258. // was cleared in this mutation.
  10259. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  10260. switch name {
  10261. case employee.EdgeEmWorkExperiences:
  10262. return m.clearedem_work_experiences
  10263. case employee.EdgeEmTutorial:
  10264. return m.clearedem_tutorial
  10265. }
  10266. return false
  10267. }
  10268. // ClearEdge clears the value of the edge with the given name. It returns an error
  10269. // if that edge is not defined in the schema.
  10270. func (m *EmployeeMutation) ClearEdge(name string) error {
  10271. switch name {
  10272. }
  10273. return fmt.Errorf("unknown Employee unique edge %s", name)
  10274. }
  10275. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10276. // It returns an error if the edge is not defined in the schema.
  10277. func (m *EmployeeMutation) ResetEdge(name string) error {
  10278. switch name {
  10279. case employee.EdgeEmWorkExperiences:
  10280. m.ResetEmWorkExperiences()
  10281. return nil
  10282. case employee.EdgeEmTutorial:
  10283. m.ResetEmTutorial()
  10284. return nil
  10285. }
  10286. return fmt.Errorf("unknown Employee edge %s", name)
  10287. }
  10288. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  10289. type EmployeeConfigMutation struct {
  10290. config
  10291. op Op
  10292. typ string
  10293. id *uint64
  10294. created_at *time.Time
  10295. updated_at *time.Time
  10296. deleted_at *time.Time
  10297. stype *string
  10298. title *string
  10299. photo *string
  10300. organization_id *uint64
  10301. addorganization_id *int64
  10302. clearedFields map[string]struct{}
  10303. done bool
  10304. oldValue func(context.Context) (*EmployeeConfig, error)
  10305. predicates []predicate.EmployeeConfig
  10306. }
  10307. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  10308. // employeeconfigOption allows management of the mutation configuration using functional options.
  10309. type employeeconfigOption func(*EmployeeConfigMutation)
  10310. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  10311. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  10312. m := &EmployeeConfigMutation{
  10313. config: c,
  10314. op: op,
  10315. typ: TypeEmployeeConfig,
  10316. clearedFields: make(map[string]struct{}),
  10317. }
  10318. for _, opt := range opts {
  10319. opt(m)
  10320. }
  10321. return m
  10322. }
  10323. // withEmployeeConfigID sets the ID field of the mutation.
  10324. func withEmployeeConfigID(id uint64) employeeconfigOption {
  10325. return func(m *EmployeeConfigMutation) {
  10326. var (
  10327. err error
  10328. once sync.Once
  10329. value *EmployeeConfig
  10330. )
  10331. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  10332. once.Do(func() {
  10333. if m.done {
  10334. err = errors.New("querying old values post mutation is not allowed")
  10335. } else {
  10336. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  10337. }
  10338. })
  10339. return value, err
  10340. }
  10341. m.id = &id
  10342. }
  10343. }
  10344. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  10345. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  10346. return func(m *EmployeeConfigMutation) {
  10347. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  10348. return node, nil
  10349. }
  10350. m.id = &node.ID
  10351. }
  10352. }
  10353. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10354. // executed in a transaction (ent.Tx), a transactional client is returned.
  10355. func (m EmployeeConfigMutation) Client() *Client {
  10356. client := &Client{config: m.config}
  10357. client.init()
  10358. return client
  10359. }
  10360. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10361. // it returns an error otherwise.
  10362. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  10363. if _, ok := m.driver.(*txDriver); !ok {
  10364. return nil, errors.New("ent: mutation is not running in a transaction")
  10365. }
  10366. tx := &Tx{config: m.config}
  10367. tx.init()
  10368. return tx, nil
  10369. }
  10370. // SetID sets the value of the id field. Note that this
  10371. // operation is only accepted on creation of EmployeeConfig entities.
  10372. func (m *EmployeeConfigMutation) SetID(id uint64) {
  10373. m.id = &id
  10374. }
  10375. // ID returns the ID value in the mutation. Note that the ID is only available
  10376. // if it was provided to the builder or after it was returned from the database.
  10377. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  10378. if m.id == nil {
  10379. return
  10380. }
  10381. return *m.id, true
  10382. }
  10383. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10384. // That means, if the mutation is applied within a transaction with an isolation level such
  10385. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10386. // or updated by the mutation.
  10387. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  10388. switch {
  10389. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10390. id, exists := m.ID()
  10391. if exists {
  10392. return []uint64{id}, nil
  10393. }
  10394. fallthrough
  10395. case m.op.Is(OpUpdate | OpDelete):
  10396. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  10397. default:
  10398. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10399. }
  10400. }
  10401. // SetCreatedAt sets the "created_at" field.
  10402. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  10403. m.created_at = &t
  10404. }
  10405. // CreatedAt returns the value of the "created_at" field in the mutation.
  10406. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  10407. v := m.created_at
  10408. if v == nil {
  10409. return
  10410. }
  10411. return *v, true
  10412. }
  10413. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  10414. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10415. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10416. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10417. if !m.op.Is(OpUpdateOne) {
  10418. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10419. }
  10420. if m.id == nil || m.oldValue == nil {
  10421. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10422. }
  10423. oldValue, err := m.oldValue(ctx)
  10424. if err != nil {
  10425. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10426. }
  10427. return oldValue.CreatedAt, nil
  10428. }
  10429. // ResetCreatedAt resets all changes to the "created_at" field.
  10430. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  10431. m.created_at = nil
  10432. }
  10433. // SetUpdatedAt sets the "updated_at" field.
  10434. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  10435. m.updated_at = &t
  10436. }
  10437. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10438. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  10439. v := m.updated_at
  10440. if v == nil {
  10441. return
  10442. }
  10443. return *v, true
  10444. }
  10445. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  10446. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10447. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10448. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10449. if !m.op.Is(OpUpdateOne) {
  10450. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10451. }
  10452. if m.id == nil || m.oldValue == nil {
  10453. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10454. }
  10455. oldValue, err := m.oldValue(ctx)
  10456. if err != nil {
  10457. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10458. }
  10459. return oldValue.UpdatedAt, nil
  10460. }
  10461. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10462. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  10463. m.updated_at = nil
  10464. }
  10465. // SetDeletedAt sets the "deleted_at" field.
  10466. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  10467. m.deleted_at = &t
  10468. }
  10469. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10470. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  10471. v := m.deleted_at
  10472. if v == nil {
  10473. return
  10474. }
  10475. return *v, true
  10476. }
  10477. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  10478. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10479. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10480. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10481. if !m.op.Is(OpUpdateOne) {
  10482. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10483. }
  10484. if m.id == nil || m.oldValue == nil {
  10485. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10486. }
  10487. oldValue, err := m.oldValue(ctx)
  10488. if err != nil {
  10489. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10490. }
  10491. return oldValue.DeletedAt, nil
  10492. }
  10493. // ClearDeletedAt clears the value of the "deleted_at" field.
  10494. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  10495. m.deleted_at = nil
  10496. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  10497. }
  10498. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10499. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  10500. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  10501. return ok
  10502. }
  10503. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10504. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  10505. m.deleted_at = nil
  10506. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  10507. }
  10508. // SetStype sets the "stype" field.
  10509. func (m *EmployeeConfigMutation) SetStype(s string) {
  10510. m.stype = &s
  10511. }
  10512. // Stype returns the value of the "stype" field in the mutation.
  10513. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  10514. v := m.stype
  10515. if v == nil {
  10516. return
  10517. }
  10518. return *v, true
  10519. }
  10520. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  10521. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10522. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10523. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  10524. if !m.op.Is(OpUpdateOne) {
  10525. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  10526. }
  10527. if m.id == nil || m.oldValue == nil {
  10528. return v, errors.New("OldStype requires an ID field in the mutation")
  10529. }
  10530. oldValue, err := m.oldValue(ctx)
  10531. if err != nil {
  10532. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  10533. }
  10534. return oldValue.Stype, nil
  10535. }
  10536. // ResetStype resets all changes to the "stype" field.
  10537. func (m *EmployeeConfigMutation) ResetStype() {
  10538. m.stype = nil
  10539. }
  10540. // SetTitle sets the "title" field.
  10541. func (m *EmployeeConfigMutation) SetTitle(s string) {
  10542. m.title = &s
  10543. }
  10544. // Title returns the value of the "title" field in the mutation.
  10545. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  10546. v := m.title
  10547. if v == nil {
  10548. return
  10549. }
  10550. return *v, true
  10551. }
  10552. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  10553. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10554. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10555. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  10556. if !m.op.Is(OpUpdateOne) {
  10557. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  10558. }
  10559. if m.id == nil || m.oldValue == nil {
  10560. return v, errors.New("OldTitle requires an ID field in the mutation")
  10561. }
  10562. oldValue, err := m.oldValue(ctx)
  10563. if err != nil {
  10564. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  10565. }
  10566. return oldValue.Title, nil
  10567. }
  10568. // ResetTitle resets all changes to the "title" field.
  10569. func (m *EmployeeConfigMutation) ResetTitle() {
  10570. m.title = nil
  10571. }
  10572. // SetPhoto sets the "photo" field.
  10573. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  10574. m.photo = &s
  10575. }
  10576. // Photo returns the value of the "photo" field in the mutation.
  10577. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  10578. v := m.photo
  10579. if v == nil {
  10580. return
  10581. }
  10582. return *v, true
  10583. }
  10584. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  10585. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10586. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10587. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  10588. if !m.op.Is(OpUpdateOne) {
  10589. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  10590. }
  10591. if m.id == nil || m.oldValue == nil {
  10592. return v, errors.New("OldPhoto requires an ID field in the mutation")
  10593. }
  10594. oldValue, err := m.oldValue(ctx)
  10595. if err != nil {
  10596. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  10597. }
  10598. return oldValue.Photo, nil
  10599. }
  10600. // ResetPhoto resets all changes to the "photo" field.
  10601. func (m *EmployeeConfigMutation) ResetPhoto() {
  10602. m.photo = nil
  10603. }
  10604. // SetOrganizationID sets the "organization_id" field.
  10605. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  10606. m.organization_id = &u
  10607. m.addorganization_id = nil
  10608. }
  10609. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10610. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  10611. v := m.organization_id
  10612. if v == nil {
  10613. return
  10614. }
  10615. return *v, true
  10616. }
  10617. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  10618. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10619. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10620. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10621. if !m.op.Is(OpUpdateOne) {
  10622. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10623. }
  10624. if m.id == nil || m.oldValue == nil {
  10625. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10626. }
  10627. oldValue, err := m.oldValue(ctx)
  10628. if err != nil {
  10629. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10630. }
  10631. return oldValue.OrganizationID, nil
  10632. }
  10633. // AddOrganizationID adds u to the "organization_id" field.
  10634. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  10635. if m.addorganization_id != nil {
  10636. *m.addorganization_id += u
  10637. } else {
  10638. m.addorganization_id = &u
  10639. }
  10640. }
  10641. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10642. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  10643. v := m.addorganization_id
  10644. if v == nil {
  10645. return
  10646. }
  10647. return *v, true
  10648. }
  10649. // ClearOrganizationID clears the value of the "organization_id" field.
  10650. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  10651. m.organization_id = nil
  10652. m.addorganization_id = nil
  10653. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  10654. }
  10655. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10656. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  10657. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  10658. return ok
  10659. }
  10660. // ResetOrganizationID resets all changes to the "organization_id" field.
  10661. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  10662. m.organization_id = nil
  10663. m.addorganization_id = nil
  10664. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  10665. }
  10666. // Where appends a list predicates to the EmployeeConfigMutation builder.
  10667. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  10668. m.predicates = append(m.predicates, ps...)
  10669. }
  10670. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  10671. // users can use type-assertion to append predicates that do not depend on any generated package.
  10672. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  10673. p := make([]predicate.EmployeeConfig, len(ps))
  10674. for i := range ps {
  10675. p[i] = ps[i]
  10676. }
  10677. m.Where(p...)
  10678. }
  10679. // Op returns the operation name.
  10680. func (m *EmployeeConfigMutation) Op() Op {
  10681. return m.op
  10682. }
  10683. // SetOp allows setting the mutation operation.
  10684. func (m *EmployeeConfigMutation) SetOp(op Op) {
  10685. m.op = op
  10686. }
  10687. // Type returns the node type of this mutation (EmployeeConfig).
  10688. func (m *EmployeeConfigMutation) Type() string {
  10689. return m.typ
  10690. }
  10691. // Fields returns all fields that were changed during this mutation. Note that in
  10692. // order to get all numeric fields that were incremented/decremented, call
  10693. // AddedFields().
  10694. func (m *EmployeeConfigMutation) Fields() []string {
  10695. fields := make([]string, 0, 7)
  10696. if m.created_at != nil {
  10697. fields = append(fields, employeeconfig.FieldCreatedAt)
  10698. }
  10699. if m.updated_at != nil {
  10700. fields = append(fields, employeeconfig.FieldUpdatedAt)
  10701. }
  10702. if m.deleted_at != nil {
  10703. fields = append(fields, employeeconfig.FieldDeletedAt)
  10704. }
  10705. if m.stype != nil {
  10706. fields = append(fields, employeeconfig.FieldStype)
  10707. }
  10708. if m.title != nil {
  10709. fields = append(fields, employeeconfig.FieldTitle)
  10710. }
  10711. if m.photo != nil {
  10712. fields = append(fields, employeeconfig.FieldPhoto)
  10713. }
  10714. if m.organization_id != nil {
  10715. fields = append(fields, employeeconfig.FieldOrganizationID)
  10716. }
  10717. return fields
  10718. }
  10719. // Field returns the value of a field with the given name. The second boolean
  10720. // return value indicates that this field was not set, or was not defined in the
  10721. // schema.
  10722. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  10723. switch name {
  10724. case employeeconfig.FieldCreatedAt:
  10725. return m.CreatedAt()
  10726. case employeeconfig.FieldUpdatedAt:
  10727. return m.UpdatedAt()
  10728. case employeeconfig.FieldDeletedAt:
  10729. return m.DeletedAt()
  10730. case employeeconfig.FieldStype:
  10731. return m.Stype()
  10732. case employeeconfig.FieldTitle:
  10733. return m.Title()
  10734. case employeeconfig.FieldPhoto:
  10735. return m.Photo()
  10736. case employeeconfig.FieldOrganizationID:
  10737. return m.OrganizationID()
  10738. }
  10739. return nil, false
  10740. }
  10741. // OldField returns the old value of the field from the database. An error is
  10742. // returned if the mutation operation is not UpdateOne, or the query to the
  10743. // database failed.
  10744. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10745. switch name {
  10746. case employeeconfig.FieldCreatedAt:
  10747. return m.OldCreatedAt(ctx)
  10748. case employeeconfig.FieldUpdatedAt:
  10749. return m.OldUpdatedAt(ctx)
  10750. case employeeconfig.FieldDeletedAt:
  10751. return m.OldDeletedAt(ctx)
  10752. case employeeconfig.FieldStype:
  10753. return m.OldStype(ctx)
  10754. case employeeconfig.FieldTitle:
  10755. return m.OldTitle(ctx)
  10756. case employeeconfig.FieldPhoto:
  10757. return m.OldPhoto(ctx)
  10758. case employeeconfig.FieldOrganizationID:
  10759. return m.OldOrganizationID(ctx)
  10760. }
  10761. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  10762. }
  10763. // SetField sets the value of a field with the given name. It returns an error if
  10764. // the field is not defined in the schema, or if the type mismatched the field
  10765. // type.
  10766. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  10767. switch name {
  10768. case employeeconfig.FieldCreatedAt:
  10769. v, ok := value.(time.Time)
  10770. if !ok {
  10771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10772. }
  10773. m.SetCreatedAt(v)
  10774. return nil
  10775. case employeeconfig.FieldUpdatedAt:
  10776. v, ok := value.(time.Time)
  10777. if !ok {
  10778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10779. }
  10780. m.SetUpdatedAt(v)
  10781. return nil
  10782. case employeeconfig.FieldDeletedAt:
  10783. v, ok := value.(time.Time)
  10784. if !ok {
  10785. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10786. }
  10787. m.SetDeletedAt(v)
  10788. return nil
  10789. case employeeconfig.FieldStype:
  10790. v, ok := value.(string)
  10791. if !ok {
  10792. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10793. }
  10794. m.SetStype(v)
  10795. return nil
  10796. case employeeconfig.FieldTitle:
  10797. v, ok := value.(string)
  10798. if !ok {
  10799. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10800. }
  10801. m.SetTitle(v)
  10802. return nil
  10803. case employeeconfig.FieldPhoto:
  10804. v, ok := value.(string)
  10805. if !ok {
  10806. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10807. }
  10808. m.SetPhoto(v)
  10809. return nil
  10810. case employeeconfig.FieldOrganizationID:
  10811. v, ok := value.(uint64)
  10812. if !ok {
  10813. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10814. }
  10815. m.SetOrganizationID(v)
  10816. return nil
  10817. }
  10818. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  10819. }
  10820. // AddedFields returns all numeric fields that were incremented/decremented during
  10821. // this mutation.
  10822. func (m *EmployeeConfigMutation) AddedFields() []string {
  10823. var fields []string
  10824. if m.addorganization_id != nil {
  10825. fields = append(fields, employeeconfig.FieldOrganizationID)
  10826. }
  10827. return fields
  10828. }
  10829. // AddedField returns the numeric value that was incremented/decremented on a field
  10830. // with the given name. The second boolean return value indicates that this field
  10831. // was not set, or was not defined in the schema.
  10832. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  10833. switch name {
  10834. case employeeconfig.FieldOrganizationID:
  10835. return m.AddedOrganizationID()
  10836. }
  10837. return nil, false
  10838. }
  10839. // AddField adds the value to the field with the given name. It returns an error if
  10840. // the field is not defined in the schema, or if the type mismatched the field
  10841. // type.
  10842. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  10843. switch name {
  10844. case employeeconfig.FieldOrganizationID:
  10845. v, ok := value.(int64)
  10846. if !ok {
  10847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10848. }
  10849. m.AddOrganizationID(v)
  10850. return nil
  10851. }
  10852. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  10853. }
  10854. // ClearedFields returns all nullable fields that were cleared during this
  10855. // mutation.
  10856. func (m *EmployeeConfigMutation) ClearedFields() []string {
  10857. var fields []string
  10858. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  10859. fields = append(fields, employeeconfig.FieldDeletedAt)
  10860. }
  10861. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  10862. fields = append(fields, employeeconfig.FieldOrganizationID)
  10863. }
  10864. return fields
  10865. }
  10866. // FieldCleared returns a boolean indicating if a field with the given name was
  10867. // cleared in this mutation.
  10868. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  10869. _, ok := m.clearedFields[name]
  10870. return ok
  10871. }
  10872. // ClearField clears the value of the field with the given name. It returns an
  10873. // error if the field is not defined in the schema.
  10874. func (m *EmployeeConfigMutation) ClearField(name string) error {
  10875. switch name {
  10876. case employeeconfig.FieldDeletedAt:
  10877. m.ClearDeletedAt()
  10878. return nil
  10879. case employeeconfig.FieldOrganizationID:
  10880. m.ClearOrganizationID()
  10881. return nil
  10882. }
  10883. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  10884. }
  10885. // ResetField resets all changes in the mutation for the field with the given name.
  10886. // It returns an error if the field is not defined in the schema.
  10887. func (m *EmployeeConfigMutation) ResetField(name string) error {
  10888. switch name {
  10889. case employeeconfig.FieldCreatedAt:
  10890. m.ResetCreatedAt()
  10891. return nil
  10892. case employeeconfig.FieldUpdatedAt:
  10893. m.ResetUpdatedAt()
  10894. return nil
  10895. case employeeconfig.FieldDeletedAt:
  10896. m.ResetDeletedAt()
  10897. return nil
  10898. case employeeconfig.FieldStype:
  10899. m.ResetStype()
  10900. return nil
  10901. case employeeconfig.FieldTitle:
  10902. m.ResetTitle()
  10903. return nil
  10904. case employeeconfig.FieldPhoto:
  10905. m.ResetPhoto()
  10906. return nil
  10907. case employeeconfig.FieldOrganizationID:
  10908. m.ResetOrganizationID()
  10909. return nil
  10910. }
  10911. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  10912. }
  10913. // AddedEdges returns all edge names that were set/added in this mutation.
  10914. func (m *EmployeeConfigMutation) AddedEdges() []string {
  10915. edges := make([]string, 0, 0)
  10916. return edges
  10917. }
  10918. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10919. // name in this mutation.
  10920. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  10921. return nil
  10922. }
  10923. // RemovedEdges returns all edge names that were removed in this mutation.
  10924. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  10925. edges := make([]string, 0, 0)
  10926. return edges
  10927. }
  10928. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10929. // the given name in this mutation.
  10930. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  10931. return nil
  10932. }
  10933. // ClearedEdges returns all edge names that were cleared in this mutation.
  10934. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  10935. edges := make([]string, 0, 0)
  10936. return edges
  10937. }
  10938. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10939. // was cleared in this mutation.
  10940. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  10941. return false
  10942. }
  10943. // ClearEdge clears the value of the edge with the given name. It returns an error
  10944. // if that edge is not defined in the schema.
  10945. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  10946. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  10947. }
  10948. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10949. // It returns an error if the edge is not defined in the schema.
  10950. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  10951. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  10952. }
  10953. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  10954. type LabelMutation struct {
  10955. config
  10956. op Op
  10957. typ string
  10958. id *uint64
  10959. created_at *time.Time
  10960. updated_at *time.Time
  10961. status *uint8
  10962. addstatus *int8
  10963. _type *int
  10964. add_type *int
  10965. name *string
  10966. from *int
  10967. addfrom *int
  10968. mode *int
  10969. addmode *int
  10970. conditions *string
  10971. organization_id *uint64
  10972. addorganization_id *int64
  10973. clearedFields map[string]struct{}
  10974. label_relationships map[uint64]struct{}
  10975. removedlabel_relationships map[uint64]struct{}
  10976. clearedlabel_relationships bool
  10977. done bool
  10978. oldValue func(context.Context) (*Label, error)
  10979. predicates []predicate.Label
  10980. }
  10981. var _ ent.Mutation = (*LabelMutation)(nil)
  10982. // labelOption allows management of the mutation configuration using functional options.
  10983. type labelOption func(*LabelMutation)
  10984. // newLabelMutation creates new mutation for the Label entity.
  10985. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  10986. m := &LabelMutation{
  10987. config: c,
  10988. op: op,
  10989. typ: TypeLabel,
  10990. clearedFields: make(map[string]struct{}),
  10991. }
  10992. for _, opt := range opts {
  10993. opt(m)
  10994. }
  10995. return m
  10996. }
  10997. // withLabelID sets the ID field of the mutation.
  10998. func withLabelID(id uint64) labelOption {
  10999. return func(m *LabelMutation) {
  11000. var (
  11001. err error
  11002. once sync.Once
  11003. value *Label
  11004. )
  11005. m.oldValue = func(ctx context.Context) (*Label, error) {
  11006. once.Do(func() {
  11007. if m.done {
  11008. err = errors.New("querying old values post mutation is not allowed")
  11009. } else {
  11010. value, err = m.Client().Label.Get(ctx, id)
  11011. }
  11012. })
  11013. return value, err
  11014. }
  11015. m.id = &id
  11016. }
  11017. }
  11018. // withLabel sets the old Label of the mutation.
  11019. func withLabel(node *Label) labelOption {
  11020. return func(m *LabelMutation) {
  11021. m.oldValue = func(context.Context) (*Label, error) {
  11022. return node, nil
  11023. }
  11024. m.id = &node.ID
  11025. }
  11026. }
  11027. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11028. // executed in a transaction (ent.Tx), a transactional client is returned.
  11029. func (m LabelMutation) Client() *Client {
  11030. client := &Client{config: m.config}
  11031. client.init()
  11032. return client
  11033. }
  11034. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11035. // it returns an error otherwise.
  11036. func (m LabelMutation) Tx() (*Tx, error) {
  11037. if _, ok := m.driver.(*txDriver); !ok {
  11038. return nil, errors.New("ent: mutation is not running in a transaction")
  11039. }
  11040. tx := &Tx{config: m.config}
  11041. tx.init()
  11042. return tx, nil
  11043. }
  11044. // SetID sets the value of the id field. Note that this
  11045. // operation is only accepted on creation of Label entities.
  11046. func (m *LabelMutation) SetID(id uint64) {
  11047. m.id = &id
  11048. }
  11049. // ID returns the ID value in the mutation. Note that the ID is only available
  11050. // if it was provided to the builder or after it was returned from the database.
  11051. func (m *LabelMutation) ID() (id uint64, exists bool) {
  11052. if m.id == nil {
  11053. return
  11054. }
  11055. return *m.id, true
  11056. }
  11057. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11058. // That means, if the mutation is applied within a transaction with an isolation level such
  11059. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11060. // or updated by the mutation.
  11061. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  11062. switch {
  11063. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11064. id, exists := m.ID()
  11065. if exists {
  11066. return []uint64{id}, nil
  11067. }
  11068. fallthrough
  11069. case m.op.Is(OpUpdate | OpDelete):
  11070. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  11071. default:
  11072. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11073. }
  11074. }
  11075. // SetCreatedAt sets the "created_at" field.
  11076. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  11077. m.created_at = &t
  11078. }
  11079. // CreatedAt returns the value of the "created_at" field in the mutation.
  11080. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  11081. v := m.created_at
  11082. if v == nil {
  11083. return
  11084. }
  11085. return *v, true
  11086. }
  11087. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  11088. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11089. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11090. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11091. if !m.op.Is(OpUpdateOne) {
  11092. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11093. }
  11094. if m.id == nil || m.oldValue == nil {
  11095. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11096. }
  11097. oldValue, err := m.oldValue(ctx)
  11098. if err != nil {
  11099. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11100. }
  11101. return oldValue.CreatedAt, nil
  11102. }
  11103. // ResetCreatedAt resets all changes to the "created_at" field.
  11104. func (m *LabelMutation) ResetCreatedAt() {
  11105. m.created_at = nil
  11106. }
  11107. // SetUpdatedAt sets the "updated_at" field.
  11108. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  11109. m.updated_at = &t
  11110. }
  11111. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11112. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  11113. v := m.updated_at
  11114. if v == nil {
  11115. return
  11116. }
  11117. return *v, true
  11118. }
  11119. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  11120. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11121. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11122. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11123. if !m.op.Is(OpUpdateOne) {
  11124. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11125. }
  11126. if m.id == nil || m.oldValue == nil {
  11127. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11128. }
  11129. oldValue, err := m.oldValue(ctx)
  11130. if err != nil {
  11131. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11132. }
  11133. return oldValue.UpdatedAt, nil
  11134. }
  11135. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11136. func (m *LabelMutation) ResetUpdatedAt() {
  11137. m.updated_at = nil
  11138. }
  11139. // SetStatus sets the "status" field.
  11140. func (m *LabelMutation) SetStatus(u uint8) {
  11141. m.status = &u
  11142. m.addstatus = nil
  11143. }
  11144. // Status returns the value of the "status" field in the mutation.
  11145. func (m *LabelMutation) Status() (r uint8, exists bool) {
  11146. v := m.status
  11147. if v == nil {
  11148. return
  11149. }
  11150. return *v, true
  11151. }
  11152. // OldStatus returns the old "status" field's value of the Label entity.
  11153. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11155. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11156. if !m.op.Is(OpUpdateOne) {
  11157. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11158. }
  11159. if m.id == nil || m.oldValue == nil {
  11160. return v, errors.New("OldStatus requires an ID field in the mutation")
  11161. }
  11162. oldValue, err := m.oldValue(ctx)
  11163. if err != nil {
  11164. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11165. }
  11166. return oldValue.Status, nil
  11167. }
  11168. // AddStatus adds u to the "status" field.
  11169. func (m *LabelMutation) AddStatus(u int8) {
  11170. if m.addstatus != nil {
  11171. *m.addstatus += u
  11172. } else {
  11173. m.addstatus = &u
  11174. }
  11175. }
  11176. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11177. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  11178. v := m.addstatus
  11179. if v == nil {
  11180. return
  11181. }
  11182. return *v, true
  11183. }
  11184. // ClearStatus clears the value of the "status" field.
  11185. func (m *LabelMutation) ClearStatus() {
  11186. m.status = nil
  11187. m.addstatus = nil
  11188. m.clearedFields[label.FieldStatus] = struct{}{}
  11189. }
  11190. // StatusCleared returns if the "status" field was cleared in this mutation.
  11191. func (m *LabelMutation) StatusCleared() bool {
  11192. _, ok := m.clearedFields[label.FieldStatus]
  11193. return ok
  11194. }
  11195. // ResetStatus resets all changes to the "status" field.
  11196. func (m *LabelMutation) ResetStatus() {
  11197. m.status = nil
  11198. m.addstatus = nil
  11199. delete(m.clearedFields, label.FieldStatus)
  11200. }
  11201. // SetType sets the "type" field.
  11202. func (m *LabelMutation) SetType(i int) {
  11203. m._type = &i
  11204. m.add_type = nil
  11205. }
  11206. // GetType returns the value of the "type" field in the mutation.
  11207. func (m *LabelMutation) GetType() (r int, exists bool) {
  11208. v := m._type
  11209. if v == nil {
  11210. return
  11211. }
  11212. return *v, true
  11213. }
  11214. // OldType returns the old "type" field's value of the Label entity.
  11215. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11216. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11217. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  11218. if !m.op.Is(OpUpdateOne) {
  11219. return v, errors.New("OldType is only allowed on UpdateOne operations")
  11220. }
  11221. if m.id == nil || m.oldValue == nil {
  11222. return v, errors.New("OldType requires an ID field in the mutation")
  11223. }
  11224. oldValue, err := m.oldValue(ctx)
  11225. if err != nil {
  11226. return v, fmt.Errorf("querying old value for OldType: %w", err)
  11227. }
  11228. return oldValue.Type, nil
  11229. }
  11230. // AddType adds i to the "type" field.
  11231. func (m *LabelMutation) AddType(i int) {
  11232. if m.add_type != nil {
  11233. *m.add_type += i
  11234. } else {
  11235. m.add_type = &i
  11236. }
  11237. }
  11238. // AddedType returns the value that was added to the "type" field in this mutation.
  11239. func (m *LabelMutation) AddedType() (r int, exists bool) {
  11240. v := m.add_type
  11241. if v == nil {
  11242. return
  11243. }
  11244. return *v, true
  11245. }
  11246. // ResetType resets all changes to the "type" field.
  11247. func (m *LabelMutation) ResetType() {
  11248. m._type = nil
  11249. m.add_type = nil
  11250. }
  11251. // SetName sets the "name" field.
  11252. func (m *LabelMutation) SetName(s string) {
  11253. m.name = &s
  11254. }
  11255. // Name returns the value of the "name" field in the mutation.
  11256. func (m *LabelMutation) Name() (r string, exists bool) {
  11257. v := m.name
  11258. if v == nil {
  11259. return
  11260. }
  11261. return *v, true
  11262. }
  11263. // OldName returns the old "name" field's value of the Label entity.
  11264. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11266. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  11267. if !m.op.Is(OpUpdateOne) {
  11268. return v, errors.New("OldName is only allowed on UpdateOne operations")
  11269. }
  11270. if m.id == nil || m.oldValue == nil {
  11271. return v, errors.New("OldName requires an ID field in the mutation")
  11272. }
  11273. oldValue, err := m.oldValue(ctx)
  11274. if err != nil {
  11275. return v, fmt.Errorf("querying old value for OldName: %w", err)
  11276. }
  11277. return oldValue.Name, nil
  11278. }
  11279. // ResetName resets all changes to the "name" field.
  11280. func (m *LabelMutation) ResetName() {
  11281. m.name = nil
  11282. }
  11283. // SetFrom sets the "from" field.
  11284. func (m *LabelMutation) SetFrom(i int) {
  11285. m.from = &i
  11286. m.addfrom = nil
  11287. }
  11288. // From returns the value of the "from" field in the mutation.
  11289. func (m *LabelMutation) From() (r int, exists bool) {
  11290. v := m.from
  11291. if v == nil {
  11292. return
  11293. }
  11294. return *v, true
  11295. }
  11296. // OldFrom returns the old "from" field's value of the Label entity.
  11297. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11298. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11299. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  11300. if !m.op.Is(OpUpdateOne) {
  11301. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  11302. }
  11303. if m.id == nil || m.oldValue == nil {
  11304. return v, errors.New("OldFrom requires an ID field in the mutation")
  11305. }
  11306. oldValue, err := m.oldValue(ctx)
  11307. if err != nil {
  11308. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  11309. }
  11310. return oldValue.From, nil
  11311. }
  11312. // AddFrom adds i to the "from" field.
  11313. func (m *LabelMutation) AddFrom(i int) {
  11314. if m.addfrom != nil {
  11315. *m.addfrom += i
  11316. } else {
  11317. m.addfrom = &i
  11318. }
  11319. }
  11320. // AddedFrom returns the value that was added to the "from" field in this mutation.
  11321. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  11322. v := m.addfrom
  11323. if v == nil {
  11324. return
  11325. }
  11326. return *v, true
  11327. }
  11328. // ResetFrom resets all changes to the "from" field.
  11329. func (m *LabelMutation) ResetFrom() {
  11330. m.from = nil
  11331. m.addfrom = nil
  11332. }
  11333. // SetMode sets the "mode" field.
  11334. func (m *LabelMutation) SetMode(i int) {
  11335. m.mode = &i
  11336. m.addmode = nil
  11337. }
  11338. // Mode returns the value of the "mode" field in the mutation.
  11339. func (m *LabelMutation) Mode() (r int, exists bool) {
  11340. v := m.mode
  11341. if v == nil {
  11342. return
  11343. }
  11344. return *v, true
  11345. }
  11346. // OldMode returns the old "mode" field's value of the Label entity.
  11347. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11348. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11349. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  11350. if !m.op.Is(OpUpdateOne) {
  11351. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  11352. }
  11353. if m.id == nil || m.oldValue == nil {
  11354. return v, errors.New("OldMode requires an ID field in the mutation")
  11355. }
  11356. oldValue, err := m.oldValue(ctx)
  11357. if err != nil {
  11358. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  11359. }
  11360. return oldValue.Mode, nil
  11361. }
  11362. // AddMode adds i to the "mode" field.
  11363. func (m *LabelMutation) AddMode(i int) {
  11364. if m.addmode != nil {
  11365. *m.addmode += i
  11366. } else {
  11367. m.addmode = &i
  11368. }
  11369. }
  11370. // AddedMode returns the value that was added to the "mode" field in this mutation.
  11371. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  11372. v := m.addmode
  11373. if v == nil {
  11374. return
  11375. }
  11376. return *v, true
  11377. }
  11378. // ResetMode resets all changes to the "mode" field.
  11379. func (m *LabelMutation) ResetMode() {
  11380. m.mode = nil
  11381. m.addmode = nil
  11382. }
  11383. // SetConditions sets the "conditions" field.
  11384. func (m *LabelMutation) SetConditions(s string) {
  11385. m.conditions = &s
  11386. }
  11387. // Conditions returns the value of the "conditions" field in the mutation.
  11388. func (m *LabelMutation) Conditions() (r string, exists bool) {
  11389. v := m.conditions
  11390. if v == nil {
  11391. return
  11392. }
  11393. return *v, true
  11394. }
  11395. // OldConditions returns the old "conditions" field's value of the Label entity.
  11396. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11397. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11398. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  11399. if !m.op.Is(OpUpdateOne) {
  11400. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  11401. }
  11402. if m.id == nil || m.oldValue == nil {
  11403. return v, errors.New("OldConditions requires an ID field in the mutation")
  11404. }
  11405. oldValue, err := m.oldValue(ctx)
  11406. if err != nil {
  11407. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  11408. }
  11409. return oldValue.Conditions, nil
  11410. }
  11411. // ClearConditions clears the value of the "conditions" field.
  11412. func (m *LabelMutation) ClearConditions() {
  11413. m.conditions = nil
  11414. m.clearedFields[label.FieldConditions] = struct{}{}
  11415. }
  11416. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  11417. func (m *LabelMutation) ConditionsCleared() bool {
  11418. _, ok := m.clearedFields[label.FieldConditions]
  11419. return ok
  11420. }
  11421. // ResetConditions resets all changes to the "conditions" field.
  11422. func (m *LabelMutation) ResetConditions() {
  11423. m.conditions = nil
  11424. delete(m.clearedFields, label.FieldConditions)
  11425. }
  11426. // SetOrganizationID sets the "organization_id" field.
  11427. func (m *LabelMutation) SetOrganizationID(u uint64) {
  11428. m.organization_id = &u
  11429. m.addorganization_id = nil
  11430. }
  11431. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11432. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  11433. v := m.organization_id
  11434. if v == nil {
  11435. return
  11436. }
  11437. return *v, true
  11438. }
  11439. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  11440. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11442. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11443. if !m.op.Is(OpUpdateOne) {
  11444. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11445. }
  11446. if m.id == nil || m.oldValue == nil {
  11447. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11448. }
  11449. oldValue, err := m.oldValue(ctx)
  11450. if err != nil {
  11451. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11452. }
  11453. return oldValue.OrganizationID, nil
  11454. }
  11455. // AddOrganizationID adds u to the "organization_id" field.
  11456. func (m *LabelMutation) AddOrganizationID(u int64) {
  11457. if m.addorganization_id != nil {
  11458. *m.addorganization_id += u
  11459. } else {
  11460. m.addorganization_id = &u
  11461. }
  11462. }
  11463. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11464. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  11465. v := m.addorganization_id
  11466. if v == nil {
  11467. return
  11468. }
  11469. return *v, true
  11470. }
  11471. // ClearOrganizationID clears the value of the "organization_id" field.
  11472. func (m *LabelMutation) ClearOrganizationID() {
  11473. m.organization_id = nil
  11474. m.addorganization_id = nil
  11475. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  11476. }
  11477. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11478. func (m *LabelMutation) OrganizationIDCleared() bool {
  11479. _, ok := m.clearedFields[label.FieldOrganizationID]
  11480. return ok
  11481. }
  11482. // ResetOrganizationID resets all changes to the "organization_id" field.
  11483. func (m *LabelMutation) ResetOrganizationID() {
  11484. m.organization_id = nil
  11485. m.addorganization_id = nil
  11486. delete(m.clearedFields, label.FieldOrganizationID)
  11487. }
  11488. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  11489. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  11490. if m.label_relationships == nil {
  11491. m.label_relationships = make(map[uint64]struct{})
  11492. }
  11493. for i := range ids {
  11494. m.label_relationships[ids[i]] = struct{}{}
  11495. }
  11496. }
  11497. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  11498. func (m *LabelMutation) ClearLabelRelationships() {
  11499. m.clearedlabel_relationships = true
  11500. }
  11501. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  11502. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  11503. return m.clearedlabel_relationships
  11504. }
  11505. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  11506. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  11507. if m.removedlabel_relationships == nil {
  11508. m.removedlabel_relationships = make(map[uint64]struct{})
  11509. }
  11510. for i := range ids {
  11511. delete(m.label_relationships, ids[i])
  11512. m.removedlabel_relationships[ids[i]] = struct{}{}
  11513. }
  11514. }
  11515. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  11516. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  11517. for id := range m.removedlabel_relationships {
  11518. ids = append(ids, id)
  11519. }
  11520. return
  11521. }
  11522. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  11523. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  11524. for id := range m.label_relationships {
  11525. ids = append(ids, id)
  11526. }
  11527. return
  11528. }
  11529. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  11530. func (m *LabelMutation) ResetLabelRelationships() {
  11531. m.label_relationships = nil
  11532. m.clearedlabel_relationships = false
  11533. m.removedlabel_relationships = nil
  11534. }
  11535. // Where appends a list predicates to the LabelMutation builder.
  11536. func (m *LabelMutation) Where(ps ...predicate.Label) {
  11537. m.predicates = append(m.predicates, ps...)
  11538. }
  11539. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  11540. // users can use type-assertion to append predicates that do not depend on any generated package.
  11541. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  11542. p := make([]predicate.Label, len(ps))
  11543. for i := range ps {
  11544. p[i] = ps[i]
  11545. }
  11546. m.Where(p...)
  11547. }
  11548. // Op returns the operation name.
  11549. func (m *LabelMutation) Op() Op {
  11550. return m.op
  11551. }
  11552. // SetOp allows setting the mutation operation.
  11553. func (m *LabelMutation) SetOp(op Op) {
  11554. m.op = op
  11555. }
  11556. // Type returns the node type of this mutation (Label).
  11557. func (m *LabelMutation) Type() string {
  11558. return m.typ
  11559. }
  11560. // Fields returns all fields that were changed during this mutation. Note that in
  11561. // order to get all numeric fields that were incremented/decremented, call
  11562. // AddedFields().
  11563. func (m *LabelMutation) Fields() []string {
  11564. fields := make([]string, 0, 9)
  11565. if m.created_at != nil {
  11566. fields = append(fields, label.FieldCreatedAt)
  11567. }
  11568. if m.updated_at != nil {
  11569. fields = append(fields, label.FieldUpdatedAt)
  11570. }
  11571. if m.status != nil {
  11572. fields = append(fields, label.FieldStatus)
  11573. }
  11574. if m._type != nil {
  11575. fields = append(fields, label.FieldType)
  11576. }
  11577. if m.name != nil {
  11578. fields = append(fields, label.FieldName)
  11579. }
  11580. if m.from != nil {
  11581. fields = append(fields, label.FieldFrom)
  11582. }
  11583. if m.mode != nil {
  11584. fields = append(fields, label.FieldMode)
  11585. }
  11586. if m.conditions != nil {
  11587. fields = append(fields, label.FieldConditions)
  11588. }
  11589. if m.organization_id != nil {
  11590. fields = append(fields, label.FieldOrganizationID)
  11591. }
  11592. return fields
  11593. }
  11594. // Field returns the value of a field with the given name. The second boolean
  11595. // return value indicates that this field was not set, or was not defined in the
  11596. // schema.
  11597. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  11598. switch name {
  11599. case label.FieldCreatedAt:
  11600. return m.CreatedAt()
  11601. case label.FieldUpdatedAt:
  11602. return m.UpdatedAt()
  11603. case label.FieldStatus:
  11604. return m.Status()
  11605. case label.FieldType:
  11606. return m.GetType()
  11607. case label.FieldName:
  11608. return m.Name()
  11609. case label.FieldFrom:
  11610. return m.From()
  11611. case label.FieldMode:
  11612. return m.Mode()
  11613. case label.FieldConditions:
  11614. return m.Conditions()
  11615. case label.FieldOrganizationID:
  11616. return m.OrganizationID()
  11617. }
  11618. return nil, false
  11619. }
  11620. // OldField returns the old value of the field from the database. An error is
  11621. // returned if the mutation operation is not UpdateOne, or the query to the
  11622. // database failed.
  11623. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11624. switch name {
  11625. case label.FieldCreatedAt:
  11626. return m.OldCreatedAt(ctx)
  11627. case label.FieldUpdatedAt:
  11628. return m.OldUpdatedAt(ctx)
  11629. case label.FieldStatus:
  11630. return m.OldStatus(ctx)
  11631. case label.FieldType:
  11632. return m.OldType(ctx)
  11633. case label.FieldName:
  11634. return m.OldName(ctx)
  11635. case label.FieldFrom:
  11636. return m.OldFrom(ctx)
  11637. case label.FieldMode:
  11638. return m.OldMode(ctx)
  11639. case label.FieldConditions:
  11640. return m.OldConditions(ctx)
  11641. case label.FieldOrganizationID:
  11642. return m.OldOrganizationID(ctx)
  11643. }
  11644. return nil, fmt.Errorf("unknown Label field %s", name)
  11645. }
  11646. // SetField sets the value of a field with the given name. It returns an error if
  11647. // the field is not defined in the schema, or if the type mismatched the field
  11648. // type.
  11649. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  11650. switch name {
  11651. case label.FieldCreatedAt:
  11652. v, ok := value.(time.Time)
  11653. if !ok {
  11654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11655. }
  11656. m.SetCreatedAt(v)
  11657. return nil
  11658. case label.FieldUpdatedAt:
  11659. v, ok := value.(time.Time)
  11660. if !ok {
  11661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11662. }
  11663. m.SetUpdatedAt(v)
  11664. return nil
  11665. case label.FieldStatus:
  11666. v, ok := value.(uint8)
  11667. if !ok {
  11668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11669. }
  11670. m.SetStatus(v)
  11671. return nil
  11672. case label.FieldType:
  11673. v, ok := value.(int)
  11674. if !ok {
  11675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11676. }
  11677. m.SetType(v)
  11678. return nil
  11679. case label.FieldName:
  11680. v, ok := value.(string)
  11681. if !ok {
  11682. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11683. }
  11684. m.SetName(v)
  11685. return nil
  11686. case label.FieldFrom:
  11687. v, ok := value.(int)
  11688. if !ok {
  11689. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11690. }
  11691. m.SetFrom(v)
  11692. return nil
  11693. case label.FieldMode:
  11694. v, ok := value.(int)
  11695. if !ok {
  11696. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11697. }
  11698. m.SetMode(v)
  11699. return nil
  11700. case label.FieldConditions:
  11701. v, ok := value.(string)
  11702. if !ok {
  11703. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11704. }
  11705. m.SetConditions(v)
  11706. return nil
  11707. case label.FieldOrganizationID:
  11708. v, ok := value.(uint64)
  11709. if !ok {
  11710. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11711. }
  11712. m.SetOrganizationID(v)
  11713. return nil
  11714. }
  11715. return fmt.Errorf("unknown Label field %s", name)
  11716. }
  11717. // AddedFields returns all numeric fields that were incremented/decremented during
  11718. // this mutation.
  11719. func (m *LabelMutation) AddedFields() []string {
  11720. var fields []string
  11721. if m.addstatus != nil {
  11722. fields = append(fields, label.FieldStatus)
  11723. }
  11724. if m.add_type != nil {
  11725. fields = append(fields, label.FieldType)
  11726. }
  11727. if m.addfrom != nil {
  11728. fields = append(fields, label.FieldFrom)
  11729. }
  11730. if m.addmode != nil {
  11731. fields = append(fields, label.FieldMode)
  11732. }
  11733. if m.addorganization_id != nil {
  11734. fields = append(fields, label.FieldOrganizationID)
  11735. }
  11736. return fields
  11737. }
  11738. // AddedField returns the numeric value that was incremented/decremented on a field
  11739. // with the given name. The second boolean return value indicates that this field
  11740. // was not set, or was not defined in the schema.
  11741. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  11742. switch name {
  11743. case label.FieldStatus:
  11744. return m.AddedStatus()
  11745. case label.FieldType:
  11746. return m.AddedType()
  11747. case label.FieldFrom:
  11748. return m.AddedFrom()
  11749. case label.FieldMode:
  11750. return m.AddedMode()
  11751. case label.FieldOrganizationID:
  11752. return m.AddedOrganizationID()
  11753. }
  11754. return nil, false
  11755. }
  11756. // AddField adds the value to the field with the given name. It returns an error if
  11757. // the field is not defined in the schema, or if the type mismatched the field
  11758. // type.
  11759. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  11760. switch name {
  11761. case label.FieldStatus:
  11762. v, ok := value.(int8)
  11763. if !ok {
  11764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11765. }
  11766. m.AddStatus(v)
  11767. return nil
  11768. case label.FieldType:
  11769. v, ok := value.(int)
  11770. if !ok {
  11771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11772. }
  11773. m.AddType(v)
  11774. return nil
  11775. case label.FieldFrom:
  11776. v, ok := value.(int)
  11777. if !ok {
  11778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11779. }
  11780. m.AddFrom(v)
  11781. return nil
  11782. case label.FieldMode:
  11783. v, ok := value.(int)
  11784. if !ok {
  11785. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11786. }
  11787. m.AddMode(v)
  11788. return nil
  11789. case label.FieldOrganizationID:
  11790. v, ok := value.(int64)
  11791. if !ok {
  11792. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11793. }
  11794. m.AddOrganizationID(v)
  11795. return nil
  11796. }
  11797. return fmt.Errorf("unknown Label numeric field %s", name)
  11798. }
  11799. // ClearedFields returns all nullable fields that were cleared during this
  11800. // mutation.
  11801. func (m *LabelMutation) ClearedFields() []string {
  11802. var fields []string
  11803. if m.FieldCleared(label.FieldStatus) {
  11804. fields = append(fields, label.FieldStatus)
  11805. }
  11806. if m.FieldCleared(label.FieldConditions) {
  11807. fields = append(fields, label.FieldConditions)
  11808. }
  11809. if m.FieldCleared(label.FieldOrganizationID) {
  11810. fields = append(fields, label.FieldOrganizationID)
  11811. }
  11812. return fields
  11813. }
  11814. // FieldCleared returns a boolean indicating if a field with the given name was
  11815. // cleared in this mutation.
  11816. func (m *LabelMutation) FieldCleared(name string) bool {
  11817. _, ok := m.clearedFields[name]
  11818. return ok
  11819. }
  11820. // ClearField clears the value of the field with the given name. It returns an
  11821. // error if the field is not defined in the schema.
  11822. func (m *LabelMutation) ClearField(name string) error {
  11823. switch name {
  11824. case label.FieldStatus:
  11825. m.ClearStatus()
  11826. return nil
  11827. case label.FieldConditions:
  11828. m.ClearConditions()
  11829. return nil
  11830. case label.FieldOrganizationID:
  11831. m.ClearOrganizationID()
  11832. return nil
  11833. }
  11834. return fmt.Errorf("unknown Label nullable field %s", name)
  11835. }
  11836. // ResetField resets all changes in the mutation for the field with the given name.
  11837. // It returns an error if the field is not defined in the schema.
  11838. func (m *LabelMutation) ResetField(name string) error {
  11839. switch name {
  11840. case label.FieldCreatedAt:
  11841. m.ResetCreatedAt()
  11842. return nil
  11843. case label.FieldUpdatedAt:
  11844. m.ResetUpdatedAt()
  11845. return nil
  11846. case label.FieldStatus:
  11847. m.ResetStatus()
  11848. return nil
  11849. case label.FieldType:
  11850. m.ResetType()
  11851. return nil
  11852. case label.FieldName:
  11853. m.ResetName()
  11854. return nil
  11855. case label.FieldFrom:
  11856. m.ResetFrom()
  11857. return nil
  11858. case label.FieldMode:
  11859. m.ResetMode()
  11860. return nil
  11861. case label.FieldConditions:
  11862. m.ResetConditions()
  11863. return nil
  11864. case label.FieldOrganizationID:
  11865. m.ResetOrganizationID()
  11866. return nil
  11867. }
  11868. return fmt.Errorf("unknown Label field %s", name)
  11869. }
  11870. // AddedEdges returns all edge names that were set/added in this mutation.
  11871. func (m *LabelMutation) AddedEdges() []string {
  11872. edges := make([]string, 0, 1)
  11873. if m.label_relationships != nil {
  11874. edges = append(edges, label.EdgeLabelRelationships)
  11875. }
  11876. return edges
  11877. }
  11878. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11879. // name in this mutation.
  11880. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  11881. switch name {
  11882. case label.EdgeLabelRelationships:
  11883. ids := make([]ent.Value, 0, len(m.label_relationships))
  11884. for id := range m.label_relationships {
  11885. ids = append(ids, id)
  11886. }
  11887. return ids
  11888. }
  11889. return nil
  11890. }
  11891. // RemovedEdges returns all edge names that were removed in this mutation.
  11892. func (m *LabelMutation) RemovedEdges() []string {
  11893. edges := make([]string, 0, 1)
  11894. if m.removedlabel_relationships != nil {
  11895. edges = append(edges, label.EdgeLabelRelationships)
  11896. }
  11897. return edges
  11898. }
  11899. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11900. // the given name in this mutation.
  11901. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  11902. switch name {
  11903. case label.EdgeLabelRelationships:
  11904. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  11905. for id := range m.removedlabel_relationships {
  11906. ids = append(ids, id)
  11907. }
  11908. return ids
  11909. }
  11910. return nil
  11911. }
  11912. // ClearedEdges returns all edge names that were cleared in this mutation.
  11913. func (m *LabelMutation) ClearedEdges() []string {
  11914. edges := make([]string, 0, 1)
  11915. if m.clearedlabel_relationships {
  11916. edges = append(edges, label.EdgeLabelRelationships)
  11917. }
  11918. return edges
  11919. }
  11920. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11921. // was cleared in this mutation.
  11922. func (m *LabelMutation) EdgeCleared(name string) bool {
  11923. switch name {
  11924. case label.EdgeLabelRelationships:
  11925. return m.clearedlabel_relationships
  11926. }
  11927. return false
  11928. }
  11929. // ClearEdge clears the value of the edge with the given name. It returns an error
  11930. // if that edge is not defined in the schema.
  11931. func (m *LabelMutation) ClearEdge(name string) error {
  11932. switch name {
  11933. }
  11934. return fmt.Errorf("unknown Label unique edge %s", name)
  11935. }
  11936. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11937. // It returns an error if the edge is not defined in the schema.
  11938. func (m *LabelMutation) ResetEdge(name string) error {
  11939. switch name {
  11940. case label.EdgeLabelRelationships:
  11941. m.ResetLabelRelationships()
  11942. return nil
  11943. }
  11944. return fmt.Errorf("unknown Label edge %s", name)
  11945. }
  11946. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  11947. type LabelRelationshipMutation struct {
  11948. config
  11949. op Op
  11950. typ string
  11951. id *uint64
  11952. created_at *time.Time
  11953. updated_at *time.Time
  11954. status *uint8
  11955. addstatus *int8
  11956. deleted_at *time.Time
  11957. organization_id *uint64
  11958. addorganization_id *int64
  11959. clearedFields map[string]struct{}
  11960. contacts *uint64
  11961. clearedcontacts bool
  11962. labels *uint64
  11963. clearedlabels bool
  11964. done bool
  11965. oldValue func(context.Context) (*LabelRelationship, error)
  11966. predicates []predicate.LabelRelationship
  11967. }
  11968. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  11969. // labelrelationshipOption allows management of the mutation configuration using functional options.
  11970. type labelrelationshipOption func(*LabelRelationshipMutation)
  11971. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  11972. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  11973. m := &LabelRelationshipMutation{
  11974. config: c,
  11975. op: op,
  11976. typ: TypeLabelRelationship,
  11977. clearedFields: make(map[string]struct{}),
  11978. }
  11979. for _, opt := range opts {
  11980. opt(m)
  11981. }
  11982. return m
  11983. }
  11984. // withLabelRelationshipID sets the ID field of the mutation.
  11985. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  11986. return func(m *LabelRelationshipMutation) {
  11987. var (
  11988. err error
  11989. once sync.Once
  11990. value *LabelRelationship
  11991. )
  11992. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  11993. once.Do(func() {
  11994. if m.done {
  11995. err = errors.New("querying old values post mutation is not allowed")
  11996. } else {
  11997. value, err = m.Client().LabelRelationship.Get(ctx, id)
  11998. }
  11999. })
  12000. return value, err
  12001. }
  12002. m.id = &id
  12003. }
  12004. }
  12005. // withLabelRelationship sets the old LabelRelationship of the mutation.
  12006. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  12007. return func(m *LabelRelationshipMutation) {
  12008. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  12009. return node, nil
  12010. }
  12011. m.id = &node.ID
  12012. }
  12013. }
  12014. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12015. // executed in a transaction (ent.Tx), a transactional client is returned.
  12016. func (m LabelRelationshipMutation) Client() *Client {
  12017. client := &Client{config: m.config}
  12018. client.init()
  12019. return client
  12020. }
  12021. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12022. // it returns an error otherwise.
  12023. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  12024. if _, ok := m.driver.(*txDriver); !ok {
  12025. return nil, errors.New("ent: mutation is not running in a transaction")
  12026. }
  12027. tx := &Tx{config: m.config}
  12028. tx.init()
  12029. return tx, nil
  12030. }
  12031. // SetID sets the value of the id field. Note that this
  12032. // operation is only accepted on creation of LabelRelationship entities.
  12033. func (m *LabelRelationshipMutation) SetID(id uint64) {
  12034. m.id = &id
  12035. }
  12036. // ID returns the ID value in the mutation. Note that the ID is only available
  12037. // if it was provided to the builder or after it was returned from the database.
  12038. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  12039. if m.id == nil {
  12040. return
  12041. }
  12042. return *m.id, true
  12043. }
  12044. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12045. // That means, if the mutation is applied within a transaction with an isolation level such
  12046. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12047. // or updated by the mutation.
  12048. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  12049. switch {
  12050. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12051. id, exists := m.ID()
  12052. if exists {
  12053. return []uint64{id}, nil
  12054. }
  12055. fallthrough
  12056. case m.op.Is(OpUpdate | OpDelete):
  12057. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  12058. default:
  12059. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12060. }
  12061. }
  12062. // SetCreatedAt sets the "created_at" field.
  12063. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  12064. m.created_at = &t
  12065. }
  12066. // CreatedAt returns the value of the "created_at" field in the mutation.
  12067. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  12068. v := m.created_at
  12069. if v == nil {
  12070. return
  12071. }
  12072. return *v, true
  12073. }
  12074. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  12075. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12076. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12077. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12078. if !m.op.Is(OpUpdateOne) {
  12079. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12080. }
  12081. if m.id == nil || m.oldValue == nil {
  12082. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12083. }
  12084. oldValue, err := m.oldValue(ctx)
  12085. if err != nil {
  12086. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12087. }
  12088. return oldValue.CreatedAt, nil
  12089. }
  12090. // ResetCreatedAt resets all changes to the "created_at" field.
  12091. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  12092. m.created_at = nil
  12093. }
  12094. // SetUpdatedAt sets the "updated_at" field.
  12095. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  12096. m.updated_at = &t
  12097. }
  12098. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12099. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  12100. v := m.updated_at
  12101. if v == nil {
  12102. return
  12103. }
  12104. return *v, true
  12105. }
  12106. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  12107. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12108. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12109. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12110. if !m.op.Is(OpUpdateOne) {
  12111. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12112. }
  12113. if m.id == nil || m.oldValue == nil {
  12114. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12115. }
  12116. oldValue, err := m.oldValue(ctx)
  12117. if err != nil {
  12118. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12119. }
  12120. return oldValue.UpdatedAt, nil
  12121. }
  12122. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12123. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  12124. m.updated_at = nil
  12125. }
  12126. // SetStatus sets the "status" field.
  12127. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  12128. m.status = &u
  12129. m.addstatus = nil
  12130. }
  12131. // Status returns the value of the "status" field in the mutation.
  12132. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  12133. v := m.status
  12134. if v == nil {
  12135. return
  12136. }
  12137. return *v, true
  12138. }
  12139. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  12140. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12141. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12142. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12143. if !m.op.Is(OpUpdateOne) {
  12144. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12145. }
  12146. if m.id == nil || m.oldValue == nil {
  12147. return v, errors.New("OldStatus requires an ID field in the mutation")
  12148. }
  12149. oldValue, err := m.oldValue(ctx)
  12150. if err != nil {
  12151. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12152. }
  12153. return oldValue.Status, nil
  12154. }
  12155. // AddStatus adds u to the "status" field.
  12156. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  12157. if m.addstatus != nil {
  12158. *m.addstatus += u
  12159. } else {
  12160. m.addstatus = &u
  12161. }
  12162. }
  12163. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12164. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  12165. v := m.addstatus
  12166. if v == nil {
  12167. return
  12168. }
  12169. return *v, true
  12170. }
  12171. // ClearStatus clears the value of the "status" field.
  12172. func (m *LabelRelationshipMutation) ClearStatus() {
  12173. m.status = nil
  12174. m.addstatus = nil
  12175. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  12176. }
  12177. // StatusCleared returns if the "status" field was cleared in this mutation.
  12178. func (m *LabelRelationshipMutation) StatusCleared() bool {
  12179. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  12180. return ok
  12181. }
  12182. // ResetStatus resets all changes to the "status" field.
  12183. func (m *LabelRelationshipMutation) ResetStatus() {
  12184. m.status = nil
  12185. m.addstatus = nil
  12186. delete(m.clearedFields, labelrelationship.FieldStatus)
  12187. }
  12188. // SetDeletedAt sets the "deleted_at" field.
  12189. func (m *LabelRelationshipMutation) SetDeletedAt(t time.Time) {
  12190. m.deleted_at = &t
  12191. }
  12192. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12193. func (m *LabelRelationshipMutation) DeletedAt() (r time.Time, exists bool) {
  12194. v := m.deleted_at
  12195. if v == nil {
  12196. return
  12197. }
  12198. return *v, true
  12199. }
  12200. // OldDeletedAt returns the old "deleted_at" field's value of the LabelRelationship entity.
  12201. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12202. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12203. func (m *LabelRelationshipMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12204. if !m.op.Is(OpUpdateOne) {
  12205. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12206. }
  12207. if m.id == nil || m.oldValue == nil {
  12208. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12209. }
  12210. oldValue, err := m.oldValue(ctx)
  12211. if err != nil {
  12212. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12213. }
  12214. return oldValue.DeletedAt, nil
  12215. }
  12216. // ClearDeletedAt clears the value of the "deleted_at" field.
  12217. func (m *LabelRelationshipMutation) ClearDeletedAt() {
  12218. m.deleted_at = nil
  12219. m.clearedFields[labelrelationship.FieldDeletedAt] = struct{}{}
  12220. }
  12221. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12222. func (m *LabelRelationshipMutation) DeletedAtCleared() bool {
  12223. _, ok := m.clearedFields[labelrelationship.FieldDeletedAt]
  12224. return ok
  12225. }
  12226. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12227. func (m *LabelRelationshipMutation) ResetDeletedAt() {
  12228. m.deleted_at = nil
  12229. delete(m.clearedFields, labelrelationship.FieldDeletedAt)
  12230. }
  12231. // SetLabelID sets the "label_id" field.
  12232. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  12233. m.labels = &u
  12234. }
  12235. // LabelID returns the value of the "label_id" field in the mutation.
  12236. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  12237. v := m.labels
  12238. if v == nil {
  12239. return
  12240. }
  12241. return *v, true
  12242. }
  12243. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  12244. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12245. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12246. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  12247. if !m.op.Is(OpUpdateOne) {
  12248. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  12249. }
  12250. if m.id == nil || m.oldValue == nil {
  12251. return v, errors.New("OldLabelID requires an ID field in the mutation")
  12252. }
  12253. oldValue, err := m.oldValue(ctx)
  12254. if err != nil {
  12255. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  12256. }
  12257. return oldValue.LabelID, nil
  12258. }
  12259. // ResetLabelID resets all changes to the "label_id" field.
  12260. func (m *LabelRelationshipMutation) ResetLabelID() {
  12261. m.labels = nil
  12262. }
  12263. // SetContactID sets the "contact_id" field.
  12264. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  12265. m.contacts = &u
  12266. }
  12267. // ContactID returns the value of the "contact_id" field in the mutation.
  12268. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  12269. v := m.contacts
  12270. if v == nil {
  12271. return
  12272. }
  12273. return *v, true
  12274. }
  12275. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  12276. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12277. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12278. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  12279. if !m.op.Is(OpUpdateOne) {
  12280. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  12281. }
  12282. if m.id == nil || m.oldValue == nil {
  12283. return v, errors.New("OldContactID requires an ID field in the mutation")
  12284. }
  12285. oldValue, err := m.oldValue(ctx)
  12286. if err != nil {
  12287. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  12288. }
  12289. return oldValue.ContactID, nil
  12290. }
  12291. // ResetContactID resets all changes to the "contact_id" field.
  12292. func (m *LabelRelationshipMutation) ResetContactID() {
  12293. m.contacts = nil
  12294. }
  12295. // SetOrganizationID sets the "organization_id" field.
  12296. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  12297. m.organization_id = &u
  12298. m.addorganization_id = nil
  12299. }
  12300. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12301. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  12302. v := m.organization_id
  12303. if v == nil {
  12304. return
  12305. }
  12306. return *v, true
  12307. }
  12308. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  12309. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12310. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12311. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12312. if !m.op.Is(OpUpdateOne) {
  12313. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12314. }
  12315. if m.id == nil || m.oldValue == nil {
  12316. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12317. }
  12318. oldValue, err := m.oldValue(ctx)
  12319. if err != nil {
  12320. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12321. }
  12322. return oldValue.OrganizationID, nil
  12323. }
  12324. // AddOrganizationID adds u to the "organization_id" field.
  12325. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  12326. if m.addorganization_id != nil {
  12327. *m.addorganization_id += u
  12328. } else {
  12329. m.addorganization_id = &u
  12330. }
  12331. }
  12332. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12333. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  12334. v := m.addorganization_id
  12335. if v == nil {
  12336. return
  12337. }
  12338. return *v, true
  12339. }
  12340. // ClearOrganizationID clears the value of the "organization_id" field.
  12341. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  12342. m.organization_id = nil
  12343. m.addorganization_id = nil
  12344. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  12345. }
  12346. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  12347. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  12348. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  12349. return ok
  12350. }
  12351. // ResetOrganizationID resets all changes to the "organization_id" field.
  12352. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  12353. m.organization_id = nil
  12354. m.addorganization_id = nil
  12355. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  12356. }
  12357. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  12358. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  12359. m.contacts = &id
  12360. }
  12361. // ClearContacts clears the "contacts" edge to the Contact entity.
  12362. func (m *LabelRelationshipMutation) ClearContacts() {
  12363. m.clearedcontacts = true
  12364. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  12365. }
  12366. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  12367. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  12368. return m.clearedcontacts
  12369. }
  12370. // ContactsID returns the "contacts" edge ID in the mutation.
  12371. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  12372. if m.contacts != nil {
  12373. return *m.contacts, true
  12374. }
  12375. return
  12376. }
  12377. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  12378. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  12379. // ContactsID instead. It exists only for internal usage by the builders.
  12380. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  12381. if id := m.contacts; id != nil {
  12382. ids = append(ids, *id)
  12383. }
  12384. return
  12385. }
  12386. // ResetContacts resets all changes to the "contacts" edge.
  12387. func (m *LabelRelationshipMutation) ResetContacts() {
  12388. m.contacts = nil
  12389. m.clearedcontacts = false
  12390. }
  12391. // SetLabelsID sets the "labels" edge to the Label entity by id.
  12392. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  12393. m.labels = &id
  12394. }
  12395. // ClearLabels clears the "labels" edge to the Label entity.
  12396. func (m *LabelRelationshipMutation) ClearLabels() {
  12397. m.clearedlabels = true
  12398. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  12399. }
  12400. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  12401. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  12402. return m.clearedlabels
  12403. }
  12404. // LabelsID returns the "labels" edge ID in the mutation.
  12405. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  12406. if m.labels != nil {
  12407. return *m.labels, true
  12408. }
  12409. return
  12410. }
  12411. // LabelsIDs returns the "labels" edge IDs in the mutation.
  12412. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  12413. // LabelsID instead. It exists only for internal usage by the builders.
  12414. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  12415. if id := m.labels; id != nil {
  12416. ids = append(ids, *id)
  12417. }
  12418. return
  12419. }
  12420. // ResetLabels resets all changes to the "labels" edge.
  12421. func (m *LabelRelationshipMutation) ResetLabels() {
  12422. m.labels = nil
  12423. m.clearedlabels = false
  12424. }
  12425. // Where appends a list predicates to the LabelRelationshipMutation builder.
  12426. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  12427. m.predicates = append(m.predicates, ps...)
  12428. }
  12429. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  12430. // users can use type-assertion to append predicates that do not depend on any generated package.
  12431. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  12432. p := make([]predicate.LabelRelationship, len(ps))
  12433. for i := range ps {
  12434. p[i] = ps[i]
  12435. }
  12436. m.Where(p...)
  12437. }
  12438. // Op returns the operation name.
  12439. func (m *LabelRelationshipMutation) Op() Op {
  12440. return m.op
  12441. }
  12442. // SetOp allows setting the mutation operation.
  12443. func (m *LabelRelationshipMutation) SetOp(op Op) {
  12444. m.op = op
  12445. }
  12446. // Type returns the node type of this mutation (LabelRelationship).
  12447. func (m *LabelRelationshipMutation) Type() string {
  12448. return m.typ
  12449. }
  12450. // Fields returns all fields that were changed during this mutation. Note that in
  12451. // order to get all numeric fields that were incremented/decremented, call
  12452. // AddedFields().
  12453. func (m *LabelRelationshipMutation) Fields() []string {
  12454. fields := make([]string, 0, 7)
  12455. if m.created_at != nil {
  12456. fields = append(fields, labelrelationship.FieldCreatedAt)
  12457. }
  12458. if m.updated_at != nil {
  12459. fields = append(fields, labelrelationship.FieldUpdatedAt)
  12460. }
  12461. if m.status != nil {
  12462. fields = append(fields, labelrelationship.FieldStatus)
  12463. }
  12464. if m.deleted_at != nil {
  12465. fields = append(fields, labelrelationship.FieldDeletedAt)
  12466. }
  12467. if m.labels != nil {
  12468. fields = append(fields, labelrelationship.FieldLabelID)
  12469. }
  12470. if m.contacts != nil {
  12471. fields = append(fields, labelrelationship.FieldContactID)
  12472. }
  12473. if m.organization_id != nil {
  12474. fields = append(fields, labelrelationship.FieldOrganizationID)
  12475. }
  12476. return fields
  12477. }
  12478. // Field returns the value of a field with the given name. The second boolean
  12479. // return value indicates that this field was not set, or was not defined in the
  12480. // schema.
  12481. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  12482. switch name {
  12483. case labelrelationship.FieldCreatedAt:
  12484. return m.CreatedAt()
  12485. case labelrelationship.FieldUpdatedAt:
  12486. return m.UpdatedAt()
  12487. case labelrelationship.FieldStatus:
  12488. return m.Status()
  12489. case labelrelationship.FieldDeletedAt:
  12490. return m.DeletedAt()
  12491. case labelrelationship.FieldLabelID:
  12492. return m.LabelID()
  12493. case labelrelationship.FieldContactID:
  12494. return m.ContactID()
  12495. case labelrelationship.FieldOrganizationID:
  12496. return m.OrganizationID()
  12497. }
  12498. return nil, false
  12499. }
  12500. // OldField returns the old value of the field from the database. An error is
  12501. // returned if the mutation operation is not UpdateOne, or the query to the
  12502. // database failed.
  12503. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12504. switch name {
  12505. case labelrelationship.FieldCreatedAt:
  12506. return m.OldCreatedAt(ctx)
  12507. case labelrelationship.FieldUpdatedAt:
  12508. return m.OldUpdatedAt(ctx)
  12509. case labelrelationship.FieldStatus:
  12510. return m.OldStatus(ctx)
  12511. case labelrelationship.FieldDeletedAt:
  12512. return m.OldDeletedAt(ctx)
  12513. case labelrelationship.FieldLabelID:
  12514. return m.OldLabelID(ctx)
  12515. case labelrelationship.FieldContactID:
  12516. return m.OldContactID(ctx)
  12517. case labelrelationship.FieldOrganizationID:
  12518. return m.OldOrganizationID(ctx)
  12519. }
  12520. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  12521. }
  12522. // SetField sets the value of a field with the given name. It returns an error if
  12523. // the field is not defined in the schema, or if the type mismatched the field
  12524. // type.
  12525. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  12526. switch name {
  12527. case labelrelationship.FieldCreatedAt:
  12528. v, ok := value.(time.Time)
  12529. if !ok {
  12530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12531. }
  12532. m.SetCreatedAt(v)
  12533. return nil
  12534. case labelrelationship.FieldUpdatedAt:
  12535. v, ok := value.(time.Time)
  12536. if !ok {
  12537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12538. }
  12539. m.SetUpdatedAt(v)
  12540. return nil
  12541. case labelrelationship.FieldStatus:
  12542. v, ok := value.(uint8)
  12543. if !ok {
  12544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12545. }
  12546. m.SetStatus(v)
  12547. return nil
  12548. case labelrelationship.FieldDeletedAt:
  12549. v, ok := value.(time.Time)
  12550. if !ok {
  12551. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12552. }
  12553. m.SetDeletedAt(v)
  12554. return nil
  12555. case labelrelationship.FieldLabelID:
  12556. v, ok := value.(uint64)
  12557. if !ok {
  12558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12559. }
  12560. m.SetLabelID(v)
  12561. return nil
  12562. case labelrelationship.FieldContactID:
  12563. v, ok := value.(uint64)
  12564. if !ok {
  12565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12566. }
  12567. m.SetContactID(v)
  12568. return nil
  12569. case labelrelationship.FieldOrganizationID:
  12570. v, ok := value.(uint64)
  12571. if !ok {
  12572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12573. }
  12574. m.SetOrganizationID(v)
  12575. return nil
  12576. }
  12577. return fmt.Errorf("unknown LabelRelationship field %s", name)
  12578. }
  12579. // AddedFields returns all numeric fields that were incremented/decremented during
  12580. // this mutation.
  12581. func (m *LabelRelationshipMutation) AddedFields() []string {
  12582. var fields []string
  12583. if m.addstatus != nil {
  12584. fields = append(fields, labelrelationship.FieldStatus)
  12585. }
  12586. if m.addorganization_id != nil {
  12587. fields = append(fields, labelrelationship.FieldOrganizationID)
  12588. }
  12589. return fields
  12590. }
  12591. // AddedField returns the numeric value that was incremented/decremented on a field
  12592. // with the given name. The second boolean return value indicates that this field
  12593. // was not set, or was not defined in the schema.
  12594. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  12595. switch name {
  12596. case labelrelationship.FieldStatus:
  12597. return m.AddedStatus()
  12598. case labelrelationship.FieldOrganizationID:
  12599. return m.AddedOrganizationID()
  12600. }
  12601. return nil, false
  12602. }
  12603. // AddField adds the value to the field with the given name. It returns an error if
  12604. // the field is not defined in the schema, or if the type mismatched the field
  12605. // type.
  12606. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  12607. switch name {
  12608. case labelrelationship.FieldStatus:
  12609. v, ok := value.(int8)
  12610. if !ok {
  12611. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12612. }
  12613. m.AddStatus(v)
  12614. return nil
  12615. case labelrelationship.FieldOrganizationID:
  12616. v, ok := value.(int64)
  12617. if !ok {
  12618. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12619. }
  12620. m.AddOrganizationID(v)
  12621. return nil
  12622. }
  12623. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  12624. }
  12625. // ClearedFields returns all nullable fields that were cleared during this
  12626. // mutation.
  12627. func (m *LabelRelationshipMutation) ClearedFields() []string {
  12628. var fields []string
  12629. if m.FieldCleared(labelrelationship.FieldStatus) {
  12630. fields = append(fields, labelrelationship.FieldStatus)
  12631. }
  12632. if m.FieldCleared(labelrelationship.FieldDeletedAt) {
  12633. fields = append(fields, labelrelationship.FieldDeletedAt)
  12634. }
  12635. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  12636. fields = append(fields, labelrelationship.FieldOrganizationID)
  12637. }
  12638. return fields
  12639. }
  12640. // FieldCleared returns a boolean indicating if a field with the given name was
  12641. // cleared in this mutation.
  12642. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  12643. _, ok := m.clearedFields[name]
  12644. return ok
  12645. }
  12646. // ClearField clears the value of the field with the given name. It returns an
  12647. // error if the field is not defined in the schema.
  12648. func (m *LabelRelationshipMutation) ClearField(name string) error {
  12649. switch name {
  12650. case labelrelationship.FieldStatus:
  12651. m.ClearStatus()
  12652. return nil
  12653. case labelrelationship.FieldDeletedAt:
  12654. m.ClearDeletedAt()
  12655. return nil
  12656. case labelrelationship.FieldOrganizationID:
  12657. m.ClearOrganizationID()
  12658. return nil
  12659. }
  12660. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  12661. }
  12662. // ResetField resets all changes in the mutation for the field with the given name.
  12663. // It returns an error if the field is not defined in the schema.
  12664. func (m *LabelRelationshipMutation) ResetField(name string) error {
  12665. switch name {
  12666. case labelrelationship.FieldCreatedAt:
  12667. m.ResetCreatedAt()
  12668. return nil
  12669. case labelrelationship.FieldUpdatedAt:
  12670. m.ResetUpdatedAt()
  12671. return nil
  12672. case labelrelationship.FieldStatus:
  12673. m.ResetStatus()
  12674. return nil
  12675. case labelrelationship.FieldDeletedAt:
  12676. m.ResetDeletedAt()
  12677. return nil
  12678. case labelrelationship.FieldLabelID:
  12679. m.ResetLabelID()
  12680. return nil
  12681. case labelrelationship.FieldContactID:
  12682. m.ResetContactID()
  12683. return nil
  12684. case labelrelationship.FieldOrganizationID:
  12685. m.ResetOrganizationID()
  12686. return nil
  12687. }
  12688. return fmt.Errorf("unknown LabelRelationship field %s", name)
  12689. }
  12690. // AddedEdges returns all edge names that were set/added in this mutation.
  12691. func (m *LabelRelationshipMutation) AddedEdges() []string {
  12692. edges := make([]string, 0, 2)
  12693. if m.contacts != nil {
  12694. edges = append(edges, labelrelationship.EdgeContacts)
  12695. }
  12696. if m.labels != nil {
  12697. edges = append(edges, labelrelationship.EdgeLabels)
  12698. }
  12699. return edges
  12700. }
  12701. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12702. // name in this mutation.
  12703. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  12704. switch name {
  12705. case labelrelationship.EdgeContacts:
  12706. if id := m.contacts; id != nil {
  12707. return []ent.Value{*id}
  12708. }
  12709. case labelrelationship.EdgeLabels:
  12710. if id := m.labels; id != nil {
  12711. return []ent.Value{*id}
  12712. }
  12713. }
  12714. return nil
  12715. }
  12716. // RemovedEdges returns all edge names that were removed in this mutation.
  12717. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  12718. edges := make([]string, 0, 2)
  12719. return edges
  12720. }
  12721. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12722. // the given name in this mutation.
  12723. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  12724. return nil
  12725. }
  12726. // ClearedEdges returns all edge names that were cleared in this mutation.
  12727. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  12728. edges := make([]string, 0, 2)
  12729. if m.clearedcontacts {
  12730. edges = append(edges, labelrelationship.EdgeContacts)
  12731. }
  12732. if m.clearedlabels {
  12733. edges = append(edges, labelrelationship.EdgeLabels)
  12734. }
  12735. return edges
  12736. }
  12737. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12738. // was cleared in this mutation.
  12739. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  12740. switch name {
  12741. case labelrelationship.EdgeContacts:
  12742. return m.clearedcontacts
  12743. case labelrelationship.EdgeLabels:
  12744. return m.clearedlabels
  12745. }
  12746. return false
  12747. }
  12748. // ClearEdge clears the value of the edge with the given name. It returns an error
  12749. // if that edge is not defined in the schema.
  12750. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  12751. switch name {
  12752. case labelrelationship.EdgeContacts:
  12753. m.ClearContacts()
  12754. return nil
  12755. case labelrelationship.EdgeLabels:
  12756. m.ClearLabels()
  12757. return nil
  12758. }
  12759. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  12760. }
  12761. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12762. // It returns an error if the edge is not defined in the schema.
  12763. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  12764. switch name {
  12765. case labelrelationship.EdgeContacts:
  12766. m.ResetContacts()
  12767. return nil
  12768. case labelrelationship.EdgeLabels:
  12769. m.ResetLabels()
  12770. return nil
  12771. }
  12772. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  12773. }
  12774. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  12775. type MessageMutation struct {
  12776. config
  12777. op Op
  12778. typ string
  12779. id *int
  12780. wx_wxid *string
  12781. wxid *string
  12782. content *string
  12783. clearedFields map[string]struct{}
  12784. done bool
  12785. oldValue func(context.Context) (*Message, error)
  12786. predicates []predicate.Message
  12787. }
  12788. var _ ent.Mutation = (*MessageMutation)(nil)
  12789. // messageOption allows management of the mutation configuration using functional options.
  12790. type messageOption func(*MessageMutation)
  12791. // newMessageMutation creates new mutation for the Message entity.
  12792. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  12793. m := &MessageMutation{
  12794. config: c,
  12795. op: op,
  12796. typ: TypeMessage,
  12797. clearedFields: make(map[string]struct{}),
  12798. }
  12799. for _, opt := range opts {
  12800. opt(m)
  12801. }
  12802. return m
  12803. }
  12804. // withMessageID sets the ID field of the mutation.
  12805. func withMessageID(id int) messageOption {
  12806. return func(m *MessageMutation) {
  12807. var (
  12808. err error
  12809. once sync.Once
  12810. value *Message
  12811. )
  12812. m.oldValue = func(ctx context.Context) (*Message, error) {
  12813. once.Do(func() {
  12814. if m.done {
  12815. err = errors.New("querying old values post mutation is not allowed")
  12816. } else {
  12817. value, err = m.Client().Message.Get(ctx, id)
  12818. }
  12819. })
  12820. return value, err
  12821. }
  12822. m.id = &id
  12823. }
  12824. }
  12825. // withMessage sets the old Message of the mutation.
  12826. func withMessage(node *Message) messageOption {
  12827. return func(m *MessageMutation) {
  12828. m.oldValue = func(context.Context) (*Message, error) {
  12829. return node, nil
  12830. }
  12831. m.id = &node.ID
  12832. }
  12833. }
  12834. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12835. // executed in a transaction (ent.Tx), a transactional client is returned.
  12836. func (m MessageMutation) Client() *Client {
  12837. client := &Client{config: m.config}
  12838. client.init()
  12839. return client
  12840. }
  12841. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12842. // it returns an error otherwise.
  12843. func (m MessageMutation) Tx() (*Tx, error) {
  12844. if _, ok := m.driver.(*txDriver); !ok {
  12845. return nil, errors.New("ent: mutation is not running in a transaction")
  12846. }
  12847. tx := &Tx{config: m.config}
  12848. tx.init()
  12849. return tx, nil
  12850. }
  12851. // ID returns the ID value in the mutation. Note that the ID is only available
  12852. // if it was provided to the builder or after it was returned from the database.
  12853. func (m *MessageMutation) ID() (id int, exists bool) {
  12854. if m.id == nil {
  12855. return
  12856. }
  12857. return *m.id, true
  12858. }
  12859. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12860. // That means, if the mutation is applied within a transaction with an isolation level such
  12861. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12862. // or updated by the mutation.
  12863. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  12864. switch {
  12865. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12866. id, exists := m.ID()
  12867. if exists {
  12868. return []int{id}, nil
  12869. }
  12870. fallthrough
  12871. case m.op.Is(OpUpdate | OpDelete):
  12872. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  12873. default:
  12874. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12875. }
  12876. }
  12877. // SetWxWxid sets the "wx_wxid" field.
  12878. func (m *MessageMutation) SetWxWxid(s string) {
  12879. m.wx_wxid = &s
  12880. }
  12881. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  12882. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  12883. v := m.wx_wxid
  12884. if v == nil {
  12885. return
  12886. }
  12887. return *v, true
  12888. }
  12889. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  12890. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  12891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12892. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  12893. if !m.op.Is(OpUpdateOne) {
  12894. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  12895. }
  12896. if m.id == nil || m.oldValue == nil {
  12897. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  12898. }
  12899. oldValue, err := m.oldValue(ctx)
  12900. if err != nil {
  12901. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  12902. }
  12903. return oldValue.WxWxid, nil
  12904. }
  12905. // ClearWxWxid clears the value of the "wx_wxid" field.
  12906. func (m *MessageMutation) ClearWxWxid() {
  12907. m.wx_wxid = nil
  12908. m.clearedFields[message.FieldWxWxid] = struct{}{}
  12909. }
  12910. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  12911. func (m *MessageMutation) WxWxidCleared() bool {
  12912. _, ok := m.clearedFields[message.FieldWxWxid]
  12913. return ok
  12914. }
  12915. // ResetWxWxid resets all changes to the "wx_wxid" field.
  12916. func (m *MessageMutation) ResetWxWxid() {
  12917. m.wx_wxid = nil
  12918. delete(m.clearedFields, message.FieldWxWxid)
  12919. }
  12920. // SetWxid sets the "wxid" field.
  12921. func (m *MessageMutation) SetWxid(s string) {
  12922. m.wxid = &s
  12923. }
  12924. // Wxid returns the value of the "wxid" field in the mutation.
  12925. func (m *MessageMutation) Wxid() (r string, exists bool) {
  12926. v := m.wxid
  12927. if v == nil {
  12928. return
  12929. }
  12930. return *v, true
  12931. }
  12932. // OldWxid returns the old "wxid" field's value of the Message entity.
  12933. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  12934. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12935. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  12936. if !m.op.Is(OpUpdateOne) {
  12937. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  12938. }
  12939. if m.id == nil || m.oldValue == nil {
  12940. return v, errors.New("OldWxid requires an ID field in the mutation")
  12941. }
  12942. oldValue, err := m.oldValue(ctx)
  12943. if err != nil {
  12944. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  12945. }
  12946. return oldValue.Wxid, nil
  12947. }
  12948. // ResetWxid resets all changes to the "wxid" field.
  12949. func (m *MessageMutation) ResetWxid() {
  12950. m.wxid = nil
  12951. }
  12952. // SetContent sets the "content" field.
  12953. func (m *MessageMutation) SetContent(s string) {
  12954. m.content = &s
  12955. }
  12956. // Content returns the value of the "content" field in the mutation.
  12957. func (m *MessageMutation) Content() (r string, exists bool) {
  12958. v := m.content
  12959. if v == nil {
  12960. return
  12961. }
  12962. return *v, true
  12963. }
  12964. // OldContent returns the old "content" field's value of the Message entity.
  12965. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  12966. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12967. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  12968. if !m.op.Is(OpUpdateOne) {
  12969. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  12970. }
  12971. if m.id == nil || m.oldValue == nil {
  12972. return v, errors.New("OldContent requires an ID field in the mutation")
  12973. }
  12974. oldValue, err := m.oldValue(ctx)
  12975. if err != nil {
  12976. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  12977. }
  12978. return oldValue.Content, nil
  12979. }
  12980. // ResetContent resets all changes to the "content" field.
  12981. func (m *MessageMutation) ResetContent() {
  12982. m.content = nil
  12983. }
  12984. // Where appends a list predicates to the MessageMutation builder.
  12985. func (m *MessageMutation) Where(ps ...predicate.Message) {
  12986. m.predicates = append(m.predicates, ps...)
  12987. }
  12988. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  12989. // users can use type-assertion to append predicates that do not depend on any generated package.
  12990. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  12991. p := make([]predicate.Message, len(ps))
  12992. for i := range ps {
  12993. p[i] = ps[i]
  12994. }
  12995. m.Where(p...)
  12996. }
  12997. // Op returns the operation name.
  12998. func (m *MessageMutation) Op() Op {
  12999. return m.op
  13000. }
  13001. // SetOp allows setting the mutation operation.
  13002. func (m *MessageMutation) SetOp(op Op) {
  13003. m.op = op
  13004. }
  13005. // Type returns the node type of this mutation (Message).
  13006. func (m *MessageMutation) Type() string {
  13007. return m.typ
  13008. }
  13009. // Fields returns all fields that were changed during this mutation. Note that in
  13010. // order to get all numeric fields that were incremented/decremented, call
  13011. // AddedFields().
  13012. func (m *MessageMutation) Fields() []string {
  13013. fields := make([]string, 0, 3)
  13014. if m.wx_wxid != nil {
  13015. fields = append(fields, message.FieldWxWxid)
  13016. }
  13017. if m.wxid != nil {
  13018. fields = append(fields, message.FieldWxid)
  13019. }
  13020. if m.content != nil {
  13021. fields = append(fields, message.FieldContent)
  13022. }
  13023. return fields
  13024. }
  13025. // Field returns the value of a field with the given name. The second boolean
  13026. // return value indicates that this field was not set, or was not defined in the
  13027. // schema.
  13028. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  13029. switch name {
  13030. case message.FieldWxWxid:
  13031. return m.WxWxid()
  13032. case message.FieldWxid:
  13033. return m.Wxid()
  13034. case message.FieldContent:
  13035. return m.Content()
  13036. }
  13037. return nil, false
  13038. }
  13039. // OldField returns the old value of the field from the database. An error is
  13040. // returned if the mutation operation is not UpdateOne, or the query to the
  13041. // database failed.
  13042. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13043. switch name {
  13044. case message.FieldWxWxid:
  13045. return m.OldWxWxid(ctx)
  13046. case message.FieldWxid:
  13047. return m.OldWxid(ctx)
  13048. case message.FieldContent:
  13049. return m.OldContent(ctx)
  13050. }
  13051. return nil, fmt.Errorf("unknown Message field %s", name)
  13052. }
  13053. // SetField sets the value of a field with the given name. It returns an error if
  13054. // the field is not defined in the schema, or if the type mismatched the field
  13055. // type.
  13056. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  13057. switch name {
  13058. case message.FieldWxWxid:
  13059. v, ok := value.(string)
  13060. if !ok {
  13061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13062. }
  13063. m.SetWxWxid(v)
  13064. return nil
  13065. case message.FieldWxid:
  13066. v, ok := value.(string)
  13067. if !ok {
  13068. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13069. }
  13070. m.SetWxid(v)
  13071. return nil
  13072. case message.FieldContent:
  13073. v, ok := value.(string)
  13074. if !ok {
  13075. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13076. }
  13077. m.SetContent(v)
  13078. return nil
  13079. }
  13080. return fmt.Errorf("unknown Message field %s", name)
  13081. }
  13082. // AddedFields returns all numeric fields that were incremented/decremented during
  13083. // this mutation.
  13084. func (m *MessageMutation) AddedFields() []string {
  13085. return nil
  13086. }
  13087. // AddedField returns the numeric value that was incremented/decremented on a field
  13088. // with the given name. The second boolean return value indicates that this field
  13089. // was not set, or was not defined in the schema.
  13090. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  13091. return nil, false
  13092. }
  13093. // AddField adds the value to the field with the given name. It returns an error if
  13094. // the field is not defined in the schema, or if the type mismatched the field
  13095. // type.
  13096. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  13097. switch name {
  13098. }
  13099. return fmt.Errorf("unknown Message numeric field %s", name)
  13100. }
  13101. // ClearedFields returns all nullable fields that were cleared during this
  13102. // mutation.
  13103. func (m *MessageMutation) ClearedFields() []string {
  13104. var fields []string
  13105. if m.FieldCleared(message.FieldWxWxid) {
  13106. fields = append(fields, message.FieldWxWxid)
  13107. }
  13108. return fields
  13109. }
  13110. // FieldCleared returns a boolean indicating if a field with the given name was
  13111. // cleared in this mutation.
  13112. func (m *MessageMutation) FieldCleared(name string) bool {
  13113. _, ok := m.clearedFields[name]
  13114. return ok
  13115. }
  13116. // ClearField clears the value of the field with the given name. It returns an
  13117. // error if the field is not defined in the schema.
  13118. func (m *MessageMutation) ClearField(name string) error {
  13119. switch name {
  13120. case message.FieldWxWxid:
  13121. m.ClearWxWxid()
  13122. return nil
  13123. }
  13124. return fmt.Errorf("unknown Message nullable field %s", name)
  13125. }
  13126. // ResetField resets all changes in the mutation for the field with the given name.
  13127. // It returns an error if the field is not defined in the schema.
  13128. func (m *MessageMutation) ResetField(name string) error {
  13129. switch name {
  13130. case message.FieldWxWxid:
  13131. m.ResetWxWxid()
  13132. return nil
  13133. case message.FieldWxid:
  13134. m.ResetWxid()
  13135. return nil
  13136. case message.FieldContent:
  13137. m.ResetContent()
  13138. return nil
  13139. }
  13140. return fmt.Errorf("unknown Message field %s", name)
  13141. }
  13142. // AddedEdges returns all edge names that were set/added in this mutation.
  13143. func (m *MessageMutation) AddedEdges() []string {
  13144. edges := make([]string, 0, 0)
  13145. return edges
  13146. }
  13147. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13148. // name in this mutation.
  13149. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  13150. return nil
  13151. }
  13152. // RemovedEdges returns all edge names that were removed in this mutation.
  13153. func (m *MessageMutation) RemovedEdges() []string {
  13154. edges := make([]string, 0, 0)
  13155. return edges
  13156. }
  13157. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13158. // the given name in this mutation.
  13159. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  13160. return nil
  13161. }
  13162. // ClearedEdges returns all edge names that were cleared in this mutation.
  13163. func (m *MessageMutation) ClearedEdges() []string {
  13164. edges := make([]string, 0, 0)
  13165. return edges
  13166. }
  13167. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13168. // was cleared in this mutation.
  13169. func (m *MessageMutation) EdgeCleared(name string) bool {
  13170. return false
  13171. }
  13172. // ClearEdge clears the value of the edge with the given name. It returns an error
  13173. // if that edge is not defined in the schema.
  13174. func (m *MessageMutation) ClearEdge(name string) error {
  13175. return fmt.Errorf("unknown Message unique edge %s", name)
  13176. }
  13177. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13178. // It returns an error if the edge is not defined in the schema.
  13179. func (m *MessageMutation) ResetEdge(name string) error {
  13180. return fmt.Errorf("unknown Message edge %s", name)
  13181. }
  13182. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  13183. type MessageRecordsMutation struct {
  13184. config
  13185. op Op
  13186. typ string
  13187. id *uint64
  13188. created_at *time.Time
  13189. updated_at *time.Time
  13190. status *uint8
  13191. addstatus *int8
  13192. bot_wxid *string
  13193. contact_type *int
  13194. addcontact_type *int
  13195. contact_wxid *string
  13196. content_type *int
  13197. addcontent_type *int
  13198. content *string
  13199. meta *custom_types.Meta
  13200. error_detail *string
  13201. send_time *time.Time
  13202. source_type *int
  13203. addsource_type *int
  13204. organization_id *uint64
  13205. addorganization_id *int64
  13206. clearedFields map[string]struct{}
  13207. sop_stage *uint64
  13208. clearedsop_stage bool
  13209. sop_node *uint64
  13210. clearedsop_node bool
  13211. message_contact *uint64
  13212. clearedmessage_contact bool
  13213. done bool
  13214. oldValue func(context.Context) (*MessageRecords, error)
  13215. predicates []predicate.MessageRecords
  13216. }
  13217. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  13218. // messagerecordsOption allows management of the mutation configuration using functional options.
  13219. type messagerecordsOption func(*MessageRecordsMutation)
  13220. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  13221. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  13222. m := &MessageRecordsMutation{
  13223. config: c,
  13224. op: op,
  13225. typ: TypeMessageRecords,
  13226. clearedFields: make(map[string]struct{}),
  13227. }
  13228. for _, opt := range opts {
  13229. opt(m)
  13230. }
  13231. return m
  13232. }
  13233. // withMessageRecordsID sets the ID field of the mutation.
  13234. func withMessageRecordsID(id uint64) messagerecordsOption {
  13235. return func(m *MessageRecordsMutation) {
  13236. var (
  13237. err error
  13238. once sync.Once
  13239. value *MessageRecords
  13240. )
  13241. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  13242. once.Do(func() {
  13243. if m.done {
  13244. err = errors.New("querying old values post mutation is not allowed")
  13245. } else {
  13246. value, err = m.Client().MessageRecords.Get(ctx, id)
  13247. }
  13248. })
  13249. return value, err
  13250. }
  13251. m.id = &id
  13252. }
  13253. }
  13254. // withMessageRecords sets the old MessageRecords of the mutation.
  13255. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  13256. return func(m *MessageRecordsMutation) {
  13257. m.oldValue = func(context.Context) (*MessageRecords, error) {
  13258. return node, nil
  13259. }
  13260. m.id = &node.ID
  13261. }
  13262. }
  13263. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13264. // executed in a transaction (ent.Tx), a transactional client is returned.
  13265. func (m MessageRecordsMutation) Client() *Client {
  13266. client := &Client{config: m.config}
  13267. client.init()
  13268. return client
  13269. }
  13270. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13271. // it returns an error otherwise.
  13272. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  13273. if _, ok := m.driver.(*txDriver); !ok {
  13274. return nil, errors.New("ent: mutation is not running in a transaction")
  13275. }
  13276. tx := &Tx{config: m.config}
  13277. tx.init()
  13278. return tx, nil
  13279. }
  13280. // SetID sets the value of the id field. Note that this
  13281. // operation is only accepted on creation of MessageRecords entities.
  13282. func (m *MessageRecordsMutation) SetID(id uint64) {
  13283. m.id = &id
  13284. }
  13285. // ID returns the ID value in the mutation. Note that the ID is only available
  13286. // if it was provided to the builder or after it was returned from the database.
  13287. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  13288. if m.id == nil {
  13289. return
  13290. }
  13291. return *m.id, true
  13292. }
  13293. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13294. // That means, if the mutation is applied within a transaction with an isolation level such
  13295. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13296. // or updated by the mutation.
  13297. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  13298. switch {
  13299. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13300. id, exists := m.ID()
  13301. if exists {
  13302. return []uint64{id}, nil
  13303. }
  13304. fallthrough
  13305. case m.op.Is(OpUpdate | OpDelete):
  13306. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  13307. default:
  13308. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13309. }
  13310. }
  13311. // SetCreatedAt sets the "created_at" field.
  13312. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  13313. m.created_at = &t
  13314. }
  13315. // CreatedAt returns the value of the "created_at" field in the mutation.
  13316. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  13317. v := m.created_at
  13318. if v == nil {
  13319. return
  13320. }
  13321. return *v, true
  13322. }
  13323. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  13324. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13325. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13326. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13327. if !m.op.Is(OpUpdateOne) {
  13328. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13329. }
  13330. if m.id == nil || m.oldValue == nil {
  13331. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13332. }
  13333. oldValue, err := m.oldValue(ctx)
  13334. if err != nil {
  13335. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13336. }
  13337. return oldValue.CreatedAt, nil
  13338. }
  13339. // ResetCreatedAt resets all changes to the "created_at" field.
  13340. func (m *MessageRecordsMutation) ResetCreatedAt() {
  13341. m.created_at = nil
  13342. }
  13343. // SetUpdatedAt sets the "updated_at" field.
  13344. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  13345. m.updated_at = &t
  13346. }
  13347. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13348. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  13349. v := m.updated_at
  13350. if v == nil {
  13351. return
  13352. }
  13353. return *v, true
  13354. }
  13355. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  13356. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13357. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13358. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13359. if !m.op.Is(OpUpdateOne) {
  13360. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13361. }
  13362. if m.id == nil || m.oldValue == nil {
  13363. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13364. }
  13365. oldValue, err := m.oldValue(ctx)
  13366. if err != nil {
  13367. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13368. }
  13369. return oldValue.UpdatedAt, nil
  13370. }
  13371. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13372. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  13373. m.updated_at = nil
  13374. }
  13375. // SetStatus sets the "status" field.
  13376. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  13377. m.status = &u
  13378. m.addstatus = nil
  13379. }
  13380. // Status returns the value of the "status" field in the mutation.
  13381. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  13382. v := m.status
  13383. if v == nil {
  13384. return
  13385. }
  13386. return *v, true
  13387. }
  13388. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  13389. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13390. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13391. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13392. if !m.op.Is(OpUpdateOne) {
  13393. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13394. }
  13395. if m.id == nil || m.oldValue == nil {
  13396. return v, errors.New("OldStatus requires an ID field in the mutation")
  13397. }
  13398. oldValue, err := m.oldValue(ctx)
  13399. if err != nil {
  13400. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13401. }
  13402. return oldValue.Status, nil
  13403. }
  13404. // AddStatus adds u to the "status" field.
  13405. func (m *MessageRecordsMutation) AddStatus(u int8) {
  13406. if m.addstatus != nil {
  13407. *m.addstatus += u
  13408. } else {
  13409. m.addstatus = &u
  13410. }
  13411. }
  13412. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13413. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  13414. v := m.addstatus
  13415. if v == nil {
  13416. return
  13417. }
  13418. return *v, true
  13419. }
  13420. // ClearStatus clears the value of the "status" field.
  13421. func (m *MessageRecordsMutation) ClearStatus() {
  13422. m.status = nil
  13423. m.addstatus = nil
  13424. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  13425. }
  13426. // StatusCleared returns if the "status" field was cleared in this mutation.
  13427. func (m *MessageRecordsMutation) StatusCleared() bool {
  13428. _, ok := m.clearedFields[messagerecords.FieldStatus]
  13429. return ok
  13430. }
  13431. // ResetStatus resets all changes to the "status" field.
  13432. func (m *MessageRecordsMutation) ResetStatus() {
  13433. m.status = nil
  13434. m.addstatus = nil
  13435. delete(m.clearedFields, messagerecords.FieldStatus)
  13436. }
  13437. // SetBotWxid sets the "bot_wxid" field.
  13438. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  13439. m.bot_wxid = &s
  13440. }
  13441. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  13442. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  13443. v := m.bot_wxid
  13444. if v == nil {
  13445. return
  13446. }
  13447. return *v, true
  13448. }
  13449. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  13450. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13451. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13452. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  13453. if !m.op.Is(OpUpdateOne) {
  13454. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  13455. }
  13456. if m.id == nil || m.oldValue == nil {
  13457. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  13458. }
  13459. oldValue, err := m.oldValue(ctx)
  13460. if err != nil {
  13461. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  13462. }
  13463. return oldValue.BotWxid, nil
  13464. }
  13465. // ResetBotWxid resets all changes to the "bot_wxid" field.
  13466. func (m *MessageRecordsMutation) ResetBotWxid() {
  13467. m.bot_wxid = nil
  13468. }
  13469. // SetContactID sets the "contact_id" field.
  13470. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  13471. m.message_contact = &u
  13472. }
  13473. // ContactID returns the value of the "contact_id" field in the mutation.
  13474. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  13475. v := m.message_contact
  13476. if v == nil {
  13477. return
  13478. }
  13479. return *v, true
  13480. }
  13481. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  13482. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13483. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13484. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  13485. if !m.op.Is(OpUpdateOne) {
  13486. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  13487. }
  13488. if m.id == nil || m.oldValue == nil {
  13489. return v, errors.New("OldContactID requires an ID field in the mutation")
  13490. }
  13491. oldValue, err := m.oldValue(ctx)
  13492. if err != nil {
  13493. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  13494. }
  13495. return oldValue.ContactID, nil
  13496. }
  13497. // ClearContactID clears the value of the "contact_id" field.
  13498. func (m *MessageRecordsMutation) ClearContactID() {
  13499. m.message_contact = nil
  13500. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  13501. }
  13502. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  13503. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  13504. _, ok := m.clearedFields[messagerecords.FieldContactID]
  13505. return ok
  13506. }
  13507. // ResetContactID resets all changes to the "contact_id" field.
  13508. func (m *MessageRecordsMutation) ResetContactID() {
  13509. m.message_contact = nil
  13510. delete(m.clearedFields, messagerecords.FieldContactID)
  13511. }
  13512. // SetContactType sets the "contact_type" field.
  13513. func (m *MessageRecordsMutation) SetContactType(i int) {
  13514. m.contact_type = &i
  13515. m.addcontact_type = nil
  13516. }
  13517. // ContactType returns the value of the "contact_type" field in the mutation.
  13518. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  13519. v := m.contact_type
  13520. if v == nil {
  13521. return
  13522. }
  13523. return *v, true
  13524. }
  13525. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  13526. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13527. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13528. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  13529. if !m.op.Is(OpUpdateOne) {
  13530. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  13531. }
  13532. if m.id == nil || m.oldValue == nil {
  13533. return v, errors.New("OldContactType requires an ID field in the mutation")
  13534. }
  13535. oldValue, err := m.oldValue(ctx)
  13536. if err != nil {
  13537. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  13538. }
  13539. return oldValue.ContactType, nil
  13540. }
  13541. // AddContactType adds i to the "contact_type" field.
  13542. func (m *MessageRecordsMutation) AddContactType(i int) {
  13543. if m.addcontact_type != nil {
  13544. *m.addcontact_type += i
  13545. } else {
  13546. m.addcontact_type = &i
  13547. }
  13548. }
  13549. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  13550. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  13551. v := m.addcontact_type
  13552. if v == nil {
  13553. return
  13554. }
  13555. return *v, true
  13556. }
  13557. // ResetContactType resets all changes to the "contact_type" field.
  13558. func (m *MessageRecordsMutation) ResetContactType() {
  13559. m.contact_type = nil
  13560. m.addcontact_type = nil
  13561. }
  13562. // SetContactWxid sets the "contact_wxid" field.
  13563. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  13564. m.contact_wxid = &s
  13565. }
  13566. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  13567. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  13568. v := m.contact_wxid
  13569. if v == nil {
  13570. return
  13571. }
  13572. return *v, true
  13573. }
  13574. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  13575. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13577. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  13578. if !m.op.Is(OpUpdateOne) {
  13579. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  13580. }
  13581. if m.id == nil || m.oldValue == nil {
  13582. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  13583. }
  13584. oldValue, err := m.oldValue(ctx)
  13585. if err != nil {
  13586. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  13587. }
  13588. return oldValue.ContactWxid, nil
  13589. }
  13590. // ResetContactWxid resets all changes to the "contact_wxid" field.
  13591. func (m *MessageRecordsMutation) ResetContactWxid() {
  13592. m.contact_wxid = nil
  13593. }
  13594. // SetContentType sets the "content_type" field.
  13595. func (m *MessageRecordsMutation) SetContentType(i int) {
  13596. m.content_type = &i
  13597. m.addcontent_type = nil
  13598. }
  13599. // ContentType returns the value of the "content_type" field in the mutation.
  13600. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  13601. v := m.content_type
  13602. if v == nil {
  13603. return
  13604. }
  13605. return *v, true
  13606. }
  13607. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  13608. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13609. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13610. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  13611. if !m.op.Is(OpUpdateOne) {
  13612. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  13613. }
  13614. if m.id == nil || m.oldValue == nil {
  13615. return v, errors.New("OldContentType requires an ID field in the mutation")
  13616. }
  13617. oldValue, err := m.oldValue(ctx)
  13618. if err != nil {
  13619. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  13620. }
  13621. return oldValue.ContentType, nil
  13622. }
  13623. // AddContentType adds i to the "content_type" field.
  13624. func (m *MessageRecordsMutation) AddContentType(i int) {
  13625. if m.addcontent_type != nil {
  13626. *m.addcontent_type += i
  13627. } else {
  13628. m.addcontent_type = &i
  13629. }
  13630. }
  13631. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  13632. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  13633. v := m.addcontent_type
  13634. if v == nil {
  13635. return
  13636. }
  13637. return *v, true
  13638. }
  13639. // ResetContentType resets all changes to the "content_type" field.
  13640. func (m *MessageRecordsMutation) ResetContentType() {
  13641. m.content_type = nil
  13642. m.addcontent_type = nil
  13643. }
  13644. // SetContent sets the "content" field.
  13645. func (m *MessageRecordsMutation) SetContent(s string) {
  13646. m.content = &s
  13647. }
  13648. // Content returns the value of the "content" field in the mutation.
  13649. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  13650. v := m.content
  13651. if v == nil {
  13652. return
  13653. }
  13654. return *v, true
  13655. }
  13656. // OldContent returns the old "content" field's value of the MessageRecords entity.
  13657. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13658. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13659. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  13660. if !m.op.Is(OpUpdateOne) {
  13661. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  13662. }
  13663. if m.id == nil || m.oldValue == nil {
  13664. return v, errors.New("OldContent requires an ID field in the mutation")
  13665. }
  13666. oldValue, err := m.oldValue(ctx)
  13667. if err != nil {
  13668. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  13669. }
  13670. return oldValue.Content, nil
  13671. }
  13672. // ResetContent resets all changes to the "content" field.
  13673. func (m *MessageRecordsMutation) ResetContent() {
  13674. m.content = nil
  13675. }
  13676. // SetMeta sets the "meta" field.
  13677. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  13678. m.meta = &ct
  13679. }
  13680. // Meta returns the value of the "meta" field in the mutation.
  13681. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  13682. v := m.meta
  13683. if v == nil {
  13684. return
  13685. }
  13686. return *v, true
  13687. }
  13688. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  13689. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13690. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13691. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  13692. if !m.op.Is(OpUpdateOne) {
  13693. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  13694. }
  13695. if m.id == nil || m.oldValue == nil {
  13696. return v, errors.New("OldMeta requires an ID field in the mutation")
  13697. }
  13698. oldValue, err := m.oldValue(ctx)
  13699. if err != nil {
  13700. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  13701. }
  13702. return oldValue.Meta, nil
  13703. }
  13704. // ClearMeta clears the value of the "meta" field.
  13705. func (m *MessageRecordsMutation) ClearMeta() {
  13706. m.meta = nil
  13707. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  13708. }
  13709. // MetaCleared returns if the "meta" field was cleared in this mutation.
  13710. func (m *MessageRecordsMutation) MetaCleared() bool {
  13711. _, ok := m.clearedFields[messagerecords.FieldMeta]
  13712. return ok
  13713. }
  13714. // ResetMeta resets all changes to the "meta" field.
  13715. func (m *MessageRecordsMutation) ResetMeta() {
  13716. m.meta = nil
  13717. delete(m.clearedFields, messagerecords.FieldMeta)
  13718. }
  13719. // SetErrorDetail sets the "error_detail" field.
  13720. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  13721. m.error_detail = &s
  13722. }
  13723. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  13724. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  13725. v := m.error_detail
  13726. if v == nil {
  13727. return
  13728. }
  13729. return *v, true
  13730. }
  13731. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  13732. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13733. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13734. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  13735. if !m.op.Is(OpUpdateOne) {
  13736. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  13737. }
  13738. if m.id == nil || m.oldValue == nil {
  13739. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  13740. }
  13741. oldValue, err := m.oldValue(ctx)
  13742. if err != nil {
  13743. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  13744. }
  13745. return oldValue.ErrorDetail, nil
  13746. }
  13747. // ResetErrorDetail resets all changes to the "error_detail" field.
  13748. func (m *MessageRecordsMutation) ResetErrorDetail() {
  13749. m.error_detail = nil
  13750. }
  13751. // SetSendTime sets the "send_time" field.
  13752. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  13753. m.send_time = &t
  13754. }
  13755. // SendTime returns the value of the "send_time" field in the mutation.
  13756. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  13757. v := m.send_time
  13758. if v == nil {
  13759. return
  13760. }
  13761. return *v, true
  13762. }
  13763. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  13764. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13765. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13766. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  13767. if !m.op.Is(OpUpdateOne) {
  13768. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  13769. }
  13770. if m.id == nil || m.oldValue == nil {
  13771. return v, errors.New("OldSendTime requires an ID field in the mutation")
  13772. }
  13773. oldValue, err := m.oldValue(ctx)
  13774. if err != nil {
  13775. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  13776. }
  13777. return oldValue.SendTime, nil
  13778. }
  13779. // ClearSendTime clears the value of the "send_time" field.
  13780. func (m *MessageRecordsMutation) ClearSendTime() {
  13781. m.send_time = nil
  13782. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  13783. }
  13784. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  13785. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  13786. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  13787. return ok
  13788. }
  13789. // ResetSendTime resets all changes to the "send_time" field.
  13790. func (m *MessageRecordsMutation) ResetSendTime() {
  13791. m.send_time = nil
  13792. delete(m.clearedFields, messagerecords.FieldSendTime)
  13793. }
  13794. // SetSourceType sets the "source_type" field.
  13795. func (m *MessageRecordsMutation) SetSourceType(i int) {
  13796. m.source_type = &i
  13797. m.addsource_type = nil
  13798. }
  13799. // SourceType returns the value of the "source_type" field in the mutation.
  13800. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  13801. v := m.source_type
  13802. if v == nil {
  13803. return
  13804. }
  13805. return *v, true
  13806. }
  13807. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  13808. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13810. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  13811. if !m.op.Is(OpUpdateOne) {
  13812. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  13813. }
  13814. if m.id == nil || m.oldValue == nil {
  13815. return v, errors.New("OldSourceType requires an ID field in the mutation")
  13816. }
  13817. oldValue, err := m.oldValue(ctx)
  13818. if err != nil {
  13819. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  13820. }
  13821. return oldValue.SourceType, nil
  13822. }
  13823. // AddSourceType adds i to the "source_type" field.
  13824. func (m *MessageRecordsMutation) AddSourceType(i int) {
  13825. if m.addsource_type != nil {
  13826. *m.addsource_type += i
  13827. } else {
  13828. m.addsource_type = &i
  13829. }
  13830. }
  13831. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  13832. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  13833. v := m.addsource_type
  13834. if v == nil {
  13835. return
  13836. }
  13837. return *v, true
  13838. }
  13839. // ResetSourceType resets all changes to the "source_type" field.
  13840. func (m *MessageRecordsMutation) ResetSourceType() {
  13841. m.source_type = nil
  13842. m.addsource_type = nil
  13843. }
  13844. // SetSourceID sets the "source_id" field.
  13845. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  13846. m.sop_stage = &u
  13847. }
  13848. // SourceID returns the value of the "source_id" field in the mutation.
  13849. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  13850. v := m.sop_stage
  13851. if v == nil {
  13852. return
  13853. }
  13854. return *v, true
  13855. }
  13856. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  13857. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13858. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13859. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  13860. if !m.op.Is(OpUpdateOne) {
  13861. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  13862. }
  13863. if m.id == nil || m.oldValue == nil {
  13864. return v, errors.New("OldSourceID requires an ID field in the mutation")
  13865. }
  13866. oldValue, err := m.oldValue(ctx)
  13867. if err != nil {
  13868. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  13869. }
  13870. return oldValue.SourceID, nil
  13871. }
  13872. // ClearSourceID clears the value of the "source_id" field.
  13873. func (m *MessageRecordsMutation) ClearSourceID() {
  13874. m.sop_stage = nil
  13875. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  13876. }
  13877. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  13878. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  13879. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  13880. return ok
  13881. }
  13882. // ResetSourceID resets all changes to the "source_id" field.
  13883. func (m *MessageRecordsMutation) ResetSourceID() {
  13884. m.sop_stage = nil
  13885. delete(m.clearedFields, messagerecords.FieldSourceID)
  13886. }
  13887. // SetSubSourceID sets the "sub_source_id" field.
  13888. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  13889. m.sop_node = &u
  13890. }
  13891. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  13892. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  13893. v := m.sop_node
  13894. if v == nil {
  13895. return
  13896. }
  13897. return *v, true
  13898. }
  13899. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  13900. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13901. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13902. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  13903. if !m.op.Is(OpUpdateOne) {
  13904. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  13905. }
  13906. if m.id == nil || m.oldValue == nil {
  13907. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  13908. }
  13909. oldValue, err := m.oldValue(ctx)
  13910. if err != nil {
  13911. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  13912. }
  13913. return oldValue.SubSourceID, nil
  13914. }
  13915. // ClearSubSourceID clears the value of the "sub_source_id" field.
  13916. func (m *MessageRecordsMutation) ClearSubSourceID() {
  13917. m.sop_node = nil
  13918. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  13919. }
  13920. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  13921. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  13922. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  13923. return ok
  13924. }
  13925. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  13926. func (m *MessageRecordsMutation) ResetSubSourceID() {
  13927. m.sop_node = nil
  13928. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  13929. }
  13930. // SetOrganizationID sets the "organization_id" field.
  13931. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  13932. m.organization_id = &u
  13933. m.addorganization_id = nil
  13934. }
  13935. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13936. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  13937. v := m.organization_id
  13938. if v == nil {
  13939. return
  13940. }
  13941. return *v, true
  13942. }
  13943. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  13944. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  13945. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13946. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13947. if !m.op.Is(OpUpdateOne) {
  13948. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13949. }
  13950. if m.id == nil || m.oldValue == nil {
  13951. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13952. }
  13953. oldValue, err := m.oldValue(ctx)
  13954. if err != nil {
  13955. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13956. }
  13957. return oldValue.OrganizationID, nil
  13958. }
  13959. // AddOrganizationID adds u to the "organization_id" field.
  13960. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  13961. if m.addorganization_id != nil {
  13962. *m.addorganization_id += u
  13963. } else {
  13964. m.addorganization_id = &u
  13965. }
  13966. }
  13967. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13968. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  13969. v := m.addorganization_id
  13970. if v == nil {
  13971. return
  13972. }
  13973. return *v, true
  13974. }
  13975. // ClearOrganizationID clears the value of the "organization_id" field.
  13976. func (m *MessageRecordsMutation) ClearOrganizationID() {
  13977. m.organization_id = nil
  13978. m.addorganization_id = nil
  13979. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  13980. }
  13981. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13982. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  13983. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  13984. return ok
  13985. }
  13986. // ResetOrganizationID resets all changes to the "organization_id" field.
  13987. func (m *MessageRecordsMutation) ResetOrganizationID() {
  13988. m.organization_id = nil
  13989. m.addorganization_id = nil
  13990. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  13991. }
  13992. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  13993. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  13994. m.sop_stage = &id
  13995. }
  13996. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  13997. func (m *MessageRecordsMutation) ClearSopStage() {
  13998. m.clearedsop_stage = true
  13999. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  14000. }
  14001. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  14002. func (m *MessageRecordsMutation) SopStageCleared() bool {
  14003. return m.SourceIDCleared() || m.clearedsop_stage
  14004. }
  14005. // SopStageID returns the "sop_stage" edge ID in the mutation.
  14006. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  14007. if m.sop_stage != nil {
  14008. return *m.sop_stage, true
  14009. }
  14010. return
  14011. }
  14012. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  14013. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14014. // SopStageID instead. It exists only for internal usage by the builders.
  14015. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  14016. if id := m.sop_stage; id != nil {
  14017. ids = append(ids, *id)
  14018. }
  14019. return
  14020. }
  14021. // ResetSopStage resets all changes to the "sop_stage" edge.
  14022. func (m *MessageRecordsMutation) ResetSopStage() {
  14023. m.sop_stage = nil
  14024. m.clearedsop_stage = false
  14025. }
  14026. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  14027. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  14028. m.sop_node = &id
  14029. }
  14030. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  14031. func (m *MessageRecordsMutation) ClearSopNode() {
  14032. m.clearedsop_node = true
  14033. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  14034. }
  14035. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  14036. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  14037. return m.SubSourceIDCleared() || m.clearedsop_node
  14038. }
  14039. // SopNodeID returns the "sop_node" edge ID in the mutation.
  14040. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  14041. if m.sop_node != nil {
  14042. return *m.sop_node, true
  14043. }
  14044. return
  14045. }
  14046. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  14047. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14048. // SopNodeID instead. It exists only for internal usage by the builders.
  14049. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  14050. if id := m.sop_node; id != nil {
  14051. ids = append(ids, *id)
  14052. }
  14053. return
  14054. }
  14055. // ResetSopNode resets all changes to the "sop_node" edge.
  14056. func (m *MessageRecordsMutation) ResetSopNode() {
  14057. m.sop_node = nil
  14058. m.clearedsop_node = false
  14059. }
  14060. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  14061. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  14062. m.message_contact = &id
  14063. }
  14064. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  14065. func (m *MessageRecordsMutation) ClearMessageContact() {
  14066. m.clearedmessage_contact = true
  14067. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  14068. }
  14069. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  14070. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  14071. return m.ContactIDCleared() || m.clearedmessage_contact
  14072. }
  14073. // MessageContactID returns the "message_contact" edge ID in the mutation.
  14074. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  14075. if m.message_contact != nil {
  14076. return *m.message_contact, true
  14077. }
  14078. return
  14079. }
  14080. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  14081. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14082. // MessageContactID instead. It exists only for internal usage by the builders.
  14083. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  14084. if id := m.message_contact; id != nil {
  14085. ids = append(ids, *id)
  14086. }
  14087. return
  14088. }
  14089. // ResetMessageContact resets all changes to the "message_contact" edge.
  14090. func (m *MessageRecordsMutation) ResetMessageContact() {
  14091. m.message_contact = nil
  14092. m.clearedmessage_contact = false
  14093. }
  14094. // Where appends a list predicates to the MessageRecordsMutation builder.
  14095. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  14096. m.predicates = append(m.predicates, ps...)
  14097. }
  14098. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  14099. // users can use type-assertion to append predicates that do not depend on any generated package.
  14100. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  14101. p := make([]predicate.MessageRecords, len(ps))
  14102. for i := range ps {
  14103. p[i] = ps[i]
  14104. }
  14105. m.Where(p...)
  14106. }
  14107. // Op returns the operation name.
  14108. func (m *MessageRecordsMutation) Op() Op {
  14109. return m.op
  14110. }
  14111. // SetOp allows setting the mutation operation.
  14112. func (m *MessageRecordsMutation) SetOp(op Op) {
  14113. m.op = op
  14114. }
  14115. // Type returns the node type of this mutation (MessageRecords).
  14116. func (m *MessageRecordsMutation) Type() string {
  14117. return m.typ
  14118. }
  14119. // Fields returns all fields that were changed during this mutation. Note that in
  14120. // order to get all numeric fields that were incremented/decremented, call
  14121. // AddedFields().
  14122. func (m *MessageRecordsMutation) Fields() []string {
  14123. fields := make([]string, 0, 16)
  14124. if m.created_at != nil {
  14125. fields = append(fields, messagerecords.FieldCreatedAt)
  14126. }
  14127. if m.updated_at != nil {
  14128. fields = append(fields, messagerecords.FieldUpdatedAt)
  14129. }
  14130. if m.status != nil {
  14131. fields = append(fields, messagerecords.FieldStatus)
  14132. }
  14133. if m.bot_wxid != nil {
  14134. fields = append(fields, messagerecords.FieldBotWxid)
  14135. }
  14136. if m.message_contact != nil {
  14137. fields = append(fields, messagerecords.FieldContactID)
  14138. }
  14139. if m.contact_type != nil {
  14140. fields = append(fields, messagerecords.FieldContactType)
  14141. }
  14142. if m.contact_wxid != nil {
  14143. fields = append(fields, messagerecords.FieldContactWxid)
  14144. }
  14145. if m.content_type != nil {
  14146. fields = append(fields, messagerecords.FieldContentType)
  14147. }
  14148. if m.content != nil {
  14149. fields = append(fields, messagerecords.FieldContent)
  14150. }
  14151. if m.meta != nil {
  14152. fields = append(fields, messagerecords.FieldMeta)
  14153. }
  14154. if m.error_detail != nil {
  14155. fields = append(fields, messagerecords.FieldErrorDetail)
  14156. }
  14157. if m.send_time != nil {
  14158. fields = append(fields, messagerecords.FieldSendTime)
  14159. }
  14160. if m.source_type != nil {
  14161. fields = append(fields, messagerecords.FieldSourceType)
  14162. }
  14163. if m.sop_stage != nil {
  14164. fields = append(fields, messagerecords.FieldSourceID)
  14165. }
  14166. if m.sop_node != nil {
  14167. fields = append(fields, messagerecords.FieldSubSourceID)
  14168. }
  14169. if m.organization_id != nil {
  14170. fields = append(fields, messagerecords.FieldOrganizationID)
  14171. }
  14172. return fields
  14173. }
  14174. // Field returns the value of a field with the given name. The second boolean
  14175. // return value indicates that this field was not set, or was not defined in the
  14176. // schema.
  14177. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  14178. switch name {
  14179. case messagerecords.FieldCreatedAt:
  14180. return m.CreatedAt()
  14181. case messagerecords.FieldUpdatedAt:
  14182. return m.UpdatedAt()
  14183. case messagerecords.FieldStatus:
  14184. return m.Status()
  14185. case messagerecords.FieldBotWxid:
  14186. return m.BotWxid()
  14187. case messagerecords.FieldContactID:
  14188. return m.ContactID()
  14189. case messagerecords.FieldContactType:
  14190. return m.ContactType()
  14191. case messagerecords.FieldContactWxid:
  14192. return m.ContactWxid()
  14193. case messagerecords.FieldContentType:
  14194. return m.ContentType()
  14195. case messagerecords.FieldContent:
  14196. return m.Content()
  14197. case messagerecords.FieldMeta:
  14198. return m.Meta()
  14199. case messagerecords.FieldErrorDetail:
  14200. return m.ErrorDetail()
  14201. case messagerecords.FieldSendTime:
  14202. return m.SendTime()
  14203. case messagerecords.FieldSourceType:
  14204. return m.SourceType()
  14205. case messagerecords.FieldSourceID:
  14206. return m.SourceID()
  14207. case messagerecords.FieldSubSourceID:
  14208. return m.SubSourceID()
  14209. case messagerecords.FieldOrganizationID:
  14210. return m.OrganizationID()
  14211. }
  14212. return nil, false
  14213. }
  14214. // OldField returns the old value of the field from the database. An error is
  14215. // returned if the mutation operation is not UpdateOne, or the query to the
  14216. // database failed.
  14217. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14218. switch name {
  14219. case messagerecords.FieldCreatedAt:
  14220. return m.OldCreatedAt(ctx)
  14221. case messagerecords.FieldUpdatedAt:
  14222. return m.OldUpdatedAt(ctx)
  14223. case messagerecords.FieldStatus:
  14224. return m.OldStatus(ctx)
  14225. case messagerecords.FieldBotWxid:
  14226. return m.OldBotWxid(ctx)
  14227. case messagerecords.FieldContactID:
  14228. return m.OldContactID(ctx)
  14229. case messagerecords.FieldContactType:
  14230. return m.OldContactType(ctx)
  14231. case messagerecords.FieldContactWxid:
  14232. return m.OldContactWxid(ctx)
  14233. case messagerecords.FieldContentType:
  14234. return m.OldContentType(ctx)
  14235. case messagerecords.FieldContent:
  14236. return m.OldContent(ctx)
  14237. case messagerecords.FieldMeta:
  14238. return m.OldMeta(ctx)
  14239. case messagerecords.FieldErrorDetail:
  14240. return m.OldErrorDetail(ctx)
  14241. case messagerecords.FieldSendTime:
  14242. return m.OldSendTime(ctx)
  14243. case messagerecords.FieldSourceType:
  14244. return m.OldSourceType(ctx)
  14245. case messagerecords.FieldSourceID:
  14246. return m.OldSourceID(ctx)
  14247. case messagerecords.FieldSubSourceID:
  14248. return m.OldSubSourceID(ctx)
  14249. case messagerecords.FieldOrganizationID:
  14250. return m.OldOrganizationID(ctx)
  14251. }
  14252. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  14253. }
  14254. // SetField sets the value of a field with the given name. It returns an error if
  14255. // the field is not defined in the schema, or if the type mismatched the field
  14256. // type.
  14257. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  14258. switch name {
  14259. case messagerecords.FieldCreatedAt:
  14260. v, ok := value.(time.Time)
  14261. if !ok {
  14262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14263. }
  14264. m.SetCreatedAt(v)
  14265. return nil
  14266. case messagerecords.FieldUpdatedAt:
  14267. v, ok := value.(time.Time)
  14268. if !ok {
  14269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14270. }
  14271. m.SetUpdatedAt(v)
  14272. return nil
  14273. case messagerecords.FieldStatus:
  14274. v, ok := value.(uint8)
  14275. if !ok {
  14276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14277. }
  14278. m.SetStatus(v)
  14279. return nil
  14280. case messagerecords.FieldBotWxid:
  14281. v, ok := value.(string)
  14282. if !ok {
  14283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14284. }
  14285. m.SetBotWxid(v)
  14286. return nil
  14287. case messagerecords.FieldContactID:
  14288. v, ok := value.(uint64)
  14289. if !ok {
  14290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14291. }
  14292. m.SetContactID(v)
  14293. return nil
  14294. case messagerecords.FieldContactType:
  14295. v, ok := value.(int)
  14296. if !ok {
  14297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14298. }
  14299. m.SetContactType(v)
  14300. return nil
  14301. case messagerecords.FieldContactWxid:
  14302. v, ok := value.(string)
  14303. if !ok {
  14304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14305. }
  14306. m.SetContactWxid(v)
  14307. return nil
  14308. case messagerecords.FieldContentType:
  14309. v, ok := value.(int)
  14310. if !ok {
  14311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14312. }
  14313. m.SetContentType(v)
  14314. return nil
  14315. case messagerecords.FieldContent:
  14316. v, ok := value.(string)
  14317. if !ok {
  14318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14319. }
  14320. m.SetContent(v)
  14321. return nil
  14322. case messagerecords.FieldMeta:
  14323. v, ok := value.(custom_types.Meta)
  14324. if !ok {
  14325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14326. }
  14327. m.SetMeta(v)
  14328. return nil
  14329. case messagerecords.FieldErrorDetail:
  14330. v, ok := value.(string)
  14331. if !ok {
  14332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14333. }
  14334. m.SetErrorDetail(v)
  14335. return nil
  14336. case messagerecords.FieldSendTime:
  14337. v, ok := value.(time.Time)
  14338. if !ok {
  14339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14340. }
  14341. m.SetSendTime(v)
  14342. return nil
  14343. case messagerecords.FieldSourceType:
  14344. v, ok := value.(int)
  14345. if !ok {
  14346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14347. }
  14348. m.SetSourceType(v)
  14349. return nil
  14350. case messagerecords.FieldSourceID:
  14351. v, ok := value.(uint64)
  14352. if !ok {
  14353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14354. }
  14355. m.SetSourceID(v)
  14356. return nil
  14357. case messagerecords.FieldSubSourceID:
  14358. v, ok := value.(uint64)
  14359. if !ok {
  14360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14361. }
  14362. m.SetSubSourceID(v)
  14363. return nil
  14364. case messagerecords.FieldOrganizationID:
  14365. v, ok := value.(uint64)
  14366. if !ok {
  14367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14368. }
  14369. m.SetOrganizationID(v)
  14370. return nil
  14371. }
  14372. return fmt.Errorf("unknown MessageRecords field %s", name)
  14373. }
  14374. // AddedFields returns all numeric fields that were incremented/decremented during
  14375. // this mutation.
  14376. func (m *MessageRecordsMutation) AddedFields() []string {
  14377. var fields []string
  14378. if m.addstatus != nil {
  14379. fields = append(fields, messagerecords.FieldStatus)
  14380. }
  14381. if m.addcontact_type != nil {
  14382. fields = append(fields, messagerecords.FieldContactType)
  14383. }
  14384. if m.addcontent_type != nil {
  14385. fields = append(fields, messagerecords.FieldContentType)
  14386. }
  14387. if m.addsource_type != nil {
  14388. fields = append(fields, messagerecords.FieldSourceType)
  14389. }
  14390. if m.addorganization_id != nil {
  14391. fields = append(fields, messagerecords.FieldOrganizationID)
  14392. }
  14393. return fields
  14394. }
  14395. // AddedField returns the numeric value that was incremented/decremented on a field
  14396. // with the given name. The second boolean return value indicates that this field
  14397. // was not set, or was not defined in the schema.
  14398. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  14399. switch name {
  14400. case messagerecords.FieldStatus:
  14401. return m.AddedStatus()
  14402. case messagerecords.FieldContactType:
  14403. return m.AddedContactType()
  14404. case messagerecords.FieldContentType:
  14405. return m.AddedContentType()
  14406. case messagerecords.FieldSourceType:
  14407. return m.AddedSourceType()
  14408. case messagerecords.FieldOrganizationID:
  14409. return m.AddedOrganizationID()
  14410. }
  14411. return nil, false
  14412. }
  14413. // AddField adds the value to the field with the given name. It returns an error if
  14414. // the field is not defined in the schema, or if the type mismatched the field
  14415. // type.
  14416. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  14417. switch name {
  14418. case messagerecords.FieldStatus:
  14419. v, ok := value.(int8)
  14420. if !ok {
  14421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14422. }
  14423. m.AddStatus(v)
  14424. return nil
  14425. case messagerecords.FieldContactType:
  14426. v, ok := value.(int)
  14427. if !ok {
  14428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14429. }
  14430. m.AddContactType(v)
  14431. return nil
  14432. case messagerecords.FieldContentType:
  14433. v, ok := value.(int)
  14434. if !ok {
  14435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14436. }
  14437. m.AddContentType(v)
  14438. return nil
  14439. case messagerecords.FieldSourceType:
  14440. v, ok := value.(int)
  14441. if !ok {
  14442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14443. }
  14444. m.AddSourceType(v)
  14445. return nil
  14446. case messagerecords.FieldOrganizationID:
  14447. v, ok := value.(int64)
  14448. if !ok {
  14449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14450. }
  14451. m.AddOrganizationID(v)
  14452. return nil
  14453. }
  14454. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  14455. }
  14456. // ClearedFields returns all nullable fields that were cleared during this
  14457. // mutation.
  14458. func (m *MessageRecordsMutation) ClearedFields() []string {
  14459. var fields []string
  14460. if m.FieldCleared(messagerecords.FieldStatus) {
  14461. fields = append(fields, messagerecords.FieldStatus)
  14462. }
  14463. if m.FieldCleared(messagerecords.FieldContactID) {
  14464. fields = append(fields, messagerecords.FieldContactID)
  14465. }
  14466. if m.FieldCleared(messagerecords.FieldMeta) {
  14467. fields = append(fields, messagerecords.FieldMeta)
  14468. }
  14469. if m.FieldCleared(messagerecords.FieldSendTime) {
  14470. fields = append(fields, messagerecords.FieldSendTime)
  14471. }
  14472. if m.FieldCleared(messagerecords.FieldSourceID) {
  14473. fields = append(fields, messagerecords.FieldSourceID)
  14474. }
  14475. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  14476. fields = append(fields, messagerecords.FieldSubSourceID)
  14477. }
  14478. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  14479. fields = append(fields, messagerecords.FieldOrganizationID)
  14480. }
  14481. return fields
  14482. }
  14483. // FieldCleared returns a boolean indicating if a field with the given name was
  14484. // cleared in this mutation.
  14485. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  14486. _, ok := m.clearedFields[name]
  14487. return ok
  14488. }
  14489. // ClearField clears the value of the field with the given name. It returns an
  14490. // error if the field is not defined in the schema.
  14491. func (m *MessageRecordsMutation) ClearField(name string) error {
  14492. switch name {
  14493. case messagerecords.FieldStatus:
  14494. m.ClearStatus()
  14495. return nil
  14496. case messagerecords.FieldContactID:
  14497. m.ClearContactID()
  14498. return nil
  14499. case messagerecords.FieldMeta:
  14500. m.ClearMeta()
  14501. return nil
  14502. case messagerecords.FieldSendTime:
  14503. m.ClearSendTime()
  14504. return nil
  14505. case messagerecords.FieldSourceID:
  14506. m.ClearSourceID()
  14507. return nil
  14508. case messagerecords.FieldSubSourceID:
  14509. m.ClearSubSourceID()
  14510. return nil
  14511. case messagerecords.FieldOrganizationID:
  14512. m.ClearOrganizationID()
  14513. return nil
  14514. }
  14515. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  14516. }
  14517. // ResetField resets all changes in the mutation for the field with the given name.
  14518. // It returns an error if the field is not defined in the schema.
  14519. func (m *MessageRecordsMutation) ResetField(name string) error {
  14520. switch name {
  14521. case messagerecords.FieldCreatedAt:
  14522. m.ResetCreatedAt()
  14523. return nil
  14524. case messagerecords.FieldUpdatedAt:
  14525. m.ResetUpdatedAt()
  14526. return nil
  14527. case messagerecords.FieldStatus:
  14528. m.ResetStatus()
  14529. return nil
  14530. case messagerecords.FieldBotWxid:
  14531. m.ResetBotWxid()
  14532. return nil
  14533. case messagerecords.FieldContactID:
  14534. m.ResetContactID()
  14535. return nil
  14536. case messagerecords.FieldContactType:
  14537. m.ResetContactType()
  14538. return nil
  14539. case messagerecords.FieldContactWxid:
  14540. m.ResetContactWxid()
  14541. return nil
  14542. case messagerecords.FieldContentType:
  14543. m.ResetContentType()
  14544. return nil
  14545. case messagerecords.FieldContent:
  14546. m.ResetContent()
  14547. return nil
  14548. case messagerecords.FieldMeta:
  14549. m.ResetMeta()
  14550. return nil
  14551. case messagerecords.FieldErrorDetail:
  14552. m.ResetErrorDetail()
  14553. return nil
  14554. case messagerecords.FieldSendTime:
  14555. m.ResetSendTime()
  14556. return nil
  14557. case messagerecords.FieldSourceType:
  14558. m.ResetSourceType()
  14559. return nil
  14560. case messagerecords.FieldSourceID:
  14561. m.ResetSourceID()
  14562. return nil
  14563. case messagerecords.FieldSubSourceID:
  14564. m.ResetSubSourceID()
  14565. return nil
  14566. case messagerecords.FieldOrganizationID:
  14567. m.ResetOrganizationID()
  14568. return nil
  14569. }
  14570. return fmt.Errorf("unknown MessageRecords field %s", name)
  14571. }
  14572. // AddedEdges returns all edge names that were set/added in this mutation.
  14573. func (m *MessageRecordsMutation) AddedEdges() []string {
  14574. edges := make([]string, 0, 3)
  14575. if m.sop_stage != nil {
  14576. edges = append(edges, messagerecords.EdgeSopStage)
  14577. }
  14578. if m.sop_node != nil {
  14579. edges = append(edges, messagerecords.EdgeSopNode)
  14580. }
  14581. if m.message_contact != nil {
  14582. edges = append(edges, messagerecords.EdgeMessageContact)
  14583. }
  14584. return edges
  14585. }
  14586. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14587. // name in this mutation.
  14588. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  14589. switch name {
  14590. case messagerecords.EdgeSopStage:
  14591. if id := m.sop_stage; id != nil {
  14592. return []ent.Value{*id}
  14593. }
  14594. case messagerecords.EdgeSopNode:
  14595. if id := m.sop_node; id != nil {
  14596. return []ent.Value{*id}
  14597. }
  14598. case messagerecords.EdgeMessageContact:
  14599. if id := m.message_contact; id != nil {
  14600. return []ent.Value{*id}
  14601. }
  14602. }
  14603. return nil
  14604. }
  14605. // RemovedEdges returns all edge names that were removed in this mutation.
  14606. func (m *MessageRecordsMutation) RemovedEdges() []string {
  14607. edges := make([]string, 0, 3)
  14608. return edges
  14609. }
  14610. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14611. // the given name in this mutation.
  14612. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  14613. return nil
  14614. }
  14615. // ClearedEdges returns all edge names that were cleared in this mutation.
  14616. func (m *MessageRecordsMutation) ClearedEdges() []string {
  14617. edges := make([]string, 0, 3)
  14618. if m.clearedsop_stage {
  14619. edges = append(edges, messagerecords.EdgeSopStage)
  14620. }
  14621. if m.clearedsop_node {
  14622. edges = append(edges, messagerecords.EdgeSopNode)
  14623. }
  14624. if m.clearedmessage_contact {
  14625. edges = append(edges, messagerecords.EdgeMessageContact)
  14626. }
  14627. return edges
  14628. }
  14629. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14630. // was cleared in this mutation.
  14631. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  14632. switch name {
  14633. case messagerecords.EdgeSopStage:
  14634. return m.clearedsop_stage
  14635. case messagerecords.EdgeSopNode:
  14636. return m.clearedsop_node
  14637. case messagerecords.EdgeMessageContact:
  14638. return m.clearedmessage_contact
  14639. }
  14640. return false
  14641. }
  14642. // ClearEdge clears the value of the edge with the given name. It returns an error
  14643. // if that edge is not defined in the schema.
  14644. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  14645. switch name {
  14646. case messagerecords.EdgeSopStage:
  14647. m.ClearSopStage()
  14648. return nil
  14649. case messagerecords.EdgeSopNode:
  14650. m.ClearSopNode()
  14651. return nil
  14652. case messagerecords.EdgeMessageContact:
  14653. m.ClearMessageContact()
  14654. return nil
  14655. }
  14656. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  14657. }
  14658. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14659. // It returns an error if the edge is not defined in the schema.
  14660. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  14661. switch name {
  14662. case messagerecords.EdgeSopStage:
  14663. m.ResetSopStage()
  14664. return nil
  14665. case messagerecords.EdgeSopNode:
  14666. m.ResetSopNode()
  14667. return nil
  14668. case messagerecords.EdgeMessageContact:
  14669. m.ResetMessageContact()
  14670. return nil
  14671. }
  14672. return fmt.Errorf("unknown MessageRecords edge %s", name)
  14673. }
  14674. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  14675. type MsgMutation struct {
  14676. config
  14677. op Op
  14678. typ string
  14679. id *uint64
  14680. created_at *time.Time
  14681. updated_at *time.Time
  14682. deleted_at *time.Time
  14683. status *uint8
  14684. addstatus *int8
  14685. fromwxid *string
  14686. toid *string
  14687. msgtype *int32
  14688. addmsgtype *int32
  14689. msg *string
  14690. batch_no *string
  14691. clearedFields map[string]struct{}
  14692. done bool
  14693. oldValue func(context.Context) (*Msg, error)
  14694. predicates []predicate.Msg
  14695. }
  14696. var _ ent.Mutation = (*MsgMutation)(nil)
  14697. // msgOption allows management of the mutation configuration using functional options.
  14698. type msgOption func(*MsgMutation)
  14699. // newMsgMutation creates new mutation for the Msg entity.
  14700. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  14701. m := &MsgMutation{
  14702. config: c,
  14703. op: op,
  14704. typ: TypeMsg,
  14705. clearedFields: make(map[string]struct{}),
  14706. }
  14707. for _, opt := range opts {
  14708. opt(m)
  14709. }
  14710. return m
  14711. }
  14712. // withMsgID sets the ID field of the mutation.
  14713. func withMsgID(id uint64) msgOption {
  14714. return func(m *MsgMutation) {
  14715. var (
  14716. err error
  14717. once sync.Once
  14718. value *Msg
  14719. )
  14720. m.oldValue = func(ctx context.Context) (*Msg, error) {
  14721. once.Do(func() {
  14722. if m.done {
  14723. err = errors.New("querying old values post mutation is not allowed")
  14724. } else {
  14725. value, err = m.Client().Msg.Get(ctx, id)
  14726. }
  14727. })
  14728. return value, err
  14729. }
  14730. m.id = &id
  14731. }
  14732. }
  14733. // withMsg sets the old Msg of the mutation.
  14734. func withMsg(node *Msg) msgOption {
  14735. return func(m *MsgMutation) {
  14736. m.oldValue = func(context.Context) (*Msg, error) {
  14737. return node, nil
  14738. }
  14739. m.id = &node.ID
  14740. }
  14741. }
  14742. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14743. // executed in a transaction (ent.Tx), a transactional client is returned.
  14744. func (m MsgMutation) Client() *Client {
  14745. client := &Client{config: m.config}
  14746. client.init()
  14747. return client
  14748. }
  14749. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14750. // it returns an error otherwise.
  14751. func (m MsgMutation) Tx() (*Tx, error) {
  14752. if _, ok := m.driver.(*txDriver); !ok {
  14753. return nil, errors.New("ent: mutation is not running in a transaction")
  14754. }
  14755. tx := &Tx{config: m.config}
  14756. tx.init()
  14757. return tx, nil
  14758. }
  14759. // SetID sets the value of the id field. Note that this
  14760. // operation is only accepted on creation of Msg entities.
  14761. func (m *MsgMutation) SetID(id uint64) {
  14762. m.id = &id
  14763. }
  14764. // ID returns the ID value in the mutation. Note that the ID is only available
  14765. // if it was provided to the builder or after it was returned from the database.
  14766. func (m *MsgMutation) ID() (id uint64, exists bool) {
  14767. if m.id == nil {
  14768. return
  14769. }
  14770. return *m.id, true
  14771. }
  14772. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14773. // That means, if the mutation is applied within a transaction with an isolation level such
  14774. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14775. // or updated by the mutation.
  14776. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  14777. switch {
  14778. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14779. id, exists := m.ID()
  14780. if exists {
  14781. return []uint64{id}, nil
  14782. }
  14783. fallthrough
  14784. case m.op.Is(OpUpdate | OpDelete):
  14785. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  14786. default:
  14787. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14788. }
  14789. }
  14790. // SetCreatedAt sets the "created_at" field.
  14791. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  14792. m.created_at = &t
  14793. }
  14794. // CreatedAt returns the value of the "created_at" field in the mutation.
  14795. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  14796. v := m.created_at
  14797. if v == nil {
  14798. return
  14799. }
  14800. return *v, true
  14801. }
  14802. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  14803. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14804. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14805. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14806. if !m.op.Is(OpUpdateOne) {
  14807. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14808. }
  14809. if m.id == nil || m.oldValue == nil {
  14810. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14811. }
  14812. oldValue, err := m.oldValue(ctx)
  14813. if err != nil {
  14814. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14815. }
  14816. return oldValue.CreatedAt, nil
  14817. }
  14818. // ResetCreatedAt resets all changes to the "created_at" field.
  14819. func (m *MsgMutation) ResetCreatedAt() {
  14820. m.created_at = nil
  14821. }
  14822. // SetUpdatedAt sets the "updated_at" field.
  14823. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  14824. m.updated_at = &t
  14825. }
  14826. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14827. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  14828. v := m.updated_at
  14829. if v == nil {
  14830. return
  14831. }
  14832. return *v, true
  14833. }
  14834. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  14835. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14836. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14837. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14838. if !m.op.Is(OpUpdateOne) {
  14839. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14840. }
  14841. if m.id == nil || m.oldValue == nil {
  14842. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14843. }
  14844. oldValue, err := m.oldValue(ctx)
  14845. if err != nil {
  14846. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14847. }
  14848. return oldValue.UpdatedAt, nil
  14849. }
  14850. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14851. func (m *MsgMutation) ResetUpdatedAt() {
  14852. m.updated_at = nil
  14853. }
  14854. // SetDeletedAt sets the "deleted_at" field.
  14855. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  14856. m.deleted_at = &t
  14857. }
  14858. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14859. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  14860. v := m.deleted_at
  14861. if v == nil {
  14862. return
  14863. }
  14864. return *v, true
  14865. }
  14866. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  14867. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14868. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14869. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14870. if !m.op.Is(OpUpdateOne) {
  14871. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14872. }
  14873. if m.id == nil || m.oldValue == nil {
  14874. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14875. }
  14876. oldValue, err := m.oldValue(ctx)
  14877. if err != nil {
  14878. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14879. }
  14880. return oldValue.DeletedAt, nil
  14881. }
  14882. // ClearDeletedAt clears the value of the "deleted_at" field.
  14883. func (m *MsgMutation) ClearDeletedAt() {
  14884. m.deleted_at = nil
  14885. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  14886. }
  14887. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14888. func (m *MsgMutation) DeletedAtCleared() bool {
  14889. _, ok := m.clearedFields[msg.FieldDeletedAt]
  14890. return ok
  14891. }
  14892. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14893. func (m *MsgMutation) ResetDeletedAt() {
  14894. m.deleted_at = nil
  14895. delete(m.clearedFields, msg.FieldDeletedAt)
  14896. }
  14897. // SetStatus sets the "status" field.
  14898. func (m *MsgMutation) SetStatus(u uint8) {
  14899. m.status = &u
  14900. m.addstatus = nil
  14901. }
  14902. // Status returns the value of the "status" field in the mutation.
  14903. func (m *MsgMutation) Status() (r uint8, exists bool) {
  14904. v := m.status
  14905. if v == nil {
  14906. return
  14907. }
  14908. return *v, true
  14909. }
  14910. // OldStatus returns the old "status" field's value of the Msg entity.
  14911. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14912. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14913. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14914. if !m.op.Is(OpUpdateOne) {
  14915. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14916. }
  14917. if m.id == nil || m.oldValue == nil {
  14918. return v, errors.New("OldStatus requires an ID field in the mutation")
  14919. }
  14920. oldValue, err := m.oldValue(ctx)
  14921. if err != nil {
  14922. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14923. }
  14924. return oldValue.Status, nil
  14925. }
  14926. // AddStatus adds u to the "status" field.
  14927. func (m *MsgMutation) AddStatus(u int8) {
  14928. if m.addstatus != nil {
  14929. *m.addstatus += u
  14930. } else {
  14931. m.addstatus = &u
  14932. }
  14933. }
  14934. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14935. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  14936. v := m.addstatus
  14937. if v == nil {
  14938. return
  14939. }
  14940. return *v, true
  14941. }
  14942. // ClearStatus clears the value of the "status" field.
  14943. func (m *MsgMutation) ClearStatus() {
  14944. m.status = nil
  14945. m.addstatus = nil
  14946. m.clearedFields[msg.FieldStatus] = struct{}{}
  14947. }
  14948. // StatusCleared returns if the "status" field was cleared in this mutation.
  14949. func (m *MsgMutation) StatusCleared() bool {
  14950. _, ok := m.clearedFields[msg.FieldStatus]
  14951. return ok
  14952. }
  14953. // ResetStatus resets all changes to the "status" field.
  14954. func (m *MsgMutation) ResetStatus() {
  14955. m.status = nil
  14956. m.addstatus = nil
  14957. delete(m.clearedFields, msg.FieldStatus)
  14958. }
  14959. // SetFromwxid sets the "fromwxid" field.
  14960. func (m *MsgMutation) SetFromwxid(s string) {
  14961. m.fromwxid = &s
  14962. }
  14963. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  14964. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  14965. v := m.fromwxid
  14966. if v == nil {
  14967. return
  14968. }
  14969. return *v, true
  14970. }
  14971. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  14972. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  14973. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14974. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  14975. if !m.op.Is(OpUpdateOne) {
  14976. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  14977. }
  14978. if m.id == nil || m.oldValue == nil {
  14979. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  14980. }
  14981. oldValue, err := m.oldValue(ctx)
  14982. if err != nil {
  14983. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  14984. }
  14985. return oldValue.Fromwxid, nil
  14986. }
  14987. // ClearFromwxid clears the value of the "fromwxid" field.
  14988. func (m *MsgMutation) ClearFromwxid() {
  14989. m.fromwxid = nil
  14990. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  14991. }
  14992. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  14993. func (m *MsgMutation) FromwxidCleared() bool {
  14994. _, ok := m.clearedFields[msg.FieldFromwxid]
  14995. return ok
  14996. }
  14997. // ResetFromwxid resets all changes to the "fromwxid" field.
  14998. func (m *MsgMutation) ResetFromwxid() {
  14999. m.fromwxid = nil
  15000. delete(m.clearedFields, msg.FieldFromwxid)
  15001. }
  15002. // SetToid sets the "toid" field.
  15003. func (m *MsgMutation) SetToid(s string) {
  15004. m.toid = &s
  15005. }
  15006. // Toid returns the value of the "toid" field in the mutation.
  15007. func (m *MsgMutation) Toid() (r string, exists bool) {
  15008. v := m.toid
  15009. if v == nil {
  15010. return
  15011. }
  15012. return *v, true
  15013. }
  15014. // OldToid returns the old "toid" field's value of the Msg entity.
  15015. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15016. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15017. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  15018. if !m.op.Is(OpUpdateOne) {
  15019. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  15020. }
  15021. if m.id == nil || m.oldValue == nil {
  15022. return v, errors.New("OldToid requires an ID field in the mutation")
  15023. }
  15024. oldValue, err := m.oldValue(ctx)
  15025. if err != nil {
  15026. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  15027. }
  15028. return oldValue.Toid, nil
  15029. }
  15030. // ClearToid clears the value of the "toid" field.
  15031. func (m *MsgMutation) ClearToid() {
  15032. m.toid = nil
  15033. m.clearedFields[msg.FieldToid] = struct{}{}
  15034. }
  15035. // ToidCleared returns if the "toid" field was cleared in this mutation.
  15036. func (m *MsgMutation) ToidCleared() bool {
  15037. _, ok := m.clearedFields[msg.FieldToid]
  15038. return ok
  15039. }
  15040. // ResetToid resets all changes to the "toid" field.
  15041. func (m *MsgMutation) ResetToid() {
  15042. m.toid = nil
  15043. delete(m.clearedFields, msg.FieldToid)
  15044. }
  15045. // SetMsgtype sets the "msgtype" field.
  15046. func (m *MsgMutation) SetMsgtype(i int32) {
  15047. m.msgtype = &i
  15048. m.addmsgtype = nil
  15049. }
  15050. // Msgtype returns the value of the "msgtype" field in the mutation.
  15051. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  15052. v := m.msgtype
  15053. if v == nil {
  15054. return
  15055. }
  15056. return *v, true
  15057. }
  15058. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  15059. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15060. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15061. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  15062. if !m.op.Is(OpUpdateOne) {
  15063. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  15064. }
  15065. if m.id == nil || m.oldValue == nil {
  15066. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  15067. }
  15068. oldValue, err := m.oldValue(ctx)
  15069. if err != nil {
  15070. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  15071. }
  15072. return oldValue.Msgtype, nil
  15073. }
  15074. // AddMsgtype adds i to the "msgtype" field.
  15075. func (m *MsgMutation) AddMsgtype(i int32) {
  15076. if m.addmsgtype != nil {
  15077. *m.addmsgtype += i
  15078. } else {
  15079. m.addmsgtype = &i
  15080. }
  15081. }
  15082. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  15083. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  15084. v := m.addmsgtype
  15085. if v == nil {
  15086. return
  15087. }
  15088. return *v, true
  15089. }
  15090. // ClearMsgtype clears the value of the "msgtype" field.
  15091. func (m *MsgMutation) ClearMsgtype() {
  15092. m.msgtype = nil
  15093. m.addmsgtype = nil
  15094. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  15095. }
  15096. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  15097. func (m *MsgMutation) MsgtypeCleared() bool {
  15098. _, ok := m.clearedFields[msg.FieldMsgtype]
  15099. return ok
  15100. }
  15101. // ResetMsgtype resets all changes to the "msgtype" field.
  15102. func (m *MsgMutation) ResetMsgtype() {
  15103. m.msgtype = nil
  15104. m.addmsgtype = nil
  15105. delete(m.clearedFields, msg.FieldMsgtype)
  15106. }
  15107. // SetMsg sets the "msg" field.
  15108. func (m *MsgMutation) SetMsg(s string) {
  15109. m.msg = &s
  15110. }
  15111. // Msg returns the value of the "msg" field in the mutation.
  15112. func (m *MsgMutation) Msg() (r string, exists bool) {
  15113. v := m.msg
  15114. if v == nil {
  15115. return
  15116. }
  15117. return *v, true
  15118. }
  15119. // OldMsg returns the old "msg" field's value of the Msg entity.
  15120. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15121. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15122. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  15123. if !m.op.Is(OpUpdateOne) {
  15124. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  15125. }
  15126. if m.id == nil || m.oldValue == nil {
  15127. return v, errors.New("OldMsg requires an ID field in the mutation")
  15128. }
  15129. oldValue, err := m.oldValue(ctx)
  15130. if err != nil {
  15131. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  15132. }
  15133. return oldValue.Msg, nil
  15134. }
  15135. // ClearMsg clears the value of the "msg" field.
  15136. func (m *MsgMutation) ClearMsg() {
  15137. m.msg = nil
  15138. m.clearedFields[msg.FieldMsg] = struct{}{}
  15139. }
  15140. // MsgCleared returns if the "msg" field was cleared in this mutation.
  15141. func (m *MsgMutation) MsgCleared() bool {
  15142. _, ok := m.clearedFields[msg.FieldMsg]
  15143. return ok
  15144. }
  15145. // ResetMsg resets all changes to the "msg" field.
  15146. func (m *MsgMutation) ResetMsg() {
  15147. m.msg = nil
  15148. delete(m.clearedFields, msg.FieldMsg)
  15149. }
  15150. // SetBatchNo sets the "batch_no" field.
  15151. func (m *MsgMutation) SetBatchNo(s string) {
  15152. m.batch_no = &s
  15153. }
  15154. // BatchNo returns the value of the "batch_no" field in the mutation.
  15155. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  15156. v := m.batch_no
  15157. if v == nil {
  15158. return
  15159. }
  15160. return *v, true
  15161. }
  15162. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  15163. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15164. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15165. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  15166. if !m.op.Is(OpUpdateOne) {
  15167. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  15168. }
  15169. if m.id == nil || m.oldValue == nil {
  15170. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  15171. }
  15172. oldValue, err := m.oldValue(ctx)
  15173. if err != nil {
  15174. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  15175. }
  15176. return oldValue.BatchNo, nil
  15177. }
  15178. // ClearBatchNo clears the value of the "batch_no" field.
  15179. func (m *MsgMutation) ClearBatchNo() {
  15180. m.batch_no = nil
  15181. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  15182. }
  15183. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  15184. func (m *MsgMutation) BatchNoCleared() bool {
  15185. _, ok := m.clearedFields[msg.FieldBatchNo]
  15186. return ok
  15187. }
  15188. // ResetBatchNo resets all changes to the "batch_no" field.
  15189. func (m *MsgMutation) ResetBatchNo() {
  15190. m.batch_no = nil
  15191. delete(m.clearedFields, msg.FieldBatchNo)
  15192. }
  15193. // Where appends a list predicates to the MsgMutation builder.
  15194. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  15195. m.predicates = append(m.predicates, ps...)
  15196. }
  15197. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  15198. // users can use type-assertion to append predicates that do not depend on any generated package.
  15199. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  15200. p := make([]predicate.Msg, len(ps))
  15201. for i := range ps {
  15202. p[i] = ps[i]
  15203. }
  15204. m.Where(p...)
  15205. }
  15206. // Op returns the operation name.
  15207. func (m *MsgMutation) Op() Op {
  15208. return m.op
  15209. }
  15210. // SetOp allows setting the mutation operation.
  15211. func (m *MsgMutation) SetOp(op Op) {
  15212. m.op = op
  15213. }
  15214. // Type returns the node type of this mutation (Msg).
  15215. func (m *MsgMutation) Type() string {
  15216. return m.typ
  15217. }
  15218. // Fields returns all fields that were changed during this mutation. Note that in
  15219. // order to get all numeric fields that were incremented/decremented, call
  15220. // AddedFields().
  15221. func (m *MsgMutation) Fields() []string {
  15222. fields := make([]string, 0, 9)
  15223. if m.created_at != nil {
  15224. fields = append(fields, msg.FieldCreatedAt)
  15225. }
  15226. if m.updated_at != nil {
  15227. fields = append(fields, msg.FieldUpdatedAt)
  15228. }
  15229. if m.deleted_at != nil {
  15230. fields = append(fields, msg.FieldDeletedAt)
  15231. }
  15232. if m.status != nil {
  15233. fields = append(fields, msg.FieldStatus)
  15234. }
  15235. if m.fromwxid != nil {
  15236. fields = append(fields, msg.FieldFromwxid)
  15237. }
  15238. if m.toid != nil {
  15239. fields = append(fields, msg.FieldToid)
  15240. }
  15241. if m.msgtype != nil {
  15242. fields = append(fields, msg.FieldMsgtype)
  15243. }
  15244. if m.msg != nil {
  15245. fields = append(fields, msg.FieldMsg)
  15246. }
  15247. if m.batch_no != nil {
  15248. fields = append(fields, msg.FieldBatchNo)
  15249. }
  15250. return fields
  15251. }
  15252. // Field returns the value of a field with the given name. The second boolean
  15253. // return value indicates that this field was not set, or was not defined in the
  15254. // schema.
  15255. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  15256. switch name {
  15257. case msg.FieldCreatedAt:
  15258. return m.CreatedAt()
  15259. case msg.FieldUpdatedAt:
  15260. return m.UpdatedAt()
  15261. case msg.FieldDeletedAt:
  15262. return m.DeletedAt()
  15263. case msg.FieldStatus:
  15264. return m.Status()
  15265. case msg.FieldFromwxid:
  15266. return m.Fromwxid()
  15267. case msg.FieldToid:
  15268. return m.Toid()
  15269. case msg.FieldMsgtype:
  15270. return m.Msgtype()
  15271. case msg.FieldMsg:
  15272. return m.Msg()
  15273. case msg.FieldBatchNo:
  15274. return m.BatchNo()
  15275. }
  15276. return nil, false
  15277. }
  15278. // OldField returns the old value of the field from the database. An error is
  15279. // returned if the mutation operation is not UpdateOne, or the query to the
  15280. // database failed.
  15281. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15282. switch name {
  15283. case msg.FieldCreatedAt:
  15284. return m.OldCreatedAt(ctx)
  15285. case msg.FieldUpdatedAt:
  15286. return m.OldUpdatedAt(ctx)
  15287. case msg.FieldDeletedAt:
  15288. return m.OldDeletedAt(ctx)
  15289. case msg.FieldStatus:
  15290. return m.OldStatus(ctx)
  15291. case msg.FieldFromwxid:
  15292. return m.OldFromwxid(ctx)
  15293. case msg.FieldToid:
  15294. return m.OldToid(ctx)
  15295. case msg.FieldMsgtype:
  15296. return m.OldMsgtype(ctx)
  15297. case msg.FieldMsg:
  15298. return m.OldMsg(ctx)
  15299. case msg.FieldBatchNo:
  15300. return m.OldBatchNo(ctx)
  15301. }
  15302. return nil, fmt.Errorf("unknown Msg field %s", name)
  15303. }
  15304. // SetField sets the value of a field with the given name. It returns an error if
  15305. // the field is not defined in the schema, or if the type mismatched the field
  15306. // type.
  15307. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  15308. switch name {
  15309. case msg.FieldCreatedAt:
  15310. v, ok := value.(time.Time)
  15311. if !ok {
  15312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15313. }
  15314. m.SetCreatedAt(v)
  15315. return nil
  15316. case msg.FieldUpdatedAt:
  15317. v, ok := value.(time.Time)
  15318. if !ok {
  15319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15320. }
  15321. m.SetUpdatedAt(v)
  15322. return nil
  15323. case msg.FieldDeletedAt:
  15324. v, ok := value.(time.Time)
  15325. if !ok {
  15326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15327. }
  15328. m.SetDeletedAt(v)
  15329. return nil
  15330. case msg.FieldStatus:
  15331. v, ok := value.(uint8)
  15332. if !ok {
  15333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15334. }
  15335. m.SetStatus(v)
  15336. return nil
  15337. case msg.FieldFromwxid:
  15338. v, ok := value.(string)
  15339. if !ok {
  15340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15341. }
  15342. m.SetFromwxid(v)
  15343. return nil
  15344. case msg.FieldToid:
  15345. v, ok := value.(string)
  15346. if !ok {
  15347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15348. }
  15349. m.SetToid(v)
  15350. return nil
  15351. case msg.FieldMsgtype:
  15352. v, ok := value.(int32)
  15353. if !ok {
  15354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15355. }
  15356. m.SetMsgtype(v)
  15357. return nil
  15358. case msg.FieldMsg:
  15359. v, ok := value.(string)
  15360. if !ok {
  15361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15362. }
  15363. m.SetMsg(v)
  15364. return nil
  15365. case msg.FieldBatchNo:
  15366. v, ok := value.(string)
  15367. if !ok {
  15368. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15369. }
  15370. m.SetBatchNo(v)
  15371. return nil
  15372. }
  15373. return fmt.Errorf("unknown Msg field %s", name)
  15374. }
  15375. // AddedFields returns all numeric fields that were incremented/decremented during
  15376. // this mutation.
  15377. func (m *MsgMutation) AddedFields() []string {
  15378. var fields []string
  15379. if m.addstatus != nil {
  15380. fields = append(fields, msg.FieldStatus)
  15381. }
  15382. if m.addmsgtype != nil {
  15383. fields = append(fields, msg.FieldMsgtype)
  15384. }
  15385. return fields
  15386. }
  15387. // AddedField returns the numeric value that was incremented/decremented on a field
  15388. // with the given name. The second boolean return value indicates that this field
  15389. // was not set, or was not defined in the schema.
  15390. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  15391. switch name {
  15392. case msg.FieldStatus:
  15393. return m.AddedStatus()
  15394. case msg.FieldMsgtype:
  15395. return m.AddedMsgtype()
  15396. }
  15397. return nil, false
  15398. }
  15399. // AddField adds the value to the field with the given name. It returns an error if
  15400. // the field is not defined in the schema, or if the type mismatched the field
  15401. // type.
  15402. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  15403. switch name {
  15404. case msg.FieldStatus:
  15405. v, ok := value.(int8)
  15406. if !ok {
  15407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15408. }
  15409. m.AddStatus(v)
  15410. return nil
  15411. case msg.FieldMsgtype:
  15412. v, ok := value.(int32)
  15413. if !ok {
  15414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15415. }
  15416. m.AddMsgtype(v)
  15417. return nil
  15418. }
  15419. return fmt.Errorf("unknown Msg numeric field %s", name)
  15420. }
  15421. // ClearedFields returns all nullable fields that were cleared during this
  15422. // mutation.
  15423. func (m *MsgMutation) ClearedFields() []string {
  15424. var fields []string
  15425. if m.FieldCleared(msg.FieldDeletedAt) {
  15426. fields = append(fields, msg.FieldDeletedAt)
  15427. }
  15428. if m.FieldCleared(msg.FieldStatus) {
  15429. fields = append(fields, msg.FieldStatus)
  15430. }
  15431. if m.FieldCleared(msg.FieldFromwxid) {
  15432. fields = append(fields, msg.FieldFromwxid)
  15433. }
  15434. if m.FieldCleared(msg.FieldToid) {
  15435. fields = append(fields, msg.FieldToid)
  15436. }
  15437. if m.FieldCleared(msg.FieldMsgtype) {
  15438. fields = append(fields, msg.FieldMsgtype)
  15439. }
  15440. if m.FieldCleared(msg.FieldMsg) {
  15441. fields = append(fields, msg.FieldMsg)
  15442. }
  15443. if m.FieldCleared(msg.FieldBatchNo) {
  15444. fields = append(fields, msg.FieldBatchNo)
  15445. }
  15446. return fields
  15447. }
  15448. // FieldCleared returns a boolean indicating if a field with the given name was
  15449. // cleared in this mutation.
  15450. func (m *MsgMutation) FieldCleared(name string) bool {
  15451. _, ok := m.clearedFields[name]
  15452. return ok
  15453. }
  15454. // ClearField clears the value of the field with the given name. It returns an
  15455. // error if the field is not defined in the schema.
  15456. func (m *MsgMutation) ClearField(name string) error {
  15457. switch name {
  15458. case msg.FieldDeletedAt:
  15459. m.ClearDeletedAt()
  15460. return nil
  15461. case msg.FieldStatus:
  15462. m.ClearStatus()
  15463. return nil
  15464. case msg.FieldFromwxid:
  15465. m.ClearFromwxid()
  15466. return nil
  15467. case msg.FieldToid:
  15468. m.ClearToid()
  15469. return nil
  15470. case msg.FieldMsgtype:
  15471. m.ClearMsgtype()
  15472. return nil
  15473. case msg.FieldMsg:
  15474. m.ClearMsg()
  15475. return nil
  15476. case msg.FieldBatchNo:
  15477. m.ClearBatchNo()
  15478. return nil
  15479. }
  15480. return fmt.Errorf("unknown Msg nullable field %s", name)
  15481. }
  15482. // ResetField resets all changes in the mutation for the field with the given name.
  15483. // It returns an error if the field is not defined in the schema.
  15484. func (m *MsgMutation) ResetField(name string) error {
  15485. switch name {
  15486. case msg.FieldCreatedAt:
  15487. m.ResetCreatedAt()
  15488. return nil
  15489. case msg.FieldUpdatedAt:
  15490. m.ResetUpdatedAt()
  15491. return nil
  15492. case msg.FieldDeletedAt:
  15493. m.ResetDeletedAt()
  15494. return nil
  15495. case msg.FieldStatus:
  15496. m.ResetStatus()
  15497. return nil
  15498. case msg.FieldFromwxid:
  15499. m.ResetFromwxid()
  15500. return nil
  15501. case msg.FieldToid:
  15502. m.ResetToid()
  15503. return nil
  15504. case msg.FieldMsgtype:
  15505. m.ResetMsgtype()
  15506. return nil
  15507. case msg.FieldMsg:
  15508. m.ResetMsg()
  15509. return nil
  15510. case msg.FieldBatchNo:
  15511. m.ResetBatchNo()
  15512. return nil
  15513. }
  15514. return fmt.Errorf("unknown Msg field %s", name)
  15515. }
  15516. // AddedEdges returns all edge names that were set/added in this mutation.
  15517. func (m *MsgMutation) AddedEdges() []string {
  15518. edges := make([]string, 0, 0)
  15519. return edges
  15520. }
  15521. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15522. // name in this mutation.
  15523. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  15524. return nil
  15525. }
  15526. // RemovedEdges returns all edge names that were removed in this mutation.
  15527. func (m *MsgMutation) RemovedEdges() []string {
  15528. edges := make([]string, 0, 0)
  15529. return edges
  15530. }
  15531. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15532. // the given name in this mutation.
  15533. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  15534. return nil
  15535. }
  15536. // ClearedEdges returns all edge names that were cleared in this mutation.
  15537. func (m *MsgMutation) ClearedEdges() []string {
  15538. edges := make([]string, 0, 0)
  15539. return edges
  15540. }
  15541. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15542. // was cleared in this mutation.
  15543. func (m *MsgMutation) EdgeCleared(name string) bool {
  15544. return false
  15545. }
  15546. // ClearEdge clears the value of the edge with the given name. It returns an error
  15547. // if that edge is not defined in the schema.
  15548. func (m *MsgMutation) ClearEdge(name string) error {
  15549. return fmt.Errorf("unknown Msg unique edge %s", name)
  15550. }
  15551. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15552. // It returns an error if the edge is not defined in the schema.
  15553. func (m *MsgMutation) ResetEdge(name string) error {
  15554. return fmt.Errorf("unknown Msg edge %s", name)
  15555. }
  15556. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  15557. type ServerMutation struct {
  15558. config
  15559. op Op
  15560. typ string
  15561. id *uint64
  15562. created_at *time.Time
  15563. updated_at *time.Time
  15564. status *uint8
  15565. addstatus *int8
  15566. deleted_at *time.Time
  15567. name *string
  15568. public_ip *string
  15569. private_ip *string
  15570. admin_port *string
  15571. clearedFields map[string]struct{}
  15572. wxs map[uint64]struct{}
  15573. removedwxs map[uint64]struct{}
  15574. clearedwxs bool
  15575. done bool
  15576. oldValue func(context.Context) (*Server, error)
  15577. predicates []predicate.Server
  15578. }
  15579. var _ ent.Mutation = (*ServerMutation)(nil)
  15580. // serverOption allows management of the mutation configuration using functional options.
  15581. type serverOption func(*ServerMutation)
  15582. // newServerMutation creates new mutation for the Server entity.
  15583. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  15584. m := &ServerMutation{
  15585. config: c,
  15586. op: op,
  15587. typ: TypeServer,
  15588. clearedFields: make(map[string]struct{}),
  15589. }
  15590. for _, opt := range opts {
  15591. opt(m)
  15592. }
  15593. return m
  15594. }
  15595. // withServerID sets the ID field of the mutation.
  15596. func withServerID(id uint64) serverOption {
  15597. return func(m *ServerMutation) {
  15598. var (
  15599. err error
  15600. once sync.Once
  15601. value *Server
  15602. )
  15603. m.oldValue = func(ctx context.Context) (*Server, error) {
  15604. once.Do(func() {
  15605. if m.done {
  15606. err = errors.New("querying old values post mutation is not allowed")
  15607. } else {
  15608. value, err = m.Client().Server.Get(ctx, id)
  15609. }
  15610. })
  15611. return value, err
  15612. }
  15613. m.id = &id
  15614. }
  15615. }
  15616. // withServer sets the old Server of the mutation.
  15617. func withServer(node *Server) serverOption {
  15618. return func(m *ServerMutation) {
  15619. m.oldValue = func(context.Context) (*Server, error) {
  15620. return node, nil
  15621. }
  15622. m.id = &node.ID
  15623. }
  15624. }
  15625. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15626. // executed in a transaction (ent.Tx), a transactional client is returned.
  15627. func (m ServerMutation) Client() *Client {
  15628. client := &Client{config: m.config}
  15629. client.init()
  15630. return client
  15631. }
  15632. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15633. // it returns an error otherwise.
  15634. func (m ServerMutation) Tx() (*Tx, error) {
  15635. if _, ok := m.driver.(*txDriver); !ok {
  15636. return nil, errors.New("ent: mutation is not running in a transaction")
  15637. }
  15638. tx := &Tx{config: m.config}
  15639. tx.init()
  15640. return tx, nil
  15641. }
  15642. // SetID sets the value of the id field. Note that this
  15643. // operation is only accepted on creation of Server entities.
  15644. func (m *ServerMutation) SetID(id uint64) {
  15645. m.id = &id
  15646. }
  15647. // ID returns the ID value in the mutation. Note that the ID is only available
  15648. // if it was provided to the builder or after it was returned from the database.
  15649. func (m *ServerMutation) ID() (id uint64, exists bool) {
  15650. if m.id == nil {
  15651. return
  15652. }
  15653. return *m.id, true
  15654. }
  15655. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15656. // That means, if the mutation is applied within a transaction with an isolation level such
  15657. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15658. // or updated by the mutation.
  15659. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  15660. switch {
  15661. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15662. id, exists := m.ID()
  15663. if exists {
  15664. return []uint64{id}, nil
  15665. }
  15666. fallthrough
  15667. case m.op.Is(OpUpdate | OpDelete):
  15668. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  15669. default:
  15670. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15671. }
  15672. }
  15673. // SetCreatedAt sets the "created_at" field.
  15674. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  15675. m.created_at = &t
  15676. }
  15677. // CreatedAt returns the value of the "created_at" field in the mutation.
  15678. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  15679. v := m.created_at
  15680. if v == nil {
  15681. return
  15682. }
  15683. return *v, true
  15684. }
  15685. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  15686. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15687. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15688. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15689. if !m.op.Is(OpUpdateOne) {
  15690. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15691. }
  15692. if m.id == nil || m.oldValue == nil {
  15693. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15694. }
  15695. oldValue, err := m.oldValue(ctx)
  15696. if err != nil {
  15697. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15698. }
  15699. return oldValue.CreatedAt, nil
  15700. }
  15701. // ResetCreatedAt resets all changes to the "created_at" field.
  15702. func (m *ServerMutation) ResetCreatedAt() {
  15703. m.created_at = nil
  15704. }
  15705. // SetUpdatedAt sets the "updated_at" field.
  15706. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  15707. m.updated_at = &t
  15708. }
  15709. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15710. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  15711. v := m.updated_at
  15712. if v == nil {
  15713. return
  15714. }
  15715. return *v, true
  15716. }
  15717. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  15718. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15719. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15720. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15721. if !m.op.Is(OpUpdateOne) {
  15722. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15723. }
  15724. if m.id == nil || m.oldValue == nil {
  15725. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15726. }
  15727. oldValue, err := m.oldValue(ctx)
  15728. if err != nil {
  15729. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15730. }
  15731. return oldValue.UpdatedAt, nil
  15732. }
  15733. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15734. func (m *ServerMutation) ResetUpdatedAt() {
  15735. m.updated_at = nil
  15736. }
  15737. // SetStatus sets the "status" field.
  15738. func (m *ServerMutation) SetStatus(u uint8) {
  15739. m.status = &u
  15740. m.addstatus = nil
  15741. }
  15742. // Status returns the value of the "status" field in the mutation.
  15743. func (m *ServerMutation) Status() (r uint8, exists bool) {
  15744. v := m.status
  15745. if v == nil {
  15746. return
  15747. }
  15748. return *v, true
  15749. }
  15750. // OldStatus returns the old "status" field's value of the Server entity.
  15751. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15752. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15753. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15754. if !m.op.Is(OpUpdateOne) {
  15755. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15756. }
  15757. if m.id == nil || m.oldValue == nil {
  15758. return v, errors.New("OldStatus requires an ID field in the mutation")
  15759. }
  15760. oldValue, err := m.oldValue(ctx)
  15761. if err != nil {
  15762. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15763. }
  15764. return oldValue.Status, nil
  15765. }
  15766. // AddStatus adds u to the "status" field.
  15767. func (m *ServerMutation) AddStatus(u int8) {
  15768. if m.addstatus != nil {
  15769. *m.addstatus += u
  15770. } else {
  15771. m.addstatus = &u
  15772. }
  15773. }
  15774. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15775. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  15776. v := m.addstatus
  15777. if v == nil {
  15778. return
  15779. }
  15780. return *v, true
  15781. }
  15782. // ClearStatus clears the value of the "status" field.
  15783. func (m *ServerMutation) ClearStatus() {
  15784. m.status = nil
  15785. m.addstatus = nil
  15786. m.clearedFields[server.FieldStatus] = struct{}{}
  15787. }
  15788. // StatusCleared returns if the "status" field was cleared in this mutation.
  15789. func (m *ServerMutation) StatusCleared() bool {
  15790. _, ok := m.clearedFields[server.FieldStatus]
  15791. return ok
  15792. }
  15793. // ResetStatus resets all changes to the "status" field.
  15794. func (m *ServerMutation) ResetStatus() {
  15795. m.status = nil
  15796. m.addstatus = nil
  15797. delete(m.clearedFields, server.FieldStatus)
  15798. }
  15799. // SetDeletedAt sets the "deleted_at" field.
  15800. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  15801. m.deleted_at = &t
  15802. }
  15803. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15804. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  15805. v := m.deleted_at
  15806. if v == nil {
  15807. return
  15808. }
  15809. return *v, true
  15810. }
  15811. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  15812. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15814. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15815. if !m.op.Is(OpUpdateOne) {
  15816. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15817. }
  15818. if m.id == nil || m.oldValue == nil {
  15819. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15820. }
  15821. oldValue, err := m.oldValue(ctx)
  15822. if err != nil {
  15823. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15824. }
  15825. return oldValue.DeletedAt, nil
  15826. }
  15827. // ClearDeletedAt clears the value of the "deleted_at" field.
  15828. func (m *ServerMutation) ClearDeletedAt() {
  15829. m.deleted_at = nil
  15830. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  15831. }
  15832. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15833. func (m *ServerMutation) DeletedAtCleared() bool {
  15834. _, ok := m.clearedFields[server.FieldDeletedAt]
  15835. return ok
  15836. }
  15837. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15838. func (m *ServerMutation) ResetDeletedAt() {
  15839. m.deleted_at = nil
  15840. delete(m.clearedFields, server.FieldDeletedAt)
  15841. }
  15842. // SetName sets the "name" field.
  15843. func (m *ServerMutation) SetName(s string) {
  15844. m.name = &s
  15845. }
  15846. // Name returns the value of the "name" field in the mutation.
  15847. func (m *ServerMutation) Name() (r string, exists bool) {
  15848. v := m.name
  15849. if v == nil {
  15850. return
  15851. }
  15852. return *v, true
  15853. }
  15854. // OldName returns the old "name" field's value of the Server entity.
  15855. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15857. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  15858. if !m.op.Is(OpUpdateOne) {
  15859. return v, errors.New("OldName is only allowed on UpdateOne operations")
  15860. }
  15861. if m.id == nil || m.oldValue == nil {
  15862. return v, errors.New("OldName requires an ID field in the mutation")
  15863. }
  15864. oldValue, err := m.oldValue(ctx)
  15865. if err != nil {
  15866. return v, fmt.Errorf("querying old value for OldName: %w", err)
  15867. }
  15868. return oldValue.Name, nil
  15869. }
  15870. // ResetName resets all changes to the "name" field.
  15871. func (m *ServerMutation) ResetName() {
  15872. m.name = nil
  15873. }
  15874. // SetPublicIP sets the "public_ip" field.
  15875. func (m *ServerMutation) SetPublicIP(s string) {
  15876. m.public_ip = &s
  15877. }
  15878. // PublicIP returns the value of the "public_ip" field in the mutation.
  15879. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  15880. v := m.public_ip
  15881. if v == nil {
  15882. return
  15883. }
  15884. return *v, true
  15885. }
  15886. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  15887. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15888. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15889. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  15890. if !m.op.Is(OpUpdateOne) {
  15891. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  15892. }
  15893. if m.id == nil || m.oldValue == nil {
  15894. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  15895. }
  15896. oldValue, err := m.oldValue(ctx)
  15897. if err != nil {
  15898. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  15899. }
  15900. return oldValue.PublicIP, nil
  15901. }
  15902. // ResetPublicIP resets all changes to the "public_ip" field.
  15903. func (m *ServerMutation) ResetPublicIP() {
  15904. m.public_ip = nil
  15905. }
  15906. // SetPrivateIP sets the "private_ip" field.
  15907. func (m *ServerMutation) SetPrivateIP(s string) {
  15908. m.private_ip = &s
  15909. }
  15910. // PrivateIP returns the value of the "private_ip" field in the mutation.
  15911. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  15912. v := m.private_ip
  15913. if v == nil {
  15914. return
  15915. }
  15916. return *v, true
  15917. }
  15918. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  15919. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15920. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15921. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  15922. if !m.op.Is(OpUpdateOne) {
  15923. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  15924. }
  15925. if m.id == nil || m.oldValue == nil {
  15926. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  15927. }
  15928. oldValue, err := m.oldValue(ctx)
  15929. if err != nil {
  15930. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  15931. }
  15932. return oldValue.PrivateIP, nil
  15933. }
  15934. // ResetPrivateIP resets all changes to the "private_ip" field.
  15935. func (m *ServerMutation) ResetPrivateIP() {
  15936. m.private_ip = nil
  15937. }
  15938. // SetAdminPort sets the "admin_port" field.
  15939. func (m *ServerMutation) SetAdminPort(s string) {
  15940. m.admin_port = &s
  15941. }
  15942. // AdminPort returns the value of the "admin_port" field in the mutation.
  15943. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  15944. v := m.admin_port
  15945. if v == nil {
  15946. return
  15947. }
  15948. return *v, true
  15949. }
  15950. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  15951. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  15952. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15953. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  15954. if !m.op.Is(OpUpdateOne) {
  15955. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  15956. }
  15957. if m.id == nil || m.oldValue == nil {
  15958. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  15959. }
  15960. oldValue, err := m.oldValue(ctx)
  15961. if err != nil {
  15962. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  15963. }
  15964. return oldValue.AdminPort, nil
  15965. }
  15966. // ResetAdminPort resets all changes to the "admin_port" field.
  15967. func (m *ServerMutation) ResetAdminPort() {
  15968. m.admin_port = nil
  15969. }
  15970. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  15971. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  15972. if m.wxs == nil {
  15973. m.wxs = make(map[uint64]struct{})
  15974. }
  15975. for i := range ids {
  15976. m.wxs[ids[i]] = struct{}{}
  15977. }
  15978. }
  15979. // ClearWxs clears the "wxs" edge to the Wx entity.
  15980. func (m *ServerMutation) ClearWxs() {
  15981. m.clearedwxs = true
  15982. }
  15983. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  15984. func (m *ServerMutation) WxsCleared() bool {
  15985. return m.clearedwxs
  15986. }
  15987. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  15988. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  15989. if m.removedwxs == nil {
  15990. m.removedwxs = make(map[uint64]struct{})
  15991. }
  15992. for i := range ids {
  15993. delete(m.wxs, ids[i])
  15994. m.removedwxs[ids[i]] = struct{}{}
  15995. }
  15996. }
  15997. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  15998. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  15999. for id := range m.removedwxs {
  16000. ids = append(ids, id)
  16001. }
  16002. return
  16003. }
  16004. // WxsIDs returns the "wxs" edge IDs in the mutation.
  16005. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  16006. for id := range m.wxs {
  16007. ids = append(ids, id)
  16008. }
  16009. return
  16010. }
  16011. // ResetWxs resets all changes to the "wxs" edge.
  16012. func (m *ServerMutation) ResetWxs() {
  16013. m.wxs = nil
  16014. m.clearedwxs = false
  16015. m.removedwxs = nil
  16016. }
  16017. // Where appends a list predicates to the ServerMutation builder.
  16018. func (m *ServerMutation) Where(ps ...predicate.Server) {
  16019. m.predicates = append(m.predicates, ps...)
  16020. }
  16021. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  16022. // users can use type-assertion to append predicates that do not depend on any generated package.
  16023. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  16024. p := make([]predicate.Server, len(ps))
  16025. for i := range ps {
  16026. p[i] = ps[i]
  16027. }
  16028. m.Where(p...)
  16029. }
  16030. // Op returns the operation name.
  16031. func (m *ServerMutation) Op() Op {
  16032. return m.op
  16033. }
  16034. // SetOp allows setting the mutation operation.
  16035. func (m *ServerMutation) SetOp(op Op) {
  16036. m.op = op
  16037. }
  16038. // Type returns the node type of this mutation (Server).
  16039. func (m *ServerMutation) Type() string {
  16040. return m.typ
  16041. }
  16042. // Fields returns all fields that were changed during this mutation. Note that in
  16043. // order to get all numeric fields that were incremented/decremented, call
  16044. // AddedFields().
  16045. func (m *ServerMutation) Fields() []string {
  16046. fields := make([]string, 0, 8)
  16047. if m.created_at != nil {
  16048. fields = append(fields, server.FieldCreatedAt)
  16049. }
  16050. if m.updated_at != nil {
  16051. fields = append(fields, server.FieldUpdatedAt)
  16052. }
  16053. if m.status != nil {
  16054. fields = append(fields, server.FieldStatus)
  16055. }
  16056. if m.deleted_at != nil {
  16057. fields = append(fields, server.FieldDeletedAt)
  16058. }
  16059. if m.name != nil {
  16060. fields = append(fields, server.FieldName)
  16061. }
  16062. if m.public_ip != nil {
  16063. fields = append(fields, server.FieldPublicIP)
  16064. }
  16065. if m.private_ip != nil {
  16066. fields = append(fields, server.FieldPrivateIP)
  16067. }
  16068. if m.admin_port != nil {
  16069. fields = append(fields, server.FieldAdminPort)
  16070. }
  16071. return fields
  16072. }
  16073. // Field returns the value of a field with the given name. The second boolean
  16074. // return value indicates that this field was not set, or was not defined in the
  16075. // schema.
  16076. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  16077. switch name {
  16078. case server.FieldCreatedAt:
  16079. return m.CreatedAt()
  16080. case server.FieldUpdatedAt:
  16081. return m.UpdatedAt()
  16082. case server.FieldStatus:
  16083. return m.Status()
  16084. case server.FieldDeletedAt:
  16085. return m.DeletedAt()
  16086. case server.FieldName:
  16087. return m.Name()
  16088. case server.FieldPublicIP:
  16089. return m.PublicIP()
  16090. case server.FieldPrivateIP:
  16091. return m.PrivateIP()
  16092. case server.FieldAdminPort:
  16093. return m.AdminPort()
  16094. }
  16095. return nil, false
  16096. }
  16097. // OldField returns the old value of the field from the database. An error is
  16098. // returned if the mutation operation is not UpdateOne, or the query to the
  16099. // database failed.
  16100. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16101. switch name {
  16102. case server.FieldCreatedAt:
  16103. return m.OldCreatedAt(ctx)
  16104. case server.FieldUpdatedAt:
  16105. return m.OldUpdatedAt(ctx)
  16106. case server.FieldStatus:
  16107. return m.OldStatus(ctx)
  16108. case server.FieldDeletedAt:
  16109. return m.OldDeletedAt(ctx)
  16110. case server.FieldName:
  16111. return m.OldName(ctx)
  16112. case server.FieldPublicIP:
  16113. return m.OldPublicIP(ctx)
  16114. case server.FieldPrivateIP:
  16115. return m.OldPrivateIP(ctx)
  16116. case server.FieldAdminPort:
  16117. return m.OldAdminPort(ctx)
  16118. }
  16119. return nil, fmt.Errorf("unknown Server field %s", name)
  16120. }
  16121. // SetField sets the value of a field with the given name. It returns an error if
  16122. // the field is not defined in the schema, or if the type mismatched the field
  16123. // type.
  16124. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  16125. switch name {
  16126. case server.FieldCreatedAt:
  16127. v, ok := value.(time.Time)
  16128. if !ok {
  16129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16130. }
  16131. m.SetCreatedAt(v)
  16132. return nil
  16133. case server.FieldUpdatedAt:
  16134. v, ok := value.(time.Time)
  16135. if !ok {
  16136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16137. }
  16138. m.SetUpdatedAt(v)
  16139. return nil
  16140. case server.FieldStatus:
  16141. v, ok := value.(uint8)
  16142. if !ok {
  16143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16144. }
  16145. m.SetStatus(v)
  16146. return nil
  16147. case server.FieldDeletedAt:
  16148. v, ok := value.(time.Time)
  16149. if !ok {
  16150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16151. }
  16152. m.SetDeletedAt(v)
  16153. return nil
  16154. case server.FieldName:
  16155. v, ok := value.(string)
  16156. if !ok {
  16157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16158. }
  16159. m.SetName(v)
  16160. return nil
  16161. case server.FieldPublicIP:
  16162. v, ok := value.(string)
  16163. if !ok {
  16164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16165. }
  16166. m.SetPublicIP(v)
  16167. return nil
  16168. case server.FieldPrivateIP:
  16169. v, ok := value.(string)
  16170. if !ok {
  16171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16172. }
  16173. m.SetPrivateIP(v)
  16174. return nil
  16175. case server.FieldAdminPort:
  16176. v, ok := value.(string)
  16177. if !ok {
  16178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16179. }
  16180. m.SetAdminPort(v)
  16181. return nil
  16182. }
  16183. return fmt.Errorf("unknown Server field %s", name)
  16184. }
  16185. // AddedFields returns all numeric fields that were incremented/decremented during
  16186. // this mutation.
  16187. func (m *ServerMutation) AddedFields() []string {
  16188. var fields []string
  16189. if m.addstatus != nil {
  16190. fields = append(fields, server.FieldStatus)
  16191. }
  16192. return fields
  16193. }
  16194. // AddedField returns the numeric value that was incremented/decremented on a field
  16195. // with the given name. The second boolean return value indicates that this field
  16196. // was not set, or was not defined in the schema.
  16197. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  16198. switch name {
  16199. case server.FieldStatus:
  16200. return m.AddedStatus()
  16201. }
  16202. return nil, false
  16203. }
  16204. // AddField adds the value to the field with the given name. It returns an error if
  16205. // the field is not defined in the schema, or if the type mismatched the field
  16206. // type.
  16207. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  16208. switch name {
  16209. case server.FieldStatus:
  16210. v, ok := value.(int8)
  16211. if !ok {
  16212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16213. }
  16214. m.AddStatus(v)
  16215. return nil
  16216. }
  16217. return fmt.Errorf("unknown Server numeric field %s", name)
  16218. }
  16219. // ClearedFields returns all nullable fields that were cleared during this
  16220. // mutation.
  16221. func (m *ServerMutation) ClearedFields() []string {
  16222. var fields []string
  16223. if m.FieldCleared(server.FieldStatus) {
  16224. fields = append(fields, server.FieldStatus)
  16225. }
  16226. if m.FieldCleared(server.FieldDeletedAt) {
  16227. fields = append(fields, server.FieldDeletedAt)
  16228. }
  16229. return fields
  16230. }
  16231. // FieldCleared returns a boolean indicating if a field with the given name was
  16232. // cleared in this mutation.
  16233. func (m *ServerMutation) FieldCleared(name string) bool {
  16234. _, ok := m.clearedFields[name]
  16235. return ok
  16236. }
  16237. // ClearField clears the value of the field with the given name. It returns an
  16238. // error if the field is not defined in the schema.
  16239. func (m *ServerMutation) ClearField(name string) error {
  16240. switch name {
  16241. case server.FieldStatus:
  16242. m.ClearStatus()
  16243. return nil
  16244. case server.FieldDeletedAt:
  16245. m.ClearDeletedAt()
  16246. return nil
  16247. }
  16248. return fmt.Errorf("unknown Server nullable field %s", name)
  16249. }
  16250. // ResetField resets all changes in the mutation for the field with the given name.
  16251. // It returns an error if the field is not defined in the schema.
  16252. func (m *ServerMutation) ResetField(name string) error {
  16253. switch name {
  16254. case server.FieldCreatedAt:
  16255. m.ResetCreatedAt()
  16256. return nil
  16257. case server.FieldUpdatedAt:
  16258. m.ResetUpdatedAt()
  16259. return nil
  16260. case server.FieldStatus:
  16261. m.ResetStatus()
  16262. return nil
  16263. case server.FieldDeletedAt:
  16264. m.ResetDeletedAt()
  16265. return nil
  16266. case server.FieldName:
  16267. m.ResetName()
  16268. return nil
  16269. case server.FieldPublicIP:
  16270. m.ResetPublicIP()
  16271. return nil
  16272. case server.FieldPrivateIP:
  16273. m.ResetPrivateIP()
  16274. return nil
  16275. case server.FieldAdminPort:
  16276. m.ResetAdminPort()
  16277. return nil
  16278. }
  16279. return fmt.Errorf("unknown Server field %s", name)
  16280. }
  16281. // AddedEdges returns all edge names that were set/added in this mutation.
  16282. func (m *ServerMutation) AddedEdges() []string {
  16283. edges := make([]string, 0, 1)
  16284. if m.wxs != nil {
  16285. edges = append(edges, server.EdgeWxs)
  16286. }
  16287. return edges
  16288. }
  16289. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16290. // name in this mutation.
  16291. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  16292. switch name {
  16293. case server.EdgeWxs:
  16294. ids := make([]ent.Value, 0, len(m.wxs))
  16295. for id := range m.wxs {
  16296. ids = append(ids, id)
  16297. }
  16298. return ids
  16299. }
  16300. return nil
  16301. }
  16302. // RemovedEdges returns all edge names that were removed in this mutation.
  16303. func (m *ServerMutation) RemovedEdges() []string {
  16304. edges := make([]string, 0, 1)
  16305. if m.removedwxs != nil {
  16306. edges = append(edges, server.EdgeWxs)
  16307. }
  16308. return edges
  16309. }
  16310. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16311. // the given name in this mutation.
  16312. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  16313. switch name {
  16314. case server.EdgeWxs:
  16315. ids := make([]ent.Value, 0, len(m.removedwxs))
  16316. for id := range m.removedwxs {
  16317. ids = append(ids, id)
  16318. }
  16319. return ids
  16320. }
  16321. return nil
  16322. }
  16323. // ClearedEdges returns all edge names that were cleared in this mutation.
  16324. func (m *ServerMutation) ClearedEdges() []string {
  16325. edges := make([]string, 0, 1)
  16326. if m.clearedwxs {
  16327. edges = append(edges, server.EdgeWxs)
  16328. }
  16329. return edges
  16330. }
  16331. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16332. // was cleared in this mutation.
  16333. func (m *ServerMutation) EdgeCleared(name string) bool {
  16334. switch name {
  16335. case server.EdgeWxs:
  16336. return m.clearedwxs
  16337. }
  16338. return false
  16339. }
  16340. // ClearEdge clears the value of the edge with the given name. It returns an error
  16341. // if that edge is not defined in the schema.
  16342. func (m *ServerMutation) ClearEdge(name string) error {
  16343. switch name {
  16344. }
  16345. return fmt.Errorf("unknown Server unique edge %s", name)
  16346. }
  16347. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16348. // It returns an error if the edge is not defined in the schema.
  16349. func (m *ServerMutation) ResetEdge(name string) error {
  16350. switch name {
  16351. case server.EdgeWxs:
  16352. m.ResetWxs()
  16353. return nil
  16354. }
  16355. return fmt.Errorf("unknown Server edge %s", name)
  16356. }
  16357. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  16358. type SopNodeMutation struct {
  16359. config
  16360. op Op
  16361. typ string
  16362. id *uint64
  16363. created_at *time.Time
  16364. updated_at *time.Time
  16365. status *uint8
  16366. addstatus *int8
  16367. deleted_at *time.Time
  16368. parent_id *uint64
  16369. addparent_id *int64
  16370. name *string
  16371. condition_type *int
  16372. addcondition_type *int
  16373. condition_list *[]string
  16374. appendcondition_list []string
  16375. no_reply_condition *uint64
  16376. addno_reply_condition *int64
  16377. no_reply_unit *string
  16378. action_message *[]custom_types.Action
  16379. appendaction_message []custom_types.Action
  16380. action_label_add *[]uint64
  16381. appendaction_label_add []uint64
  16382. action_label_del *[]uint64
  16383. appendaction_label_del []uint64
  16384. action_forward **custom_types.ActionForward
  16385. clearedFields map[string]struct{}
  16386. sop_stage *uint64
  16387. clearedsop_stage bool
  16388. node_messages map[uint64]struct{}
  16389. removednode_messages map[uint64]struct{}
  16390. clearednode_messages bool
  16391. done bool
  16392. oldValue func(context.Context) (*SopNode, error)
  16393. predicates []predicate.SopNode
  16394. }
  16395. var _ ent.Mutation = (*SopNodeMutation)(nil)
  16396. // sopnodeOption allows management of the mutation configuration using functional options.
  16397. type sopnodeOption func(*SopNodeMutation)
  16398. // newSopNodeMutation creates new mutation for the SopNode entity.
  16399. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  16400. m := &SopNodeMutation{
  16401. config: c,
  16402. op: op,
  16403. typ: TypeSopNode,
  16404. clearedFields: make(map[string]struct{}),
  16405. }
  16406. for _, opt := range opts {
  16407. opt(m)
  16408. }
  16409. return m
  16410. }
  16411. // withSopNodeID sets the ID field of the mutation.
  16412. func withSopNodeID(id uint64) sopnodeOption {
  16413. return func(m *SopNodeMutation) {
  16414. var (
  16415. err error
  16416. once sync.Once
  16417. value *SopNode
  16418. )
  16419. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  16420. once.Do(func() {
  16421. if m.done {
  16422. err = errors.New("querying old values post mutation is not allowed")
  16423. } else {
  16424. value, err = m.Client().SopNode.Get(ctx, id)
  16425. }
  16426. })
  16427. return value, err
  16428. }
  16429. m.id = &id
  16430. }
  16431. }
  16432. // withSopNode sets the old SopNode of the mutation.
  16433. func withSopNode(node *SopNode) sopnodeOption {
  16434. return func(m *SopNodeMutation) {
  16435. m.oldValue = func(context.Context) (*SopNode, error) {
  16436. return node, nil
  16437. }
  16438. m.id = &node.ID
  16439. }
  16440. }
  16441. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16442. // executed in a transaction (ent.Tx), a transactional client is returned.
  16443. func (m SopNodeMutation) Client() *Client {
  16444. client := &Client{config: m.config}
  16445. client.init()
  16446. return client
  16447. }
  16448. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16449. // it returns an error otherwise.
  16450. func (m SopNodeMutation) Tx() (*Tx, error) {
  16451. if _, ok := m.driver.(*txDriver); !ok {
  16452. return nil, errors.New("ent: mutation is not running in a transaction")
  16453. }
  16454. tx := &Tx{config: m.config}
  16455. tx.init()
  16456. return tx, nil
  16457. }
  16458. // SetID sets the value of the id field. Note that this
  16459. // operation is only accepted on creation of SopNode entities.
  16460. func (m *SopNodeMutation) SetID(id uint64) {
  16461. m.id = &id
  16462. }
  16463. // ID returns the ID value in the mutation. Note that the ID is only available
  16464. // if it was provided to the builder or after it was returned from the database.
  16465. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  16466. if m.id == nil {
  16467. return
  16468. }
  16469. return *m.id, true
  16470. }
  16471. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16472. // That means, if the mutation is applied within a transaction with an isolation level such
  16473. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16474. // or updated by the mutation.
  16475. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  16476. switch {
  16477. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16478. id, exists := m.ID()
  16479. if exists {
  16480. return []uint64{id}, nil
  16481. }
  16482. fallthrough
  16483. case m.op.Is(OpUpdate | OpDelete):
  16484. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  16485. default:
  16486. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16487. }
  16488. }
  16489. // SetCreatedAt sets the "created_at" field.
  16490. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  16491. m.created_at = &t
  16492. }
  16493. // CreatedAt returns the value of the "created_at" field in the mutation.
  16494. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  16495. v := m.created_at
  16496. if v == nil {
  16497. return
  16498. }
  16499. return *v, true
  16500. }
  16501. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  16502. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16503. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16504. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16505. if !m.op.Is(OpUpdateOne) {
  16506. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16507. }
  16508. if m.id == nil || m.oldValue == nil {
  16509. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16510. }
  16511. oldValue, err := m.oldValue(ctx)
  16512. if err != nil {
  16513. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16514. }
  16515. return oldValue.CreatedAt, nil
  16516. }
  16517. // ResetCreatedAt resets all changes to the "created_at" field.
  16518. func (m *SopNodeMutation) ResetCreatedAt() {
  16519. m.created_at = nil
  16520. }
  16521. // SetUpdatedAt sets the "updated_at" field.
  16522. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  16523. m.updated_at = &t
  16524. }
  16525. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16526. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  16527. v := m.updated_at
  16528. if v == nil {
  16529. return
  16530. }
  16531. return *v, true
  16532. }
  16533. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  16534. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16535. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16536. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16537. if !m.op.Is(OpUpdateOne) {
  16538. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16539. }
  16540. if m.id == nil || m.oldValue == nil {
  16541. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16542. }
  16543. oldValue, err := m.oldValue(ctx)
  16544. if err != nil {
  16545. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16546. }
  16547. return oldValue.UpdatedAt, nil
  16548. }
  16549. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16550. func (m *SopNodeMutation) ResetUpdatedAt() {
  16551. m.updated_at = nil
  16552. }
  16553. // SetStatus sets the "status" field.
  16554. func (m *SopNodeMutation) SetStatus(u uint8) {
  16555. m.status = &u
  16556. m.addstatus = nil
  16557. }
  16558. // Status returns the value of the "status" field in the mutation.
  16559. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  16560. v := m.status
  16561. if v == nil {
  16562. return
  16563. }
  16564. return *v, true
  16565. }
  16566. // OldStatus returns the old "status" field's value of the SopNode entity.
  16567. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16568. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16569. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16570. if !m.op.Is(OpUpdateOne) {
  16571. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16572. }
  16573. if m.id == nil || m.oldValue == nil {
  16574. return v, errors.New("OldStatus requires an ID field in the mutation")
  16575. }
  16576. oldValue, err := m.oldValue(ctx)
  16577. if err != nil {
  16578. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16579. }
  16580. return oldValue.Status, nil
  16581. }
  16582. // AddStatus adds u to the "status" field.
  16583. func (m *SopNodeMutation) AddStatus(u int8) {
  16584. if m.addstatus != nil {
  16585. *m.addstatus += u
  16586. } else {
  16587. m.addstatus = &u
  16588. }
  16589. }
  16590. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16591. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  16592. v := m.addstatus
  16593. if v == nil {
  16594. return
  16595. }
  16596. return *v, true
  16597. }
  16598. // ClearStatus clears the value of the "status" field.
  16599. func (m *SopNodeMutation) ClearStatus() {
  16600. m.status = nil
  16601. m.addstatus = nil
  16602. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  16603. }
  16604. // StatusCleared returns if the "status" field was cleared in this mutation.
  16605. func (m *SopNodeMutation) StatusCleared() bool {
  16606. _, ok := m.clearedFields[sopnode.FieldStatus]
  16607. return ok
  16608. }
  16609. // ResetStatus resets all changes to the "status" field.
  16610. func (m *SopNodeMutation) ResetStatus() {
  16611. m.status = nil
  16612. m.addstatus = nil
  16613. delete(m.clearedFields, sopnode.FieldStatus)
  16614. }
  16615. // SetDeletedAt sets the "deleted_at" field.
  16616. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  16617. m.deleted_at = &t
  16618. }
  16619. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16620. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  16621. v := m.deleted_at
  16622. if v == nil {
  16623. return
  16624. }
  16625. return *v, true
  16626. }
  16627. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  16628. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16629. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16630. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16631. if !m.op.Is(OpUpdateOne) {
  16632. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16633. }
  16634. if m.id == nil || m.oldValue == nil {
  16635. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16636. }
  16637. oldValue, err := m.oldValue(ctx)
  16638. if err != nil {
  16639. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16640. }
  16641. return oldValue.DeletedAt, nil
  16642. }
  16643. // ClearDeletedAt clears the value of the "deleted_at" field.
  16644. func (m *SopNodeMutation) ClearDeletedAt() {
  16645. m.deleted_at = nil
  16646. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  16647. }
  16648. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16649. func (m *SopNodeMutation) DeletedAtCleared() bool {
  16650. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  16651. return ok
  16652. }
  16653. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16654. func (m *SopNodeMutation) ResetDeletedAt() {
  16655. m.deleted_at = nil
  16656. delete(m.clearedFields, sopnode.FieldDeletedAt)
  16657. }
  16658. // SetStageID sets the "stage_id" field.
  16659. func (m *SopNodeMutation) SetStageID(u uint64) {
  16660. m.sop_stage = &u
  16661. }
  16662. // StageID returns the value of the "stage_id" field in the mutation.
  16663. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  16664. v := m.sop_stage
  16665. if v == nil {
  16666. return
  16667. }
  16668. return *v, true
  16669. }
  16670. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  16671. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16672. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16673. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  16674. if !m.op.Is(OpUpdateOne) {
  16675. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  16676. }
  16677. if m.id == nil || m.oldValue == nil {
  16678. return v, errors.New("OldStageID requires an ID field in the mutation")
  16679. }
  16680. oldValue, err := m.oldValue(ctx)
  16681. if err != nil {
  16682. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  16683. }
  16684. return oldValue.StageID, nil
  16685. }
  16686. // ResetStageID resets all changes to the "stage_id" field.
  16687. func (m *SopNodeMutation) ResetStageID() {
  16688. m.sop_stage = nil
  16689. }
  16690. // SetParentID sets the "parent_id" field.
  16691. func (m *SopNodeMutation) SetParentID(u uint64) {
  16692. m.parent_id = &u
  16693. m.addparent_id = nil
  16694. }
  16695. // ParentID returns the value of the "parent_id" field in the mutation.
  16696. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  16697. v := m.parent_id
  16698. if v == nil {
  16699. return
  16700. }
  16701. return *v, true
  16702. }
  16703. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  16704. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16705. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16706. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  16707. if !m.op.Is(OpUpdateOne) {
  16708. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  16709. }
  16710. if m.id == nil || m.oldValue == nil {
  16711. return v, errors.New("OldParentID requires an ID field in the mutation")
  16712. }
  16713. oldValue, err := m.oldValue(ctx)
  16714. if err != nil {
  16715. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  16716. }
  16717. return oldValue.ParentID, nil
  16718. }
  16719. // AddParentID adds u to the "parent_id" field.
  16720. func (m *SopNodeMutation) AddParentID(u int64) {
  16721. if m.addparent_id != nil {
  16722. *m.addparent_id += u
  16723. } else {
  16724. m.addparent_id = &u
  16725. }
  16726. }
  16727. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  16728. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  16729. v := m.addparent_id
  16730. if v == nil {
  16731. return
  16732. }
  16733. return *v, true
  16734. }
  16735. // ResetParentID resets all changes to the "parent_id" field.
  16736. func (m *SopNodeMutation) ResetParentID() {
  16737. m.parent_id = nil
  16738. m.addparent_id = nil
  16739. }
  16740. // SetName sets the "name" field.
  16741. func (m *SopNodeMutation) SetName(s string) {
  16742. m.name = &s
  16743. }
  16744. // Name returns the value of the "name" field in the mutation.
  16745. func (m *SopNodeMutation) Name() (r string, exists bool) {
  16746. v := m.name
  16747. if v == nil {
  16748. return
  16749. }
  16750. return *v, true
  16751. }
  16752. // OldName returns the old "name" field's value of the SopNode entity.
  16753. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16754. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16755. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  16756. if !m.op.Is(OpUpdateOne) {
  16757. return v, errors.New("OldName is only allowed on UpdateOne operations")
  16758. }
  16759. if m.id == nil || m.oldValue == nil {
  16760. return v, errors.New("OldName requires an ID field in the mutation")
  16761. }
  16762. oldValue, err := m.oldValue(ctx)
  16763. if err != nil {
  16764. return v, fmt.Errorf("querying old value for OldName: %w", err)
  16765. }
  16766. return oldValue.Name, nil
  16767. }
  16768. // ResetName resets all changes to the "name" field.
  16769. func (m *SopNodeMutation) ResetName() {
  16770. m.name = nil
  16771. }
  16772. // SetConditionType sets the "condition_type" field.
  16773. func (m *SopNodeMutation) SetConditionType(i int) {
  16774. m.condition_type = &i
  16775. m.addcondition_type = nil
  16776. }
  16777. // ConditionType returns the value of the "condition_type" field in the mutation.
  16778. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  16779. v := m.condition_type
  16780. if v == nil {
  16781. return
  16782. }
  16783. return *v, true
  16784. }
  16785. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  16786. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16787. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16788. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  16789. if !m.op.Is(OpUpdateOne) {
  16790. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  16791. }
  16792. if m.id == nil || m.oldValue == nil {
  16793. return v, errors.New("OldConditionType requires an ID field in the mutation")
  16794. }
  16795. oldValue, err := m.oldValue(ctx)
  16796. if err != nil {
  16797. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  16798. }
  16799. return oldValue.ConditionType, nil
  16800. }
  16801. // AddConditionType adds i to the "condition_type" field.
  16802. func (m *SopNodeMutation) AddConditionType(i int) {
  16803. if m.addcondition_type != nil {
  16804. *m.addcondition_type += i
  16805. } else {
  16806. m.addcondition_type = &i
  16807. }
  16808. }
  16809. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  16810. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  16811. v := m.addcondition_type
  16812. if v == nil {
  16813. return
  16814. }
  16815. return *v, true
  16816. }
  16817. // ResetConditionType resets all changes to the "condition_type" field.
  16818. func (m *SopNodeMutation) ResetConditionType() {
  16819. m.condition_type = nil
  16820. m.addcondition_type = nil
  16821. }
  16822. // SetConditionList sets the "condition_list" field.
  16823. func (m *SopNodeMutation) SetConditionList(s []string) {
  16824. m.condition_list = &s
  16825. m.appendcondition_list = nil
  16826. }
  16827. // ConditionList returns the value of the "condition_list" field in the mutation.
  16828. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  16829. v := m.condition_list
  16830. if v == nil {
  16831. return
  16832. }
  16833. return *v, true
  16834. }
  16835. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  16836. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16837. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16838. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  16839. if !m.op.Is(OpUpdateOne) {
  16840. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  16841. }
  16842. if m.id == nil || m.oldValue == nil {
  16843. return v, errors.New("OldConditionList requires an ID field in the mutation")
  16844. }
  16845. oldValue, err := m.oldValue(ctx)
  16846. if err != nil {
  16847. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  16848. }
  16849. return oldValue.ConditionList, nil
  16850. }
  16851. // AppendConditionList adds s to the "condition_list" field.
  16852. func (m *SopNodeMutation) AppendConditionList(s []string) {
  16853. m.appendcondition_list = append(m.appendcondition_list, s...)
  16854. }
  16855. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  16856. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  16857. if len(m.appendcondition_list) == 0 {
  16858. return nil, false
  16859. }
  16860. return m.appendcondition_list, true
  16861. }
  16862. // ClearConditionList clears the value of the "condition_list" field.
  16863. func (m *SopNodeMutation) ClearConditionList() {
  16864. m.condition_list = nil
  16865. m.appendcondition_list = nil
  16866. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  16867. }
  16868. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  16869. func (m *SopNodeMutation) ConditionListCleared() bool {
  16870. _, ok := m.clearedFields[sopnode.FieldConditionList]
  16871. return ok
  16872. }
  16873. // ResetConditionList resets all changes to the "condition_list" field.
  16874. func (m *SopNodeMutation) ResetConditionList() {
  16875. m.condition_list = nil
  16876. m.appendcondition_list = nil
  16877. delete(m.clearedFields, sopnode.FieldConditionList)
  16878. }
  16879. // SetNoReplyCondition sets the "no_reply_condition" field.
  16880. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  16881. m.no_reply_condition = &u
  16882. m.addno_reply_condition = nil
  16883. }
  16884. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  16885. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  16886. v := m.no_reply_condition
  16887. if v == nil {
  16888. return
  16889. }
  16890. return *v, true
  16891. }
  16892. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  16893. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16894. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16895. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  16896. if !m.op.Is(OpUpdateOne) {
  16897. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  16898. }
  16899. if m.id == nil || m.oldValue == nil {
  16900. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  16901. }
  16902. oldValue, err := m.oldValue(ctx)
  16903. if err != nil {
  16904. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  16905. }
  16906. return oldValue.NoReplyCondition, nil
  16907. }
  16908. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  16909. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  16910. if m.addno_reply_condition != nil {
  16911. *m.addno_reply_condition += u
  16912. } else {
  16913. m.addno_reply_condition = &u
  16914. }
  16915. }
  16916. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  16917. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  16918. v := m.addno_reply_condition
  16919. if v == nil {
  16920. return
  16921. }
  16922. return *v, true
  16923. }
  16924. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  16925. func (m *SopNodeMutation) ResetNoReplyCondition() {
  16926. m.no_reply_condition = nil
  16927. m.addno_reply_condition = nil
  16928. }
  16929. // SetNoReplyUnit sets the "no_reply_unit" field.
  16930. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  16931. m.no_reply_unit = &s
  16932. }
  16933. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  16934. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  16935. v := m.no_reply_unit
  16936. if v == nil {
  16937. return
  16938. }
  16939. return *v, true
  16940. }
  16941. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  16942. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16943. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16944. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  16945. if !m.op.Is(OpUpdateOne) {
  16946. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  16947. }
  16948. if m.id == nil || m.oldValue == nil {
  16949. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  16950. }
  16951. oldValue, err := m.oldValue(ctx)
  16952. if err != nil {
  16953. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  16954. }
  16955. return oldValue.NoReplyUnit, nil
  16956. }
  16957. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  16958. func (m *SopNodeMutation) ResetNoReplyUnit() {
  16959. m.no_reply_unit = nil
  16960. }
  16961. // SetActionMessage sets the "action_message" field.
  16962. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  16963. m.action_message = &ct
  16964. m.appendaction_message = nil
  16965. }
  16966. // ActionMessage returns the value of the "action_message" field in the mutation.
  16967. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  16968. v := m.action_message
  16969. if v == nil {
  16970. return
  16971. }
  16972. return *v, true
  16973. }
  16974. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  16975. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  16976. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16977. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  16978. if !m.op.Is(OpUpdateOne) {
  16979. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  16980. }
  16981. if m.id == nil || m.oldValue == nil {
  16982. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  16983. }
  16984. oldValue, err := m.oldValue(ctx)
  16985. if err != nil {
  16986. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  16987. }
  16988. return oldValue.ActionMessage, nil
  16989. }
  16990. // AppendActionMessage adds ct to the "action_message" field.
  16991. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  16992. m.appendaction_message = append(m.appendaction_message, ct...)
  16993. }
  16994. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  16995. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  16996. if len(m.appendaction_message) == 0 {
  16997. return nil, false
  16998. }
  16999. return m.appendaction_message, true
  17000. }
  17001. // ClearActionMessage clears the value of the "action_message" field.
  17002. func (m *SopNodeMutation) ClearActionMessage() {
  17003. m.action_message = nil
  17004. m.appendaction_message = nil
  17005. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  17006. }
  17007. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  17008. func (m *SopNodeMutation) ActionMessageCleared() bool {
  17009. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  17010. return ok
  17011. }
  17012. // ResetActionMessage resets all changes to the "action_message" field.
  17013. func (m *SopNodeMutation) ResetActionMessage() {
  17014. m.action_message = nil
  17015. m.appendaction_message = nil
  17016. delete(m.clearedFields, sopnode.FieldActionMessage)
  17017. }
  17018. // SetActionLabelAdd sets the "action_label_add" field.
  17019. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  17020. m.action_label_add = &u
  17021. m.appendaction_label_add = nil
  17022. }
  17023. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  17024. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  17025. v := m.action_label_add
  17026. if v == nil {
  17027. return
  17028. }
  17029. return *v, true
  17030. }
  17031. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  17032. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17033. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17034. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  17035. if !m.op.Is(OpUpdateOne) {
  17036. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  17037. }
  17038. if m.id == nil || m.oldValue == nil {
  17039. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  17040. }
  17041. oldValue, err := m.oldValue(ctx)
  17042. if err != nil {
  17043. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  17044. }
  17045. return oldValue.ActionLabelAdd, nil
  17046. }
  17047. // AppendActionLabelAdd adds u to the "action_label_add" field.
  17048. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  17049. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  17050. }
  17051. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  17052. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  17053. if len(m.appendaction_label_add) == 0 {
  17054. return nil, false
  17055. }
  17056. return m.appendaction_label_add, true
  17057. }
  17058. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  17059. func (m *SopNodeMutation) ClearActionLabelAdd() {
  17060. m.action_label_add = nil
  17061. m.appendaction_label_add = nil
  17062. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  17063. }
  17064. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  17065. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  17066. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  17067. return ok
  17068. }
  17069. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  17070. func (m *SopNodeMutation) ResetActionLabelAdd() {
  17071. m.action_label_add = nil
  17072. m.appendaction_label_add = nil
  17073. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  17074. }
  17075. // SetActionLabelDel sets the "action_label_del" field.
  17076. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  17077. m.action_label_del = &u
  17078. m.appendaction_label_del = nil
  17079. }
  17080. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  17081. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  17082. v := m.action_label_del
  17083. if v == nil {
  17084. return
  17085. }
  17086. return *v, true
  17087. }
  17088. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  17089. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17090. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17091. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  17092. if !m.op.Is(OpUpdateOne) {
  17093. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  17094. }
  17095. if m.id == nil || m.oldValue == nil {
  17096. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  17097. }
  17098. oldValue, err := m.oldValue(ctx)
  17099. if err != nil {
  17100. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  17101. }
  17102. return oldValue.ActionLabelDel, nil
  17103. }
  17104. // AppendActionLabelDel adds u to the "action_label_del" field.
  17105. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  17106. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  17107. }
  17108. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  17109. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  17110. if len(m.appendaction_label_del) == 0 {
  17111. return nil, false
  17112. }
  17113. return m.appendaction_label_del, true
  17114. }
  17115. // ClearActionLabelDel clears the value of the "action_label_del" field.
  17116. func (m *SopNodeMutation) ClearActionLabelDel() {
  17117. m.action_label_del = nil
  17118. m.appendaction_label_del = nil
  17119. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  17120. }
  17121. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  17122. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  17123. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  17124. return ok
  17125. }
  17126. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  17127. func (m *SopNodeMutation) ResetActionLabelDel() {
  17128. m.action_label_del = nil
  17129. m.appendaction_label_del = nil
  17130. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  17131. }
  17132. // SetActionForward sets the "action_forward" field.
  17133. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  17134. m.action_forward = &ctf
  17135. }
  17136. // ActionForward returns the value of the "action_forward" field in the mutation.
  17137. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  17138. v := m.action_forward
  17139. if v == nil {
  17140. return
  17141. }
  17142. return *v, true
  17143. }
  17144. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  17145. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17146. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17147. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  17148. if !m.op.Is(OpUpdateOne) {
  17149. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  17150. }
  17151. if m.id == nil || m.oldValue == nil {
  17152. return v, errors.New("OldActionForward requires an ID field in the mutation")
  17153. }
  17154. oldValue, err := m.oldValue(ctx)
  17155. if err != nil {
  17156. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  17157. }
  17158. return oldValue.ActionForward, nil
  17159. }
  17160. // ClearActionForward clears the value of the "action_forward" field.
  17161. func (m *SopNodeMutation) ClearActionForward() {
  17162. m.action_forward = nil
  17163. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  17164. }
  17165. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  17166. func (m *SopNodeMutation) ActionForwardCleared() bool {
  17167. _, ok := m.clearedFields[sopnode.FieldActionForward]
  17168. return ok
  17169. }
  17170. // ResetActionForward resets all changes to the "action_forward" field.
  17171. func (m *SopNodeMutation) ResetActionForward() {
  17172. m.action_forward = nil
  17173. delete(m.clearedFields, sopnode.FieldActionForward)
  17174. }
  17175. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  17176. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  17177. m.sop_stage = &id
  17178. }
  17179. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  17180. func (m *SopNodeMutation) ClearSopStage() {
  17181. m.clearedsop_stage = true
  17182. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  17183. }
  17184. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  17185. func (m *SopNodeMutation) SopStageCleared() bool {
  17186. return m.clearedsop_stage
  17187. }
  17188. // SopStageID returns the "sop_stage" edge ID in the mutation.
  17189. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  17190. if m.sop_stage != nil {
  17191. return *m.sop_stage, true
  17192. }
  17193. return
  17194. }
  17195. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  17196. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17197. // SopStageID instead. It exists only for internal usage by the builders.
  17198. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  17199. if id := m.sop_stage; id != nil {
  17200. ids = append(ids, *id)
  17201. }
  17202. return
  17203. }
  17204. // ResetSopStage resets all changes to the "sop_stage" edge.
  17205. func (m *SopNodeMutation) ResetSopStage() {
  17206. m.sop_stage = nil
  17207. m.clearedsop_stage = false
  17208. }
  17209. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  17210. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  17211. if m.node_messages == nil {
  17212. m.node_messages = make(map[uint64]struct{})
  17213. }
  17214. for i := range ids {
  17215. m.node_messages[ids[i]] = struct{}{}
  17216. }
  17217. }
  17218. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  17219. func (m *SopNodeMutation) ClearNodeMessages() {
  17220. m.clearednode_messages = true
  17221. }
  17222. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  17223. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  17224. return m.clearednode_messages
  17225. }
  17226. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  17227. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  17228. if m.removednode_messages == nil {
  17229. m.removednode_messages = make(map[uint64]struct{})
  17230. }
  17231. for i := range ids {
  17232. delete(m.node_messages, ids[i])
  17233. m.removednode_messages[ids[i]] = struct{}{}
  17234. }
  17235. }
  17236. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  17237. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  17238. for id := range m.removednode_messages {
  17239. ids = append(ids, id)
  17240. }
  17241. return
  17242. }
  17243. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  17244. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  17245. for id := range m.node_messages {
  17246. ids = append(ids, id)
  17247. }
  17248. return
  17249. }
  17250. // ResetNodeMessages resets all changes to the "node_messages" edge.
  17251. func (m *SopNodeMutation) ResetNodeMessages() {
  17252. m.node_messages = nil
  17253. m.clearednode_messages = false
  17254. m.removednode_messages = nil
  17255. }
  17256. // Where appends a list predicates to the SopNodeMutation builder.
  17257. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  17258. m.predicates = append(m.predicates, ps...)
  17259. }
  17260. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  17261. // users can use type-assertion to append predicates that do not depend on any generated package.
  17262. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  17263. p := make([]predicate.SopNode, len(ps))
  17264. for i := range ps {
  17265. p[i] = ps[i]
  17266. }
  17267. m.Where(p...)
  17268. }
  17269. // Op returns the operation name.
  17270. func (m *SopNodeMutation) Op() Op {
  17271. return m.op
  17272. }
  17273. // SetOp allows setting the mutation operation.
  17274. func (m *SopNodeMutation) SetOp(op Op) {
  17275. m.op = op
  17276. }
  17277. // Type returns the node type of this mutation (SopNode).
  17278. func (m *SopNodeMutation) Type() string {
  17279. return m.typ
  17280. }
  17281. // Fields returns all fields that were changed during this mutation. Note that in
  17282. // order to get all numeric fields that were incremented/decremented, call
  17283. // AddedFields().
  17284. func (m *SopNodeMutation) Fields() []string {
  17285. fields := make([]string, 0, 15)
  17286. if m.created_at != nil {
  17287. fields = append(fields, sopnode.FieldCreatedAt)
  17288. }
  17289. if m.updated_at != nil {
  17290. fields = append(fields, sopnode.FieldUpdatedAt)
  17291. }
  17292. if m.status != nil {
  17293. fields = append(fields, sopnode.FieldStatus)
  17294. }
  17295. if m.deleted_at != nil {
  17296. fields = append(fields, sopnode.FieldDeletedAt)
  17297. }
  17298. if m.sop_stage != nil {
  17299. fields = append(fields, sopnode.FieldStageID)
  17300. }
  17301. if m.parent_id != nil {
  17302. fields = append(fields, sopnode.FieldParentID)
  17303. }
  17304. if m.name != nil {
  17305. fields = append(fields, sopnode.FieldName)
  17306. }
  17307. if m.condition_type != nil {
  17308. fields = append(fields, sopnode.FieldConditionType)
  17309. }
  17310. if m.condition_list != nil {
  17311. fields = append(fields, sopnode.FieldConditionList)
  17312. }
  17313. if m.no_reply_condition != nil {
  17314. fields = append(fields, sopnode.FieldNoReplyCondition)
  17315. }
  17316. if m.no_reply_unit != nil {
  17317. fields = append(fields, sopnode.FieldNoReplyUnit)
  17318. }
  17319. if m.action_message != nil {
  17320. fields = append(fields, sopnode.FieldActionMessage)
  17321. }
  17322. if m.action_label_add != nil {
  17323. fields = append(fields, sopnode.FieldActionLabelAdd)
  17324. }
  17325. if m.action_label_del != nil {
  17326. fields = append(fields, sopnode.FieldActionLabelDel)
  17327. }
  17328. if m.action_forward != nil {
  17329. fields = append(fields, sopnode.FieldActionForward)
  17330. }
  17331. return fields
  17332. }
  17333. // Field returns the value of a field with the given name. The second boolean
  17334. // return value indicates that this field was not set, or was not defined in the
  17335. // schema.
  17336. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  17337. switch name {
  17338. case sopnode.FieldCreatedAt:
  17339. return m.CreatedAt()
  17340. case sopnode.FieldUpdatedAt:
  17341. return m.UpdatedAt()
  17342. case sopnode.FieldStatus:
  17343. return m.Status()
  17344. case sopnode.FieldDeletedAt:
  17345. return m.DeletedAt()
  17346. case sopnode.FieldStageID:
  17347. return m.StageID()
  17348. case sopnode.FieldParentID:
  17349. return m.ParentID()
  17350. case sopnode.FieldName:
  17351. return m.Name()
  17352. case sopnode.FieldConditionType:
  17353. return m.ConditionType()
  17354. case sopnode.FieldConditionList:
  17355. return m.ConditionList()
  17356. case sopnode.FieldNoReplyCondition:
  17357. return m.NoReplyCondition()
  17358. case sopnode.FieldNoReplyUnit:
  17359. return m.NoReplyUnit()
  17360. case sopnode.FieldActionMessage:
  17361. return m.ActionMessage()
  17362. case sopnode.FieldActionLabelAdd:
  17363. return m.ActionLabelAdd()
  17364. case sopnode.FieldActionLabelDel:
  17365. return m.ActionLabelDel()
  17366. case sopnode.FieldActionForward:
  17367. return m.ActionForward()
  17368. }
  17369. return nil, false
  17370. }
  17371. // OldField returns the old value of the field from the database. An error is
  17372. // returned if the mutation operation is not UpdateOne, or the query to the
  17373. // database failed.
  17374. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17375. switch name {
  17376. case sopnode.FieldCreatedAt:
  17377. return m.OldCreatedAt(ctx)
  17378. case sopnode.FieldUpdatedAt:
  17379. return m.OldUpdatedAt(ctx)
  17380. case sopnode.FieldStatus:
  17381. return m.OldStatus(ctx)
  17382. case sopnode.FieldDeletedAt:
  17383. return m.OldDeletedAt(ctx)
  17384. case sopnode.FieldStageID:
  17385. return m.OldStageID(ctx)
  17386. case sopnode.FieldParentID:
  17387. return m.OldParentID(ctx)
  17388. case sopnode.FieldName:
  17389. return m.OldName(ctx)
  17390. case sopnode.FieldConditionType:
  17391. return m.OldConditionType(ctx)
  17392. case sopnode.FieldConditionList:
  17393. return m.OldConditionList(ctx)
  17394. case sopnode.FieldNoReplyCondition:
  17395. return m.OldNoReplyCondition(ctx)
  17396. case sopnode.FieldNoReplyUnit:
  17397. return m.OldNoReplyUnit(ctx)
  17398. case sopnode.FieldActionMessage:
  17399. return m.OldActionMessage(ctx)
  17400. case sopnode.FieldActionLabelAdd:
  17401. return m.OldActionLabelAdd(ctx)
  17402. case sopnode.FieldActionLabelDel:
  17403. return m.OldActionLabelDel(ctx)
  17404. case sopnode.FieldActionForward:
  17405. return m.OldActionForward(ctx)
  17406. }
  17407. return nil, fmt.Errorf("unknown SopNode field %s", name)
  17408. }
  17409. // SetField sets the value of a field with the given name. It returns an error if
  17410. // the field is not defined in the schema, or if the type mismatched the field
  17411. // type.
  17412. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  17413. switch name {
  17414. case sopnode.FieldCreatedAt:
  17415. v, ok := value.(time.Time)
  17416. if !ok {
  17417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17418. }
  17419. m.SetCreatedAt(v)
  17420. return nil
  17421. case sopnode.FieldUpdatedAt:
  17422. v, ok := value.(time.Time)
  17423. if !ok {
  17424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17425. }
  17426. m.SetUpdatedAt(v)
  17427. return nil
  17428. case sopnode.FieldStatus:
  17429. v, ok := value.(uint8)
  17430. if !ok {
  17431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17432. }
  17433. m.SetStatus(v)
  17434. return nil
  17435. case sopnode.FieldDeletedAt:
  17436. v, ok := value.(time.Time)
  17437. if !ok {
  17438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17439. }
  17440. m.SetDeletedAt(v)
  17441. return nil
  17442. case sopnode.FieldStageID:
  17443. v, ok := value.(uint64)
  17444. if !ok {
  17445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17446. }
  17447. m.SetStageID(v)
  17448. return nil
  17449. case sopnode.FieldParentID:
  17450. v, ok := value.(uint64)
  17451. if !ok {
  17452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17453. }
  17454. m.SetParentID(v)
  17455. return nil
  17456. case sopnode.FieldName:
  17457. v, ok := value.(string)
  17458. if !ok {
  17459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17460. }
  17461. m.SetName(v)
  17462. return nil
  17463. case sopnode.FieldConditionType:
  17464. v, ok := value.(int)
  17465. if !ok {
  17466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17467. }
  17468. m.SetConditionType(v)
  17469. return nil
  17470. case sopnode.FieldConditionList:
  17471. v, ok := value.([]string)
  17472. if !ok {
  17473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17474. }
  17475. m.SetConditionList(v)
  17476. return nil
  17477. case sopnode.FieldNoReplyCondition:
  17478. v, ok := value.(uint64)
  17479. if !ok {
  17480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17481. }
  17482. m.SetNoReplyCondition(v)
  17483. return nil
  17484. case sopnode.FieldNoReplyUnit:
  17485. v, ok := value.(string)
  17486. if !ok {
  17487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17488. }
  17489. m.SetNoReplyUnit(v)
  17490. return nil
  17491. case sopnode.FieldActionMessage:
  17492. v, ok := value.([]custom_types.Action)
  17493. if !ok {
  17494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17495. }
  17496. m.SetActionMessage(v)
  17497. return nil
  17498. case sopnode.FieldActionLabelAdd:
  17499. v, ok := value.([]uint64)
  17500. if !ok {
  17501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17502. }
  17503. m.SetActionLabelAdd(v)
  17504. return nil
  17505. case sopnode.FieldActionLabelDel:
  17506. v, ok := value.([]uint64)
  17507. if !ok {
  17508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17509. }
  17510. m.SetActionLabelDel(v)
  17511. return nil
  17512. case sopnode.FieldActionForward:
  17513. v, ok := value.(*custom_types.ActionForward)
  17514. if !ok {
  17515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17516. }
  17517. m.SetActionForward(v)
  17518. return nil
  17519. }
  17520. return fmt.Errorf("unknown SopNode field %s", name)
  17521. }
  17522. // AddedFields returns all numeric fields that were incremented/decremented during
  17523. // this mutation.
  17524. func (m *SopNodeMutation) AddedFields() []string {
  17525. var fields []string
  17526. if m.addstatus != nil {
  17527. fields = append(fields, sopnode.FieldStatus)
  17528. }
  17529. if m.addparent_id != nil {
  17530. fields = append(fields, sopnode.FieldParentID)
  17531. }
  17532. if m.addcondition_type != nil {
  17533. fields = append(fields, sopnode.FieldConditionType)
  17534. }
  17535. if m.addno_reply_condition != nil {
  17536. fields = append(fields, sopnode.FieldNoReplyCondition)
  17537. }
  17538. return fields
  17539. }
  17540. // AddedField returns the numeric value that was incremented/decremented on a field
  17541. // with the given name. The second boolean return value indicates that this field
  17542. // was not set, or was not defined in the schema.
  17543. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  17544. switch name {
  17545. case sopnode.FieldStatus:
  17546. return m.AddedStatus()
  17547. case sopnode.FieldParentID:
  17548. return m.AddedParentID()
  17549. case sopnode.FieldConditionType:
  17550. return m.AddedConditionType()
  17551. case sopnode.FieldNoReplyCondition:
  17552. return m.AddedNoReplyCondition()
  17553. }
  17554. return nil, false
  17555. }
  17556. // AddField adds the value to the field with the given name. It returns an error if
  17557. // the field is not defined in the schema, or if the type mismatched the field
  17558. // type.
  17559. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  17560. switch name {
  17561. case sopnode.FieldStatus:
  17562. v, ok := value.(int8)
  17563. if !ok {
  17564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17565. }
  17566. m.AddStatus(v)
  17567. return nil
  17568. case sopnode.FieldParentID:
  17569. v, ok := value.(int64)
  17570. if !ok {
  17571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17572. }
  17573. m.AddParentID(v)
  17574. return nil
  17575. case sopnode.FieldConditionType:
  17576. v, ok := value.(int)
  17577. if !ok {
  17578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17579. }
  17580. m.AddConditionType(v)
  17581. return nil
  17582. case sopnode.FieldNoReplyCondition:
  17583. v, ok := value.(int64)
  17584. if !ok {
  17585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17586. }
  17587. m.AddNoReplyCondition(v)
  17588. return nil
  17589. }
  17590. return fmt.Errorf("unknown SopNode numeric field %s", name)
  17591. }
  17592. // ClearedFields returns all nullable fields that were cleared during this
  17593. // mutation.
  17594. func (m *SopNodeMutation) ClearedFields() []string {
  17595. var fields []string
  17596. if m.FieldCleared(sopnode.FieldStatus) {
  17597. fields = append(fields, sopnode.FieldStatus)
  17598. }
  17599. if m.FieldCleared(sopnode.FieldDeletedAt) {
  17600. fields = append(fields, sopnode.FieldDeletedAt)
  17601. }
  17602. if m.FieldCleared(sopnode.FieldConditionList) {
  17603. fields = append(fields, sopnode.FieldConditionList)
  17604. }
  17605. if m.FieldCleared(sopnode.FieldActionMessage) {
  17606. fields = append(fields, sopnode.FieldActionMessage)
  17607. }
  17608. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  17609. fields = append(fields, sopnode.FieldActionLabelAdd)
  17610. }
  17611. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  17612. fields = append(fields, sopnode.FieldActionLabelDel)
  17613. }
  17614. if m.FieldCleared(sopnode.FieldActionForward) {
  17615. fields = append(fields, sopnode.FieldActionForward)
  17616. }
  17617. return fields
  17618. }
  17619. // FieldCleared returns a boolean indicating if a field with the given name was
  17620. // cleared in this mutation.
  17621. func (m *SopNodeMutation) FieldCleared(name string) bool {
  17622. _, ok := m.clearedFields[name]
  17623. return ok
  17624. }
  17625. // ClearField clears the value of the field with the given name. It returns an
  17626. // error if the field is not defined in the schema.
  17627. func (m *SopNodeMutation) ClearField(name string) error {
  17628. switch name {
  17629. case sopnode.FieldStatus:
  17630. m.ClearStatus()
  17631. return nil
  17632. case sopnode.FieldDeletedAt:
  17633. m.ClearDeletedAt()
  17634. return nil
  17635. case sopnode.FieldConditionList:
  17636. m.ClearConditionList()
  17637. return nil
  17638. case sopnode.FieldActionMessage:
  17639. m.ClearActionMessage()
  17640. return nil
  17641. case sopnode.FieldActionLabelAdd:
  17642. m.ClearActionLabelAdd()
  17643. return nil
  17644. case sopnode.FieldActionLabelDel:
  17645. m.ClearActionLabelDel()
  17646. return nil
  17647. case sopnode.FieldActionForward:
  17648. m.ClearActionForward()
  17649. return nil
  17650. }
  17651. return fmt.Errorf("unknown SopNode nullable field %s", name)
  17652. }
  17653. // ResetField resets all changes in the mutation for the field with the given name.
  17654. // It returns an error if the field is not defined in the schema.
  17655. func (m *SopNodeMutation) ResetField(name string) error {
  17656. switch name {
  17657. case sopnode.FieldCreatedAt:
  17658. m.ResetCreatedAt()
  17659. return nil
  17660. case sopnode.FieldUpdatedAt:
  17661. m.ResetUpdatedAt()
  17662. return nil
  17663. case sopnode.FieldStatus:
  17664. m.ResetStatus()
  17665. return nil
  17666. case sopnode.FieldDeletedAt:
  17667. m.ResetDeletedAt()
  17668. return nil
  17669. case sopnode.FieldStageID:
  17670. m.ResetStageID()
  17671. return nil
  17672. case sopnode.FieldParentID:
  17673. m.ResetParentID()
  17674. return nil
  17675. case sopnode.FieldName:
  17676. m.ResetName()
  17677. return nil
  17678. case sopnode.FieldConditionType:
  17679. m.ResetConditionType()
  17680. return nil
  17681. case sopnode.FieldConditionList:
  17682. m.ResetConditionList()
  17683. return nil
  17684. case sopnode.FieldNoReplyCondition:
  17685. m.ResetNoReplyCondition()
  17686. return nil
  17687. case sopnode.FieldNoReplyUnit:
  17688. m.ResetNoReplyUnit()
  17689. return nil
  17690. case sopnode.FieldActionMessage:
  17691. m.ResetActionMessage()
  17692. return nil
  17693. case sopnode.FieldActionLabelAdd:
  17694. m.ResetActionLabelAdd()
  17695. return nil
  17696. case sopnode.FieldActionLabelDel:
  17697. m.ResetActionLabelDel()
  17698. return nil
  17699. case sopnode.FieldActionForward:
  17700. m.ResetActionForward()
  17701. return nil
  17702. }
  17703. return fmt.Errorf("unknown SopNode field %s", name)
  17704. }
  17705. // AddedEdges returns all edge names that were set/added in this mutation.
  17706. func (m *SopNodeMutation) AddedEdges() []string {
  17707. edges := make([]string, 0, 2)
  17708. if m.sop_stage != nil {
  17709. edges = append(edges, sopnode.EdgeSopStage)
  17710. }
  17711. if m.node_messages != nil {
  17712. edges = append(edges, sopnode.EdgeNodeMessages)
  17713. }
  17714. return edges
  17715. }
  17716. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17717. // name in this mutation.
  17718. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  17719. switch name {
  17720. case sopnode.EdgeSopStage:
  17721. if id := m.sop_stage; id != nil {
  17722. return []ent.Value{*id}
  17723. }
  17724. case sopnode.EdgeNodeMessages:
  17725. ids := make([]ent.Value, 0, len(m.node_messages))
  17726. for id := range m.node_messages {
  17727. ids = append(ids, id)
  17728. }
  17729. return ids
  17730. }
  17731. return nil
  17732. }
  17733. // RemovedEdges returns all edge names that were removed in this mutation.
  17734. func (m *SopNodeMutation) RemovedEdges() []string {
  17735. edges := make([]string, 0, 2)
  17736. if m.removednode_messages != nil {
  17737. edges = append(edges, sopnode.EdgeNodeMessages)
  17738. }
  17739. return edges
  17740. }
  17741. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17742. // the given name in this mutation.
  17743. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  17744. switch name {
  17745. case sopnode.EdgeNodeMessages:
  17746. ids := make([]ent.Value, 0, len(m.removednode_messages))
  17747. for id := range m.removednode_messages {
  17748. ids = append(ids, id)
  17749. }
  17750. return ids
  17751. }
  17752. return nil
  17753. }
  17754. // ClearedEdges returns all edge names that were cleared in this mutation.
  17755. func (m *SopNodeMutation) ClearedEdges() []string {
  17756. edges := make([]string, 0, 2)
  17757. if m.clearedsop_stage {
  17758. edges = append(edges, sopnode.EdgeSopStage)
  17759. }
  17760. if m.clearednode_messages {
  17761. edges = append(edges, sopnode.EdgeNodeMessages)
  17762. }
  17763. return edges
  17764. }
  17765. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17766. // was cleared in this mutation.
  17767. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  17768. switch name {
  17769. case sopnode.EdgeSopStage:
  17770. return m.clearedsop_stage
  17771. case sopnode.EdgeNodeMessages:
  17772. return m.clearednode_messages
  17773. }
  17774. return false
  17775. }
  17776. // ClearEdge clears the value of the edge with the given name. It returns an error
  17777. // if that edge is not defined in the schema.
  17778. func (m *SopNodeMutation) ClearEdge(name string) error {
  17779. switch name {
  17780. case sopnode.EdgeSopStage:
  17781. m.ClearSopStage()
  17782. return nil
  17783. }
  17784. return fmt.Errorf("unknown SopNode unique edge %s", name)
  17785. }
  17786. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17787. // It returns an error if the edge is not defined in the schema.
  17788. func (m *SopNodeMutation) ResetEdge(name string) error {
  17789. switch name {
  17790. case sopnode.EdgeSopStage:
  17791. m.ResetSopStage()
  17792. return nil
  17793. case sopnode.EdgeNodeMessages:
  17794. m.ResetNodeMessages()
  17795. return nil
  17796. }
  17797. return fmt.Errorf("unknown SopNode edge %s", name)
  17798. }
  17799. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  17800. type SopStageMutation struct {
  17801. config
  17802. op Op
  17803. typ string
  17804. id *uint64
  17805. created_at *time.Time
  17806. updated_at *time.Time
  17807. status *uint8
  17808. addstatus *int8
  17809. deleted_at *time.Time
  17810. name *string
  17811. condition_type *int
  17812. addcondition_type *int
  17813. condition_operator *int
  17814. addcondition_operator *int
  17815. condition_list *[]custom_types.Condition
  17816. appendcondition_list []custom_types.Condition
  17817. action_message *[]custom_types.Action
  17818. appendaction_message []custom_types.Action
  17819. action_label_add *[]uint64
  17820. appendaction_label_add []uint64
  17821. action_label_del *[]uint64
  17822. appendaction_label_del []uint64
  17823. action_forward **custom_types.ActionForward
  17824. index_sort *int
  17825. addindex_sort *int
  17826. clearedFields map[string]struct{}
  17827. sop_task *uint64
  17828. clearedsop_task bool
  17829. stage_nodes map[uint64]struct{}
  17830. removedstage_nodes map[uint64]struct{}
  17831. clearedstage_nodes bool
  17832. stage_messages map[uint64]struct{}
  17833. removedstage_messages map[uint64]struct{}
  17834. clearedstage_messages bool
  17835. done bool
  17836. oldValue func(context.Context) (*SopStage, error)
  17837. predicates []predicate.SopStage
  17838. }
  17839. var _ ent.Mutation = (*SopStageMutation)(nil)
  17840. // sopstageOption allows management of the mutation configuration using functional options.
  17841. type sopstageOption func(*SopStageMutation)
  17842. // newSopStageMutation creates new mutation for the SopStage entity.
  17843. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  17844. m := &SopStageMutation{
  17845. config: c,
  17846. op: op,
  17847. typ: TypeSopStage,
  17848. clearedFields: make(map[string]struct{}),
  17849. }
  17850. for _, opt := range opts {
  17851. opt(m)
  17852. }
  17853. return m
  17854. }
  17855. // withSopStageID sets the ID field of the mutation.
  17856. func withSopStageID(id uint64) sopstageOption {
  17857. return func(m *SopStageMutation) {
  17858. var (
  17859. err error
  17860. once sync.Once
  17861. value *SopStage
  17862. )
  17863. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  17864. once.Do(func() {
  17865. if m.done {
  17866. err = errors.New("querying old values post mutation is not allowed")
  17867. } else {
  17868. value, err = m.Client().SopStage.Get(ctx, id)
  17869. }
  17870. })
  17871. return value, err
  17872. }
  17873. m.id = &id
  17874. }
  17875. }
  17876. // withSopStage sets the old SopStage of the mutation.
  17877. func withSopStage(node *SopStage) sopstageOption {
  17878. return func(m *SopStageMutation) {
  17879. m.oldValue = func(context.Context) (*SopStage, error) {
  17880. return node, nil
  17881. }
  17882. m.id = &node.ID
  17883. }
  17884. }
  17885. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17886. // executed in a transaction (ent.Tx), a transactional client is returned.
  17887. func (m SopStageMutation) Client() *Client {
  17888. client := &Client{config: m.config}
  17889. client.init()
  17890. return client
  17891. }
  17892. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17893. // it returns an error otherwise.
  17894. func (m SopStageMutation) Tx() (*Tx, error) {
  17895. if _, ok := m.driver.(*txDriver); !ok {
  17896. return nil, errors.New("ent: mutation is not running in a transaction")
  17897. }
  17898. tx := &Tx{config: m.config}
  17899. tx.init()
  17900. return tx, nil
  17901. }
  17902. // SetID sets the value of the id field. Note that this
  17903. // operation is only accepted on creation of SopStage entities.
  17904. func (m *SopStageMutation) SetID(id uint64) {
  17905. m.id = &id
  17906. }
  17907. // ID returns the ID value in the mutation. Note that the ID is only available
  17908. // if it was provided to the builder or after it was returned from the database.
  17909. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  17910. if m.id == nil {
  17911. return
  17912. }
  17913. return *m.id, true
  17914. }
  17915. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17916. // That means, if the mutation is applied within a transaction with an isolation level such
  17917. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17918. // or updated by the mutation.
  17919. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  17920. switch {
  17921. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17922. id, exists := m.ID()
  17923. if exists {
  17924. return []uint64{id}, nil
  17925. }
  17926. fallthrough
  17927. case m.op.Is(OpUpdate | OpDelete):
  17928. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  17929. default:
  17930. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17931. }
  17932. }
  17933. // SetCreatedAt sets the "created_at" field.
  17934. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  17935. m.created_at = &t
  17936. }
  17937. // CreatedAt returns the value of the "created_at" field in the mutation.
  17938. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  17939. v := m.created_at
  17940. if v == nil {
  17941. return
  17942. }
  17943. return *v, true
  17944. }
  17945. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  17946. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17947. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17948. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17949. if !m.op.Is(OpUpdateOne) {
  17950. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17951. }
  17952. if m.id == nil || m.oldValue == nil {
  17953. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17954. }
  17955. oldValue, err := m.oldValue(ctx)
  17956. if err != nil {
  17957. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17958. }
  17959. return oldValue.CreatedAt, nil
  17960. }
  17961. // ResetCreatedAt resets all changes to the "created_at" field.
  17962. func (m *SopStageMutation) ResetCreatedAt() {
  17963. m.created_at = nil
  17964. }
  17965. // SetUpdatedAt sets the "updated_at" field.
  17966. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  17967. m.updated_at = &t
  17968. }
  17969. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17970. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  17971. v := m.updated_at
  17972. if v == nil {
  17973. return
  17974. }
  17975. return *v, true
  17976. }
  17977. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  17978. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  17979. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17980. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17981. if !m.op.Is(OpUpdateOne) {
  17982. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17983. }
  17984. if m.id == nil || m.oldValue == nil {
  17985. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17986. }
  17987. oldValue, err := m.oldValue(ctx)
  17988. if err != nil {
  17989. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17990. }
  17991. return oldValue.UpdatedAt, nil
  17992. }
  17993. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17994. func (m *SopStageMutation) ResetUpdatedAt() {
  17995. m.updated_at = nil
  17996. }
  17997. // SetStatus sets the "status" field.
  17998. func (m *SopStageMutation) SetStatus(u uint8) {
  17999. m.status = &u
  18000. m.addstatus = nil
  18001. }
  18002. // Status returns the value of the "status" field in the mutation.
  18003. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  18004. v := m.status
  18005. if v == nil {
  18006. return
  18007. }
  18008. return *v, true
  18009. }
  18010. // OldStatus returns the old "status" field's value of the SopStage entity.
  18011. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18013. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18014. if !m.op.Is(OpUpdateOne) {
  18015. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18016. }
  18017. if m.id == nil || m.oldValue == nil {
  18018. return v, errors.New("OldStatus requires an ID field in the mutation")
  18019. }
  18020. oldValue, err := m.oldValue(ctx)
  18021. if err != nil {
  18022. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18023. }
  18024. return oldValue.Status, nil
  18025. }
  18026. // AddStatus adds u to the "status" field.
  18027. func (m *SopStageMutation) AddStatus(u int8) {
  18028. if m.addstatus != nil {
  18029. *m.addstatus += u
  18030. } else {
  18031. m.addstatus = &u
  18032. }
  18033. }
  18034. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18035. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  18036. v := m.addstatus
  18037. if v == nil {
  18038. return
  18039. }
  18040. return *v, true
  18041. }
  18042. // ClearStatus clears the value of the "status" field.
  18043. func (m *SopStageMutation) ClearStatus() {
  18044. m.status = nil
  18045. m.addstatus = nil
  18046. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  18047. }
  18048. // StatusCleared returns if the "status" field was cleared in this mutation.
  18049. func (m *SopStageMutation) StatusCleared() bool {
  18050. _, ok := m.clearedFields[sopstage.FieldStatus]
  18051. return ok
  18052. }
  18053. // ResetStatus resets all changes to the "status" field.
  18054. func (m *SopStageMutation) ResetStatus() {
  18055. m.status = nil
  18056. m.addstatus = nil
  18057. delete(m.clearedFields, sopstage.FieldStatus)
  18058. }
  18059. // SetDeletedAt sets the "deleted_at" field.
  18060. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  18061. m.deleted_at = &t
  18062. }
  18063. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18064. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  18065. v := m.deleted_at
  18066. if v == nil {
  18067. return
  18068. }
  18069. return *v, true
  18070. }
  18071. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  18072. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18073. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18074. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18075. if !m.op.Is(OpUpdateOne) {
  18076. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18077. }
  18078. if m.id == nil || m.oldValue == nil {
  18079. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18080. }
  18081. oldValue, err := m.oldValue(ctx)
  18082. if err != nil {
  18083. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18084. }
  18085. return oldValue.DeletedAt, nil
  18086. }
  18087. // ClearDeletedAt clears the value of the "deleted_at" field.
  18088. func (m *SopStageMutation) ClearDeletedAt() {
  18089. m.deleted_at = nil
  18090. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  18091. }
  18092. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18093. func (m *SopStageMutation) DeletedAtCleared() bool {
  18094. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  18095. return ok
  18096. }
  18097. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18098. func (m *SopStageMutation) ResetDeletedAt() {
  18099. m.deleted_at = nil
  18100. delete(m.clearedFields, sopstage.FieldDeletedAt)
  18101. }
  18102. // SetTaskID sets the "task_id" field.
  18103. func (m *SopStageMutation) SetTaskID(u uint64) {
  18104. m.sop_task = &u
  18105. }
  18106. // TaskID returns the value of the "task_id" field in the mutation.
  18107. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  18108. v := m.sop_task
  18109. if v == nil {
  18110. return
  18111. }
  18112. return *v, true
  18113. }
  18114. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  18115. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18116. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18117. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  18118. if !m.op.Is(OpUpdateOne) {
  18119. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  18120. }
  18121. if m.id == nil || m.oldValue == nil {
  18122. return v, errors.New("OldTaskID requires an ID field in the mutation")
  18123. }
  18124. oldValue, err := m.oldValue(ctx)
  18125. if err != nil {
  18126. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  18127. }
  18128. return oldValue.TaskID, nil
  18129. }
  18130. // ResetTaskID resets all changes to the "task_id" field.
  18131. func (m *SopStageMutation) ResetTaskID() {
  18132. m.sop_task = nil
  18133. }
  18134. // SetName sets the "name" field.
  18135. func (m *SopStageMutation) SetName(s string) {
  18136. m.name = &s
  18137. }
  18138. // Name returns the value of the "name" field in the mutation.
  18139. func (m *SopStageMutation) Name() (r string, exists bool) {
  18140. v := m.name
  18141. if v == nil {
  18142. return
  18143. }
  18144. return *v, true
  18145. }
  18146. // OldName returns the old "name" field's value of the SopStage entity.
  18147. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18148. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18149. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  18150. if !m.op.Is(OpUpdateOne) {
  18151. return v, errors.New("OldName is only allowed on UpdateOne operations")
  18152. }
  18153. if m.id == nil || m.oldValue == nil {
  18154. return v, errors.New("OldName requires an ID field in the mutation")
  18155. }
  18156. oldValue, err := m.oldValue(ctx)
  18157. if err != nil {
  18158. return v, fmt.Errorf("querying old value for OldName: %w", err)
  18159. }
  18160. return oldValue.Name, nil
  18161. }
  18162. // ResetName resets all changes to the "name" field.
  18163. func (m *SopStageMutation) ResetName() {
  18164. m.name = nil
  18165. }
  18166. // SetConditionType sets the "condition_type" field.
  18167. func (m *SopStageMutation) SetConditionType(i int) {
  18168. m.condition_type = &i
  18169. m.addcondition_type = nil
  18170. }
  18171. // ConditionType returns the value of the "condition_type" field in the mutation.
  18172. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  18173. v := m.condition_type
  18174. if v == nil {
  18175. return
  18176. }
  18177. return *v, true
  18178. }
  18179. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  18180. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18181. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18182. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  18183. if !m.op.Is(OpUpdateOne) {
  18184. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  18185. }
  18186. if m.id == nil || m.oldValue == nil {
  18187. return v, errors.New("OldConditionType requires an ID field in the mutation")
  18188. }
  18189. oldValue, err := m.oldValue(ctx)
  18190. if err != nil {
  18191. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  18192. }
  18193. return oldValue.ConditionType, nil
  18194. }
  18195. // AddConditionType adds i to the "condition_type" field.
  18196. func (m *SopStageMutation) AddConditionType(i int) {
  18197. if m.addcondition_type != nil {
  18198. *m.addcondition_type += i
  18199. } else {
  18200. m.addcondition_type = &i
  18201. }
  18202. }
  18203. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  18204. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  18205. v := m.addcondition_type
  18206. if v == nil {
  18207. return
  18208. }
  18209. return *v, true
  18210. }
  18211. // ResetConditionType resets all changes to the "condition_type" field.
  18212. func (m *SopStageMutation) ResetConditionType() {
  18213. m.condition_type = nil
  18214. m.addcondition_type = nil
  18215. }
  18216. // SetConditionOperator sets the "condition_operator" field.
  18217. func (m *SopStageMutation) SetConditionOperator(i int) {
  18218. m.condition_operator = &i
  18219. m.addcondition_operator = nil
  18220. }
  18221. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  18222. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  18223. v := m.condition_operator
  18224. if v == nil {
  18225. return
  18226. }
  18227. return *v, true
  18228. }
  18229. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  18230. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18231. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18232. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  18233. if !m.op.Is(OpUpdateOne) {
  18234. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  18235. }
  18236. if m.id == nil || m.oldValue == nil {
  18237. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  18238. }
  18239. oldValue, err := m.oldValue(ctx)
  18240. if err != nil {
  18241. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  18242. }
  18243. return oldValue.ConditionOperator, nil
  18244. }
  18245. // AddConditionOperator adds i to the "condition_operator" field.
  18246. func (m *SopStageMutation) AddConditionOperator(i int) {
  18247. if m.addcondition_operator != nil {
  18248. *m.addcondition_operator += i
  18249. } else {
  18250. m.addcondition_operator = &i
  18251. }
  18252. }
  18253. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  18254. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  18255. v := m.addcondition_operator
  18256. if v == nil {
  18257. return
  18258. }
  18259. return *v, true
  18260. }
  18261. // ResetConditionOperator resets all changes to the "condition_operator" field.
  18262. func (m *SopStageMutation) ResetConditionOperator() {
  18263. m.condition_operator = nil
  18264. m.addcondition_operator = nil
  18265. }
  18266. // SetConditionList sets the "condition_list" field.
  18267. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  18268. m.condition_list = &ct
  18269. m.appendcondition_list = nil
  18270. }
  18271. // ConditionList returns the value of the "condition_list" field in the mutation.
  18272. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  18273. v := m.condition_list
  18274. if v == nil {
  18275. return
  18276. }
  18277. return *v, true
  18278. }
  18279. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  18280. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18281. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18282. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  18283. if !m.op.Is(OpUpdateOne) {
  18284. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  18285. }
  18286. if m.id == nil || m.oldValue == nil {
  18287. return v, errors.New("OldConditionList requires an ID field in the mutation")
  18288. }
  18289. oldValue, err := m.oldValue(ctx)
  18290. if err != nil {
  18291. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  18292. }
  18293. return oldValue.ConditionList, nil
  18294. }
  18295. // AppendConditionList adds ct to the "condition_list" field.
  18296. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  18297. m.appendcondition_list = append(m.appendcondition_list, ct...)
  18298. }
  18299. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  18300. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  18301. if len(m.appendcondition_list) == 0 {
  18302. return nil, false
  18303. }
  18304. return m.appendcondition_list, true
  18305. }
  18306. // ResetConditionList resets all changes to the "condition_list" field.
  18307. func (m *SopStageMutation) ResetConditionList() {
  18308. m.condition_list = nil
  18309. m.appendcondition_list = nil
  18310. }
  18311. // SetActionMessage sets the "action_message" field.
  18312. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  18313. m.action_message = &ct
  18314. m.appendaction_message = nil
  18315. }
  18316. // ActionMessage returns the value of the "action_message" field in the mutation.
  18317. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  18318. v := m.action_message
  18319. if v == nil {
  18320. return
  18321. }
  18322. return *v, true
  18323. }
  18324. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  18325. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18326. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18327. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  18328. if !m.op.Is(OpUpdateOne) {
  18329. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  18330. }
  18331. if m.id == nil || m.oldValue == nil {
  18332. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  18333. }
  18334. oldValue, err := m.oldValue(ctx)
  18335. if err != nil {
  18336. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  18337. }
  18338. return oldValue.ActionMessage, nil
  18339. }
  18340. // AppendActionMessage adds ct to the "action_message" field.
  18341. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  18342. m.appendaction_message = append(m.appendaction_message, ct...)
  18343. }
  18344. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  18345. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  18346. if len(m.appendaction_message) == 0 {
  18347. return nil, false
  18348. }
  18349. return m.appendaction_message, true
  18350. }
  18351. // ClearActionMessage clears the value of the "action_message" field.
  18352. func (m *SopStageMutation) ClearActionMessage() {
  18353. m.action_message = nil
  18354. m.appendaction_message = nil
  18355. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  18356. }
  18357. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  18358. func (m *SopStageMutation) ActionMessageCleared() bool {
  18359. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  18360. return ok
  18361. }
  18362. // ResetActionMessage resets all changes to the "action_message" field.
  18363. func (m *SopStageMutation) ResetActionMessage() {
  18364. m.action_message = nil
  18365. m.appendaction_message = nil
  18366. delete(m.clearedFields, sopstage.FieldActionMessage)
  18367. }
  18368. // SetActionLabelAdd sets the "action_label_add" field.
  18369. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  18370. m.action_label_add = &u
  18371. m.appendaction_label_add = nil
  18372. }
  18373. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  18374. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  18375. v := m.action_label_add
  18376. if v == nil {
  18377. return
  18378. }
  18379. return *v, true
  18380. }
  18381. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  18382. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18383. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18384. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  18385. if !m.op.Is(OpUpdateOne) {
  18386. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  18387. }
  18388. if m.id == nil || m.oldValue == nil {
  18389. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  18390. }
  18391. oldValue, err := m.oldValue(ctx)
  18392. if err != nil {
  18393. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  18394. }
  18395. return oldValue.ActionLabelAdd, nil
  18396. }
  18397. // AppendActionLabelAdd adds u to the "action_label_add" field.
  18398. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  18399. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  18400. }
  18401. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  18402. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  18403. if len(m.appendaction_label_add) == 0 {
  18404. return nil, false
  18405. }
  18406. return m.appendaction_label_add, true
  18407. }
  18408. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  18409. func (m *SopStageMutation) ClearActionLabelAdd() {
  18410. m.action_label_add = nil
  18411. m.appendaction_label_add = nil
  18412. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  18413. }
  18414. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  18415. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  18416. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  18417. return ok
  18418. }
  18419. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  18420. func (m *SopStageMutation) ResetActionLabelAdd() {
  18421. m.action_label_add = nil
  18422. m.appendaction_label_add = nil
  18423. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  18424. }
  18425. // SetActionLabelDel sets the "action_label_del" field.
  18426. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  18427. m.action_label_del = &u
  18428. m.appendaction_label_del = nil
  18429. }
  18430. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  18431. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  18432. v := m.action_label_del
  18433. if v == nil {
  18434. return
  18435. }
  18436. return *v, true
  18437. }
  18438. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  18439. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18440. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18441. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  18442. if !m.op.Is(OpUpdateOne) {
  18443. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  18444. }
  18445. if m.id == nil || m.oldValue == nil {
  18446. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  18447. }
  18448. oldValue, err := m.oldValue(ctx)
  18449. if err != nil {
  18450. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  18451. }
  18452. return oldValue.ActionLabelDel, nil
  18453. }
  18454. // AppendActionLabelDel adds u to the "action_label_del" field.
  18455. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  18456. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  18457. }
  18458. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  18459. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  18460. if len(m.appendaction_label_del) == 0 {
  18461. return nil, false
  18462. }
  18463. return m.appendaction_label_del, true
  18464. }
  18465. // ClearActionLabelDel clears the value of the "action_label_del" field.
  18466. func (m *SopStageMutation) ClearActionLabelDel() {
  18467. m.action_label_del = nil
  18468. m.appendaction_label_del = nil
  18469. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  18470. }
  18471. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  18472. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  18473. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  18474. return ok
  18475. }
  18476. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  18477. func (m *SopStageMutation) ResetActionLabelDel() {
  18478. m.action_label_del = nil
  18479. m.appendaction_label_del = nil
  18480. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  18481. }
  18482. // SetActionForward sets the "action_forward" field.
  18483. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  18484. m.action_forward = &ctf
  18485. }
  18486. // ActionForward returns the value of the "action_forward" field in the mutation.
  18487. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  18488. v := m.action_forward
  18489. if v == nil {
  18490. return
  18491. }
  18492. return *v, true
  18493. }
  18494. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  18495. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18496. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18497. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  18498. if !m.op.Is(OpUpdateOne) {
  18499. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  18500. }
  18501. if m.id == nil || m.oldValue == nil {
  18502. return v, errors.New("OldActionForward requires an ID field in the mutation")
  18503. }
  18504. oldValue, err := m.oldValue(ctx)
  18505. if err != nil {
  18506. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  18507. }
  18508. return oldValue.ActionForward, nil
  18509. }
  18510. // ClearActionForward clears the value of the "action_forward" field.
  18511. func (m *SopStageMutation) ClearActionForward() {
  18512. m.action_forward = nil
  18513. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  18514. }
  18515. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  18516. func (m *SopStageMutation) ActionForwardCleared() bool {
  18517. _, ok := m.clearedFields[sopstage.FieldActionForward]
  18518. return ok
  18519. }
  18520. // ResetActionForward resets all changes to the "action_forward" field.
  18521. func (m *SopStageMutation) ResetActionForward() {
  18522. m.action_forward = nil
  18523. delete(m.clearedFields, sopstage.FieldActionForward)
  18524. }
  18525. // SetIndexSort sets the "index_sort" field.
  18526. func (m *SopStageMutation) SetIndexSort(i int) {
  18527. m.index_sort = &i
  18528. m.addindex_sort = nil
  18529. }
  18530. // IndexSort returns the value of the "index_sort" field in the mutation.
  18531. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  18532. v := m.index_sort
  18533. if v == nil {
  18534. return
  18535. }
  18536. return *v, true
  18537. }
  18538. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  18539. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18540. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18541. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  18542. if !m.op.Is(OpUpdateOne) {
  18543. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  18544. }
  18545. if m.id == nil || m.oldValue == nil {
  18546. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  18547. }
  18548. oldValue, err := m.oldValue(ctx)
  18549. if err != nil {
  18550. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  18551. }
  18552. return oldValue.IndexSort, nil
  18553. }
  18554. // AddIndexSort adds i to the "index_sort" field.
  18555. func (m *SopStageMutation) AddIndexSort(i int) {
  18556. if m.addindex_sort != nil {
  18557. *m.addindex_sort += i
  18558. } else {
  18559. m.addindex_sort = &i
  18560. }
  18561. }
  18562. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  18563. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  18564. v := m.addindex_sort
  18565. if v == nil {
  18566. return
  18567. }
  18568. return *v, true
  18569. }
  18570. // ClearIndexSort clears the value of the "index_sort" field.
  18571. func (m *SopStageMutation) ClearIndexSort() {
  18572. m.index_sort = nil
  18573. m.addindex_sort = nil
  18574. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  18575. }
  18576. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  18577. func (m *SopStageMutation) IndexSortCleared() bool {
  18578. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  18579. return ok
  18580. }
  18581. // ResetIndexSort resets all changes to the "index_sort" field.
  18582. func (m *SopStageMutation) ResetIndexSort() {
  18583. m.index_sort = nil
  18584. m.addindex_sort = nil
  18585. delete(m.clearedFields, sopstage.FieldIndexSort)
  18586. }
  18587. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  18588. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  18589. m.sop_task = &id
  18590. }
  18591. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  18592. func (m *SopStageMutation) ClearSopTask() {
  18593. m.clearedsop_task = true
  18594. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  18595. }
  18596. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  18597. func (m *SopStageMutation) SopTaskCleared() bool {
  18598. return m.clearedsop_task
  18599. }
  18600. // SopTaskID returns the "sop_task" edge ID in the mutation.
  18601. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  18602. if m.sop_task != nil {
  18603. return *m.sop_task, true
  18604. }
  18605. return
  18606. }
  18607. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  18608. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18609. // SopTaskID instead. It exists only for internal usage by the builders.
  18610. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  18611. if id := m.sop_task; id != nil {
  18612. ids = append(ids, *id)
  18613. }
  18614. return
  18615. }
  18616. // ResetSopTask resets all changes to the "sop_task" edge.
  18617. func (m *SopStageMutation) ResetSopTask() {
  18618. m.sop_task = nil
  18619. m.clearedsop_task = false
  18620. }
  18621. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  18622. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  18623. if m.stage_nodes == nil {
  18624. m.stage_nodes = make(map[uint64]struct{})
  18625. }
  18626. for i := range ids {
  18627. m.stage_nodes[ids[i]] = struct{}{}
  18628. }
  18629. }
  18630. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  18631. func (m *SopStageMutation) ClearStageNodes() {
  18632. m.clearedstage_nodes = true
  18633. }
  18634. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  18635. func (m *SopStageMutation) StageNodesCleared() bool {
  18636. return m.clearedstage_nodes
  18637. }
  18638. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  18639. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  18640. if m.removedstage_nodes == nil {
  18641. m.removedstage_nodes = make(map[uint64]struct{})
  18642. }
  18643. for i := range ids {
  18644. delete(m.stage_nodes, ids[i])
  18645. m.removedstage_nodes[ids[i]] = struct{}{}
  18646. }
  18647. }
  18648. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  18649. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  18650. for id := range m.removedstage_nodes {
  18651. ids = append(ids, id)
  18652. }
  18653. return
  18654. }
  18655. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  18656. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  18657. for id := range m.stage_nodes {
  18658. ids = append(ids, id)
  18659. }
  18660. return
  18661. }
  18662. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  18663. func (m *SopStageMutation) ResetStageNodes() {
  18664. m.stage_nodes = nil
  18665. m.clearedstage_nodes = false
  18666. m.removedstage_nodes = nil
  18667. }
  18668. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  18669. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  18670. if m.stage_messages == nil {
  18671. m.stage_messages = make(map[uint64]struct{})
  18672. }
  18673. for i := range ids {
  18674. m.stage_messages[ids[i]] = struct{}{}
  18675. }
  18676. }
  18677. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  18678. func (m *SopStageMutation) ClearStageMessages() {
  18679. m.clearedstage_messages = true
  18680. }
  18681. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  18682. func (m *SopStageMutation) StageMessagesCleared() bool {
  18683. return m.clearedstage_messages
  18684. }
  18685. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  18686. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  18687. if m.removedstage_messages == nil {
  18688. m.removedstage_messages = make(map[uint64]struct{})
  18689. }
  18690. for i := range ids {
  18691. delete(m.stage_messages, ids[i])
  18692. m.removedstage_messages[ids[i]] = struct{}{}
  18693. }
  18694. }
  18695. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  18696. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  18697. for id := range m.removedstage_messages {
  18698. ids = append(ids, id)
  18699. }
  18700. return
  18701. }
  18702. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  18703. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  18704. for id := range m.stage_messages {
  18705. ids = append(ids, id)
  18706. }
  18707. return
  18708. }
  18709. // ResetStageMessages resets all changes to the "stage_messages" edge.
  18710. func (m *SopStageMutation) ResetStageMessages() {
  18711. m.stage_messages = nil
  18712. m.clearedstage_messages = false
  18713. m.removedstage_messages = nil
  18714. }
  18715. // Where appends a list predicates to the SopStageMutation builder.
  18716. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  18717. m.predicates = append(m.predicates, ps...)
  18718. }
  18719. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  18720. // users can use type-assertion to append predicates that do not depend on any generated package.
  18721. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  18722. p := make([]predicate.SopStage, len(ps))
  18723. for i := range ps {
  18724. p[i] = ps[i]
  18725. }
  18726. m.Where(p...)
  18727. }
  18728. // Op returns the operation name.
  18729. func (m *SopStageMutation) Op() Op {
  18730. return m.op
  18731. }
  18732. // SetOp allows setting the mutation operation.
  18733. func (m *SopStageMutation) SetOp(op Op) {
  18734. m.op = op
  18735. }
  18736. // Type returns the node type of this mutation (SopStage).
  18737. func (m *SopStageMutation) Type() string {
  18738. return m.typ
  18739. }
  18740. // Fields returns all fields that were changed during this mutation. Note that in
  18741. // order to get all numeric fields that were incremented/decremented, call
  18742. // AddedFields().
  18743. func (m *SopStageMutation) Fields() []string {
  18744. fields := make([]string, 0, 14)
  18745. if m.created_at != nil {
  18746. fields = append(fields, sopstage.FieldCreatedAt)
  18747. }
  18748. if m.updated_at != nil {
  18749. fields = append(fields, sopstage.FieldUpdatedAt)
  18750. }
  18751. if m.status != nil {
  18752. fields = append(fields, sopstage.FieldStatus)
  18753. }
  18754. if m.deleted_at != nil {
  18755. fields = append(fields, sopstage.FieldDeletedAt)
  18756. }
  18757. if m.sop_task != nil {
  18758. fields = append(fields, sopstage.FieldTaskID)
  18759. }
  18760. if m.name != nil {
  18761. fields = append(fields, sopstage.FieldName)
  18762. }
  18763. if m.condition_type != nil {
  18764. fields = append(fields, sopstage.FieldConditionType)
  18765. }
  18766. if m.condition_operator != nil {
  18767. fields = append(fields, sopstage.FieldConditionOperator)
  18768. }
  18769. if m.condition_list != nil {
  18770. fields = append(fields, sopstage.FieldConditionList)
  18771. }
  18772. if m.action_message != nil {
  18773. fields = append(fields, sopstage.FieldActionMessage)
  18774. }
  18775. if m.action_label_add != nil {
  18776. fields = append(fields, sopstage.FieldActionLabelAdd)
  18777. }
  18778. if m.action_label_del != nil {
  18779. fields = append(fields, sopstage.FieldActionLabelDel)
  18780. }
  18781. if m.action_forward != nil {
  18782. fields = append(fields, sopstage.FieldActionForward)
  18783. }
  18784. if m.index_sort != nil {
  18785. fields = append(fields, sopstage.FieldIndexSort)
  18786. }
  18787. return fields
  18788. }
  18789. // Field returns the value of a field with the given name. The second boolean
  18790. // return value indicates that this field was not set, or was not defined in the
  18791. // schema.
  18792. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  18793. switch name {
  18794. case sopstage.FieldCreatedAt:
  18795. return m.CreatedAt()
  18796. case sopstage.FieldUpdatedAt:
  18797. return m.UpdatedAt()
  18798. case sopstage.FieldStatus:
  18799. return m.Status()
  18800. case sopstage.FieldDeletedAt:
  18801. return m.DeletedAt()
  18802. case sopstage.FieldTaskID:
  18803. return m.TaskID()
  18804. case sopstage.FieldName:
  18805. return m.Name()
  18806. case sopstage.FieldConditionType:
  18807. return m.ConditionType()
  18808. case sopstage.FieldConditionOperator:
  18809. return m.ConditionOperator()
  18810. case sopstage.FieldConditionList:
  18811. return m.ConditionList()
  18812. case sopstage.FieldActionMessage:
  18813. return m.ActionMessage()
  18814. case sopstage.FieldActionLabelAdd:
  18815. return m.ActionLabelAdd()
  18816. case sopstage.FieldActionLabelDel:
  18817. return m.ActionLabelDel()
  18818. case sopstage.FieldActionForward:
  18819. return m.ActionForward()
  18820. case sopstage.FieldIndexSort:
  18821. return m.IndexSort()
  18822. }
  18823. return nil, false
  18824. }
  18825. // OldField returns the old value of the field from the database. An error is
  18826. // returned if the mutation operation is not UpdateOne, or the query to the
  18827. // database failed.
  18828. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18829. switch name {
  18830. case sopstage.FieldCreatedAt:
  18831. return m.OldCreatedAt(ctx)
  18832. case sopstage.FieldUpdatedAt:
  18833. return m.OldUpdatedAt(ctx)
  18834. case sopstage.FieldStatus:
  18835. return m.OldStatus(ctx)
  18836. case sopstage.FieldDeletedAt:
  18837. return m.OldDeletedAt(ctx)
  18838. case sopstage.FieldTaskID:
  18839. return m.OldTaskID(ctx)
  18840. case sopstage.FieldName:
  18841. return m.OldName(ctx)
  18842. case sopstage.FieldConditionType:
  18843. return m.OldConditionType(ctx)
  18844. case sopstage.FieldConditionOperator:
  18845. return m.OldConditionOperator(ctx)
  18846. case sopstage.FieldConditionList:
  18847. return m.OldConditionList(ctx)
  18848. case sopstage.FieldActionMessage:
  18849. return m.OldActionMessage(ctx)
  18850. case sopstage.FieldActionLabelAdd:
  18851. return m.OldActionLabelAdd(ctx)
  18852. case sopstage.FieldActionLabelDel:
  18853. return m.OldActionLabelDel(ctx)
  18854. case sopstage.FieldActionForward:
  18855. return m.OldActionForward(ctx)
  18856. case sopstage.FieldIndexSort:
  18857. return m.OldIndexSort(ctx)
  18858. }
  18859. return nil, fmt.Errorf("unknown SopStage field %s", name)
  18860. }
  18861. // SetField sets the value of a field with the given name. It returns an error if
  18862. // the field is not defined in the schema, or if the type mismatched the field
  18863. // type.
  18864. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  18865. switch name {
  18866. case sopstage.FieldCreatedAt:
  18867. v, ok := value.(time.Time)
  18868. if !ok {
  18869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18870. }
  18871. m.SetCreatedAt(v)
  18872. return nil
  18873. case sopstage.FieldUpdatedAt:
  18874. v, ok := value.(time.Time)
  18875. if !ok {
  18876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18877. }
  18878. m.SetUpdatedAt(v)
  18879. return nil
  18880. case sopstage.FieldStatus:
  18881. v, ok := value.(uint8)
  18882. if !ok {
  18883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18884. }
  18885. m.SetStatus(v)
  18886. return nil
  18887. case sopstage.FieldDeletedAt:
  18888. v, ok := value.(time.Time)
  18889. if !ok {
  18890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18891. }
  18892. m.SetDeletedAt(v)
  18893. return nil
  18894. case sopstage.FieldTaskID:
  18895. v, ok := value.(uint64)
  18896. if !ok {
  18897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18898. }
  18899. m.SetTaskID(v)
  18900. return nil
  18901. case sopstage.FieldName:
  18902. v, ok := value.(string)
  18903. if !ok {
  18904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18905. }
  18906. m.SetName(v)
  18907. return nil
  18908. case sopstage.FieldConditionType:
  18909. v, ok := value.(int)
  18910. if !ok {
  18911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18912. }
  18913. m.SetConditionType(v)
  18914. return nil
  18915. case sopstage.FieldConditionOperator:
  18916. v, ok := value.(int)
  18917. if !ok {
  18918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18919. }
  18920. m.SetConditionOperator(v)
  18921. return nil
  18922. case sopstage.FieldConditionList:
  18923. v, ok := value.([]custom_types.Condition)
  18924. if !ok {
  18925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18926. }
  18927. m.SetConditionList(v)
  18928. return nil
  18929. case sopstage.FieldActionMessage:
  18930. v, ok := value.([]custom_types.Action)
  18931. if !ok {
  18932. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18933. }
  18934. m.SetActionMessage(v)
  18935. return nil
  18936. case sopstage.FieldActionLabelAdd:
  18937. v, ok := value.([]uint64)
  18938. if !ok {
  18939. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18940. }
  18941. m.SetActionLabelAdd(v)
  18942. return nil
  18943. case sopstage.FieldActionLabelDel:
  18944. v, ok := value.([]uint64)
  18945. if !ok {
  18946. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18947. }
  18948. m.SetActionLabelDel(v)
  18949. return nil
  18950. case sopstage.FieldActionForward:
  18951. v, ok := value.(*custom_types.ActionForward)
  18952. if !ok {
  18953. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18954. }
  18955. m.SetActionForward(v)
  18956. return nil
  18957. case sopstage.FieldIndexSort:
  18958. v, ok := value.(int)
  18959. if !ok {
  18960. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18961. }
  18962. m.SetIndexSort(v)
  18963. return nil
  18964. }
  18965. return fmt.Errorf("unknown SopStage field %s", name)
  18966. }
  18967. // AddedFields returns all numeric fields that were incremented/decremented during
  18968. // this mutation.
  18969. func (m *SopStageMutation) AddedFields() []string {
  18970. var fields []string
  18971. if m.addstatus != nil {
  18972. fields = append(fields, sopstage.FieldStatus)
  18973. }
  18974. if m.addcondition_type != nil {
  18975. fields = append(fields, sopstage.FieldConditionType)
  18976. }
  18977. if m.addcondition_operator != nil {
  18978. fields = append(fields, sopstage.FieldConditionOperator)
  18979. }
  18980. if m.addindex_sort != nil {
  18981. fields = append(fields, sopstage.FieldIndexSort)
  18982. }
  18983. return fields
  18984. }
  18985. // AddedField returns the numeric value that was incremented/decremented on a field
  18986. // with the given name. The second boolean return value indicates that this field
  18987. // was not set, or was not defined in the schema.
  18988. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  18989. switch name {
  18990. case sopstage.FieldStatus:
  18991. return m.AddedStatus()
  18992. case sopstage.FieldConditionType:
  18993. return m.AddedConditionType()
  18994. case sopstage.FieldConditionOperator:
  18995. return m.AddedConditionOperator()
  18996. case sopstage.FieldIndexSort:
  18997. return m.AddedIndexSort()
  18998. }
  18999. return nil, false
  19000. }
  19001. // AddField adds the value to the field with the given name. It returns an error if
  19002. // the field is not defined in the schema, or if the type mismatched the field
  19003. // type.
  19004. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  19005. switch name {
  19006. case sopstage.FieldStatus:
  19007. v, ok := value.(int8)
  19008. if !ok {
  19009. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19010. }
  19011. m.AddStatus(v)
  19012. return nil
  19013. case sopstage.FieldConditionType:
  19014. v, ok := value.(int)
  19015. if !ok {
  19016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19017. }
  19018. m.AddConditionType(v)
  19019. return nil
  19020. case sopstage.FieldConditionOperator:
  19021. v, ok := value.(int)
  19022. if !ok {
  19023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19024. }
  19025. m.AddConditionOperator(v)
  19026. return nil
  19027. case sopstage.FieldIndexSort:
  19028. v, ok := value.(int)
  19029. if !ok {
  19030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19031. }
  19032. m.AddIndexSort(v)
  19033. return nil
  19034. }
  19035. return fmt.Errorf("unknown SopStage numeric field %s", name)
  19036. }
  19037. // ClearedFields returns all nullable fields that were cleared during this
  19038. // mutation.
  19039. func (m *SopStageMutation) ClearedFields() []string {
  19040. var fields []string
  19041. if m.FieldCleared(sopstage.FieldStatus) {
  19042. fields = append(fields, sopstage.FieldStatus)
  19043. }
  19044. if m.FieldCleared(sopstage.FieldDeletedAt) {
  19045. fields = append(fields, sopstage.FieldDeletedAt)
  19046. }
  19047. if m.FieldCleared(sopstage.FieldActionMessage) {
  19048. fields = append(fields, sopstage.FieldActionMessage)
  19049. }
  19050. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  19051. fields = append(fields, sopstage.FieldActionLabelAdd)
  19052. }
  19053. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  19054. fields = append(fields, sopstage.FieldActionLabelDel)
  19055. }
  19056. if m.FieldCleared(sopstage.FieldActionForward) {
  19057. fields = append(fields, sopstage.FieldActionForward)
  19058. }
  19059. if m.FieldCleared(sopstage.FieldIndexSort) {
  19060. fields = append(fields, sopstage.FieldIndexSort)
  19061. }
  19062. return fields
  19063. }
  19064. // FieldCleared returns a boolean indicating if a field with the given name was
  19065. // cleared in this mutation.
  19066. func (m *SopStageMutation) FieldCleared(name string) bool {
  19067. _, ok := m.clearedFields[name]
  19068. return ok
  19069. }
  19070. // ClearField clears the value of the field with the given name. It returns an
  19071. // error if the field is not defined in the schema.
  19072. func (m *SopStageMutation) ClearField(name string) error {
  19073. switch name {
  19074. case sopstage.FieldStatus:
  19075. m.ClearStatus()
  19076. return nil
  19077. case sopstage.FieldDeletedAt:
  19078. m.ClearDeletedAt()
  19079. return nil
  19080. case sopstage.FieldActionMessage:
  19081. m.ClearActionMessage()
  19082. return nil
  19083. case sopstage.FieldActionLabelAdd:
  19084. m.ClearActionLabelAdd()
  19085. return nil
  19086. case sopstage.FieldActionLabelDel:
  19087. m.ClearActionLabelDel()
  19088. return nil
  19089. case sopstage.FieldActionForward:
  19090. m.ClearActionForward()
  19091. return nil
  19092. case sopstage.FieldIndexSort:
  19093. m.ClearIndexSort()
  19094. return nil
  19095. }
  19096. return fmt.Errorf("unknown SopStage nullable field %s", name)
  19097. }
  19098. // ResetField resets all changes in the mutation for the field with the given name.
  19099. // It returns an error if the field is not defined in the schema.
  19100. func (m *SopStageMutation) ResetField(name string) error {
  19101. switch name {
  19102. case sopstage.FieldCreatedAt:
  19103. m.ResetCreatedAt()
  19104. return nil
  19105. case sopstage.FieldUpdatedAt:
  19106. m.ResetUpdatedAt()
  19107. return nil
  19108. case sopstage.FieldStatus:
  19109. m.ResetStatus()
  19110. return nil
  19111. case sopstage.FieldDeletedAt:
  19112. m.ResetDeletedAt()
  19113. return nil
  19114. case sopstage.FieldTaskID:
  19115. m.ResetTaskID()
  19116. return nil
  19117. case sopstage.FieldName:
  19118. m.ResetName()
  19119. return nil
  19120. case sopstage.FieldConditionType:
  19121. m.ResetConditionType()
  19122. return nil
  19123. case sopstage.FieldConditionOperator:
  19124. m.ResetConditionOperator()
  19125. return nil
  19126. case sopstage.FieldConditionList:
  19127. m.ResetConditionList()
  19128. return nil
  19129. case sopstage.FieldActionMessage:
  19130. m.ResetActionMessage()
  19131. return nil
  19132. case sopstage.FieldActionLabelAdd:
  19133. m.ResetActionLabelAdd()
  19134. return nil
  19135. case sopstage.FieldActionLabelDel:
  19136. m.ResetActionLabelDel()
  19137. return nil
  19138. case sopstage.FieldActionForward:
  19139. m.ResetActionForward()
  19140. return nil
  19141. case sopstage.FieldIndexSort:
  19142. m.ResetIndexSort()
  19143. return nil
  19144. }
  19145. return fmt.Errorf("unknown SopStage field %s", name)
  19146. }
  19147. // AddedEdges returns all edge names that were set/added in this mutation.
  19148. func (m *SopStageMutation) AddedEdges() []string {
  19149. edges := make([]string, 0, 3)
  19150. if m.sop_task != nil {
  19151. edges = append(edges, sopstage.EdgeSopTask)
  19152. }
  19153. if m.stage_nodes != nil {
  19154. edges = append(edges, sopstage.EdgeStageNodes)
  19155. }
  19156. if m.stage_messages != nil {
  19157. edges = append(edges, sopstage.EdgeStageMessages)
  19158. }
  19159. return edges
  19160. }
  19161. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19162. // name in this mutation.
  19163. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  19164. switch name {
  19165. case sopstage.EdgeSopTask:
  19166. if id := m.sop_task; id != nil {
  19167. return []ent.Value{*id}
  19168. }
  19169. case sopstage.EdgeStageNodes:
  19170. ids := make([]ent.Value, 0, len(m.stage_nodes))
  19171. for id := range m.stage_nodes {
  19172. ids = append(ids, id)
  19173. }
  19174. return ids
  19175. case sopstage.EdgeStageMessages:
  19176. ids := make([]ent.Value, 0, len(m.stage_messages))
  19177. for id := range m.stage_messages {
  19178. ids = append(ids, id)
  19179. }
  19180. return ids
  19181. }
  19182. return nil
  19183. }
  19184. // RemovedEdges returns all edge names that were removed in this mutation.
  19185. func (m *SopStageMutation) RemovedEdges() []string {
  19186. edges := make([]string, 0, 3)
  19187. if m.removedstage_nodes != nil {
  19188. edges = append(edges, sopstage.EdgeStageNodes)
  19189. }
  19190. if m.removedstage_messages != nil {
  19191. edges = append(edges, sopstage.EdgeStageMessages)
  19192. }
  19193. return edges
  19194. }
  19195. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19196. // the given name in this mutation.
  19197. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  19198. switch name {
  19199. case sopstage.EdgeStageNodes:
  19200. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  19201. for id := range m.removedstage_nodes {
  19202. ids = append(ids, id)
  19203. }
  19204. return ids
  19205. case sopstage.EdgeStageMessages:
  19206. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  19207. for id := range m.removedstage_messages {
  19208. ids = append(ids, id)
  19209. }
  19210. return ids
  19211. }
  19212. return nil
  19213. }
  19214. // ClearedEdges returns all edge names that were cleared in this mutation.
  19215. func (m *SopStageMutation) ClearedEdges() []string {
  19216. edges := make([]string, 0, 3)
  19217. if m.clearedsop_task {
  19218. edges = append(edges, sopstage.EdgeSopTask)
  19219. }
  19220. if m.clearedstage_nodes {
  19221. edges = append(edges, sopstage.EdgeStageNodes)
  19222. }
  19223. if m.clearedstage_messages {
  19224. edges = append(edges, sopstage.EdgeStageMessages)
  19225. }
  19226. return edges
  19227. }
  19228. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19229. // was cleared in this mutation.
  19230. func (m *SopStageMutation) EdgeCleared(name string) bool {
  19231. switch name {
  19232. case sopstage.EdgeSopTask:
  19233. return m.clearedsop_task
  19234. case sopstage.EdgeStageNodes:
  19235. return m.clearedstage_nodes
  19236. case sopstage.EdgeStageMessages:
  19237. return m.clearedstage_messages
  19238. }
  19239. return false
  19240. }
  19241. // ClearEdge clears the value of the edge with the given name. It returns an error
  19242. // if that edge is not defined in the schema.
  19243. func (m *SopStageMutation) ClearEdge(name string) error {
  19244. switch name {
  19245. case sopstage.EdgeSopTask:
  19246. m.ClearSopTask()
  19247. return nil
  19248. }
  19249. return fmt.Errorf("unknown SopStage unique edge %s", name)
  19250. }
  19251. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19252. // It returns an error if the edge is not defined in the schema.
  19253. func (m *SopStageMutation) ResetEdge(name string) error {
  19254. switch name {
  19255. case sopstage.EdgeSopTask:
  19256. m.ResetSopTask()
  19257. return nil
  19258. case sopstage.EdgeStageNodes:
  19259. m.ResetStageNodes()
  19260. return nil
  19261. case sopstage.EdgeStageMessages:
  19262. m.ResetStageMessages()
  19263. return nil
  19264. }
  19265. return fmt.Errorf("unknown SopStage edge %s", name)
  19266. }
  19267. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  19268. type SopTaskMutation struct {
  19269. config
  19270. op Op
  19271. typ string
  19272. id *uint64
  19273. created_at *time.Time
  19274. updated_at *time.Time
  19275. status *uint8
  19276. addstatus *int8
  19277. deleted_at *time.Time
  19278. name *string
  19279. bot_wxid_list *[]string
  19280. appendbot_wxid_list []string
  19281. _type *int
  19282. add_type *int
  19283. plan_start_time *time.Time
  19284. plan_end_time *time.Time
  19285. creator_id *string
  19286. organization_id *uint64
  19287. addorganization_id *int64
  19288. token *[]string
  19289. appendtoken []string
  19290. clearedFields map[string]struct{}
  19291. task_stages map[uint64]struct{}
  19292. removedtask_stages map[uint64]struct{}
  19293. clearedtask_stages bool
  19294. done bool
  19295. oldValue func(context.Context) (*SopTask, error)
  19296. predicates []predicate.SopTask
  19297. }
  19298. var _ ent.Mutation = (*SopTaskMutation)(nil)
  19299. // soptaskOption allows management of the mutation configuration using functional options.
  19300. type soptaskOption func(*SopTaskMutation)
  19301. // newSopTaskMutation creates new mutation for the SopTask entity.
  19302. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  19303. m := &SopTaskMutation{
  19304. config: c,
  19305. op: op,
  19306. typ: TypeSopTask,
  19307. clearedFields: make(map[string]struct{}),
  19308. }
  19309. for _, opt := range opts {
  19310. opt(m)
  19311. }
  19312. return m
  19313. }
  19314. // withSopTaskID sets the ID field of the mutation.
  19315. func withSopTaskID(id uint64) soptaskOption {
  19316. return func(m *SopTaskMutation) {
  19317. var (
  19318. err error
  19319. once sync.Once
  19320. value *SopTask
  19321. )
  19322. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  19323. once.Do(func() {
  19324. if m.done {
  19325. err = errors.New("querying old values post mutation is not allowed")
  19326. } else {
  19327. value, err = m.Client().SopTask.Get(ctx, id)
  19328. }
  19329. })
  19330. return value, err
  19331. }
  19332. m.id = &id
  19333. }
  19334. }
  19335. // withSopTask sets the old SopTask of the mutation.
  19336. func withSopTask(node *SopTask) soptaskOption {
  19337. return func(m *SopTaskMutation) {
  19338. m.oldValue = func(context.Context) (*SopTask, error) {
  19339. return node, nil
  19340. }
  19341. m.id = &node.ID
  19342. }
  19343. }
  19344. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19345. // executed in a transaction (ent.Tx), a transactional client is returned.
  19346. func (m SopTaskMutation) Client() *Client {
  19347. client := &Client{config: m.config}
  19348. client.init()
  19349. return client
  19350. }
  19351. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19352. // it returns an error otherwise.
  19353. func (m SopTaskMutation) Tx() (*Tx, error) {
  19354. if _, ok := m.driver.(*txDriver); !ok {
  19355. return nil, errors.New("ent: mutation is not running in a transaction")
  19356. }
  19357. tx := &Tx{config: m.config}
  19358. tx.init()
  19359. return tx, nil
  19360. }
  19361. // SetID sets the value of the id field. Note that this
  19362. // operation is only accepted on creation of SopTask entities.
  19363. func (m *SopTaskMutation) SetID(id uint64) {
  19364. m.id = &id
  19365. }
  19366. // ID returns the ID value in the mutation. Note that the ID is only available
  19367. // if it was provided to the builder or after it was returned from the database.
  19368. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  19369. if m.id == nil {
  19370. return
  19371. }
  19372. return *m.id, true
  19373. }
  19374. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19375. // That means, if the mutation is applied within a transaction with an isolation level such
  19376. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19377. // or updated by the mutation.
  19378. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  19379. switch {
  19380. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19381. id, exists := m.ID()
  19382. if exists {
  19383. return []uint64{id}, nil
  19384. }
  19385. fallthrough
  19386. case m.op.Is(OpUpdate | OpDelete):
  19387. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  19388. default:
  19389. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19390. }
  19391. }
  19392. // SetCreatedAt sets the "created_at" field.
  19393. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  19394. m.created_at = &t
  19395. }
  19396. // CreatedAt returns the value of the "created_at" field in the mutation.
  19397. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  19398. v := m.created_at
  19399. if v == nil {
  19400. return
  19401. }
  19402. return *v, true
  19403. }
  19404. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  19405. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19407. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19408. if !m.op.Is(OpUpdateOne) {
  19409. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19410. }
  19411. if m.id == nil || m.oldValue == nil {
  19412. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19413. }
  19414. oldValue, err := m.oldValue(ctx)
  19415. if err != nil {
  19416. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19417. }
  19418. return oldValue.CreatedAt, nil
  19419. }
  19420. // ResetCreatedAt resets all changes to the "created_at" field.
  19421. func (m *SopTaskMutation) ResetCreatedAt() {
  19422. m.created_at = nil
  19423. }
  19424. // SetUpdatedAt sets the "updated_at" field.
  19425. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  19426. m.updated_at = &t
  19427. }
  19428. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19429. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  19430. v := m.updated_at
  19431. if v == nil {
  19432. return
  19433. }
  19434. return *v, true
  19435. }
  19436. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  19437. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19438. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19439. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19440. if !m.op.Is(OpUpdateOne) {
  19441. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19442. }
  19443. if m.id == nil || m.oldValue == nil {
  19444. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19445. }
  19446. oldValue, err := m.oldValue(ctx)
  19447. if err != nil {
  19448. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19449. }
  19450. return oldValue.UpdatedAt, nil
  19451. }
  19452. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19453. func (m *SopTaskMutation) ResetUpdatedAt() {
  19454. m.updated_at = nil
  19455. }
  19456. // SetStatus sets the "status" field.
  19457. func (m *SopTaskMutation) SetStatus(u uint8) {
  19458. m.status = &u
  19459. m.addstatus = nil
  19460. }
  19461. // Status returns the value of the "status" field in the mutation.
  19462. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  19463. v := m.status
  19464. if v == nil {
  19465. return
  19466. }
  19467. return *v, true
  19468. }
  19469. // OldStatus returns the old "status" field's value of the SopTask entity.
  19470. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19472. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19473. if !m.op.Is(OpUpdateOne) {
  19474. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19475. }
  19476. if m.id == nil || m.oldValue == nil {
  19477. return v, errors.New("OldStatus requires an ID field in the mutation")
  19478. }
  19479. oldValue, err := m.oldValue(ctx)
  19480. if err != nil {
  19481. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19482. }
  19483. return oldValue.Status, nil
  19484. }
  19485. // AddStatus adds u to the "status" field.
  19486. func (m *SopTaskMutation) AddStatus(u int8) {
  19487. if m.addstatus != nil {
  19488. *m.addstatus += u
  19489. } else {
  19490. m.addstatus = &u
  19491. }
  19492. }
  19493. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19494. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  19495. v := m.addstatus
  19496. if v == nil {
  19497. return
  19498. }
  19499. return *v, true
  19500. }
  19501. // ClearStatus clears the value of the "status" field.
  19502. func (m *SopTaskMutation) ClearStatus() {
  19503. m.status = nil
  19504. m.addstatus = nil
  19505. m.clearedFields[soptask.FieldStatus] = struct{}{}
  19506. }
  19507. // StatusCleared returns if the "status" field was cleared in this mutation.
  19508. func (m *SopTaskMutation) StatusCleared() bool {
  19509. _, ok := m.clearedFields[soptask.FieldStatus]
  19510. return ok
  19511. }
  19512. // ResetStatus resets all changes to the "status" field.
  19513. func (m *SopTaskMutation) ResetStatus() {
  19514. m.status = nil
  19515. m.addstatus = nil
  19516. delete(m.clearedFields, soptask.FieldStatus)
  19517. }
  19518. // SetDeletedAt sets the "deleted_at" field.
  19519. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  19520. m.deleted_at = &t
  19521. }
  19522. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19523. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  19524. v := m.deleted_at
  19525. if v == nil {
  19526. return
  19527. }
  19528. return *v, true
  19529. }
  19530. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  19531. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19533. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19534. if !m.op.Is(OpUpdateOne) {
  19535. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19536. }
  19537. if m.id == nil || m.oldValue == nil {
  19538. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19539. }
  19540. oldValue, err := m.oldValue(ctx)
  19541. if err != nil {
  19542. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19543. }
  19544. return oldValue.DeletedAt, nil
  19545. }
  19546. // ClearDeletedAt clears the value of the "deleted_at" field.
  19547. func (m *SopTaskMutation) ClearDeletedAt() {
  19548. m.deleted_at = nil
  19549. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  19550. }
  19551. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19552. func (m *SopTaskMutation) DeletedAtCleared() bool {
  19553. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  19554. return ok
  19555. }
  19556. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19557. func (m *SopTaskMutation) ResetDeletedAt() {
  19558. m.deleted_at = nil
  19559. delete(m.clearedFields, soptask.FieldDeletedAt)
  19560. }
  19561. // SetName sets the "name" field.
  19562. func (m *SopTaskMutation) SetName(s string) {
  19563. m.name = &s
  19564. }
  19565. // Name returns the value of the "name" field in the mutation.
  19566. func (m *SopTaskMutation) Name() (r string, exists bool) {
  19567. v := m.name
  19568. if v == nil {
  19569. return
  19570. }
  19571. return *v, true
  19572. }
  19573. // OldName returns the old "name" field's value of the SopTask entity.
  19574. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19575. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19576. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  19577. if !m.op.Is(OpUpdateOne) {
  19578. return v, errors.New("OldName is only allowed on UpdateOne operations")
  19579. }
  19580. if m.id == nil || m.oldValue == nil {
  19581. return v, errors.New("OldName requires an ID field in the mutation")
  19582. }
  19583. oldValue, err := m.oldValue(ctx)
  19584. if err != nil {
  19585. return v, fmt.Errorf("querying old value for OldName: %w", err)
  19586. }
  19587. return oldValue.Name, nil
  19588. }
  19589. // ResetName resets all changes to the "name" field.
  19590. func (m *SopTaskMutation) ResetName() {
  19591. m.name = nil
  19592. }
  19593. // SetBotWxidList sets the "bot_wxid_list" field.
  19594. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  19595. m.bot_wxid_list = &s
  19596. m.appendbot_wxid_list = nil
  19597. }
  19598. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  19599. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  19600. v := m.bot_wxid_list
  19601. if v == nil {
  19602. return
  19603. }
  19604. return *v, true
  19605. }
  19606. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  19607. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19608. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19609. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  19610. if !m.op.Is(OpUpdateOne) {
  19611. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  19612. }
  19613. if m.id == nil || m.oldValue == nil {
  19614. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  19615. }
  19616. oldValue, err := m.oldValue(ctx)
  19617. if err != nil {
  19618. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  19619. }
  19620. return oldValue.BotWxidList, nil
  19621. }
  19622. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  19623. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  19624. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  19625. }
  19626. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  19627. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  19628. if len(m.appendbot_wxid_list) == 0 {
  19629. return nil, false
  19630. }
  19631. return m.appendbot_wxid_list, true
  19632. }
  19633. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  19634. func (m *SopTaskMutation) ClearBotWxidList() {
  19635. m.bot_wxid_list = nil
  19636. m.appendbot_wxid_list = nil
  19637. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  19638. }
  19639. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  19640. func (m *SopTaskMutation) BotWxidListCleared() bool {
  19641. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  19642. return ok
  19643. }
  19644. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  19645. func (m *SopTaskMutation) ResetBotWxidList() {
  19646. m.bot_wxid_list = nil
  19647. m.appendbot_wxid_list = nil
  19648. delete(m.clearedFields, soptask.FieldBotWxidList)
  19649. }
  19650. // SetType sets the "type" field.
  19651. func (m *SopTaskMutation) SetType(i int) {
  19652. m._type = &i
  19653. m.add_type = nil
  19654. }
  19655. // GetType returns the value of the "type" field in the mutation.
  19656. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  19657. v := m._type
  19658. if v == nil {
  19659. return
  19660. }
  19661. return *v, true
  19662. }
  19663. // OldType returns the old "type" field's value of the SopTask entity.
  19664. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19665. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19666. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  19667. if !m.op.Is(OpUpdateOne) {
  19668. return v, errors.New("OldType is only allowed on UpdateOne operations")
  19669. }
  19670. if m.id == nil || m.oldValue == nil {
  19671. return v, errors.New("OldType requires an ID field in the mutation")
  19672. }
  19673. oldValue, err := m.oldValue(ctx)
  19674. if err != nil {
  19675. return v, fmt.Errorf("querying old value for OldType: %w", err)
  19676. }
  19677. return oldValue.Type, nil
  19678. }
  19679. // AddType adds i to the "type" field.
  19680. func (m *SopTaskMutation) AddType(i int) {
  19681. if m.add_type != nil {
  19682. *m.add_type += i
  19683. } else {
  19684. m.add_type = &i
  19685. }
  19686. }
  19687. // AddedType returns the value that was added to the "type" field in this mutation.
  19688. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  19689. v := m.add_type
  19690. if v == nil {
  19691. return
  19692. }
  19693. return *v, true
  19694. }
  19695. // ResetType resets all changes to the "type" field.
  19696. func (m *SopTaskMutation) ResetType() {
  19697. m._type = nil
  19698. m.add_type = nil
  19699. }
  19700. // SetPlanStartTime sets the "plan_start_time" field.
  19701. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  19702. m.plan_start_time = &t
  19703. }
  19704. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  19705. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  19706. v := m.plan_start_time
  19707. if v == nil {
  19708. return
  19709. }
  19710. return *v, true
  19711. }
  19712. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  19713. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19714. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19715. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  19716. if !m.op.Is(OpUpdateOne) {
  19717. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  19718. }
  19719. if m.id == nil || m.oldValue == nil {
  19720. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  19721. }
  19722. oldValue, err := m.oldValue(ctx)
  19723. if err != nil {
  19724. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  19725. }
  19726. return oldValue.PlanStartTime, nil
  19727. }
  19728. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  19729. func (m *SopTaskMutation) ClearPlanStartTime() {
  19730. m.plan_start_time = nil
  19731. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  19732. }
  19733. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  19734. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  19735. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  19736. return ok
  19737. }
  19738. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  19739. func (m *SopTaskMutation) ResetPlanStartTime() {
  19740. m.plan_start_time = nil
  19741. delete(m.clearedFields, soptask.FieldPlanStartTime)
  19742. }
  19743. // SetPlanEndTime sets the "plan_end_time" field.
  19744. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  19745. m.plan_end_time = &t
  19746. }
  19747. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  19748. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  19749. v := m.plan_end_time
  19750. if v == nil {
  19751. return
  19752. }
  19753. return *v, true
  19754. }
  19755. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  19756. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19757. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19758. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  19759. if !m.op.Is(OpUpdateOne) {
  19760. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  19761. }
  19762. if m.id == nil || m.oldValue == nil {
  19763. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  19764. }
  19765. oldValue, err := m.oldValue(ctx)
  19766. if err != nil {
  19767. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  19768. }
  19769. return oldValue.PlanEndTime, nil
  19770. }
  19771. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  19772. func (m *SopTaskMutation) ClearPlanEndTime() {
  19773. m.plan_end_time = nil
  19774. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  19775. }
  19776. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  19777. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  19778. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  19779. return ok
  19780. }
  19781. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  19782. func (m *SopTaskMutation) ResetPlanEndTime() {
  19783. m.plan_end_time = nil
  19784. delete(m.clearedFields, soptask.FieldPlanEndTime)
  19785. }
  19786. // SetCreatorID sets the "creator_id" field.
  19787. func (m *SopTaskMutation) SetCreatorID(s string) {
  19788. m.creator_id = &s
  19789. }
  19790. // CreatorID returns the value of the "creator_id" field in the mutation.
  19791. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  19792. v := m.creator_id
  19793. if v == nil {
  19794. return
  19795. }
  19796. return *v, true
  19797. }
  19798. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  19799. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19801. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  19802. if !m.op.Is(OpUpdateOne) {
  19803. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  19804. }
  19805. if m.id == nil || m.oldValue == nil {
  19806. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  19807. }
  19808. oldValue, err := m.oldValue(ctx)
  19809. if err != nil {
  19810. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  19811. }
  19812. return oldValue.CreatorID, nil
  19813. }
  19814. // ClearCreatorID clears the value of the "creator_id" field.
  19815. func (m *SopTaskMutation) ClearCreatorID() {
  19816. m.creator_id = nil
  19817. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  19818. }
  19819. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  19820. func (m *SopTaskMutation) CreatorIDCleared() bool {
  19821. _, ok := m.clearedFields[soptask.FieldCreatorID]
  19822. return ok
  19823. }
  19824. // ResetCreatorID resets all changes to the "creator_id" field.
  19825. func (m *SopTaskMutation) ResetCreatorID() {
  19826. m.creator_id = nil
  19827. delete(m.clearedFields, soptask.FieldCreatorID)
  19828. }
  19829. // SetOrganizationID sets the "organization_id" field.
  19830. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  19831. m.organization_id = &u
  19832. m.addorganization_id = nil
  19833. }
  19834. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19835. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  19836. v := m.organization_id
  19837. if v == nil {
  19838. return
  19839. }
  19840. return *v, true
  19841. }
  19842. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  19843. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19845. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19846. if !m.op.Is(OpUpdateOne) {
  19847. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19848. }
  19849. if m.id == nil || m.oldValue == nil {
  19850. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19851. }
  19852. oldValue, err := m.oldValue(ctx)
  19853. if err != nil {
  19854. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19855. }
  19856. return oldValue.OrganizationID, nil
  19857. }
  19858. // AddOrganizationID adds u to the "organization_id" field.
  19859. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  19860. if m.addorganization_id != nil {
  19861. *m.addorganization_id += u
  19862. } else {
  19863. m.addorganization_id = &u
  19864. }
  19865. }
  19866. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19867. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  19868. v := m.addorganization_id
  19869. if v == nil {
  19870. return
  19871. }
  19872. return *v, true
  19873. }
  19874. // ClearOrganizationID clears the value of the "organization_id" field.
  19875. func (m *SopTaskMutation) ClearOrganizationID() {
  19876. m.organization_id = nil
  19877. m.addorganization_id = nil
  19878. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  19879. }
  19880. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  19881. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  19882. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  19883. return ok
  19884. }
  19885. // ResetOrganizationID resets all changes to the "organization_id" field.
  19886. func (m *SopTaskMutation) ResetOrganizationID() {
  19887. m.organization_id = nil
  19888. m.addorganization_id = nil
  19889. delete(m.clearedFields, soptask.FieldOrganizationID)
  19890. }
  19891. // SetToken sets the "token" field.
  19892. func (m *SopTaskMutation) SetToken(s []string) {
  19893. m.token = &s
  19894. m.appendtoken = nil
  19895. }
  19896. // Token returns the value of the "token" field in the mutation.
  19897. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  19898. v := m.token
  19899. if v == nil {
  19900. return
  19901. }
  19902. return *v, true
  19903. }
  19904. // OldToken returns the old "token" field's value of the SopTask entity.
  19905. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  19906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19907. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  19908. if !m.op.Is(OpUpdateOne) {
  19909. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  19910. }
  19911. if m.id == nil || m.oldValue == nil {
  19912. return v, errors.New("OldToken requires an ID field in the mutation")
  19913. }
  19914. oldValue, err := m.oldValue(ctx)
  19915. if err != nil {
  19916. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  19917. }
  19918. return oldValue.Token, nil
  19919. }
  19920. // AppendToken adds s to the "token" field.
  19921. func (m *SopTaskMutation) AppendToken(s []string) {
  19922. m.appendtoken = append(m.appendtoken, s...)
  19923. }
  19924. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  19925. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  19926. if len(m.appendtoken) == 0 {
  19927. return nil, false
  19928. }
  19929. return m.appendtoken, true
  19930. }
  19931. // ClearToken clears the value of the "token" field.
  19932. func (m *SopTaskMutation) ClearToken() {
  19933. m.token = nil
  19934. m.appendtoken = nil
  19935. m.clearedFields[soptask.FieldToken] = struct{}{}
  19936. }
  19937. // TokenCleared returns if the "token" field was cleared in this mutation.
  19938. func (m *SopTaskMutation) TokenCleared() bool {
  19939. _, ok := m.clearedFields[soptask.FieldToken]
  19940. return ok
  19941. }
  19942. // ResetToken resets all changes to the "token" field.
  19943. func (m *SopTaskMutation) ResetToken() {
  19944. m.token = nil
  19945. m.appendtoken = nil
  19946. delete(m.clearedFields, soptask.FieldToken)
  19947. }
  19948. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  19949. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  19950. if m.task_stages == nil {
  19951. m.task_stages = make(map[uint64]struct{})
  19952. }
  19953. for i := range ids {
  19954. m.task_stages[ids[i]] = struct{}{}
  19955. }
  19956. }
  19957. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  19958. func (m *SopTaskMutation) ClearTaskStages() {
  19959. m.clearedtask_stages = true
  19960. }
  19961. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  19962. func (m *SopTaskMutation) TaskStagesCleared() bool {
  19963. return m.clearedtask_stages
  19964. }
  19965. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  19966. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  19967. if m.removedtask_stages == nil {
  19968. m.removedtask_stages = make(map[uint64]struct{})
  19969. }
  19970. for i := range ids {
  19971. delete(m.task_stages, ids[i])
  19972. m.removedtask_stages[ids[i]] = struct{}{}
  19973. }
  19974. }
  19975. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  19976. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  19977. for id := range m.removedtask_stages {
  19978. ids = append(ids, id)
  19979. }
  19980. return
  19981. }
  19982. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  19983. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  19984. for id := range m.task_stages {
  19985. ids = append(ids, id)
  19986. }
  19987. return
  19988. }
  19989. // ResetTaskStages resets all changes to the "task_stages" edge.
  19990. func (m *SopTaskMutation) ResetTaskStages() {
  19991. m.task_stages = nil
  19992. m.clearedtask_stages = false
  19993. m.removedtask_stages = nil
  19994. }
  19995. // Where appends a list predicates to the SopTaskMutation builder.
  19996. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  19997. m.predicates = append(m.predicates, ps...)
  19998. }
  19999. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  20000. // users can use type-assertion to append predicates that do not depend on any generated package.
  20001. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  20002. p := make([]predicate.SopTask, len(ps))
  20003. for i := range ps {
  20004. p[i] = ps[i]
  20005. }
  20006. m.Where(p...)
  20007. }
  20008. // Op returns the operation name.
  20009. func (m *SopTaskMutation) Op() Op {
  20010. return m.op
  20011. }
  20012. // SetOp allows setting the mutation operation.
  20013. func (m *SopTaskMutation) SetOp(op Op) {
  20014. m.op = op
  20015. }
  20016. // Type returns the node type of this mutation (SopTask).
  20017. func (m *SopTaskMutation) Type() string {
  20018. return m.typ
  20019. }
  20020. // Fields returns all fields that were changed during this mutation. Note that in
  20021. // order to get all numeric fields that were incremented/decremented, call
  20022. // AddedFields().
  20023. func (m *SopTaskMutation) Fields() []string {
  20024. fields := make([]string, 0, 12)
  20025. if m.created_at != nil {
  20026. fields = append(fields, soptask.FieldCreatedAt)
  20027. }
  20028. if m.updated_at != nil {
  20029. fields = append(fields, soptask.FieldUpdatedAt)
  20030. }
  20031. if m.status != nil {
  20032. fields = append(fields, soptask.FieldStatus)
  20033. }
  20034. if m.deleted_at != nil {
  20035. fields = append(fields, soptask.FieldDeletedAt)
  20036. }
  20037. if m.name != nil {
  20038. fields = append(fields, soptask.FieldName)
  20039. }
  20040. if m.bot_wxid_list != nil {
  20041. fields = append(fields, soptask.FieldBotWxidList)
  20042. }
  20043. if m._type != nil {
  20044. fields = append(fields, soptask.FieldType)
  20045. }
  20046. if m.plan_start_time != nil {
  20047. fields = append(fields, soptask.FieldPlanStartTime)
  20048. }
  20049. if m.plan_end_time != nil {
  20050. fields = append(fields, soptask.FieldPlanEndTime)
  20051. }
  20052. if m.creator_id != nil {
  20053. fields = append(fields, soptask.FieldCreatorID)
  20054. }
  20055. if m.organization_id != nil {
  20056. fields = append(fields, soptask.FieldOrganizationID)
  20057. }
  20058. if m.token != nil {
  20059. fields = append(fields, soptask.FieldToken)
  20060. }
  20061. return fields
  20062. }
  20063. // Field returns the value of a field with the given name. The second boolean
  20064. // return value indicates that this field was not set, or was not defined in the
  20065. // schema.
  20066. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  20067. switch name {
  20068. case soptask.FieldCreatedAt:
  20069. return m.CreatedAt()
  20070. case soptask.FieldUpdatedAt:
  20071. return m.UpdatedAt()
  20072. case soptask.FieldStatus:
  20073. return m.Status()
  20074. case soptask.FieldDeletedAt:
  20075. return m.DeletedAt()
  20076. case soptask.FieldName:
  20077. return m.Name()
  20078. case soptask.FieldBotWxidList:
  20079. return m.BotWxidList()
  20080. case soptask.FieldType:
  20081. return m.GetType()
  20082. case soptask.FieldPlanStartTime:
  20083. return m.PlanStartTime()
  20084. case soptask.FieldPlanEndTime:
  20085. return m.PlanEndTime()
  20086. case soptask.FieldCreatorID:
  20087. return m.CreatorID()
  20088. case soptask.FieldOrganizationID:
  20089. return m.OrganizationID()
  20090. case soptask.FieldToken:
  20091. return m.Token()
  20092. }
  20093. return nil, false
  20094. }
  20095. // OldField returns the old value of the field from the database. An error is
  20096. // returned if the mutation operation is not UpdateOne, or the query to the
  20097. // database failed.
  20098. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20099. switch name {
  20100. case soptask.FieldCreatedAt:
  20101. return m.OldCreatedAt(ctx)
  20102. case soptask.FieldUpdatedAt:
  20103. return m.OldUpdatedAt(ctx)
  20104. case soptask.FieldStatus:
  20105. return m.OldStatus(ctx)
  20106. case soptask.FieldDeletedAt:
  20107. return m.OldDeletedAt(ctx)
  20108. case soptask.FieldName:
  20109. return m.OldName(ctx)
  20110. case soptask.FieldBotWxidList:
  20111. return m.OldBotWxidList(ctx)
  20112. case soptask.FieldType:
  20113. return m.OldType(ctx)
  20114. case soptask.FieldPlanStartTime:
  20115. return m.OldPlanStartTime(ctx)
  20116. case soptask.FieldPlanEndTime:
  20117. return m.OldPlanEndTime(ctx)
  20118. case soptask.FieldCreatorID:
  20119. return m.OldCreatorID(ctx)
  20120. case soptask.FieldOrganizationID:
  20121. return m.OldOrganizationID(ctx)
  20122. case soptask.FieldToken:
  20123. return m.OldToken(ctx)
  20124. }
  20125. return nil, fmt.Errorf("unknown SopTask field %s", name)
  20126. }
  20127. // SetField sets the value of a field with the given name. It returns an error if
  20128. // the field is not defined in the schema, or if the type mismatched the field
  20129. // type.
  20130. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  20131. switch name {
  20132. case soptask.FieldCreatedAt:
  20133. v, ok := value.(time.Time)
  20134. if !ok {
  20135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20136. }
  20137. m.SetCreatedAt(v)
  20138. return nil
  20139. case soptask.FieldUpdatedAt:
  20140. v, ok := value.(time.Time)
  20141. if !ok {
  20142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20143. }
  20144. m.SetUpdatedAt(v)
  20145. return nil
  20146. case soptask.FieldStatus:
  20147. v, ok := value.(uint8)
  20148. if !ok {
  20149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20150. }
  20151. m.SetStatus(v)
  20152. return nil
  20153. case soptask.FieldDeletedAt:
  20154. v, ok := value.(time.Time)
  20155. if !ok {
  20156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20157. }
  20158. m.SetDeletedAt(v)
  20159. return nil
  20160. case soptask.FieldName:
  20161. v, ok := value.(string)
  20162. if !ok {
  20163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20164. }
  20165. m.SetName(v)
  20166. return nil
  20167. case soptask.FieldBotWxidList:
  20168. v, ok := value.([]string)
  20169. if !ok {
  20170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20171. }
  20172. m.SetBotWxidList(v)
  20173. return nil
  20174. case soptask.FieldType:
  20175. v, ok := value.(int)
  20176. if !ok {
  20177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20178. }
  20179. m.SetType(v)
  20180. return nil
  20181. case soptask.FieldPlanStartTime:
  20182. v, ok := value.(time.Time)
  20183. if !ok {
  20184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20185. }
  20186. m.SetPlanStartTime(v)
  20187. return nil
  20188. case soptask.FieldPlanEndTime:
  20189. v, ok := value.(time.Time)
  20190. if !ok {
  20191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20192. }
  20193. m.SetPlanEndTime(v)
  20194. return nil
  20195. case soptask.FieldCreatorID:
  20196. v, ok := value.(string)
  20197. if !ok {
  20198. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20199. }
  20200. m.SetCreatorID(v)
  20201. return nil
  20202. case soptask.FieldOrganizationID:
  20203. v, ok := value.(uint64)
  20204. if !ok {
  20205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20206. }
  20207. m.SetOrganizationID(v)
  20208. return nil
  20209. case soptask.FieldToken:
  20210. v, ok := value.([]string)
  20211. if !ok {
  20212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20213. }
  20214. m.SetToken(v)
  20215. return nil
  20216. }
  20217. return fmt.Errorf("unknown SopTask field %s", name)
  20218. }
  20219. // AddedFields returns all numeric fields that were incremented/decremented during
  20220. // this mutation.
  20221. func (m *SopTaskMutation) AddedFields() []string {
  20222. var fields []string
  20223. if m.addstatus != nil {
  20224. fields = append(fields, soptask.FieldStatus)
  20225. }
  20226. if m.add_type != nil {
  20227. fields = append(fields, soptask.FieldType)
  20228. }
  20229. if m.addorganization_id != nil {
  20230. fields = append(fields, soptask.FieldOrganizationID)
  20231. }
  20232. return fields
  20233. }
  20234. // AddedField returns the numeric value that was incremented/decremented on a field
  20235. // with the given name. The second boolean return value indicates that this field
  20236. // was not set, or was not defined in the schema.
  20237. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  20238. switch name {
  20239. case soptask.FieldStatus:
  20240. return m.AddedStatus()
  20241. case soptask.FieldType:
  20242. return m.AddedType()
  20243. case soptask.FieldOrganizationID:
  20244. return m.AddedOrganizationID()
  20245. }
  20246. return nil, false
  20247. }
  20248. // AddField adds the value to the field with the given name. It returns an error if
  20249. // the field is not defined in the schema, or if the type mismatched the field
  20250. // type.
  20251. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  20252. switch name {
  20253. case soptask.FieldStatus:
  20254. v, ok := value.(int8)
  20255. if !ok {
  20256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20257. }
  20258. m.AddStatus(v)
  20259. return nil
  20260. case soptask.FieldType:
  20261. v, ok := value.(int)
  20262. if !ok {
  20263. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20264. }
  20265. m.AddType(v)
  20266. return nil
  20267. case soptask.FieldOrganizationID:
  20268. v, ok := value.(int64)
  20269. if !ok {
  20270. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20271. }
  20272. m.AddOrganizationID(v)
  20273. return nil
  20274. }
  20275. return fmt.Errorf("unknown SopTask numeric field %s", name)
  20276. }
  20277. // ClearedFields returns all nullable fields that were cleared during this
  20278. // mutation.
  20279. func (m *SopTaskMutation) ClearedFields() []string {
  20280. var fields []string
  20281. if m.FieldCleared(soptask.FieldStatus) {
  20282. fields = append(fields, soptask.FieldStatus)
  20283. }
  20284. if m.FieldCleared(soptask.FieldDeletedAt) {
  20285. fields = append(fields, soptask.FieldDeletedAt)
  20286. }
  20287. if m.FieldCleared(soptask.FieldBotWxidList) {
  20288. fields = append(fields, soptask.FieldBotWxidList)
  20289. }
  20290. if m.FieldCleared(soptask.FieldPlanStartTime) {
  20291. fields = append(fields, soptask.FieldPlanStartTime)
  20292. }
  20293. if m.FieldCleared(soptask.FieldPlanEndTime) {
  20294. fields = append(fields, soptask.FieldPlanEndTime)
  20295. }
  20296. if m.FieldCleared(soptask.FieldCreatorID) {
  20297. fields = append(fields, soptask.FieldCreatorID)
  20298. }
  20299. if m.FieldCleared(soptask.FieldOrganizationID) {
  20300. fields = append(fields, soptask.FieldOrganizationID)
  20301. }
  20302. if m.FieldCleared(soptask.FieldToken) {
  20303. fields = append(fields, soptask.FieldToken)
  20304. }
  20305. return fields
  20306. }
  20307. // FieldCleared returns a boolean indicating if a field with the given name was
  20308. // cleared in this mutation.
  20309. func (m *SopTaskMutation) FieldCleared(name string) bool {
  20310. _, ok := m.clearedFields[name]
  20311. return ok
  20312. }
  20313. // ClearField clears the value of the field with the given name. It returns an
  20314. // error if the field is not defined in the schema.
  20315. func (m *SopTaskMutation) ClearField(name string) error {
  20316. switch name {
  20317. case soptask.FieldStatus:
  20318. m.ClearStatus()
  20319. return nil
  20320. case soptask.FieldDeletedAt:
  20321. m.ClearDeletedAt()
  20322. return nil
  20323. case soptask.FieldBotWxidList:
  20324. m.ClearBotWxidList()
  20325. return nil
  20326. case soptask.FieldPlanStartTime:
  20327. m.ClearPlanStartTime()
  20328. return nil
  20329. case soptask.FieldPlanEndTime:
  20330. m.ClearPlanEndTime()
  20331. return nil
  20332. case soptask.FieldCreatorID:
  20333. m.ClearCreatorID()
  20334. return nil
  20335. case soptask.FieldOrganizationID:
  20336. m.ClearOrganizationID()
  20337. return nil
  20338. case soptask.FieldToken:
  20339. m.ClearToken()
  20340. return nil
  20341. }
  20342. return fmt.Errorf("unknown SopTask nullable field %s", name)
  20343. }
  20344. // ResetField resets all changes in the mutation for the field with the given name.
  20345. // It returns an error if the field is not defined in the schema.
  20346. func (m *SopTaskMutation) ResetField(name string) error {
  20347. switch name {
  20348. case soptask.FieldCreatedAt:
  20349. m.ResetCreatedAt()
  20350. return nil
  20351. case soptask.FieldUpdatedAt:
  20352. m.ResetUpdatedAt()
  20353. return nil
  20354. case soptask.FieldStatus:
  20355. m.ResetStatus()
  20356. return nil
  20357. case soptask.FieldDeletedAt:
  20358. m.ResetDeletedAt()
  20359. return nil
  20360. case soptask.FieldName:
  20361. m.ResetName()
  20362. return nil
  20363. case soptask.FieldBotWxidList:
  20364. m.ResetBotWxidList()
  20365. return nil
  20366. case soptask.FieldType:
  20367. m.ResetType()
  20368. return nil
  20369. case soptask.FieldPlanStartTime:
  20370. m.ResetPlanStartTime()
  20371. return nil
  20372. case soptask.FieldPlanEndTime:
  20373. m.ResetPlanEndTime()
  20374. return nil
  20375. case soptask.FieldCreatorID:
  20376. m.ResetCreatorID()
  20377. return nil
  20378. case soptask.FieldOrganizationID:
  20379. m.ResetOrganizationID()
  20380. return nil
  20381. case soptask.FieldToken:
  20382. m.ResetToken()
  20383. return nil
  20384. }
  20385. return fmt.Errorf("unknown SopTask field %s", name)
  20386. }
  20387. // AddedEdges returns all edge names that were set/added in this mutation.
  20388. func (m *SopTaskMutation) AddedEdges() []string {
  20389. edges := make([]string, 0, 1)
  20390. if m.task_stages != nil {
  20391. edges = append(edges, soptask.EdgeTaskStages)
  20392. }
  20393. return edges
  20394. }
  20395. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20396. // name in this mutation.
  20397. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  20398. switch name {
  20399. case soptask.EdgeTaskStages:
  20400. ids := make([]ent.Value, 0, len(m.task_stages))
  20401. for id := range m.task_stages {
  20402. ids = append(ids, id)
  20403. }
  20404. return ids
  20405. }
  20406. return nil
  20407. }
  20408. // RemovedEdges returns all edge names that were removed in this mutation.
  20409. func (m *SopTaskMutation) RemovedEdges() []string {
  20410. edges := make([]string, 0, 1)
  20411. if m.removedtask_stages != nil {
  20412. edges = append(edges, soptask.EdgeTaskStages)
  20413. }
  20414. return edges
  20415. }
  20416. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20417. // the given name in this mutation.
  20418. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  20419. switch name {
  20420. case soptask.EdgeTaskStages:
  20421. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  20422. for id := range m.removedtask_stages {
  20423. ids = append(ids, id)
  20424. }
  20425. return ids
  20426. }
  20427. return nil
  20428. }
  20429. // ClearedEdges returns all edge names that were cleared in this mutation.
  20430. func (m *SopTaskMutation) ClearedEdges() []string {
  20431. edges := make([]string, 0, 1)
  20432. if m.clearedtask_stages {
  20433. edges = append(edges, soptask.EdgeTaskStages)
  20434. }
  20435. return edges
  20436. }
  20437. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20438. // was cleared in this mutation.
  20439. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  20440. switch name {
  20441. case soptask.EdgeTaskStages:
  20442. return m.clearedtask_stages
  20443. }
  20444. return false
  20445. }
  20446. // ClearEdge clears the value of the edge with the given name. It returns an error
  20447. // if that edge is not defined in the schema.
  20448. func (m *SopTaskMutation) ClearEdge(name string) error {
  20449. switch name {
  20450. }
  20451. return fmt.Errorf("unknown SopTask unique edge %s", name)
  20452. }
  20453. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20454. // It returns an error if the edge is not defined in the schema.
  20455. func (m *SopTaskMutation) ResetEdge(name string) error {
  20456. switch name {
  20457. case soptask.EdgeTaskStages:
  20458. m.ResetTaskStages()
  20459. return nil
  20460. }
  20461. return fmt.Errorf("unknown SopTask edge %s", name)
  20462. }
  20463. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  20464. type TokenMutation struct {
  20465. config
  20466. op Op
  20467. typ string
  20468. id *uint64
  20469. created_at *time.Time
  20470. updated_at *time.Time
  20471. deleted_at *time.Time
  20472. expire_at *time.Time
  20473. token *string
  20474. mac *string
  20475. organization_id *uint64
  20476. addorganization_id *int64
  20477. custom_agent_base *string
  20478. custom_agent_key *string
  20479. openai_base *string
  20480. openai_key *string
  20481. clearedFields map[string]struct{}
  20482. agent *uint64
  20483. clearedagent bool
  20484. done bool
  20485. oldValue func(context.Context) (*Token, error)
  20486. predicates []predicate.Token
  20487. }
  20488. var _ ent.Mutation = (*TokenMutation)(nil)
  20489. // tokenOption allows management of the mutation configuration using functional options.
  20490. type tokenOption func(*TokenMutation)
  20491. // newTokenMutation creates new mutation for the Token entity.
  20492. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  20493. m := &TokenMutation{
  20494. config: c,
  20495. op: op,
  20496. typ: TypeToken,
  20497. clearedFields: make(map[string]struct{}),
  20498. }
  20499. for _, opt := range opts {
  20500. opt(m)
  20501. }
  20502. return m
  20503. }
  20504. // withTokenID sets the ID field of the mutation.
  20505. func withTokenID(id uint64) tokenOption {
  20506. return func(m *TokenMutation) {
  20507. var (
  20508. err error
  20509. once sync.Once
  20510. value *Token
  20511. )
  20512. m.oldValue = func(ctx context.Context) (*Token, error) {
  20513. once.Do(func() {
  20514. if m.done {
  20515. err = errors.New("querying old values post mutation is not allowed")
  20516. } else {
  20517. value, err = m.Client().Token.Get(ctx, id)
  20518. }
  20519. })
  20520. return value, err
  20521. }
  20522. m.id = &id
  20523. }
  20524. }
  20525. // withToken sets the old Token of the mutation.
  20526. func withToken(node *Token) tokenOption {
  20527. return func(m *TokenMutation) {
  20528. m.oldValue = func(context.Context) (*Token, error) {
  20529. return node, nil
  20530. }
  20531. m.id = &node.ID
  20532. }
  20533. }
  20534. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20535. // executed in a transaction (ent.Tx), a transactional client is returned.
  20536. func (m TokenMutation) Client() *Client {
  20537. client := &Client{config: m.config}
  20538. client.init()
  20539. return client
  20540. }
  20541. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20542. // it returns an error otherwise.
  20543. func (m TokenMutation) Tx() (*Tx, error) {
  20544. if _, ok := m.driver.(*txDriver); !ok {
  20545. return nil, errors.New("ent: mutation is not running in a transaction")
  20546. }
  20547. tx := &Tx{config: m.config}
  20548. tx.init()
  20549. return tx, nil
  20550. }
  20551. // SetID sets the value of the id field. Note that this
  20552. // operation is only accepted on creation of Token entities.
  20553. func (m *TokenMutation) SetID(id uint64) {
  20554. m.id = &id
  20555. }
  20556. // ID returns the ID value in the mutation. Note that the ID is only available
  20557. // if it was provided to the builder or after it was returned from the database.
  20558. func (m *TokenMutation) ID() (id uint64, exists bool) {
  20559. if m.id == nil {
  20560. return
  20561. }
  20562. return *m.id, true
  20563. }
  20564. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20565. // That means, if the mutation is applied within a transaction with an isolation level such
  20566. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20567. // or updated by the mutation.
  20568. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  20569. switch {
  20570. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20571. id, exists := m.ID()
  20572. if exists {
  20573. return []uint64{id}, nil
  20574. }
  20575. fallthrough
  20576. case m.op.Is(OpUpdate | OpDelete):
  20577. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  20578. default:
  20579. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20580. }
  20581. }
  20582. // SetCreatedAt sets the "created_at" field.
  20583. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  20584. m.created_at = &t
  20585. }
  20586. // CreatedAt returns the value of the "created_at" field in the mutation.
  20587. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  20588. v := m.created_at
  20589. if v == nil {
  20590. return
  20591. }
  20592. return *v, true
  20593. }
  20594. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  20595. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20596. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20597. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20598. if !m.op.Is(OpUpdateOne) {
  20599. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20600. }
  20601. if m.id == nil || m.oldValue == nil {
  20602. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20603. }
  20604. oldValue, err := m.oldValue(ctx)
  20605. if err != nil {
  20606. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20607. }
  20608. return oldValue.CreatedAt, nil
  20609. }
  20610. // ResetCreatedAt resets all changes to the "created_at" field.
  20611. func (m *TokenMutation) ResetCreatedAt() {
  20612. m.created_at = nil
  20613. }
  20614. // SetUpdatedAt sets the "updated_at" field.
  20615. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  20616. m.updated_at = &t
  20617. }
  20618. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20619. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  20620. v := m.updated_at
  20621. if v == nil {
  20622. return
  20623. }
  20624. return *v, true
  20625. }
  20626. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  20627. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20628. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20629. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20630. if !m.op.Is(OpUpdateOne) {
  20631. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20632. }
  20633. if m.id == nil || m.oldValue == nil {
  20634. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20635. }
  20636. oldValue, err := m.oldValue(ctx)
  20637. if err != nil {
  20638. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20639. }
  20640. return oldValue.UpdatedAt, nil
  20641. }
  20642. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20643. func (m *TokenMutation) ResetUpdatedAt() {
  20644. m.updated_at = nil
  20645. }
  20646. // SetDeletedAt sets the "deleted_at" field.
  20647. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  20648. m.deleted_at = &t
  20649. }
  20650. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20651. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  20652. v := m.deleted_at
  20653. if v == nil {
  20654. return
  20655. }
  20656. return *v, true
  20657. }
  20658. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  20659. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20660. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20661. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20662. if !m.op.Is(OpUpdateOne) {
  20663. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20664. }
  20665. if m.id == nil || m.oldValue == nil {
  20666. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20667. }
  20668. oldValue, err := m.oldValue(ctx)
  20669. if err != nil {
  20670. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20671. }
  20672. return oldValue.DeletedAt, nil
  20673. }
  20674. // ClearDeletedAt clears the value of the "deleted_at" field.
  20675. func (m *TokenMutation) ClearDeletedAt() {
  20676. m.deleted_at = nil
  20677. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  20678. }
  20679. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20680. func (m *TokenMutation) DeletedAtCleared() bool {
  20681. _, ok := m.clearedFields[token.FieldDeletedAt]
  20682. return ok
  20683. }
  20684. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20685. func (m *TokenMutation) ResetDeletedAt() {
  20686. m.deleted_at = nil
  20687. delete(m.clearedFields, token.FieldDeletedAt)
  20688. }
  20689. // SetExpireAt sets the "expire_at" field.
  20690. func (m *TokenMutation) SetExpireAt(t time.Time) {
  20691. m.expire_at = &t
  20692. }
  20693. // ExpireAt returns the value of the "expire_at" field in the mutation.
  20694. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  20695. v := m.expire_at
  20696. if v == nil {
  20697. return
  20698. }
  20699. return *v, true
  20700. }
  20701. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  20702. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20703. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20704. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  20705. if !m.op.Is(OpUpdateOne) {
  20706. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  20707. }
  20708. if m.id == nil || m.oldValue == nil {
  20709. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  20710. }
  20711. oldValue, err := m.oldValue(ctx)
  20712. if err != nil {
  20713. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  20714. }
  20715. return oldValue.ExpireAt, nil
  20716. }
  20717. // ClearExpireAt clears the value of the "expire_at" field.
  20718. func (m *TokenMutation) ClearExpireAt() {
  20719. m.expire_at = nil
  20720. m.clearedFields[token.FieldExpireAt] = struct{}{}
  20721. }
  20722. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  20723. func (m *TokenMutation) ExpireAtCleared() bool {
  20724. _, ok := m.clearedFields[token.FieldExpireAt]
  20725. return ok
  20726. }
  20727. // ResetExpireAt resets all changes to the "expire_at" field.
  20728. func (m *TokenMutation) ResetExpireAt() {
  20729. m.expire_at = nil
  20730. delete(m.clearedFields, token.FieldExpireAt)
  20731. }
  20732. // SetToken sets the "token" field.
  20733. func (m *TokenMutation) SetToken(s string) {
  20734. m.token = &s
  20735. }
  20736. // Token returns the value of the "token" field in the mutation.
  20737. func (m *TokenMutation) Token() (r string, exists bool) {
  20738. v := m.token
  20739. if v == nil {
  20740. return
  20741. }
  20742. return *v, true
  20743. }
  20744. // OldToken returns the old "token" field's value of the Token entity.
  20745. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20746. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20747. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  20748. if !m.op.Is(OpUpdateOne) {
  20749. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  20750. }
  20751. if m.id == nil || m.oldValue == nil {
  20752. return v, errors.New("OldToken requires an ID field in the mutation")
  20753. }
  20754. oldValue, err := m.oldValue(ctx)
  20755. if err != nil {
  20756. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  20757. }
  20758. return oldValue.Token, nil
  20759. }
  20760. // ClearToken clears the value of the "token" field.
  20761. func (m *TokenMutation) ClearToken() {
  20762. m.token = nil
  20763. m.clearedFields[token.FieldToken] = struct{}{}
  20764. }
  20765. // TokenCleared returns if the "token" field was cleared in this mutation.
  20766. func (m *TokenMutation) TokenCleared() bool {
  20767. _, ok := m.clearedFields[token.FieldToken]
  20768. return ok
  20769. }
  20770. // ResetToken resets all changes to the "token" field.
  20771. func (m *TokenMutation) ResetToken() {
  20772. m.token = nil
  20773. delete(m.clearedFields, token.FieldToken)
  20774. }
  20775. // SetMAC sets the "mac" field.
  20776. func (m *TokenMutation) SetMAC(s string) {
  20777. m.mac = &s
  20778. }
  20779. // MAC returns the value of the "mac" field in the mutation.
  20780. func (m *TokenMutation) MAC() (r string, exists bool) {
  20781. v := m.mac
  20782. if v == nil {
  20783. return
  20784. }
  20785. return *v, true
  20786. }
  20787. // OldMAC returns the old "mac" field's value of the Token entity.
  20788. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20789. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20790. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  20791. if !m.op.Is(OpUpdateOne) {
  20792. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  20793. }
  20794. if m.id == nil || m.oldValue == nil {
  20795. return v, errors.New("OldMAC requires an ID field in the mutation")
  20796. }
  20797. oldValue, err := m.oldValue(ctx)
  20798. if err != nil {
  20799. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  20800. }
  20801. return oldValue.MAC, nil
  20802. }
  20803. // ClearMAC clears the value of the "mac" field.
  20804. func (m *TokenMutation) ClearMAC() {
  20805. m.mac = nil
  20806. m.clearedFields[token.FieldMAC] = struct{}{}
  20807. }
  20808. // MACCleared returns if the "mac" field was cleared in this mutation.
  20809. func (m *TokenMutation) MACCleared() bool {
  20810. _, ok := m.clearedFields[token.FieldMAC]
  20811. return ok
  20812. }
  20813. // ResetMAC resets all changes to the "mac" field.
  20814. func (m *TokenMutation) ResetMAC() {
  20815. m.mac = nil
  20816. delete(m.clearedFields, token.FieldMAC)
  20817. }
  20818. // SetOrganizationID sets the "organization_id" field.
  20819. func (m *TokenMutation) SetOrganizationID(u uint64) {
  20820. m.organization_id = &u
  20821. m.addorganization_id = nil
  20822. }
  20823. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20824. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  20825. v := m.organization_id
  20826. if v == nil {
  20827. return
  20828. }
  20829. return *v, true
  20830. }
  20831. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  20832. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20833. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20834. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20835. if !m.op.Is(OpUpdateOne) {
  20836. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20837. }
  20838. if m.id == nil || m.oldValue == nil {
  20839. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20840. }
  20841. oldValue, err := m.oldValue(ctx)
  20842. if err != nil {
  20843. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20844. }
  20845. return oldValue.OrganizationID, nil
  20846. }
  20847. // AddOrganizationID adds u to the "organization_id" field.
  20848. func (m *TokenMutation) AddOrganizationID(u int64) {
  20849. if m.addorganization_id != nil {
  20850. *m.addorganization_id += u
  20851. } else {
  20852. m.addorganization_id = &u
  20853. }
  20854. }
  20855. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20856. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  20857. v := m.addorganization_id
  20858. if v == nil {
  20859. return
  20860. }
  20861. return *v, true
  20862. }
  20863. // ResetOrganizationID resets all changes to the "organization_id" field.
  20864. func (m *TokenMutation) ResetOrganizationID() {
  20865. m.organization_id = nil
  20866. m.addorganization_id = nil
  20867. }
  20868. // SetAgentID sets the "agent_id" field.
  20869. func (m *TokenMutation) SetAgentID(u uint64) {
  20870. m.agent = &u
  20871. }
  20872. // AgentID returns the value of the "agent_id" field in the mutation.
  20873. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  20874. v := m.agent
  20875. if v == nil {
  20876. return
  20877. }
  20878. return *v, true
  20879. }
  20880. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  20881. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20882. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20883. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  20884. if !m.op.Is(OpUpdateOne) {
  20885. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  20886. }
  20887. if m.id == nil || m.oldValue == nil {
  20888. return v, errors.New("OldAgentID requires an ID field in the mutation")
  20889. }
  20890. oldValue, err := m.oldValue(ctx)
  20891. if err != nil {
  20892. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  20893. }
  20894. return oldValue.AgentID, nil
  20895. }
  20896. // ResetAgentID resets all changes to the "agent_id" field.
  20897. func (m *TokenMutation) ResetAgentID() {
  20898. m.agent = nil
  20899. }
  20900. // SetCustomAgentBase sets the "custom_agent_base" field.
  20901. func (m *TokenMutation) SetCustomAgentBase(s string) {
  20902. m.custom_agent_base = &s
  20903. }
  20904. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  20905. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  20906. v := m.custom_agent_base
  20907. if v == nil {
  20908. return
  20909. }
  20910. return *v, true
  20911. }
  20912. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  20913. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20914. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20915. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  20916. if !m.op.Is(OpUpdateOne) {
  20917. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  20918. }
  20919. if m.id == nil || m.oldValue == nil {
  20920. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  20921. }
  20922. oldValue, err := m.oldValue(ctx)
  20923. if err != nil {
  20924. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  20925. }
  20926. return oldValue.CustomAgentBase, nil
  20927. }
  20928. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  20929. func (m *TokenMutation) ClearCustomAgentBase() {
  20930. m.custom_agent_base = nil
  20931. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  20932. }
  20933. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  20934. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  20935. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  20936. return ok
  20937. }
  20938. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  20939. func (m *TokenMutation) ResetCustomAgentBase() {
  20940. m.custom_agent_base = nil
  20941. delete(m.clearedFields, token.FieldCustomAgentBase)
  20942. }
  20943. // SetCustomAgentKey sets the "custom_agent_key" field.
  20944. func (m *TokenMutation) SetCustomAgentKey(s string) {
  20945. m.custom_agent_key = &s
  20946. }
  20947. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  20948. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  20949. v := m.custom_agent_key
  20950. if v == nil {
  20951. return
  20952. }
  20953. return *v, true
  20954. }
  20955. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  20956. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  20957. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20958. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  20959. if !m.op.Is(OpUpdateOne) {
  20960. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  20961. }
  20962. if m.id == nil || m.oldValue == nil {
  20963. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  20964. }
  20965. oldValue, err := m.oldValue(ctx)
  20966. if err != nil {
  20967. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  20968. }
  20969. return oldValue.CustomAgentKey, nil
  20970. }
  20971. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  20972. func (m *TokenMutation) ClearCustomAgentKey() {
  20973. m.custom_agent_key = nil
  20974. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  20975. }
  20976. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  20977. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  20978. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  20979. return ok
  20980. }
  20981. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  20982. func (m *TokenMutation) ResetCustomAgentKey() {
  20983. m.custom_agent_key = nil
  20984. delete(m.clearedFields, token.FieldCustomAgentKey)
  20985. }
  20986. // SetOpenaiBase sets the "openai_base" field.
  20987. func (m *TokenMutation) SetOpenaiBase(s string) {
  20988. m.openai_base = &s
  20989. }
  20990. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  20991. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  20992. v := m.openai_base
  20993. if v == nil {
  20994. return
  20995. }
  20996. return *v, true
  20997. }
  20998. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  20999. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21001. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  21002. if !m.op.Is(OpUpdateOne) {
  21003. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  21004. }
  21005. if m.id == nil || m.oldValue == nil {
  21006. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  21007. }
  21008. oldValue, err := m.oldValue(ctx)
  21009. if err != nil {
  21010. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  21011. }
  21012. return oldValue.OpenaiBase, nil
  21013. }
  21014. // ClearOpenaiBase clears the value of the "openai_base" field.
  21015. func (m *TokenMutation) ClearOpenaiBase() {
  21016. m.openai_base = nil
  21017. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  21018. }
  21019. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  21020. func (m *TokenMutation) OpenaiBaseCleared() bool {
  21021. _, ok := m.clearedFields[token.FieldOpenaiBase]
  21022. return ok
  21023. }
  21024. // ResetOpenaiBase resets all changes to the "openai_base" field.
  21025. func (m *TokenMutation) ResetOpenaiBase() {
  21026. m.openai_base = nil
  21027. delete(m.clearedFields, token.FieldOpenaiBase)
  21028. }
  21029. // SetOpenaiKey sets the "openai_key" field.
  21030. func (m *TokenMutation) SetOpenaiKey(s string) {
  21031. m.openai_key = &s
  21032. }
  21033. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  21034. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  21035. v := m.openai_key
  21036. if v == nil {
  21037. return
  21038. }
  21039. return *v, true
  21040. }
  21041. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  21042. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21044. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  21045. if !m.op.Is(OpUpdateOne) {
  21046. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  21047. }
  21048. if m.id == nil || m.oldValue == nil {
  21049. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  21050. }
  21051. oldValue, err := m.oldValue(ctx)
  21052. if err != nil {
  21053. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  21054. }
  21055. return oldValue.OpenaiKey, nil
  21056. }
  21057. // ClearOpenaiKey clears the value of the "openai_key" field.
  21058. func (m *TokenMutation) ClearOpenaiKey() {
  21059. m.openai_key = nil
  21060. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  21061. }
  21062. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  21063. func (m *TokenMutation) OpenaiKeyCleared() bool {
  21064. _, ok := m.clearedFields[token.FieldOpenaiKey]
  21065. return ok
  21066. }
  21067. // ResetOpenaiKey resets all changes to the "openai_key" field.
  21068. func (m *TokenMutation) ResetOpenaiKey() {
  21069. m.openai_key = nil
  21070. delete(m.clearedFields, token.FieldOpenaiKey)
  21071. }
  21072. // ClearAgent clears the "agent" edge to the Agent entity.
  21073. func (m *TokenMutation) ClearAgent() {
  21074. m.clearedagent = true
  21075. m.clearedFields[token.FieldAgentID] = struct{}{}
  21076. }
  21077. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  21078. func (m *TokenMutation) AgentCleared() bool {
  21079. return m.clearedagent
  21080. }
  21081. // AgentIDs returns the "agent" edge IDs in the mutation.
  21082. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21083. // AgentID instead. It exists only for internal usage by the builders.
  21084. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  21085. if id := m.agent; id != nil {
  21086. ids = append(ids, *id)
  21087. }
  21088. return
  21089. }
  21090. // ResetAgent resets all changes to the "agent" edge.
  21091. func (m *TokenMutation) ResetAgent() {
  21092. m.agent = nil
  21093. m.clearedagent = false
  21094. }
  21095. // Where appends a list predicates to the TokenMutation builder.
  21096. func (m *TokenMutation) Where(ps ...predicate.Token) {
  21097. m.predicates = append(m.predicates, ps...)
  21098. }
  21099. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  21100. // users can use type-assertion to append predicates that do not depend on any generated package.
  21101. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  21102. p := make([]predicate.Token, len(ps))
  21103. for i := range ps {
  21104. p[i] = ps[i]
  21105. }
  21106. m.Where(p...)
  21107. }
  21108. // Op returns the operation name.
  21109. func (m *TokenMutation) Op() Op {
  21110. return m.op
  21111. }
  21112. // SetOp allows setting the mutation operation.
  21113. func (m *TokenMutation) SetOp(op Op) {
  21114. m.op = op
  21115. }
  21116. // Type returns the node type of this mutation (Token).
  21117. func (m *TokenMutation) Type() string {
  21118. return m.typ
  21119. }
  21120. // Fields returns all fields that were changed during this mutation. Note that in
  21121. // order to get all numeric fields that were incremented/decremented, call
  21122. // AddedFields().
  21123. func (m *TokenMutation) Fields() []string {
  21124. fields := make([]string, 0, 12)
  21125. if m.created_at != nil {
  21126. fields = append(fields, token.FieldCreatedAt)
  21127. }
  21128. if m.updated_at != nil {
  21129. fields = append(fields, token.FieldUpdatedAt)
  21130. }
  21131. if m.deleted_at != nil {
  21132. fields = append(fields, token.FieldDeletedAt)
  21133. }
  21134. if m.expire_at != nil {
  21135. fields = append(fields, token.FieldExpireAt)
  21136. }
  21137. if m.token != nil {
  21138. fields = append(fields, token.FieldToken)
  21139. }
  21140. if m.mac != nil {
  21141. fields = append(fields, token.FieldMAC)
  21142. }
  21143. if m.organization_id != nil {
  21144. fields = append(fields, token.FieldOrganizationID)
  21145. }
  21146. if m.agent != nil {
  21147. fields = append(fields, token.FieldAgentID)
  21148. }
  21149. if m.custom_agent_base != nil {
  21150. fields = append(fields, token.FieldCustomAgentBase)
  21151. }
  21152. if m.custom_agent_key != nil {
  21153. fields = append(fields, token.FieldCustomAgentKey)
  21154. }
  21155. if m.openai_base != nil {
  21156. fields = append(fields, token.FieldOpenaiBase)
  21157. }
  21158. if m.openai_key != nil {
  21159. fields = append(fields, token.FieldOpenaiKey)
  21160. }
  21161. return fields
  21162. }
  21163. // Field returns the value of a field with the given name. The second boolean
  21164. // return value indicates that this field was not set, or was not defined in the
  21165. // schema.
  21166. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  21167. switch name {
  21168. case token.FieldCreatedAt:
  21169. return m.CreatedAt()
  21170. case token.FieldUpdatedAt:
  21171. return m.UpdatedAt()
  21172. case token.FieldDeletedAt:
  21173. return m.DeletedAt()
  21174. case token.FieldExpireAt:
  21175. return m.ExpireAt()
  21176. case token.FieldToken:
  21177. return m.Token()
  21178. case token.FieldMAC:
  21179. return m.MAC()
  21180. case token.FieldOrganizationID:
  21181. return m.OrganizationID()
  21182. case token.FieldAgentID:
  21183. return m.AgentID()
  21184. case token.FieldCustomAgentBase:
  21185. return m.CustomAgentBase()
  21186. case token.FieldCustomAgentKey:
  21187. return m.CustomAgentKey()
  21188. case token.FieldOpenaiBase:
  21189. return m.OpenaiBase()
  21190. case token.FieldOpenaiKey:
  21191. return m.OpenaiKey()
  21192. }
  21193. return nil, false
  21194. }
  21195. // OldField returns the old value of the field from the database. An error is
  21196. // returned if the mutation operation is not UpdateOne, or the query to the
  21197. // database failed.
  21198. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21199. switch name {
  21200. case token.FieldCreatedAt:
  21201. return m.OldCreatedAt(ctx)
  21202. case token.FieldUpdatedAt:
  21203. return m.OldUpdatedAt(ctx)
  21204. case token.FieldDeletedAt:
  21205. return m.OldDeletedAt(ctx)
  21206. case token.FieldExpireAt:
  21207. return m.OldExpireAt(ctx)
  21208. case token.FieldToken:
  21209. return m.OldToken(ctx)
  21210. case token.FieldMAC:
  21211. return m.OldMAC(ctx)
  21212. case token.FieldOrganizationID:
  21213. return m.OldOrganizationID(ctx)
  21214. case token.FieldAgentID:
  21215. return m.OldAgentID(ctx)
  21216. case token.FieldCustomAgentBase:
  21217. return m.OldCustomAgentBase(ctx)
  21218. case token.FieldCustomAgentKey:
  21219. return m.OldCustomAgentKey(ctx)
  21220. case token.FieldOpenaiBase:
  21221. return m.OldOpenaiBase(ctx)
  21222. case token.FieldOpenaiKey:
  21223. return m.OldOpenaiKey(ctx)
  21224. }
  21225. return nil, fmt.Errorf("unknown Token field %s", name)
  21226. }
  21227. // SetField sets the value of a field with the given name. It returns an error if
  21228. // the field is not defined in the schema, or if the type mismatched the field
  21229. // type.
  21230. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  21231. switch name {
  21232. case token.FieldCreatedAt:
  21233. v, ok := value.(time.Time)
  21234. if !ok {
  21235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21236. }
  21237. m.SetCreatedAt(v)
  21238. return nil
  21239. case token.FieldUpdatedAt:
  21240. v, ok := value.(time.Time)
  21241. if !ok {
  21242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21243. }
  21244. m.SetUpdatedAt(v)
  21245. return nil
  21246. case token.FieldDeletedAt:
  21247. v, ok := value.(time.Time)
  21248. if !ok {
  21249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21250. }
  21251. m.SetDeletedAt(v)
  21252. return nil
  21253. case token.FieldExpireAt:
  21254. v, ok := value.(time.Time)
  21255. if !ok {
  21256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21257. }
  21258. m.SetExpireAt(v)
  21259. return nil
  21260. case token.FieldToken:
  21261. v, ok := value.(string)
  21262. if !ok {
  21263. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21264. }
  21265. m.SetToken(v)
  21266. return nil
  21267. case token.FieldMAC:
  21268. v, ok := value.(string)
  21269. if !ok {
  21270. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21271. }
  21272. m.SetMAC(v)
  21273. return nil
  21274. case token.FieldOrganizationID:
  21275. v, ok := value.(uint64)
  21276. if !ok {
  21277. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21278. }
  21279. m.SetOrganizationID(v)
  21280. return nil
  21281. case token.FieldAgentID:
  21282. v, ok := value.(uint64)
  21283. if !ok {
  21284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21285. }
  21286. m.SetAgentID(v)
  21287. return nil
  21288. case token.FieldCustomAgentBase:
  21289. v, ok := value.(string)
  21290. if !ok {
  21291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21292. }
  21293. m.SetCustomAgentBase(v)
  21294. return nil
  21295. case token.FieldCustomAgentKey:
  21296. v, ok := value.(string)
  21297. if !ok {
  21298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21299. }
  21300. m.SetCustomAgentKey(v)
  21301. return nil
  21302. case token.FieldOpenaiBase:
  21303. v, ok := value.(string)
  21304. if !ok {
  21305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21306. }
  21307. m.SetOpenaiBase(v)
  21308. return nil
  21309. case token.FieldOpenaiKey:
  21310. v, ok := value.(string)
  21311. if !ok {
  21312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21313. }
  21314. m.SetOpenaiKey(v)
  21315. return nil
  21316. }
  21317. return fmt.Errorf("unknown Token field %s", name)
  21318. }
  21319. // AddedFields returns all numeric fields that were incremented/decremented during
  21320. // this mutation.
  21321. func (m *TokenMutation) AddedFields() []string {
  21322. var fields []string
  21323. if m.addorganization_id != nil {
  21324. fields = append(fields, token.FieldOrganizationID)
  21325. }
  21326. return fields
  21327. }
  21328. // AddedField returns the numeric value that was incremented/decremented on a field
  21329. // with the given name. The second boolean return value indicates that this field
  21330. // was not set, or was not defined in the schema.
  21331. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  21332. switch name {
  21333. case token.FieldOrganizationID:
  21334. return m.AddedOrganizationID()
  21335. }
  21336. return nil, false
  21337. }
  21338. // AddField adds the value to the field with the given name. It returns an error if
  21339. // the field is not defined in the schema, or if the type mismatched the field
  21340. // type.
  21341. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  21342. switch name {
  21343. case token.FieldOrganizationID:
  21344. v, ok := value.(int64)
  21345. if !ok {
  21346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21347. }
  21348. m.AddOrganizationID(v)
  21349. return nil
  21350. }
  21351. return fmt.Errorf("unknown Token numeric field %s", name)
  21352. }
  21353. // ClearedFields returns all nullable fields that were cleared during this
  21354. // mutation.
  21355. func (m *TokenMutation) ClearedFields() []string {
  21356. var fields []string
  21357. if m.FieldCleared(token.FieldDeletedAt) {
  21358. fields = append(fields, token.FieldDeletedAt)
  21359. }
  21360. if m.FieldCleared(token.FieldExpireAt) {
  21361. fields = append(fields, token.FieldExpireAt)
  21362. }
  21363. if m.FieldCleared(token.FieldToken) {
  21364. fields = append(fields, token.FieldToken)
  21365. }
  21366. if m.FieldCleared(token.FieldMAC) {
  21367. fields = append(fields, token.FieldMAC)
  21368. }
  21369. if m.FieldCleared(token.FieldCustomAgentBase) {
  21370. fields = append(fields, token.FieldCustomAgentBase)
  21371. }
  21372. if m.FieldCleared(token.FieldCustomAgentKey) {
  21373. fields = append(fields, token.FieldCustomAgentKey)
  21374. }
  21375. if m.FieldCleared(token.FieldOpenaiBase) {
  21376. fields = append(fields, token.FieldOpenaiBase)
  21377. }
  21378. if m.FieldCleared(token.FieldOpenaiKey) {
  21379. fields = append(fields, token.FieldOpenaiKey)
  21380. }
  21381. return fields
  21382. }
  21383. // FieldCleared returns a boolean indicating if a field with the given name was
  21384. // cleared in this mutation.
  21385. func (m *TokenMutation) FieldCleared(name string) bool {
  21386. _, ok := m.clearedFields[name]
  21387. return ok
  21388. }
  21389. // ClearField clears the value of the field with the given name. It returns an
  21390. // error if the field is not defined in the schema.
  21391. func (m *TokenMutation) ClearField(name string) error {
  21392. switch name {
  21393. case token.FieldDeletedAt:
  21394. m.ClearDeletedAt()
  21395. return nil
  21396. case token.FieldExpireAt:
  21397. m.ClearExpireAt()
  21398. return nil
  21399. case token.FieldToken:
  21400. m.ClearToken()
  21401. return nil
  21402. case token.FieldMAC:
  21403. m.ClearMAC()
  21404. return nil
  21405. case token.FieldCustomAgentBase:
  21406. m.ClearCustomAgentBase()
  21407. return nil
  21408. case token.FieldCustomAgentKey:
  21409. m.ClearCustomAgentKey()
  21410. return nil
  21411. case token.FieldOpenaiBase:
  21412. m.ClearOpenaiBase()
  21413. return nil
  21414. case token.FieldOpenaiKey:
  21415. m.ClearOpenaiKey()
  21416. return nil
  21417. }
  21418. return fmt.Errorf("unknown Token nullable field %s", name)
  21419. }
  21420. // ResetField resets all changes in the mutation for the field with the given name.
  21421. // It returns an error if the field is not defined in the schema.
  21422. func (m *TokenMutation) ResetField(name string) error {
  21423. switch name {
  21424. case token.FieldCreatedAt:
  21425. m.ResetCreatedAt()
  21426. return nil
  21427. case token.FieldUpdatedAt:
  21428. m.ResetUpdatedAt()
  21429. return nil
  21430. case token.FieldDeletedAt:
  21431. m.ResetDeletedAt()
  21432. return nil
  21433. case token.FieldExpireAt:
  21434. m.ResetExpireAt()
  21435. return nil
  21436. case token.FieldToken:
  21437. m.ResetToken()
  21438. return nil
  21439. case token.FieldMAC:
  21440. m.ResetMAC()
  21441. return nil
  21442. case token.FieldOrganizationID:
  21443. m.ResetOrganizationID()
  21444. return nil
  21445. case token.FieldAgentID:
  21446. m.ResetAgentID()
  21447. return nil
  21448. case token.FieldCustomAgentBase:
  21449. m.ResetCustomAgentBase()
  21450. return nil
  21451. case token.FieldCustomAgentKey:
  21452. m.ResetCustomAgentKey()
  21453. return nil
  21454. case token.FieldOpenaiBase:
  21455. m.ResetOpenaiBase()
  21456. return nil
  21457. case token.FieldOpenaiKey:
  21458. m.ResetOpenaiKey()
  21459. return nil
  21460. }
  21461. return fmt.Errorf("unknown Token field %s", name)
  21462. }
  21463. // AddedEdges returns all edge names that were set/added in this mutation.
  21464. func (m *TokenMutation) AddedEdges() []string {
  21465. edges := make([]string, 0, 1)
  21466. if m.agent != nil {
  21467. edges = append(edges, token.EdgeAgent)
  21468. }
  21469. return edges
  21470. }
  21471. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21472. // name in this mutation.
  21473. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  21474. switch name {
  21475. case token.EdgeAgent:
  21476. if id := m.agent; id != nil {
  21477. return []ent.Value{*id}
  21478. }
  21479. }
  21480. return nil
  21481. }
  21482. // RemovedEdges returns all edge names that were removed in this mutation.
  21483. func (m *TokenMutation) RemovedEdges() []string {
  21484. edges := make([]string, 0, 1)
  21485. return edges
  21486. }
  21487. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21488. // the given name in this mutation.
  21489. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  21490. return nil
  21491. }
  21492. // ClearedEdges returns all edge names that were cleared in this mutation.
  21493. func (m *TokenMutation) ClearedEdges() []string {
  21494. edges := make([]string, 0, 1)
  21495. if m.clearedagent {
  21496. edges = append(edges, token.EdgeAgent)
  21497. }
  21498. return edges
  21499. }
  21500. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21501. // was cleared in this mutation.
  21502. func (m *TokenMutation) EdgeCleared(name string) bool {
  21503. switch name {
  21504. case token.EdgeAgent:
  21505. return m.clearedagent
  21506. }
  21507. return false
  21508. }
  21509. // ClearEdge clears the value of the edge with the given name. It returns an error
  21510. // if that edge is not defined in the schema.
  21511. func (m *TokenMutation) ClearEdge(name string) error {
  21512. switch name {
  21513. case token.EdgeAgent:
  21514. m.ClearAgent()
  21515. return nil
  21516. }
  21517. return fmt.Errorf("unknown Token unique edge %s", name)
  21518. }
  21519. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21520. // It returns an error if the edge is not defined in the schema.
  21521. func (m *TokenMutation) ResetEdge(name string) error {
  21522. switch name {
  21523. case token.EdgeAgent:
  21524. m.ResetAgent()
  21525. return nil
  21526. }
  21527. return fmt.Errorf("unknown Token edge %s", name)
  21528. }
  21529. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  21530. type TutorialMutation struct {
  21531. config
  21532. op Op
  21533. typ string
  21534. id *uint64
  21535. created_at *time.Time
  21536. updated_at *time.Time
  21537. deleted_at *time.Time
  21538. index *int
  21539. addindex *int
  21540. title *string
  21541. content *string
  21542. organization_id *uint64
  21543. addorganization_id *int64
  21544. clearedFields map[string]struct{}
  21545. employee *uint64
  21546. clearedemployee bool
  21547. done bool
  21548. oldValue func(context.Context) (*Tutorial, error)
  21549. predicates []predicate.Tutorial
  21550. }
  21551. var _ ent.Mutation = (*TutorialMutation)(nil)
  21552. // tutorialOption allows management of the mutation configuration using functional options.
  21553. type tutorialOption func(*TutorialMutation)
  21554. // newTutorialMutation creates new mutation for the Tutorial entity.
  21555. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  21556. m := &TutorialMutation{
  21557. config: c,
  21558. op: op,
  21559. typ: TypeTutorial,
  21560. clearedFields: make(map[string]struct{}),
  21561. }
  21562. for _, opt := range opts {
  21563. opt(m)
  21564. }
  21565. return m
  21566. }
  21567. // withTutorialID sets the ID field of the mutation.
  21568. func withTutorialID(id uint64) tutorialOption {
  21569. return func(m *TutorialMutation) {
  21570. var (
  21571. err error
  21572. once sync.Once
  21573. value *Tutorial
  21574. )
  21575. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  21576. once.Do(func() {
  21577. if m.done {
  21578. err = errors.New("querying old values post mutation is not allowed")
  21579. } else {
  21580. value, err = m.Client().Tutorial.Get(ctx, id)
  21581. }
  21582. })
  21583. return value, err
  21584. }
  21585. m.id = &id
  21586. }
  21587. }
  21588. // withTutorial sets the old Tutorial of the mutation.
  21589. func withTutorial(node *Tutorial) tutorialOption {
  21590. return func(m *TutorialMutation) {
  21591. m.oldValue = func(context.Context) (*Tutorial, error) {
  21592. return node, nil
  21593. }
  21594. m.id = &node.ID
  21595. }
  21596. }
  21597. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21598. // executed in a transaction (ent.Tx), a transactional client is returned.
  21599. func (m TutorialMutation) Client() *Client {
  21600. client := &Client{config: m.config}
  21601. client.init()
  21602. return client
  21603. }
  21604. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21605. // it returns an error otherwise.
  21606. func (m TutorialMutation) Tx() (*Tx, error) {
  21607. if _, ok := m.driver.(*txDriver); !ok {
  21608. return nil, errors.New("ent: mutation is not running in a transaction")
  21609. }
  21610. tx := &Tx{config: m.config}
  21611. tx.init()
  21612. return tx, nil
  21613. }
  21614. // SetID sets the value of the id field. Note that this
  21615. // operation is only accepted on creation of Tutorial entities.
  21616. func (m *TutorialMutation) SetID(id uint64) {
  21617. m.id = &id
  21618. }
  21619. // ID returns the ID value in the mutation. Note that the ID is only available
  21620. // if it was provided to the builder or after it was returned from the database.
  21621. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  21622. if m.id == nil {
  21623. return
  21624. }
  21625. return *m.id, true
  21626. }
  21627. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21628. // That means, if the mutation is applied within a transaction with an isolation level such
  21629. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21630. // or updated by the mutation.
  21631. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  21632. switch {
  21633. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21634. id, exists := m.ID()
  21635. if exists {
  21636. return []uint64{id}, nil
  21637. }
  21638. fallthrough
  21639. case m.op.Is(OpUpdate | OpDelete):
  21640. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  21641. default:
  21642. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21643. }
  21644. }
  21645. // SetCreatedAt sets the "created_at" field.
  21646. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  21647. m.created_at = &t
  21648. }
  21649. // CreatedAt returns the value of the "created_at" field in the mutation.
  21650. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  21651. v := m.created_at
  21652. if v == nil {
  21653. return
  21654. }
  21655. return *v, true
  21656. }
  21657. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  21658. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21659. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21660. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21661. if !m.op.Is(OpUpdateOne) {
  21662. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21663. }
  21664. if m.id == nil || m.oldValue == nil {
  21665. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21666. }
  21667. oldValue, err := m.oldValue(ctx)
  21668. if err != nil {
  21669. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21670. }
  21671. return oldValue.CreatedAt, nil
  21672. }
  21673. // ResetCreatedAt resets all changes to the "created_at" field.
  21674. func (m *TutorialMutation) ResetCreatedAt() {
  21675. m.created_at = nil
  21676. }
  21677. // SetUpdatedAt sets the "updated_at" field.
  21678. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  21679. m.updated_at = &t
  21680. }
  21681. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21682. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  21683. v := m.updated_at
  21684. if v == nil {
  21685. return
  21686. }
  21687. return *v, true
  21688. }
  21689. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  21690. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21691. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21692. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21693. if !m.op.Is(OpUpdateOne) {
  21694. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21695. }
  21696. if m.id == nil || m.oldValue == nil {
  21697. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21698. }
  21699. oldValue, err := m.oldValue(ctx)
  21700. if err != nil {
  21701. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21702. }
  21703. return oldValue.UpdatedAt, nil
  21704. }
  21705. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21706. func (m *TutorialMutation) ResetUpdatedAt() {
  21707. m.updated_at = nil
  21708. }
  21709. // SetDeletedAt sets the "deleted_at" field.
  21710. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  21711. m.deleted_at = &t
  21712. }
  21713. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21714. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  21715. v := m.deleted_at
  21716. if v == nil {
  21717. return
  21718. }
  21719. return *v, true
  21720. }
  21721. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  21722. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21723. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21724. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21725. if !m.op.Is(OpUpdateOne) {
  21726. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21727. }
  21728. if m.id == nil || m.oldValue == nil {
  21729. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21730. }
  21731. oldValue, err := m.oldValue(ctx)
  21732. if err != nil {
  21733. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21734. }
  21735. return oldValue.DeletedAt, nil
  21736. }
  21737. // ClearDeletedAt clears the value of the "deleted_at" field.
  21738. func (m *TutorialMutation) ClearDeletedAt() {
  21739. m.deleted_at = nil
  21740. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  21741. }
  21742. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21743. func (m *TutorialMutation) DeletedAtCleared() bool {
  21744. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  21745. return ok
  21746. }
  21747. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21748. func (m *TutorialMutation) ResetDeletedAt() {
  21749. m.deleted_at = nil
  21750. delete(m.clearedFields, tutorial.FieldDeletedAt)
  21751. }
  21752. // SetEmployeeID sets the "employee_id" field.
  21753. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  21754. m.employee = &u
  21755. }
  21756. // EmployeeID returns the value of the "employee_id" field in the mutation.
  21757. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  21758. v := m.employee
  21759. if v == nil {
  21760. return
  21761. }
  21762. return *v, true
  21763. }
  21764. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  21765. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21766. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21767. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  21768. if !m.op.Is(OpUpdateOne) {
  21769. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  21770. }
  21771. if m.id == nil || m.oldValue == nil {
  21772. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  21773. }
  21774. oldValue, err := m.oldValue(ctx)
  21775. if err != nil {
  21776. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  21777. }
  21778. return oldValue.EmployeeID, nil
  21779. }
  21780. // ResetEmployeeID resets all changes to the "employee_id" field.
  21781. func (m *TutorialMutation) ResetEmployeeID() {
  21782. m.employee = nil
  21783. }
  21784. // SetIndex sets the "index" field.
  21785. func (m *TutorialMutation) SetIndex(i int) {
  21786. m.index = &i
  21787. m.addindex = nil
  21788. }
  21789. // Index returns the value of the "index" field in the mutation.
  21790. func (m *TutorialMutation) Index() (r int, exists bool) {
  21791. v := m.index
  21792. if v == nil {
  21793. return
  21794. }
  21795. return *v, true
  21796. }
  21797. // OldIndex returns the old "index" field's value of the Tutorial entity.
  21798. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21799. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21800. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  21801. if !m.op.Is(OpUpdateOne) {
  21802. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  21803. }
  21804. if m.id == nil || m.oldValue == nil {
  21805. return v, errors.New("OldIndex requires an ID field in the mutation")
  21806. }
  21807. oldValue, err := m.oldValue(ctx)
  21808. if err != nil {
  21809. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  21810. }
  21811. return oldValue.Index, nil
  21812. }
  21813. // AddIndex adds i to the "index" field.
  21814. func (m *TutorialMutation) AddIndex(i int) {
  21815. if m.addindex != nil {
  21816. *m.addindex += i
  21817. } else {
  21818. m.addindex = &i
  21819. }
  21820. }
  21821. // AddedIndex returns the value that was added to the "index" field in this mutation.
  21822. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  21823. v := m.addindex
  21824. if v == nil {
  21825. return
  21826. }
  21827. return *v, true
  21828. }
  21829. // ResetIndex resets all changes to the "index" field.
  21830. func (m *TutorialMutation) ResetIndex() {
  21831. m.index = nil
  21832. m.addindex = nil
  21833. }
  21834. // SetTitle sets the "title" field.
  21835. func (m *TutorialMutation) SetTitle(s string) {
  21836. m.title = &s
  21837. }
  21838. // Title returns the value of the "title" field in the mutation.
  21839. func (m *TutorialMutation) Title() (r string, exists bool) {
  21840. v := m.title
  21841. if v == nil {
  21842. return
  21843. }
  21844. return *v, true
  21845. }
  21846. // OldTitle returns the old "title" field's value of the Tutorial entity.
  21847. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21848. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21849. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  21850. if !m.op.Is(OpUpdateOne) {
  21851. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  21852. }
  21853. if m.id == nil || m.oldValue == nil {
  21854. return v, errors.New("OldTitle requires an ID field in the mutation")
  21855. }
  21856. oldValue, err := m.oldValue(ctx)
  21857. if err != nil {
  21858. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  21859. }
  21860. return oldValue.Title, nil
  21861. }
  21862. // ResetTitle resets all changes to the "title" field.
  21863. func (m *TutorialMutation) ResetTitle() {
  21864. m.title = nil
  21865. }
  21866. // SetContent sets the "content" field.
  21867. func (m *TutorialMutation) SetContent(s string) {
  21868. m.content = &s
  21869. }
  21870. // Content returns the value of the "content" field in the mutation.
  21871. func (m *TutorialMutation) Content() (r string, exists bool) {
  21872. v := m.content
  21873. if v == nil {
  21874. return
  21875. }
  21876. return *v, true
  21877. }
  21878. // OldContent returns the old "content" field's value of the Tutorial entity.
  21879. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21880. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21881. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  21882. if !m.op.Is(OpUpdateOne) {
  21883. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  21884. }
  21885. if m.id == nil || m.oldValue == nil {
  21886. return v, errors.New("OldContent requires an ID field in the mutation")
  21887. }
  21888. oldValue, err := m.oldValue(ctx)
  21889. if err != nil {
  21890. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  21891. }
  21892. return oldValue.Content, nil
  21893. }
  21894. // ResetContent resets all changes to the "content" field.
  21895. func (m *TutorialMutation) ResetContent() {
  21896. m.content = nil
  21897. }
  21898. // SetOrganizationID sets the "organization_id" field.
  21899. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  21900. m.organization_id = &u
  21901. m.addorganization_id = nil
  21902. }
  21903. // OrganizationID returns the value of the "organization_id" field in the mutation.
  21904. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  21905. v := m.organization_id
  21906. if v == nil {
  21907. return
  21908. }
  21909. return *v, true
  21910. }
  21911. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  21912. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  21913. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21914. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  21915. if !m.op.Is(OpUpdateOne) {
  21916. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  21917. }
  21918. if m.id == nil || m.oldValue == nil {
  21919. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  21920. }
  21921. oldValue, err := m.oldValue(ctx)
  21922. if err != nil {
  21923. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  21924. }
  21925. return oldValue.OrganizationID, nil
  21926. }
  21927. // AddOrganizationID adds u to the "organization_id" field.
  21928. func (m *TutorialMutation) AddOrganizationID(u int64) {
  21929. if m.addorganization_id != nil {
  21930. *m.addorganization_id += u
  21931. } else {
  21932. m.addorganization_id = &u
  21933. }
  21934. }
  21935. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21936. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  21937. v := m.addorganization_id
  21938. if v == nil {
  21939. return
  21940. }
  21941. return *v, true
  21942. }
  21943. // ResetOrganizationID resets all changes to the "organization_id" field.
  21944. func (m *TutorialMutation) ResetOrganizationID() {
  21945. m.organization_id = nil
  21946. m.addorganization_id = nil
  21947. }
  21948. // ClearEmployee clears the "employee" edge to the Employee entity.
  21949. func (m *TutorialMutation) ClearEmployee() {
  21950. m.clearedemployee = true
  21951. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  21952. }
  21953. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  21954. func (m *TutorialMutation) EmployeeCleared() bool {
  21955. return m.clearedemployee
  21956. }
  21957. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  21958. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21959. // EmployeeID instead. It exists only for internal usage by the builders.
  21960. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  21961. if id := m.employee; id != nil {
  21962. ids = append(ids, *id)
  21963. }
  21964. return
  21965. }
  21966. // ResetEmployee resets all changes to the "employee" edge.
  21967. func (m *TutorialMutation) ResetEmployee() {
  21968. m.employee = nil
  21969. m.clearedemployee = false
  21970. }
  21971. // Where appends a list predicates to the TutorialMutation builder.
  21972. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  21973. m.predicates = append(m.predicates, ps...)
  21974. }
  21975. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  21976. // users can use type-assertion to append predicates that do not depend on any generated package.
  21977. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  21978. p := make([]predicate.Tutorial, len(ps))
  21979. for i := range ps {
  21980. p[i] = ps[i]
  21981. }
  21982. m.Where(p...)
  21983. }
  21984. // Op returns the operation name.
  21985. func (m *TutorialMutation) Op() Op {
  21986. return m.op
  21987. }
  21988. // SetOp allows setting the mutation operation.
  21989. func (m *TutorialMutation) SetOp(op Op) {
  21990. m.op = op
  21991. }
  21992. // Type returns the node type of this mutation (Tutorial).
  21993. func (m *TutorialMutation) Type() string {
  21994. return m.typ
  21995. }
  21996. // Fields returns all fields that were changed during this mutation. Note that in
  21997. // order to get all numeric fields that were incremented/decremented, call
  21998. // AddedFields().
  21999. func (m *TutorialMutation) Fields() []string {
  22000. fields := make([]string, 0, 8)
  22001. if m.created_at != nil {
  22002. fields = append(fields, tutorial.FieldCreatedAt)
  22003. }
  22004. if m.updated_at != nil {
  22005. fields = append(fields, tutorial.FieldUpdatedAt)
  22006. }
  22007. if m.deleted_at != nil {
  22008. fields = append(fields, tutorial.FieldDeletedAt)
  22009. }
  22010. if m.employee != nil {
  22011. fields = append(fields, tutorial.FieldEmployeeID)
  22012. }
  22013. if m.index != nil {
  22014. fields = append(fields, tutorial.FieldIndex)
  22015. }
  22016. if m.title != nil {
  22017. fields = append(fields, tutorial.FieldTitle)
  22018. }
  22019. if m.content != nil {
  22020. fields = append(fields, tutorial.FieldContent)
  22021. }
  22022. if m.organization_id != nil {
  22023. fields = append(fields, tutorial.FieldOrganizationID)
  22024. }
  22025. return fields
  22026. }
  22027. // Field returns the value of a field with the given name. The second boolean
  22028. // return value indicates that this field was not set, or was not defined in the
  22029. // schema.
  22030. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  22031. switch name {
  22032. case tutorial.FieldCreatedAt:
  22033. return m.CreatedAt()
  22034. case tutorial.FieldUpdatedAt:
  22035. return m.UpdatedAt()
  22036. case tutorial.FieldDeletedAt:
  22037. return m.DeletedAt()
  22038. case tutorial.FieldEmployeeID:
  22039. return m.EmployeeID()
  22040. case tutorial.FieldIndex:
  22041. return m.Index()
  22042. case tutorial.FieldTitle:
  22043. return m.Title()
  22044. case tutorial.FieldContent:
  22045. return m.Content()
  22046. case tutorial.FieldOrganizationID:
  22047. return m.OrganizationID()
  22048. }
  22049. return nil, false
  22050. }
  22051. // OldField returns the old value of the field from the database. An error is
  22052. // returned if the mutation operation is not UpdateOne, or the query to the
  22053. // database failed.
  22054. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22055. switch name {
  22056. case tutorial.FieldCreatedAt:
  22057. return m.OldCreatedAt(ctx)
  22058. case tutorial.FieldUpdatedAt:
  22059. return m.OldUpdatedAt(ctx)
  22060. case tutorial.FieldDeletedAt:
  22061. return m.OldDeletedAt(ctx)
  22062. case tutorial.FieldEmployeeID:
  22063. return m.OldEmployeeID(ctx)
  22064. case tutorial.FieldIndex:
  22065. return m.OldIndex(ctx)
  22066. case tutorial.FieldTitle:
  22067. return m.OldTitle(ctx)
  22068. case tutorial.FieldContent:
  22069. return m.OldContent(ctx)
  22070. case tutorial.FieldOrganizationID:
  22071. return m.OldOrganizationID(ctx)
  22072. }
  22073. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  22074. }
  22075. // SetField sets the value of a field with the given name. It returns an error if
  22076. // the field is not defined in the schema, or if the type mismatched the field
  22077. // type.
  22078. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  22079. switch name {
  22080. case tutorial.FieldCreatedAt:
  22081. v, ok := value.(time.Time)
  22082. if !ok {
  22083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22084. }
  22085. m.SetCreatedAt(v)
  22086. return nil
  22087. case tutorial.FieldUpdatedAt:
  22088. v, ok := value.(time.Time)
  22089. if !ok {
  22090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22091. }
  22092. m.SetUpdatedAt(v)
  22093. return nil
  22094. case tutorial.FieldDeletedAt:
  22095. v, ok := value.(time.Time)
  22096. if !ok {
  22097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22098. }
  22099. m.SetDeletedAt(v)
  22100. return nil
  22101. case tutorial.FieldEmployeeID:
  22102. v, ok := value.(uint64)
  22103. if !ok {
  22104. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22105. }
  22106. m.SetEmployeeID(v)
  22107. return nil
  22108. case tutorial.FieldIndex:
  22109. v, ok := value.(int)
  22110. if !ok {
  22111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22112. }
  22113. m.SetIndex(v)
  22114. return nil
  22115. case tutorial.FieldTitle:
  22116. v, ok := value.(string)
  22117. if !ok {
  22118. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22119. }
  22120. m.SetTitle(v)
  22121. return nil
  22122. case tutorial.FieldContent:
  22123. v, ok := value.(string)
  22124. if !ok {
  22125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22126. }
  22127. m.SetContent(v)
  22128. return nil
  22129. case tutorial.FieldOrganizationID:
  22130. v, ok := value.(uint64)
  22131. if !ok {
  22132. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22133. }
  22134. m.SetOrganizationID(v)
  22135. return nil
  22136. }
  22137. return fmt.Errorf("unknown Tutorial field %s", name)
  22138. }
  22139. // AddedFields returns all numeric fields that were incremented/decremented during
  22140. // this mutation.
  22141. func (m *TutorialMutation) AddedFields() []string {
  22142. var fields []string
  22143. if m.addindex != nil {
  22144. fields = append(fields, tutorial.FieldIndex)
  22145. }
  22146. if m.addorganization_id != nil {
  22147. fields = append(fields, tutorial.FieldOrganizationID)
  22148. }
  22149. return fields
  22150. }
  22151. // AddedField returns the numeric value that was incremented/decremented on a field
  22152. // with the given name. The second boolean return value indicates that this field
  22153. // was not set, or was not defined in the schema.
  22154. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  22155. switch name {
  22156. case tutorial.FieldIndex:
  22157. return m.AddedIndex()
  22158. case tutorial.FieldOrganizationID:
  22159. return m.AddedOrganizationID()
  22160. }
  22161. return nil, false
  22162. }
  22163. // AddField adds the value to the field with the given name. It returns an error if
  22164. // the field is not defined in the schema, or if the type mismatched the field
  22165. // type.
  22166. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  22167. switch name {
  22168. case tutorial.FieldIndex:
  22169. v, ok := value.(int)
  22170. if !ok {
  22171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22172. }
  22173. m.AddIndex(v)
  22174. return nil
  22175. case tutorial.FieldOrganizationID:
  22176. v, ok := value.(int64)
  22177. if !ok {
  22178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22179. }
  22180. m.AddOrganizationID(v)
  22181. return nil
  22182. }
  22183. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  22184. }
  22185. // ClearedFields returns all nullable fields that were cleared during this
  22186. // mutation.
  22187. func (m *TutorialMutation) ClearedFields() []string {
  22188. var fields []string
  22189. if m.FieldCleared(tutorial.FieldDeletedAt) {
  22190. fields = append(fields, tutorial.FieldDeletedAt)
  22191. }
  22192. return fields
  22193. }
  22194. // FieldCleared returns a boolean indicating if a field with the given name was
  22195. // cleared in this mutation.
  22196. func (m *TutorialMutation) FieldCleared(name string) bool {
  22197. _, ok := m.clearedFields[name]
  22198. return ok
  22199. }
  22200. // ClearField clears the value of the field with the given name. It returns an
  22201. // error if the field is not defined in the schema.
  22202. func (m *TutorialMutation) ClearField(name string) error {
  22203. switch name {
  22204. case tutorial.FieldDeletedAt:
  22205. m.ClearDeletedAt()
  22206. return nil
  22207. }
  22208. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  22209. }
  22210. // ResetField resets all changes in the mutation for the field with the given name.
  22211. // It returns an error if the field is not defined in the schema.
  22212. func (m *TutorialMutation) ResetField(name string) error {
  22213. switch name {
  22214. case tutorial.FieldCreatedAt:
  22215. m.ResetCreatedAt()
  22216. return nil
  22217. case tutorial.FieldUpdatedAt:
  22218. m.ResetUpdatedAt()
  22219. return nil
  22220. case tutorial.FieldDeletedAt:
  22221. m.ResetDeletedAt()
  22222. return nil
  22223. case tutorial.FieldEmployeeID:
  22224. m.ResetEmployeeID()
  22225. return nil
  22226. case tutorial.FieldIndex:
  22227. m.ResetIndex()
  22228. return nil
  22229. case tutorial.FieldTitle:
  22230. m.ResetTitle()
  22231. return nil
  22232. case tutorial.FieldContent:
  22233. m.ResetContent()
  22234. return nil
  22235. case tutorial.FieldOrganizationID:
  22236. m.ResetOrganizationID()
  22237. return nil
  22238. }
  22239. return fmt.Errorf("unknown Tutorial field %s", name)
  22240. }
  22241. // AddedEdges returns all edge names that were set/added in this mutation.
  22242. func (m *TutorialMutation) AddedEdges() []string {
  22243. edges := make([]string, 0, 1)
  22244. if m.employee != nil {
  22245. edges = append(edges, tutorial.EdgeEmployee)
  22246. }
  22247. return edges
  22248. }
  22249. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22250. // name in this mutation.
  22251. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  22252. switch name {
  22253. case tutorial.EdgeEmployee:
  22254. if id := m.employee; id != nil {
  22255. return []ent.Value{*id}
  22256. }
  22257. }
  22258. return nil
  22259. }
  22260. // RemovedEdges returns all edge names that were removed in this mutation.
  22261. func (m *TutorialMutation) RemovedEdges() []string {
  22262. edges := make([]string, 0, 1)
  22263. return edges
  22264. }
  22265. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22266. // the given name in this mutation.
  22267. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  22268. return nil
  22269. }
  22270. // ClearedEdges returns all edge names that were cleared in this mutation.
  22271. func (m *TutorialMutation) ClearedEdges() []string {
  22272. edges := make([]string, 0, 1)
  22273. if m.clearedemployee {
  22274. edges = append(edges, tutorial.EdgeEmployee)
  22275. }
  22276. return edges
  22277. }
  22278. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22279. // was cleared in this mutation.
  22280. func (m *TutorialMutation) EdgeCleared(name string) bool {
  22281. switch name {
  22282. case tutorial.EdgeEmployee:
  22283. return m.clearedemployee
  22284. }
  22285. return false
  22286. }
  22287. // ClearEdge clears the value of the edge with the given name. It returns an error
  22288. // if that edge is not defined in the schema.
  22289. func (m *TutorialMutation) ClearEdge(name string) error {
  22290. switch name {
  22291. case tutorial.EdgeEmployee:
  22292. m.ClearEmployee()
  22293. return nil
  22294. }
  22295. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  22296. }
  22297. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22298. // It returns an error if the edge is not defined in the schema.
  22299. func (m *TutorialMutation) ResetEdge(name string) error {
  22300. switch name {
  22301. case tutorial.EdgeEmployee:
  22302. m.ResetEmployee()
  22303. return nil
  22304. }
  22305. return fmt.Errorf("unknown Tutorial edge %s", name)
  22306. }
  22307. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  22308. type UsageDetailMutation struct {
  22309. config
  22310. op Op
  22311. typ string
  22312. id *uint64
  22313. created_at *time.Time
  22314. updated_at *time.Time
  22315. status *uint8
  22316. addstatus *int8
  22317. _type *int
  22318. add_type *int
  22319. bot_id *string
  22320. receiver_id *string
  22321. app *int
  22322. addapp *int
  22323. session_id *uint64
  22324. addsession_id *int64
  22325. request *string
  22326. response *string
  22327. total_tokens *uint64
  22328. addtotal_tokens *int64
  22329. prompt_tokens *uint64
  22330. addprompt_tokens *int64
  22331. completion_tokens *uint64
  22332. addcompletion_tokens *int64
  22333. organization_id *uint64
  22334. addorganization_id *int64
  22335. clearedFields map[string]struct{}
  22336. done bool
  22337. oldValue func(context.Context) (*UsageDetail, error)
  22338. predicates []predicate.UsageDetail
  22339. }
  22340. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  22341. // usagedetailOption allows management of the mutation configuration using functional options.
  22342. type usagedetailOption func(*UsageDetailMutation)
  22343. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  22344. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  22345. m := &UsageDetailMutation{
  22346. config: c,
  22347. op: op,
  22348. typ: TypeUsageDetail,
  22349. clearedFields: make(map[string]struct{}),
  22350. }
  22351. for _, opt := range opts {
  22352. opt(m)
  22353. }
  22354. return m
  22355. }
  22356. // withUsageDetailID sets the ID field of the mutation.
  22357. func withUsageDetailID(id uint64) usagedetailOption {
  22358. return func(m *UsageDetailMutation) {
  22359. var (
  22360. err error
  22361. once sync.Once
  22362. value *UsageDetail
  22363. )
  22364. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  22365. once.Do(func() {
  22366. if m.done {
  22367. err = errors.New("querying old values post mutation is not allowed")
  22368. } else {
  22369. value, err = m.Client().UsageDetail.Get(ctx, id)
  22370. }
  22371. })
  22372. return value, err
  22373. }
  22374. m.id = &id
  22375. }
  22376. }
  22377. // withUsageDetail sets the old UsageDetail of the mutation.
  22378. func withUsageDetail(node *UsageDetail) usagedetailOption {
  22379. return func(m *UsageDetailMutation) {
  22380. m.oldValue = func(context.Context) (*UsageDetail, error) {
  22381. return node, nil
  22382. }
  22383. m.id = &node.ID
  22384. }
  22385. }
  22386. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22387. // executed in a transaction (ent.Tx), a transactional client is returned.
  22388. func (m UsageDetailMutation) Client() *Client {
  22389. client := &Client{config: m.config}
  22390. client.init()
  22391. return client
  22392. }
  22393. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22394. // it returns an error otherwise.
  22395. func (m UsageDetailMutation) Tx() (*Tx, error) {
  22396. if _, ok := m.driver.(*txDriver); !ok {
  22397. return nil, errors.New("ent: mutation is not running in a transaction")
  22398. }
  22399. tx := &Tx{config: m.config}
  22400. tx.init()
  22401. return tx, nil
  22402. }
  22403. // SetID sets the value of the id field. Note that this
  22404. // operation is only accepted on creation of UsageDetail entities.
  22405. func (m *UsageDetailMutation) SetID(id uint64) {
  22406. m.id = &id
  22407. }
  22408. // ID returns the ID value in the mutation. Note that the ID is only available
  22409. // if it was provided to the builder or after it was returned from the database.
  22410. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  22411. if m.id == nil {
  22412. return
  22413. }
  22414. return *m.id, true
  22415. }
  22416. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22417. // That means, if the mutation is applied within a transaction with an isolation level such
  22418. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22419. // or updated by the mutation.
  22420. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  22421. switch {
  22422. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22423. id, exists := m.ID()
  22424. if exists {
  22425. return []uint64{id}, nil
  22426. }
  22427. fallthrough
  22428. case m.op.Is(OpUpdate | OpDelete):
  22429. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  22430. default:
  22431. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22432. }
  22433. }
  22434. // SetCreatedAt sets the "created_at" field.
  22435. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  22436. m.created_at = &t
  22437. }
  22438. // CreatedAt returns the value of the "created_at" field in the mutation.
  22439. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  22440. v := m.created_at
  22441. if v == nil {
  22442. return
  22443. }
  22444. return *v, true
  22445. }
  22446. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  22447. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22448. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22449. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22450. if !m.op.Is(OpUpdateOne) {
  22451. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22452. }
  22453. if m.id == nil || m.oldValue == nil {
  22454. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22455. }
  22456. oldValue, err := m.oldValue(ctx)
  22457. if err != nil {
  22458. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22459. }
  22460. return oldValue.CreatedAt, nil
  22461. }
  22462. // ResetCreatedAt resets all changes to the "created_at" field.
  22463. func (m *UsageDetailMutation) ResetCreatedAt() {
  22464. m.created_at = nil
  22465. }
  22466. // SetUpdatedAt sets the "updated_at" field.
  22467. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  22468. m.updated_at = &t
  22469. }
  22470. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22471. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  22472. v := m.updated_at
  22473. if v == nil {
  22474. return
  22475. }
  22476. return *v, true
  22477. }
  22478. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  22479. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22480. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22481. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22482. if !m.op.Is(OpUpdateOne) {
  22483. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22484. }
  22485. if m.id == nil || m.oldValue == nil {
  22486. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22487. }
  22488. oldValue, err := m.oldValue(ctx)
  22489. if err != nil {
  22490. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22491. }
  22492. return oldValue.UpdatedAt, nil
  22493. }
  22494. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22495. func (m *UsageDetailMutation) ResetUpdatedAt() {
  22496. m.updated_at = nil
  22497. }
  22498. // SetStatus sets the "status" field.
  22499. func (m *UsageDetailMutation) SetStatus(u uint8) {
  22500. m.status = &u
  22501. m.addstatus = nil
  22502. }
  22503. // Status returns the value of the "status" field in the mutation.
  22504. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  22505. v := m.status
  22506. if v == nil {
  22507. return
  22508. }
  22509. return *v, true
  22510. }
  22511. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  22512. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22513. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22514. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22515. if !m.op.Is(OpUpdateOne) {
  22516. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22517. }
  22518. if m.id == nil || m.oldValue == nil {
  22519. return v, errors.New("OldStatus requires an ID field in the mutation")
  22520. }
  22521. oldValue, err := m.oldValue(ctx)
  22522. if err != nil {
  22523. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22524. }
  22525. return oldValue.Status, nil
  22526. }
  22527. // AddStatus adds u to the "status" field.
  22528. func (m *UsageDetailMutation) AddStatus(u int8) {
  22529. if m.addstatus != nil {
  22530. *m.addstatus += u
  22531. } else {
  22532. m.addstatus = &u
  22533. }
  22534. }
  22535. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22536. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  22537. v := m.addstatus
  22538. if v == nil {
  22539. return
  22540. }
  22541. return *v, true
  22542. }
  22543. // ClearStatus clears the value of the "status" field.
  22544. func (m *UsageDetailMutation) ClearStatus() {
  22545. m.status = nil
  22546. m.addstatus = nil
  22547. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  22548. }
  22549. // StatusCleared returns if the "status" field was cleared in this mutation.
  22550. func (m *UsageDetailMutation) StatusCleared() bool {
  22551. _, ok := m.clearedFields[usagedetail.FieldStatus]
  22552. return ok
  22553. }
  22554. // ResetStatus resets all changes to the "status" field.
  22555. func (m *UsageDetailMutation) ResetStatus() {
  22556. m.status = nil
  22557. m.addstatus = nil
  22558. delete(m.clearedFields, usagedetail.FieldStatus)
  22559. }
  22560. // SetType sets the "type" field.
  22561. func (m *UsageDetailMutation) SetType(i int) {
  22562. m._type = &i
  22563. m.add_type = nil
  22564. }
  22565. // GetType returns the value of the "type" field in the mutation.
  22566. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  22567. v := m._type
  22568. if v == nil {
  22569. return
  22570. }
  22571. return *v, true
  22572. }
  22573. // OldType returns the old "type" field's value of the UsageDetail entity.
  22574. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22575. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22576. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  22577. if !m.op.Is(OpUpdateOne) {
  22578. return v, errors.New("OldType is only allowed on UpdateOne operations")
  22579. }
  22580. if m.id == nil || m.oldValue == nil {
  22581. return v, errors.New("OldType requires an ID field in the mutation")
  22582. }
  22583. oldValue, err := m.oldValue(ctx)
  22584. if err != nil {
  22585. return v, fmt.Errorf("querying old value for OldType: %w", err)
  22586. }
  22587. return oldValue.Type, nil
  22588. }
  22589. // AddType adds i to the "type" field.
  22590. func (m *UsageDetailMutation) AddType(i int) {
  22591. if m.add_type != nil {
  22592. *m.add_type += i
  22593. } else {
  22594. m.add_type = &i
  22595. }
  22596. }
  22597. // AddedType returns the value that was added to the "type" field in this mutation.
  22598. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  22599. v := m.add_type
  22600. if v == nil {
  22601. return
  22602. }
  22603. return *v, true
  22604. }
  22605. // ClearType clears the value of the "type" field.
  22606. func (m *UsageDetailMutation) ClearType() {
  22607. m._type = nil
  22608. m.add_type = nil
  22609. m.clearedFields[usagedetail.FieldType] = struct{}{}
  22610. }
  22611. // TypeCleared returns if the "type" field was cleared in this mutation.
  22612. func (m *UsageDetailMutation) TypeCleared() bool {
  22613. _, ok := m.clearedFields[usagedetail.FieldType]
  22614. return ok
  22615. }
  22616. // ResetType resets all changes to the "type" field.
  22617. func (m *UsageDetailMutation) ResetType() {
  22618. m._type = nil
  22619. m.add_type = nil
  22620. delete(m.clearedFields, usagedetail.FieldType)
  22621. }
  22622. // SetBotID sets the "bot_id" field.
  22623. func (m *UsageDetailMutation) SetBotID(s string) {
  22624. m.bot_id = &s
  22625. }
  22626. // BotID returns the value of the "bot_id" field in the mutation.
  22627. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  22628. v := m.bot_id
  22629. if v == nil {
  22630. return
  22631. }
  22632. return *v, true
  22633. }
  22634. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  22635. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22636. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22637. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  22638. if !m.op.Is(OpUpdateOne) {
  22639. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  22640. }
  22641. if m.id == nil || m.oldValue == nil {
  22642. return v, errors.New("OldBotID requires an ID field in the mutation")
  22643. }
  22644. oldValue, err := m.oldValue(ctx)
  22645. if err != nil {
  22646. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  22647. }
  22648. return oldValue.BotID, nil
  22649. }
  22650. // ResetBotID resets all changes to the "bot_id" field.
  22651. func (m *UsageDetailMutation) ResetBotID() {
  22652. m.bot_id = nil
  22653. }
  22654. // SetReceiverID sets the "receiver_id" field.
  22655. func (m *UsageDetailMutation) SetReceiverID(s string) {
  22656. m.receiver_id = &s
  22657. }
  22658. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  22659. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  22660. v := m.receiver_id
  22661. if v == nil {
  22662. return
  22663. }
  22664. return *v, true
  22665. }
  22666. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  22667. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22668. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22669. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  22670. if !m.op.Is(OpUpdateOne) {
  22671. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  22672. }
  22673. if m.id == nil || m.oldValue == nil {
  22674. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  22675. }
  22676. oldValue, err := m.oldValue(ctx)
  22677. if err != nil {
  22678. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  22679. }
  22680. return oldValue.ReceiverID, nil
  22681. }
  22682. // ResetReceiverID resets all changes to the "receiver_id" field.
  22683. func (m *UsageDetailMutation) ResetReceiverID() {
  22684. m.receiver_id = nil
  22685. }
  22686. // SetApp sets the "app" field.
  22687. func (m *UsageDetailMutation) SetApp(i int) {
  22688. m.app = &i
  22689. m.addapp = nil
  22690. }
  22691. // App returns the value of the "app" field in the mutation.
  22692. func (m *UsageDetailMutation) App() (r int, exists bool) {
  22693. v := m.app
  22694. if v == nil {
  22695. return
  22696. }
  22697. return *v, true
  22698. }
  22699. // OldApp returns the old "app" field's value of the UsageDetail entity.
  22700. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22702. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  22703. if !m.op.Is(OpUpdateOne) {
  22704. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  22705. }
  22706. if m.id == nil || m.oldValue == nil {
  22707. return v, errors.New("OldApp requires an ID field in the mutation")
  22708. }
  22709. oldValue, err := m.oldValue(ctx)
  22710. if err != nil {
  22711. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  22712. }
  22713. return oldValue.App, nil
  22714. }
  22715. // AddApp adds i to the "app" field.
  22716. func (m *UsageDetailMutation) AddApp(i int) {
  22717. if m.addapp != nil {
  22718. *m.addapp += i
  22719. } else {
  22720. m.addapp = &i
  22721. }
  22722. }
  22723. // AddedApp returns the value that was added to the "app" field in this mutation.
  22724. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  22725. v := m.addapp
  22726. if v == nil {
  22727. return
  22728. }
  22729. return *v, true
  22730. }
  22731. // ClearApp clears the value of the "app" field.
  22732. func (m *UsageDetailMutation) ClearApp() {
  22733. m.app = nil
  22734. m.addapp = nil
  22735. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  22736. }
  22737. // AppCleared returns if the "app" field was cleared in this mutation.
  22738. func (m *UsageDetailMutation) AppCleared() bool {
  22739. _, ok := m.clearedFields[usagedetail.FieldApp]
  22740. return ok
  22741. }
  22742. // ResetApp resets all changes to the "app" field.
  22743. func (m *UsageDetailMutation) ResetApp() {
  22744. m.app = nil
  22745. m.addapp = nil
  22746. delete(m.clearedFields, usagedetail.FieldApp)
  22747. }
  22748. // SetSessionID sets the "session_id" field.
  22749. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  22750. m.session_id = &u
  22751. m.addsession_id = nil
  22752. }
  22753. // SessionID returns the value of the "session_id" field in the mutation.
  22754. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  22755. v := m.session_id
  22756. if v == nil {
  22757. return
  22758. }
  22759. return *v, true
  22760. }
  22761. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  22762. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22764. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  22765. if !m.op.Is(OpUpdateOne) {
  22766. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  22767. }
  22768. if m.id == nil || m.oldValue == nil {
  22769. return v, errors.New("OldSessionID requires an ID field in the mutation")
  22770. }
  22771. oldValue, err := m.oldValue(ctx)
  22772. if err != nil {
  22773. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  22774. }
  22775. return oldValue.SessionID, nil
  22776. }
  22777. // AddSessionID adds u to the "session_id" field.
  22778. func (m *UsageDetailMutation) AddSessionID(u int64) {
  22779. if m.addsession_id != nil {
  22780. *m.addsession_id += u
  22781. } else {
  22782. m.addsession_id = &u
  22783. }
  22784. }
  22785. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  22786. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  22787. v := m.addsession_id
  22788. if v == nil {
  22789. return
  22790. }
  22791. return *v, true
  22792. }
  22793. // ClearSessionID clears the value of the "session_id" field.
  22794. func (m *UsageDetailMutation) ClearSessionID() {
  22795. m.session_id = nil
  22796. m.addsession_id = nil
  22797. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  22798. }
  22799. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  22800. func (m *UsageDetailMutation) SessionIDCleared() bool {
  22801. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  22802. return ok
  22803. }
  22804. // ResetSessionID resets all changes to the "session_id" field.
  22805. func (m *UsageDetailMutation) ResetSessionID() {
  22806. m.session_id = nil
  22807. m.addsession_id = nil
  22808. delete(m.clearedFields, usagedetail.FieldSessionID)
  22809. }
  22810. // SetRequest sets the "request" field.
  22811. func (m *UsageDetailMutation) SetRequest(s string) {
  22812. m.request = &s
  22813. }
  22814. // Request returns the value of the "request" field in the mutation.
  22815. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  22816. v := m.request
  22817. if v == nil {
  22818. return
  22819. }
  22820. return *v, true
  22821. }
  22822. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  22823. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22824. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22825. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  22826. if !m.op.Is(OpUpdateOne) {
  22827. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  22828. }
  22829. if m.id == nil || m.oldValue == nil {
  22830. return v, errors.New("OldRequest requires an ID field in the mutation")
  22831. }
  22832. oldValue, err := m.oldValue(ctx)
  22833. if err != nil {
  22834. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  22835. }
  22836. return oldValue.Request, nil
  22837. }
  22838. // ResetRequest resets all changes to the "request" field.
  22839. func (m *UsageDetailMutation) ResetRequest() {
  22840. m.request = nil
  22841. }
  22842. // SetResponse sets the "response" field.
  22843. func (m *UsageDetailMutation) SetResponse(s string) {
  22844. m.response = &s
  22845. }
  22846. // Response returns the value of the "response" field in the mutation.
  22847. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  22848. v := m.response
  22849. if v == nil {
  22850. return
  22851. }
  22852. return *v, true
  22853. }
  22854. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  22855. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22857. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  22858. if !m.op.Is(OpUpdateOne) {
  22859. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  22860. }
  22861. if m.id == nil || m.oldValue == nil {
  22862. return v, errors.New("OldResponse requires an ID field in the mutation")
  22863. }
  22864. oldValue, err := m.oldValue(ctx)
  22865. if err != nil {
  22866. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  22867. }
  22868. return oldValue.Response, nil
  22869. }
  22870. // ResetResponse resets all changes to the "response" field.
  22871. func (m *UsageDetailMutation) ResetResponse() {
  22872. m.response = nil
  22873. }
  22874. // SetTotalTokens sets the "total_tokens" field.
  22875. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  22876. m.total_tokens = &u
  22877. m.addtotal_tokens = nil
  22878. }
  22879. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  22880. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  22881. v := m.total_tokens
  22882. if v == nil {
  22883. return
  22884. }
  22885. return *v, true
  22886. }
  22887. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  22888. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22890. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  22891. if !m.op.Is(OpUpdateOne) {
  22892. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  22893. }
  22894. if m.id == nil || m.oldValue == nil {
  22895. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  22896. }
  22897. oldValue, err := m.oldValue(ctx)
  22898. if err != nil {
  22899. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  22900. }
  22901. return oldValue.TotalTokens, nil
  22902. }
  22903. // AddTotalTokens adds u to the "total_tokens" field.
  22904. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  22905. if m.addtotal_tokens != nil {
  22906. *m.addtotal_tokens += u
  22907. } else {
  22908. m.addtotal_tokens = &u
  22909. }
  22910. }
  22911. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  22912. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  22913. v := m.addtotal_tokens
  22914. if v == nil {
  22915. return
  22916. }
  22917. return *v, true
  22918. }
  22919. // ClearTotalTokens clears the value of the "total_tokens" field.
  22920. func (m *UsageDetailMutation) ClearTotalTokens() {
  22921. m.total_tokens = nil
  22922. m.addtotal_tokens = nil
  22923. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  22924. }
  22925. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  22926. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  22927. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  22928. return ok
  22929. }
  22930. // ResetTotalTokens resets all changes to the "total_tokens" field.
  22931. func (m *UsageDetailMutation) ResetTotalTokens() {
  22932. m.total_tokens = nil
  22933. m.addtotal_tokens = nil
  22934. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  22935. }
  22936. // SetPromptTokens sets the "prompt_tokens" field.
  22937. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  22938. m.prompt_tokens = &u
  22939. m.addprompt_tokens = nil
  22940. }
  22941. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  22942. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  22943. v := m.prompt_tokens
  22944. if v == nil {
  22945. return
  22946. }
  22947. return *v, true
  22948. }
  22949. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  22950. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  22951. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22952. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  22953. if !m.op.Is(OpUpdateOne) {
  22954. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  22955. }
  22956. if m.id == nil || m.oldValue == nil {
  22957. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  22958. }
  22959. oldValue, err := m.oldValue(ctx)
  22960. if err != nil {
  22961. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  22962. }
  22963. return oldValue.PromptTokens, nil
  22964. }
  22965. // AddPromptTokens adds u to the "prompt_tokens" field.
  22966. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  22967. if m.addprompt_tokens != nil {
  22968. *m.addprompt_tokens += u
  22969. } else {
  22970. m.addprompt_tokens = &u
  22971. }
  22972. }
  22973. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  22974. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  22975. v := m.addprompt_tokens
  22976. if v == nil {
  22977. return
  22978. }
  22979. return *v, true
  22980. }
  22981. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  22982. func (m *UsageDetailMutation) ClearPromptTokens() {
  22983. m.prompt_tokens = nil
  22984. m.addprompt_tokens = nil
  22985. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  22986. }
  22987. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  22988. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  22989. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  22990. return ok
  22991. }
  22992. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  22993. func (m *UsageDetailMutation) ResetPromptTokens() {
  22994. m.prompt_tokens = nil
  22995. m.addprompt_tokens = nil
  22996. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  22997. }
  22998. // SetCompletionTokens sets the "completion_tokens" field.
  22999. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  23000. m.completion_tokens = &u
  23001. m.addcompletion_tokens = nil
  23002. }
  23003. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  23004. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  23005. v := m.completion_tokens
  23006. if v == nil {
  23007. return
  23008. }
  23009. return *v, true
  23010. }
  23011. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  23012. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23013. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23014. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  23015. if !m.op.Is(OpUpdateOne) {
  23016. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  23017. }
  23018. if m.id == nil || m.oldValue == nil {
  23019. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  23020. }
  23021. oldValue, err := m.oldValue(ctx)
  23022. if err != nil {
  23023. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  23024. }
  23025. return oldValue.CompletionTokens, nil
  23026. }
  23027. // AddCompletionTokens adds u to the "completion_tokens" field.
  23028. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  23029. if m.addcompletion_tokens != nil {
  23030. *m.addcompletion_tokens += u
  23031. } else {
  23032. m.addcompletion_tokens = &u
  23033. }
  23034. }
  23035. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  23036. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  23037. v := m.addcompletion_tokens
  23038. if v == nil {
  23039. return
  23040. }
  23041. return *v, true
  23042. }
  23043. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  23044. func (m *UsageDetailMutation) ClearCompletionTokens() {
  23045. m.completion_tokens = nil
  23046. m.addcompletion_tokens = nil
  23047. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  23048. }
  23049. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  23050. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  23051. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  23052. return ok
  23053. }
  23054. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  23055. func (m *UsageDetailMutation) ResetCompletionTokens() {
  23056. m.completion_tokens = nil
  23057. m.addcompletion_tokens = nil
  23058. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  23059. }
  23060. // SetOrganizationID sets the "organization_id" field.
  23061. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  23062. m.organization_id = &u
  23063. m.addorganization_id = nil
  23064. }
  23065. // OrganizationID returns the value of the "organization_id" field in the mutation.
  23066. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  23067. v := m.organization_id
  23068. if v == nil {
  23069. return
  23070. }
  23071. return *v, true
  23072. }
  23073. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  23074. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23075. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23076. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  23077. if !m.op.Is(OpUpdateOne) {
  23078. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  23079. }
  23080. if m.id == nil || m.oldValue == nil {
  23081. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  23082. }
  23083. oldValue, err := m.oldValue(ctx)
  23084. if err != nil {
  23085. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  23086. }
  23087. return oldValue.OrganizationID, nil
  23088. }
  23089. // AddOrganizationID adds u to the "organization_id" field.
  23090. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  23091. if m.addorganization_id != nil {
  23092. *m.addorganization_id += u
  23093. } else {
  23094. m.addorganization_id = &u
  23095. }
  23096. }
  23097. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  23098. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  23099. v := m.addorganization_id
  23100. if v == nil {
  23101. return
  23102. }
  23103. return *v, true
  23104. }
  23105. // ClearOrganizationID clears the value of the "organization_id" field.
  23106. func (m *UsageDetailMutation) ClearOrganizationID() {
  23107. m.organization_id = nil
  23108. m.addorganization_id = nil
  23109. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  23110. }
  23111. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  23112. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  23113. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  23114. return ok
  23115. }
  23116. // ResetOrganizationID resets all changes to the "organization_id" field.
  23117. func (m *UsageDetailMutation) ResetOrganizationID() {
  23118. m.organization_id = nil
  23119. m.addorganization_id = nil
  23120. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  23121. }
  23122. // Where appends a list predicates to the UsageDetailMutation builder.
  23123. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  23124. m.predicates = append(m.predicates, ps...)
  23125. }
  23126. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  23127. // users can use type-assertion to append predicates that do not depend on any generated package.
  23128. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  23129. p := make([]predicate.UsageDetail, len(ps))
  23130. for i := range ps {
  23131. p[i] = ps[i]
  23132. }
  23133. m.Where(p...)
  23134. }
  23135. // Op returns the operation name.
  23136. func (m *UsageDetailMutation) Op() Op {
  23137. return m.op
  23138. }
  23139. // SetOp allows setting the mutation operation.
  23140. func (m *UsageDetailMutation) SetOp(op Op) {
  23141. m.op = op
  23142. }
  23143. // Type returns the node type of this mutation (UsageDetail).
  23144. func (m *UsageDetailMutation) Type() string {
  23145. return m.typ
  23146. }
  23147. // Fields returns all fields that were changed during this mutation. Note that in
  23148. // order to get all numeric fields that were incremented/decremented, call
  23149. // AddedFields().
  23150. func (m *UsageDetailMutation) Fields() []string {
  23151. fields := make([]string, 0, 14)
  23152. if m.created_at != nil {
  23153. fields = append(fields, usagedetail.FieldCreatedAt)
  23154. }
  23155. if m.updated_at != nil {
  23156. fields = append(fields, usagedetail.FieldUpdatedAt)
  23157. }
  23158. if m.status != nil {
  23159. fields = append(fields, usagedetail.FieldStatus)
  23160. }
  23161. if m._type != nil {
  23162. fields = append(fields, usagedetail.FieldType)
  23163. }
  23164. if m.bot_id != nil {
  23165. fields = append(fields, usagedetail.FieldBotID)
  23166. }
  23167. if m.receiver_id != nil {
  23168. fields = append(fields, usagedetail.FieldReceiverID)
  23169. }
  23170. if m.app != nil {
  23171. fields = append(fields, usagedetail.FieldApp)
  23172. }
  23173. if m.session_id != nil {
  23174. fields = append(fields, usagedetail.FieldSessionID)
  23175. }
  23176. if m.request != nil {
  23177. fields = append(fields, usagedetail.FieldRequest)
  23178. }
  23179. if m.response != nil {
  23180. fields = append(fields, usagedetail.FieldResponse)
  23181. }
  23182. if m.total_tokens != nil {
  23183. fields = append(fields, usagedetail.FieldTotalTokens)
  23184. }
  23185. if m.prompt_tokens != nil {
  23186. fields = append(fields, usagedetail.FieldPromptTokens)
  23187. }
  23188. if m.completion_tokens != nil {
  23189. fields = append(fields, usagedetail.FieldCompletionTokens)
  23190. }
  23191. if m.organization_id != nil {
  23192. fields = append(fields, usagedetail.FieldOrganizationID)
  23193. }
  23194. return fields
  23195. }
  23196. // Field returns the value of a field with the given name. The second boolean
  23197. // return value indicates that this field was not set, or was not defined in the
  23198. // schema.
  23199. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  23200. switch name {
  23201. case usagedetail.FieldCreatedAt:
  23202. return m.CreatedAt()
  23203. case usagedetail.FieldUpdatedAt:
  23204. return m.UpdatedAt()
  23205. case usagedetail.FieldStatus:
  23206. return m.Status()
  23207. case usagedetail.FieldType:
  23208. return m.GetType()
  23209. case usagedetail.FieldBotID:
  23210. return m.BotID()
  23211. case usagedetail.FieldReceiverID:
  23212. return m.ReceiverID()
  23213. case usagedetail.FieldApp:
  23214. return m.App()
  23215. case usagedetail.FieldSessionID:
  23216. return m.SessionID()
  23217. case usagedetail.FieldRequest:
  23218. return m.Request()
  23219. case usagedetail.FieldResponse:
  23220. return m.Response()
  23221. case usagedetail.FieldTotalTokens:
  23222. return m.TotalTokens()
  23223. case usagedetail.FieldPromptTokens:
  23224. return m.PromptTokens()
  23225. case usagedetail.FieldCompletionTokens:
  23226. return m.CompletionTokens()
  23227. case usagedetail.FieldOrganizationID:
  23228. return m.OrganizationID()
  23229. }
  23230. return nil, false
  23231. }
  23232. // OldField returns the old value of the field from the database. An error is
  23233. // returned if the mutation operation is not UpdateOne, or the query to the
  23234. // database failed.
  23235. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23236. switch name {
  23237. case usagedetail.FieldCreatedAt:
  23238. return m.OldCreatedAt(ctx)
  23239. case usagedetail.FieldUpdatedAt:
  23240. return m.OldUpdatedAt(ctx)
  23241. case usagedetail.FieldStatus:
  23242. return m.OldStatus(ctx)
  23243. case usagedetail.FieldType:
  23244. return m.OldType(ctx)
  23245. case usagedetail.FieldBotID:
  23246. return m.OldBotID(ctx)
  23247. case usagedetail.FieldReceiverID:
  23248. return m.OldReceiverID(ctx)
  23249. case usagedetail.FieldApp:
  23250. return m.OldApp(ctx)
  23251. case usagedetail.FieldSessionID:
  23252. return m.OldSessionID(ctx)
  23253. case usagedetail.FieldRequest:
  23254. return m.OldRequest(ctx)
  23255. case usagedetail.FieldResponse:
  23256. return m.OldResponse(ctx)
  23257. case usagedetail.FieldTotalTokens:
  23258. return m.OldTotalTokens(ctx)
  23259. case usagedetail.FieldPromptTokens:
  23260. return m.OldPromptTokens(ctx)
  23261. case usagedetail.FieldCompletionTokens:
  23262. return m.OldCompletionTokens(ctx)
  23263. case usagedetail.FieldOrganizationID:
  23264. return m.OldOrganizationID(ctx)
  23265. }
  23266. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  23267. }
  23268. // SetField sets the value of a field with the given name. It returns an error if
  23269. // the field is not defined in the schema, or if the type mismatched the field
  23270. // type.
  23271. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  23272. switch name {
  23273. case usagedetail.FieldCreatedAt:
  23274. v, ok := value.(time.Time)
  23275. if !ok {
  23276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23277. }
  23278. m.SetCreatedAt(v)
  23279. return nil
  23280. case usagedetail.FieldUpdatedAt:
  23281. v, ok := value.(time.Time)
  23282. if !ok {
  23283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23284. }
  23285. m.SetUpdatedAt(v)
  23286. return nil
  23287. case usagedetail.FieldStatus:
  23288. v, ok := value.(uint8)
  23289. if !ok {
  23290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23291. }
  23292. m.SetStatus(v)
  23293. return nil
  23294. case usagedetail.FieldType:
  23295. v, ok := value.(int)
  23296. if !ok {
  23297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23298. }
  23299. m.SetType(v)
  23300. return nil
  23301. case usagedetail.FieldBotID:
  23302. v, ok := value.(string)
  23303. if !ok {
  23304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23305. }
  23306. m.SetBotID(v)
  23307. return nil
  23308. case usagedetail.FieldReceiverID:
  23309. v, ok := value.(string)
  23310. if !ok {
  23311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23312. }
  23313. m.SetReceiverID(v)
  23314. return nil
  23315. case usagedetail.FieldApp:
  23316. v, ok := value.(int)
  23317. if !ok {
  23318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23319. }
  23320. m.SetApp(v)
  23321. return nil
  23322. case usagedetail.FieldSessionID:
  23323. v, ok := value.(uint64)
  23324. if !ok {
  23325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23326. }
  23327. m.SetSessionID(v)
  23328. return nil
  23329. case usagedetail.FieldRequest:
  23330. v, ok := value.(string)
  23331. if !ok {
  23332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23333. }
  23334. m.SetRequest(v)
  23335. return nil
  23336. case usagedetail.FieldResponse:
  23337. v, ok := value.(string)
  23338. if !ok {
  23339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23340. }
  23341. m.SetResponse(v)
  23342. return nil
  23343. case usagedetail.FieldTotalTokens:
  23344. v, ok := value.(uint64)
  23345. if !ok {
  23346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23347. }
  23348. m.SetTotalTokens(v)
  23349. return nil
  23350. case usagedetail.FieldPromptTokens:
  23351. v, ok := value.(uint64)
  23352. if !ok {
  23353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23354. }
  23355. m.SetPromptTokens(v)
  23356. return nil
  23357. case usagedetail.FieldCompletionTokens:
  23358. v, ok := value.(uint64)
  23359. if !ok {
  23360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23361. }
  23362. m.SetCompletionTokens(v)
  23363. return nil
  23364. case usagedetail.FieldOrganizationID:
  23365. v, ok := value.(uint64)
  23366. if !ok {
  23367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23368. }
  23369. m.SetOrganizationID(v)
  23370. return nil
  23371. }
  23372. return fmt.Errorf("unknown UsageDetail field %s", name)
  23373. }
  23374. // AddedFields returns all numeric fields that were incremented/decremented during
  23375. // this mutation.
  23376. func (m *UsageDetailMutation) AddedFields() []string {
  23377. var fields []string
  23378. if m.addstatus != nil {
  23379. fields = append(fields, usagedetail.FieldStatus)
  23380. }
  23381. if m.add_type != nil {
  23382. fields = append(fields, usagedetail.FieldType)
  23383. }
  23384. if m.addapp != nil {
  23385. fields = append(fields, usagedetail.FieldApp)
  23386. }
  23387. if m.addsession_id != nil {
  23388. fields = append(fields, usagedetail.FieldSessionID)
  23389. }
  23390. if m.addtotal_tokens != nil {
  23391. fields = append(fields, usagedetail.FieldTotalTokens)
  23392. }
  23393. if m.addprompt_tokens != nil {
  23394. fields = append(fields, usagedetail.FieldPromptTokens)
  23395. }
  23396. if m.addcompletion_tokens != nil {
  23397. fields = append(fields, usagedetail.FieldCompletionTokens)
  23398. }
  23399. if m.addorganization_id != nil {
  23400. fields = append(fields, usagedetail.FieldOrganizationID)
  23401. }
  23402. return fields
  23403. }
  23404. // AddedField returns the numeric value that was incremented/decremented on a field
  23405. // with the given name. The second boolean return value indicates that this field
  23406. // was not set, or was not defined in the schema.
  23407. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  23408. switch name {
  23409. case usagedetail.FieldStatus:
  23410. return m.AddedStatus()
  23411. case usagedetail.FieldType:
  23412. return m.AddedType()
  23413. case usagedetail.FieldApp:
  23414. return m.AddedApp()
  23415. case usagedetail.FieldSessionID:
  23416. return m.AddedSessionID()
  23417. case usagedetail.FieldTotalTokens:
  23418. return m.AddedTotalTokens()
  23419. case usagedetail.FieldPromptTokens:
  23420. return m.AddedPromptTokens()
  23421. case usagedetail.FieldCompletionTokens:
  23422. return m.AddedCompletionTokens()
  23423. case usagedetail.FieldOrganizationID:
  23424. return m.AddedOrganizationID()
  23425. }
  23426. return nil, false
  23427. }
  23428. // AddField adds the value to the field with the given name. It returns an error if
  23429. // the field is not defined in the schema, or if the type mismatched the field
  23430. // type.
  23431. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  23432. switch name {
  23433. case usagedetail.FieldStatus:
  23434. v, ok := value.(int8)
  23435. if !ok {
  23436. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23437. }
  23438. m.AddStatus(v)
  23439. return nil
  23440. case usagedetail.FieldType:
  23441. v, ok := value.(int)
  23442. if !ok {
  23443. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23444. }
  23445. m.AddType(v)
  23446. return nil
  23447. case usagedetail.FieldApp:
  23448. v, ok := value.(int)
  23449. if !ok {
  23450. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23451. }
  23452. m.AddApp(v)
  23453. return nil
  23454. case usagedetail.FieldSessionID:
  23455. v, ok := value.(int64)
  23456. if !ok {
  23457. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23458. }
  23459. m.AddSessionID(v)
  23460. return nil
  23461. case usagedetail.FieldTotalTokens:
  23462. v, ok := value.(int64)
  23463. if !ok {
  23464. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23465. }
  23466. m.AddTotalTokens(v)
  23467. return nil
  23468. case usagedetail.FieldPromptTokens:
  23469. v, ok := value.(int64)
  23470. if !ok {
  23471. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23472. }
  23473. m.AddPromptTokens(v)
  23474. return nil
  23475. case usagedetail.FieldCompletionTokens:
  23476. v, ok := value.(int64)
  23477. if !ok {
  23478. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23479. }
  23480. m.AddCompletionTokens(v)
  23481. return nil
  23482. case usagedetail.FieldOrganizationID:
  23483. v, ok := value.(int64)
  23484. if !ok {
  23485. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23486. }
  23487. m.AddOrganizationID(v)
  23488. return nil
  23489. }
  23490. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  23491. }
  23492. // ClearedFields returns all nullable fields that were cleared during this
  23493. // mutation.
  23494. func (m *UsageDetailMutation) ClearedFields() []string {
  23495. var fields []string
  23496. if m.FieldCleared(usagedetail.FieldStatus) {
  23497. fields = append(fields, usagedetail.FieldStatus)
  23498. }
  23499. if m.FieldCleared(usagedetail.FieldType) {
  23500. fields = append(fields, usagedetail.FieldType)
  23501. }
  23502. if m.FieldCleared(usagedetail.FieldApp) {
  23503. fields = append(fields, usagedetail.FieldApp)
  23504. }
  23505. if m.FieldCleared(usagedetail.FieldSessionID) {
  23506. fields = append(fields, usagedetail.FieldSessionID)
  23507. }
  23508. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  23509. fields = append(fields, usagedetail.FieldTotalTokens)
  23510. }
  23511. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  23512. fields = append(fields, usagedetail.FieldPromptTokens)
  23513. }
  23514. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  23515. fields = append(fields, usagedetail.FieldCompletionTokens)
  23516. }
  23517. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  23518. fields = append(fields, usagedetail.FieldOrganizationID)
  23519. }
  23520. return fields
  23521. }
  23522. // FieldCleared returns a boolean indicating if a field with the given name was
  23523. // cleared in this mutation.
  23524. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  23525. _, ok := m.clearedFields[name]
  23526. return ok
  23527. }
  23528. // ClearField clears the value of the field with the given name. It returns an
  23529. // error if the field is not defined in the schema.
  23530. func (m *UsageDetailMutation) ClearField(name string) error {
  23531. switch name {
  23532. case usagedetail.FieldStatus:
  23533. m.ClearStatus()
  23534. return nil
  23535. case usagedetail.FieldType:
  23536. m.ClearType()
  23537. return nil
  23538. case usagedetail.FieldApp:
  23539. m.ClearApp()
  23540. return nil
  23541. case usagedetail.FieldSessionID:
  23542. m.ClearSessionID()
  23543. return nil
  23544. case usagedetail.FieldTotalTokens:
  23545. m.ClearTotalTokens()
  23546. return nil
  23547. case usagedetail.FieldPromptTokens:
  23548. m.ClearPromptTokens()
  23549. return nil
  23550. case usagedetail.FieldCompletionTokens:
  23551. m.ClearCompletionTokens()
  23552. return nil
  23553. case usagedetail.FieldOrganizationID:
  23554. m.ClearOrganizationID()
  23555. return nil
  23556. }
  23557. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  23558. }
  23559. // ResetField resets all changes in the mutation for the field with the given name.
  23560. // It returns an error if the field is not defined in the schema.
  23561. func (m *UsageDetailMutation) ResetField(name string) error {
  23562. switch name {
  23563. case usagedetail.FieldCreatedAt:
  23564. m.ResetCreatedAt()
  23565. return nil
  23566. case usagedetail.FieldUpdatedAt:
  23567. m.ResetUpdatedAt()
  23568. return nil
  23569. case usagedetail.FieldStatus:
  23570. m.ResetStatus()
  23571. return nil
  23572. case usagedetail.FieldType:
  23573. m.ResetType()
  23574. return nil
  23575. case usagedetail.FieldBotID:
  23576. m.ResetBotID()
  23577. return nil
  23578. case usagedetail.FieldReceiverID:
  23579. m.ResetReceiverID()
  23580. return nil
  23581. case usagedetail.FieldApp:
  23582. m.ResetApp()
  23583. return nil
  23584. case usagedetail.FieldSessionID:
  23585. m.ResetSessionID()
  23586. return nil
  23587. case usagedetail.FieldRequest:
  23588. m.ResetRequest()
  23589. return nil
  23590. case usagedetail.FieldResponse:
  23591. m.ResetResponse()
  23592. return nil
  23593. case usagedetail.FieldTotalTokens:
  23594. m.ResetTotalTokens()
  23595. return nil
  23596. case usagedetail.FieldPromptTokens:
  23597. m.ResetPromptTokens()
  23598. return nil
  23599. case usagedetail.FieldCompletionTokens:
  23600. m.ResetCompletionTokens()
  23601. return nil
  23602. case usagedetail.FieldOrganizationID:
  23603. m.ResetOrganizationID()
  23604. return nil
  23605. }
  23606. return fmt.Errorf("unknown UsageDetail field %s", name)
  23607. }
  23608. // AddedEdges returns all edge names that were set/added in this mutation.
  23609. func (m *UsageDetailMutation) AddedEdges() []string {
  23610. edges := make([]string, 0, 0)
  23611. return edges
  23612. }
  23613. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23614. // name in this mutation.
  23615. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  23616. return nil
  23617. }
  23618. // RemovedEdges returns all edge names that were removed in this mutation.
  23619. func (m *UsageDetailMutation) RemovedEdges() []string {
  23620. edges := make([]string, 0, 0)
  23621. return edges
  23622. }
  23623. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23624. // the given name in this mutation.
  23625. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  23626. return nil
  23627. }
  23628. // ClearedEdges returns all edge names that were cleared in this mutation.
  23629. func (m *UsageDetailMutation) ClearedEdges() []string {
  23630. edges := make([]string, 0, 0)
  23631. return edges
  23632. }
  23633. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23634. // was cleared in this mutation.
  23635. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  23636. return false
  23637. }
  23638. // ClearEdge clears the value of the edge with the given name. It returns an error
  23639. // if that edge is not defined in the schema.
  23640. func (m *UsageDetailMutation) ClearEdge(name string) error {
  23641. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  23642. }
  23643. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23644. // It returns an error if the edge is not defined in the schema.
  23645. func (m *UsageDetailMutation) ResetEdge(name string) error {
  23646. return fmt.Errorf("unknown UsageDetail edge %s", name)
  23647. }
  23648. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  23649. type UsageTotalMutation struct {
  23650. config
  23651. op Op
  23652. typ string
  23653. id *uint64
  23654. created_at *time.Time
  23655. updated_at *time.Time
  23656. status *uint8
  23657. addstatus *int8
  23658. _type *int
  23659. add_type *int
  23660. bot_id *string
  23661. total_tokens *uint64
  23662. addtotal_tokens *int64
  23663. start_index *uint64
  23664. addstart_index *int64
  23665. end_index *uint64
  23666. addend_index *int64
  23667. organization_id *uint64
  23668. addorganization_id *int64
  23669. clearedFields map[string]struct{}
  23670. done bool
  23671. oldValue func(context.Context) (*UsageTotal, error)
  23672. predicates []predicate.UsageTotal
  23673. }
  23674. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  23675. // usagetotalOption allows management of the mutation configuration using functional options.
  23676. type usagetotalOption func(*UsageTotalMutation)
  23677. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  23678. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  23679. m := &UsageTotalMutation{
  23680. config: c,
  23681. op: op,
  23682. typ: TypeUsageTotal,
  23683. clearedFields: make(map[string]struct{}),
  23684. }
  23685. for _, opt := range opts {
  23686. opt(m)
  23687. }
  23688. return m
  23689. }
  23690. // withUsageTotalID sets the ID field of the mutation.
  23691. func withUsageTotalID(id uint64) usagetotalOption {
  23692. return func(m *UsageTotalMutation) {
  23693. var (
  23694. err error
  23695. once sync.Once
  23696. value *UsageTotal
  23697. )
  23698. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  23699. once.Do(func() {
  23700. if m.done {
  23701. err = errors.New("querying old values post mutation is not allowed")
  23702. } else {
  23703. value, err = m.Client().UsageTotal.Get(ctx, id)
  23704. }
  23705. })
  23706. return value, err
  23707. }
  23708. m.id = &id
  23709. }
  23710. }
  23711. // withUsageTotal sets the old UsageTotal of the mutation.
  23712. func withUsageTotal(node *UsageTotal) usagetotalOption {
  23713. return func(m *UsageTotalMutation) {
  23714. m.oldValue = func(context.Context) (*UsageTotal, error) {
  23715. return node, nil
  23716. }
  23717. m.id = &node.ID
  23718. }
  23719. }
  23720. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23721. // executed in a transaction (ent.Tx), a transactional client is returned.
  23722. func (m UsageTotalMutation) Client() *Client {
  23723. client := &Client{config: m.config}
  23724. client.init()
  23725. return client
  23726. }
  23727. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23728. // it returns an error otherwise.
  23729. func (m UsageTotalMutation) Tx() (*Tx, error) {
  23730. if _, ok := m.driver.(*txDriver); !ok {
  23731. return nil, errors.New("ent: mutation is not running in a transaction")
  23732. }
  23733. tx := &Tx{config: m.config}
  23734. tx.init()
  23735. return tx, nil
  23736. }
  23737. // SetID sets the value of the id field. Note that this
  23738. // operation is only accepted on creation of UsageTotal entities.
  23739. func (m *UsageTotalMutation) SetID(id uint64) {
  23740. m.id = &id
  23741. }
  23742. // ID returns the ID value in the mutation. Note that the ID is only available
  23743. // if it was provided to the builder or after it was returned from the database.
  23744. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  23745. if m.id == nil {
  23746. return
  23747. }
  23748. return *m.id, true
  23749. }
  23750. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23751. // That means, if the mutation is applied within a transaction with an isolation level such
  23752. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23753. // or updated by the mutation.
  23754. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  23755. switch {
  23756. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23757. id, exists := m.ID()
  23758. if exists {
  23759. return []uint64{id}, nil
  23760. }
  23761. fallthrough
  23762. case m.op.Is(OpUpdate | OpDelete):
  23763. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  23764. default:
  23765. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23766. }
  23767. }
  23768. // SetCreatedAt sets the "created_at" field.
  23769. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  23770. m.created_at = &t
  23771. }
  23772. // CreatedAt returns the value of the "created_at" field in the mutation.
  23773. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  23774. v := m.created_at
  23775. if v == nil {
  23776. return
  23777. }
  23778. return *v, true
  23779. }
  23780. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  23781. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  23782. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23783. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23784. if !m.op.Is(OpUpdateOne) {
  23785. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23786. }
  23787. if m.id == nil || m.oldValue == nil {
  23788. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23789. }
  23790. oldValue, err := m.oldValue(ctx)
  23791. if err != nil {
  23792. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23793. }
  23794. return oldValue.CreatedAt, nil
  23795. }
  23796. // ResetCreatedAt resets all changes to the "created_at" field.
  23797. func (m *UsageTotalMutation) ResetCreatedAt() {
  23798. m.created_at = nil
  23799. }
  23800. // SetUpdatedAt sets the "updated_at" field.
  23801. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  23802. m.updated_at = &t
  23803. }
  23804. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23805. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  23806. v := m.updated_at
  23807. if v == nil {
  23808. return
  23809. }
  23810. return *v, true
  23811. }
  23812. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  23813. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  23814. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23815. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23816. if !m.op.Is(OpUpdateOne) {
  23817. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23818. }
  23819. if m.id == nil || m.oldValue == nil {
  23820. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23821. }
  23822. oldValue, err := m.oldValue(ctx)
  23823. if err != nil {
  23824. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23825. }
  23826. return oldValue.UpdatedAt, nil
  23827. }
  23828. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23829. func (m *UsageTotalMutation) ResetUpdatedAt() {
  23830. m.updated_at = nil
  23831. }
  23832. // SetStatus sets the "status" field.
  23833. func (m *UsageTotalMutation) SetStatus(u uint8) {
  23834. m.status = &u
  23835. m.addstatus = nil
  23836. }
  23837. // Status returns the value of the "status" field in the mutation.
  23838. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  23839. v := m.status
  23840. if v == nil {
  23841. return
  23842. }
  23843. return *v, true
  23844. }
  23845. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  23846. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  23847. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23848. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23849. if !m.op.Is(OpUpdateOne) {
  23850. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23851. }
  23852. if m.id == nil || m.oldValue == nil {
  23853. return v, errors.New("OldStatus requires an ID field in the mutation")
  23854. }
  23855. oldValue, err := m.oldValue(ctx)
  23856. if err != nil {
  23857. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23858. }
  23859. return oldValue.Status, nil
  23860. }
  23861. // AddStatus adds u to the "status" field.
  23862. func (m *UsageTotalMutation) AddStatus(u int8) {
  23863. if m.addstatus != nil {
  23864. *m.addstatus += u
  23865. } else {
  23866. m.addstatus = &u
  23867. }
  23868. }
  23869. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23870. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  23871. v := m.addstatus
  23872. if v == nil {
  23873. return
  23874. }
  23875. return *v, true
  23876. }
  23877. // ClearStatus clears the value of the "status" field.
  23878. func (m *UsageTotalMutation) ClearStatus() {
  23879. m.status = nil
  23880. m.addstatus = nil
  23881. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  23882. }
  23883. // StatusCleared returns if the "status" field was cleared in this mutation.
  23884. func (m *UsageTotalMutation) StatusCleared() bool {
  23885. _, ok := m.clearedFields[usagetotal.FieldStatus]
  23886. return ok
  23887. }
  23888. // ResetStatus resets all changes to the "status" field.
  23889. func (m *UsageTotalMutation) ResetStatus() {
  23890. m.status = nil
  23891. m.addstatus = nil
  23892. delete(m.clearedFields, usagetotal.FieldStatus)
  23893. }
  23894. // SetType sets the "type" field.
  23895. func (m *UsageTotalMutation) SetType(i int) {
  23896. m._type = &i
  23897. m.add_type = nil
  23898. }
  23899. // GetType returns the value of the "type" field in the mutation.
  23900. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  23901. v := m._type
  23902. if v == nil {
  23903. return
  23904. }
  23905. return *v, true
  23906. }
  23907. // OldType returns the old "type" field's value of the UsageTotal entity.
  23908. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  23909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23910. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  23911. if !m.op.Is(OpUpdateOne) {
  23912. return v, errors.New("OldType is only allowed on UpdateOne operations")
  23913. }
  23914. if m.id == nil || m.oldValue == nil {
  23915. return v, errors.New("OldType requires an ID field in the mutation")
  23916. }
  23917. oldValue, err := m.oldValue(ctx)
  23918. if err != nil {
  23919. return v, fmt.Errorf("querying old value for OldType: %w", err)
  23920. }
  23921. return oldValue.Type, nil
  23922. }
  23923. // AddType adds i to the "type" field.
  23924. func (m *UsageTotalMutation) AddType(i int) {
  23925. if m.add_type != nil {
  23926. *m.add_type += i
  23927. } else {
  23928. m.add_type = &i
  23929. }
  23930. }
  23931. // AddedType returns the value that was added to the "type" field in this mutation.
  23932. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  23933. v := m.add_type
  23934. if v == nil {
  23935. return
  23936. }
  23937. return *v, true
  23938. }
  23939. // ClearType clears the value of the "type" field.
  23940. func (m *UsageTotalMutation) ClearType() {
  23941. m._type = nil
  23942. m.add_type = nil
  23943. m.clearedFields[usagetotal.FieldType] = struct{}{}
  23944. }
  23945. // TypeCleared returns if the "type" field was cleared in this mutation.
  23946. func (m *UsageTotalMutation) TypeCleared() bool {
  23947. _, ok := m.clearedFields[usagetotal.FieldType]
  23948. return ok
  23949. }
  23950. // ResetType resets all changes to the "type" field.
  23951. func (m *UsageTotalMutation) ResetType() {
  23952. m._type = nil
  23953. m.add_type = nil
  23954. delete(m.clearedFields, usagetotal.FieldType)
  23955. }
  23956. // SetBotID sets the "bot_id" field.
  23957. func (m *UsageTotalMutation) SetBotID(s string) {
  23958. m.bot_id = &s
  23959. }
  23960. // BotID returns the value of the "bot_id" field in the mutation.
  23961. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  23962. v := m.bot_id
  23963. if v == nil {
  23964. return
  23965. }
  23966. return *v, true
  23967. }
  23968. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  23969. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  23970. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23971. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  23972. if !m.op.Is(OpUpdateOne) {
  23973. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  23974. }
  23975. if m.id == nil || m.oldValue == nil {
  23976. return v, errors.New("OldBotID requires an ID field in the mutation")
  23977. }
  23978. oldValue, err := m.oldValue(ctx)
  23979. if err != nil {
  23980. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  23981. }
  23982. return oldValue.BotID, nil
  23983. }
  23984. // ResetBotID resets all changes to the "bot_id" field.
  23985. func (m *UsageTotalMutation) ResetBotID() {
  23986. m.bot_id = nil
  23987. }
  23988. // SetTotalTokens sets the "total_tokens" field.
  23989. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  23990. m.total_tokens = &u
  23991. m.addtotal_tokens = nil
  23992. }
  23993. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  23994. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  23995. v := m.total_tokens
  23996. if v == nil {
  23997. return
  23998. }
  23999. return *v, true
  24000. }
  24001. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  24002. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  24003. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24004. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  24005. if !m.op.Is(OpUpdateOne) {
  24006. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  24007. }
  24008. if m.id == nil || m.oldValue == nil {
  24009. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  24010. }
  24011. oldValue, err := m.oldValue(ctx)
  24012. if err != nil {
  24013. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  24014. }
  24015. return oldValue.TotalTokens, nil
  24016. }
  24017. // AddTotalTokens adds u to the "total_tokens" field.
  24018. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  24019. if m.addtotal_tokens != nil {
  24020. *m.addtotal_tokens += u
  24021. } else {
  24022. m.addtotal_tokens = &u
  24023. }
  24024. }
  24025. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  24026. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  24027. v := m.addtotal_tokens
  24028. if v == nil {
  24029. return
  24030. }
  24031. return *v, true
  24032. }
  24033. // ClearTotalTokens clears the value of the "total_tokens" field.
  24034. func (m *UsageTotalMutation) ClearTotalTokens() {
  24035. m.total_tokens = nil
  24036. m.addtotal_tokens = nil
  24037. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  24038. }
  24039. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  24040. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  24041. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  24042. return ok
  24043. }
  24044. // ResetTotalTokens resets all changes to the "total_tokens" field.
  24045. func (m *UsageTotalMutation) ResetTotalTokens() {
  24046. m.total_tokens = nil
  24047. m.addtotal_tokens = nil
  24048. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  24049. }
  24050. // SetStartIndex sets the "start_index" field.
  24051. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  24052. m.start_index = &u
  24053. m.addstart_index = nil
  24054. }
  24055. // StartIndex returns the value of the "start_index" field in the mutation.
  24056. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  24057. v := m.start_index
  24058. if v == nil {
  24059. return
  24060. }
  24061. return *v, true
  24062. }
  24063. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  24064. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  24065. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24066. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  24067. if !m.op.Is(OpUpdateOne) {
  24068. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  24069. }
  24070. if m.id == nil || m.oldValue == nil {
  24071. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  24072. }
  24073. oldValue, err := m.oldValue(ctx)
  24074. if err != nil {
  24075. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  24076. }
  24077. return oldValue.StartIndex, nil
  24078. }
  24079. // AddStartIndex adds u to the "start_index" field.
  24080. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  24081. if m.addstart_index != nil {
  24082. *m.addstart_index += u
  24083. } else {
  24084. m.addstart_index = &u
  24085. }
  24086. }
  24087. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  24088. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  24089. v := m.addstart_index
  24090. if v == nil {
  24091. return
  24092. }
  24093. return *v, true
  24094. }
  24095. // ClearStartIndex clears the value of the "start_index" field.
  24096. func (m *UsageTotalMutation) ClearStartIndex() {
  24097. m.start_index = nil
  24098. m.addstart_index = nil
  24099. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  24100. }
  24101. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  24102. func (m *UsageTotalMutation) StartIndexCleared() bool {
  24103. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  24104. return ok
  24105. }
  24106. // ResetStartIndex resets all changes to the "start_index" field.
  24107. func (m *UsageTotalMutation) ResetStartIndex() {
  24108. m.start_index = nil
  24109. m.addstart_index = nil
  24110. delete(m.clearedFields, usagetotal.FieldStartIndex)
  24111. }
  24112. // SetEndIndex sets the "end_index" field.
  24113. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  24114. m.end_index = &u
  24115. m.addend_index = nil
  24116. }
  24117. // EndIndex returns the value of the "end_index" field in the mutation.
  24118. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  24119. v := m.end_index
  24120. if v == nil {
  24121. return
  24122. }
  24123. return *v, true
  24124. }
  24125. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  24126. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  24127. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24128. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  24129. if !m.op.Is(OpUpdateOne) {
  24130. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  24131. }
  24132. if m.id == nil || m.oldValue == nil {
  24133. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  24134. }
  24135. oldValue, err := m.oldValue(ctx)
  24136. if err != nil {
  24137. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  24138. }
  24139. return oldValue.EndIndex, nil
  24140. }
  24141. // AddEndIndex adds u to the "end_index" field.
  24142. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  24143. if m.addend_index != nil {
  24144. *m.addend_index += u
  24145. } else {
  24146. m.addend_index = &u
  24147. }
  24148. }
  24149. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  24150. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  24151. v := m.addend_index
  24152. if v == nil {
  24153. return
  24154. }
  24155. return *v, true
  24156. }
  24157. // ClearEndIndex clears the value of the "end_index" field.
  24158. func (m *UsageTotalMutation) ClearEndIndex() {
  24159. m.end_index = nil
  24160. m.addend_index = nil
  24161. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  24162. }
  24163. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  24164. func (m *UsageTotalMutation) EndIndexCleared() bool {
  24165. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  24166. return ok
  24167. }
  24168. // ResetEndIndex resets all changes to the "end_index" field.
  24169. func (m *UsageTotalMutation) ResetEndIndex() {
  24170. m.end_index = nil
  24171. m.addend_index = nil
  24172. delete(m.clearedFields, usagetotal.FieldEndIndex)
  24173. }
  24174. // SetOrganizationID sets the "organization_id" field.
  24175. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  24176. m.organization_id = &u
  24177. m.addorganization_id = nil
  24178. }
  24179. // OrganizationID returns the value of the "organization_id" field in the mutation.
  24180. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  24181. v := m.organization_id
  24182. if v == nil {
  24183. return
  24184. }
  24185. return *v, true
  24186. }
  24187. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  24188. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  24189. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24190. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  24191. if !m.op.Is(OpUpdateOne) {
  24192. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  24193. }
  24194. if m.id == nil || m.oldValue == nil {
  24195. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  24196. }
  24197. oldValue, err := m.oldValue(ctx)
  24198. if err != nil {
  24199. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  24200. }
  24201. return oldValue.OrganizationID, nil
  24202. }
  24203. // AddOrganizationID adds u to the "organization_id" field.
  24204. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  24205. if m.addorganization_id != nil {
  24206. *m.addorganization_id += u
  24207. } else {
  24208. m.addorganization_id = &u
  24209. }
  24210. }
  24211. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  24212. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  24213. v := m.addorganization_id
  24214. if v == nil {
  24215. return
  24216. }
  24217. return *v, true
  24218. }
  24219. // ClearOrganizationID clears the value of the "organization_id" field.
  24220. func (m *UsageTotalMutation) ClearOrganizationID() {
  24221. m.organization_id = nil
  24222. m.addorganization_id = nil
  24223. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  24224. }
  24225. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  24226. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  24227. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  24228. return ok
  24229. }
  24230. // ResetOrganizationID resets all changes to the "organization_id" field.
  24231. func (m *UsageTotalMutation) ResetOrganizationID() {
  24232. m.organization_id = nil
  24233. m.addorganization_id = nil
  24234. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  24235. }
  24236. // Where appends a list predicates to the UsageTotalMutation builder.
  24237. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  24238. m.predicates = append(m.predicates, ps...)
  24239. }
  24240. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  24241. // users can use type-assertion to append predicates that do not depend on any generated package.
  24242. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  24243. p := make([]predicate.UsageTotal, len(ps))
  24244. for i := range ps {
  24245. p[i] = ps[i]
  24246. }
  24247. m.Where(p...)
  24248. }
  24249. // Op returns the operation name.
  24250. func (m *UsageTotalMutation) Op() Op {
  24251. return m.op
  24252. }
  24253. // SetOp allows setting the mutation operation.
  24254. func (m *UsageTotalMutation) SetOp(op Op) {
  24255. m.op = op
  24256. }
  24257. // Type returns the node type of this mutation (UsageTotal).
  24258. func (m *UsageTotalMutation) Type() string {
  24259. return m.typ
  24260. }
  24261. // Fields returns all fields that were changed during this mutation. Note that in
  24262. // order to get all numeric fields that were incremented/decremented, call
  24263. // AddedFields().
  24264. func (m *UsageTotalMutation) Fields() []string {
  24265. fields := make([]string, 0, 9)
  24266. if m.created_at != nil {
  24267. fields = append(fields, usagetotal.FieldCreatedAt)
  24268. }
  24269. if m.updated_at != nil {
  24270. fields = append(fields, usagetotal.FieldUpdatedAt)
  24271. }
  24272. if m.status != nil {
  24273. fields = append(fields, usagetotal.FieldStatus)
  24274. }
  24275. if m._type != nil {
  24276. fields = append(fields, usagetotal.FieldType)
  24277. }
  24278. if m.bot_id != nil {
  24279. fields = append(fields, usagetotal.FieldBotID)
  24280. }
  24281. if m.total_tokens != nil {
  24282. fields = append(fields, usagetotal.FieldTotalTokens)
  24283. }
  24284. if m.start_index != nil {
  24285. fields = append(fields, usagetotal.FieldStartIndex)
  24286. }
  24287. if m.end_index != nil {
  24288. fields = append(fields, usagetotal.FieldEndIndex)
  24289. }
  24290. if m.organization_id != nil {
  24291. fields = append(fields, usagetotal.FieldOrganizationID)
  24292. }
  24293. return fields
  24294. }
  24295. // Field returns the value of a field with the given name. The second boolean
  24296. // return value indicates that this field was not set, or was not defined in the
  24297. // schema.
  24298. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  24299. switch name {
  24300. case usagetotal.FieldCreatedAt:
  24301. return m.CreatedAt()
  24302. case usagetotal.FieldUpdatedAt:
  24303. return m.UpdatedAt()
  24304. case usagetotal.FieldStatus:
  24305. return m.Status()
  24306. case usagetotal.FieldType:
  24307. return m.GetType()
  24308. case usagetotal.FieldBotID:
  24309. return m.BotID()
  24310. case usagetotal.FieldTotalTokens:
  24311. return m.TotalTokens()
  24312. case usagetotal.FieldStartIndex:
  24313. return m.StartIndex()
  24314. case usagetotal.FieldEndIndex:
  24315. return m.EndIndex()
  24316. case usagetotal.FieldOrganizationID:
  24317. return m.OrganizationID()
  24318. }
  24319. return nil, false
  24320. }
  24321. // OldField returns the old value of the field from the database. An error is
  24322. // returned if the mutation operation is not UpdateOne, or the query to the
  24323. // database failed.
  24324. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24325. switch name {
  24326. case usagetotal.FieldCreatedAt:
  24327. return m.OldCreatedAt(ctx)
  24328. case usagetotal.FieldUpdatedAt:
  24329. return m.OldUpdatedAt(ctx)
  24330. case usagetotal.FieldStatus:
  24331. return m.OldStatus(ctx)
  24332. case usagetotal.FieldType:
  24333. return m.OldType(ctx)
  24334. case usagetotal.FieldBotID:
  24335. return m.OldBotID(ctx)
  24336. case usagetotal.FieldTotalTokens:
  24337. return m.OldTotalTokens(ctx)
  24338. case usagetotal.FieldStartIndex:
  24339. return m.OldStartIndex(ctx)
  24340. case usagetotal.FieldEndIndex:
  24341. return m.OldEndIndex(ctx)
  24342. case usagetotal.FieldOrganizationID:
  24343. return m.OldOrganizationID(ctx)
  24344. }
  24345. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  24346. }
  24347. // SetField sets the value of a field with the given name. It returns an error if
  24348. // the field is not defined in the schema, or if the type mismatched the field
  24349. // type.
  24350. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  24351. switch name {
  24352. case usagetotal.FieldCreatedAt:
  24353. v, ok := value.(time.Time)
  24354. if !ok {
  24355. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24356. }
  24357. m.SetCreatedAt(v)
  24358. return nil
  24359. case usagetotal.FieldUpdatedAt:
  24360. v, ok := value.(time.Time)
  24361. if !ok {
  24362. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24363. }
  24364. m.SetUpdatedAt(v)
  24365. return nil
  24366. case usagetotal.FieldStatus:
  24367. v, ok := value.(uint8)
  24368. if !ok {
  24369. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24370. }
  24371. m.SetStatus(v)
  24372. return nil
  24373. case usagetotal.FieldType:
  24374. v, ok := value.(int)
  24375. if !ok {
  24376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24377. }
  24378. m.SetType(v)
  24379. return nil
  24380. case usagetotal.FieldBotID:
  24381. v, ok := value.(string)
  24382. if !ok {
  24383. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24384. }
  24385. m.SetBotID(v)
  24386. return nil
  24387. case usagetotal.FieldTotalTokens:
  24388. v, ok := value.(uint64)
  24389. if !ok {
  24390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24391. }
  24392. m.SetTotalTokens(v)
  24393. return nil
  24394. case usagetotal.FieldStartIndex:
  24395. v, ok := value.(uint64)
  24396. if !ok {
  24397. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24398. }
  24399. m.SetStartIndex(v)
  24400. return nil
  24401. case usagetotal.FieldEndIndex:
  24402. v, ok := value.(uint64)
  24403. if !ok {
  24404. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24405. }
  24406. m.SetEndIndex(v)
  24407. return nil
  24408. case usagetotal.FieldOrganizationID:
  24409. v, ok := value.(uint64)
  24410. if !ok {
  24411. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24412. }
  24413. m.SetOrganizationID(v)
  24414. return nil
  24415. }
  24416. return fmt.Errorf("unknown UsageTotal field %s", name)
  24417. }
  24418. // AddedFields returns all numeric fields that were incremented/decremented during
  24419. // this mutation.
  24420. func (m *UsageTotalMutation) AddedFields() []string {
  24421. var fields []string
  24422. if m.addstatus != nil {
  24423. fields = append(fields, usagetotal.FieldStatus)
  24424. }
  24425. if m.add_type != nil {
  24426. fields = append(fields, usagetotal.FieldType)
  24427. }
  24428. if m.addtotal_tokens != nil {
  24429. fields = append(fields, usagetotal.FieldTotalTokens)
  24430. }
  24431. if m.addstart_index != nil {
  24432. fields = append(fields, usagetotal.FieldStartIndex)
  24433. }
  24434. if m.addend_index != nil {
  24435. fields = append(fields, usagetotal.FieldEndIndex)
  24436. }
  24437. if m.addorganization_id != nil {
  24438. fields = append(fields, usagetotal.FieldOrganizationID)
  24439. }
  24440. return fields
  24441. }
  24442. // AddedField returns the numeric value that was incremented/decremented on a field
  24443. // with the given name. The second boolean return value indicates that this field
  24444. // was not set, or was not defined in the schema.
  24445. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  24446. switch name {
  24447. case usagetotal.FieldStatus:
  24448. return m.AddedStatus()
  24449. case usagetotal.FieldType:
  24450. return m.AddedType()
  24451. case usagetotal.FieldTotalTokens:
  24452. return m.AddedTotalTokens()
  24453. case usagetotal.FieldStartIndex:
  24454. return m.AddedStartIndex()
  24455. case usagetotal.FieldEndIndex:
  24456. return m.AddedEndIndex()
  24457. case usagetotal.FieldOrganizationID:
  24458. return m.AddedOrganizationID()
  24459. }
  24460. return nil, false
  24461. }
  24462. // AddField adds the value to the field with the given name. It returns an error if
  24463. // the field is not defined in the schema, or if the type mismatched the field
  24464. // type.
  24465. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  24466. switch name {
  24467. case usagetotal.FieldStatus:
  24468. v, ok := value.(int8)
  24469. if !ok {
  24470. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24471. }
  24472. m.AddStatus(v)
  24473. return nil
  24474. case usagetotal.FieldType:
  24475. v, ok := value.(int)
  24476. if !ok {
  24477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24478. }
  24479. m.AddType(v)
  24480. return nil
  24481. case usagetotal.FieldTotalTokens:
  24482. v, ok := value.(int64)
  24483. if !ok {
  24484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24485. }
  24486. m.AddTotalTokens(v)
  24487. return nil
  24488. case usagetotal.FieldStartIndex:
  24489. v, ok := value.(int64)
  24490. if !ok {
  24491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24492. }
  24493. m.AddStartIndex(v)
  24494. return nil
  24495. case usagetotal.FieldEndIndex:
  24496. v, ok := value.(int64)
  24497. if !ok {
  24498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24499. }
  24500. m.AddEndIndex(v)
  24501. return nil
  24502. case usagetotal.FieldOrganizationID:
  24503. v, ok := value.(int64)
  24504. if !ok {
  24505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24506. }
  24507. m.AddOrganizationID(v)
  24508. return nil
  24509. }
  24510. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  24511. }
  24512. // ClearedFields returns all nullable fields that were cleared during this
  24513. // mutation.
  24514. func (m *UsageTotalMutation) ClearedFields() []string {
  24515. var fields []string
  24516. if m.FieldCleared(usagetotal.FieldStatus) {
  24517. fields = append(fields, usagetotal.FieldStatus)
  24518. }
  24519. if m.FieldCleared(usagetotal.FieldType) {
  24520. fields = append(fields, usagetotal.FieldType)
  24521. }
  24522. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  24523. fields = append(fields, usagetotal.FieldTotalTokens)
  24524. }
  24525. if m.FieldCleared(usagetotal.FieldStartIndex) {
  24526. fields = append(fields, usagetotal.FieldStartIndex)
  24527. }
  24528. if m.FieldCleared(usagetotal.FieldEndIndex) {
  24529. fields = append(fields, usagetotal.FieldEndIndex)
  24530. }
  24531. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  24532. fields = append(fields, usagetotal.FieldOrganizationID)
  24533. }
  24534. return fields
  24535. }
  24536. // FieldCleared returns a boolean indicating if a field with the given name was
  24537. // cleared in this mutation.
  24538. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  24539. _, ok := m.clearedFields[name]
  24540. return ok
  24541. }
  24542. // ClearField clears the value of the field with the given name. It returns an
  24543. // error if the field is not defined in the schema.
  24544. func (m *UsageTotalMutation) ClearField(name string) error {
  24545. switch name {
  24546. case usagetotal.FieldStatus:
  24547. m.ClearStatus()
  24548. return nil
  24549. case usagetotal.FieldType:
  24550. m.ClearType()
  24551. return nil
  24552. case usagetotal.FieldTotalTokens:
  24553. m.ClearTotalTokens()
  24554. return nil
  24555. case usagetotal.FieldStartIndex:
  24556. m.ClearStartIndex()
  24557. return nil
  24558. case usagetotal.FieldEndIndex:
  24559. m.ClearEndIndex()
  24560. return nil
  24561. case usagetotal.FieldOrganizationID:
  24562. m.ClearOrganizationID()
  24563. return nil
  24564. }
  24565. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  24566. }
  24567. // ResetField resets all changes in the mutation for the field with the given name.
  24568. // It returns an error if the field is not defined in the schema.
  24569. func (m *UsageTotalMutation) ResetField(name string) error {
  24570. switch name {
  24571. case usagetotal.FieldCreatedAt:
  24572. m.ResetCreatedAt()
  24573. return nil
  24574. case usagetotal.FieldUpdatedAt:
  24575. m.ResetUpdatedAt()
  24576. return nil
  24577. case usagetotal.FieldStatus:
  24578. m.ResetStatus()
  24579. return nil
  24580. case usagetotal.FieldType:
  24581. m.ResetType()
  24582. return nil
  24583. case usagetotal.FieldBotID:
  24584. m.ResetBotID()
  24585. return nil
  24586. case usagetotal.FieldTotalTokens:
  24587. m.ResetTotalTokens()
  24588. return nil
  24589. case usagetotal.FieldStartIndex:
  24590. m.ResetStartIndex()
  24591. return nil
  24592. case usagetotal.FieldEndIndex:
  24593. m.ResetEndIndex()
  24594. return nil
  24595. case usagetotal.FieldOrganizationID:
  24596. m.ResetOrganizationID()
  24597. return nil
  24598. }
  24599. return fmt.Errorf("unknown UsageTotal field %s", name)
  24600. }
  24601. // AddedEdges returns all edge names that were set/added in this mutation.
  24602. func (m *UsageTotalMutation) AddedEdges() []string {
  24603. edges := make([]string, 0, 0)
  24604. return edges
  24605. }
  24606. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24607. // name in this mutation.
  24608. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  24609. return nil
  24610. }
  24611. // RemovedEdges returns all edge names that were removed in this mutation.
  24612. func (m *UsageTotalMutation) RemovedEdges() []string {
  24613. edges := make([]string, 0, 0)
  24614. return edges
  24615. }
  24616. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24617. // the given name in this mutation.
  24618. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  24619. return nil
  24620. }
  24621. // ClearedEdges returns all edge names that were cleared in this mutation.
  24622. func (m *UsageTotalMutation) ClearedEdges() []string {
  24623. edges := make([]string, 0, 0)
  24624. return edges
  24625. }
  24626. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24627. // was cleared in this mutation.
  24628. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  24629. return false
  24630. }
  24631. // ClearEdge clears the value of the edge with the given name. It returns an error
  24632. // if that edge is not defined in the schema.
  24633. func (m *UsageTotalMutation) ClearEdge(name string) error {
  24634. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  24635. }
  24636. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24637. // It returns an error if the edge is not defined in the schema.
  24638. func (m *UsageTotalMutation) ResetEdge(name string) error {
  24639. return fmt.Errorf("unknown UsageTotal edge %s", name)
  24640. }
  24641. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  24642. type WorkExperienceMutation struct {
  24643. config
  24644. op Op
  24645. typ string
  24646. id *uint64
  24647. created_at *time.Time
  24648. updated_at *time.Time
  24649. deleted_at *time.Time
  24650. start_date *time.Time
  24651. end_date *time.Time
  24652. company *string
  24653. experience *string
  24654. organization_id *uint64
  24655. addorganization_id *int64
  24656. clearedFields map[string]struct{}
  24657. employee *uint64
  24658. clearedemployee bool
  24659. done bool
  24660. oldValue func(context.Context) (*WorkExperience, error)
  24661. predicates []predicate.WorkExperience
  24662. }
  24663. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  24664. // workexperienceOption allows management of the mutation configuration using functional options.
  24665. type workexperienceOption func(*WorkExperienceMutation)
  24666. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  24667. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  24668. m := &WorkExperienceMutation{
  24669. config: c,
  24670. op: op,
  24671. typ: TypeWorkExperience,
  24672. clearedFields: make(map[string]struct{}),
  24673. }
  24674. for _, opt := range opts {
  24675. opt(m)
  24676. }
  24677. return m
  24678. }
  24679. // withWorkExperienceID sets the ID field of the mutation.
  24680. func withWorkExperienceID(id uint64) workexperienceOption {
  24681. return func(m *WorkExperienceMutation) {
  24682. var (
  24683. err error
  24684. once sync.Once
  24685. value *WorkExperience
  24686. )
  24687. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  24688. once.Do(func() {
  24689. if m.done {
  24690. err = errors.New("querying old values post mutation is not allowed")
  24691. } else {
  24692. value, err = m.Client().WorkExperience.Get(ctx, id)
  24693. }
  24694. })
  24695. return value, err
  24696. }
  24697. m.id = &id
  24698. }
  24699. }
  24700. // withWorkExperience sets the old WorkExperience of the mutation.
  24701. func withWorkExperience(node *WorkExperience) workexperienceOption {
  24702. return func(m *WorkExperienceMutation) {
  24703. m.oldValue = func(context.Context) (*WorkExperience, error) {
  24704. return node, nil
  24705. }
  24706. m.id = &node.ID
  24707. }
  24708. }
  24709. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24710. // executed in a transaction (ent.Tx), a transactional client is returned.
  24711. func (m WorkExperienceMutation) Client() *Client {
  24712. client := &Client{config: m.config}
  24713. client.init()
  24714. return client
  24715. }
  24716. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24717. // it returns an error otherwise.
  24718. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  24719. if _, ok := m.driver.(*txDriver); !ok {
  24720. return nil, errors.New("ent: mutation is not running in a transaction")
  24721. }
  24722. tx := &Tx{config: m.config}
  24723. tx.init()
  24724. return tx, nil
  24725. }
  24726. // SetID sets the value of the id field. Note that this
  24727. // operation is only accepted on creation of WorkExperience entities.
  24728. func (m *WorkExperienceMutation) SetID(id uint64) {
  24729. m.id = &id
  24730. }
  24731. // ID returns the ID value in the mutation. Note that the ID is only available
  24732. // if it was provided to the builder or after it was returned from the database.
  24733. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  24734. if m.id == nil {
  24735. return
  24736. }
  24737. return *m.id, true
  24738. }
  24739. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24740. // That means, if the mutation is applied within a transaction with an isolation level such
  24741. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24742. // or updated by the mutation.
  24743. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  24744. switch {
  24745. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24746. id, exists := m.ID()
  24747. if exists {
  24748. return []uint64{id}, nil
  24749. }
  24750. fallthrough
  24751. case m.op.Is(OpUpdate | OpDelete):
  24752. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  24753. default:
  24754. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24755. }
  24756. }
  24757. // SetCreatedAt sets the "created_at" field.
  24758. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  24759. m.created_at = &t
  24760. }
  24761. // CreatedAt returns the value of the "created_at" field in the mutation.
  24762. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  24763. v := m.created_at
  24764. if v == nil {
  24765. return
  24766. }
  24767. return *v, true
  24768. }
  24769. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  24770. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  24771. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24772. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24773. if !m.op.Is(OpUpdateOne) {
  24774. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24775. }
  24776. if m.id == nil || m.oldValue == nil {
  24777. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24778. }
  24779. oldValue, err := m.oldValue(ctx)
  24780. if err != nil {
  24781. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24782. }
  24783. return oldValue.CreatedAt, nil
  24784. }
  24785. // ResetCreatedAt resets all changes to the "created_at" field.
  24786. func (m *WorkExperienceMutation) ResetCreatedAt() {
  24787. m.created_at = nil
  24788. }
  24789. // SetUpdatedAt sets the "updated_at" field.
  24790. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  24791. m.updated_at = &t
  24792. }
  24793. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24794. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  24795. v := m.updated_at
  24796. if v == nil {
  24797. return
  24798. }
  24799. return *v, true
  24800. }
  24801. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  24802. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  24803. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24804. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24805. if !m.op.Is(OpUpdateOne) {
  24806. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24807. }
  24808. if m.id == nil || m.oldValue == nil {
  24809. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24810. }
  24811. oldValue, err := m.oldValue(ctx)
  24812. if err != nil {
  24813. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24814. }
  24815. return oldValue.UpdatedAt, nil
  24816. }
  24817. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24818. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  24819. m.updated_at = nil
  24820. }
  24821. // SetDeletedAt sets the "deleted_at" field.
  24822. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  24823. m.deleted_at = &t
  24824. }
  24825. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24826. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  24827. v := m.deleted_at
  24828. if v == nil {
  24829. return
  24830. }
  24831. return *v, true
  24832. }
  24833. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  24834. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  24835. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24836. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24837. if !m.op.Is(OpUpdateOne) {
  24838. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24839. }
  24840. if m.id == nil || m.oldValue == nil {
  24841. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  24842. }
  24843. oldValue, err := m.oldValue(ctx)
  24844. if err != nil {
  24845. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  24846. }
  24847. return oldValue.DeletedAt, nil
  24848. }
  24849. // ClearDeletedAt clears the value of the "deleted_at" field.
  24850. func (m *WorkExperienceMutation) ClearDeletedAt() {
  24851. m.deleted_at = nil
  24852. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  24853. }
  24854. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  24855. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  24856. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  24857. return ok
  24858. }
  24859. // ResetDeletedAt resets all changes to the "deleted_at" field.
  24860. func (m *WorkExperienceMutation) ResetDeletedAt() {
  24861. m.deleted_at = nil
  24862. delete(m.clearedFields, workexperience.FieldDeletedAt)
  24863. }
  24864. // SetEmployeeID sets the "employee_id" field.
  24865. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  24866. m.employee = &u
  24867. }
  24868. // EmployeeID returns the value of the "employee_id" field in the mutation.
  24869. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  24870. v := m.employee
  24871. if v == nil {
  24872. return
  24873. }
  24874. return *v, true
  24875. }
  24876. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  24877. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  24878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24879. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  24880. if !m.op.Is(OpUpdateOne) {
  24881. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  24882. }
  24883. if m.id == nil || m.oldValue == nil {
  24884. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  24885. }
  24886. oldValue, err := m.oldValue(ctx)
  24887. if err != nil {
  24888. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  24889. }
  24890. return oldValue.EmployeeID, nil
  24891. }
  24892. // ResetEmployeeID resets all changes to the "employee_id" field.
  24893. func (m *WorkExperienceMutation) ResetEmployeeID() {
  24894. m.employee = nil
  24895. }
  24896. // SetStartDate sets the "start_date" field.
  24897. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  24898. m.start_date = &t
  24899. }
  24900. // StartDate returns the value of the "start_date" field in the mutation.
  24901. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  24902. v := m.start_date
  24903. if v == nil {
  24904. return
  24905. }
  24906. return *v, true
  24907. }
  24908. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  24909. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  24910. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24911. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  24912. if !m.op.Is(OpUpdateOne) {
  24913. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  24914. }
  24915. if m.id == nil || m.oldValue == nil {
  24916. return v, errors.New("OldStartDate requires an ID field in the mutation")
  24917. }
  24918. oldValue, err := m.oldValue(ctx)
  24919. if err != nil {
  24920. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  24921. }
  24922. return oldValue.StartDate, nil
  24923. }
  24924. // ResetStartDate resets all changes to the "start_date" field.
  24925. func (m *WorkExperienceMutation) ResetStartDate() {
  24926. m.start_date = nil
  24927. }
  24928. // SetEndDate sets the "end_date" field.
  24929. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  24930. m.end_date = &t
  24931. }
  24932. // EndDate returns the value of the "end_date" field in the mutation.
  24933. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  24934. v := m.end_date
  24935. if v == nil {
  24936. return
  24937. }
  24938. return *v, true
  24939. }
  24940. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  24941. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  24942. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24943. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  24944. if !m.op.Is(OpUpdateOne) {
  24945. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  24946. }
  24947. if m.id == nil || m.oldValue == nil {
  24948. return v, errors.New("OldEndDate requires an ID field in the mutation")
  24949. }
  24950. oldValue, err := m.oldValue(ctx)
  24951. if err != nil {
  24952. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  24953. }
  24954. return oldValue.EndDate, nil
  24955. }
  24956. // ResetEndDate resets all changes to the "end_date" field.
  24957. func (m *WorkExperienceMutation) ResetEndDate() {
  24958. m.end_date = nil
  24959. }
  24960. // SetCompany sets the "company" field.
  24961. func (m *WorkExperienceMutation) SetCompany(s string) {
  24962. m.company = &s
  24963. }
  24964. // Company returns the value of the "company" field in the mutation.
  24965. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  24966. v := m.company
  24967. if v == nil {
  24968. return
  24969. }
  24970. return *v, true
  24971. }
  24972. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  24973. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  24974. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24975. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  24976. if !m.op.Is(OpUpdateOne) {
  24977. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  24978. }
  24979. if m.id == nil || m.oldValue == nil {
  24980. return v, errors.New("OldCompany requires an ID field in the mutation")
  24981. }
  24982. oldValue, err := m.oldValue(ctx)
  24983. if err != nil {
  24984. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  24985. }
  24986. return oldValue.Company, nil
  24987. }
  24988. // ResetCompany resets all changes to the "company" field.
  24989. func (m *WorkExperienceMutation) ResetCompany() {
  24990. m.company = nil
  24991. }
  24992. // SetExperience sets the "experience" field.
  24993. func (m *WorkExperienceMutation) SetExperience(s string) {
  24994. m.experience = &s
  24995. }
  24996. // Experience returns the value of the "experience" field in the mutation.
  24997. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  24998. v := m.experience
  24999. if v == nil {
  25000. return
  25001. }
  25002. return *v, true
  25003. }
  25004. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  25005. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  25006. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25007. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  25008. if !m.op.Is(OpUpdateOne) {
  25009. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  25010. }
  25011. if m.id == nil || m.oldValue == nil {
  25012. return v, errors.New("OldExperience requires an ID field in the mutation")
  25013. }
  25014. oldValue, err := m.oldValue(ctx)
  25015. if err != nil {
  25016. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  25017. }
  25018. return oldValue.Experience, nil
  25019. }
  25020. // ResetExperience resets all changes to the "experience" field.
  25021. func (m *WorkExperienceMutation) ResetExperience() {
  25022. m.experience = nil
  25023. }
  25024. // SetOrganizationID sets the "organization_id" field.
  25025. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  25026. m.organization_id = &u
  25027. m.addorganization_id = nil
  25028. }
  25029. // OrganizationID returns the value of the "organization_id" field in the mutation.
  25030. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  25031. v := m.organization_id
  25032. if v == nil {
  25033. return
  25034. }
  25035. return *v, true
  25036. }
  25037. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  25038. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  25039. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25040. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  25041. if !m.op.Is(OpUpdateOne) {
  25042. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  25043. }
  25044. if m.id == nil || m.oldValue == nil {
  25045. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  25046. }
  25047. oldValue, err := m.oldValue(ctx)
  25048. if err != nil {
  25049. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  25050. }
  25051. return oldValue.OrganizationID, nil
  25052. }
  25053. // AddOrganizationID adds u to the "organization_id" field.
  25054. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  25055. if m.addorganization_id != nil {
  25056. *m.addorganization_id += u
  25057. } else {
  25058. m.addorganization_id = &u
  25059. }
  25060. }
  25061. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  25062. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  25063. v := m.addorganization_id
  25064. if v == nil {
  25065. return
  25066. }
  25067. return *v, true
  25068. }
  25069. // ResetOrganizationID resets all changes to the "organization_id" field.
  25070. func (m *WorkExperienceMutation) ResetOrganizationID() {
  25071. m.organization_id = nil
  25072. m.addorganization_id = nil
  25073. }
  25074. // ClearEmployee clears the "employee" edge to the Employee entity.
  25075. func (m *WorkExperienceMutation) ClearEmployee() {
  25076. m.clearedemployee = true
  25077. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  25078. }
  25079. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  25080. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  25081. return m.clearedemployee
  25082. }
  25083. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  25084. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  25085. // EmployeeID instead. It exists only for internal usage by the builders.
  25086. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  25087. if id := m.employee; id != nil {
  25088. ids = append(ids, *id)
  25089. }
  25090. return
  25091. }
  25092. // ResetEmployee resets all changes to the "employee" edge.
  25093. func (m *WorkExperienceMutation) ResetEmployee() {
  25094. m.employee = nil
  25095. m.clearedemployee = false
  25096. }
  25097. // Where appends a list predicates to the WorkExperienceMutation builder.
  25098. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  25099. m.predicates = append(m.predicates, ps...)
  25100. }
  25101. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  25102. // users can use type-assertion to append predicates that do not depend on any generated package.
  25103. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  25104. p := make([]predicate.WorkExperience, len(ps))
  25105. for i := range ps {
  25106. p[i] = ps[i]
  25107. }
  25108. m.Where(p...)
  25109. }
  25110. // Op returns the operation name.
  25111. func (m *WorkExperienceMutation) Op() Op {
  25112. return m.op
  25113. }
  25114. // SetOp allows setting the mutation operation.
  25115. func (m *WorkExperienceMutation) SetOp(op Op) {
  25116. m.op = op
  25117. }
  25118. // Type returns the node type of this mutation (WorkExperience).
  25119. func (m *WorkExperienceMutation) Type() string {
  25120. return m.typ
  25121. }
  25122. // Fields returns all fields that were changed during this mutation. Note that in
  25123. // order to get all numeric fields that were incremented/decremented, call
  25124. // AddedFields().
  25125. func (m *WorkExperienceMutation) Fields() []string {
  25126. fields := make([]string, 0, 9)
  25127. if m.created_at != nil {
  25128. fields = append(fields, workexperience.FieldCreatedAt)
  25129. }
  25130. if m.updated_at != nil {
  25131. fields = append(fields, workexperience.FieldUpdatedAt)
  25132. }
  25133. if m.deleted_at != nil {
  25134. fields = append(fields, workexperience.FieldDeletedAt)
  25135. }
  25136. if m.employee != nil {
  25137. fields = append(fields, workexperience.FieldEmployeeID)
  25138. }
  25139. if m.start_date != nil {
  25140. fields = append(fields, workexperience.FieldStartDate)
  25141. }
  25142. if m.end_date != nil {
  25143. fields = append(fields, workexperience.FieldEndDate)
  25144. }
  25145. if m.company != nil {
  25146. fields = append(fields, workexperience.FieldCompany)
  25147. }
  25148. if m.experience != nil {
  25149. fields = append(fields, workexperience.FieldExperience)
  25150. }
  25151. if m.organization_id != nil {
  25152. fields = append(fields, workexperience.FieldOrganizationID)
  25153. }
  25154. return fields
  25155. }
  25156. // Field returns the value of a field with the given name. The second boolean
  25157. // return value indicates that this field was not set, or was not defined in the
  25158. // schema.
  25159. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  25160. switch name {
  25161. case workexperience.FieldCreatedAt:
  25162. return m.CreatedAt()
  25163. case workexperience.FieldUpdatedAt:
  25164. return m.UpdatedAt()
  25165. case workexperience.FieldDeletedAt:
  25166. return m.DeletedAt()
  25167. case workexperience.FieldEmployeeID:
  25168. return m.EmployeeID()
  25169. case workexperience.FieldStartDate:
  25170. return m.StartDate()
  25171. case workexperience.FieldEndDate:
  25172. return m.EndDate()
  25173. case workexperience.FieldCompany:
  25174. return m.Company()
  25175. case workexperience.FieldExperience:
  25176. return m.Experience()
  25177. case workexperience.FieldOrganizationID:
  25178. return m.OrganizationID()
  25179. }
  25180. return nil, false
  25181. }
  25182. // OldField returns the old value of the field from the database. An error is
  25183. // returned if the mutation operation is not UpdateOne, or the query to the
  25184. // database failed.
  25185. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25186. switch name {
  25187. case workexperience.FieldCreatedAt:
  25188. return m.OldCreatedAt(ctx)
  25189. case workexperience.FieldUpdatedAt:
  25190. return m.OldUpdatedAt(ctx)
  25191. case workexperience.FieldDeletedAt:
  25192. return m.OldDeletedAt(ctx)
  25193. case workexperience.FieldEmployeeID:
  25194. return m.OldEmployeeID(ctx)
  25195. case workexperience.FieldStartDate:
  25196. return m.OldStartDate(ctx)
  25197. case workexperience.FieldEndDate:
  25198. return m.OldEndDate(ctx)
  25199. case workexperience.FieldCompany:
  25200. return m.OldCompany(ctx)
  25201. case workexperience.FieldExperience:
  25202. return m.OldExperience(ctx)
  25203. case workexperience.FieldOrganizationID:
  25204. return m.OldOrganizationID(ctx)
  25205. }
  25206. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  25207. }
  25208. // SetField sets the value of a field with the given name. It returns an error if
  25209. // the field is not defined in the schema, or if the type mismatched the field
  25210. // type.
  25211. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  25212. switch name {
  25213. case workexperience.FieldCreatedAt:
  25214. v, ok := value.(time.Time)
  25215. if !ok {
  25216. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25217. }
  25218. m.SetCreatedAt(v)
  25219. return nil
  25220. case workexperience.FieldUpdatedAt:
  25221. v, ok := value.(time.Time)
  25222. if !ok {
  25223. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25224. }
  25225. m.SetUpdatedAt(v)
  25226. return nil
  25227. case workexperience.FieldDeletedAt:
  25228. v, ok := value.(time.Time)
  25229. if !ok {
  25230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25231. }
  25232. m.SetDeletedAt(v)
  25233. return nil
  25234. case workexperience.FieldEmployeeID:
  25235. v, ok := value.(uint64)
  25236. if !ok {
  25237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25238. }
  25239. m.SetEmployeeID(v)
  25240. return nil
  25241. case workexperience.FieldStartDate:
  25242. v, ok := value.(time.Time)
  25243. if !ok {
  25244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25245. }
  25246. m.SetStartDate(v)
  25247. return nil
  25248. case workexperience.FieldEndDate:
  25249. v, ok := value.(time.Time)
  25250. if !ok {
  25251. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25252. }
  25253. m.SetEndDate(v)
  25254. return nil
  25255. case workexperience.FieldCompany:
  25256. v, ok := value.(string)
  25257. if !ok {
  25258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25259. }
  25260. m.SetCompany(v)
  25261. return nil
  25262. case workexperience.FieldExperience:
  25263. v, ok := value.(string)
  25264. if !ok {
  25265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25266. }
  25267. m.SetExperience(v)
  25268. return nil
  25269. case workexperience.FieldOrganizationID:
  25270. v, ok := value.(uint64)
  25271. if !ok {
  25272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25273. }
  25274. m.SetOrganizationID(v)
  25275. return nil
  25276. }
  25277. return fmt.Errorf("unknown WorkExperience field %s", name)
  25278. }
  25279. // AddedFields returns all numeric fields that were incremented/decremented during
  25280. // this mutation.
  25281. func (m *WorkExperienceMutation) AddedFields() []string {
  25282. var fields []string
  25283. if m.addorganization_id != nil {
  25284. fields = append(fields, workexperience.FieldOrganizationID)
  25285. }
  25286. return fields
  25287. }
  25288. // AddedField returns the numeric value that was incremented/decremented on a field
  25289. // with the given name. The second boolean return value indicates that this field
  25290. // was not set, or was not defined in the schema.
  25291. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  25292. switch name {
  25293. case workexperience.FieldOrganizationID:
  25294. return m.AddedOrganizationID()
  25295. }
  25296. return nil, false
  25297. }
  25298. // AddField adds the value to the field with the given name. It returns an error if
  25299. // the field is not defined in the schema, or if the type mismatched the field
  25300. // type.
  25301. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  25302. switch name {
  25303. case workexperience.FieldOrganizationID:
  25304. v, ok := value.(int64)
  25305. if !ok {
  25306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25307. }
  25308. m.AddOrganizationID(v)
  25309. return nil
  25310. }
  25311. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  25312. }
  25313. // ClearedFields returns all nullable fields that were cleared during this
  25314. // mutation.
  25315. func (m *WorkExperienceMutation) ClearedFields() []string {
  25316. var fields []string
  25317. if m.FieldCleared(workexperience.FieldDeletedAt) {
  25318. fields = append(fields, workexperience.FieldDeletedAt)
  25319. }
  25320. return fields
  25321. }
  25322. // FieldCleared returns a boolean indicating if a field with the given name was
  25323. // cleared in this mutation.
  25324. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  25325. _, ok := m.clearedFields[name]
  25326. return ok
  25327. }
  25328. // ClearField clears the value of the field with the given name. It returns an
  25329. // error if the field is not defined in the schema.
  25330. func (m *WorkExperienceMutation) ClearField(name string) error {
  25331. switch name {
  25332. case workexperience.FieldDeletedAt:
  25333. m.ClearDeletedAt()
  25334. return nil
  25335. }
  25336. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  25337. }
  25338. // ResetField resets all changes in the mutation for the field with the given name.
  25339. // It returns an error if the field is not defined in the schema.
  25340. func (m *WorkExperienceMutation) ResetField(name string) error {
  25341. switch name {
  25342. case workexperience.FieldCreatedAt:
  25343. m.ResetCreatedAt()
  25344. return nil
  25345. case workexperience.FieldUpdatedAt:
  25346. m.ResetUpdatedAt()
  25347. return nil
  25348. case workexperience.FieldDeletedAt:
  25349. m.ResetDeletedAt()
  25350. return nil
  25351. case workexperience.FieldEmployeeID:
  25352. m.ResetEmployeeID()
  25353. return nil
  25354. case workexperience.FieldStartDate:
  25355. m.ResetStartDate()
  25356. return nil
  25357. case workexperience.FieldEndDate:
  25358. m.ResetEndDate()
  25359. return nil
  25360. case workexperience.FieldCompany:
  25361. m.ResetCompany()
  25362. return nil
  25363. case workexperience.FieldExperience:
  25364. m.ResetExperience()
  25365. return nil
  25366. case workexperience.FieldOrganizationID:
  25367. m.ResetOrganizationID()
  25368. return nil
  25369. }
  25370. return fmt.Errorf("unknown WorkExperience field %s", name)
  25371. }
  25372. // AddedEdges returns all edge names that were set/added in this mutation.
  25373. func (m *WorkExperienceMutation) AddedEdges() []string {
  25374. edges := make([]string, 0, 1)
  25375. if m.employee != nil {
  25376. edges = append(edges, workexperience.EdgeEmployee)
  25377. }
  25378. return edges
  25379. }
  25380. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25381. // name in this mutation.
  25382. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  25383. switch name {
  25384. case workexperience.EdgeEmployee:
  25385. if id := m.employee; id != nil {
  25386. return []ent.Value{*id}
  25387. }
  25388. }
  25389. return nil
  25390. }
  25391. // RemovedEdges returns all edge names that were removed in this mutation.
  25392. func (m *WorkExperienceMutation) RemovedEdges() []string {
  25393. edges := make([]string, 0, 1)
  25394. return edges
  25395. }
  25396. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25397. // the given name in this mutation.
  25398. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  25399. return nil
  25400. }
  25401. // ClearedEdges returns all edge names that were cleared in this mutation.
  25402. func (m *WorkExperienceMutation) ClearedEdges() []string {
  25403. edges := make([]string, 0, 1)
  25404. if m.clearedemployee {
  25405. edges = append(edges, workexperience.EdgeEmployee)
  25406. }
  25407. return edges
  25408. }
  25409. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25410. // was cleared in this mutation.
  25411. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  25412. switch name {
  25413. case workexperience.EdgeEmployee:
  25414. return m.clearedemployee
  25415. }
  25416. return false
  25417. }
  25418. // ClearEdge clears the value of the edge with the given name. It returns an error
  25419. // if that edge is not defined in the schema.
  25420. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  25421. switch name {
  25422. case workexperience.EdgeEmployee:
  25423. m.ClearEmployee()
  25424. return nil
  25425. }
  25426. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  25427. }
  25428. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25429. // It returns an error if the edge is not defined in the schema.
  25430. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  25431. switch name {
  25432. case workexperience.EdgeEmployee:
  25433. m.ResetEmployee()
  25434. return nil
  25435. }
  25436. return fmt.Errorf("unknown WorkExperience edge %s", name)
  25437. }
  25438. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  25439. type WpChatroomMutation struct {
  25440. config
  25441. op Op
  25442. typ string
  25443. id *uint64
  25444. created_at *time.Time
  25445. updated_at *time.Time
  25446. status *uint8
  25447. addstatus *int8
  25448. wx_wxid *string
  25449. chatroom_id *string
  25450. nickname *string
  25451. owner *string
  25452. avatar *string
  25453. member_list *[]string
  25454. appendmember_list []string
  25455. clearedFields map[string]struct{}
  25456. done bool
  25457. oldValue func(context.Context) (*WpChatroom, error)
  25458. predicates []predicate.WpChatroom
  25459. }
  25460. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  25461. // wpchatroomOption allows management of the mutation configuration using functional options.
  25462. type wpchatroomOption func(*WpChatroomMutation)
  25463. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  25464. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  25465. m := &WpChatroomMutation{
  25466. config: c,
  25467. op: op,
  25468. typ: TypeWpChatroom,
  25469. clearedFields: make(map[string]struct{}),
  25470. }
  25471. for _, opt := range opts {
  25472. opt(m)
  25473. }
  25474. return m
  25475. }
  25476. // withWpChatroomID sets the ID field of the mutation.
  25477. func withWpChatroomID(id uint64) wpchatroomOption {
  25478. return func(m *WpChatroomMutation) {
  25479. var (
  25480. err error
  25481. once sync.Once
  25482. value *WpChatroom
  25483. )
  25484. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  25485. once.Do(func() {
  25486. if m.done {
  25487. err = errors.New("querying old values post mutation is not allowed")
  25488. } else {
  25489. value, err = m.Client().WpChatroom.Get(ctx, id)
  25490. }
  25491. })
  25492. return value, err
  25493. }
  25494. m.id = &id
  25495. }
  25496. }
  25497. // withWpChatroom sets the old WpChatroom of the mutation.
  25498. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  25499. return func(m *WpChatroomMutation) {
  25500. m.oldValue = func(context.Context) (*WpChatroom, error) {
  25501. return node, nil
  25502. }
  25503. m.id = &node.ID
  25504. }
  25505. }
  25506. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25507. // executed in a transaction (ent.Tx), a transactional client is returned.
  25508. func (m WpChatroomMutation) Client() *Client {
  25509. client := &Client{config: m.config}
  25510. client.init()
  25511. return client
  25512. }
  25513. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25514. // it returns an error otherwise.
  25515. func (m WpChatroomMutation) Tx() (*Tx, error) {
  25516. if _, ok := m.driver.(*txDriver); !ok {
  25517. return nil, errors.New("ent: mutation is not running in a transaction")
  25518. }
  25519. tx := &Tx{config: m.config}
  25520. tx.init()
  25521. return tx, nil
  25522. }
  25523. // SetID sets the value of the id field. Note that this
  25524. // operation is only accepted on creation of WpChatroom entities.
  25525. func (m *WpChatroomMutation) SetID(id uint64) {
  25526. m.id = &id
  25527. }
  25528. // ID returns the ID value in the mutation. Note that the ID is only available
  25529. // if it was provided to the builder or after it was returned from the database.
  25530. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  25531. if m.id == nil {
  25532. return
  25533. }
  25534. return *m.id, true
  25535. }
  25536. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25537. // That means, if the mutation is applied within a transaction with an isolation level such
  25538. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25539. // or updated by the mutation.
  25540. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  25541. switch {
  25542. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25543. id, exists := m.ID()
  25544. if exists {
  25545. return []uint64{id}, nil
  25546. }
  25547. fallthrough
  25548. case m.op.Is(OpUpdate | OpDelete):
  25549. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  25550. default:
  25551. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25552. }
  25553. }
  25554. // SetCreatedAt sets the "created_at" field.
  25555. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  25556. m.created_at = &t
  25557. }
  25558. // CreatedAt returns the value of the "created_at" field in the mutation.
  25559. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  25560. v := m.created_at
  25561. if v == nil {
  25562. return
  25563. }
  25564. return *v, true
  25565. }
  25566. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  25567. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  25568. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25569. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25570. if !m.op.Is(OpUpdateOne) {
  25571. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25572. }
  25573. if m.id == nil || m.oldValue == nil {
  25574. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  25575. }
  25576. oldValue, err := m.oldValue(ctx)
  25577. if err != nil {
  25578. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25579. }
  25580. return oldValue.CreatedAt, nil
  25581. }
  25582. // ResetCreatedAt resets all changes to the "created_at" field.
  25583. func (m *WpChatroomMutation) ResetCreatedAt() {
  25584. m.created_at = nil
  25585. }
  25586. // SetUpdatedAt sets the "updated_at" field.
  25587. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  25588. m.updated_at = &t
  25589. }
  25590. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25591. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  25592. v := m.updated_at
  25593. if v == nil {
  25594. return
  25595. }
  25596. return *v, true
  25597. }
  25598. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  25599. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  25600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25601. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25602. if !m.op.Is(OpUpdateOne) {
  25603. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25604. }
  25605. if m.id == nil || m.oldValue == nil {
  25606. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25607. }
  25608. oldValue, err := m.oldValue(ctx)
  25609. if err != nil {
  25610. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25611. }
  25612. return oldValue.UpdatedAt, nil
  25613. }
  25614. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25615. func (m *WpChatroomMutation) ResetUpdatedAt() {
  25616. m.updated_at = nil
  25617. }
  25618. // SetStatus sets the "status" field.
  25619. func (m *WpChatroomMutation) SetStatus(u uint8) {
  25620. m.status = &u
  25621. m.addstatus = nil
  25622. }
  25623. // Status returns the value of the "status" field in the mutation.
  25624. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  25625. v := m.status
  25626. if v == nil {
  25627. return
  25628. }
  25629. return *v, true
  25630. }
  25631. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  25632. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  25633. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25634. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  25635. if !m.op.Is(OpUpdateOne) {
  25636. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  25637. }
  25638. if m.id == nil || m.oldValue == nil {
  25639. return v, errors.New("OldStatus requires an ID field in the mutation")
  25640. }
  25641. oldValue, err := m.oldValue(ctx)
  25642. if err != nil {
  25643. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  25644. }
  25645. return oldValue.Status, nil
  25646. }
  25647. // AddStatus adds u to the "status" field.
  25648. func (m *WpChatroomMutation) AddStatus(u int8) {
  25649. if m.addstatus != nil {
  25650. *m.addstatus += u
  25651. } else {
  25652. m.addstatus = &u
  25653. }
  25654. }
  25655. // AddedStatus returns the value that was added to the "status" field in this mutation.
  25656. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  25657. v := m.addstatus
  25658. if v == nil {
  25659. return
  25660. }
  25661. return *v, true
  25662. }
  25663. // ClearStatus clears the value of the "status" field.
  25664. func (m *WpChatroomMutation) ClearStatus() {
  25665. m.status = nil
  25666. m.addstatus = nil
  25667. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  25668. }
  25669. // StatusCleared returns if the "status" field was cleared in this mutation.
  25670. func (m *WpChatroomMutation) StatusCleared() bool {
  25671. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  25672. return ok
  25673. }
  25674. // ResetStatus resets all changes to the "status" field.
  25675. func (m *WpChatroomMutation) ResetStatus() {
  25676. m.status = nil
  25677. m.addstatus = nil
  25678. delete(m.clearedFields, wpchatroom.FieldStatus)
  25679. }
  25680. // SetWxWxid sets the "wx_wxid" field.
  25681. func (m *WpChatroomMutation) SetWxWxid(s string) {
  25682. m.wx_wxid = &s
  25683. }
  25684. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  25685. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  25686. v := m.wx_wxid
  25687. if v == nil {
  25688. return
  25689. }
  25690. return *v, true
  25691. }
  25692. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  25693. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  25694. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25695. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  25696. if !m.op.Is(OpUpdateOne) {
  25697. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  25698. }
  25699. if m.id == nil || m.oldValue == nil {
  25700. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  25701. }
  25702. oldValue, err := m.oldValue(ctx)
  25703. if err != nil {
  25704. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  25705. }
  25706. return oldValue.WxWxid, nil
  25707. }
  25708. // ResetWxWxid resets all changes to the "wx_wxid" field.
  25709. func (m *WpChatroomMutation) ResetWxWxid() {
  25710. m.wx_wxid = nil
  25711. }
  25712. // SetChatroomID sets the "chatroom_id" field.
  25713. func (m *WpChatroomMutation) SetChatroomID(s string) {
  25714. m.chatroom_id = &s
  25715. }
  25716. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  25717. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  25718. v := m.chatroom_id
  25719. if v == nil {
  25720. return
  25721. }
  25722. return *v, true
  25723. }
  25724. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  25725. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  25726. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25727. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  25728. if !m.op.Is(OpUpdateOne) {
  25729. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  25730. }
  25731. if m.id == nil || m.oldValue == nil {
  25732. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  25733. }
  25734. oldValue, err := m.oldValue(ctx)
  25735. if err != nil {
  25736. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  25737. }
  25738. return oldValue.ChatroomID, nil
  25739. }
  25740. // ResetChatroomID resets all changes to the "chatroom_id" field.
  25741. func (m *WpChatroomMutation) ResetChatroomID() {
  25742. m.chatroom_id = nil
  25743. }
  25744. // SetNickname sets the "nickname" field.
  25745. func (m *WpChatroomMutation) SetNickname(s string) {
  25746. m.nickname = &s
  25747. }
  25748. // Nickname returns the value of the "nickname" field in the mutation.
  25749. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  25750. v := m.nickname
  25751. if v == nil {
  25752. return
  25753. }
  25754. return *v, true
  25755. }
  25756. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  25757. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  25758. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25759. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  25760. if !m.op.Is(OpUpdateOne) {
  25761. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  25762. }
  25763. if m.id == nil || m.oldValue == nil {
  25764. return v, errors.New("OldNickname requires an ID field in the mutation")
  25765. }
  25766. oldValue, err := m.oldValue(ctx)
  25767. if err != nil {
  25768. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  25769. }
  25770. return oldValue.Nickname, nil
  25771. }
  25772. // ResetNickname resets all changes to the "nickname" field.
  25773. func (m *WpChatroomMutation) ResetNickname() {
  25774. m.nickname = nil
  25775. }
  25776. // SetOwner sets the "owner" field.
  25777. func (m *WpChatroomMutation) SetOwner(s string) {
  25778. m.owner = &s
  25779. }
  25780. // Owner returns the value of the "owner" field in the mutation.
  25781. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  25782. v := m.owner
  25783. if v == nil {
  25784. return
  25785. }
  25786. return *v, true
  25787. }
  25788. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  25789. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  25790. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25791. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  25792. if !m.op.Is(OpUpdateOne) {
  25793. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  25794. }
  25795. if m.id == nil || m.oldValue == nil {
  25796. return v, errors.New("OldOwner requires an ID field in the mutation")
  25797. }
  25798. oldValue, err := m.oldValue(ctx)
  25799. if err != nil {
  25800. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  25801. }
  25802. return oldValue.Owner, nil
  25803. }
  25804. // ResetOwner resets all changes to the "owner" field.
  25805. func (m *WpChatroomMutation) ResetOwner() {
  25806. m.owner = nil
  25807. }
  25808. // SetAvatar sets the "avatar" field.
  25809. func (m *WpChatroomMutation) SetAvatar(s string) {
  25810. m.avatar = &s
  25811. }
  25812. // Avatar returns the value of the "avatar" field in the mutation.
  25813. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  25814. v := m.avatar
  25815. if v == nil {
  25816. return
  25817. }
  25818. return *v, true
  25819. }
  25820. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  25821. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  25822. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25823. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  25824. if !m.op.Is(OpUpdateOne) {
  25825. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  25826. }
  25827. if m.id == nil || m.oldValue == nil {
  25828. return v, errors.New("OldAvatar requires an ID field in the mutation")
  25829. }
  25830. oldValue, err := m.oldValue(ctx)
  25831. if err != nil {
  25832. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  25833. }
  25834. return oldValue.Avatar, nil
  25835. }
  25836. // ResetAvatar resets all changes to the "avatar" field.
  25837. func (m *WpChatroomMutation) ResetAvatar() {
  25838. m.avatar = nil
  25839. }
  25840. // SetMemberList sets the "member_list" field.
  25841. func (m *WpChatroomMutation) SetMemberList(s []string) {
  25842. m.member_list = &s
  25843. m.appendmember_list = nil
  25844. }
  25845. // MemberList returns the value of the "member_list" field in the mutation.
  25846. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  25847. v := m.member_list
  25848. if v == nil {
  25849. return
  25850. }
  25851. return *v, true
  25852. }
  25853. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  25854. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  25855. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25856. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  25857. if !m.op.Is(OpUpdateOne) {
  25858. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  25859. }
  25860. if m.id == nil || m.oldValue == nil {
  25861. return v, errors.New("OldMemberList requires an ID field in the mutation")
  25862. }
  25863. oldValue, err := m.oldValue(ctx)
  25864. if err != nil {
  25865. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  25866. }
  25867. return oldValue.MemberList, nil
  25868. }
  25869. // AppendMemberList adds s to the "member_list" field.
  25870. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  25871. m.appendmember_list = append(m.appendmember_list, s...)
  25872. }
  25873. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  25874. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  25875. if len(m.appendmember_list) == 0 {
  25876. return nil, false
  25877. }
  25878. return m.appendmember_list, true
  25879. }
  25880. // ResetMemberList resets all changes to the "member_list" field.
  25881. func (m *WpChatroomMutation) ResetMemberList() {
  25882. m.member_list = nil
  25883. m.appendmember_list = nil
  25884. }
  25885. // Where appends a list predicates to the WpChatroomMutation builder.
  25886. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  25887. m.predicates = append(m.predicates, ps...)
  25888. }
  25889. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  25890. // users can use type-assertion to append predicates that do not depend on any generated package.
  25891. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  25892. p := make([]predicate.WpChatroom, len(ps))
  25893. for i := range ps {
  25894. p[i] = ps[i]
  25895. }
  25896. m.Where(p...)
  25897. }
  25898. // Op returns the operation name.
  25899. func (m *WpChatroomMutation) Op() Op {
  25900. return m.op
  25901. }
  25902. // SetOp allows setting the mutation operation.
  25903. func (m *WpChatroomMutation) SetOp(op Op) {
  25904. m.op = op
  25905. }
  25906. // Type returns the node type of this mutation (WpChatroom).
  25907. func (m *WpChatroomMutation) Type() string {
  25908. return m.typ
  25909. }
  25910. // Fields returns all fields that were changed during this mutation. Note that in
  25911. // order to get all numeric fields that were incremented/decremented, call
  25912. // AddedFields().
  25913. func (m *WpChatroomMutation) Fields() []string {
  25914. fields := make([]string, 0, 9)
  25915. if m.created_at != nil {
  25916. fields = append(fields, wpchatroom.FieldCreatedAt)
  25917. }
  25918. if m.updated_at != nil {
  25919. fields = append(fields, wpchatroom.FieldUpdatedAt)
  25920. }
  25921. if m.status != nil {
  25922. fields = append(fields, wpchatroom.FieldStatus)
  25923. }
  25924. if m.wx_wxid != nil {
  25925. fields = append(fields, wpchatroom.FieldWxWxid)
  25926. }
  25927. if m.chatroom_id != nil {
  25928. fields = append(fields, wpchatroom.FieldChatroomID)
  25929. }
  25930. if m.nickname != nil {
  25931. fields = append(fields, wpchatroom.FieldNickname)
  25932. }
  25933. if m.owner != nil {
  25934. fields = append(fields, wpchatroom.FieldOwner)
  25935. }
  25936. if m.avatar != nil {
  25937. fields = append(fields, wpchatroom.FieldAvatar)
  25938. }
  25939. if m.member_list != nil {
  25940. fields = append(fields, wpchatroom.FieldMemberList)
  25941. }
  25942. return fields
  25943. }
  25944. // Field returns the value of a field with the given name. The second boolean
  25945. // return value indicates that this field was not set, or was not defined in the
  25946. // schema.
  25947. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  25948. switch name {
  25949. case wpchatroom.FieldCreatedAt:
  25950. return m.CreatedAt()
  25951. case wpchatroom.FieldUpdatedAt:
  25952. return m.UpdatedAt()
  25953. case wpchatroom.FieldStatus:
  25954. return m.Status()
  25955. case wpchatroom.FieldWxWxid:
  25956. return m.WxWxid()
  25957. case wpchatroom.FieldChatroomID:
  25958. return m.ChatroomID()
  25959. case wpchatroom.FieldNickname:
  25960. return m.Nickname()
  25961. case wpchatroom.FieldOwner:
  25962. return m.Owner()
  25963. case wpchatroom.FieldAvatar:
  25964. return m.Avatar()
  25965. case wpchatroom.FieldMemberList:
  25966. return m.MemberList()
  25967. }
  25968. return nil, false
  25969. }
  25970. // OldField returns the old value of the field from the database. An error is
  25971. // returned if the mutation operation is not UpdateOne, or the query to the
  25972. // database failed.
  25973. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25974. switch name {
  25975. case wpchatroom.FieldCreatedAt:
  25976. return m.OldCreatedAt(ctx)
  25977. case wpchatroom.FieldUpdatedAt:
  25978. return m.OldUpdatedAt(ctx)
  25979. case wpchatroom.FieldStatus:
  25980. return m.OldStatus(ctx)
  25981. case wpchatroom.FieldWxWxid:
  25982. return m.OldWxWxid(ctx)
  25983. case wpchatroom.FieldChatroomID:
  25984. return m.OldChatroomID(ctx)
  25985. case wpchatroom.FieldNickname:
  25986. return m.OldNickname(ctx)
  25987. case wpchatroom.FieldOwner:
  25988. return m.OldOwner(ctx)
  25989. case wpchatroom.FieldAvatar:
  25990. return m.OldAvatar(ctx)
  25991. case wpchatroom.FieldMemberList:
  25992. return m.OldMemberList(ctx)
  25993. }
  25994. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  25995. }
  25996. // SetField sets the value of a field with the given name. It returns an error if
  25997. // the field is not defined in the schema, or if the type mismatched the field
  25998. // type.
  25999. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  26000. switch name {
  26001. case wpchatroom.FieldCreatedAt:
  26002. v, ok := value.(time.Time)
  26003. if !ok {
  26004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26005. }
  26006. m.SetCreatedAt(v)
  26007. return nil
  26008. case wpchatroom.FieldUpdatedAt:
  26009. v, ok := value.(time.Time)
  26010. if !ok {
  26011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26012. }
  26013. m.SetUpdatedAt(v)
  26014. return nil
  26015. case wpchatroom.FieldStatus:
  26016. v, ok := value.(uint8)
  26017. if !ok {
  26018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26019. }
  26020. m.SetStatus(v)
  26021. return nil
  26022. case wpchatroom.FieldWxWxid:
  26023. v, ok := value.(string)
  26024. if !ok {
  26025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26026. }
  26027. m.SetWxWxid(v)
  26028. return nil
  26029. case wpchatroom.FieldChatroomID:
  26030. v, ok := value.(string)
  26031. if !ok {
  26032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26033. }
  26034. m.SetChatroomID(v)
  26035. return nil
  26036. case wpchatroom.FieldNickname:
  26037. v, ok := value.(string)
  26038. if !ok {
  26039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26040. }
  26041. m.SetNickname(v)
  26042. return nil
  26043. case wpchatroom.FieldOwner:
  26044. v, ok := value.(string)
  26045. if !ok {
  26046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26047. }
  26048. m.SetOwner(v)
  26049. return nil
  26050. case wpchatroom.FieldAvatar:
  26051. v, ok := value.(string)
  26052. if !ok {
  26053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26054. }
  26055. m.SetAvatar(v)
  26056. return nil
  26057. case wpchatroom.FieldMemberList:
  26058. v, ok := value.([]string)
  26059. if !ok {
  26060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26061. }
  26062. m.SetMemberList(v)
  26063. return nil
  26064. }
  26065. return fmt.Errorf("unknown WpChatroom field %s", name)
  26066. }
  26067. // AddedFields returns all numeric fields that were incremented/decremented during
  26068. // this mutation.
  26069. func (m *WpChatroomMutation) AddedFields() []string {
  26070. var fields []string
  26071. if m.addstatus != nil {
  26072. fields = append(fields, wpchatroom.FieldStatus)
  26073. }
  26074. return fields
  26075. }
  26076. // AddedField returns the numeric value that was incremented/decremented on a field
  26077. // with the given name. The second boolean return value indicates that this field
  26078. // was not set, or was not defined in the schema.
  26079. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  26080. switch name {
  26081. case wpchatroom.FieldStatus:
  26082. return m.AddedStatus()
  26083. }
  26084. return nil, false
  26085. }
  26086. // AddField adds the value to the field with the given name. It returns an error if
  26087. // the field is not defined in the schema, or if the type mismatched the field
  26088. // type.
  26089. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  26090. switch name {
  26091. case wpchatroom.FieldStatus:
  26092. v, ok := value.(int8)
  26093. if !ok {
  26094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26095. }
  26096. m.AddStatus(v)
  26097. return nil
  26098. }
  26099. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  26100. }
  26101. // ClearedFields returns all nullable fields that were cleared during this
  26102. // mutation.
  26103. func (m *WpChatroomMutation) ClearedFields() []string {
  26104. var fields []string
  26105. if m.FieldCleared(wpchatroom.FieldStatus) {
  26106. fields = append(fields, wpchatroom.FieldStatus)
  26107. }
  26108. return fields
  26109. }
  26110. // FieldCleared returns a boolean indicating if a field with the given name was
  26111. // cleared in this mutation.
  26112. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  26113. _, ok := m.clearedFields[name]
  26114. return ok
  26115. }
  26116. // ClearField clears the value of the field with the given name. It returns an
  26117. // error if the field is not defined in the schema.
  26118. func (m *WpChatroomMutation) ClearField(name string) error {
  26119. switch name {
  26120. case wpchatroom.FieldStatus:
  26121. m.ClearStatus()
  26122. return nil
  26123. }
  26124. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  26125. }
  26126. // ResetField resets all changes in the mutation for the field with the given name.
  26127. // It returns an error if the field is not defined in the schema.
  26128. func (m *WpChatroomMutation) ResetField(name string) error {
  26129. switch name {
  26130. case wpchatroom.FieldCreatedAt:
  26131. m.ResetCreatedAt()
  26132. return nil
  26133. case wpchatroom.FieldUpdatedAt:
  26134. m.ResetUpdatedAt()
  26135. return nil
  26136. case wpchatroom.FieldStatus:
  26137. m.ResetStatus()
  26138. return nil
  26139. case wpchatroom.FieldWxWxid:
  26140. m.ResetWxWxid()
  26141. return nil
  26142. case wpchatroom.FieldChatroomID:
  26143. m.ResetChatroomID()
  26144. return nil
  26145. case wpchatroom.FieldNickname:
  26146. m.ResetNickname()
  26147. return nil
  26148. case wpchatroom.FieldOwner:
  26149. m.ResetOwner()
  26150. return nil
  26151. case wpchatroom.FieldAvatar:
  26152. m.ResetAvatar()
  26153. return nil
  26154. case wpchatroom.FieldMemberList:
  26155. m.ResetMemberList()
  26156. return nil
  26157. }
  26158. return fmt.Errorf("unknown WpChatroom field %s", name)
  26159. }
  26160. // AddedEdges returns all edge names that were set/added in this mutation.
  26161. func (m *WpChatroomMutation) AddedEdges() []string {
  26162. edges := make([]string, 0, 0)
  26163. return edges
  26164. }
  26165. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26166. // name in this mutation.
  26167. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  26168. return nil
  26169. }
  26170. // RemovedEdges returns all edge names that were removed in this mutation.
  26171. func (m *WpChatroomMutation) RemovedEdges() []string {
  26172. edges := make([]string, 0, 0)
  26173. return edges
  26174. }
  26175. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26176. // the given name in this mutation.
  26177. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  26178. return nil
  26179. }
  26180. // ClearedEdges returns all edge names that were cleared in this mutation.
  26181. func (m *WpChatroomMutation) ClearedEdges() []string {
  26182. edges := make([]string, 0, 0)
  26183. return edges
  26184. }
  26185. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26186. // was cleared in this mutation.
  26187. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  26188. return false
  26189. }
  26190. // ClearEdge clears the value of the edge with the given name. It returns an error
  26191. // if that edge is not defined in the schema.
  26192. func (m *WpChatroomMutation) ClearEdge(name string) error {
  26193. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  26194. }
  26195. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26196. // It returns an error if the edge is not defined in the schema.
  26197. func (m *WpChatroomMutation) ResetEdge(name string) error {
  26198. return fmt.Errorf("unknown WpChatroom edge %s", name)
  26199. }
  26200. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  26201. type WpChatroomMemberMutation struct {
  26202. config
  26203. op Op
  26204. typ string
  26205. id *uint64
  26206. created_at *time.Time
  26207. updated_at *time.Time
  26208. status *uint8
  26209. addstatus *int8
  26210. wx_wxid *string
  26211. wxid *string
  26212. nickname *string
  26213. avatar *string
  26214. clearedFields map[string]struct{}
  26215. done bool
  26216. oldValue func(context.Context) (*WpChatroomMember, error)
  26217. predicates []predicate.WpChatroomMember
  26218. }
  26219. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  26220. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  26221. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  26222. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  26223. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  26224. m := &WpChatroomMemberMutation{
  26225. config: c,
  26226. op: op,
  26227. typ: TypeWpChatroomMember,
  26228. clearedFields: make(map[string]struct{}),
  26229. }
  26230. for _, opt := range opts {
  26231. opt(m)
  26232. }
  26233. return m
  26234. }
  26235. // withWpChatroomMemberID sets the ID field of the mutation.
  26236. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  26237. return func(m *WpChatroomMemberMutation) {
  26238. var (
  26239. err error
  26240. once sync.Once
  26241. value *WpChatroomMember
  26242. )
  26243. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  26244. once.Do(func() {
  26245. if m.done {
  26246. err = errors.New("querying old values post mutation is not allowed")
  26247. } else {
  26248. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  26249. }
  26250. })
  26251. return value, err
  26252. }
  26253. m.id = &id
  26254. }
  26255. }
  26256. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  26257. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  26258. return func(m *WpChatroomMemberMutation) {
  26259. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  26260. return node, nil
  26261. }
  26262. m.id = &node.ID
  26263. }
  26264. }
  26265. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26266. // executed in a transaction (ent.Tx), a transactional client is returned.
  26267. func (m WpChatroomMemberMutation) Client() *Client {
  26268. client := &Client{config: m.config}
  26269. client.init()
  26270. return client
  26271. }
  26272. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26273. // it returns an error otherwise.
  26274. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  26275. if _, ok := m.driver.(*txDriver); !ok {
  26276. return nil, errors.New("ent: mutation is not running in a transaction")
  26277. }
  26278. tx := &Tx{config: m.config}
  26279. tx.init()
  26280. return tx, nil
  26281. }
  26282. // SetID sets the value of the id field. Note that this
  26283. // operation is only accepted on creation of WpChatroomMember entities.
  26284. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  26285. m.id = &id
  26286. }
  26287. // ID returns the ID value in the mutation. Note that the ID is only available
  26288. // if it was provided to the builder or after it was returned from the database.
  26289. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  26290. if m.id == nil {
  26291. return
  26292. }
  26293. return *m.id, true
  26294. }
  26295. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26296. // That means, if the mutation is applied within a transaction with an isolation level such
  26297. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26298. // or updated by the mutation.
  26299. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  26300. switch {
  26301. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26302. id, exists := m.ID()
  26303. if exists {
  26304. return []uint64{id}, nil
  26305. }
  26306. fallthrough
  26307. case m.op.Is(OpUpdate | OpDelete):
  26308. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  26309. default:
  26310. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26311. }
  26312. }
  26313. // SetCreatedAt sets the "created_at" field.
  26314. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  26315. m.created_at = &t
  26316. }
  26317. // CreatedAt returns the value of the "created_at" field in the mutation.
  26318. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  26319. v := m.created_at
  26320. if v == nil {
  26321. return
  26322. }
  26323. return *v, true
  26324. }
  26325. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  26326. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  26327. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26328. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26329. if !m.op.Is(OpUpdateOne) {
  26330. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26331. }
  26332. if m.id == nil || m.oldValue == nil {
  26333. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26334. }
  26335. oldValue, err := m.oldValue(ctx)
  26336. if err != nil {
  26337. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26338. }
  26339. return oldValue.CreatedAt, nil
  26340. }
  26341. // ResetCreatedAt resets all changes to the "created_at" field.
  26342. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  26343. m.created_at = nil
  26344. }
  26345. // SetUpdatedAt sets the "updated_at" field.
  26346. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  26347. m.updated_at = &t
  26348. }
  26349. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26350. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  26351. v := m.updated_at
  26352. if v == nil {
  26353. return
  26354. }
  26355. return *v, true
  26356. }
  26357. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  26358. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  26359. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26360. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26361. if !m.op.Is(OpUpdateOne) {
  26362. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26363. }
  26364. if m.id == nil || m.oldValue == nil {
  26365. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26366. }
  26367. oldValue, err := m.oldValue(ctx)
  26368. if err != nil {
  26369. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26370. }
  26371. return oldValue.UpdatedAt, nil
  26372. }
  26373. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26374. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  26375. m.updated_at = nil
  26376. }
  26377. // SetStatus sets the "status" field.
  26378. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  26379. m.status = &u
  26380. m.addstatus = nil
  26381. }
  26382. // Status returns the value of the "status" field in the mutation.
  26383. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  26384. v := m.status
  26385. if v == nil {
  26386. return
  26387. }
  26388. return *v, true
  26389. }
  26390. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  26391. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  26392. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26393. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26394. if !m.op.Is(OpUpdateOne) {
  26395. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26396. }
  26397. if m.id == nil || m.oldValue == nil {
  26398. return v, errors.New("OldStatus requires an ID field in the mutation")
  26399. }
  26400. oldValue, err := m.oldValue(ctx)
  26401. if err != nil {
  26402. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26403. }
  26404. return oldValue.Status, nil
  26405. }
  26406. // AddStatus adds u to the "status" field.
  26407. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  26408. if m.addstatus != nil {
  26409. *m.addstatus += u
  26410. } else {
  26411. m.addstatus = &u
  26412. }
  26413. }
  26414. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26415. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  26416. v := m.addstatus
  26417. if v == nil {
  26418. return
  26419. }
  26420. return *v, true
  26421. }
  26422. // ClearStatus clears the value of the "status" field.
  26423. func (m *WpChatroomMemberMutation) ClearStatus() {
  26424. m.status = nil
  26425. m.addstatus = nil
  26426. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  26427. }
  26428. // StatusCleared returns if the "status" field was cleared in this mutation.
  26429. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  26430. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  26431. return ok
  26432. }
  26433. // ResetStatus resets all changes to the "status" field.
  26434. func (m *WpChatroomMemberMutation) ResetStatus() {
  26435. m.status = nil
  26436. m.addstatus = nil
  26437. delete(m.clearedFields, wpchatroommember.FieldStatus)
  26438. }
  26439. // SetWxWxid sets the "wx_wxid" field.
  26440. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  26441. m.wx_wxid = &s
  26442. }
  26443. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  26444. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  26445. v := m.wx_wxid
  26446. if v == nil {
  26447. return
  26448. }
  26449. return *v, true
  26450. }
  26451. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  26452. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  26453. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26454. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  26455. if !m.op.Is(OpUpdateOne) {
  26456. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  26457. }
  26458. if m.id == nil || m.oldValue == nil {
  26459. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  26460. }
  26461. oldValue, err := m.oldValue(ctx)
  26462. if err != nil {
  26463. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  26464. }
  26465. return oldValue.WxWxid, nil
  26466. }
  26467. // ResetWxWxid resets all changes to the "wx_wxid" field.
  26468. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  26469. m.wx_wxid = nil
  26470. }
  26471. // SetWxid sets the "wxid" field.
  26472. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  26473. m.wxid = &s
  26474. }
  26475. // Wxid returns the value of the "wxid" field in the mutation.
  26476. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  26477. v := m.wxid
  26478. if v == nil {
  26479. return
  26480. }
  26481. return *v, true
  26482. }
  26483. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  26484. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  26485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26486. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  26487. if !m.op.Is(OpUpdateOne) {
  26488. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  26489. }
  26490. if m.id == nil || m.oldValue == nil {
  26491. return v, errors.New("OldWxid requires an ID field in the mutation")
  26492. }
  26493. oldValue, err := m.oldValue(ctx)
  26494. if err != nil {
  26495. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  26496. }
  26497. return oldValue.Wxid, nil
  26498. }
  26499. // ResetWxid resets all changes to the "wxid" field.
  26500. func (m *WpChatroomMemberMutation) ResetWxid() {
  26501. m.wxid = nil
  26502. }
  26503. // SetNickname sets the "nickname" field.
  26504. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  26505. m.nickname = &s
  26506. }
  26507. // Nickname returns the value of the "nickname" field in the mutation.
  26508. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  26509. v := m.nickname
  26510. if v == nil {
  26511. return
  26512. }
  26513. return *v, true
  26514. }
  26515. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  26516. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  26517. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26518. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  26519. if !m.op.Is(OpUpdateOne) {
  26520. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  26521. }
  26522. if m.id == nil || m.oldValue == nil {
  26523. return v, errors.New("OldNickname requires an ID field in the mutation")
  26524. }
  26525. oldValue, err := m.oldValue(ctx)
  26526. if err != nil {
  26527. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  26528. }
  26529. return oldValue.Nickname, nil
  26530. }
  26531. // ResetNickname resets all changes to the "nickname" field.
  26532. func (m *WpChatroomMemberMutation) ResetNickname() {
  26533. m.nickname = nil
  26534. }
  26535. // SetAvatar sets the "avatar" field.
  26536. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  26537. m.avatar = &s
  26538. }
  26539. // Avatar returns the value of the "avatar" field in the mutation.
  26540. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  26541. v := m.avatar
  26542. if v == nil {
  26543. return
  26544. }
  26545. return *v, true
  26546. }
  26547. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  26548. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  26549. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26550. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  26551. if !m.op.Is(OpUpdateOne) {
  26552. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  26553. }
  26554. if m.id == nil || m.oldValue == nil {
  26555. return v, errors.New("OldAvatar requires an ID field in the mutation")
  26556. }
  26557. oldValue, err := m.oldValue(ctx)
  26558. if err != nil {
  26559. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  26560. }
  26561. return oldValue.Avatar, nil
  26562. }
  26563. // ResetAvatar resets all changes to the "avatar" field.
  26564. func (m *WpChatroomMemberMutation) ResetAvatar() {
  26565. m.avatar = nil
  26566. }
  26567. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  26568. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  26569. m.predicates = append(m.predicates, ps...)
  26570. }
  26571. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  26572. // users can use type-assertion to append predicates that do not depend on any generated package.
  26573. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  26574. p := make([]predicate.WpChatroomMember, len(ps))
  26575. for i := range ps {
  26576. p[i] = ps[i]
  26577. }
  26578. m.Where(p...)
  26579. }
  26580. // Op returns the operation name.
  26581. func (m *WpChatroomMemberMutation) Op() Op {
  26582. return m.op
  26583. }
  26584. // SetOp allows setting the mutation operation.
  26585. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  26586. m.op = op
  26587. }
  26588. // Type returns the node type of this mutation (WpChatroomMember).
  26589. func (m *WpChatroomMemberMutation) Type() string {
  26590. return m.typ
  26591. }
  26592. // Fields returns all fields that were changed during this mutation. Note that in
  26593. // order to get all numeric fields that were incremented/decremented, call
  26594. // AddedFields().
  26595. func (m *WpChatroomMemberMutation) Fields() []string {
  26596. fields := make([]string, 0, 7)
  26597. if m.created_at != nil {
  26598. fields = append(fields, wpchatroommember.FieldCreatedAt)
  26599. }
  26600. if m.updated_at != nil {
  26601. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  26602. }
  26603. if m.status != nil {
  26604. fields = append(fields, wpchatroommember.FieldStatus)
  26605. }
  26606. if m.wx_wxid != nil {
  26607. fields = append(fields, wpchatroommember.FieldWxWxid)
  26608. }
  26609. if m.wxid != nil {
  26610. fields = append(fields, wpchatroommember.FieldWxid)
  26611. }
  26612. if m.nickname != nil {
  26613. fields = append(fields, wpchatroommember.FieldNickname)
  26614. }
  26615. if m.avatar != nil {
  26616. fields = append(fields, wpchatroommember.FieldAvatar)
  26617. }
  26618. return fields
  26619. }
  26620. // Field returns the value of a field with the given name. The second boolean
  26621. // return value indicates that this field was not set, or was not defined in the
  26622. // schema.
  26623. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  26624. switch name {
  26625. case wpchatroommember.FieldCreatedAt:
  26626. return m.CreatedAt()
  26627. case wpchatroommember.FieldUpdatedAt:
  26628. return m.UpdatedAt()
  26629. case wpchatroommember.FieldStatus:
  26630. return m.Status()
  26631. case wpchatroommember.FieldWxWxid:
  26632. return m.WxWxid()
  26633. case wpchatroommember.FieldWxid:
  26634. return m.Wxid()
  26635. case wpchatroommember.FieldNickname:
  26636. return m.Nickname()
  26637. case wpchatroommember.FieldAvatar:
  26638. return m.Avatar()
  26639. }
  26640. return nil, false
  26641. }
  26642. // OldField returns the old value of the field from the database. An error is
  26643. // returned if the mutation operation is not UpdateOne, or the query to the
  26644. // database failed.
  26645. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26646. switch name {
  26647. case wpchatroommember.FieldCreatedAt:
  26648. return m.OldCreatedAt(ctx)
  26649. case wpchatroommember.FieldUpdatedAt:
  26650. return m.OldUpdatedAt(ctx)
  26651. case wpchatroommember.FieldStatus:
  26652. return m.OldStatus(ctx)
  26653. case wpchatroommember.FieldWxWxid:
  26654. return m.OldWxWxid(ctx)
  26655. case wpchatroommember.FieldWxid:
  26656. return m.OldWxid(ctx)
  26657. case wpchatroommember.FieldNickname:
  26658. return m.OldNickname(ctx)
  26659. case wpchatroommember.FieldAvatar:
  26660. return m.OldAvatar(ctx)
  26661. }
  26662. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  26663. }
  26664. // SetField sets the value of a field with the given name. It returns an error if
  26665. // the field is not defined in the schema, or if the type mismatched the field
  26666. // type.
  26667. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  26668. switch name {
  26669. case wpchatroommember.FieldCreatedAt:
  26670. v, ok := value.(time.Time)
  26671. if !ok {
  26672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26673. }
  26674. m.SetCreatedAt(v)
  26675. return nil
  26676. case wpchatroommember.FieldUpdatedAt:
  26677. v, ok := value.(time.Time)
  26678. if !ok {
  26679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26680. }
  26681. m.SetUpdatedAt(v)
  26682. return nil
  26683. case wpchatroommember.FieldStatus:
  26684. v, ok := value.(uint8)
  26685. if !ok {
  26686. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26687. }
  26688. m.SetStatus(v)
  26689. return nil
  26690. case wpchatroommember.FieldWxWxid:
  26691. v, ok := value.(string)
  26692. if !ok {
  26693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26694. }
  26695. m.SetWxWxid(v)
  26696. return nil
  26697. case wpchatroommember.FieldWxid:
  26698. v, ok := value.(string)
  26699. if !ok {
  26700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26701. }
  26702. m.SetWxid(v)
  26703. return nil
  26704. case wpchatroommember.FieldNickname:
  26705. v, ok := value.(string)
  26706. if !ok {
  26707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26708. }
  26709. m.SetNickname(v)
  26710. return nil
  26711. case wpchatroommember.FieldAvatar:
  26712. v, ok := value.(string)
  26713. if !ok {
  26714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26715. }
  26716. m.SetAvatar(v)
  26717. return nil
  26718. }
  26719. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  26720. }
  26721. // AddedFields returns all numeric fields that were incremented/decremented during
  26722. // this mutation.
  26723. func (m *WpChatroomMemberMutation) AddedFields() []string {
  26724. var fields []string
  26725. if m.addstatus != nil {
  26726. fields = append(fields, wpchatroommember.FieldStatus)
  26727. }
  26728. return fields
  26729. }
  26730. // AddedField returns the numeric value that was incremented/decremented on a field
  26731. // with the given name. The second boolean return value indicates that this field
  26732. // was not set, or was not defined in the schema.
  26733. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  26734. switch name {
  26735. case wpchatroommember.FieldStatus:
  26736. return m.AddedStatus()
  26737. }
  26738. return nil, false
  26739. }
  26740. // AddField adds the value to the field with the given name. It returns an error if
  26741. // the field is not defined in the schema, or if the type mismatched the field
  26742. // type.
  26743. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  26744. switch name {
  26745. case wpchatroommember.FieldStatus:
  26746. v, ok := value.(int8)
  26747. if !ok {
  26748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26749. }
  26750. m.AddStatus(v)
  26751. return nil
  26752. }
  26753. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  26754. }
  26755. // ClearedFields returns all nullable fields that were cleared during this
  26756. // mutation.
  26757. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  26758. var fields []string
  26759. if m.FieldCleared(wpchatroommember.FieldStatus) {
  26760. fields = append(fields, wpchatroommember.FieldStatus)
  26761. }
  26762. return fields
  26763. }
  26764. // FieldCleared returns a boolean indicating if a field with the given name was
  26765. // cleared in this mutation.
  26766. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  26767. _, ok := m.clearedFields[name]
  26768. return ok
  26769. }
  26770. // ClearField clears the value of the field with the given name. It returns an
  26771. // error if the field is not defined in the schema.
  26772. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  26773. switch name {
  26774. case wpchatroommember.FieldStatus:
  26775. m.ClearStatus()
  26776. return nil
  26777. }
  26778. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  26779. }
  26780. // ResetField resets all changes in the mutation for the field with the given name.
  26781. // It returns an error if the field is not defined in the schema.
  26782. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  26783. switch name {
  26784. case wpchatroommember.FieldCreatedAt:
  26785. m.ResetCreatedAt()
  26786. return nil
  26787. case wpchatroommember.FieldUpdatedAt:
  26788. m.ResetUpdatedAt()
  26789. return nil
  26790. case wpchatroommember.FieldStatus:
  26791. m.ResetStatus()
  26792. return nil
  26793. case wpchatroommember.FieldWxWxid:
  26794. m.ResetWxWxid()
  26795. return nil
  26796. case wpchatroommember.FieldWxid:
  26797. m.ResetWxid()
  26798. return nil
  26799. case wpchatroommember.FieldNickname:
  26800. m.ResetNickname()
  26801. return nil
  26802. case wpchatroommember.FieldAvatar:
  26803. m.ResetAvatar()
  26804. return nil
  26805. }
  26806. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  26807. }
  26808. // AddedEdges returns all edge names that were set/added in this mutation.
  26809. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  26810. edges := make([]string, 0, 0)
  26811. return edges
  26812. }
  26813. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26814. // name in this mutation.
  26815. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  26816. return nil
  26817. }
  26818. // RemovedEdges returns all edge names that were removed in this mutation.
  26819. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  26820. edges := make([]string, 0, 0)
  26821. return edges
  26822. }
  26823. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26824. // the given name in this mutation.
  26825. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  26826. return nil
  26827. }
  26828. // ClearedEdges returns all edge names that were cleared in this mutation.
  26829. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  26830. edges := make([]string, 0, 0)
  26831. return edges
  26832. }
  26833. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26834. // was cleared in this mutation.
  26835. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  26836. return false
  26837. }
  26838. // ClearEdge clears the value of the edge with the given name. It returns an error
  26839. // if that edge is not defined in the schema.
  26840. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  26841. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  26842. }
  26843. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26844. // It returns an error if the edge is not defined in the schema.
  26845. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  26846. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  26847. }
  26848. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  26849. type WxMutation struct {
  26850. config
  26851. op Op
  26852. typ string
  26853. id *uint64
  26854. created_at *time.Time
  26855. updated_at *time.Time
  26856. status *uint8
  26857. addstatus *int8
  26858. deleted_at *time.Time
  26859. port *string
  26860. process_id *string
  26861. callback *string
  26862. wxid *string
  26863. account *string
  26864. nickname *string
  26865. tel *string
  26866. head_big *string
  26867. organization_id *uint64
  26868. addorganization_id *int64
  26869. api_base *string
  26870. api_key *string
  26871. allow_list *[]string
  26872. appendallow_list []string
  26873. group_allow_list *[]string
  26874. appendgroup_allow_list []string
  26875. block_list *[]string
  26876. appendblock_list []string
  26877. group_block_list *[]string
  26878. appendgroup_block_list []string
  26879. clearedFields map[string]struct{}
  26880. server *uint64
  26881. clearedserver bool
  26882. agent *uint64
  26883. clearedagent bool
  26884. done bool
  26885. oldValue func(context.Context) (*Wx, error)
  26886. predicates []predicate.Wx
  26887. }
  26888. var _ ent.Mutation = (*WxMutation)(nil)
  26889. // wxOption allows management of the mutation configuration using functional options.
  26890. type wxOption func(*WxMutation)
  26891. // newWxMutation creates new mutation for the Wx entity.
  26892. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  26893. m := &WxMutation{
  26894. config: c,
  26895. op: op,
  26896. typ: TypeWx,
  26897. clearedFields: make(map[string]struct{}),
  26898. }
  26899. for _, opt := range opts {
  26900. opt(m)
  26901. }
  26902. return m
  26903. }
  26904. // withWxID sets the ID field of the mutation.
  26905. func withWxID(id uint64) wxOption {
  26906. return func(m *WxMutation) {
  26907. var (
  26908. err error
  26909. once sync.Once
  26910. value *Wx
  26911. )
  26912. m.oldValue = func(ctx context.Context) (*Wx, error) {
  26913. once.Do(func() {
  26914. if m.done {
  26915. err = errors.New("querying old values post mutation is not allowed")
  26916. } else {
  26917. value, err = m.Client().Wx.Get(ctx, id)
  26918. }
  26919. })
  26920. return value, err
  26921. }
  26922. m.id = &id
  26923. }
  26924. }
  26925. // withWx sets the old Wx of the mutation.
  26926. func withWx(node *Wx) wxOption {
  26927. return func(m *WxMutation) {
  26928. m.oldValue = func(context.Context) (*Wx, error) {
  26929. return node, nil
  26930. }
  26931. m.id = &node.ID
  26932. }
  26933. }
  26934. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26935. // executed in a transaction (ent.Tx), a transactional client is returned.
  26936. func (m WxMutation) Client() *Client {
  26937. client := &Client{config: m.config}
  26938. client.init()
  26939. return client
  26940. }
  26941. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26942. // it returns an error otherwise.
  26943. func (m WxMutation) Tx() (*Tx, error) {
  26944. if _, ok := m.driver.(*txDriver); !ok {
  26945. return nil, errors.New("ent: mutation is not running in a transaction")
  26946. }
  26947. tx := &Tx{config: m.config}
  26948. tx.init()
  26949. return tx, nil
  26950. }
  26951. // SetID sets the value of the id field. Note that this
  26952. // operation is only accepted on creation of Wx entities.
  26953. func (m *WxMutation) SetID(id uint64) {
  26954. m.id = &id
  26955. }
  26956. // ID returns the ID value in the mutation. Note that the ID is only available
  26957. // if it was provided to the builder or after it was returned from the database.
  26958. func (m *WxMutation) ID() (id uint64, exists bool) {
  26959. if m.id == nil {
  26960. return
  26961. }
  26962. return *m.id, true
  26963. }
  26964. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26965. // That means, if the mutation is applied within a transaction with an isolation level such
  26966. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26967. // or updated by the mutation.
  26968. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  26969. switch {
  26970. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26971. id, exists := m.ID()
  26972. if exists {
  26973. return []uint64{id}, nil
  26974. }
  26975. fallthrough
  26976. case m.op.Is(OpUpdate | OpDelete):
  26977. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  26978. default:
  26979. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26980. }
  26981. }
  26982. // SetCreatedAt sets the "created_at" field.
  26983. func (m *WxMutation) SetCreatedAt(t time.Time) {
  26984. m.created_at = &t
  26985. }
  26986. // CreatedAt returns the value of the "created_at" field in the mutation.
  26987. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  26988. v := m.created_at
  26989. if v == nil {
  26990. return
  26991. }
  26992. return *v, true
  26993. }
  26994. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  26995. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  26996. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26997. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26998. if !m.op.Is(OpUpdateOne) {
  26999. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27000. }
  27001. if m.id == nil || m.oldValue == nil {
  27002. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27003. }
  27004. oldValue, err := m.oldValue(ctx)
  27005. if err != nil {
  27006. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27007. }
  27008. return oldValue.CreatedAt, nil
  27009. }
  27010. // ResetCreatedAt resets all changes to the "created_at" field.
  27011. func (m *WxMutation) ResetCreatedAt() {
  27012. m.created_at = nil
  27013. }
  27014. // SetUpdatedAt sets the "updated_at" field.
  27015. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  27016. m.updated_at = &t
  27017. }
  27018. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27019. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  27020. v := m.updated_at
  27021. if v == nil {
  27022. return
  27023. }
  27024. return *v, true
  27025. }
  27026. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  27027. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  27028. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27029. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27030. if !m.op.Is(OpUpdateOne) {
  27031. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27032. }
  27033. if m.id == nil || m.oldValue == nil {
  27034. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27035. }
  27036. oldValue, err := m.oldValue(ctx)
  27037. if err != nil {
  27038. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27039. }
  27040. return oldValue.UpdatedAt, nil
  27041. }
  27042. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27043. func (m *WxMutation) ResetUpdatedAt() {
  27044. m.updated_at = nil
  27045. }
  27046. // SetStatus sets the "status" field.
  27047. func (m *WxMutation) SetStatus(u uint8) {
  27048. m.status = &u
  27049. m.addstatus = nil
  27050. }
  27051. // Status returns the value of the "status" field in the mutation.
  27052. func (m *WxMutation) Status() (r uint8, exists bool) {
  27053. v := m.status
  27054. if v == nil {
  27055. return
  27056. }
  27057. return *v, true
  27058. }
  27059. // OldStatus returns the old "status" field's value of the Wx entity.
  27060. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  27061. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27062. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  27063. if !m.op.Is(OpUpdateOne) {
  27064. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  27065. }
  27066. if m.id == nil || m.oldValue == nil {
  27067. return v, errors.New("OldStatus requires an ID field in the mutation")
  27068. }
  27069. oldValue, err := m.oldValue(ctx)
  27070. if err != nil {
  27071. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  27072. }
  27073. return oldValue.Status, nil
  27074. }
  27075. // AddStatus adds u to the "status" field.
  27076. func (m *WxMutation) AddStatus(u int8) {
  27077. if m.addstatus != nil {
  27078. *m.addstatus += u
  27079. } else {
  27080. m.addstatus = &u
  27081. }
  27082. }
  27083. // AddedStatus returns the value that was added to the "status" field in this mutation.
  27084. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  27085. v := m.addstatus
  27086. if v == nil {
  27087. return
  27088. }
  27089. return *v, true
  27090. }
  27091. // ClearStatus clears the value of the "status" field.
  27092. func (m *WxMutation) ClearStatus() {
  27093. m.status = nil
  27094. m.addstatus = nil
  27095. m.clearedFields[wx.FieldStatus] = struct{}{}
  27096. }
  27097. // StatusCleared returns if the "status" field was cleared in this mutation.
  27098. func (m *WxMutation) StatusCleared() bool {
  27099. _, ok := m.clearedFields[wx.FieldStatus]
  27100. return ok
  27101. }
  27102. // ResetStatus resets all changes to the "status" field.
  27103. func (m *WxMutation) ResetStatus() {
  27104. m.status = nil
  27105. m.addstatus = nil
  27106. delete(m.clearedFields, wx.FieldStatus)
  27107. }
  27108. // SetDeletedAt sets the "deleted_at" field.
  27109. func (m *WxMutation) SetDeletedAt(t time.Time) {
  27110. m.deleted_at = &t
  27111. }
  27112. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  27113. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  27114. v := m.deleted_at
  27115. if v == nil {
  27116. return
  27117. }
  27118. return *v, true
  27119. }
  27120. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  27121. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  27122. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27123. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  27124. if !m.op.Is(OpUpdateOne) {
  27125. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  27126. }
  27127. if m.id == nil || m.oldValue == nil {
  27128. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  27129. }
  27130. oldValue, err := m.oldValue(ctx)
  27131. if err != nil {
  27132. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  27133. }
  27134. return oldValue.DeletedAt, nil
  27135. }
  27136. // ClearDeletedAt clears the value of the "deleted_at" field.
  27137. func (m *WxMutation) ClearDeletedAt() {
  27138. m.deleted_at = nil
  27139. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  27140. }
  27141. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  27142. func (m *WxMutation) DeletedAtCleared() bool {
  27143. _, ok := m.clearedFields[wx.FieldDeletedAt]
  27144. return ok
  27145. }
  27146. // ResetDeletedAt resets all changes to the "deleted_at" field.
  27147. func (m *WxMutation) ResetDeletedAt() {
  27148. m.deleted_at = nil
  27149. delete(m.clearedFields, wx.FieldDeletedAt)
  27150. }
  27151. // SetServerID sets the "server_id" field.
  27152. func (m *WxMutation) SetServerID(u uint64) {
  27153. m.server = &u
  27154. }
  27155. // ServerID returns the value of the "server_id" field in the mutation.
  27156. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  27157. v := m.server
  27158. if v == nil {
  27159. return
  27160. }
  27161. return *v, true
  27162. }
  27163. // OldServerID returns the old "server_id" field's value of the Wx entity.
  27164. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  27165. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27166. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  27167. if !m.op.Is(OpUpdateOne) {
  27168. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  27169. }
  27170. if m.id == nil || m.oldValue == nil {
  27171. return v, errors.New("OldServerID requires an ID field in the mutation")
  27172. }
  27173. oldValue, err := m.oldValue(ctx)
  27174. if err != nil {
  27175. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  27176. }
  27177. return oldValue.ServerID, nil
  27178. }
  27179. // ClearServerID clears the value of the "server_id" field.
  27180. func (m *WxMutation) ClearServerID() {
  27181. m.server = nil
  27182. m.clearedFields[wx.FieldServerID] = struct{}{}
  27183. }
  27184. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  27185. func (m *WxMutation) ServerIDCleared() bool {
  27186. _, ok := m.clearedFields[wx.FieldServerID]
  27187. return ok
  27188. }
  27189. // ResetServerID resets all changes to the "server_id" field.
  27190. func (m *WxMutation) ResetServerID() {
  27191. m.server = nil
  27192. delete(m.clearedFields, wx.FieldServerID)
  27193. }
  27194. // SetPort sets the "port" field.
  27195. func (m *WxMutation) SetPort(s string) {
  27196. m.port = &s
  27197. }
  27198. // Port returns the value of the "port" field in the mutation.
  27199. func (m *WxMutation) Port() (r string, exists bool) {
  27200. v := m.port
  27201. if v == nil {
  27202. return
  27203. }
  27204. return *v, true
  27205. }
  27206. // OldPort returns the old "port" field's value of the Wx entity.
  27207. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  27208. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27209. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  27210. if !m.op.Is(OpUpdateOne) {
  27211. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  27212. }
  27213. if m.id == nil || m.oldValue == nil {
  27214. return v, errors.New("OldPort requires an ID field in the mutation")
  27215. }
  27216. oldValue, err := m.oldValue(ctx)
  27217. if err != nil {
  27218. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  27219. }
  27220. return oldValue.Port, nil
  27221. }
  27222. // ResetPort resets all changes to the "port" field.
  27223. func (m *WxMutation) ResetPort() {
  27224. m.port = nil
  27225. }
  27226. // SetProcessID sets the "process_id" field.
  27227. func (m *WxMutation) SetProcessID(s string) {
  27228. m.process_id = &s
  27229. }
  27230. // ProcessID returns the value of the "process_id" field in the mutation.
  27231. func (m *WxMutation) ProcessID() (r string, exists bool) {
  27232. v := m.process_id
  27233. if v == nil {
  27234. return
  27235. }
  27236. return *v, true
  27237. }
  27238. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  27239. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  27240. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27241. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  27242. if !m.op.Is(OpUpdateOne) {
  27243. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  27244. }
  27245. if m.id == nil || m.oldValue == nil {
  27246. return v, errors.New("OldProcessID requires an ID field in the mutation")
  27247. }
  27248. oldValue, err := m.oldValue(ctx)
  27249. if err != nil {
  27250. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  27251. }
  27252. return oldValue.ProcessID, nil
  27253. }
  27254. // ResetProcessID resets all changes to the "process_id" field.
  27255. func (m *WxMutation) ResetProcessID() {
  27256. m.process_id = nil
  27257. }
  27258. // SetCallback sets the "callback" field.
  27259. func (m *WxMutation) SetCallback(s string) {
  27260. m.callback = &s
  27261. }
  27262. // Callback returns the value of the "callback" field in the mutation.
  27263. func (m *WxMutation) Callback() (r string, exists bool) {
  27264. v := m.callback
  27265. if v == nil {
  27266. return
  27267. }
  27268. return *v, true
  27269. }
  27270. // OldCallback returns the old "callback" field's value of the Wx entity.
  27271. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  27272. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27273. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  27274. if !m.op.Is(OpUpdateOne) {
  27275. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  27276. }
  27277. if m.id == nil || m.oldValue == nil {
  27278. return v, errors.New("OldCallback requires an ID field in the mutation")
  27279. }
  27280. oldValue, err := m.oldValue(ctx)
  27281. if err != nil {
  27282. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  27283. }
  27284. return oldValue.Callback, nil
  27285. }
  27286. // ResetCallback resets all changes to the "callback" field.
  27287. func (m *WxMutation) ResetCallback() {
  27288. m.callback = nil
  27289. }
  27290. // SetWxid sets the "wxid" field.
  27291. func (m *WxMutation) SetWxid(s string) {
  27292. m.wxid = &s
  27293. }
  27294. // Wxid returns the value of the "wxid" field in the mutation.
  27295. func (m *WxMutation) Wxid() (r string, exists bool) {
  27296. v := m.wxid
  27297. if v == nil {
  27298. return
  27299. }
  27300. return *v, true
  27301. }
  27302. // OldWxid returns the old "wxid" field's value of the Wx entity.
  27303. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  27304. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27305. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  27306. if !m.op.Is(OpUpdateOne) {
  27307. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  27308. }
  27309. if m.id == nil || m.oldValue == nil {
  27310. return v, errors.New("OldWxid requires an ID field in the mutation")
  27311. }
  27312. oldValue, err := m.oldValue(ctx)
  27313. if err != nil {
  27314. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  27315. }
  27316. return oldValue.Wxid, nil
  27317. }
  27318. // ResetWxid resets all changes to the "wxid" field.
  27319. func (m *WxMutation) ResetWxid() {
  27320. m.wxid = nil
  27321. }
  27322. // SetAccount sets the "account" field.
  27323. func (m *WxMutation) SetAccount(s string) {
  27324. m.account = &s
  27325. }
  27326. // Account returns the value of the "account" field in the mutation.
  27327. func (m *WxMutation) Account() (r string, exists bool) {
  27328. v := m.account
  27329. if v == nil {
  27330. return
  27331. }
  27332. return *v, true
  27333. }
  27334. // OldAccount returns the old "account" field's value of the Wx entity.
  27335. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  27336. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27337. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  27338. if !m.op.Is(OpUpdateOne) {
  27339. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  27340. }
  27341. if m.id == nil || m.oldValue == nil {
  27342. return v, errors.New("OldAccount requires an ID field in the mutation")
  27343. }
  27344. oldValue, err := m.oldValue(ctx)
  27345. if err != nil {
  27346. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  27347. }
  27348. return oldValue.Account, nil
  27349. }
  27350. // ResetAccount resets all changes to the "account" field.
  27351. func (m *WxMutation) ResetAccount() {
  27352. m.account = nil
  27353. }
  27354. // SetNickname sets the "nickname" field.
  27355. func (m *WxMutation) SetNickname(s string) {
  27356. m.nickname = &s
  27357. }
  27358. // Nickname returns the value of the "nickname" field in the mutation.
  27359. func (m *WxMutation) Nickname() (r string, exists bool) {
  27360. v := m.nickname
  27361. if v == nil {
  27362. return
  27363. }
  27364. return *v, true
  27365. }
  27366. // OldNickname returns the old "nickname" field's value of the Wx entity.
  27367. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  27368. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27369. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  27370. if !m.op.Is(OpUpdateOne) {
  27371. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  27372. }
  27373. if m.id == nil || m.oldValue == nil {
  27374. return v, errors.New("OldNickname requires an ID field in the mutation")
  27375. }
  27376. oldValue, err := m.oldValue(ctx)
  27377. if err != nil {
  27378. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  27379. }
  27380. return oldValue.Nickname, nil
  27381. }
  27382. // ResetNickname resets all changes to the "nickname" field.
  27383. func (m *WxMutation) ResetNickname() {
  27384. m.nickname = nil
  27385. }
  27386. // SetTel sets the "tel" field.
  27387. func (m *WxMutation) SetTel(s string) {
  27388. m.tel = &s
  27389. }
  27390. // Tel returns the value of the "tel" field in the mutation.
  27391. func (m *WxMutation) Tel() (r string, exists bool) {
  27392. v := m.tel
  27393. if v == nil {
  27394. return
  27395. }
  27396. return *v, true
  27397. }
  27398. // OldTel returns the old "tel" field's value of the Wx entity.
  27399. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  27400. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27401. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  27402. if !m.op.Is(OpUpdateOne) {
  27403. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  27404. }
  27405. if m.id == nil || m.oldValue == nil {
  27406. return v, errors.New("OldTel requires an ID field in the mutation")
  27407. }
  27408. oldValue, err := m.oldValue(ctx)
  27409. if err != nil {
  27410. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  27411. }
  27412. return oldValue.Tel, nil
  27413. }
  27414. // ResetTel resets all changes to the "tel" field.
  27415. func (m *WxMutation) ResetTel() {
  27416. m.tel = nil
  27417. }
  27418. // SetHeadBig sets the "head_big" field.
  27419. func (m *WxMutation) SetHeadBig(s string) {
  27420. m.head_big = &s
  27421. }
  27422. // HeadBig returns the value of the "head_big" field in the mutation.
  27423. func (m *WxMutation) HeadBig() (r string, exists bool) {
  27424. v := m.head_big
  27425. if v == nil {
  27426. return
  27427. }
  27428. return *v, true
  27429. }
  27430. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  27431. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  27432. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27433. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  27434. if !m.op.Is(OpUpdateOne) {
  27435. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  27436. }
  27437. if m.id == nil || m.oldValue == nil {
  27438. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  27439. }
  27440. oldValue, err := m.oldValue(ctx)
  27441. if err != nil {
  27442. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  27443. }
  27444. return oldValue.HeadBig, nil
  27445. }
  27446. // ResetHeadBig resets all changes to the "head_big" field.
  27447. func (m *WxMutation) ResetHeadBig() {
  27448. m.head_big = nil
  27449. }
  27450. // SetOrganizationID sets the "organization_id" field.
  27451. func (m *WxMutation) SetOrganizationID(u uint64) {
  27452. m.organization_id = &u
  27453. m.addorganization_id = nil
  27454. }
  27455. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27456. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  27457. v := m.organization_id
  27458. if v == nil {
  27459. return
  27460. }
  27461. return *v, true
  27462. }
  27463. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  27464. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  27465. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27466. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27467. if !m.op.Is(OpUpdateOne) {
  27468. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27469. }
  27470. if m.id == nil || m.oldValue == nil {
  27471. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27472. }
  27473. oldValue, err := m.oldValue(ctx)
  27474. if err != nil {
  27475. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27476. }
  27477. return oldValue.OrganizationID, nil
  27478. }
  27479. // AddOrganizationID adds u to the "organization_id" field.
  27480. func (m *WxMutation) AddOrganizationID(u int64) {
  27481. if m.addorganization_id != nil {
  27482. *m.addorganization_id += u
  27483. } else {
  27484. m.addorganization_id = &u
  27485. }
  27486. }
  27487. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27488. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  27489. v := m.addorganization_id
  27490. if v == nil {
  27491. return
  27492. }
  27493. return *v, true
  27494. }
  27495. // ClearOrganizationID clears the value of the "organization_id" field.
  27496. func (m *WxMutation) ClearOrganizationID() {
  27497. m.organization_id = nil
  27498. m.addorganization_id = nil
  27499. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  27500. }
  27501. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  27502. func (m *WxMutation) OrganizationIDCleared() bool {
  27503. _, ok := m.clearedFields[wx.FieldOrganizationID]
  27504. return ok
  27505. }
  27506. // ResetOrganizationID resets all changes to the "organization_id" field.
  27507. func (m *WxMutation) ResetOrganizationID() {
  27508. m.organization_id = nil
  27509. m.addorganization_id = nil
  27510. delete(m.clearedFields, wx.FieldOrganizationID)
  27511. }
  27512. // SetAgentID sets the "agent_id" field.
  27513. func (m *WxMutation) SetAgentID(u uint64) {
  27514. m.agent = &u
  27515. }
  27516. // AgentID returns the value of the "agent_id" field in the mutation.
  27517. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  27518. v := m.agent
  27519. if v == nil {
  27520. return
  27521. }
  27522. return *v, true
  27523. }
  27524. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  27525. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  27526. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27527. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  27528. if !m.op.Is(OpUpdateOne) {
  27529. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  27530. }
  27531. if m.id == nil || m.oldValue == nil {
  27532. return v, errors.New("OldAgentID requires an ID field in the mutation")
  27533. }
  27534. oldValue, err := m.oldValue(ctx)
  27535. if err != nil {
  27536. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  27537. }
  27538. return oldValue.AgentID, nil
  27539. }
  27540. // ResetAgentID resets all changes to the "agent_id" field.
  27541. func (m *WxMutation) ResetAgentID() {
  27542. m.agent = nil
  27543. }
  27544. // SetAPIBase sets the "api_base" field.
  27545. func (m *WxMutation) SetAPIBase(s string) {
  27546. m.api_base = &s
  27547. }
  27548. // APIBase returns the value of the "api_base" field in the mutation.
  27549. func (m *WxMutation) APIBase() (r string, exists bool) {
  27550. v := m.api_base
  27551. if v == nil {
  27552. return
  27553. }
  27554. return *v, true
  27555. }
  27556. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  27557. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  27558. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27559. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  27560. if !m.op.Is(OpUpdateOne) {
  27561. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  27562. }
  27563. if m.id == nil || m.oldValue == nil {
  27564. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  27565. }
  27566. oldValue, err := m.oldValue(ctx)
  27567. if err != nil {
  27568. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  27569. }
  27570. return oldValue.APIBase, nil
  27571. }
  27572. // ClearAPIBase clears the value of the "api_base" field.
  27573. func (m *WxMutation) ClearAPIBase() {
  27574. m.api_base = nil
  27575. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  27576. }
  27577. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  27578. func (m *WxMutation) APIBaseCleared() bool {
  27579. _, ok := m.clearedFields[wx.FieldAPIBase]
  27580. return ok
  27581. }
  27582. // ResetAPIBase resets all changes to the "api_base" field.
  27583. func (m *WxMutation) ResetAPIBase() {
  27584. m.api_base = nil
  27585. delete(m.clearedFields, wx.FieldAPIBase)
  27586. }
  27587. // SetAPIKey sets the "api_key" field.
  27588. func (m *WxMutation) SetAPIKey(s string) {
  27589. m.api_key = &s
  27590. }
  27591. // APIKey returns the value of the "api_key" field in the mutation.
  27592. func (m *WxMutation) APIKey() (r string, exists bool) {
  27593. v := m.api_key
  27594. if v == nil {
  27595. return
  27596. }
  27597. return *v, true
  27598. }
  27599. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  27600. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  27601. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27602. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  27603. if !m.op.Is(OpUpdateOne) {
  27604. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  27605. }
  27606. if m.id == nil || m.oldValue == nil {
  27607. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  27608. }
  27609. oldValue, err := m.oldValue(ctx)
  27610. if err != nil {
  27611. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  27612. }
  27613. return oldValue.APIKey, nil
  27614. }
  27615. // ClearAPIKey clears the value of the "api_key" field.
  27616. func (m *WxMutation) ClearAPIKey() {
  27617. m.api_key = nil
  27618. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  27619. }
  27620. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  27621. func (m *WxMutation) APIKeyCleared() bool {
  27622. _, ok := m.clearedFields[wx.FieldAPIKey]
  27623. return ok
  27624. }
  27625. // ResetAPIKey resets all changes to the "api_key" field.
  27626. func (m *WxMutation) ResetAPIKey() {
  27627. m.api_key = nil
  27628. delete(m.clearedFields, wx.FieldAPIKey)
  27629. }
  27630. // SetAllowList sets the "allow_list" field.
  27631. func (m *WxMutation) SetAllowList(s []string) {
  27632. m.allow_list = &s
  27633. m.appendallow_list = nil
  27634. }
  27635. // AllowList returns the value of the "allow_list" field in the mutation.
  27636. func (m *WxMutation) AllowList() (r []string, exists bool) {
  27637. v := m.allow_list
  27638. if v == nil {
  27639. return
  27640. }
  27641. return *v, true
  27642. }
  27643. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  27644. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  27645. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27646. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  27647. if !m.op.Is(OpUpdateOne) {
  27648. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  27649. }
  27650. if m.id == nil || m.oldValue == nil {
  27651. return v, errors.New("OldAllowList requires an ID field in the mutation")
  27652. }
  27653. oldValue, err := m.oldValue(ctx)
  27654. if err != nil {
  27655. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  27656. }
  27657. return oldValue.AllowList, nil
  27658. }
  27659. // AppendAllowList adds s to the "allow_list" field.
  27660. func (m *WxMutation) AppendAllowList(s []string) {
  27661. m.appendallow_list = append(m.appendallow_list, s...)
  27662. }
  27663. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  27664. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  27665. if len(m.appendallow_list) == 0 {
  27666. return nil, false
  27667. }
  27668. return m.appendallow_list, true
  27669. }
  27670. // ResetAllowList resets all changes to the "allow_list" field.
  27671. func (m *WxMutation) ResetAllowList() {
  27672. m.allow_list = nil
  27673. m.appendallow_list = nil
  27674. }
  27675. // SetGroupAllowList sets the "group_allow_list" field.
  27676. func (m *WxMutation) SetGroupAllowList(s []string) {
  27677. m.group_allow_list = &s
  27678. m.appendgroup_allow_list = nil
  27679. }
  27680. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  27681. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  27682. v := m.group_allow_list
  27683. if v == nil {
  27684. return
  27685. }
  27686. return *v, true
  27687. }
  27688. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  27689. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  27690. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27691. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  27692. if !m.op.Is(OpUpdateOne) {
  27693. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  27694. }
  27695. if m.id == nil || m.oldValue == nil {
  27696. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  27697. }
  27698. oldValue, err := m.oldValue(ctx)
  27699. if err != nil {
  27700. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  27701. }
  27702. return oldValue.GroupAllowList, nil
  27703. }
  27704. // AppendGroupAllowList adds s to the "group_allow_list" field.
  27705. func (m *WxMutation) AppendGroupAllowList(s []string) {
  27706. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  27707. }
  27708. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  27709. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  27710. if len(m.appendgroup_allow_list) == 0 {
  27711. return nil, false
  27712. }
  27713. return m.appendgroup_allow_list, true
  27714. }
  27715. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  27716. func (m *WxMutation) ResetGroupAllowList() {
  27717. m.group_allow_list = nil
  27718. m.appendgroup_allow_list = nil
  27719. }
  27720. // SetBlockList sets the "block_list" field.
  27721. func (m *WxMutation) SetBlockList(s []string) {
  27722. m.block_list = &s
  27723. m.appendblock_list = nil
  27724. }
  27725. // BlockList returns the value of the "block_list" field in the mutation.
  27726. func (m *WxMutation) BlockList() (r []string, exists bool) {
  27727. v := m.block_list
  27728. if v == nil {
  27729. return
  27730. }
  27731. return *v, true
  27732. }
  27733. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  27734. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  27735. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27736. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  27737. if !m.op.Is(OpUpdateOne) {
  27738. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  27739. }
  27740. if m.id == nil || m.oldValue == nil {
  27741. return v, errors.New("OldBlockList requires an ID field in the mutation")
  27742. }
  27743. oldValue, err := m.oldValue(ctx)
  27744. if err != nil {
  27745. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  27746. }
  27747. return oldValue.BlockList, nil
  27748. }
  27749. // AppendBlockList adds s to the "block_list" field.
  27750. func (m *WxMutation) AppendBlockList(s []string) {
  27751. m.appendblock_list = append(m.appendblock_list, s...)
  27752. }
  27753. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  27754. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  27755. if len(m.appendblock_list) == 0 {
  27756. return nil, false
  27757. }
  27758. return m.appendblock_list, true
  27759. }
  27760. // ResetBlockList resets all changes to the "block_list" field.
  27761. func (m *WxMutation) ResetBlockList() {
  27762. m.block_list = nil
  27763. m.appendblock_list = nil
  27764. }
  27765. // SetGroupBlockList sets the "group_block_list" field.
  27766. func (m *WxMutation) SetGroupBlockList(s []string) {
  27767. m.group_block_list = &s
  27768. m.appendgroup_block_list = nil
  27769. }
  27770. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  27771. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  27772. v := m.group_block_list
  27773. if v == nil {
  27774. return
  27775. }
  27776. return *v, true
  27777. }
  27778. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  27779. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  27780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27781. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  27782. if !m.op.Is(OpUpdateOne) {
  27783. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  27784. }
  27785. if m.id == nil || m.oldValue == nil {
  27786. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  27787. }
  27788. oldValue, err := m.oldValue(ctx)
  27789. if err != nil {
  27790. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  27791. }
  27792. return oldValue.GroupBlockList, nil
  27793. }
  27794. // AppendGroupBlockList adds s to the "group_block_list" field.
  27795. func (m *WxMutation) AppendGroupBlockList(s []string) {
  27796. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  27797. }
  27798. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  27799. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  27800. if len(m.appendgroup_block_list) == 0 {
  27801. return nil, false
  27802. }
  27803. return m.appendgroup_block_list, true
  27804. }
  27805. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  27806. func (m *WxMutation) ResetGroupBlockList() {
  27807. m.group_block_list = nil
  27808. m.appendgroup_block_list = nil
  27809. }
  27810. // ClearServer clears the "server" edge to the Server entity.
  27811. func (m *WxMutation) ClearServer() {
  27812. m.clearedserver = true
  27813. m.clearedFields[wx.FieldServerID] = struct{}{}
  27814. }
  27815. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  27816. func (m *WxMutation) ServerCleared() bool {
  27817. return m.ServerIDCleared() || m.clearedserver
  27818. }
  27819. // ServerIDs returns the "server" edge IDs in the mutation.
  27820. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  27821. // ServerID instead. It exists only for internal usage by the builders.
  27822. func (m *WxMutation) ServerIDs() (ids []uint64) {
  27823. if id := m.server; id != nil {
  27824. ids = append(ids, *id)
  27825. }
  27826. return
  27827. }
  27828. // ResetServer resets all changes to the "server" edge.
  27829. func (m *WxMutation) ResetServer() {
  27830. m.server = nil
  27831. m.clearedserver = false
  27832. }
  27833. // ClearAgent clears the "agent" edge to the Agent entity.
  27834. func (m *WxMutation) ClearAgent() {
  27835. m.clearedagent = true
  27836. m.clearedFields[wx.FieldAgentID] = struct{}{}
  27837. }
  27838. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  27839. func (m *WxMutation) AgentCleared() bool {
  27840. return m.clearedagent
  27841. }
  27842. // AgentIDs returns the "agent" edge IDs in the mutation.
  27843. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  27844. // AgentID instead. It exists only for internal usage by the builders.
  27845. func (m *WxMutation) AgentIDs() (ids []uint64) {
  27846. if id := m.agent; id != nil {
  27847. ids = append(ids, *id)
  27848. }
  27849. return
  27850. }
  27851. // ResetAgent resets all changes to the "agent" edge.
  27852. func (m *WxMutation) ResetAgent() {
  27853. m.agent = nil
  27854. m.clearedagent = false
  27855. }
  27856. // Where appends a list predicates to the WxMutation builder.
  27857. func (m *WxMutation) Where(ps ...predicate.Wx) {
  27858. m.predicates = append(m.predicates, ps...)
  27859. }
  27860. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  27861. // users can use type-assertion to append predicates that do not depend on any generated package.
  27862. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  27863. p := make([]predicate.Wx, len(ps))
  27864. for i := range ps {
  27865. p[i] = ps[i]
  27866. }
  27867. m.Where(p...)
  27868. }
  27869. // Op returns the operation name.
  27870. func (m *WxMutation) Op() Op {
  27871. return m.op
  27872. }
  27873. // SetOp allows setting the mutation operation.
  27874. func (m *WxMutation) SetOp(op Op) {
  27875. m.op = op
  27876. }
  27877. // Type returns the node type of this mutation (Wx).
  27878. func (m *WxMutation) Type() string {
  27879. return m.typ
  27880. }
  27881. // Fields returns all fields that were changed during this mutation. Note that in
  27882. // order to get all numeric fields that were incremented/decremented, call
  27883. // AddedFields().
  27884. func (m *WxMutation) Fields() []string {
  27885. fields := make([]string, 0, 21)
  27886. if m.created_at != nil {
  27887. fields = append(fields, wx.FieldCreatedAt)
  27888. }
  27889. if m.updated_at != nil {
  27890. fields = append(fields, wx.FieldUpdatedAt)
  27891. }
  27892. if m.status != nil {
  27893. fields = append(fields, wx.FieldStatus)
  27894. }
  27895. if m.deleted_at != nil {
  27896. fields = append(fields, wx.FieldDeletedAt)
  27897. }
  27898. if m.server != nil {
  27899. fields = append(fields, wx.FieldServerID)
  27900. }
  27901. if m.port != nil {
  27902. fields = append(fields, wx.FieldPort)
  27903. }
  27904. if m.process_id != nil {
  27905. fields = append(fields, wx.FieldProcessID)
  27906. }
  27907. if m.callback != nil {
  27908. fields = append(fields, wx.FieldCallback)
  27909. }
  27910. if m.wxid != nil {
  27911. fields = append(fields, wx.FieldWxid)
  27912. }
  27913. if m.account != nil {
  27914. fields = append(fields, wx.FieldAccount)
  27915. }
  27916. if m.nickname != nil {
  27917. fields = append(fields, wx.FieldNickname)
  27918. }
  27919. if m.tel != nil {
  27920. fields = append(fields, wx.FieldTel)
  27921. }
  27922. if m.head_big != nil {
  27923. fields = append(fields, wx.FieldHeadBig)
  27924. }
  27925. if m.organization_id != nil {
  27926. fields = append(fields, wx.FieldOrganizationID)
  27927. }
  27928. if m.agent != nil {
  27929. fields = append(fields, wx.FieldAgentID)
  27930. }
  27931. if m.api_base != nil {
  27932. fields = append(fields, wx.FieldAPIBase)
  27933. }
  27934. if m.api_key != nil {
  27935. fields = append(fields, wx.FieldAPIKey)
  27936. }
  27937. if m.allow_list != nil {
  27938. fields = append(fields, wx.FieldAllowList)
  27939. }
  27940. if m.group_allow_list != nil {
  27941. fields = append(fields, wx.FieldGroupAllowList)
  27942. }
  27943. if m.block_list != nil {
  27944. fields = append(fields, wx.FieldBlockList)
  27945. }
  27946. if m.group_block_list != nil {
  27947. fields = append(fields, wx.FieldGroupBlockList)
  27948. }
  27949. return fields
  27950. }
  27951. // Field returns the value of a field with the given name. The second boolean
  27952. // return value indicates that this field was not set, or was not defined in the
  27953. // schema.
  27954. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  27955. switch name {
  27956. case wx.FieldCreatedAt:
  27957. return m.CreatedAt()
  27958. case wx.FieldUpdatedAt:
  27959. return m.UpdatedAt()
  27960. case wx.FieldStatus:
  27961. return m.Status()
  27962. case wx.FieldDeletedAt:
  27963. return m.DeletedAt()
  27964. case wx.FieldServerID:
  27965. return m.ServerID()
  27966. case wx.FieldPort:
  27967. return m.Port()
  27968. case wx.FieldProcessID:
  27969. return m.ProcessID()
  27970. case wx.FieldCallback:
  27971. return m.Callback()
  27972. case wx.FieldWxid:
  27973. return m.Wxid()
  27974. case wx.FieldAccount:
  27975. return m.Account()
  27976. case wx.FieldNickname:
  27977. return m.Nickname()
  27978. case wx.FieldTel:
  27979. return m.Tel()
  27980. case wx.FieldHeadBig:
  27981. return m.HeadBig()
  27982. case wx.FieldOrganizationID:
  27983. return m.OrganizationID()
  27984. case wx.FieldAgentID:
  27985. return m.AgentID()
  27986. case wx.FieldAPIBase:
  27987. return m.APIBase()
  27988. case wx.FieldAPIKey:
  27989. return m.APIKey()
  27990. case wx.FieldAllowList:
  27991. return m.AllowList()
  27992. case wx.FieldGroupAllowList:
  27993. return m.GroupAllowList()
  27994. case wx.FieldBlockList:
  27995. return m.BlockList()
  27996. case wx.FieldGroupBlockList:
  27997. return m.GroupBlockList()
  27998. }
  27999. return nil, false
  28000. }
  28001. // OldField returns the old value of the field from the database. An error is
  28002. // returned if the mutation operation is not UpdateOne, or the query to the
  28003. // database failed.
  28004. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28005. switch name {
  28006. case wx.FieldCreatedAt:
  28007. return m.OldCreatedAt(ctx)
  28008. case wx.FieldUpdatedAt:
  28009. return m.OldUpdatedAt(ctx)
  28010. case wx.FieldStatus:
  28011. return m.OldStatus(ctx)
  28012. case wx.FieldDeletedAt:
  28013. return m.OldDeletedAt(ctx)
  28014. case wx.FieldServerID:
  28015. return m.OldServerID(ctx)
  28016. case wx.FieldPort:
  28017. return m.OldPort(ctx)
  28018. case wx.FieldProcessID:
  28019. return m.OldProcessID(ctx)
  28020. case wx.FieldCallback:
  28021. return m.OldCallback(ctx)
  28022. case wx.FieldWxid:
  28023. return m.OldWxid(ctx)
  28024. case wx.FieldAccount:
  28025. return m.OldAccount(ctx)
  28026. case wx.FieldNickname:
  28027. return m.OldNickname(ctx)
  28028. case wx.FieldTel:
  28029. return m.OldTel(ctx)
  28030. case wx.FieldHeadBig:
  28031. return m.OldHeadBig(ctx)
  28032. case wx.FieldOrganizationID:
  28033. return m.OldOrganizationID(ctx)
  28034. case wx.FieldAgentID:
  28035. return m.OldAgentID(ctx)
  28036. case wx.FieldAPIBase:
  28037. return m.OldAPIBase(ctx)
  28038. case wx.FieldAPIKey:
  28039. return m.OldAPIKey(ctx)
  28040. case wx.FieldAllowList:
  28041. return m.OldAllowList(ctx)
  28042. case wx.FieldGroupAllowList:
  28043. return m.OldGroupAllowList(ctx)
  28044. case wx.FieldBlockList:
  28045. return m.OldBlockList(ctx)
  28046. case wx.FieldGroupBlockList:
  28047. return m.OldGroupBlockList(ctx)
  28048. }
  28049. return nil, fmt.Errorf("unknown Wx field %s", name)
  28050. }
  28051. // SetField sets the value of a field with the given name. It returns an error if
  28052. // the field is not defined in the schema, or if the type mismatched the field
  28053. // type.
  28054. func (m *WxMutation) SetField(name string, value ent.Value) error {
  28055. switch name {
  28056. case wx.FieldCreatedAt:
  28057. v, ok := value.(time.Time)
  28058. if !ok {
  28059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28060. }
  28061. m.SetCreatedAt(v)
  28062. return nil
  28063. case wx.FieldUpdatedAt:
  28064. v, ok := value.(time.Time)
  28065. if !ok {
  28066. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28067. }
  28068. m.SetUpdatedAt(v)
  28069. return nil
  28070. case wx.FieldStatus:
  28071. v, ok := value.(uint8)
  28072. if !ok {
  28073. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28074. }
  28075. m.SetStatus(v)
  28076. return nil
  28077. case wx.FieldDeletedAt:
  28078. v, ok := value.(time.Time)
  28079. if !ok {
  28080. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28081. }
  28082. m.SetDeletedAt(v)
  28083. return nil
  28084. case wx.FieldServerID:
  28085. v, ok := value.(uint64)
  28086. if !ok {
  28087. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28088. }
  28089. m.SetServerID(v)
  28090. return nil
  28091. case wx.FieldPort:
  28092. v, ok := value.(string)
  28093. if !ok {
  28094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28095. }
  28096. m.SetPort(v)
  28097. return nil
  28098. case wx.FieldProcessID:
  28099. v, ok := value.(string)
  28100. if !ok {
  28101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28102. }
  28103. m.SetProcessID(v)
  28104. return nil
  28105. case wx.FieldCallback:
  28106. v, ok := value.(string)
  28107. if !ok {
  28108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28109. }
  28110. m.SetCallback(v)
  28111. return nil
  28112. case wx.FieldWxid:
  28113. v, ok := value.(string)
  28114. if !ok {
  28115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28116. }
  28117. m.SetWxid(v)
  28118. return nil
  28119. case wx.FieldAccount:
  28120. v, ok := value.(string)
  28121. if !ok {
  28122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28123. }
  28124. m.SetAccount(v)
  28125. return nil
  28126. case wx.FieldNickname:
  28127. v, ok := value.(string)
  28128. if !ok {
  28129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28130. }
  28131. m.SetNickname(v)
  28132. return nil
  28133. case wx.FieldTel:
  28134. v, ok := value.(string)
  28135. if !ok {
  28136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28137. }
  28138. m.SetTel(v)
  28139. return nil
  28140. case wx.FieldHeadBig:
  28141. v, ok := value.(string)
  28142. if !ok {
  28143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28144. }
  28145. m.SetHeadBig(v)
  28146. return nil
  28147. case wx.FieldOrganizationID:
  28148. v, ok := value.(uint64)
  28149. if !ok {
  28150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28151. }
  28152. m.SetOrganizationID(v)
  28153. return nil
  28154. case wx.FieldAgentID:
  28155. v, ok := value.(uint64)
  28156. if !ok {
  28157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28158. }
  28159. m.SetAgentID(v)
  28160. return nil
  28161. case wx.FieldAPIBase:
  28162. v, ok := value.(string)
  28163. if !ok {
  28164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28165. }
  28166. m.SetAPIBase(v)
  28167. return nil
  28168. case wx.FieldAPIKey:
  28169. v, ok := value.(string)
  28170. if !ok {
  28171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28172. }
  28173. m.SetAPIKey(v)
  28174. return nil
  28175. case wx.FieldAllowList:
  28176. v, ok := value.([]string)
  28177. if !ok {
  28178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28179. }
  28180. m.SetAllowList(v)
  28181. return nil
  28182. case wx.FieldGroupAllowList:
  28183. v, ok := value.([]string)
  28184. if !ok {
  28185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28186. }
  28187. m.SetGroupAllowList(v)
  28188. return nil
  28189. case wx.FieldBlockList:
  28190. v, ok := value.([]string)
  28191. if !ok {
  28192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28193. }
  28194. m.SetBlockList(v)
  28195. return nil
  28196. case wx.FieldGroupBlockList:
  28197. v, ok := value.([]string)
  28198. if !ok {
  28199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28200. }
  28201. m.SetGroupBlockList(v)
  28202. return nil
  28203. }
  28204. return fmt.Errorf("unknown Wx field %s", name)
  28205. }
  28206. // AddedFields returns all numeric fields that were incremented/decremented during
  28207. // this mutation.
  28208. func (m *WxMutation) AddedFields() []string {
  28209. var fields []string
  28210. if m.addstatus != nil {
  28211. fields = append(fields, wx.FieldStatus)
  28212. }
  28213. if m.addorganization_id != nil {
  28214. fields = append(fields, wx.FieldOrganizationID)
  28215. }
  28216. return fields
  28217. }
  28218. // AddedField returns the numeric value that was incremented/decremented on a field
  28219. // with the given name. The second boolean return value indicates that this field
  28220. // was not set, or was not defined in the schema.
  28221. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  28222. switch name {
  28223. case wx.FieldStatus:
  28224. return m.AddedStatus()
  28225. case wx.FieldOrganizationID:
  28226. return m.AddedOrganizationID()
  28227. }
  28228. return nil, false
  28229. }
  28230. // AddField adds the value to the field with the given name. It returns an error if
  28231. // the field is not defined in the schema, or if the type mismatched the field
  28232. // type.
  28233. func (m *WxMutation) AddField(name string, value ent.Value) error {
  28234. switch name {
  28235. case wx.FieldStatus:
  28236. v, ok := value.(int8)
  28237. if !ok {
  28238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28239. }
  28240. m.AddStatus(v)
  28241. return nil
  28242. case wx.FieldOrganizationID:
  28243. v, ok := value.(int64)
  28244. if !ok {
  28245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28246. }
  28247. m.AddOrganizationID(v)
  28248. return nil
  28249. }
  28250. return fmt.Errorf("unknown Wx numeric field %s", name)
  28251. }
  28252. // ClearedFields returns all nullable fields that were cleared during this
  28253. // mutation.
  28254. func (m *WxMutation) ClearedFields() []string {
  28255. var fields []string
  28256. if m.FieldCleared(wx.FieldStatus) {
  28257. fields = append(fields, wx.FieldStatus)
  28258. }
  28259. if m.FieldCleared(wx.FieldDeletedAt) {
  28260. fields = append(fields, wx.FieldDeletedAt)
  28261. }
  28262. if m.FieldCleared(wx.FieldServerID) {
  28263. fields = append(fields, wx.FieldServerID)
  28264. }
  28265. if m.FieldCleared(wx.FieldOrganizationID) {
  28266. fields = append(fields, wx.FieldOrganizationID)
  28267. }
  28268. if m.FieldCleared(wx.FieldAPIBase) {
  28269. fields = append(fields, wx.FieldAPIBase)
  28270. }
  28271. if m.FieldCleared(wx.FieldAPIKey) {
  28272. fields = append(fields, wx.FieldAPIKey)
  28273. }
  28274. return fields
  28275. }
  28276. // FieldCleared returns a boolean indicating if a field with the given name was
  28277. // cleared in this mutation.
  28278. func (m *WxMutation) FieldCleared(name string) bool {
  28279. _, ok := m.clearedFields[name]
  28280. return ok
  28281. }
  28282. // ClearField clears the value of the field with the given name. It returns an
  28283. // error if the field is not defined in the schema.
  28284. func (m *WxMutation) ClearField(name string) error {
  28285. switch name {
  28286. case wx.FieldStatus:
  28287. m.ClearStatus()
  28288. return nil
  28289. case wx.FieldDeletedAt:
  28290. m.ClearDeletedAt()
  28291. return nil
  28292. case wx.FieldServerID:
  28293. m.ClearServerID()
  28294. return nil
  28295. case wx.FieldOrganizationID:
  28296. m.ClearOrganizationID()
  28297. return nil
  28298. case wx.FieldAPIBase:
  28299. m.ClearAPIBase()
  28300. return nil
  28301. case wx.FieldAPIKey:
  28302. m.ClearAPIKey()
  28303. return nil
  28304. }
  28305. return fmt.Errorf("unknown Wx nullable field %s", name)
  28306. }
  28307. // ResetField resets all changes in the mutation for the field with the given name.
  28308. // It returns an error if the field is not defined in the schema.
  28309. func (m *WxMutation) ResetField(name string) error {
  28310. switch name {
  28311. case wx.FieldCreatedAt:
  28312. m.ResetCreatedAt()
  28313. return nil
  28314. case wx.FieldUpdatedAt:
  28315. m.ResetUpdatedAt()
  28316. return nil
  28317. case wx.FieldStatus:
  28318. m.ResetStatus()
  28319. return nil
  28320. case wx.FieldDeletedAt:
  28321. m.ResetDeletedAt()
  28322. return nil
  28323. case wx.FieldServerID:
  28324. m.ResetServerID()
  28325. return nil
  28326. case wx.FieldPort:
  28327. m.ResetPort()
  28328. return nil
  28329. case wx.FieldProcessID:
  28330. m.ResetProcessID()
  28331. return nil
  28332. case wx.FieldCallback:
  28333. m.ResetCallback()
  28334. return nil
  28335. case wx.FieldWxid:
  28336. m.ResetWxid()
  28337. return nil
  28338. case wx.FieldAccount:
  28339. m.ResetAccount()
  28340. return nil
  28341. case wx.FieldNickname:
  28342. m.ResetNickname()
  28343. return nil
  28344. case wx.FieldTel:
  28345. m.ResetTel()
  28346. return nil
  28347. case wx.FieldHeadBig:
  28348. m.ResetHeadBig()
  28349. return nil
  28350. case wx.FieldOrganizationID:
  28351. m.ResetOrganizationID()
  28352. return nil
  28353. case wx.FieldAgentID:
  28354. m.ResetAgentID()
  28355. return nil
  28356. case wx.FieldAPIBase:
  28357. m.ResetAPIBase()
  28358. return nil
  28359. case wx.FieldAPIKey:
  28360. m.ResetAPIKey()
  28361. return nil
  28362. case wx.FieldAllowList:
  28363. m.ResetAllowList()
  28364. return nil
  28365. case wx.FieldGroupAllowList:
  28366. m.ResetGroupAllowList()
  28367. return nil
  28368. case wx.FieldBlockList:
  28369. m.ResetBlockList()
  28370. return nil
  28371. case wx.FieldGroupBlockList:
  28372. m.ResetGroupBlockList()
  28373. return nil
  28374. }
  28375. return fmt.Errorf("unknown Wx field %s", name)
  28376. }
  28377. // AddedEdges returns all edge names that were set/added in this mutation.
  28378. func (m *WxMutation) AddedEdges() []string {
  28379. edges := make([]string, 0, 2)
  28380. if m.server != nil {
  28381. edges = append(edges, wx.EdgeServer)
  28382. }
  28383. if m.agent != nil {
  28384. edges = append(edges, wx.EdgeAgent)
  28385. }
  28386. return edges
  28387. }
  28388. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28389. // name in this mutation.
  28390. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  28391. switch name {
  28392. case wx.EdgeServer:
  28393. if id := m.server; id != nil {
  28394. return []ent.Value{*id}
  28395. }
  28396. case wx.EdgeAgent:
  28397. if id := m.agent; id != nil {
  28398. return []ent.Value{*id}
  28399. }
  28400. }
  28401. return nil
  28402. }
  28403. // RemovedEdges returns all edge names that were removed in this mutation.
  28404. func (m *WxMutation) RemovedEdges() []string {
  28405. edges := make([]string, 0, 2)
  28406. return edges
  28407. }
  28408. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28409. // the given name in this mutation.
  28410. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  28411. return nil
  28412. }
  28413. // ClearedEdges returns all edge names that were cleared in this mutation.
  28414. func (m *WxMutation) ClearedEdges() []string {
  28415. edges := make([]string, 0, 2)
  28416. if m.clearedserver {
  28417. edges = append(edges, wx.EdgeServer)
  28418. }
  28419. if m.clearedagent {
  28420. edges = append(edges, wx.EdgeAgent)
  28421. }
  28422. return edges
  28423. }
  28424. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28425. // was cleared in this mutation.
  28426. func (m *WxMutation) EdgeCleared(name string) bool {
  28427. switch name {
  28428. case wx.EdgeServer:
  28429. return m.clearedserver
  28430. case wx.EdgeAgent:
  28431. return m.clearedagent
  28432. }
  28433. return false
  28434. }
  28435. // ClearEdge clears the value of the edge with the given name. It returns an error
  28436. // if that edge is not defined in the schema.
  28437. func (m *WxMutation) ClearEdge(name string) error {
  28438. switch name {
  28439. case wx.EdgeServer:
  28440. m.ClearServer()
  28441. return nil
  28442. case wx.EdgeAgent:
  28443. m.ClearAgent()
  28444. return nil
  28445. }
  28446. return fmt.Errorf("unknown Wx unique edge %s", name)
  28447. }
  28448. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28449. // It returns an error if the edge is not defined in the schema.
  28450. func (m *WxMutation) ResetEdge(name string) error {
  28451. switch name {
  28452. case wx.EdgeServer:
  28453. m.ResetServer()
  28454. return nil
  28455. case wx.EdgeAgent:
  28456. m.ResetAgent()
  28457. return nil
  28458. }
  28459. return fmt.Errorf("unknown Wx edge %s", name)
  28460. }
  28461. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  28462. type WxCardMutation struct {
  28463. config
  28464. op Op
  28465. typ string
  28466. id *uint64
  28467. created_at *time.Time
  28468. updated_at *time.Time
  28469. deleted_at *time.Time
  28470. user_id *uint64
  28471. adduser_id *int64
  28472. wx_user_id *uint64
  28473. addwx_user_id *int64
  28474. avatar *string
  28475. logo *string
  28476. name *string
  28477. company *string
  28478. address *string
  28479. phone *string
  28480. official_account *string
  28481. wechat_account *string
  28482. email *string
  28483. api_base *string
  28484. api_key *string
  28485. ai_info *string
  28486. intro *string
  28487. clearedFields map[string]struct{}
  28488. done bool
  28489. oldValue func(context.Context) (*WxCard, error)
  28490. predicates []predicate.WxCard
  28491. }
  28492. var _ ent.Mutation = (*WxCardMutation)(nil)
  28493. // wxcardOption allows management of the mutation configuration using functional options.
  28494. type wxcardOption func(*WxCardMutation)
  28495. // newWxCardMutation creates new mutation for the WxCard entity.
  28496. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  28497. m := &WxCardMutation{
  28498. config: c,
  28499. op: op,
  28500. typ: TypeWxCard,
  28501. clearedFields: make(map[string]struct{}),
  28502. }
  28503. for _, opt := range opts {
  28504. opt(m)
  28505. }
  28506. return m
  28507. }
  28508. // withWxCardID sets the ID field of the mutation.
  28509. func withWxCardID(id uint64) wxcardOption {
  28510. return func(m *WxCardMutation) {
  28511. var (
  28512. err error
  28513. once sync.Once
  28514. value *WxCard
  28515. )
  28516. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  28517. once.Do(func() {
  28518. if m.done {
  28519. err = errors.New("querying old values post mutation is not allowed")
  28520. } else {
  28521. value, err = m.Client().WxCard.Get(ctx, id)
  28522. }
  28523. })
  28524. return value, err
  28525. }
  28526. m.id = &id
  28527. }
  28528. }
  28529. // withWxCard sets the old WxCard of the mutation.
  28530. func withWxCard(node *WxCard) wxcardOption {
  28531. return func(m *WxCardMutation) {
  28532. m.oldValue = func(context.Context) (*WxCard, error) {
  28533. return node, nil
  28534. }
  28535. m.id = &node.ID
  28536. }
  28537. }
  28538. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28539. // executed in a transaction (ent.Tx), a transactional client is returned.
  28540. func (m WxCardMutation) Client() *Client {
  28541. client := &Client{config: m.config}
  28542. client.init()
  28543. return client
  28544. }
  28545. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28546. // it returns an error otherwise.
  28547. func (m WxCardMutation) Tx() (*Tx, error) {
  28548. if _, ok := m.driver.(*txDriver); !ok {
  28549. return nil, errors.New("ent: mutation is not running in a transaction")
  28550. }
  28551. tx := &Tx{config: m.config}
  28552. tx.init()
  28553. return tx, nil
  28554. }
  28555. // SetID sets the value of the id field. Note that this
  28556. // operation is only accepted on creation of WxCard entities.
  28557. func (m *WxCardMutation) SetID(id uint64) {
  28558. m.id = &id
  28559. }
  28560. // ID returns the ID value in the mutation. Note that the ID is only available
  28561. // if it was provided to the builder or after it was returned from the database.
  28562. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  28563. if m.id == nil {
  28564. return
  28565. }
  28566. return *m.id, true
  28567. }
  28568. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28569. // That means, if the mutation is applied within a transaction with an isolation level such
  28570. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28571. // or updated by the mutation.
  28572. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  28573. switch {
  28574. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28575. id, exists := m.ID()
  28576. if exists {
  28577. return []uint64{id}, nil
  28578. }
  28579. fallthrough
  28580. case m.op.Is(OpUpdate | OpDelete):
  28581. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  28582. default:
  28583. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28584. }
  28585. }
  28586. // SetCreatedAt sets the "created_at" field.
  28587. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  28588. m.created_at = &t
  28589. }
  28590. // CreatedAt returns the value of the "created_at" field in the mutation.
  28591. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  28592. v := m.created_at
  28593. if v == nil {
  28594. return
  28595. }
  28596. return *v, true
  28597. }
  28598. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  28599. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  28600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28601. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28602. if !m.op.Is(OpUpdateOne) {
  28603. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28604. }
  28605. if m.id == nil || m.oldValue == nil {
  28606. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28607. }
  28608. oldValue, err := m.oldValue(ctx)
  28609. if err != nil {
  28610. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28611. }
  28612. return oldValue.CreatedAt, nil
  28613. }
  28614. // ResetCreatedAt resets all changes to the "created_at" field.
  28615. func (m *WxCardMutation) ResetCreatedAt() {
  28616. m.created_at = nil
  28617. }
  28618. // SetUpdatedAt sets the "updated_at" field.
  28619. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  28620. m.updated_at = &t
  28621. }
  28622. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28623. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  28624. v := m.updated_at
  28625. if v == nil {
  28626. return
  28627. }
  28628. return *v, true
  28629. }
  28630. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  28631. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  28632. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28633. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28634. if !m.op.Is(OpUpdateOne) {
  28635. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28636. }
  28637. if m.id == nil || m.oldValue == nil {
  28638. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28639. }
  28640. oldValue, err := m.oldValue(ctx)
  28641. if err != nil {
  28642. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28643. }
  28644. return oldValue.UpdatedAt, nil
  28645. }
  28646. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28647. func (m *WxCardMutation) ResetUpdatedAt() {
  28648. m.updated_at = nil
  28649. }
  28650. // SetDeletedAt sets the "deleted_at" field.
  28651. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  28652. m.deleted_at = &t
  28653. }
  28654. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28655. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  28656. v := m.deleted_at
  28657. if v == nil {
  28658. return
  28659. }
  28660. return *v, true
  28661. }
  28662. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  28663. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  28664. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28665. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28666. if !m.op.Is(OpUpdateOne) {
  28667. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28668. }
  28669. if m.id == nil || m.oldValue == nil {
  28670. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28671. }
  28672. oldValue, err := m.oldValue(ctx)
  28673. if err != nil {
  28674. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28675. }
  28676. return oldValue.DeletedAt, nil
  28677. }
  28678. // ClearDeletedAt clears the value of the "deleted_at" field.
  28679. func (m *WxCardMutation) ClearDeletedAt() {
  28680. m.deleted_at = nil
  28681. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  28682. }
  28683. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28684. func (m *WxCardMutation) DeletedAtCleared() bool {
  28685. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  28686. return ok
  28687. }
  28688. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28689. func (m *WxCardMutation) ResetDeletedAt() {
  28690. m.deleted_at = nil
  28691. delete(m.clearedFields, wxcard.FieldDeletedAt)
  28692. }
  28693. // SetUserID sets the "user_id" field.
  28694. func (m *WxCardMutation) SetUserID(u uint64) {
  28695. m.user_id = &u
  28696. m.adduser_id = nil
  28697. }
  28698. // UserID returns the value of the "user_id" field in the mutation.
  28699. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  28700. v := m.user_id
  28701. if v == nil {
  28702. return
  28703. }
  28704. return *v, true
  28705. }
  28706. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  28707. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  28708. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28709. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  28710. if !m.op.Is(OpUpdateOne) {
  28711. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  28712. }
  28713. if m.id == nil || m.oldValue == nil {
  28714. return v, errors.New("OldUserID requires an ID field in the mutation")
  28715. }
  28716. oldValue, err := m.oldValue(ctx)
  28717. if err != nil {
  28718. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  28719. }
  28720. return oldValue.UserID, nil
  28721. }
  28722. // AddUserID adds u to the "user_id" field.
  28723. func (m *WxCardMutation) AddUserID(u int64) {
  28724. if m.adduser_id != nil {
  28725. *m.adduser_id += u
  28726. } else {
  28727. m.adduser_id = &u
  28728. }
  28729. }
  28730. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  28731. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  28732. v := m.adduser_id
  28733. if v == nil {
  28734. return
  28735. }
  28736. return *v, true
  28737. }
  28738. // ClearUserID clears the value of the "user_id" field.
  28739. func (m *WxCardMutation) ClearUserID() {
  28740. m.user_id = nil
  28741. m.adduser_id = nil
  28742. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  28743. }
  28744. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  28745. func (m *WxCardMutation) UserIDCleared() bool {
  28746. _, ok := m.clearedFields[wxcard.FieldUserID]
  28747. return ok
  28748. }
  28749. // ResetUserID resets all changes to the "user_id" field.
  28750. func (m *WxCardMutation) ResetUserID() {
  28751. m.user_id = nil
  28752. m.adduser_id = nil
  28753. delete(m.clearedFields, wxcard.FieldUserID)
  28754. }
  28755. // SetWxUserID sets the "wx_user_id" field.
  28756. func (m *WxCardMutation) SetWxUserID(u uint64) {
  28757. m.wx_user_id = &u
  28758. m.addwx_user_id = nil
  28759. }
  28760. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  28761. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  28762. v := m.wx_user_id
  28763. if v == nil {
  28764. return
  28765. }
  28766. return *v, true
  28767. }
  28768. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  28769. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  28770. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28771. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  28772. if !m.op.Is(OpUpdateOne) {
  28773. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  28774. }
  28775. if m.id == nil || m.oldValue == nil {
  28776. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  28777. }
  28778. oldValue, err := m.oldValue(ctx)
  28779. if err != nil {
  28780. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  28781. }
  28782. return oldValue.WxUserID, nil
  28783. }
  28784. // AddWxUserID adds u to the "wx_user_id" field.
  28785. func (m *WxCardMutation) AddWxUserID(u int64) {
  28786. if m.addwx_user_id != nil {
  28787. *m.addwx_user_id += u
  28788. } else {
  28789. m.addwx_user_id = &u
  28790. }
  28791. }
  28792. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  28793. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  28794. v := m.addwx_user_id
  28795. if v == nil {
  28796. return
  28797. }
  28798. return *v, true
  28799. }
  28800. // ClearWxUserID clears the value of the "wx_user_id" field.
  28801. func (m *WxCardMutation) ClearWxUserID() {
  28802. m.wx_user_id = nil
  28803. m.addwx_user_id = nil
  28804. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  28805. }
  28806. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  28807. func (m *WxCardMutation) WxUserIDCleared() bool {
  28808. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  28809. return ok
  28810. }
  28811. // ResetWxUserID resets all changes to the "wx_user_id" field.
  28812. func (m *WxCardMutation) ResetWxUserID() {
  28813. m.wx_user_id = nil
  28814. m.addwx_user_id = nil
  28815. delete(m.clearedFields, wxcard.FieldWxUserID)
  28816. }
  28817. // SetAvatar sets the "avatar" field.
  28818. func (m *WxCardMutation) SetAvatar(s string) {
  28819. m.avatar = &s
  28820. }
  28821. // Avatar returns the value of the "avatar" field in the mutation.
  28822. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  28823. v := m.avatar
  28824. if v == nil {
  28825. return
  28826. }
  28827. return *v, true
  28828. }
  28829. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  28830. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  28831. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28832. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  28833. if !m.op.Is(OpUpdateOne) {
  28834. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  28835. }
  28836. if m.id == nil || m.oldValue == nil {
  28837. return v, errors.New("OldAvatar requires an ID field in the mutation")
  28838. }
  28839. oldValue, err := m.oldValue(ctx)
  28840. if err != nil {
  28841. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  28842. }
  28843. return oldValue.Avatar, nil
  28844. }
  28845. // ResetAvatar resets all changes to the "avatar" field.
  28846. func (m *WxCardMutation) ResetAvatar() {
  28847. m.avatar = nil
  28848. }
  28849. // SetLogo sets the "logo" field.
  28850. func (m *WxCardMutation) SetLogo(s string) {
  28851. m.logo = &s
  28852. }
  28853. // Logo returns the value of the "logo" field in the mutation.
  28854. func (m *WxCardMutation) Logo() (r string, exists bool) {
  28855. v := m.logo
  28856. if v == nil {
  28857. return
  28858. }
  28859. return *v, true
  28860. }
  28861. // OldLogo returns the old "logo" field's value of the WxCard entity.
  28862. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  28863. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28864. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  28865. if !m.op.Is(OpUpdateOne) {
  28866. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  28867. }
  28868. if m.id == nil || m.oldValue == nil {
  28869. return v, errors.New("OldLogo requires an ID field in the mutation")
  28870. }
  28871. oldValue, err := m.oldValue(ctx)
  28872. if err != nil {
  28873. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  28874. }
  28875. return oldValue.Logo, nil
  28876. }
  28877. // ResetLogo resets all changes to the "logo" field.
  28878. func (m *WxCardMutation) ResetLogo() {
  28879. m.logo = nil
  28880. }
  28881. // SetName sets the "name" field.
  28882. func (m *WxCardMutation) SetName(s string) {
  28883. m.name = &s
  28884. }
  28885. // Name returns the value of the "name" field in the mutation.
  28886. func (m *WxCardMutation) Name() (r string, exists bool) {
  28887. v := m.name
  28888. if v == nil {
  28889. return
  28890. }
  28891. return *v, true
  28892. }
  28893. // OldName returns the old "name" field's value of the WxCard entity.
  28894. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  28895. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28896. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  28897. if !m.op.Is(OpUpdateOne) {
  28898. return v, errors.New("OldName is only allowed on UpdateOne operations")
  28899. }
  28900. if m.id == nil || m.oldValue == nil {
  28901. return v, errors.New("OldName requires an ID field in the mutation")
  28902. }
  28903. oldValue, err := m.oldValue(ctx)
  28904. if err != nil {
  28905. return v, fmt.Errorf("querying old value for OldName: %w", err)
  28906. }
  28907. return oldValue.Name, nil
  28908. }
  28909. // ResetName resets all changes to the "name" field.
  28910. func (m *WxCardMutation) ResetName() {
  28911. m.name = nil
  28912. }
  28913. // SetCompany sets the "company" field.
  28914. func (m *WxCardMutation) SetCompany(s string) {
  28915. m.company = &s
  28916. }
  28917. // Company returns the value of the "company" field in the mutation.
  28918. func (m *WxCardMutation) Company() (r string, exists bool) {
  28919. v := m.company
  28920. if v == nil {
  28921. return
  28922. }
  28923. return *v, true
  28924. }
  28925. // OldCompany returns the old "company" field's value of the WxCard entity.
  28926. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  28927. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28928. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  28929. if !m.op.Is(OpUpdateOne) {
  28930. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  28931. }
  28932. if m.id == nil || m.oldValue == nil {
  28933. return v, errors.New("OldCompany requires an ID field in the mutation")
  28934. }
  28935. oldValue, err := m.oldValue(ctx)
  28936. if err != nil {
  28937. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  28938. }
  28939. return oldValue.Company, nil
  28940. }
  28941. // ResetCompany resets all changes to the "company" field.
  28942. func (m *WxCardMutation) ResetCompany() {
  28943. m.company = nil
  28944. }
  28945. // SetAddress sets the "address" field.
  28946. func (m *WxCardMutation) SetAddress(s string) {
  28947. m.address = &s
  28948. }
  28949. // Address returns the value of the "address" field in the mutation.
  28950. func (m *WxCardMutation) Address() (r string, exists bool) {
  28951. v := m.address
  28952. if v == nil {
  28953. return
  28954. }
  28955. return *v, true
  28956. }
  28957. // OldAddress returns the old "address" field's value of the WxCard entity.
  28958. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  28959. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28960. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  28961. if !m.op.Is(OpUpdateOne) {
  28962. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  28963. }
  28964. if m.id == nil || m.oldValue == nil {
  28965. return v, errors.New("OldAddress requires an ID field in the mutation")
  28966. }
  28967. oldValue, err := m.oldValue(ctx)
  28968. if err != nil {
  28969. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  28970. }
  28971. return oldValue.Address, nil
  28972. }
  28973. // ResetAddress resets all changes to the "address" field.
  28974. func (m *WxCardMutation) ResetAddress() {
  28975. m.address = nil
  28976. }
  28977. // SetPhone sets the "phone" field.
  28978. func (m *WxCardMutation) SetPhone(s string) {
  28979. m.phone = &s
  28980. }
  28981. // Phone returns the value of the "phone" field in the mutation.
  28982. func (m *WxCardMutation) Phone() (r string, exists bool) {
  28983. v := m.phone
  28984. if v == nil {
  28985. return
  28986. }
  28987. return *v, true
  28988. }
  28989. // OldPhone returns the old "phone" field's value of the WxCard entity.
  28990. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  28991. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28992. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  28993. if !m.op.Is(OpUpdateOne) {
  28994. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  28995. }
  28996. if m.id == nil || m.oldValue == nil {
  28997. return v, errors.New("OldPhone requires an ID field in the mutation")
  28998. }
  28999. oldValue, err := m.oldValue(ctx)
  29000. if err != nil {
  29001. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  29002. }
  29003. return oldValue.Phone, nil
  29004. }
  29005. // ResetPhone resets all changes to the "phone" field.
  29006. func (m *WxCardMutation) ResetPhone() {
  29007. m.phone = nil
  29008. }
  29009. // SetOfficialAccount sets the "official_account" field.
  29010. func (m *WxCardMutation) SetOfficialAccount(s string) {
  29011. m.official_account = &s
  29012. }
  29013. // OfficialAccount returns the value of the "official_account" field in the mutation.
  29014. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  29015. v := m.official_account
  29016. if v == nil {
  29017. return
  29018. }
  29019. return *v, true
  29020. }
  29021. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  29022. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29023. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29024. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  29025. if !m.op.Is(OpUpdateOne) {
  29026. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  29027. }
  29028. if m.id == nil || m.oldValue == nil {
  29029. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  29030. }
  29031. oldValue, err := m.oldValue(ctx)
  29032. if err != nil {
  29033. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  29034. }
  29035. return oldValue.OfficialAccount, nil
  29036. }
  29037. // ResetOfficialAccount resets all changes to the "official_account" field.
  29038. func (m *WxCardMutation) ResetOfficialAccount() {
  29039. m.official_account = nil
  29040. }
  29041. // SetWechatAccount sets the "wechat_account" field.
  29042. func (m *WxCardMutation) SetWechatAccount(s string) {
  29043. m.wechat_account = &s
  29044. }
  29045. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  29046. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  29047. v := m.wechat_account
  29048. if v == nil {
  29049. return
  29050. }
  29051. return *v, true
  29052. }
  29053. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  29054. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29055. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29056. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  29057. if !m.op.Is(OpUpdateOne) {
  29058. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  29059. }
  29060. if m.id == nil || m.oldValue == nil {
  29061. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  29062. }
  29063. oldValue, err := m.oldValue(ctx)
  29064. if err != nil {
  29065. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  29066. }
  29067. return oldValue.WechatAccount, nil
  29068. }
  29069. // ResetWechatAccount resets all changes to the "wechat_account" field.
  29070. func (m *WxCardMutation) ResetWechatAccount() {
  29071. m.wechat_account = nil
  29072. }
  29073. // SetEmail sets the "email" field.
  29074. func (m *WxCardMutation) SetEmail(s string) {
  29075. m.email = &s
  29076. }
  29077. // Email returns the value of the "email" field in the mutation.
  29078. func (m *WxCardMutation) Email() (r string, exists bool) {
  29079. v := m.email
  29080. if v == nil {
  29081. return
  29082. }
  29083. return *v, true
  29084. }
  29085. // OldEmail returns the old "email" field's value of the WxCard entity.
  29086. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29087. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29088. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  29089. if !m.op.Is(OpUpdateOne) {
  29090. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  29091. }
  29092. if m.id == nil || m.oldValue == nil {
  29093. return v, errors.New("OldEmail requires an ID field in the mutation")
  29094. }
  29095. oldValue, err := m.oldValue(ctx)
  29096. if err != nil {
  29097. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  29098. }
  29099. return oldValue.Email, nil
  29100. }
  29101. // ClearEmail clears the value of the "email" field.
  29102. func (m *WxCardMutation) ClearEmail() {
  29103. m.email = nil
  29104. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  29105. }
  29106. // EmailCleared returns if the "email" field was cleared in this mutation.
  29107. func (m *WxCardMutation) EmailCleared() bool {
  29108. _, ok := m.clearedFields[wxcard.FieldEmail]
  29109. return ok
  29110. }
  29111. // ResetEmail resets all changes to the "email" field.
  29112. func (m *WxCardMutation) ResetEmail() {
  29113. m.email = nil
  29114. delete(m.clearedFields, wxcard.FieldEmail)
  29115. }
  29116. // SetAPIBase sets the "api_base" field.
  29117. func (m *WxCardMutation) SetAPIBase(s string) {
  29118. m.api_base = &s
  29119. }
  29120. // APIBase returns the value of the "api_base" field in the mutation.
  29121. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  29122. v := m.api_base
  29123. if v == nil {
  29124. return
  29125. }
  29126. return *v, true
  29127. }
  29128. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  29129. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29130. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29131. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  29132. if !m.op.Is(OpUpdateOne) {
  29133. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  29134. }
  29135. if m.id == nil || m.oldValue == nil {
  29136. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  29137. }
  29138. oldValue, err := m.oldValue(ctx)
  29139. if err != nil {
  29140. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  29141. }
  29142. return oldValue.APIBase, nil
  29143. }
  29144. // ClearAPIBase clears the value of the "api_base" field.
  29145. func (m *WxCardMutation) ClearAPIBase() {
  29146. m.api_base = nil
  29147. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  29148. }
  29149. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  29150. func (m *WxCardMutation) APIBaseCleared() bool {
  29151. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  29152. return ok
  29153. }
  29154. // ResetAPIBase resets all changes to the "api_base" field.
  29155. func (m *WxCardMutation) ResetAPIBase() {
  29156. m.api_base = nil
  29157. delete(m.clearedFields, wxcard.FieldAPIBase)
  29158. }
  29159. // SetAPIKey sets the "api_key" field.
  29160. func (m *WxCardMutation) SetAPIKey(s string) {
  29161. m.api_key = &s
  29162. }
  29163. // APIKey returns the value of the "api_key" field in the mutation.
  29164. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  29165. v := m.api_key
  29166. if v == nil {
  29167. return
  29168. }
  29169. return *v, true
  29170. }
  29171. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  29172. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29173. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29174. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  29175. if !m.op.Is(OpUpdateOne) {
  29176. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  29177. }
  29178. if m.id == nil || m.oldValue == nil {
  29179. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  29180. }
  29181. oldValue, err := m.oldValue(ctx)
  29182. if err != nil {
  29183. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  29184. }
  29185. return oldValue.APIKey, nil
  29186. }
  29187. // ClearAPIKey clears the value of the "api_key" field.
  29188. func (m *WxCardMutation) ClearAPIKey() {
  29189. m.api_key = nil
  29190. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  29191. }
  29192. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  29193. func (m *WxCardMutation) APIKeyCleared() bool {
  29194. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  29195. return ok
  29196. }
  29197. // ResetAPIKey resets all changes to the "api_key" field.
  29198. func (m *WxCardMutation) ResetAPIKey() {
  29199. m.api_key = nil
  29200. delete(m.clearedFields, wxcard.FieldAPIKey)
  29201. }
  29202. // SetAiInfo sets the "ai_info" field.
  29203. func (m *WxCardMutation) SetAiInfo(s string) {
  29204. m.ai_info = &s
  29205. }
  29206. // AiInfo returns the value of the "ai_info" field in the mutation.
  29207. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  29208. v := m.ai_info
  29209. if v == nil {
  29210. return
  29211. }
  29212. return *v, true
  29213. }
  29214. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  29215. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29216. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29217. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  29218. if !m.op.Is(OpUpdateOne) {
  29219. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  29220. }
  29221. if m.id == nil || m.oldValue == nil {
  29222. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  29223. }
  29224. oldValue, err := m.oldValue(ctx)
  29225. if err != nil {
  29226. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  29227. }
  29228. return oldValue.AiInfo, nil
  29229. }
  29230. // ClearAiInfo clears the value of the "ai_info" field.
  29231. func (m *WxCardMutation) ClearAiInfo() {
  29232. m.ai_info = nil
  29233. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  29234. }
  29235. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  29236. func (m *WxCardMutation) AiInfoCleared() bool {
  29237. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  29238. return ok
  29239. }
  29240. // ResetAiInfo resets all changes to the "ai_info" field.
  29241. func (m *WxCardMutation) ResetAiInfo() {
  29242. m.ai_info = nil
  29243. delete(m.clearedFields, wxcard.FieldAiInfo)
  29244. }
  29245. // SetIntro sets the "intro" field.
  29246. func (m *WxCardMutation) SetIntro(s string) {
  29247. m.intro = &s
  29248. }
  29249. // Intro returns the value of the "intro" field in the mutation.
  29250. func (m *WxCardMutation) Intro() (r string, exists bool) {
  29251. v := m.intro
  29252. if v == nil {
  29253. return
  29254. }
  29255. return *v, true
  29256. }
  29257. // OldIntro returns the old "intro" field's value of the WxCard entity.
  29258. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  29259. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29260. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  29261. if !m.op.Is(OpUpdateOne) {
  29262. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  29263. }
  29264. if m.id == nil || m.oldValue == nil {
  29265. return v, errors.New("OldIntro requires an ID field in the mutation")
  29266. }
  29267. oldValue, err := m.oldValue(ctx)
  29268. if err != nil {
  29269. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  29270. }
  29271. return oldValue.Intro, nil
  29272. }
  29273. // ClearIntro clears the value of the "intro" field.
  29274. func (m *WxCardMutation) ClearIntro() {
  29275. m.intro = nil
  29276. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  29277. }
  29278. // IntroCleared returns if the "intro" field was cleared in this mutation.
  29279. func (m *WxCardMutation) IntroCleared() bool {
  29280. _, ok := m.clearedFields[wxcard.FieldIntro]
  29281. return ok
  29282. }
  29283. // ResetIntro resets all changes to the "intro" field.
  29284. func (m *WxCardMutation) ResetIntro() {
  29285. m.intro = nil
  29286. delete(m.clearedFields, wxcard.FieldIntro)
  29287. }
  29288. // Where appends a list predicates to the WxCardMutation builder.
  29289. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  29290. m.predicates = append(m.predicates, ps...)
  29291. }
  29292. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  29293. // users can use type-assertion to append predicates that do not depend on any generated package.
  29294. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  29295. p := make([]predicate.WxCard, len(ps))
  29296. for i := range ps {
  29297. p[i] = ps[i]
  29298. }
  29299. m.Where(p...)
  29300. }
  29301. // Op returns the operation name.
  29302. func (m *WxCardMutation) Op() Op {
  29303. return m.op
  29304. }
  29305. // SetOp allows setting the mutation operation.
  29306. func (m *WxCardMutation) SetOp(op Op) {
  29307. m.op = op
  29308. }
  29309. // Type returns the node type of this mutation (WxCard).
  29310. func (m *WxCardMutation) Type() string {
  29311. return m.typ
  29312. }
  29313. // Fields returns all fields that were changed during this mutation. Note that in
  29314. // order to get all numeric fields that were incremented/decremented, call
  29315. // AddedFields().
  29316. func (m *WxCardMutation) Fields() []string {
  29317. fields := make([]string, 0, 18)
  29318. if m.created_at != nil {
  29319. fields = append(fields, wxcard.FieldCreatedAt)
  29320. }
  29321. if m.updated_at != nil {
  29322. fields = append(fields, wxcard.FieldUpdatedAt)
  29323. }
  29324. if m.deleted_at != nil {
  29325. fields = append(fields, wxcard.FieldDeletedAt)
  29326. }
  29327. if m.user_id != nil {
  29328. fields = append(fields, wxcard.FieldUserID)
  29329. }
  29330. if m.wx_user_id != nil {
  29331. fields = append(fields, wxcard.FieldWxUserID)
  29332. }
  29333. if m.avatar != nil {
  29334. fields = append(fields, wxcard.FieldAvatar)
  29335. }
  29336. if m.logo != nil {
  29337. fields = append(fields, wxcard.FieldLogo)
  29338. }
  29339. if m.name != nil {
  29340. fields = append(fields, wxcard.FieldName)
  29341. }
  29342. if m.company != nil {
  29343. fields = append(fields, wxcard.FieldCompany)
  29344. }
  29345. if m.address != nil {
  29346. fields = append(fields, wxcard.FieldAddress)
  29347. }
  29348. if m.phone != nil {
  29349. fields = append(fields, wxcard.FieldPhone)
  29350. }
  29351. if m.official_account != nil {
  29352. fields = append(fields, wxcard.FieldOfficialAccount)
  29353. }
  29354. if m.wechat_account != nil {
  29355. fields = append(fields, wxcard.FieldWechatAccount)
  29356. }
  29357. if m.email != nil {
  29358. fields = append(fields, wxcard.FieldEmail)
  29359. }
  29360. if m.api_base != nil {
  29361. fields = append(fields, wxcard.FieldAPIBase)
  29362. }
  29363. if m.api_key != nil {
  29364. fields = append(fields, wxcard.FieldAPIKey)
  29365. }
  29366. if m.ai_info != nil {
  29367. fields = append(fields, wxcard.FieldAiInfo)
  29368. }
  29369. if m.intro != nil {
  29370. fields = append(fields, wxcard.FieldIntro)
  29371. }
  29372. return fields
  29373. }
  29374. // Field returns the value of a field with the given name. The second boolean
  29375. // return value indicates that this field was not set, or was not defined in the
  29376. // schema.
  29377. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  29378. switch name {
  29379. case wxcard.FieldCreatedAt:
  29380. return m.CreatedAt()
  29381. case wxcard.FieldUpdatedAt:
  29382. return m.UpdatedAt()
  29383. case wxcard.FieldDeletedAt:
  29384. return m.DeletedAt()
  29385. case wxcard.FieldUserID:
  29386. return m.UserID()
  29387. case wxcard.FieldWxUserID:
  29388. return m.WxUserID()
  29389. case wxcard.FieldAvatar:
  29390. return m.Avatar()
  29391. case wxcard.FieldLogo:
  29392. return m.Logo()
  29393. case wxcard.FieldName:
  29394. return m.Name()
  29395. case wxcard.FieldCompany:
  29396. return m.Company()
  29397. case wxcard.FieldAddress:
  29398. return m.Address()
  29399. case wxcard.FieldPhone:
  29400. return m.Phone()
  29401. case wxcard.FieldOfficialAccount:
  29402. return m.OfficialAccount()
  29403. case wxcard.FieldWechatAccount:
  29404. return m.WechatAccount()
  29405. case wxcard.FieldEmail:
  29406. return m.Email()
  29407. case wxcard.FieldAPIBase:
  29408. return m.APIBase()
  29409. case wxcard.FieldAPIKey:
  29410. return m.APIKey()
  29411. case wxcard.FieldAiInfo:
  29412. return m.AiInfo()
  29413. case wxcard.FieldIntro:
  29414. return m.Intro()
  29415. }
  29416. return nil, false
  29417. }
  29418. // OldField returns the old value of the field from the database. An error is
  29419. // returned if the mutation operation is not UpdateOne, or the query to the
  29420. // database failed.
  29421. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29422. switch name {
  29423. case wxcard.FieldCreatedAt:
  29424. return m.OldCreatedAt(ctx)
  29425. case wxcard.FieldUpdatedAt:
  29426. return m.OldUpdatedAt(ctx)
  29427. case wxcard.FieldDeletedAt:
  29428. return m.OldDeletedAt(ctx)
  29429. case wxcard.FieldUserID:
  29430. return m.OldUserID(ctx)
  29431. case wxcard.FieldWxUserID:
  29432. return m.OldWxUserID(ctx)
  29433. case wxcard.FieldAvatar:
  29434. return m.OldAvatar(ctx)
  29435. case wxcard.FieldLogo:
  29436. return m.OldLogo(ctx)
  29437. case wxcard.FieldName:
  29438. return m.OldName(ctx)
  29439. case wxcard.FieldCompany:
  29440. return m.OldCompany(ctx)
  29441. case wxcard.FieldAddress:
  29442. return m.OldAddress(ctx)
  29443. case wxcard.FieldPhone:
  29444. return m.OldPhone(ctx)
  29445. case wxcard.FieldOfficialAccount:
  29446. return m.OldOfficialAccount(ctx)
  29447. case wxcard.FieldWechatAccount:
  29448. return m.OldWechatAccount(ctx)
  29449. case wxcard.FieldEmail:
  29450. return m.OldEmail(ctx)
  29451. case wxcard.FieldAPIBase:
  29452. return m.OldAPIBase(ctx)
  29453. case wxcard.FieldAPIKey:
  29454. return m.OldAPIKey(ctx)
  29455. case wxcard.FieldAiInfo:
  29456. return m.OldAiInfo(ctx)
  29457. case wxcard.FieldIntro:
  29458. return m.OldIntro(ctx)
  29459. }
  29460. return nil, fmt.Errorf("unknown WxCard field %s", name)
  29461. }
  29462. // SetField sets the value of a field with the given name. It returns an error if
  29463. // the field is not defined in the schema, or if the type mismatched the field
  29464. // type.
  29465. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  29466. switch name {
  29467. case wxcard.FieldCreatedAt:
  29468. v, ok := value.(time.Time)
  29469. if !ok {
  29470. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29471. }
  29472. m.SetCreatedAt(v)
  29473. return nil
  29474. case wxcard.FieldUpdatedAt:
  29475. v, ok := value.(time.Time)
  29476. if !ok {
  29477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29478. }
  29479. m.SetUpdatedAt(v)
  29480. return nil
  29481. case wxcard.FieldDeletedAt:
  29482. v, ok := value.(time.Time)
  29483. if !ok {
  29484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29485. }
  29486. m.SetDeletedAt(v)
  29487. return nil
  29488. case wxcard.FieldUserID:
  29489. v, ok := value.(uint64)
  29490. if !ok {
  29491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29492. }
  29493. m.SetUserID(v)
  29494. return nil
  29495. case wxcard.FieldWxUserID:
  29496. v, ok := value.(uint64)
  29497. if !ok {
  29498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29499. }
  29500. m.SetWxUserID(v)
  29501. return nil
  29502. case wxcard.FieldAvatar:
  29503. v, ok := value.(string)
  29504. if !ok {
  29505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29506. }
  29507. m.SetAvatar(v)
  29508. return nil
  29509. case wxcard.FieldLogo:
  29510. v, ok := value.(string)
  29511. if !ok {
  29512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29513. }
  29514. m.SetLogo(v)
  29515. return nil
  29516. case wxcard.FieldName:
  29517. v, ok := value.(string)
  29518. if !ok {
  29519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29520. }
  29521. m.SetName(v)
  29522. return nil
  29523. case wxcard.FieldCompany:
  29524. v, ok := value.(string)
  29525. if !ok {
  29526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29527. }
  29528. m.SetCompany(v)
  29529. return nil
  29530. case wxcard.FieldAddress:
  29531. v, ok := value.(string)
  29532. if !ok {
  29533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29534. }
  29535. m.SetAddress(v)
  29536. return nil
  29537. case wxcard.FieldPhone:
  29538. v, ok := value.(string)
  29539. if !ok {
  29540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29541. }
  29542. m.SetPhone(v)
  29543. return nil
  29544. case wxcard.FieldOfficialAccount:
  29545. v, ok := value.(string)
  29546. if !ok {
  29547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29548. }
  29549. m.SetOfficialAccount(v)
  29550. return nil
  29551. case wxcard.FieldWechatAccount:
  29552. v, ok := value.(string)
  29553. if !ok {
  29554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29555. }
  29556. m.SetWechatAccount(v)
  29557. return nil
  29558. case wxcard.FieldEmail:
  29559. v, ok := value.(string)
  29560. if !ok {
  29561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29562. }
  29563. m.SetEmail(v)
  29564. return nil
  29565. case wxcard.FieldAPIBase:
  29566. v, ok := value.(string)
  29567. if !ok {
  29568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29569. }
  29570. m.SetAPIBase(v)
  29571. return nil
  29572. case wxcard.FieldAPIKey:
  29573. v, ok := value.(string)
  29574. if !ok {
  29575. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29576. }
  29577. m.SetAPIKey(v)
  29578. return nil
  29579. case wxcard.FieldAiInfo:
  29580. v, ok := value.(string)
  29581. if !ok {
  29582. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29583. }
  29584. m.SetAiInfo(v)
  29585. return nil
  29586. case wxcard.FieldIntro:
  29587. v, ok := value.(string)
  29588. if !ok {
  29589. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29590. }
  29591. m.SetIntro(v)
  29592. return nil
  29593. }
  29594. return fmt.Errorf("unknown WxCard field %s", name)
  29595. }
  29596. // AddedFields returns all numeric fields that were incremented/decremented during
  29597. // this mutation.
  29598. func (m *WxCardMutation) AddedFields() []string {
  29599. var fields []string
  29600. if m.adduser_id != nil {
  29601. fields = append(fields, wxcard.FieldUserID)
  29602. }
  29603. if m.addwx_user_id != nil {
  29604. fields = append(fields, wxcard.FieldWxUserID)
  29605. }
  29606. return fields
  29607. }
  29608. // AddedField returns the numeric value that was incremented/decremented on a field
  29609. // with the given name. The second boolean return value indicates that this field
  29610. // was not set, or was not defined in the schema.
  29611. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  29612. switch name {
  29613. case wxcard.FieldUserID:
  29614. return m.AddedUserID()
  29615. case wxcard.FieldWxUserID:
  29616. return m.AddedWxUserID()
  29617. }
  29618. return nil, false
  29619. }
  29620. // AddField adds the value to the field with the given name. It returns an error if
  29621. // the field is not defined in the schema, or if the type mismatched the field
  29622. // type.
  29623. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  29624. switch name {
  29625. case wxcard.FieldUserID:
  29626. v, ok := value.(int64)
  29627. if !ok {
  29628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29629. }
  29630. m.AddUserID(v)
  29631. return nil
  29632. case wxcard.FieldWxUserID:
  29633. v, ok := value.(int64)
  29634. if !ok {
  29635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29636. }
  29637. m.AddWxUserID(v)
  29638. return nil
  29639. }
  29640. return fmt.Errorf("unknown WxCard numeric field %s", name)
  29641. }
  29642. // ClearedFields returns all nullable fields that were cleared during this
  29643. // mutation.
  29644. func (m *WxCardMutation) ClearedFields() []string {
  29645. var fields []string
  29646. if m.FieldCleared(wxcard.FieldDeletedAt) {
  29647. fields = append(fields, wxcard.FieldDeletedAt)
  29648. }
  29649. if m.FieldCleared(wxcard.FieldUserID) {
  29650. fields = append(fields, wxcard.FieldUserID)
  29651. }
  29652. if m.FieldCleared(wxcard.FieldWxUserID) {
  29653. fields = append(fields, wxcard.FieldWxUserID)
  29654. }
  29655. if m.FieldCleared(wxcard.FieldEmail) {
  29656. fields = append(fields, wxcard.FieldEmail)
  29657. }
  29658. if m.FieldCleared(wxcard.FieldAPIBase) {
  29659. fields = append(fields, wxcard.FieldAPIBase)
  29660. }
  29661. if m.FieldCleared(wxcard.FieldAPIKey) {
  29662. fields = append(fields, wxcard.FieldAPIKey)
  29663. }
  29664. if m.FieldCleared(wxcard.FieldAiInfo) {
  29665. fields = append(fields, wxcard.FieldAiInfo)
  29666. }
  29667. if m.FieldCleared(wxcard.FieldIntro) {
  29668. fields = append(fields, wxcard.FieldIntro)
  29669. }
  29670. return fields
  29671. }
  29672. // FieldCleared returns a boolean indicating if a field with the given name was
  29673. // cleared in this mutation.
  29674. func (m *WxCardMutation) FieldCleared(name string) bool {
  29675. _, ok := m.clearedFields[name]
  29676. return ok
  29677. }
  29678. // ClearField clears the value of the field with the given name. It returns an
  29679. // error if the field is not defined in the schema.
  29680. func (m *WxCardMutation) ClearField(name string) error {
  29681. switch name {
  29682. case wxcard.FieldDeletedAt:
  29683. m.ClearDeletedAt()
  29684. return nil
  29685. case wxcard.FieldUserID:
  29686. m.ClearUserID()
  29687. return nil
  29688. case wxcard.FieldWxUserID:
  29689. m.ClearWxUserID()
  29690. return nil
  29691. case wxcard.FieldEmail:
  29692. m.ClearEmail()
  29693. return nil
  29694. case wxcard.FieldAPIBase:
  29695. m.ClearAPIBase()
  29696. return nil
  29697. case wxcard.FieldAPIKey:
  29698. m.ClearAPIKey()
  29699. return nil
  29700. case wxcard.FieldAiInfo:
  29701. m.ClearAiInfo()
  29702. return nil
  29703. case wxcard.FieldIntro:
  29704. m.ClearIntro()
  29705. return nil
  29706. }
  29707. return fmt.Errorf("unknown WxCard nullable field %s", name)
  29708. }
  29709. // ResetField resets all changes in the mutation for the field with the given name.
  29710. // It returns an error if the field is not defined in the schema.
  29711. func (m *WxCardMutation) ResetField(name string) error {
  29712. switch name {
  29713. case wxcard.FieldCreatedAt:
  29714. m.ResetCreatedAt()
  29715. return nil
  29716. case wxcard.FieldUpdatedAt:
  29717. m.ResetUpdatedAt()
  29718. return nil
  29719. case wxcard.FieldDeletedAt:
  29720. m.ResetDeletedAt()
  29721. return nil
  29722. case wxcard.FieldUserID:
  29723. m.ResetUserID()
  29724. return nil
  29725. case wxcard.FieldWxUserID:
  29726. m.ResetWxUserID()
  29727. return nil
  29728. case wxcard.FieldAvatar:
  29729. m.ResetAvatar()
  29730. return nil
  29731. case wxcard.FieldLogo:
  29732. m.ResetLogo()
  29733. return nil
  29734. case wxcard.FieldName:
  29735. m.ResetName()
  29736. return nil
  29737. case wxcard.FieldCompany:
  29738. m.ResetCompany()
  29739. return nil
  29740. case wxcard.FieldAddress:
  29741. m.ResetAddress()
  29742. return nil
  29743. case wxcard.FieldPhone:
  29744. m.ResetPhone()
  29745. return nil
  29746. case wxcard.FieldOfficialAccount:
  29747. m.ResetOfficialAccount()
  29748. return nil
  29749. case wxcard.FieldWechatAccount:
  29750. m.ResetWechatAccount()
  29751. return nil
  29752. case wxcard.FieldEmail:
  29753. m.ResetEmail()
  29754. return nil
  29755. case wxcard.FieldAPIBase:
  29756. m.ResetAPIBase()
  29757. return nil
  29758. case wxcard.FieldAPIKey:
  29759. m.ResetAPIKey()
  29760. return nil
  29761. case wxcard.FieldAiInfo:
  29762. m.ResetAiInfo()
  29763. return nil
  29764. case wxcard.FieldIntro:
  29765. m.ResetIntro()
  29766. return nil
  29767. }
  29768. return fmt.Errorf("unknown WxCard field %s", name)
  29769. }
  29770. // AddedEdges returns all edge names that were set/added in this mutation.
  29771. func (m *WxCardMutation) AddedEdges() []string {
  29772. edges := make([]string, 0, 0)
  29773. return edges
  29774. }
  29775. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29776. // name in this mutation.
  29777. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  29778. return nil
  29779. }
  29780. // RemovedEdges returns all edge names that were removed in this mutation.
  29781. func (m *WxCardMutation) RemovedEdges() []string {
  29782. edges := make([]string, 0, 0)
  29783. return edges
  29784. }
  29785. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29786. // the given name in this mutation.
  29787. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  29788. return nil
  29789. }
  29790. // ClearedEdges returns all edge names that were cleared in this mutation.
  29791. func (m *WxCardMutation) ClearedEdges() []string {
  29792. edges := make([]string, 0, 0)
  29793. return edges
  29794. }
  29795. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29796. // was cleared in this mutation.
  29797. func (m *WxCardMutation) EdgeCleared(name string) bool {
  29798. return false
  29799. }
  29800. // ClearEdge clears the value of the edge with the given name. It returns an error
  29801. // if that edge is not defined in the schema.
  29802. func (m *WxCardMutation) ClearEdge(name string) error {
  29803. return fmt.Errorf("unknown WxCard unique edge %s", name)
  29804. }
  29805. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29806. // It returns an error if the edge is not defined in the schema.
  29807. func (m *WxCardMutation) ResetEdge(name string) error {
  29808. return fmt.Errorf("unknown WxCard edge %s", name)
  29809. }
  29810. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  29811. type WxCardUserMutation struct {
  29812. config
  29813. op Op
  29814. typ string
  29815. id *uint64
  29816. created_at *time.Time
  29817. updated_at *time.Time
  29818. deleted_at *time.Time
  29819. wxid *string
  29820. account *string
  29821. avatar *string
  29822. nickname *string
  29823. remark *string
  29824. phone *string
  29825. open_id *string
  29826. union_id *string
  29827. session_key *string
  29828. is_vip *int
  29829. addis_vip *int
  29830. clearedFields map[string]struct{}
  29831. done bool
  29832. oldValue func(context.Context) (*WxCardUser, error)
  29833. predicates []predicate.WxCardUser
  29834. }
  29835. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  29836. // wxcarduserOption allows management of the mutation configuration using functional options.
  29837. type wxcarduserOption func(*WxCardUserMutation)
  29838. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  29839. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  29840. m := &WxCardUserMutation{
  29841. config: c,
  29842. op: op,
  29843. typ: TypeWxCardUser,
  29844. clearedFields: make(map[string]struct{}),
  29845. }
  29846. for _, opt := range opts {
  29847. opt(m)
  29848. }
  29849. return m
  29850. }
  29851. // withWxCardUserID sets the ID field of the mutation.
  29852. func withWxCardUserID(id uint64) wxcarduserOption {
  29853. return func(m *WxCardUserMutation) {
  29854. var (
  29855. err error
  29856. once sync.Once
  29857. value *WxCardUser
  29858. )
  29859. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  29860. once.Do(func() {
  29861. if m.done {
  29862. err = errors.New("querying old values post mutation is not allowed")
  29863. } else {
  29864. value, err = m.Client().WxCardUser.Get(ctx, id)
  29865. }
  29866. })
  29867. return value, err
  29868. }
  29869. m.id = &id
  29870. }
  29871. }
  29872. // withWxCardUser sets the old WxCardUser of the mutation.
  29873. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  29874. return func(m *WxCardUserMutation) {
  29875. m.oldValue = func(context.Context) (*WxCardUser, error) {
  29876. return node, nil
  29877. }
  29878. m.id = &node.ID
  29879. }
  29880. }
  29881. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29882. // executed in a transaction (ent.Tx), a transactional client is returned.
  29883. func (m WxCardUserMutation) Client() *Client {
  29884. client := &Client{config: m.config}
  29885. client.init()
  29886. return client
  29887. }
  29888. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29889. // it returns an error otherwise.
  29890. func (m WxCardUserMutation) Tx() (*Tx, error) {
  29891. if _, ok := m.driver.(*txDriver); !ok {
  29892. return nil, errors.New("ent: mutation is not running in a transaction")
  29893. }
  29894. tx := &Tx{config: m.config}
  29895. tx.init()
  29896. return tx, nil
  29897. }
  29898. // SetID sets the value of the id field. Note that this
  29899. // operation is only accepted on creation of WxCardUser entities.
  29900. func (m *WxCardUserMutation) SetID(id uint64) {
  29901. m.id = &id
  29902. }
  29903. // ID returns the ID value in the mutation. Note that the ID is only available
  29904. // if it was provided to the builder or after it was returned from the database.
  29905. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  29906. if m.id == nil {
  29907. return
  29908. }
  29909. return *m.id, true
  29910. }
  29911. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29912. // That means, if the mutation is applied within a transaction with an isolation level such
  29913. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29914. // or updated by the mutation.
  29915. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  29916. switch {
  29917. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29918. id, exists := m.ID()
  29919. if exists {
  29920. return []uint64{id}, nil
  29921. }
  29922. fallthrough
  29923. case m.op.Is(OpUpdate | OpDelete):
  29924. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  29925. default:
  29926. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29927. }
  29928. }
  29929. // SetCreatedAt sets the "created_at" field.
  29930. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  29931. m.created_at = &t
  29932. }
  29933. // CreatedAt returns the value of the "created_at" field in the mutation.
  29934. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  29935. v := m.created_at
  29936. if v == nil {
  29937. return
  29938. }
  29939. return *v, true
  29940. }
  29941. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  29942. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  29943. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29944. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29945. if !m.op.Is(OpUpdateOne) {
  29946. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29947. }
  29948. if m.id == nil || m.oldValue == nil {
  29949. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29950. }
  29951. oldValue, err := m.oldValue(ctx)
  29952. if err != nil {
  29953. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29954. }
  29955. return oldValue.CreatedAt, nil
  29956. }
  29957. // ResetCreatedAt resets all changes to the "created_at" field.
  29958. func (m *WxCardUserMutation) ResetCreatedAt() {
  29959. m.created_at = nil
  29960. }
  29961. // SetUpdatedAt sets the "updated_at" field.
  29962. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  29963. m.updated_at = &t
  29964. }
  29965. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29966. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  29967. v := m.updated_at
  29968. if v == nil {
  29969. return
  29970. }
  29971. return *v, true
  29972. }
  29973. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  29974. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  29975. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29976. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29977. if !m.op.Is(OpUpdateOne) {
  29978. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29979. }
  29980. if m.id == nil || m.oldValue == nil {
  29981. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29982. }
  29983. oldValue, err := m.oldValue(ctx)
  29984. if err != nil {
  29985. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29986. }
  29987. return oldValue.UpdatedAt, nil
  29988. }
  29989. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29990. func (m *WxCardUserMutation) ResetUpdatedAt() {
  29991. m.updated_at = nil
  29992. }
  29993. // SetDeletedAt sets the "deleted_at" field.
  29994. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  29995. m.deleted_at = &t
  29996. }
  29997. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  29998. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  29999. v := m.deleted_at
  30000. if v == nil {
  30001. return
  30002. }
  30003. return *v, true
  30004. }
  30005. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  30006. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  30007. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30008. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  30009. if !m.op.Is(OpUpdateOne) {
  30010. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  30011. }
  30012. if m.id == nil || m.oldValue == nil {
  30013. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  30014. }
  30015. oldValue, err := m.oldValue(ctx)
  30016. if err != nil {
  30017. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  30018. }
  30019. return oldValue.DeletedAt, nil
  30020. }
  30021. // ClearDeletedAt clears the value of the "deleted_at" field.
  30022. func (m *WxCardUserMutation) ClearDeletedAt() {
  30023. m.deleted_at = nil
  30024. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  30025. }
  30026. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  30027. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  30028. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  30029. return ok
  30030. }
  30031. // ResetDeletedAt resets all changes to the "deleted_at" field.
  30032. func (m *WxCardUserMutation) ResetDeletedAt() {
  30033. m.deleted_at = nil
  30034. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  30035. }
  30036. // SetWxid sets the "wxid" field.
  30037. func (m *WxCardUserMutation) SetWxid(s string) {
  30038. m.wxid = &s
  30039. }
  30040. // Wxid returns the value of the "wxid" field in the mutation.
  30041. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  30042. v := m.wxid
  30043. if v == nil {
  30044. return
  30045. }
  30046. return *v, true
  30047. }
  30048. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  30049. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  30050. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30051. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  30052. if !m.op.Is(OpUpdateOne) {
  30053. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  30054. }
  30055. if m.id == nil || m.oldValue == nil {
  30056. return v, errors.New("OldWxid requires an ID field in the mutation")
  30057. }
  30058. oldValue, err := m.oldValue(ctx)
  30059. if err != nil {
  30060. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  30061. }
  30062. return oldValue.Wxid, nil
  30063. }
  30064. // ResetWxid resets all changes to the "wxid" field.
  30065. func (m *WxCardUserMutation) ResetWxid() {
  30066. m.wxid = nil
  30067. }
  30068. // SetAccount sets the "account" field.
  30069. func (m *WxCardUserMutation) SetAccount(s string) {
  30070. m.account = &s
  30071. }
  30072. // Account returns the value of the "account" field in the mutation.
  30073. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  30074. v := m.account
  30075. if v == nil {
  30076. return
  30077. }
  30078. return *v, true
  30079. }
  30080. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  30081. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  30082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30083. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  30084. if !m.op.Is(OpUpdateOne) {
  30085. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  30086. }
  30087. if m.id == nil || m.oldValue == nil {
  30088. return v, errors.New("OldAccount requires an ID field in the mutation")
  30089. }
  30090. oldValue, err := m.oldValue(ctx)
  30091. if err != nil {
  30092. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  30093. }
  30094. return oldValue.Account, nil
  30095. }
  30096. // ResetAccount resets all changes to the "account" field.
  30097. func (m *WxCardUserMutation) ResetAccount() {
  30098. m.account = nil
  30099. }
  30100. // SetAvatar sets the "avatar" field.
  30101. func (m *WxCardUserMutation) SetAvatar(s string) {
  30102. m.avatar = &s
  30103. }
  30104. // Avatar returns the value of the "avatar" field in the mutation.
  30105. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  30106. v := m.avatar
  30107. if v == nil {
  30108. return
  30109. }
  30110. return *v, true
  30111. }
  30112. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  30113. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  30114. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30115. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  30116. if !m.op.Is(OpUpdateOne) {
  30117. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  30118. }
  30119. if m.id == nil || m.oldValue == nil {
  30120. return v, errors.New("OldAvatar requires an ID field in the mutation")
  30121. }
  30122. oldValue, err := m.oldValue(ctx)
  30123. if err != nil {
  30124. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  30125. }
  30126. return oldValue.Avatar, nil
  30127. }
  30128. // ResetAvatar resets all changes to the "avatar" field.
  30129. func (m *WxCardUserMutation) ResetAvatar() {
  30130. m.avatar = nil
  30131. }
  30132. // SetNickname sets the "nickname" field.
  30133. func (m *WxCardUserMutation) SetNickname(s string) {
  30134. m.nickname = &s
  30135. }
  30136. // Nickname returns the value of the "nickname" field in the mutation.
  30137. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  30138. v := m.nickname
  30139. if v == nil {
  30140. return
  30141. }
  30142. return *v, true
  30143. }
  30144. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  30145. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  30146. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30147. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  30148. if !m.op.Is(OpUpdateOne) {
  30149. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  30150. }
  30151. if m.id == nil || m.oldValue == nil {
  30152. return v, errors.New("OldNickname requires an ID field in the mutation")
  30153. }
  30154. oldValue, err := m.oldValue(ctx)
  30155. if err != nil {
  30156. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  30157. }
  30158. return oldValue.Nickname, nil
  30159. }
  30160. // ResetNickname resets all changes to the "nickname" field.
  30161. func (m *WxCardUserMutation) ResetNickname() {
  30162. m.nickname = nil
  30163. }
  30164. // SetRemark sets the "remark" field.
  30165. func (m *WxCardUserMutation) SetRemark(s string) {
  30166. m.remark = &s
  30167. }
  30168. // Remark returns the value of the "remark" field in the mutation.
  30169. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  30170. v := m.remark
  30171. if v == nil {
  30172. return
  30173. }
  30174. return *v, true
  30175. }
  30176. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  30177. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  30178. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30179. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  30180. if !m.op.Is(OpUpdateOne) {
  30181. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  30182. }
  30183. if m.id == nil || m.oldValue == nil {
  30184. return v, errors.New("OldRemark requires an ID field in the mutation")
  30185. }
  30186. oldValue, err := m.oldValue(ctx)
  30187. if err != nil {
  30188. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  30189. }
  30190. return oldValue.Remark, nil
  30191. }
  30192. // ResetRemark resets all changes to the "remark" field.
  30193. func (m *WxCardUserMutation) ResetRemark() {
  30194. m.remark = nil
  30195. }
  30196. // SetPhone sets the "phone" field.
  30197. func (m *WxCardUserMutation) SetPhone(s string) {
  30198. m.phone = &s
  30199. }
  30200. // Phone returns the value of the "phone" field in the mutation.
  30201. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  30202. v := m.phone
  30203. if v == nil {
  30204. return
  30205. }
  30206. return *v, true
  30207. }
  30208. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  30209. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  30210. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30211. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  30212. if !m.op.Is(OpUpdateOne) {
  30213. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  30214. }
  30215. if m.id == nil || m.oldValue == nil {
  30216. return v, errors.New("OldPhone requires an ID field in the mutation")
  30217. }
  30218. oldValue, err := m.oldValue(ctx)
  30219. if err != nil {
  30220. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  30221. }
  30222. return oldValue.Phone, nil
  30223. }
  30224. // ResetPhone resets all changes to the "phone" field.
  30225. func (m *WxCardUserMutation) ResetPhone() {
  30226. m.phone = nil
  30227. }
  30228. // SetOpenID sets the "open_id" field.
  30229. func (m *WxCardUserMutation) SetOpenID(s string) {
  30230. m.open_id = &s
  30231. }
  30232. // OpenID returns the value of the "open_id" field in the mutation.
  30233. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  30234. v := m.open_id
  30235. if v == nil {
  30236. return
  30237. }
  30238. return *v, true
  30239. }
  30240. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  30241. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  30242. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30243. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  30244. if !m.op.Is(OpUpdateOne) {
  30245. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  30246. }
  30247. if m.id == nil || m.oldValue == nil {
  30248. return v, errors.New("OldOpenID requires an ID field in the mutation")
  30249. }
  30250. oldValue, err := m.oldValue(ctx)
  30251. if err != nil {
  30252. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  30253. }
  30254. return oldValue.OpenID, nil
  30255. }
  30256. // ResetOpenID resets all changes to the "open_id" field.
  30257. func (m *WxCardUserMutation) ResetOpenID() {
  30258. m.open_id = nil
  30259. }
  30260. // SetUnionID sets the "union_id" field.
  30261. func (m *WxCardUserMutation) SetUnionID(s string) {
  30262. m.union_id = &s
  30263. }
  30264. // UnionID returns the value of the "union_id" field in the mutation.
  30265. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  30266. v := m.union_id
  30267. if v == nil {
  30268. return
  30269. }
  30270. return *v, true
  30271. }
  30272. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  30273. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  30274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30275. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  30276. if !m.op.Is(OpUpdateOne) {
  30277. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  30278. }
  30279. if m.id == nil || m.oldValue == nil {
  30280. return v, errors.New("OldUnionID requires an ID field in the mutation")
  30281. }
  30282. oldValue, err := m.oldValue(ctx)
  30283. if err != nil {
  30284. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  30285. }
  30286. return oldValue.UnionID, nil
  30287. }
  30288. // ResetUnionID resets all changes to the "union_id" field.
  30289. func (m *WxCardUserMutation) ResetUnionID() {
  30290. m.union_id = nil
  30291. }
  30292. // SetSessionKey sets the "session_key" field.
  30293. func (m *WxCardUserMutation) SetSessionKey(s string) {
  30294. m.session_key = &s
  30295. }
  30296. // SessionKey returns the value of the "session_key" field in the mutation.
  30297. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  30298. v := m.session_key
  30299. if v == nil {
  30300. return
  30301. }
  30302. return *v, true
  30303. }
  30304. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  30305. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  30306. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30307. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  30308. if !m.op.Is(OpUpdateOne) {
  30309. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  30310. }
  30311. if m.id == nil || m.oldValue == nil {
  30312. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  30313. }
  30314. oldValue, err := m.oldValue(ctx)
  30315. if err != nil {
  30316. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  30317. }
  30318. return oldValue.SessionKey, nil
  30319. }
  30320. // ResetSessionKey resets all changes to the "session_key" field.
  30321. func (m *WxCardUserMutation) ResetSessionKey() {
  30322. m.session_key = nil
  30323. }
  30324. // SetIsVip sets the "is_vip" field.
  30325. func (m *WxCardUserMutation) SetIsVip(i int) {
  30326. m.is_vip = &i
  30327. m.addis_vip = nil
  30328. }
  30329. // IsVip returns the value of the "is_vip" field in the mutation.
  30330. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  30331. v := m.is_vip
  30332. if v == nil {
  30333. return
  30334. }
  30335. return *v, true
  30336. }
  30337. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  30338. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  30339. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30340. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  30341. if !m.op.Is(OpUpdateOne) {
  30342. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  30343. }
  30344. if m.id == nil || m.oldValue == nil {
  30345. return v, errors.New("OldIsVip requires an ID field in the mutation")
  30346. }
  30347. oldValue, err := m.oldValue(ctx)
  30348. if err != nil {
  30349. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  30350. }
  30351. return oldValue.IsVip, nil
  30352. }
  30353. // AddIsVip adds i to the "is_vip" field.
  30354. func (m *WxCardUserMutation) AddIsVip(i int) {
  30355. if m.addis_vip != nil {
  30356. *m.addis_vip += i
  30357. } else {
  30358. m.addis_vip = &i
  30359. }
  30360. }
  30361. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  30362. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  30363. v := m.addis_vip
  30364. if v == nil {
  30365. return
  30366. }
  30367. return *v, true
  30368. }
  30369. // ResetIsVip resets all changes to the "is_vip" field.
  30370. func (m *WxCardUserMutation) ResetIsVip() {
  30371. m.is_vip = nil
  30372. m.addis_vip = nil
  30373. }
  30374. // Where appends a list predicates to the WxCardUserMutation builder.
  30375. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  30376. m.predicates = append(m.predicates, ps...)
  30377. }
  30378. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  30379. // users can use type-assertion to append predicates that do not depend on any generated package.
  30380. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  30381. p := make([]predicate.WxCardUser, len(ps))
  30382. for i := range ps {
  30383. p[i] = ps[i]
  30384. }
  30385. m.Where(p...)
  30386. }
  30387. // Op returns the operation name.
  30388. func (m *WxCardUserMutation) Op() Op {
  30389. return m.op
  30390. }
  30391. // SetOp allows setting the mutation operation.
  30392. func (m *WxCardUserMutation) SetOp(op Op) {
  30393. m.op = op
  30394. }
  30395. // Type returns the node type of this mutation (WxCardUser).
  30396. func (m *WxCardUserMutation) Type() string {
  30397. return m.typ
  30398. }
  30399. // Fields returns all fields that were changed during this mutation. Note that in
  30400. // order to get all numeric fields that were incremented/decremented, call
  30401. // AddedFields().
  30402. func (m *WxCardUserMutation) Fields() []string {
  30403. fields := make([]string, 0, 13)
  30404. if m.created_at != nil {
  30405. fields = append(fields, wxcarduser.FieldCreatedAt)
  30406. }
  30407. if m.updated_at != nil {
  30408. fields = append(fields, wxcarduser.FieldUpdatedAt)
  30409. }
  30410. if m.deleted_at != nil {
  30411. fields = append(fields, wxcarduser.FieldDeletedAt)
  30412. }
  30413. if m.wxid != nil {
  30414. fields = append(fields, wxcarduser.FieldWxid)
  30415. }
  30416. if m.account != nil {
  30417. fields = append(fields, wxcarduser.FieldAccount)
  30418. }
  30419. if m.avatar != nil {
  30420. fields = append(fields, wxcarduser.FieldAvatar)
  30421. }
  30422. if m.nickname != nil {
  30423. fields = append(fields, wxcarduser.FieldNickname)
  30424. }
  30425. if m.remark != nil {
  30426. fields = append(fields, wxcarduser.FieldRemark)
  30427. }
  30428. if m.phone != nil {
  30429. fields = append(fields, wxcarduser.FieldPhone)
  30430. }
  30431. if m.open_id != nil {
  30432. fields = append(fields, wxcarduser.FieldOpenID)
  30433. }
  30434. if m.union_id != nil {
  30435. fields = append(fields, wxcarduser.FieldUnionID)
  30436. }
  30437. if m.session_key != nil {
  30438. fields = append(fields, wxcarduser.FieldSessionKey)
  30439. }
  30440. if m.is_vip != nil {
  30441. fields = append(fields, wxcarduser.FieldIsVip)
  30442. }
  30443. return fields
  30444. }
  30445. // Field returns the value of a field with the given name. The second boolean
  30446. // return value indicates that this field was not set, or was not defined in the
  30447. // schema.
  30448. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  30449. switch name {
  30450. case wxcarduser.FieldCreatedAt:
  30451. return m.CreatedAt()
  30452. case wxcarduser.FieldUpdatedAt:
  30453. return m.UpdatedAt()
  30454. case wxcarduser.FieldDeletedAt:
  30455. return m.DeletedAt()
  30456. case wxcarduser.FieldWxid:
  30457. return m.Wxid()
  30458. case wxcarduser.FieldAccount:
  30459. return m.Account()
  30460. case wxcarduser.FieldAvatar:
  30461. return m.Avatar()
  30462. case wxcarduser.FieldNickname:
  30463. return m.Nickname()
  30464. case wxcarduser.FieldRemark:
  30465. return m.Remark()
  30466. case wxcarduser.FieldPhone:
  30467. return m.Phone()
  30468. case wxcarduser.FieldOpenID:
  30469. return m.OpenID()
  30470. case wxcarduser.FieldUnionID:
  30471. return m.UnionID()
  30472. case wxcarduser.FieldSessionKey:
  30473. return m.SessionKey()
  30474. case wxcarduser.FieldIsVip:
  30475. return m.IsVip()
  30476. }
  30477. return nil, false
  30478. }
  30479. // OldField returns the old value of the field from the database. An error is
  30480. // returned if the mutation operation is not UpdateOne, or the query to the
  30481. // database failed.
  30482. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30483. switch name {
  30484. case wxcarduser.FieldCreatedAt:
  30485. return m.OldCreatedAt(ctx)
  30486. case wxcarduser.FieldUpdatedAt:
  30487. return m.OldUpdatedAt(ctx)
  30488. case wxcarduser.FieldDeletedAt:
  30489. return m.OldDeletedAt(ctx)
  30490. case wxcarduser.FieldWxid:
  30491. return m.OldWxid(ctx)
  30492. case wxcarduser.FieldAccount:
  30493. return m.OldAccount(ctx)
  30494. case wxcarduser.FieldAvatar:
  30495. return m.OldAvatar(ctx)
  30496. case wxcarduser.FieldNickname:
  30497. return m.OldNickname(ctx)
  30498. case wxcarduser.FieldRemark:
  30499. return m.OldRemark(ctx)
  30500. case wxcarduser.FieldPhone:
  30501. return m.OldPhone(ctx)
  30502. case wxcarduser.FieldOpenID:
  30503. return m.OldOpenID(ctx)
  30504. case wxcarduser.FieldUnionID:
  30505. return m.OldUnionID(ctx)
  30506. case wxcarduser.FieldSessionKey:
  30507. return m.OldSessionKey(ctx)
  30508. case wxcarduser.FieldIsVip:
  30509. return m.OldIsVip(ctx)
  30510. }
  30511. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  30512. }
  30513. // SetField sets the value of a field with the given name. It returns an error if
  30514. // the field is not defined in the schema, or if the type mismatched the field
  30515. // type.
  30516. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  30517. switch name {
  30518. case wxcarduser.FieldCreatedAt:
  30519. v, ok := value.(time.Time)
  30520. if !ok {
  30521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30522. }
  30523. m.SetCreatedAt(v)
  30524. return nil
  30525. case wxcarduser.FieldUpdatedAt:
  30526. v, ok := value.(time.Time)
  30527. if !ok {
  30528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30529. }
  30530. m.SetUpdatedAt(v)
  30531. return nil
  30532. case wxcarduser.FieldDeletedAt:
  30533. v, ok := value.(time.Time)
  30534. if !ok {
  30535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30536. }
  30537. m.SetDeletedAt(v)
  30538. return nil
  30539. case wxcarduser.FieldWxid:
  30540. v, ok := value.(string)
  30541. if !ok {
  30542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30543. }
  30544. m.SetWxid(v)
  30545. return nil
  30546. case wxcarduser.FieldAccount:
  30547. v, ok := value.(string)
  30548. if !ok {
  30549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30550. }
  30551. m.SetAccount(v)
  30552. return nil
  30553. case wxcarduser.FieldAvatar:
  30554. v, ok := value.(string)
  30555. if !ok {
  30556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30557. }
  30558. m.SetAvatar(v)
  30559. return nil
  30560. case wxcarduser.FieldNickname:
  30561. v, ok := value.(string)
  30562. if !ok {
  30563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30564. }
  30565. m.SetNickname(v)
  30566. return nil
  30567. case wxcarduser.FieldRemark:
  30568. v, ok := value.(string)
  30569. if !ok {
  30570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30571. }
  30572. m.SetRemark(v)
  30573. return nil
  30574. case wxcarduser.FieldPhone:
  30575. v, ok := value.(string)
  30576. if !ok {
  30577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30578. }
  30579. m.SetPhone(v)
  30580. return nil
  30581. case wxcarduser.FieldOpenID:
  30582. v, ok := value.(string)
  30583. if !ok {
  30584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30585. }
  30586. m.SetOpenID(v)
  30587. return nil
  30588. case wxcarduser.FieldUnionID:
  30589. v, ok := value.(string)
  30590. if !ok {
  30591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30592. }
  30593. m.SetUnionID(v)
  30594. return nil
  30595. case wxcarduser.FieldSessionKey:
  30596. v, ok := value.(string)
  30597. if !ok {
  30598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30599. }
  30600. m.SetSessionKey(v)
  30601. return nil
  30602. case wxcarduser.FieldIsVip:
  30603. v, ok := value.(int)
  30604. if !ok {
  30605. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30606. }
  30607. m.SetIsVip(v)
  30608. return nil
  30609. }
  30610. return fmt.Errorf("unknown WxCardUser field %s", name)
  30611. }
  30612. // AddedFields returns all numeric fields that were incremented/decremented during
  30613. // this mutation.
  30614. func (m *WxCardUserMutation) AddedFields() []string {
  30615. var fields []string
  30616. if m.addis_vip != nil {
  30617. fields = append(fields, wxcarduser.FieldIsVip)
  30618. }
  30619. return fields
  30620. }
  30621. // AddedField returns the numeric value that was incremented/decremented on a field
  30622. // with the given name. The second boolean return value indicates that this field
  30623. // was not set, or was not defined in the schema.
  30624. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  30625. switch name {
  30626. case wxcarduser.FieldIsVip:
  30627. return m.AddedIsVip()
  30628. }
  30629. return nil, false
  30630. }
  30631. // AddField adds the value to the field with the given name. It returns an error if
  30632. // the field is not defined in the schema, or if the type mismatched the field
  30633. // type.
  30634. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  30635. switch name {
  30636. case wxcarduser.FieldIsVip:
  30637. v, ok := value.(int)
  30638. if !ok {
  30639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30640. }
  30641. m.AddIsVip(v)
  30642. return nil
  30643. }
  30644. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  30645. }
  30646. // ClearedFields returns all nullable fields that were cleared during this
  30647. // mutation.
  30648. func (m *WxCardUserMutation) ClearedFields() []string {
  30649. var fields []string
  30650. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  30651. fields = append(fields, wxcarduser.FieldDeletedAt)
  30652. }
  30653. return fields
  30654. }
  30655. // FieldCleared returns a boolean indicating if a field with the given name was
  30656. // cleared in this mutation.
  30657. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  30658. _, ok := m.clearedFields[name]
  30659. return ok
  30660. }
  30661. // ClearField clears the value of the field with the given name. It returns an
  30662. // error if the field is not defined in the schema.
  30663. func (m *WxCardUserMutation) ClearField(name string) error {
  30664. switch name {
  30665. case wxcarduser.FieldDeletedAt:
  30666. m.ClearDeletedAt()
  30667. return nil
  30668. }
  30669. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  30670. }
  30671. // ResetField resets all changes in the mutation for the field with the given name.
  30672. // It returns an error if the field is not defined in the schema.
  30673. func (m *WxCardUserMutation) ResetField(name string) error {
  30674. switch name {
  30675. case wxcarduser.FieldCreatedAt:
  30676. m.ResetCreatedAt()
  30677. return nil
  30678. case wxcarduser.FieldUpdatedAt:
  30679. m.ResetUpdatedAt()
  30680. return nil
  30681. case wxcarduser.FieldDeletedAt:
  30682. m.ResetDeletedAt()
  30683. return nil
  30684. case wxcarduser.FieldWxid:
  30685. m.ResetWxid()
  30686. return nil
  30687. case wxcarduser.FieldAccount:
  30688. m.ResetAccount()
  30689. return nil
  30690. case wxcarduser.FieldAvatar:
  30691. m.ResetAvatar()
  30692. return nil
  30693. case wxcarduser.FieldNickname:
  30694. m.ResetNickname()
  30695. return nil
  30696. case wxcarduser.FieldRemark:
  30697. m.ResetRemark()
  30698. return nil
  30699. case wxcarduser.FieldPhone:
  30700. m.ResetPhone()
  30701. return nil
  30702. case wxcarduser.FieldOpenID:
  30703. m.ResetOpenID()
  30704. return nil
  30705. case wxcarduser.FieldUnionID:
  30706. m.ResetUnionID()
  30707. return nil
  30708. case wxcarduser.FieldSessionKey:
  30709. m.ResetSessionKey()
  30710. return nil
  30711. case wxcarduser.FieldIsVip:
  30712. m.ResetIsVip()
  30713. return nil
  30714. }
  30715. return fmt.Errorf("unknown WxCardUser field %s", name)
  30716. }
  30717. // AddedEdges returns all edge names that were set/added in this mutation.
  30718. func (m *WxCardUserMutation) AddedEdges() []string {
  30719. edges := make([]string, 0, 0)
  30720. return edges
  30721. }
  30722. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30723. // name in this mutation.
  30724. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  30725. return nil
  30726. }
  30727. // RemovedEdges returns all edge names that were removed in this mutation.
  30728. func (m *WxCardUserMutation) RemovedEdges() []string {
  30729. edges := make([]string, 0, 0)
  30730. return edges
  30731. }
  30732. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30733. // the given name in this mutation.
  30734. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  30735. return nil
  30736. }
  30737. // ClearedEdges returns all edge names that were cleared in this mutation.
  30738. func (m *WxCardUserMutation) ClearedEdges() []string {
  30739. edges := make([]string, 0, 0)
  30740. return edges
  30741. }
  30742. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30743. // was cleared in this mutation.
  30744. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  30745. return false
  30746. }
  30747. // ClearEdge clears the value of the edge with the given name. It returns an error
  30748. // if that edge is not defined in the schema.
  30749. func (m *WxCardUserMutation) ClearEdge(name string) error {
  30750. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  30751. }
  30752. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30753. // It returns an error if the edge is not defined in the schema.
  30754. func (m *WxCardUserMutation) ResetEdge(name string) error {
  30755. return fmt.Errorf("unknown WxCardUser edge %s", name)
  30756. }
  30757. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  30758. type WxCardVisitMutation struct {
  30759. config
  30760. op Op
  30761. typ string
  30762. id *uint64
  30763. created_at *time.Time
  30764. updated_at *time.Time
  30765. deleted_at *time.Time
  30766. user_id *uint64
  30767. adduser_id *int64
  30768. bot_id *uint64
  30769. addbot_id *int64
  30770. bot_type *uint8
  30771. addbot_type *int8
  30772. clearedFields map[string]struct{}
  30773. done bool
  30774. oldValue func(context.Context) (*WxCardVisit, error)
  30775. predicates []predicate.WxCardVisit
  30776. }
  30777. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  30778. // wxcardvisitOption allows management of the mutation configuration using functional options.
  30779. type wxcardvisitOption func(*WxCardVisitMutation)
  30780. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  30781. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  30782. m := &WxCardVisitMutation{
  30783. config: c,
  30784. op: op,
  30785. typ: TypeWxCardVisit,
  30786. clearedFields: make(map[string]struct{}),
  30787. }
  30788. for _, opt := range opts {
  30789. opt(m)
  30790. }
  30791. return m
  30792. }
  30793. // withWxCardVisitID sets the ID field of the mutation.
  30794. func withWxCardVisitID(id uint64) wxcardvisitOption {
  30795. return func(m *WxCardVisitMutation) {
  30796. var (
  30797. err error
  30798. once sync.Once
  30799. value *WxCardVisit
  30800. )
  30801. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  30802. once.Do(func() {
  30803. if m.done {
  30804. err = errors.New("querying old values post mutation is not allowed")
  30805. } else {
  30806. value, err = m.Client().WxCardVisit.Get(ctx, id)
  30807. }
  30808. })
  30809. return value, err
  30810. }
  30811. m.id = &id
  30812. }
  30813. }
  30814. // withWxCardVisit sets the old WxCardVisit of the mutation.
  30815. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  30816. return func(m *WxCardVisitMutation) {
  30817. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  30818. return node, nil
  30819. }
  30820. m.id = &node.ID
  30821. }
  30822. }
  30823. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30824. // executed in a transaction (ent.Tx), a transactional client is returned.
  30825. func (m WxCardVisitMutation) Client() *Client {
  30826. client := &Client{config: m.config}
  30827. client.init()
  30828. return client
  30829. }
  30830. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30831. // it returns an error otherwise.
  30832. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  30833. if _, ok := m.driver.(*txDriver); !ok {
  30834. return nil, errors.New("ent: mutation is not running in a transaction")
  30835. }
  30836. tx := &Tx{config: m.config}
  30837. tx.init()
  30838. return tx, nil
  30839. }
  30840. // SetID sets the value of the id field. Note that this
  30841. // operation is only accepted on creation of WxCardVisit entities.
  30842. func (m *WxCardVisitMutation) SetID(id uint64) {
  30843. m.id = &id
  30844. }
  30845. // ID returns the ID value in the mutation. Note that the ID is only available
  30846. // if it was provided to the builder or after it was returned from the database.
  30847. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  30848. if m.id == nil {
  30849. return
  30850. }
  30851. return *m.id, true
  30852. }
  30853. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30854. // That means, if the mutation is applied within a transaction with an isolation level such
  30855. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30856. // or updated by the mutation.
  30857. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  30858. switch {
  30859. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30860. id, exists := m.ID()
  30861. if exists {
  30862. return []uint64{id}, nil
  30863. }
  30864. fallthrough
  30865. case m.op.Is(OpUpdate | OpDelete):
  30866. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  30867. default:
  30868. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30869. }
  30870. }
  30871. // SetCreatedAt sets the "created_at" field.
  30872. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  30873. m.created_at = &t
  30874. }
  30875. // CreatedAt returns the value of the "created_at" field in the mutation.
  30876. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  30877. v := m.created_at
  30878. if v == nil {
  30879. return
  30880. }
  30881. return *v, true
  30882. }
  30883. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  30884. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  30885. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30886. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30887. if !m.op.Is(OpUpdateOne) {
  30888. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30889. }
  30890. if m.id == nil || m.oldValue == nil {
  30891. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30892. }
  30893. oldValue, err := m.oldValue(ctx)
  30894. if err != nil {
  30895. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30896. }
  30897. return oldValue.CreatedAt, nil
  30898. }
  30899. // ResetCreatedAt resets all changes to the "created_at" field.
  30900. func (m *WxCardVisitMutation) ResetCreatedAt() {
  30901. m.created_at = nil
  30902. }
  30903. // SetUpdatedAt sets the "updated_at" field.
  30904. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  30905. m.updated_at = &t
  30906. }
  30907. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30908. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  30909. v := m.updated_at
  30910. if v == nil {
  30911. return
  30912. }
  30913. return *v, true
  30914. }
  30915. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  30916. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  30917. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30918. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30919. if !m.op.Is(OpUpdateOne) {
  30920. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30921. }
  30922. if m.id == nil || m.oldValue == nil {
  30923. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30924. }
  30925. oldValue, err := m.oldValue(ctx)
  30926. if err != nil {
  30927. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30928. }
  30929. return oldValue.UpdatedAt, nil
  30930. }
  30931. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30932. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  30933. m.updated_at = nil
  30934. }
  30935. // SetDeletedAt sets the "deleted_at" field.
  30936. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  30937. m.deleted_at = &t
  30938. }
  30939. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  30940. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  30941. v := m.deleted_at
  30942. if v == nil {
  30943. return
  30944. }
  30945. return *v, true
  30946. }
  30947. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  30948. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  30949. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30950. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  30951. if !m.op.Is(OpUpdateOne) {
  30952. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  30953. }
  30954. if m.id == nil || m.oldValue == nil {
  30955. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  30956. }
  30957. oldValue, err := m.oldValue(ctx)
  30958. if err != nil {
  30959. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  30960. }
  30961. return oldValue.DeletedAt, nil
  30962. }
  30963. // ClearDeletedAt clears the value of the "deleted_at" field.
  30964. func (m *WxCardVisitMutation) ClearDeletedAt() {
  30965. m.deleted_at = nil
  30966. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  30967. }
  30968. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  30969. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  30970. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  30971. return ok
  30972. }
  30973. // ResetDeletedAt resets all changes to the "deleted_at" field.
  30974. func (m *WxCardVisitMutation) ResetDeletedAt() {
  30975. m.deleted_at = nil
  30976. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  30977. }
  30978. // SetUserID sets the "user_id" field.
  30979. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  30980. m.user_id = &u
  30981. m.adduser_id = nil
  30982. }
  30983. // UserID returns the value of the "user_id" field in the mutation.
  30984. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  30985. v := m.user_id
  30986. if v == nil {
  30987. return
  30988. }
  30989. return *v, true
  30990. }
  30991. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  30992. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  30993. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30994. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  30995. if !m.op.Is(OpUpdateOne) {
  30996. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  30997. }
  30998. if m.id == nil || m.oldValue == nil {
  30999. return v, errors.New("OldUserID requires an ID field in the mutation")
  31000. }
  31001. oldValue, err := m.oldValue(ctx)
  31002. if err != nil {
  31003. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  31004. }
  31005. return oldValue.UserID, nil
  31006. }
  31007. // AddUserID adds u to the "user_id" field.
  31008. func (m *WxCardVisitMutation) AddUserID(u int64) {
  31009. if m.adduser_id != nil {
  31010. *m.adduser_id += u
  31011. } else {
  31012. m.adduser_id = &u
  31013. }
  31014. }
  31015. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  31016. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  31017. v := m.adduser_id
  31018. if v == nil {
  31019. return
  31020. }
  31021. return *v, true
  31022. }
  31023. // ClearUserID clears the value of the "user_id" field.
  31024. func (m *WxCardVisitMutation) ClearUserID() {
  31025. m.user_id = nil
  31026. m.adduser_id = nil
  31027. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  31028. }
  31029. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  31030. func (m *WxCardVisitMutation) UserIDCleared() bool {
  31031. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  31032. return ok
  31033. }
  31034. // ResetUserID resets all changes to the "user_id" field.
  31035. func (m *WxCardVisitMutation) ResetUserID() {
  31036. m.user_id = nil
  31037. m.adduser_id = nil
  31038. delete(m.clearedFields, wxcardvisit.FieldUserID)
  31039. }
  31040. // SetBotID sets the "bot_id" field.
  31041. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  31042. m.bot_id = &u
  31043. m.addbot_id = nil
  31044. }
  31045. // BotID returns the value of the "bot_id" field in the mutation.
  31046. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  31047. v := m.bot_id
  31048. if v == nil {
  31049. return
  31050. }
  31051. return *v, true
  31052. }
  31053. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  31054. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  31055. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31056. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  31057. if !m.op.Is(OpUpdateOne) {
  31058. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  31059. }
  31060. if m.id == nil || m.oldValue == nil {
  31061. return v, errors.New("OldBotID requires an ID field in the mutation")
  31062. }
  31063. oldValue, err := m.oldValue(ctx)
  31064. if err != nil {
  31065. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  31066. }
  31067. return oldValue.BotID, nil
  31068. }
  31069. // AddBotID adds u to the "bot_id" field.
  31070. func (m *WxCardVisitMutation) AddBotID(u int64) {
  31071. if m.addbot_id != nil {
  31072. *m.addbot_id += u
  31073. } else {
  31074. m.addbot_id = &u
  31075. }
  31076. }
  31077. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  31078. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  31079. v := m.addbot_id
  31080. if v == nil {
  31081. return
  31082. }
  31083. return *v, true
  31084. }
  31085. // ResetBotID resets all changes to the "bot_id" field.
  31086. func (m *WxCardVisitMutation) ResetBotID() {
  31087. m.bot_id = nil
  31088. m.addbot_id = nil
  31089. }
  31090. // SetBotType sets the "bot_type" field.
  31091. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  31092. m.bot_type = &u
  31093. m.addbot_type = nil
  31094. }
  31095. // BotType returns the value of the "bot_type" field in the mutation.
  31096. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  31097. v := m.bot_type
  31098. if v == nil {
  31099. return
  31100. }
  31101. return *v, true
  31102. }
  31103. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  31104. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  31105. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31106. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  31107. if !m.op.Is(OpUpdateOne) {
  31108. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  31109. }
  31110. if m.id == nil || m.oldValue == nil {
  31111. return v, errors.New("OldBotType requires an ID field in the mutation")
  31112. }
  31113. oldValue, err := m.oldValue(ctx)
  31114. if err != nil {
  31115. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  31116. }
  31117. return oldValue.BotType, nil
  31118. }
  31119. // AddBotType adds u to the "bot_type" field.
  31120. func (m *WxCardVisitMutation) AddBotType(u int8) {
  31121. if m.addbot_type != nil {
  31122. *m.addbot_type += u
  31123. } else {
  31124. m.addbot_type = &u
  31125. }
  31126. }
  31127. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  31128. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  31129. v := m.addbot_type
  31130. if v == nil {
  31131. return
  31132. }
  31133. return *v, true
  31134. }
  31135. // ResetBotType resets all changes to the "bot_type" field.
  31136. func (m *WxCardVisitMutation) ResetBotType() {
  31137. m.bot_type = nil
  31138. m.addbot_type = nil
  31139. }
  31140. // Where appends a list predicates to the WxCardVisitMutation builder.
  31141. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  31142. m.predicates = append(m.predicates, ps...)
  31143. }
  31144. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  31145. // users can use type-assertion to append predicates that do not depend on any generated package.
  31146. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  31147. p := make([]predicate.WxCardVisit, len(ps))
  31148. for i := range ps {
  31149. p[i] = ps[i]
  31150. }
  31151. m.Where(p...)
  31152. }
  31153. // Op returns the operation name.
  31154. func (m *WxCardVisitMutation) Op() Op {
  31155. return m.op
  31156. }
  31157. // SetOp allows setting the mutation operation.
  31158. func (m *WxCardVisitMutation) SetOp(op Op) {
  31159. m.op = op
  31160. }
  31161. // Type returns the node type of this mutation (WxCardVisit).
  31162. func (m *WxCardVisitMutation) Type() string {
  31163. return m.typ
  31164. }
  31165. // Fields returns all fields that were changed during this mutation. Note that in
  31166. // order to get all numeric fields that were incremented/decremented, call
  31167. // AddedFields().
  31168. func (m *WxCardVisitMutation) Fields() []string {
  31169. fields := make([]string, 0, 6)
  31170. if m.created_at != nil {
  31171. fields = append(fields, wxcardvisit.FieldCreatedAt)
  31172. }
  31173. if m.updated_at != nil {
  31174. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  31175. }
  31176. if m.deleted_at != nil {
  31177. fields = append(fields, wxcardvisit.FieldDeletedAt)
  31178. }
  31179. if m.user_id != nil {
  31180. fields = append(fields, wxcardvisit.FieldUserID)
  31181. }
  31182. if m.bot_id != nil {
  31183. fields = append(fields, wxcardvisit.FieldBotID)
  31184. }
  31185. if m.bot_type != nil {
  31186. fields = append(fields, wxcardvisit.FieldBotType)
  31187. }
  31188. return fields
  31189. }
  31190. // Field returns the value of a field with the given name. The second boolean
  31191. // return value indicates that this field was not set, or was not defined in the
  31192. // schema.
  31193. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  31194. switch name {
  31195. case wxcardvisit.FieldCreatedAt:
  31196. return m.CreatedAt()
  31197. case wxcardvisit.FieldUpdatedAt:
  31198. return m.UpdatedAt()
  31199. case wxcardvisit.FieldDeletedAt:
  31200. return m.DeletedAt()
  31201. case wxcardvisit.FieldUserID:
  31202. return m.UserID()
  31203. case wxcardvisit.FieldBotID:
  31204. return m.BotID()
  31205. case wxcardvisit.FieldBotType:
  31206. return m.BotType()
  31207. }
  31208. return nil, false
  31209. }
  31210. // OldField returns the old value of the field from the database. An error is
  31211. // returned if the mutation operation is not UpdateOne, or the query to the
  31212. // database failed.
  31213. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31214. switch name {
  31215. case wxcardvisit.FieldCreatedAt:
  31216. return m.OldCreatedAt(ctx)
  31217. case wxcardvisit.FieldUpdatedAt:
  31218. return m.OldUpdatedAt(ctx)
  31219. case wxcardvisit.FieldDeletedAt:
  31220. return m.OldDeletedAt(ctx)
  31221. case wxcardvisit.FieldUserID:
  31222. return m.OldUserID(ctx)
  31223. case wxcardvisit.FieldBotID:
  31224. return m.OldBotID(ctx)
  31225. case wxcardvisit.FieldBotType:
  31226. return m.OldBotType(ctx)
  31227. }
  31228. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  31229. }
  31230. // SetField sets the value of a field with the given name. It returns an error if
  31231. // the field is not defined in the schema, or if the type mismatched the field
  31232. // type.
  31233. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  31234. switch name {
  31235. case wxcardvisit.FieldCreatedAt:
  31236. v, ok := value.(time.Time)
  31237. if !ok {
  31238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31239. }
  31240. m.SetCreatedAt(v)
  31241. return nil
  31242. case wxcardvisit.FieldUpdatedAt:
  31243. v, ok := value.(time.Time)
  31244. if !ok {
  31245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31246. }
  31247. m.SetUpdatedAt(v)
  31248. return nil
  31249. case wxcardvisit.FieldDeletedAt:
  31250. v, ok := value.(time.Time)
  31251. if !ok {
  31252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31253. }
  31254. m.SetDeletedAt(v)
  31255. return nil
  31256. case wxcardvisit.FieldUserID:
  31257. v, ok := value.(uint64)
  31258. if !ok {
  31259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31260. }
  31261. m.SetUserID(v)
  31262. return nil
  31263. case wxcardvisit.FieldBotID:
  31264. v, ok := value.(uint64)
  31265. if !ok {
  31266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31267. }
  31268. m.SetBotID(v)
  31269. return nil
  31270. case wxcardvisit.FieldBotType:
  31271. v, ok := value.(uint8)
  31272. if !ok {
  31273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31274. }
  31275. m.SetBotType(v)
  31276. return nil
  31277. }
  31278. return fmt.Errorf("unknown WxCardVisit field %s", name)
  31279. }
  31280. // AddedFields returns all numeric fields that were incremented/decremented during
  31281. // this mutation.
  31282. func (m *WxCardVisitMutation) AddedFields() []string {
  31283. var fields []string
  31284. if m.adduser_id != nil {
  31285. fields = append(fields, wxcardvisit.FieldUserID)
  31286. }
  31287. if m.addbot_id != nil {
  31288. fields = append(fields, wxcardvisit.FieldBotID)
  31289. }
  31290. if m.addbot_type != nil {
  31291. fields = append(fields, wxcardvisit.FieldBotType)
  31292. }
  31293. return fields
  31294. }
  31295. // AddedField returns the numeric value that was incremented/decremented on a field
  31296. // with the given name. The second boolean return value indicates that this field
  31297. // was not set, or was not defined in the schema.
  31298. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  31299. switch name {
  31300. case wxcardvisit.FieldUserID:
  31301. return m.AddedUserID()
  31302. case wxcardvisit.FieldBotID:
  31303. return m.AddedBotID()
  31304. case wxcardvisit.FieldBotType:
  31305. return m.AddedBotType()
  31306. }
  31307. return nil, false
  31308. }
  31309. // AddField adds the value to the field with the given name. It returns an error if
  31310. // the field is not defined in the schema, or if the type mismatched the field
  31311. // type.
  31312. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  31313. switch name {
  31314. case wxcardvisit.FieldUserID:
  31315. v, ok := value.(int64)
  31316. if !ok {
  31317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31318. }
  31319. m.AddUserID(v)
  31320. return nil
  31321. case wxcardvisit.FieldBotID:
  31322. v, ok := value.(int64)
  31323. if !ok {
  31324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31325. }
  31326. m.AddBotID(v)
  31327. return nil
  31328. case wxcardvisit.FieldBotType:
  31329. v, ok := value.(int8)
  31330. if !ok {
  31331. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31332. }
  31333. m.AddBotType(v)
  31334. return nil
  31335. }
  31336. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  31337. }
  31338. // ClearedFields returns all nullable fields that were cleared during this
  31339. // mutation.
  31340. func (m *WxCardVisitMutation) ClearedFields() []string {
  31341. var fields []string
  31342. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  31343. fields = append(fields, wxcardvisit.FieldDeletedAt)
  31344. }
  31345. if m.FieldCleared(wxcardvisit.FieldUserID) {
  31346. fields = append(fields, wxcardvisit.FieldUserID)
  31347. }
  31348. return fields
  31349. }
  31350. // FieldCleared returns a boolean indicating if a field with the given name was
  31351. // cleared in this mutation.
  31352. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  31353. _, ok := m.clearedFields[name]
  31354. return ok
  31355. }
  31356. // ClearField clears the value of the field with the given name. It returns an
  31357. // error if the field is not defined in the schema.
  31358. func (m *WxCardVisitMutation) ClearField(name string) error {
  31359. switch name {
  31360. case wxcardvisit.FieldDeletedAt:
  31361. m.ClearDeletedAt()
  31362. return nil
  31363. case wxcardvisit.FieldUserID:
  31364. m.ClearUserID()
  31365. return nil
  31366. }
  31367. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  31368. }
  31369. // ResetField resets all changes in the mutation for the field with the given name.
  31370. // It returns an error if the field is not defined in the schema.
  31371. func (m *WxCardVisitMutation) ResetField(name string) error {
  31372. switch name {
  31373. case wxcardvisit.FieldCreatedAt:
  31374. m.ResetCreatedAt()
  31375. return nil
  31376. case wxcardvisit.FieldUpdatedAt:
  31377. m.ResetUpdatedAt()
  31378. return nil
  31379. case wxcardvisit.FieldDeletedAt:
  31380. m.ResetDeletedAt()
  31381. return nil
  31382. case wxcardvisit.FieldUserID:
  31383. m.ResetUserID()
  31384. return nil
  31385. case wxcardvisit.FieldBotID:
  31386. m.ResetBotID()
  31387. return nil
  31388. case wxcardvisit.FieldBotType:
  31389. m.ResetBotType()
  31390. return nil
  31391. }
  31392. return fmt.Errorf("unknown WxCardVisit field %s", name)
  31393. }
  31394. // AddedEdges returns all edge names that were set/added in this mutation.
  31395. func (m *WxCardVisitMutation) AddedEdges() []string {
  31396. edges := make([]string, 0, 0)
  31397. return edges
  31398. }
  31399. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31400. // name in this mutation.
  31401. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  31402. return nil
  31403. }
  31404. // RemovedEdges returns all edge names that were removed in this mutation.
  31405. func (m *WxCardVisitMutation) RemovedEdges() []string {
  31406. edges := make([]string, 0, 0)
  31407. return edges
  31408. }
  31409. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31410. // the given name in this mutation.
  31411. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  31412. return nil
  31413. }
  31414. // ClearedEdges returns all edge names that were cleared in this mutation.
  31415. func (m *WxCardVisitMutation) ClearedEdges() []string {
  31416. edges := make([]string, 0, 0)
  31417. return edges
  31418. }
  31419. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31420. // was cleared in this mutation.
  31421. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  31422. return false
  31423. }
  31424. // ClearEdge clears the value of the edge with the given name. It returns an error
  31425. // if that edge is not defined in the schema.
  31426. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  31427. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  31428. }
  31429. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31430. // It returns an error if the edge is not defined in the schema.
  31431. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  31432. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  31433. }