mutation.go 379 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959
  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/batchmsg"
  10. "wechat-api/ent/contact"
  11. "wechat-api/ent/custom_types"
  12. "wechat-api/ent/label"
  13. "wechat-api/ent/labelrelationship"
  14. "wechat-api/ent/message"
  15. "wechat-api/ent/messagerecords"
  16. "wechat-api/ent/predicate"
  17. "wechat-api/ent/server"
  18. "wechat-api/ent/sopnode"
  19. "wechat-api/ent/sopstage"
  20. "wechat-api/ent/soptask"
  21. "wechat-api/ent/wx"
  22. "entgo.io/ent"
  23. "entgo.io/ent/dialect/sql"
  24. )
  25. const (
  26. // Operation types.
  27. OpCreate = ent.OpCreate
  28. OpDelete = ent.OpDelete
  29. OpDeleteOne = ent.OpDeleteOne
  30. OpUpdate = ent.OpUpdate
  31. OpUpdateOne = ent.OpUpdateOne
  32. // Node types.
  33. TypeBatchMsg = "BatchMsg"
  34. TypeContact = "Contact"
  35. TypeLabel = "Label"
  36. TypeLabelRelationship = "LabelRelationship"
  37. TypeMessage = "Message"
  38. TypeMessageRecords = "MessageRecords"
  39. TypeServer = "Server"
  40. TypeSopNode = "SopNode"
  41. TypeSopStage = "SopStage"
  42. TypeSopTask = "SopTask"
  43. TypeWx = "Wx"
  44. )
  45. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  46. type BatchMsgMutation struct {
  47. config
  48. op Op
  49. typ string
  50. id *uint64
  51. created_at *time.Time
  52. updated_at *time.Time
  53. deleted_at *time.Time
  54. status *uint8
  55. addstatus *int8
  56. batch_no *string
  57. fromwxid *string
  58. msg *string
  59. tag *string
  60. total *int32
  61. addtotal *int32
  62. success *int32
  63. addsuccess *int32
  64. fail *int32
  65. addfail *int32
  66. start_time *time.Time
  67. stop_time *time.Time
  68. clearedFields map[string]struct{}
  69. done bool
  70. oldValue func(context.Context) (*BatchMsg, error)
  71. predicates []predicate.BatchMsg
  72. }
  73. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  74. // batchmsgOption allows management of the mutation configuration using functional options.
  75. type batchmsgOption func(*BatchMsgMutation)
  76. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  77. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  78. m := &BatchMsgMutation{
  79. config: c,
  80. op: op,
  81. typ: TypeBatchMsg,
  82. clearedFields: make(map[string]struct{}),
  83. }
  84. for _, opt := range opts {
  85. opt(m)
  86. }
  87. return m
  88. }
  89. // withBatchMsgID sets the ID field of the mutation.
  90. func withBatchMsgID(id uint64) batchmsgOption {
  91. return func(m *BatchMsgMutation) {
  92. var (
  93. err error
  94. once sync.Once
  95. value *BatchMsg
  96. )
  97. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  98. once.Do(func() {
  99. if m.done {
  100. err = errors.New("querying old values post mutation is not allowed")
  101. } else {
  102. value, err = m.Client().BatchMsg.Get(ctx, id)
  103. }
  104. })
  105. return value, err
  106. }
  107. m.id = &id
  108. }
  109. }
  110. // withBatchMsg sets the old BatchMsg of the mutation.
  111. func withBatchMsg(node *BatchMsg) batchmsgOption {
  112. return func(m *BatchMsgMutation) {
  113. m.oldValue = func(context.Context) (*BatchMsg, error) {
  114. return node, nil
  115. }
  116. m.id = &node.ID
  117. }
  118. }
  119. // Client returns a new `ent.Client` from the mutation. If the mutation was
  120. // executed in a transaction (ent.Tx), a transactional client is returned.
  121. func (m BatchMsgMutation) Client() *Client {
  122. client := &Client{config: m.config}
  123. client.init()
  124. return client
  125. }
  126. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  127. // it returns an error otherwise.
  128. func (m BatchMsgMutation) Tx() (*Tx, error) {
  129. if _, ok := m.driver.(*txDriver); !ok {
  130. return nil, errors.New("ent: mutation is not running in a transaction")
  131. }
  132. tx := &Tx{config: m.config}
  133. tx.init()
  134. return tx, nil
  135. }
  136. // SetID sets the value of the id field. Note that this
  137. // operation is only accepted on creation of BatchMsg entities.
  138. func (m *BatchMsgMutation) SetID(id uint64) {
  139. m.id = &id
  140. }
  141. // ID returns the ID value in the mutation. Note that the ID is only available
  142. // if it was provided to the builder or after it was returned from the database.
  143. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  144. if m.id == nil {
  145. return
  146. }
  147. return *m.id, true
  148. }
  149. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  150. // That means, if the mutation is applied within a transaction with an isolation level such
  151. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  152. // or updated by the mutation.
  153. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  154. switch {
  155. case m.op.Is(OpUpdateOne | OpDeleteOne):
  156. id, exists := m.ID()
  157. if exists {
  158. return []uint64{id}, nil
  159. }
  160. fallthrough
  161. case m.op.Is(OpUpdate | OpDelete):
  162. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  163. default:
  164. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  165. }
  166. }
  167. // SetCreatedAt sets the "created_at" field.
  168. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  169. m.created_at = &t
  170. }
  171. // CreatedAt returns the value of the "created_at" field in the mutation.
  172. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  173. v := m.created_at
  174. if v == nil {
  175. return
  176. }
  177. return *v, true
  178. }
  179. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  180. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  181. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  182. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  183. if !m.op.Is(OpUpdateOne) {
  184. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  185. }
  186. if m.id == nil || m.oldValue == nil {
  187. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  188. }
  189. oldValue, err := m.oldValue(ctx)
  190. if err != nil {
  191. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  192. }
  193. return oldValue.CreatedAt, nil
  194. }
  195. // ResetCreatedAt resets all changes to the "created_at" field.
  196. func (m *BatchMsgMutation) ResetCreatedAt() {
  197. m.created_at = nil
  198. }
  199. // SetUpdatedAt sets the "updated_at" field.
  200. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  201. m.updated_at = &t
  202. }
  203. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  204. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  205. v := m.updated_at
  206. if v == nil {
  207. return
  208. }
  209. return *v, true
  210. }
  211. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  212. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  213. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  214. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  215. if !m.op.Is(OpUpdateOne) {
  216. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  217. }
  218. if m.id == nil || m.oldValue == nil {
  219. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  220. }
  221. oldValue, err := m.oldValue(ctx)
  222. if err != nil {
  223. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  224. }
  225. return oldValue.UpdatedAt, nil
  226. }
  227. // ResetUpdatedAt resets all changes to the "updated_at" field.
  228. func (m *BatchMsgMutation) ResetUpdatedAt() {
  229. m.updated_at = nil
  230. }
  231. // SetDeletedAt sets the "deleted_at" field.
  232. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  233. m.deleted_at = &t
  234. }
  235. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  236. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  237. v := m.deleted_at
  238. if v == nil {
  239. return
  240. }
  241. return *v, true
  242. }
  243. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  244. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  245. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  246. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  247. if !m.op.Is(OpUpdateOne) {
  248. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  249. }
  250. if m.id == nil || m.oldValue == nil {
  251. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  252. }
  253. oldValue, err := m.oldValue(ctx)
  254. if err != nil {
  255. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  256. }
  257. return oldValue.DeletedAt, nil
  258. }
  259. // ClearDeletedAt clears the value of the "deleted_at" field.
  260. func (m *BatchMsgMutation) ClearDeletedAt() {
  261. m.deleted_at = nil
  262. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  263. }
  264. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  265. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  266. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  267. return ok
  268. }
  269. // ResetDeletedAt resets all changes to the "deleted_at" field.
  270. func (m *BatchMsgMutation) ResetDeletedAt() {
  271. m.deleted_at = nil
  272. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  273. }
  274. // SetStatus sets the "status" field.
  275. func (m *BatchMsgMutation) SetStatus(u uint8) {
  276. m.status = &u
  277. m.addstatus = nil
  278. }
  279. // Status returns the value of the "status" field in the mutation.
  280. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  281. v := m.status
  282. if v == nil {
  283. return
  284. }
  285. return *v, true
  286. }
  287. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  288. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  289. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  290. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  291. if !m.op.Is(OpUpdateOne) {
  292. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  293. }
  294. if m.id == nil || m.oldValue == nil {
  295. return v, errors.New("OldStatus requires an ID field in the mutation")
  296. }
  297. oldValue, err := m.oldValue(ctx)
  298. if err != nil {
  299. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  300. }
  301. return oldValue.Status, nil
  302. }
  303. // AddStatus adds u to the "status" field.
  304. func (m *BatchMsgMutation) AddStatus(u int8) {
  305. if m.addstatus != nil {
  306. *m.addstatus += u
  307. } else {
  308. m.addstatus = &u
  309. }
  310. }
  311. // AddedStatus returns the value that was added to the "status" field in this mutation.
  312. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  313. v := m.addstatus
  314. if v == nil {
  315. return
  316. }
  317. return *v, true
  318. }
  319. // ClearStatus clears the value of the "status" field.
  320. func (m *BatchMsgMutation) ClearStatus() {
  321. m.status = nil
  322. m.addstatus = nil
  323. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  324. }
  325. // StatusCleared returns if the "status" field was cleared in this mutation.
  326. func (m *BatchMsgMutation) StatusCleared() bool {
  327. _, ok := m.clearedFields[batchmsg.FieldStatus]
  328. return ok
  329. }
  330. // ResetStatus resets all changes to the "status" field.
  331. func (m *BatchMsgMutation) ResetStatus() {
  332. m.status = nil
  333. m.addstatus = nil
  334. delete(m.clearedFields, batchmsg.FieldStatus)
  335. }
  336. // SetBatchNo sets the "batch_no" field.
  337. func (m *BatchMsgMutation) SetBatchNo(s string) {
  338. m.batch_no = &s
  339. }
  340. // BatchNo returns the value of the "batch_no" field in the mutation.
  341. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  342. v := m.batch_no
  343. if v == nil {
  344. return
  345. }
  346. return *v, true
  347. }
  348. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  349. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  350. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  351. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  352. if !m.op.Is(OpUpdateOne) {
  353. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  354. }
  355. if m.id == nil || m.oldValue == nil {
  356. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  357. }
  358. oldValue, err := m.oldValue(ctx)
  359. if err != nil {
  360. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  361. }
  362. return oldValue.BatchNo, nil
  363. }
  364. // ClearBatchNo clears the value of the "batch_no" field.
  365. func (m *BatchMsgMutation) ClearBatchNo() {
  366. m.batch_no = nil
  367. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  368. }
  369. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  370. func (m *BatchMsgMutation) BatchNoCleared() bool {
  371. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  372. return ok
  373. }
  374. // ResetBatchNo resets all changes to the "batch_no" field.
  375. func (m *BatchMsgMutation) ResetBatchNo() {
  376. m.batch_no = nil
  377. delete(m.clearedFields, batchmsg.FieldBatchNo)
  378. }
  379. // SetFromwxid sets the "fromwxid" field.
  380. func (m *BatchMsgMutation) SetFromwxid(s string) {
  381. m.fromwxid = &s
  382. }
  383. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  384. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  385. v := m.fromwxid
  386. if v == nil {
  387. return
  388. }
  389. return *v, true
  390. }
  391. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  392. // If the BatchMsg 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 *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  395. if !m.op.Is(OpUpdateOne) {
  396. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  397. }
  398. if m.id == nil || m.oldValue == nil {
  399. return v, errors.New("OldFromwxid 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 OldFromwxid: %w", err)
  404. }
  405. return oldValue.Fromwxid, nil
  406. }
  407. // ClearFromwxid clears the value of the "fromwxid" field.
  408. func (m *BatchMsgMutation) ClearFromwxid() {
  409. m.fromwxid = nil
  410. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  411. }
  412. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  413. func (m *BatchMsgMutation) FromwxidCleared() bool {
  414. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  415. return ok
  416. }
  417. // ResetFromwxid resets all changes to the "fromwxid" field.
  418. func (m *BatchMsgMutation) ResetFromwxid() {
  419. m.fromwxid = nil
  420. delete(m.clearedFields, batchmsg.FieldFromwxid)
  421. }
  422. // SetMsg sets the "msg" field.
  423. func (m *BatchMsgMutation) SetMsg(s string) {
  424. m.msg = &s
  425. }
  426. // Msg returns the value of the "msg" field in the mutation.
  427. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  428. v := m.msg
  429. if v == nil {
  430. return
  431. }
  432. return *v, true
  433. }
  434. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  435. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  436. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  437. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  438. if !m.op.Is(OpUpdateOne) {
  439. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  440. }
  441. if m.id == nil || m.oldValue == nil {
  442. return v, errors.New("OldMsg requires an ID field in the mutation")
  443. }
  444. oldValue, err := m.oldValue(ctx)
  445. if err != nil {
  446. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  447. }
  448. return oldValue.Msg, nil
  449. }
  450. // ClearMsg clears the value of the "msg" field.
  451. func (m *BatchMsgMutation) ClearMsg() {
  452. m.msg = nil
  453. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  454. }
  455. // MsgCleared returns if the "msg" field was cleared in this mutation.
  456. func (m *BatchMsgMutation) MsgCleared() bool {
  457. _, ok := m.clearedFields[batchmsg.FieldMsg]
  458. return ok
  459. }
  460. // ResetMsg resets all changes to the "msg" field.
  461. func (m *BatchMsgMutation) ResetMsg() {
  462. m.msg = nil
  463. delete(m.clearedFields, batchmsg.FieldMsg)
  464. }
  465. // SetTag sets the "tag" field.
  466. func (m *BatchMsgMutation) SetTag(s string) {
  467. m.tag = &s
  468. }
  469. // Tag returns the value of the "tag" field in the mutation.
  470. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  471. v := m.tag
  472. if v == nil {
  473. return
  474. }
  475. return *v, true
  476. }
  477. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  478. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  479. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  480. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  481. if !m.op.Is(OpUpdateOne) {
  482. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  483. }
  484. if m.id == nil || m.oldValue == nil {
  485. return v, errors.New("OldTag requires an ID field in the mutation")
  486. }
  487. oldValue, err := m.oldValue(ctx)
  488. if err != nil {
  489. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  490. }
  491. return oldValue.Tag, nil
  492. }
  493. // ClearTag clears the value of the "tag" field.
  494. func (m *BatchMsgMutation) ClearTag() {
  495. m.tag = nil
  496. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  497. }
  498. // TagCleared returns if the "tag" field was cleared in this mutation.
  499. func (m *BatchMsgMutation) TagCleared() bool {
  500. _, ok := m.clearedFields[batchmsg.FieldTag]
  501. return ok
  502. }
  503. // ResetTag resets all changes to the "tag" field.
  504. func (m *BatchMsgMutation) ResetTag() {
  505. m.tag = nil
  506. delete(m.clearedFields, batchmsg.FieldTag)
  507. }
  508. // SetTotal sets the "total" field.
  509. func (m *BatchMsgMutation) SetTotal(i int32) {
  510. m.total = &i
  511. m.addtotal = nil
  512. }
  513. // Total returns the value of the "total" field in the mutation.
  514. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  515. v := m.total
  516. if v == nil {
  517. return
  518. }
  519. return *v, true
  520. }
  521. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  522. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  523. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  524. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  525. if !m.op.Is(OpUpdateOne) {
  526. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  527. }
  528. if m.id == nil || m.oldValue == nil {
  529. return v, errors.New("OldTotal requires an ID field in the mutation")
  530. }
  531. oldValue, err := m.oldValue(ctx)
  532. if err != nil {
  533. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  534. }
  535. return oldValue.Total, nil
  536. }
  537. // AddTotal adds i to the "total" field.
  538. func (m *BatchMsgMutation) AddTotal(i int32) {
  539. if m.addtotal != nil {
  540. *m.addtotal += i
  541. } else {
  542. m.addtotal = &i
  543. }
  544. }
  545. // AddedTotal returns the value that was added to the "total" field in this mutation.
  546. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  547. v := m.addtotal
  548. if v == nil {
  549. return
  550. }
  551. return *v, true
  552. }
  553. // ClearTotal clears the value of the "total" field.
  554. func (m *BatchMsgMutation) ClearTotal() {
  555. m.total = nil
  556. m.addtotal = nil
  557. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  558. }
  559. // TotalCleared returns if the "total" field was cleared in this mutation.
  560. func (m *BatchMsgMutation) TotalCleared() bool {
  561. _, ok := m.clearedFields[batchmsg.FieldTotal]
  562. return ok
  563. }
  564. // ResetTotal resets all changes to the "total" field.
  565. func (m *BatchMsgMutation) ResetTotal() {
  566. m.total = nil
  567. m.addtotal = nil
  568. delete(m.clearedFields, batchmsg.FieldTotal)
  569. }
  570. // SetSuccess sets the "success" field.
  571. func (m *BatchMsgMutation) SetSuccess(i int32) {
  572. m.success = &i
  573. m.addsuccess = nil
  574. }
  575. // Success returns the value of the "success" field in the mutation.
  576. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  577. v := m.success
  578. if v == nil {
  579. return
  580. }
  581. return *v, true
  582. }
  583. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  584. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  585. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  586. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  587. if !m.op.Is(OpUpdateOne) {
  588. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  589. }
  590. if m.id == nil || m.oldValue == nil {
  591. return v, errors.New("OldSuccess requires an ID field in the mutation")
  592. }
  593. oldValue, err := m.oldValue(ctx)
  594. if err != nil {
  595. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  596. }
  597. return oldValue.Success, nil
  598. }
  599. // AddSuccess adds i to the "success" field.
  600. func (m *BatchMsgMutation) AddSuccess(i int32) {
  601. if m.addsuccess != nil {
  602. *m.addsuccess += i
  603. } else {
  604. m.addsuccess = &i
  605. }
  606. }
  607. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  608. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  609. v := m.addsuccess
  610. if v == nil {
  611. return
  612. }
  613. return *v, true
  614. }
  615. // ClearSuccess clears the value of the "success" field.
  616. func (m *BatchMsgMutation) ClearSuccess() {
  617. m.success = nil
  618. m.addsuccess = nil
  619. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  620. }
  621. // SuccessCleared returns if the "success" field was cleared in this mutation.
  622. func (m *BatchMsgMutation) SuccessCleared() bool {
  623. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  624. return ok
  625. }
  626. // ResetSuccess resets all changes to the "success" field.
  627. func (m *BatchMsgMutation) ResetSuccess() {
  628. m.success = nil
  629. m.addsuccess = nil
  630. delete(m.clearedFields, batchmsg.FieldSuccess)
  631. }
  632. // SetFail sets the "fail" field.
  633. func (m *BatchMsgMutation) SetFail(i int32) {
  634. m.fail = &i
  635. m.addfail = nil
  636. }
  637. // Fail returns the value of the "fail" field in the mutation.
  638. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  639. v := m.fail
  640. if v == nil {
  641. return
  642. }
  643. return *v, true
  644. }
  645. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  646. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  647. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  648. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  649. if !m.op.Is(OpUpdateOne) {
  650. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  651. }
  652. if m.id == nil || m.oldValue == nil {
  653. return v, errors.New("OldFail requires an ID field in the mutation")
  654. }
  655. oldValue, err := m.oldValue(ctx)
  656. if err != nil {
  657. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  658. }
  659. return oldValue.Fail, nil
  660. }
  661. // AddFail adds i to the "fail" field.
  662. func (m *BatchMsgMutation) AddFail(i int32) {
  663. if m.addfail != nil {
  664. *m.addfail += i
  665. } else {
  666. m.addfail = &i
  667. }
  668. }
  669. // AddedFail returns the value that was added to the "fail" field in this mutation.
  670. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  671. v := m.addfail
  672. if v == nil {
  673. return
  674. }
  675. return *v, true
  676. }
  677. // ClearFail clears the value of the "fail" field.
  678. func (m *BatchMsgMutation) ClearFail() {
  679. m.fail = nil
  680. m.addfail = nil
  681. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  682. }
  683. // FailCleared returns if the "fail" field was cleared in this mutation.
  684. func (m *BatchMsgMutation) FailCleared() bool {
  685. _, ok := m.clearedFields[batchmsg.FieldFail]
  686. return ok
  687. }
  688. // ResetFail resets all changes to the "fail" field.
  689. func (m *BatchMsgMutation) ResetFail() {
  690. m.fail = nil
  691. m.addfail = nil
  692. delete(m.clearedFields, batchmsg.FieldFail)
  693. }
  694. // SetStartTime sets the "start_time" field.
  695. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  696. m.start_time = &t
  697. }
  698. // StartTime returns the value of the "start_time" field in the mutation.
  699. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  700. v := m.start_time
  701. if v == nil {
  702. return
  703. }
  704. return *v, true
  705. }
  706. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  707. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  708. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  709. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  710. if !m.op.Is(OpUpdateOne) {
  711. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  712. }
  713. if m.id == nil || m.oldValue == nil {
  714. return v, errors.New("OldStartTime requires an ID field in the mutation")
  715. }
  716. oldValue, err := m.oldValue(ctx)
  717. if err != nil {
  718. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  719. }
  720. return oldValue.StartTime, nil
  721. }
  722. // ClearStartTime clears the value of the "start_time" field.
  723. func (m *BatchMsgMutation) ClearStartTime() {
  724. m.start_time = nil
  725. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  726. }
  727. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  728. func (m *BatchMsgMutation) StartTimeCleared() bool {
  729. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  730. return ok
  731. }
  732. // ResetStartTime resets all changes to the "start_time" field.
  733. func (m *BatchMsgMutation) ResetStartTime() {
  734. m.start_time = nil
  735. delete(m.clearedFields, batchmsg.FieldStartTime)
  736. }
  737. // SetStopTime sets the "stop_time" field.
  738. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  739. m.stop_time = &t
  740. }
  741. // StopTime returns the value of the "stop_time" field in the mutation.
  742. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  743. v := m.stop_time
  744. if v == nil {
  745. return
  746. }
  747. return *v, true
  748. }
  749. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  750. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  751. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  752. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  753. if !m.op.Is(OpUpdateOne) {
  754. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  755. }
  756. if m.id == nil || m.oldValue == nil {
  757. return v, errors.New("OldStopTime requires an ID field in the mutation")
  758. }
  759. oldValue, err := m.oldValue(ctx)
  760. if err != nil {
  761. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  762. }
  763. return oldValue.StopTime, nil
  764. }
  765. // ClearStopTime clears the value of the "stop_time" field.
  766. func (m *BatchMsgMutation) ClearStopTime() {
  767. m.stop_time = nil
  768. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  769. }
  770. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  771. func (m *BatchMsgMutation) StopTimeCleared() bool {
  772. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  773. return ok
  774. }
  775. // ResetStopTime resets all changes to the "stop_time" field.
  776. func (m *BatchMsgMutation) ResetStopTime() {
  777. m.stop_time = nil
  778. delete(m.clearedFields, batchmsg.FieldStopTime)
  779. }
  780. // Where appends a list predicates to the BatchMsgMutation builder.
  781. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  782. m.predicates = append(m.predicates, ps...)
  783. }
  784. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  785. // users can use type-assertion to append predicates that do not depend on any generated package.
  786. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  787. p := make([]predicate.BatchMsg, len(ps))
  788. for i := range ps {
  789. p[i] = ps[i]
  790. }
  791. m.Where(p...)
  792. }
  793. // Op returns the operation name.
  794. func (m *BatchMsgMutation) Op() Op {
  795. return m.op
  796. }
  797. // SetOp allows setting the mutation operation.
  798. func (m *BatchMsgMutation) SetOp(op Op) {
  799. m.op = op
  800. }
  801. // Type returns the node type of this mutation (BatchMsg).
  802. func (m *BatchMsgMutation) Type() string {
  803. return m.typ
  804. }
  805. // Fields returns all fields that were changed during this mutation. Note that in
  806. // order to get all numeric fields that were incremented/decremented, call
  807. // AddedFields().
  808. func (m *BatchMsgMutation) Fields() []string {
  809. fields := make([]string, 0, 13)
  810. if m.created_at != nil {
  811. fields = append(fields, batchmsg.FieldCreatedAt)
  812. }
  813. if m.updated_at != nil {
  814. fields = append(fields, batchmsg.FieldUpdatedAt)
  815. }
  816. if m.deleted_at != nil {
  817. fields = append(fields, batchmsg.FieldDeletedAt)
  818. }
  819. if m.status != nil {
  820. fields = append(fields, batchmsg.FieldStatus)
  821. }
  822. if m.batch_no != nil {
  823. fields = append(fields, batchmsg.FieldBatchNo)
  824. }
  825. if m.fromwxid != nil {
  826. fields = append(fields, batchmsg.FieldFromwxid)
  827. }
  828. if m.msg != nil {
  829. fields = append(fields, batchmsg.FieldMsg)
  830. }
  831. if m.tag != nil {
  832. fields = append(fields, batchmsg.FieldTag)
  833. }
  834. if m.total != nil {
  835. fields = append(fields, batchmsg.FieldTotal)
  836. }
  837. if m.success != nil {
  838. fields = append(fields, batchmsg.FieldSuccess)
  839. }
  840. if m.fail != nil {
  841. fields = append(fields, batchmsg.FieldFail)
  842. }
  843. if m.start_time != nil {
  844. fields = append(fields, batchmsg.FieldStartTime)
  845. }
  846. if m.stop_time != nil {
  847. fields = append(fields, batchmsg.FieldStopTime)
  848. }
  849. return fields
  850. }
  851. // Field returns the value of a field with the given name. The second boolean
  852. // return value indicates that this field was not set, or was not defined in the
  853. // schema.
  854. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  855. switch name {
  856. case batchmsg.FieldCreatedAt:
  857. return m.CreatedAt()
  858. case batchmsg.FieldUpdatedAt:
  859. return m.UpdatedAt()
  860. case batchmsg.FieldDeletedAt:
  861. return m.DeletedAt()
  862. case batchmsg.FieldStatus:
  863. return m.Status()
  864. case batchmsg.FieldBatchNo:
  865. return m.BatchNo()
  866. case batchmsg.FieldFromwxid:
  867. return m.Fromwxid()
  868. case batchmsg.FieldMsg:
  869. return m.Msg()
  870. case batchmsg.FieldTag:
  871. return m.Tag()
  872. case batchmsg.FieldTotal:
  873. return m.Total()
  874. case batchmsg.FieldSuccess:
  875. return m.Success()
  876. case batchmsg.FieldFail:
  877. return m.Fail()
  878. case batchmsg.FieldStartTime:
  879. return m.StartTime()
  880. case batchmsg.FieldStopTime:
  881. return m.StopTime()
  882. }
  883. return nil, false
  884. }
  885. // OldField returns the old value of the field from the database. An error is
  886. // returned if the mutation operation is not UpdateOne, or the query to the
  887. // database failed.
  888. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  889. switch name {
  890. case batchmsg.FieldCreatedAt:
  891. return m.OldCreatedAt(ctx)
  892. case batchmsg.FieldUpdatedAt:
  893. return m.OldUpdatedAt(ctx)
  894. case batchmsg.FieldDeletedAt:
  895. return m.OldDeletedAt(ctx)
  896. case batchmsg.FieldStatus:
  897. return m.OldStatus(ctx)
  898. case batchmsg.FieldBatchNo:
  899. return m.OldBatchNo(ctx)
  900. case batchmsg.FieldFromwxid:
  901. return m.OldFromwxid(ctx)
  902. case batchmsg.FieldMsg:
  903. return m.OldMsg(ctx)
  904. case batchmsg.FieldTag:
  905. return m.OldTag(ctx)
  906. case batchmsg.FieldTotal:
  907. return m.OldTotal(ctx)
  908. case batchmsg.FieldSuccess:
  909. return m.OldSuccess(ctx)
  910. case batchmsg.FieldFail:
  911. return m.OldFail(ctx)
  912. case batchmsg.FieldStartTime:
  913. return m.OldStartTime(ctx)
  914. case batchmsg.FieldStopTime:
  915. return m.OldStopTime(ctx)
  916. }
  917. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  918. }
  919. // SetField sets the value of a field with the given name. It returns an error if
  920. // the field is not defined in the schema, or if the type mismatched the field
  921. // type.
  922. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  923. switch name {
  924. case batchmsg.FieldCreatedAt:
  925. v, ok := value.(time.Time)
  926. if !ok {
  927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  928. }
  929. m.SetCreatedAt(v)
  930. return nil
  931. case batchmsg.FieldUpdatedAt:
  932. v, ok := value.(time.Time)
  933. if !ok {
  934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  935. }
  936. m.SetUpdatedAt(v)
  937. return nil
  938. case batchmsg.FieldDeletedAt:
  939. v, ok := value.(time.Time)
  940. if !ok {
  941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  942. }
  943. m.SetDeletedAt(v)
  944. return nil
  945. case batchmsg.FieldStatus:
  946. v, ok := value.(uint8)
  947. if !ok {
  948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  949. }
  950. m.SetStatus(v)
  951. return nil
  952. case batchmsg.FieldBatchNo:
  953. v, ok := value.(string)
  954. if !ok {
  955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  956. }
  957. m.SetBatchNo(v)
  958. return nil
  959. case batchmsg.FieldFromwxid:
  960. v, ok := value.(string)
  961. if !ok {
  962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  963. }
  964. m.SetFromwxid(v)
  965. return nil
  966. case batchmsg.FieldMsg:
  967. v, ok := value.(string)
  968. if !ok {
  969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  970. }
  971. m.SetMsg(v)
  972. return nil
  973. case batchmsg.FieldTag:
  974. v, ok := value.(string)
  975. if !ok {
  976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  977. }
  978. m.SetTag(v)
  979. return nil
  980. case batchmsg.FieldTotal:
  981. v, ok := value.(int32)
  982. if !ok {
  983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  984. }
  985. m.SetTotal(v)
  986. return nil
  987. case batchmsg.FieldSuccess:
  988. v, ok := value.(int32)
  989. if !ok {
  990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  991. }
  992. m.SetSuccess(v)
  993. return nil
  994. case batchmsg.FieldFail:
  995. v, ok := value.(int32)
  996. if !ok {
  997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  998. }
  999. m.SetFail(v)
  1000. return nil
  1001. case batchmsg.FieldStartTime:
  1002. v, ok := value.(time.Time)
  1003. if !ok {
  1004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1005. }
  1006. m.SetStartTime(v)
  1007. return nil
  1008. case batchmsg.FieldStopTime:
  1009. v, ok := value.(time.Time)
  1010. if !ok {
  1011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1012. }
  1013. m.SetStopTime(v)
  1014. return nil
  1015. }
  1016. return fmt.Errorf("unknown BatchMsg field %s", name)
  1017. }
  1018. // AddedFields returns all numeric fields that were incremented/decremented during
  1019. // this mutation.
  1020. func (m *BatchMsgMutation) AddedFields() []string {
  1021. var fields []string
  1022. if m.addstatus != nil {
  1023. fields = append(fields, batchmsg.FieldStatus)
  1024. }
  1025. if m.addtotal != nil {
  1026. fields = append(fields, batchmsg.FieldTotal)
  1027. }
  1028. if m.addsuccess != nil {
  1029. fields = append(fields, batchmsg.FieldSuccess)
  1030. }
  1031. if m.addfail != nil {
  1032. fields = append(fields, batchmsg.FieldFail)
  1033. }
  1034. return fields
  1035. }
  1036. // AddedField returns the numeric value that was incremented/decremented on a field
  1037. // with the given name. The second boolean return value indicates that this field
  1038. // was not set, or was not defined in the schema.
  1039. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  1040. switch name {
  1041. case batchmsg.FieldStatus:
  1042. return m.AddedStatus()
  1043. case batchmsg.FieldTotal:
  1044. return m.AddedTotal()
  1045. case batchmsg.FieldSuccess:
  1046. return m.AddedSuccess()
  1047. case batchmsg.FieldFail:
  1048. return m.AddedFail()
  1049. }
  1050. return nil, false
  1051. }
  1052. // AddField adds the value to the field with the given name. It returns an error if
  1053. // the field is not defined in the schema, or if the type mismatched the field
  1054. // type.
  1055. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  1056. switch name {
  1057. case batchmsg.FieldStatus:
  1058. v, ok := value.(int8)
  1059. if !ok {
  1060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1061. }
  1062. m.AddStatus(v)
  1063. return nil
  1064. case batchmsg.FieldTotal:
  1065. v, ok := value.(int32)
  1066. if !ok {
  1067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1068. }
  1069. m.AddTotal(v)
  1070. return nil
  1071. case batchmsg.FieldSuccess:
  1072. v, ok := value.(int32)
  1073. if !ok {
  1074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1075. }
  1076. m.AddSuccess(v)
  1077. return nil
  1078. case batchmsg.FieldFail:
  1079. v, ok := value.(int32)
  1080. if !ok {
  1081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1082. }
  1083. m.AddFail(v)
  1084. return nil
  1085. }
  1086. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  1087. }
  1088. // ClearedFields returns all nullable fields that were cleared during this
  1089. // mutation.
  1090. func (m *BatchMsgMutation) ClearedFields() []string {
  1091. var fields []string
  1092. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  1093. fields = append(fields, batchmsg.FieldDeletedAt)
  1094. }
  1095. if m.FieldCleared(batchmsg.FieldStatus) {
  1096. fields = append(fields, batchmsg.FieldStatus)
  1097. }
  1098. if m.FieldCleared(batchmsg.FieldBatchNo) {
  1099. fields = append(fields, batchmsg.FieldBatchNo)
  1100. }
  1101. if m.FieldCleared(batchmsg.FieldFromwxid) {
  1102. fields = append(fields, batchmsg.FieldFromwxid)
  1103. }
  1104. if m.FieldCleared(batchmsg.FieldMsg) {
  1105. fields = append(fields, batchmsg.FieldMsg)
  1106. }
  1107. if m.FieldCleared(batchmsg.FieldTag) {
  1108. fields = append(fields, batchmsg.FieldTag)
  1109. }
  1110. if m.FieldCleared(batchmsg.FieldTotal) {
  1111. fields = append(fields, batchmsg.FieldTotal)
  1112. }
  1113. if m.FieldCleared(batchmsg.FieldSuccess) {
  1114. fields = append(fields, batchmsg.FieldSuccess)
  1115. }
  1116. if m.FieldCleared(batchmsg.FieldFail) {
  1117. fields = append(fields, batchmsg.FieldFail)
  1118. }
  1119. if m.FieldCleared(batchmsg.FieldStartTime) {
  1120. fields = append(fields, batchmsg.FieldStartTime)
  1121. }
  1122. if m.FieldCleared(batchmsg.FieldStopTime) {
  1123. fields = append(fields, batchmsg.FieldStopTime)
  1124. }
  1125. return fields
  1126. }
  1127. // FieldCleared returns a boolean indicating if a field with the given name was
  1128. // cleared in this mutation.
  1129. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  1130. _, ok := m.clearedFields[name]
  1131. return ok
  1132. }
  1133. // ClearField clears the value of the field with the given name. It returns an
  1134. // error if the field is not defined in the schema.
  1135. func (m *BatchMsgMutation) ClearField(name string) error {
  1136. switch name {
  1137. case batchmsg.FieldDeletedAt:
  1138. m.ClearDeletedAt()
  1139. return nil
  1140. case batchmsg.FieldStatus:
  1141. m.ClearStatus()
  1142. return nil
  1143. case batchmsg.FieldBatchNo:
  1144. m.ClearBatchNo()
  1145. return nil
  1146. case batchmsg.FieldFromwxid:
  1147. m.ClearFromwxid()
  1148. return nil
  1149. case batchmsg.FieldMsg:
  1150. m.ClearMsg()
  1151. return nil
  1152. case batchmsg.FieldTag:
  1153. m.ClearTag()
  1154. return nil
  1155. case batchmsg.FieldTotal:
  1156. m.ClearTotal()
  1157. return nil
  1158. case batchmsg.FieldSuccess:
  1159. m.ClearSuccess()
  1160. return nil
  1161. case batchmsg.FieldFail:
  1162. m.ClearFail()
  1163. return nil
  1164. case batchmsg.FieldStartTime:
  1165. m.ClearStartTime()
  1166. return nil
  1167. case batchmsg.FieldStopTime:
  1168. m.ClearStopTime()
  1169. return nil
  1170. }
  1171. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  1172. }
  1173. // ResetField resets all changes in the mutation for the field with the given name.
  1174. // It returns an error if the field is not defined in the schema.
  1175. func (m *BatchMsgMutation) ResetField(name string) error {
  1176. switch name {
  1177. case batchmsg.FieldCreatedAt:
  1178. m.ResetCreatedAt()
  1179. return nil
  1180. case batchmsg.FieldUpdatedAt:
  1181. m.ResetUpdatedAt()
  1182. return nil
  1183. case batchmsg.FieldDeletedAt:
  1184. m.ResetDeletedAt()
  1185. return nil
  1186. case batchmsg.FieldStatus:
  1187. m.ResetStatus()
  1188. return nil
  1189. case batchmsg.FieldBatchNo:
  1190. m.ResetBatchNo()
  1191. return nil
  1192. case batchmsg.FieldFromwxid:
  1193. m.ResetFromwxid()
  1194. return nil
  1195. case batchmsg.FieldMsg:
  1196. m.ResetMsg()
  1197. return nil
  1198. case batchmsg.FieldTag:
  1199. m.ResetTag()
  1200. return nil
  1201. case batchmsg.FieldTotal:
  1202. m.ResetTotal()
  1203. return nil
  1204. case batchmsg.FieldSuccess:
  1205. m.ResetSuccess()
  1206. return nil
  1207. case batchmsg.FieldFail:
  1208. m.ResetFail()
  1209. return nil
  1210. case batchmsg.FieldStartTime:
  1211. m.ResetStartTime()
  1212. return nil
  1213. case batchmsg.FieldStopTime:
  1214. m.ResetStopTime()
  1215. return nil
  1216. }
  1217. return fmt.Errorf("unknown BatchMsg field %s", name)
  1218. }
  1219. // AddedEdges returns all edge names that were set/added in this mutation.
  1220. func (m *BatchMsgMutation) AddedEdges() []string {
  1221. edges := make([]string, 0, 0)
  1222. return edges
  1223. }
  1224. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1225. // name in this mutation.
  1226. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  1227. return nil
  1228. }
  1229. // RemovedEdges returns all edge names that were removed in this mutation.
  1230. func (m *BatchMsgMutation) RemovedEdges() []string {
  1231. edges := make([]string, 0, 0)
  1232. return edges
  1233. }
  1234. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1235. // the given name in this mutation.
  1236. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  1237. return nil
  1238. }
  1239. // ClearedEdges returns all edge names that were cleared in this mutation.
  1240. func (m *BatchMsgMutation) ClearedEdges() []string {
  1241. edges := make([]string, 0, 0)
  1242. return edges
  1243. }
  1244. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1245. // was cleared in this mutation.
  1246. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  1247. return false
  1248. }
  1249. // ClearEdge clears the value of the edge with the given name. It returns an error
  1250. // if that edge is not defined in the schema.
  1251. func (m *BatchMsgMutation) ClearEdge(name string) error {
  1252. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  1253. }
  1254. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1255. // It returns an error if the edge is not defined in the schema.
  1256. func (m *BatchMsgMutation) ResetEdge(name string) error {
  1257. return fmt.Errorf("unknown BatchMsg edge %s", name)
  1258. }
  1259. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  1260. type ContactMutation struct {
  1261. config
  1262. op Op
  1263. typ string
  1264. id *uint64
  1265. created_at *time.Time
  1266. updated_at *time.Time
  1267. status *uint8
  1268. addstatus *int8
  1269. deleted_at *time.Time
  1270. wx_wxid *string
  1271. _type *int
  1272. add_type *int
  1273. wxid *string
  1274. account *string
  1275. nickname *string
  1276. markname *string
  1277. headimg *string
  1278. sex *int
  1279. addsex *int
  1280. starrole *string
  1281. dontseeit *int
  1282. adddontseeit *int
  1283. dontseeme *int
  1284. adddontseeme *int
  1285. lag *string
  1286. gid *string
  1287. gname *string
  1288. v3 *string
  1289. clearedFields map[string]struct{}
  1290. contact_relationships map[uint64]struct{}
  1291. removedcontact_relationships map[uint64]struct{}
  1292. clearedcontact_relationships bool
  1293. contact_messages map[uint64]struct{}
  1294. removedcontact_messages map[uint64]struct{}
  1295. clearedcontact_messages bool
  1296. done bool
  1297. oldValue func(context.Context) (*Contact, error)
  1298. predicates []predicate.Contact
  1299. }
  1300. var _ ent.Mutation = (*ContactMutation)(nil)
  1301. // contactOption allows management of the mutation configuration using functional options.
  1302. type contactOption func(*ContactMutation)
  1303. // newContactMutation creates new mutation for the Contact entity.
  1304. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  1305. m := &ContactMutation{
  1306. config: c,
  1307. op: op,
  1308. typ: TypeContact,
  1309. clearedFields: make(map[string]struct{}),
  1310. }
  1311. for _, opt := range opts {
  1312. opt(m)
  1313. }
  1314. return m
  1315. }
  1316. // withContactID sets the ID field of the mutation.
  1317. func withContactID(id uint64) contactOption {
  1318. return func(m *ContactMutation) {
  1319. var (
  1320. err error
  1321. once sync.Once
  1322. value *Contact
  1323. )
  1324. m.oldValue = func(ctx context.Context) (*Contact, error) {
  1325. once.Do(func() {
  1326. if m.done {
  1327. err = errors.New("querying old values post mutation is not allowed")
  1328. } else {
  1329. value, err = m.Client().Contact.Get(ctx, id)
  1330. }
  1331. })
  1332. return value, err
  1333. }
  1334. m.id = &id
  1335. }
  1336. }
  1337. // withContact sets the old Contact of the mutation.
  1338. func withContact(node *Contact) contactOption {
  1339. return func(m *ContactMutation) {
  1340. m.oldValue = func(context.Context) (*Contact, error) {
  1341. return node, nil
  1342. }
  1343. m.id = &node.ID
  1344. }
  1345. }
  1346. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1347. // executed in a transaction (ent.Tx), a transactional client is returned.
  1348. func (m ContactMutation) Client() *Client {
  1349. client := &Client{config: m.config}
  1350. client.init()
  1351. return client
  1352. }
  1353. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1354. // it returns an error otherwise.
  1355. func (m ContactMutation) Tx() (*Tx, error) {
  1356. if _, ok := m.driver.(*txDriver); !ok {
  1357. return nil, errors.New("ent: mutation is not running in a transaction")
  1358. }
  1359. tx := &Tx{config: m.config}
  1360. tx.init()
  1361. return tx, nil
  1362. }
  1363. // SetID sets the value of the id field. Note that this
  1364. // operation is only accepted on creation of Contact entities.
  1365. func (m *ContactMutation) SetID(id uint64) {
  1366. m.id = &id
  1367. }
  1368. // ID returns the ID value in the mutation. Note that the ID is only available
  1369. // if it was provided to the builder or after it was returned from the database.
  1370. func (m *ContactMutation) ID() (id uint64, exists bool) {
  1371. if m.id == nil {
  1372. return
  1373. }
  1374. return *m.id, true
  1375. }
  1376. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1377. // That means, if the mutation is applied within a transaction with an isolation level such
  1378. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1379. // or updated by the mutation.
  1380. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  1381. switch {
  1382. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1383. id, exists := m.ID()
  1384. if exists {
  1385. return []uint64{id}, nil
  1386. }
  1387. fallthrough
  1388. case m.op.Is(OpUpdate | OpDelete):
  1389. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  1390. default:
  1391. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1392. }
  1393. }
  1394. // SetCreatedAt sets the "created_at" field.
  1395. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  1396. m.created_at = &t
  1397. }
  1398. // CreatedAt returns the value of the "created_at" field in the mutation.
  1399. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  1400. v := m.created_at
  1401. if v == nil {
  1402. return
  1403. }
  1404. return *v, true
  1405. }
  1406. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  1407. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1408. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1409. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  1410. if !m.op.Is(OpUpdateOne) {
  1411. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  1412. }
  1413. if m.id == nil || m.oldValue == nil {
  1414. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  1415. }
  1416. oldValue, err := m.oldValue(ctx)
  1417. if err != nil {
  1418. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  1419. }
  1420. return oldValue.CreatedAt, nil
  1421. }
  1422. // ResetCreatedAt resets all changes to the "created_at" field.
  1423. func (m *ContactMutation) ResetCreatedAt() {
  1424. m.created_at = nil
  1425. }
  1426. // SetUpdatedAt sets the "updated_at" field.
  1427. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  1428. m.updated_at = &t
  1429. }
  1430. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  1431. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  1432. v := m.updated_at
  1433. if v == nil {
  1434. return
  1435. }
  1436. return *v, true
  1437. }
  1438. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  1439. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1440. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1441. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  1442. if !m.op.Is(OpUpdateOne) {
  1443. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  1444. }
  1445. if m.id == nil || m.oldValue == nil {
  1446. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  1447. }
  1448. oldValue, err := m.oldValue(ctx)
  1449. if err != nil {
  1450. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  1451. }
  1452. return oldValue.UpdatedAt, nil
  1453. }
  1454. // ResetUpdatedAt resets all changes to the "updated_at" field.
  1455. func (m *ContactMutation) ResetUpdatedAt() {
  1456. m.updated_at = nil
  1457. }
  1458. // SetStatus sets the "status" field.
  1459. func (m *ContactMutation) SetStatus(u uint8) {
  1460. m.status = &u
  1461. m.addstatus = nil
  1462. }
  1463. // Status returns the value of the "status" field in the mutation.
  1464. func (m *ContactMutation) Status() (r uint8, exists bool) {
  1465. v := m.status
  1466. if v == nil {
  1467. return
  1468. }
  1469. return *v, true
  1470. }
  1471. // OldStatus returns the old "status" field's value of the Contact entity.
  1472. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1473. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1474. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  1475. if !m.op.Is(OpUpdateOne) {
  1476. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  1477. }
  1478. if m.id == nil || m.oldValue == nil {
  1479. return v, errors.New("OldStatus requires an ID field in the mutation")
  1480. }
  1481. oldValue, err := m.oldValue(ctx)
  1482. if err != nil {
  1483. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  1484. }
  1485. return oldValue.Status, nil
  1486. }
  1487. // AddStatus adds u to the "status" field.
  1488. func (m *ContactMutation) AddStatus(u int8) {
  1489. if m.addstatus != nil {
  1490. *m.addstatus += u
  1491. } else {
  1492. m.addstatus = &u
  1493. }
  1494. }
  1495. // AddedStatus returns the value that was added to the "status" field in this mutation.
  1496. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  1497. v := m.addstatus
  1498. if v == nil {
  1499. return
  1500. }
  1501. return *v, true
  1502. }
  1503. // ClearStatus clears the value of the "status" field.
  1504. func (m *ContactMutation) ClearStatus() {
  1505. m.status = nil
  1506. m.addstatus = nil
  1507. m.clearedFields[contact.FieldStatus] = struct{}{}
  1508. }
  1509. // StatusCleared returns if the "status" field was cleared in this mutation.
  1510. func (m *ContactMutation) StatusCleared() bool {
  1511. _, ok := m.clearedFields[contact.FieldStatus]
  1512. return ok
  1513. }
  1514. // ResetStatus resets all changes to the "status" field.
  1515. func (m *ContactMutation) ResetStatus() {
  1516. m.status = nil
  1517. m.addstatus = nil
  1518. delete(m.clearedFields, contact.FieldStatus)
  1519. }
  1520. // SetDeletedAt sets the "deleted_at" field.
  1521. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  1522. m.deleted_at = &t
  1523. }
  1524. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  1525. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  1526. v := m.deleted_at
  1527. if v == nil {
  1528. return
  1529. }
  1530. return *v, true
  1531. }
  1532. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  1533. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1534. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1535. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  1536. if !m.op.Is(OpUpdateOne) {
  1537. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  1538. }
  1539. if m.id == nil || m.oldValue == nil {
  1540. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  1541. }
  1542. oldValue, err := m.oldValue(ctx)
  1543. if err != nil {
  1544. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  1545. }
  1546. return oldValue.DeletedAt, nil
  1547. }
  1548. // ClearDeletedAt clears the value of the "deleted_at" field.
  1549. func (m *ContactMutation) ClearDeletedAt() {
  1550. m.deleted_at = nil
  1551. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  1552. }
  1553. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  1554. func (m *ContactMutation) DeletedAtCleared() bool {
  1555. _, ok := m.clearedFields[contact.FieldDeletedAt]
  1556. return ok
  1557. }
  1558. // ResetDeletedAt resets all changes to the "deleted_at" field.
  1559. func (m *ContactMutation) ResetDeletedAt() {
  1560. m.deleted_at = nil
  1561. delete(m.clearedFields, contact.FieldDeletedAt)
  1562. }
  1563. // SetWxWxid sets the "wx_wxid" field.
  1564. func (m *ContactMutation) SetWxWxid(s string) {
  1565. m.wx_wxid = &s
  1566. }
  1567. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  1568. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  1569. v := m.wx_wxid
  1570. if v == nil {
  1571. return
  1572. }
  1573. return *v, true
  1574. }
  1575. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  1576. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1577. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1578. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  1579. if !m.op.Is(OpUpdateOne) {
  1580. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  1581. }
  1582. if m.id == nil || m.oldValue == nil {
  1583. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  1584. }
  1585. oldValue, err := m.oldValue(ctx)
  1586. if err != nil {
  1587. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  1588. }
  1589. return oldValue.WxWxid, nil
  1590. }
  1591. // ClearWxWxid clears the value of the "wx_wxid" field.
  1592. func (m *ContactMutation) ClearWxWxid() {
  1593. m.wx_wxid = nil
  1594. m.clearedFields[contact.FieldWxWxid] = struct{}{}
  1595. }
  1596. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  1597. func (m *ContactMutation) WxWxidCleared() bool {
  1598. _, ok := m.clearedFields[contact.FieldWxWxid]
  1599. return ok
  1600. }
  1601. // ResetWxWxid resets all changes to the "wx_wxid" field.
  1602. func (m *ContactMutation) ResetWxWxid() {
  1603. m.wx_wxid = nil
  1604. delete(m.clearedFields, contact.FieldWxWxid)
  1605. }
  1606. // SetType sets the "type" field.
  1607. func (m *ContactMutation) SetType(i int) {
  1608. m._type = &i
  1609. m.add_type = nil
  1610. }
  1611. // GetType returns the value of the "type" field in the mutation.
  1612. func (m *ContactMutation) GetType() (r int, exists bool) {
  1613. v := m._type
  1614. if v == nil {
  1615. return
  1616. }
  1617. return *v, true
  1618. }
  1619. // OldType returns the old "type" field's value of the Contact entity.
  1620. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1621. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1622. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  1623. if !m.op.Is(OpUpdateOne) {
  1624. return v, errors.New("OldType is only allowed on UpdateOne operations")
  1625. }
  1626. if m.id == nil || m.oldValue == nil {
  1627. return v, errors.New("OldType requires an ID field in the mutation")
  1628. }
  1629. oldValue, err := m.oldValue(ctx)
  1630. if err != nil {
  1631. return v, fmt.Errorf("querying old value for OldType: %w", err)
  1632. }
  1633. return oldValue.Type, nil
  1634. }
  1635. // AddType adds i to the "type" field.
  1636. func (m *ContactMutation) AddType(i int) {
  1637. if m.add_type != nil {
  1638. *m.add_type += i
  1639. } else {
  1640. m.add_type = &i
  1641. }
  1642. }
  1643. // AddedType returns the value that was added to the "type" field in this mutation.
  1644. func (m *ContactMutation) AddedType() (r int, exists bool) {
  1645. v := m.add_type
  1646. if v == nil {
  1647. return
  1648. }
  1649. return *v, true
  1650. }
  1651. // ClearType clears the value of the "type" field.
  1652. func (m *ContactMutation) ClearType() {
  1653. m._type = nil
  1654. m.add_type = nil
  1655. m.clearedFields[contact.FieldType] = struct{}{}
  1656. }
  1657. // TypeCleared returns if the "type" field was cleared in this mutation.
  1658. func (m *ContactMutation) TypeCleared() bool {
  1659. _, ok := m.clearedFields[contact.FieldType]
  1660. return ok
  1661. }
  1662. // ResetType resets all changes to the "type" field.
  1663. func (m *ContactMutation) ResetType() {
  1664. m._type = nil
  1665. m.add_type = nil
  1666. delete(m.clearedFields, contact.FieldType)
  1667. }
  1668. // SetWxid sets the "wxid" field.
  1669. func (m *ContactMutation) SetWxid(s string) {
  1670. m.wxid = &s
  1671. }
  1672. // Wxid returns the value of the "wxid" field in the mutation.
  1673. func (m *ContactMutation) Wxid() (r string, exists bool) {
  1674. v := m.wxid
  1675. if v == nil {
  1676. return
  1677. }
  1678. return *v, true
  1679. }
  1680. // OldWxid returns the old "wxid" field's value of the Contact entity.
  1681. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1682. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1683. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  1684. if !m.op.Is(OpUpdateOne) {
  1685. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  1686. }
  1687. if m.id == nil || m.oldValue == nil {
  1688. return v, errors.New("OldWxid requires an ID field in the mutation")
  1689. }
  1690. oldValue, err := m.oldValue(ctx)
  1691. if err != nil {
  1692. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  1693. }
  1694. return oldValue.Wxid, nil
  1695. }
  1696. // ResetWxid resets all changes to the "wxid" field.
  1697. func (m *ContactMutation) ResetWxid() {
  1698. m.wxid = nil
  1699. }
  1700. // SetAccount sets the "account" field.
  1701. func (m *ContactMutation) SetAccount(s string) {
  1702. m.account = &s
  1703. }
  1704. // Account returns the value of the "account" field in the mutation.
  1705. func (m *ContactMutation) Account() (r string, exists bool) {
  1706. v := m.account
  1707. if v == nil {
  1708. return
  1709. }
  1710. return *v, true
  1711. }
  1712. // OldAccount returns the old "account" field's value of the Contact entity.
  1713. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1714. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1715. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  1716. if !m.op.Is(OpUpdateOne) {
  1717. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  1718. }
  1719. if m.id == nil || m.oldValue == nil {
  1720. return v, errors.New("OldAccount requires an ID field in the mutation")
  1721. }
  1722. oldValue, err := m.oldValue(ctx)
  1723. if err != nil {
  1724. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  1725. }
  1726. return oldValue.Account, nil
  1727. }
  1728. // ResetAccount resets all changes to the "account" field.
  1729. func (m *ContactMutation) ResetAccount() {
  1730. m.account = nil
  1731. }
  1732. // SetNickname sets the "nickname" field.
  1733. func (m *ContactMutation) SetNickname(s string) {
  1734. m.nickname = &s
  1735. }
  1736. // Nickname returns the value of the "nickname" field in the mutation.
  1737. func (m *ContactMutation) Nickname() (r string, exists bool) {
  1738. v := m.nickname
  1739. if v == nil {
  1740. return
  1741. }
  1742. return *v, true
  1743. }
  1744. // OldNickname returns the old "nickname" field's value of the Contact entity.
  1745. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1746. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1747. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  1748. if !m.op.Is(OpUpdateOne) {
  1749. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  1750. }
  1751. if m.id == nil || m.oldValue == nil {
  1752. return v, errors.New("OldNickname requires an ID field in the mutation")
  1753. }
  1754. oldValue, err := m.oldValue(ctx)
  1755. if err != nil {
  1756. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  1757. }
  1758. return oldValue.Nickname, nil
  1759. }
  1760. // ResetNickname resets all changes to the "nickname" field.
  1761. func (m *ContactMutation) ResetNickname() {
  1762. m.nickname = nil
  1763. }
  1764. // SetMarkname sets the "markname" field.
  1765. func (m *ContactMutation) SetMarkname(s string) {
  1766. m.markname = &s
  1767. }
  1768. // Markname returns the value of the "markname" field in the mutation.
  1769. func (m *ContactMutation) Markname() (r string, exists bool) {
  1770. v := m.markname
  1771. if v == nil {
  1772. return
  1773. }
  1774. return *v, true
  1775. }
  1776. // OldMarkname returns the old "markname" field's value of the Contact entity.
  1777. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1779. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  1780. if !m.op.Is(OpUpdateOne) {
  1781. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  1782. }
  1783. if m.id == nil || m.oldValue == nil {
  1784. return v, errors.New("OldMarkname requires an ID field in the mutation")
  1785. }
  1786. oldValue, err := m.oldValue(ctx)
  1787. if err != nil {
  1788. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  1789. }
  1790. return oldValue.Markname, nil
  1791. }
  1792. // ResetMarkname resets all changes to the "markname" field.
  1793. func (m *ContactMutation) ResetMarkname() {
  1794. m.markname = nil
  1795. }
  1796. // SetHeadimg sets the "headimg" field.
  1797. func (m *ContactMutation) SetHeadimg(s string) {
  1798. m.headimg = &s
  1799. }
  1800. // Headimg returns the value of the "headimg" field in the mutation.
  1801. func (m *ContactMutation) Headimg() (r string, exists bool) {
  1802. v := m.headimg
  1803. if v == nil {
  1804. return
  1805. }
  1806. return *v, true
  1807. }
  1808. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  1809. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1810. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1811. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  1812. if !m.op.Is(OpUpdateOne) {
  1813. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  1814. }
  1815. if m.id == nil || m.oldValue == nil {
  1816. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  1817. }
  1818. oldValue, err := m.oldValue(ctx)
  1819. if err != nil {
  1820. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  1821. }
  1822. return oldValue.Headimg, nil
  1823. }
  1824. // ResetHeadimg resets all changes to the "headimg" field.
  1825. func (m *ContactMutation) ResetHeadimg() {
  1826. m.headimg = nil
  1827. }
  1828. // SetSex sets the "sex" field.
  1829. func (m *ContactMutation) SetSex(i int) {
  1830. m.sex = &i
  1831. m.addsex = nil
  1832. }
  1833. // Sex returns the value of the "sex" field in the mutation.
  1834. func (m *ContactMutation) Sex() (r int, exists bool) {
  1835. v := m.sex
  1836. if v == nil {
  1837. return
  1838. }
  1839. return *v, true
  1840. }
  1841. // OldSex returns the old "sex" field's value of the Contact entity.
  1842. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1844. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  1845. if !m.op.Is(OpUpdateOne) {
  1846. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  1847. }
  1848. if m.id == nil || m.oldValue == nil {
  1849. return v, errors.New("OldSex requires an ID field in the mutation")
  1850. }
  1851. oldValue, err := m.oldValue(ctx)
  1852. if err != nil {
  1853. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  1854. }
  1855. return oldValue.Sex, nil
  1856. }
  1857. // AddSex adds i to the "sex" field.
  1858. func (m *ContactMutation) AddSex(i int) {
  1859. if m.addsex != nil {
  1860. *m.addsex += i
  1861. } else {
  1862. m.addsex = &i
  1863. }
  1864. }
  1865. // AddedSex returns the value that was added to the "sex" field in this mutation.
  1866. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  1867. v := m.addsex
  1868. if v == nil {
  1869. return
  1870. }
  1871. return *v, true
  1872. }
  1873. // ResetSex resets all changes to the "sex" field.
  1874. func (m *ContactMutation) ResetSex() {
  1875. m.sex = nil
  1876. m.addsex = nil
  1877. }
  1878. // SetStarrole sets the "starrole" field.
  1879. func (m *ContactMutation) SetStarrole(s string) {
  1880. m.starrole = &s
  1881. }
  1882. // Starrole returns the value of the "starrole" field in the mutation.
  1883. func (m *ContactMutation) Starrole() (r string, exists bool) {
  1884. v := m.starrole
  1885. if v == nil {
  1886. return
  1887. }
  1888. return *v, true
  1889. }
  1890. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  1891. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1892. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1893. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  1894. if !m.op.Is(OpUpdateOne) {
  1895. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  1896. }
  1897. if m.id == nil || m.oldValue == nil {
  1898. return v, errors.New("OldStarrole requires an ID field in the mutation")
  1899. }
  1900. oldValue, err := m.oldValue(ctx)
  1901. if err != nil {
  1902. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  1903. }
  1904. return oldValue.Starrole, nil
  1905. }
  1906. // ResetStarrole resets all changes to the "starrole" field.
  1907. func (m *ContactMutation) ResetStarrole() {
  1908. m.starrole = nil
  1909. }
  1910. // SetDontseeit sets the "dontseeit" field.
  1911. func (m *ContactMutation) SetDontseeit(i int) {
  1912. m.dontseeit = &i
  1913. m.adddontseeit = nil
  1914. }
  1915. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  1916. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  1917. v := m.dontseeit
  1918. if v == nil {
  1919. return
  1920. }
  1921. return *v, true
  1922. }
  1923. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  1924. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1925. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1926. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  1927. if !m.op.Is(OpUpdateOne) {
  1928. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  1929. }
  1930. if m.id == nil || m.oldValue == nil {
  1931. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  1932. }
  1933. oldValue, err := m.oldValue(ctx)
  1934. if err != nil {
  1935. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  1936. }
  1937. return oldValue.Dontseeit, nil
  1938. }
  1939. // AddDontseeit adds i to the "dontseeit" field.
  1940. func (m *ContactMutation) AddDontseeit(i int) {
  1941. if m.adddontseeit != nil {
  1942. *m.adddontseeit += i
  1943. } else {
  1944. m.adddontseeit = &i
  1945. }
  1946. }
  1947. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  1948. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  1949. v := m.adddontseeit
  1950. if v == nil {
  1951. return
  1952. }
  1953. return *v, true
  1954. }
  1955. // ResetDontseeit resets all changes to the "dontseeit" field.
  1956. func (m *ContactMutation) ResetDontseeit() {
  1957. m.dontseeit = nil
  1958. m.adddontseeit = nil
  1959. }
  1960. // SetDontseeme sets the "dontseeme" field.
  1961. func (m *ContactMutation) SetDontseeme(i int) {
  1962. m.dontseeme = &i
  1963. m.adddontseeme = nil
  1964. }
  1965. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  1966. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  1967. v := m.dontseeme
  1968. if v == nil {
  1969. return
  1970. }
  1971. return *v, true
  1972. }
  1973. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  1974. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1975. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1976. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  1977. if !m.op.Is(OpUpdateOne) {
  1978. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  1979. }
  1980. if m.id == nil || m.oldValue == nil {
  1981. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  1982. }
  1983. oldValue, err := m.oldValue(ctx)
  1984. if err != nil {
  1985. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  1986. }
  1987. return oldValue.Dontseeme, nil
  1988. }
  1989. // AddDontseeme adds i to the "dontseeme" field.
  1990. func (m *ContactMutation) AddDontseeme(i int) {
  1991. if m.adddontseeme != nil {
  1992. *m.adddontseeme += i
  1993. } else {
  1994. m.adddontseeme = &i
  1995. }
  1996. }
  1997. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  1998. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  1999. v := m.adddontseeme
  2000. if v == nil {
  2001. return
  2002. }
  2003. return *v, true
  2004. }
  2005. // ResetDontseeme resets all changes to the "dontseeme" field.
  2006. func (m *ContactMutation) ResetDontseeme() {
  2007. m.dontseeme = nil
  2008. m.adddontseeme = nil
  2009. }
  2010. // SetLag sets the "lag" field.
  2011. func (m *ContactMutation) SetLag(s string) {
  2012. m.lag = &s
  2013. }
  2014. // Lag returns the value of the "lag" field in the mutation.
  2015. func (m *ContactMutation) Lag() (r string, exists bool) {
  2016. v := m.lag
  2017. if v == nil {
  2018. return
  2019. }
  2020. return *v, true
  2021. }
  2022. // OldLag returns the old "lag" field's value of the Contact entity.
  2023. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2024. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2025. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  2026. if !m.op.Is(OpUpdateOne) {
  2027. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  2028. }
  2029. if m.id == nil || m.oldValue == nil {
  2030. return v, errors.New("OldLag requires an ID field in the mutation")
  2031. }
  2032. oldValue, err := m.oldValue(ctx)
  2033. if err != nil {
  2034. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  2035. }
  2036. return oldValue.Lag, nil
  2037. }
  2038. // ResetLag resets all changes to the "lag" field.
  2039. func (m *ContactMutation) ResetLag() {
  2040. m.lag = nil
  2041. }
  2042. // SetGid sets the "gid" field.
  2043. func (m *ContactMutation) SetGid(s string) {
  2044. m.gid = &s
  2045. }
  2046. // Gid returns the value of the "gid" field in the mutation.
  2047. func (m *ContactMutation) Gid() (r string, exists bool) {
  2048. v := m.gid
  2049. if v == nil {
  2050. return
  2051. }
  2052. return *v, true
  2053. }
  2054. // OldGid returns the old "gid" field's value of the Contact entity.
  2055. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2056. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2057. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  2058. if !m.op.Is(OpUpdateOne) {
  2059. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  2060. }
  2061. if m.id == nil || m.oldValue == nil {
  2062. return v, errors.New("OldGid requires an ID field in the mutation")
  2063. }
  2064. oldValue, err := m.oldValue(ctx)
  2065. if err != nil {
  2066. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  2067. }
  2068. return oldValue.Gid, nil
  2069. }
  2070. // ResetGid resets all changes to the "gid" field.
  2071. func (m *ContactMutation) ResetGid() {
  2072. m.gid = nil
  2073. }
  2074. // SetGname sets the "gname" field.
  2075. func (m *ContactMutation) SetGname(s string) {
  2076. m.gname = &s
  2077. }
  2078. // Gname returns the value of the "gname" field in the mutation.
  2079. func (m *ContactMutation) Gname() (r string, exists bool) {
  2080. v := m.gname
  2081. if v == nil {
  2082. return
  2083. }
  2084. return *v, true
  2085. }
  2086. // OldGname returns the old "gname" field's value of the Contact entity.
  2087. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2088. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2089. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  2090. if !m.op.Is(OpUpdateOne) {
  2091. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  2092. }
  2093. if m.id == nil || m.oldValue == nil {
  2094. return v, errors.New("OldGname requires an ID field in the mutation")
  2095. }
  2096. oldValue, err := m.oldValue(ctx)
  2097. if err != nil {
  2098. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  2099. }
  2100. return oldValue.Gname, nil
  2101. }
  2102. // ResetGname resets all changes to the "gname" field.
  2103. func (m *ContactMutation) ResetGname() {
  2104. m.gname = nil
  2105. }
  2106. // SetV3 sets the "v3" field.
  2107. func (m *ContactMutation) SetV3(s string) {
  2108. m.v3 = &s
  2109. }
  2110. // V3 returns the value of the "v3" field in the mutation.
  2111. func (m *ContactMutation) V3() (r string, exists bool) {
  2112. v := m.v3
  2113. if v == nil {
  2114. return
  2115. }
  2116. return *v, true
  2117. }
  2118. // OldV3 returns the old "v3" field's value of the Contact entity.
  2119. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2120. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2121. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  2122. if !m.op.Is(OpUpdateOne) {
  2123. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  2124. }
  2125. if m.id == nil || m.oldValue == nil {
  2126. return v, errors.New("OldV3 requires an ID field in the mutation")
  2127. }
  2128. oldValue, err := m.oldValue(ctx)
  2129. if err != nil {
  2130. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  2131. }
  2132. return oldValue.V3, nil
  2133. }
  2134. // ResetV3 resets all changes to the "v3" field.
  2135. func (m *ContactMutation) ResetV3() {
  2136. m.v3 = nil
  2137. }
  2138. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  2139. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  2140. if m.contact_relationships == nil {
  2141. m.contact_relationships = make(map[uint64]struct{})
  2142. }
  2143. for i := range ids {
  2144. m.contact_relationships[ids[i]] = struct{}{}
  2145. }
  2146. }
  2147. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  2148. func (m *ContactMutation) ClearContactRelationships() {
  2149. m.clearedcontact_relationships = true
  2150. }
  2151. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  2152. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  2153. return m.clearedcontact_relationships
  2154. }
  2155. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  2156. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  2157. if m.removedcontact_relationships == nil {
  2158. m.removedcontact_relationships = make(map[uint64]struct{})
  2159. }
  2160. for i := range ids {
  2161. delete(m.contact_relationships, ids[i])
  2162. m.removedcontact_relationships[ids[i]] = struct{}{}
  2163. }
  2164. }
  2165. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  2166. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  2167. for id := range m.removedcontact_relationships {
  2168. ids = append(ids, id)
  2169. }
  2170. return
  2171. }
  2172. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  2173. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  2174. for id := range m.contact_relationships {
  2175. ids = append(ids, id)
  2176. }
  2177. return
  2178. }
  2179. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  2180. func (m *ContactMutation) ResetContactRelationships() {
  2181. m.contact_relationships = nil
  2182. m.clearedcontact_relationships = false
  2183. m.removedcontact_relationships = nil
  2184. }
  2185. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  2186. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  2187. if m.contact_messages == nil {
  2188. m.contact_messages = make(map[uint64]struct{})
  2189. }
  2190. for i := range ids {
  2191. m.contact_messages[ids[i]] = struct{}{}
  2192. }
  2193. }
  2194. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  2195. func (m *ContactMutation) ClearContactMessages() {
  2196. m.clearedcontact_messages = true
  2197. }
  2198. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  2199. func (m *ContactMutation) ContactMessagesCleared() bool {
  2200. return m.clearedcontact_messages
  2201. }
  2202. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  2203. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  2204. if m.removedcontact_messages == nil {
  2205. m.removedcontact_messages = make(map[uint64]struct{})
  2206. }
  2207. for i := range ids {
  2208. delete(m.contact_messages, ids[i])
  2209. m.removedcontact_messages[ids[i]] = struct{}{}
  2210. }
  2211. }
  2212. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  2213. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  2214. for id := range m.removedcontact_messages {
  2215. ids = append(ids, id)
  2216. }
  2217. return
  2218. }
  2219. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  2220. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  2221. for id := range m.contact_messages {
  2222. ids = append(ids, id)
  2223. }
  2224. return
  2225. }
  2226. // ResetContactMessages resets all changes to the "contact_messages" edge.
  2227. func (m *ContactMutation) ResetContactMessages() {
  2228. m.contact_messages = nil
  2229. m.clearedcontact_messages = false
  2230. m.removedcontact_messages = nil
  2231. }
  2232. // Where appends a list predicates to the ContactMutation builder.
  2233. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  2234. m.predicates = append(m.predicates, ps...)
  2235. }
  2236. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  2237. // users can use type-assertion to append predicates that do not depend on any generated package.
  2238. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  2239. p := make([]predicate.Contact, len(ps))
  2240. for i := range ps {
  2241. p[i] = ps[i]
  2242. }
  2243. m.Where(p...)
  2244. }
  2245. // Op returns the operation name.
  2246. func (m *ContactMutation) Op() Op {
  2247. return m.op
  2248. }
  2249. // SetOp allows setting the mutation operation.
  2250. func (m *ContactMutation) SetOp(op Op) {
  2251. m.op = op
  2252. }
  2253. // Type returns the node type of this mutation (Contact).
  2254. func (m *ContactMutation) Type() string {
  2255. return m.typ
  2256. }
  2257. // Fields returns all fields that were changed during this mutation. Note that in
  2258. // order to get all numeric fields that were incremented/decremented, call
  2259. // AddedFields().
  2260. func (m *ContactMutation) Fields() []string {
  2261. fields := make([]string, 0, 19)
  2262. if m.created_at != nil {
  2263. fields = append(fields, contact.FieldCreatedAt)
  2264. }
  2265. if m.updated_at != nil {
  2266. fields = append(fields, contact.FieldUpdatedAt)
  2267. }
  2268. if m.status != nil {
  2269. fields = append(fields, contact.FieldStatus)
  2270. }
  2271. if m.deleted_at != nil {
  2272. fields = append(fields, contact.FieldDeletedAt)
  2273. }
  2274. if m.wx_wxid != nil {
  2275. fields = append(fields, contact.FieldWxWxid)
  2276. }
  2277. if m._type != nil {
  2278. fields = append(fields, contact.FieldType)
  2279. }
  2280. if m.wxid != nil {
  2281. fields = append(fields, contact.FieldWxid)
  2282. }
  2283. if m.account != nil {
  2284. fields = append(fields, contact.FieldAccount)
  2285. }
  2286. if m.nickname != nil {
  2287. fields = append(fields, contact.FieldNickname)
  2288. }
  2289. if m.markname != nil {
  2290. fields = append(fields, contact.FieldMarkname)
  2291. }
  2292. if m.headimg != nil {
  2293. fields = append(fields, contact.FieldHeadimg)
  2294. }
  2295. if m.sex != nil {
  2296. fields = append(fields, contact.FieldSex)
  2297. }
  2298. if m.starrole != nil {
  2299. fields = append(fields, contact.FieldStarrole)
  2300. }
  2301. if m.dontseeit != nil {
  2302. fields = append(fields, contact.FieldDontseeit)
  2303. }
  2304. if m.dontseeme != nil {
  2305. fields = append(fields, contact.FieldDontseeme)
  2306. }
  2307. if m.lag != nil {
  2308. fields = append(fields, contact.FieldLag)
  2309. }
  2310. if m.gid != nil {
  2311. fields = append(fields, contact.FieldGid)
  2312. }
  2313. if m.gname != nil {
  2314. fields = append(fields, contact.FieldGname)
  2315. }
  2316. if m.v3 != nil {
  2317. fields = append(fields, contact.FieldV3)
  2318. }
  2319. return fields
  2320. }
  2321. // Field returns the value of a field with the given name. The second boolean
  2322. // return value indicates that this field was not set, or was not defined in the
  2323. // schema.
  2324. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  2325. switch name {
  2326. case contact.FieldCreatedAt:
  2327. return m.CreatedAt()
  2328. case contact.FieldUpdatedAt:
  2329. return m.UpdatedAt()
  2330. case contact.FieldStatus:
  2331. return m.Status()
  2332. case contact.FieldDeletedAt:
  2333. return m.DeletedAt()
  2334. case contact.FieldWxWxid:
  2335. return m.WxWxid()
  2336. case contact.FieldType:
  2337. return m.GetType()
  2338. case contact.FieldWxid:
  2339. return m.Wxid()
  2340. case contact.FieldAccount:
  2341. return m.Account()
  2342. case contact.FieldNickname:
  2343. return m.Nickname()
  2344. case contact.FieldMarkname:
  2345. return m.Markname()
  2346. case contact.FieldHeadimg:
  2347. return m.Headimg()
  2348. case contact.FieldSex:
  2349. return m.Sex()
  2350. case contact.FieldStarrole:
  2351. return m.Starrole()
  2352. case contact.FieldDontseeit:
  2353. return m.Dontseeit()
  2354. case contact.FieldDontseeme:
  2355. return m.Dontseeme()
  2356. case contact.FieldLag:
  2357. return m.Lag()
  2358. case contact.FieldGid:
  2359. return m.Gid()
  2360. case contact.FieldGname:
  2361. return m.Gname()
  2362. case contact.FieldV3:
  2363. return m.V3()
  2364. }
  2365. return nil, false
  2366. }
  2367. // OldField returns the old value of the field from the database. An error is
  2368. // returned if the mutation operation is not UpdateOne, or the query to the
  2369. // database failed.
  2370. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2371. switch name {
  2372. case contact.FieldCreatedAt:
  2373. return m.OldCreatedAt(ctx)
  2374. case contact.FieldUpdatedAt:
  2375. return m.OldUpdatedAt(ctx)
  2376. case contact.FieldStatus:
  2377. return m.OldStatus(ctx)
  2378. case contact.FieldDeletedAt:
  2379. return m.OldDeletedAt(ctx)
  2380. case contact.FieldWxWxid:
  2381. return m.OldWxWxid(ctx)
  2382. case contact.FieldType:
  2383. return m.OldType(ctx)
  2384. case contact.FieldWxid:
  2385. return m.OldWxid(ctx)
  2386. case contact.FieldAccount:
  2387. return m.OldAccount(ctx)
  2388. case contact.FieldNickname:
  2389. return m.OldNickname(ctx)
  2390. case contact.FieldMarkname:
  2391. return m.OldMarkname(ctx)
  2392. case contact.FieldHeadimg:
  2393. return m.OldHeadimg(ctx)
  2394. case contact.FieldSex:
  2395. return m.OldSex(ctx)
  2396. case contact.FieldStarrole:
  2397. return m.OldStarrole(ctx)
  2398. case contact.FieldDontseeit:
  2399. return m.OldDontseeit(ctx)
  2400. case contact.FieldDontseeme:
  2401. return m.OldDontseeme(ctx)
  2402. case contact.FieldLag:
  2403. return m.OldLag(ctx)
  2404. case contact.FieldGid:
  2405. return m.OldGid(ctx)
  2406. case contact.FieldGname:
  2407. return m.OldGname(ctx)
  2408. case contact.FieldV3:
  2409. return m.OldV3(ctx)
  2410. }
  2411. return nil, fmt.Errorf("unknown Contact field %s", name)
  2412. }
  2413. // SetField sets the value of a field with the given name. It returns an error if
  2414. // the field is not defined in the schema, or if the type mismatched the field
  2415. // type.
  2416. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  2417. switch name {
  2418. case contact.FieldCreatedAt:
  2419. v, ok := value.(time.Time)
  2420. if !ok {
  2421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2422. }
  2423. m.SetCreatedAt(v)
  2424. return nil
  2425. case contact.FieldUpdatedAt:
  2426. v, ok := value.(time.Time)
  2427. if !ok {
  2428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2429. }
  2430. m.SetUpdatedAt(v)
  2431. return nil
  2432. case contact.FieldStatus:
  2433. v, ok := value.(uint8)
  2434. if !ok {
  2435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2436. }
  2437. m.SetStatus(v)
  2438. return nil
  2439. case contact.FieldDeletedAt:
  2440. v, ok := value.(time.Time)
  2441. if !ok {
  2442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2443. }
  2444. m.SetDeletedAt(v)
  2445. return nil
  2446. case contact.FieldWxWxid:
  2447. v, ok := value.(string)
  2448. if !ok {
  2449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2450. }
  2451. m.SetWxWxid(v)
  2452. return nil
  2453. case contact.FieldType:
  2454. v, ok := value.(int)
  2455. if !ok {
  2456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2457. }
  2458. m.SetType(v)
  2459. return nil
  2460. case contact.FieldWxid:
  2461. v, ok := value.(string)
  2462. if !ok {
  2463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2464. }
  2465. m.SetWxid(v)
  2466. return nil
  2467. case contact.FieldAccount:
  2468. v, ok := value.(string)
  2469. if !ok {
  2470. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2471. }
  2472. m.SetAccount(v)
  2473. return nil
  2474. case contact.FieldNickname:
  2475. v, ok := value.(string)
  2476. if !ok {
  2477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2478. }
  2479. m.SetNickname(v)
  2480. return nil
  2481. case contact.FieldMarkname:
  2482. v, ok := value.(string)
  2483. if !ok {
  2484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2485. }
  2486. m.SetMarkname(v)
  2487. return nil
  2488. case contact.FieldHeadimg:
  2489. v, ok := value.(string)
  2490. if !ok {
  2491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2492. }
  2493. m.SetHeadimg(v)
  2494. return nil
  2495. case contact.FieldSex:
  2496. v, ok := value.(int)
  2497. if !ok {
  2498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2499. }
  2500. m.SetSex(v)
  2501. return nil
  2502. case contact.FieldStarrole:
  2503. v, ok := value.(string)
  2504. if !ok {
  2505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2506. }
  2507. m.SetStarrole(v)
  2508. return nil
  2509. case contact.FieldDontseeit:
  2510. v, ok := value.(int)
  2511. if !ok {
  2512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2513. }
  2514. m.SetDontseeit(v)
  2515. return nil
  2516. case contact.FieldDontseeme:
  2517. v, ok := value.(int)
  2518. if !ok {
  2519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2520. }
  2521. m.SetDontseeme(v)
  2522. return nil
  2523. case contact.FieldLag:
  2524. v, ok := value.(string)
  2525. if !ok {
  2526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2527. }
  2528. m.SetLag(v)
  2529. return nil
  2530. case contact.FieldGid:
  2531. v, ok := value.(string)
  2532. if !ok {
  2533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2534. }
  2535. m.SetGid(v)
  2536. return nil
  2537. case contact.FieldGname:
  2538. v, ok := value.(string)
  2539. if !ok {
  2540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2541. }
  2542. m.SetGname(v)
  2543. return nil
  2544. case contact.FieldV3:
  2545. v, ok := value.(string)
  2546. if !ok {
  2547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2548. }
  2549. m.SetV3(v)
  2550. return nil
  2551. }
  2552. return fmt.Errorf("unknown Contact field %s", name)
  2553. }
  2554. // AddedFields returns all numeric fields that were incremented/decremented during
  2555. // this mutation.
  2556. func (m *ContactMutation) AddedFields() []string {
  2557. var fields []string
  2558. if m.addstatus != nil {
  2559. fields = append(fields, contact.FieldStatus)
  2560. }
  2561. if m.add_type != nil {
  2562. fields = append(fields, contact.FieldType)
  2563. }
  2564. if m.addsex != nil {
  2565. fields = append(fields, contact.FieldSex)
  2566. }
  2567. if m.adddontseeit != nil {
  2568. fields = append(fields, contact.FieldDontseeit)
  2569. }
  2570. if m.adddontseeme != nil {
  2571. fields = append(fields, contact.FieldDontseeme)
  2572. }
  2573. return fields
  2574. }
  2575. // AddedField returns the numeric value that was incremented/decremented on a field
  2576. // with the given name. The second boolean return value indicates that this field
  2577. // was not set, or was not defined in the schema.
  2578. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  2579. switch name {
  2580. case contact.FieldStatus:
  2581. return m.AddedStatus()
  2582. case contact.FieldType:
  2583. return m.AddedType()
  2584. case contact.FieldSex:
  2585. return m.AddedSex()
  2586. case contact.FieldDontseeit:
  2587. return m.AddedDontseeit()
  2588. case contact.FieldDontseeme:
  2589. return m.AddedDontseeme()
  2590. }
  2591. return nil, false
  2592. }
  2593. // AddField adds the value to the field with the given name. It returns an error if
  2594. // the field is not defined in the schema, or if the type mismatched the field
  2595. // type.
  2596. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  2597. switch name {
  2598. case contact.FieldStatus:
  2599. v, ok := value.(int8)
  2600. if !ok {
  2601. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2602. }
  2603. m.AddStatus(v)
  2604. return nil
  2605. case contact.FieldType:
  2606. v, ok := value.(int)
  2607. if !ok {
  2608. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2609. }
  2610. m.AddType(v)
  2611. return nil
  2612. case contact.FieldSex:
  2613. v, ok := value.(int)
  2614. if !ok {
  2615. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2616. }
  2617. m.AddSex(v)
  2618. return nil
  2619. case contact.FieldDontseeit:
  2620. v, ok := value.(int)
  2621. if !ok {
  2622. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2623. }
  2624. m.AddDontseeit(v)
  2625. return nil
  2626. case contact.FieldDontseeme:
  2627. v, ok := value.(int)
  2628. if !ok {
  2629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2630. }
  2631. m.AddDontseeme(v)
  2632. return nil
  2633. }
  2634. return fmt.Errorf("unknown Contact numeric field %s", name)
  2635. }
  2636. // ClearedFields returns all nullable fields that were cleared during this
  2637. // mutation.
  2638. func (m *ContactMutation) ClearedFields() []string {
  2639. var fields []string
  2640. if m.FieldCleared(contact.FieldStatus) {
  2641. fields = append(fields, contact.FieldStatus)
  2642. }
  2643. if m.FieldCleared(contact.FieldDeletedAt) {
  2644. fields = append(fields, contact.FieldDeletedAt)
  2645. }
  2646. if m.FieldCleared(contact.FieldWxWxid) {
  2647. fields = append(fields, contact.FieldWxWxid)
  2648. }
  2649. if m.FieldCleared(contact.FieldType) {
  2650. fields = append(fields, contact.FieldType)
  2651. }
  2652. return fields
  2653. }
  2654. // FieldCleared returns a boolean indicating if a field with the given name was
  2655. // cleared in this mutation.
  2656. func (m *ContactMutation) FieldCleared(name string) bool {
  2657. _, ok := m.clearedFields[name]
  2658. return ok
  2659. }
  2660. // ClearField clears the value of the field with the given name. It returns an
  2661. // error if the field is not defined in the schema.
  2662. func (m *ContactMutation) ClearField(name string) error {
  2663. switch name {
  2664. case contact.FieldStatus:
  2665. m.ClearStatus()
  2666. return nil
  2667. case contact.FieldDeletedAt:
  2668. m.ClearDeletedAt()
  2669. return nil
  2670. case contact.FieldWxWxid:
  2671. m.ClearWxWxid()
  2672. return nil
  2673. case contact.FieldType:
  2674. m.ClearType()
  2675. return nil
  2676. }
  2677. return fmt.Errorf("unknown Contact nullable field %s", name)
  2678. }
  2679. // ResetField resets all changes in the mutation for the field with the given name.
  2680. // It returns an error if the field is not defined in the schema.
  2681. func (m *ContactMutation) ResetField(name string) error {
  2682. switch name {
  2683. case contact.FieldCreatedAt:
  2684. m.ResetCreatedAt()
  2685. return nil
  2686. case contact.FieldUpdatedAt:
  2687. m.ResetUpdatedAt()
  2688. return nil
  2689. case contact.FieldStatus:
  2690. m.ResetStatus()
  2691. return nil
  2692. case contact.FieldDeletedAt:
  2693. m.ResetDeletedAt()
  2694. return nil
  2695. case contact.FieldWxWxid:
  2696. m.ResetWxWxid()
  2697. return nil
  2698. case contact.FieldType:
  2699. m.ResetType()
  2700. return nil
  2701. case contact.FieldWxid:
  2702. m.ResetWxid()
  2703. return nil
  2704. case contact.FieldAccount:
  2705. m.ResetAccount()
  2706. return nil
  2707. case contact.FieldNickname:
  2708. m.ResetNickname()
  2709. return nil
  2710. case contact.FieldMarkname:
  2711. m.ResetMarkname()
  2712. return nil
  2713. case contact.FieldHeadimg:
  2714. m.ResetHeadimg()
  2715. return nil
  2716. case contact.FieldSex:
  2717. m.ResetSex()
  2718. return nil
  2719. case contact.FieldStarrole:
  2720. m.ResetStarrole()
  2721. return nil
  2722. case contact.FieldDontseeit:
  2723. m.ResetDontseeit()
  2724. return nil
  2725. case contact.FieldDontseeme:
  2726. m.ResetDontseeme()
  2727. return nil
  2728. case contact.FieldLag:
  2729. m.ResetLag()
  2730. return nil
  2731. case contact.FieldGid:
  2732. m.ResetGid()
  2733. return nil
  2734. case contact.FieldGname:
  2735. m.ResetGname()
  2736. return nil
  2737. case contact.FieldV3:
  2738. m.ResetV3()
  2739. return nil
  2740. }
  2741. return fmt.Errorf("unknown Contact field %s", name)
  2742. }
  2743. // AddedEdges returns all edge names that were set/added in this mutation.
  2744. func (m *ContactMutation) AddedEdges() []string {
  2745. edges := make([]string, 0, 2)
  2746. if m.contact_relationships != nil {
  2747. edges = append(edges, contact.EdgeContactRelationships)
  2748. }
  2749. if m.contact_messages != nil {
  2750. edges = append(edges, contact.EdgeContactMessages)
  2751. }
  2752. return edges
  2753. }
  2754. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2755. // name in this mutation.
  2756. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  2757. switch name {
  2758. case contact.EdgeContactRelationships:
  2759. ids := make([]ent.Value, 0, len(m.contact_relationships))
  2760. for id := range m.contact_relationships {
  2761. ids = append(ids, id)
  2762. }
  2763. return ids
  2764. case contact.EdgeContactMessages:
  2765. ids := make([]ent.Value, 0, len(m.contact_messages))
  2766. for id := range m.contact_messages {
  2767. ids = append(ids, id)
  2768. }
  2769. return ids
  2770. }
  2771. return nil
  2772. }
  2773. // RemovedEdges returns all edge names that were removed in this mutation.
  2774. func (m *ContactMutation) RemovedEdges() []string {
  2775. edges := make([]string, 0, 2)
  2776. if m.removedcontact_relationships != nil {
  2777. edges = append(edges, contact.EdgeContactRelationships)
  2778. }
  2779. if m.removedcontact_messages != nil {
  2780. edges = append(edges, contact.EdgeContactMessages)
  2781. }
  2782. return edges
  2783. }
  2784. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2785. // the given name in this mutation.
  2786. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  2787. switch name {
  2788. case contact.EdgeContactRelationships:
  2789. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  2790. for id := range m.removedcontact_relationships {
  2791. ids = append(ids, id)
  2792. }
  2793. return ids
  2794. case contact.EdgeContactMessages:
  2795. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  2796. for id := range m.removedcontact_messages {
  2797. ids = append(ids, id)
  2798. }
  2799. return ids
  2800. }
  2801. return nil
  2802. }
  2803. // ClearedEdges returns all edge names that were cleared in this mutation.
  2804. func (m *ContactMutation) ClearedEdges() []string {
  2805. edges := make([]string, 0, 2)
  2806. if m.clearedcontact_relationships {
  2807. edges = append(edges, contact.EdgeContactRelationships)
  2808. }
  2809. if m.clearedcontact_messages {
  2810. edges = append(edges, contact.EdgeContactMessages)
  2811. }
  2812. return edges
  2813. }
  2814. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2815. // was cleared in this mutation.
  2816. func (m *ContactMutation) EdgeCleared(name string) bool {
  2817. switch name {
  2818. case contact.EdgeContactRelationships:
  2819. return m.clearedcontact_relationships
  2820. case contact.EdgeContactMessages:
  2821. return m.clearedcontact_messages
  2822. }
  2823. return false
  2824. }
  2825. // ClearEdge clears the value of the edge with the given name. It returns an error
  2826. // if that edge is not defined in the schema.
  2827. func (m *ContactMutation) ClearEdge(name string) error {
  2828. switch name {
  2829. }
  2830. return fmt.Errorf("unknown Contact unique edge %s", name)
  2831. }
  2832. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2833. // It returns an error if the edge is not defined in the schema.
  2834. func (m *ContactMutation) ResetEdge(name string) error {
  2835. switch name {
  2836. case contact.EdgeContactRelationships:
  2837. m.ResetContactRelationships()
  2838. return nil
  2839. case contact.EdgeContactMessages:
  2840. m.ResetContactMessages()
  2841. return nil
  2842. }
  2843. return fmt.Errorf("unknown Contact edge %s", name)
  2844. }
  2845. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  2846. type LabelMutation struct {
  2847. config
  2848. op Op
  2849. typ string
  2850. id *uint64
  2851. created_at *time.Time
  2852. updated_at *time.Time
  2853. status *uint8
  2854. addstatus *int8
  2855. deleted_at *time.Time
  2856. _type *int
  2857. add_type *int
  2858. name *string
  2859. from *int
  2860. addfrom *int
  2861. mode *int
  2862. addmode *int
  2863. conditions *string
  2864. clearedFields map[string]struct{}
  2865. label_relationships map[uint64]struct{}
  2866. removedlabel_relationships map[uint64]struct{}
  2867. clearedlabel_relationships bool
  2868. done bool
  2869. oldValue func(context.Context) (*Label, error)
  2870. predicates []predicate.Label
  2871. }
  2872. var _ ent.Mutation = (*LabelMutation)(nil)
  2873. // labelOption allows management of the mutation configuration using functional options.
  2874. type labelOption func(*LabelMutation)
  2875. // newLabelMutation creates new mutation for the Label entity.
  2876. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  2877. m := &LabelMutation{
  2878. config: c,
  2879. op: op,
  2880. typ: TypeLabel,
  2881. clearedFields: make(map[string]struct{}),
  2882. }
  2883. for _, opt := range opts {
  2884. opt(m)
  2885. }
  2886. return m
  2887. }
  2888. // withLabelID sets the ID field of the mutation.
  2889. func withLabelID(id uint64) labelOption {
  2890. return func(m *LabelMutation) {
  2891. var (
  2892. err error
  2893. once sync.Once
  2894. value *Label
  2895. )
  2896. m.oldValue = func(ctx context.Context) (*Label, error) {
  2897. once.Do(func() {
  2898. if m.done {
  2899. err = errors.New("querying old values post mutation is not allowed")
  2900. } else {
  2901. value, err = m.Client().Label.Get(ctx, id)
  2902. }
  2903. })
  2904. return value, err
  2905. }
  2906. m.id = &id
  2907. }
  2908. }
  2909. // withLabel sets the old Label of the mutation.
  2910. func withLabel(node *Label) labelOption {
  2911. return func(m *LabelMutation) {
  2912. m.oldValue = func(context.Context) (*Label, error) {
  2913. return node, nil
  2914. }
  2915. m.id = &node.ID
  2916. }
  2917. }
  2918. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2919. // executed in a transaction (ent.Tx), a transactional client is returned.
  2920. func (m LabelMutation) Client() *Client {
  2921. client := &Client{config: m.config}
  2922. client.init()
  2923. return client
  2924. }
  2925. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2926. // it returns an error otherwise.
  2927. func (m LabelMutation) Tx() (*Tx, error) {
  2928. if _, ok := m.driver.(*txDriver); !ok {
  2929. return nil, errors.New("ent: mutation is not running in a transaction")
  2930. }
  2931. tx := &Tx{config: m.config}
  2932. tx.init()
  2933. return tx, nil
  2934. }
  2935. // SetID sets the value of the id field. Note that this
  2936. // operation is only accepted on creation of Label entities.
  2937. func (m *LabelMutation) SetID(id uint64) {
  2938. m.id = &id
  2939. }
  2940. // ID returns the ID value in the mutation. Note that the ID is only available
  2941. // if it was provided to the builder or after it was returned from the database.
  2942. func (m *LabelMutation) ID() (id uint64, exists bool) {
  2943. if m.id == nil {
  2944. return
  2945. }
  2946. return *m.id, true
  2947. }
  2948. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2949. // That means, if the mutation is applied within a transaction with an isolation level such
  2950. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2951. // or updated by the mutation.
  2952. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  2953. switch {
  2954. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2955. id, exists := m.ID()
  2956. if exists {
  2957. return []uint64{id}, nil
  2958. }
  2959. fallthrough
  2960. case m.op.Is(OpUpdate | OpDelete):
  2961. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  2962. default:
  2963. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2964. }
  2965. }
  2966. // SetCreatedAt sets the "created_at" field.
  2967. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  2968. m.created_at = &t
  2969. }
  2970. // CreatedAt returns the value of the "created_at" field in the mutation.
  2971. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  2972. v := m.created_at
  2973. if v == nil {
  2974. return
  2975. }
  2976. return *v, true
  2977. }
  2978. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  2979. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  2980. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2981. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2982. if !m.op.Is(OpUpdateOne) {
  2983. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2984. }
  2985. if m.id == nil || m.oldValue == nil {
  2986. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2987. }
  2988. oldValue, err := m.oldValue(ctx)
  2989. if err != nil {
  2990. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2991. }
  2992. return oldValue.CreatedAt, nil
  2993. }
  2994. // ResetCreatedAt resets all changes to the "created_at" field.
  2995. func (m *LabelMutation) ResetCreatedAt() {
  2996. m.created_at = nil
  2997. }
  2998. // SetUpdatedAt sets the "updated_at" field.
  2999. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  3000. m.updated_at = &t
  3001. }
  3002. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3003. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  3004. v := m.updated_at
  3005. if v == nil {
  3006. return
  3007. }
  3008. return *v, true
  3009. }
  3010. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  3011. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  3012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3013. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3014. if !m.op.Is(OpUpdateOne) {
  3015. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3016. }
  3017. if m.id == nil || m.oldValue == nil {
  3018. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3019. }
  3020. oldValue, err := m.oldValue(ctx)
  3021. if err != nil {
  3022. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3023. }
  3024. return oldValue.UpdatedAt, nil
  3025. }
  3026. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3027. func (m *LabelMutation) ResetUpdatedAt() {
  3028. m.updated_at = nil
  3029. }
  3030. // SetStatus sets the "status" field.
  3031. func (m *LabelMutation) SetStatus(u uint8) {
  3032. m.status = &u
  3033. m.addstatus = nil
  3034. }
  3035. // Status returns the value of the "status" field in the mutation.
  3036. func (m *LabelMutation) Status() (r uint8, exists bool) {
  3037. v := m.status
  3038. if v == nil {
  3039. return
  3040. }
  3041. return *v, true
  3042. }
  3043. // OldStatus returns the old "status" field's value of the Label entity.
  3044. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  3045. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3046. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  3047. if !m.op.Is(OpUpdateOne) {
  3048. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3049. }
  3050. if m.id == nil || m.oldValue == nil {
  3051. return v, errors.New("OldStatus requires an ID field in the mutation")
  3052. }
  3053. oldValue, err := m.oldValue(ctx)
  3054. if err != nil {
  3055. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3056. }
  3057. return oldValue.Status, nil
  3058. }
  3059. // AddStatus adds u to the "status" field.
  3060. func (m *LabelMutation) AddStatus(u int8) {
  3061. if m.addstatus != nil {
  3062. *m.addstatus += u
  3063. } else {
  3064. m.addstatus = &u
  3065. }
  3066. }
  3067. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3068. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  3069. v := m.addstatus
  3070. if v == nil {
  3071. return
  3072. }
  3073. return *v, true
  3074. }
  3075. // ClearStatus clears the value of the "status" field.
  3076. func (m *LabelMutation) ClearStatus() {
  3077. m.status = nil
  3078. m.addstatus = nil
  3079. m.clearedFields[label.FieldStatus] = struct{}{}
  3080. }
  3081. // StatusCleared returns if the "status" field was cleared in this mutation.
  3082. func (m *LabelMutation) StatusCleared() bool {
  3083. _, ok := m.clearedFields[label.FieldStatus]
  3084. return ok
  3085. }
  3086. // ResetStatus resets all changes to the "status" field.
  3087. func (m *LabelMutation) ResetStatus() {
  3088. m.status = nil
  3089. m.addstatus = nil
  3090. delete(m.clearedFields, label.FieldStatus)
  3091. }
  3092. // SetDeletedAt sets the "deleted_at" field.
  3093. func (m *LabelMutation) SetDeletedAt(t time.Time) {
  3094. m.deleted_at = &t
  3095. }
  3096. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3097. func (m *LabelMutation) DeletedAt() (r time.Time, exists bool) {
  3098. v := m.deleted_at
  3099. if v == nil {
  3100. return
  3101. }
  3102. return *v, true
  3103. }
  3104. // OldDeletedAt returns the old "deleted_at" field's value of the Label entity.
  3105. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  3106. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3107. func (m *LabelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3108. if !m.op.Is(OpUpdateOne) {
  3109. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3110. }
  3111. if m.id == nil || m.oldValue == nil {
  3112. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3113. }
  3114. oldValue, err := m.oldValue(ctx)
  3115. if err != nil {
  3116. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3117. }
  3118. return oldValue.DeletedAt, nil
  3119. }
  3120. // ClearDeletedAt clears the value of the "deleted_at" field.
  3121. func (m *LabelMutation) ClearDeletedAt() {
  3122. m.deleted_at = nil
  3123. m.clearedFields[label.FieldDeletedAt] = struct{}{}
  3124. }
  3125. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3126. func (m *LabelMutation) DeletedAtCleared() bool {
  3127. _, ok := m.clearedFields[label.FieldDeletedAt]
  3128. return ok
  3129. }
  3130. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3131. func (m *LabelMutation) ResetDeletedAt() {
  3132. m.deleted_at = nil
  3133. delete(m.clearedFields, label.FieldDeletedAt)
  3134. }
  3135. // SetType sets the "type" field.
  3136. func (m *LabelMutation) SetType(i int) {
  3137. m._type = &i
  3138. m.add_type = nil
  3139. }
  3140. // GetType returns the value of the "type" field in the mutation.
  3141. func (m *LabelMutation) GetType() (r int, exists bool) {
  3142. v := m._type
  3143. if v == nil {
  3144. return
  3145. }
  3146. return *v, true
  3147. }
  3148. // OldType returns the old "type" field's value of the Label entity.
  3149. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  3150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3151. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  3152. if !m.op.Is(OpUpdateOne) {
  3153. return v, errors.New("OldType is only allowed on UpdateOne operations")
  3154. }
  3155. if m.id == nil || m.oldValue == nil {
  3156. return v, errors.New("OldType requires an ID field in the mutation")
  3157. }
  3158. oldValue, err := m.oldValue(ctx)
  3159. if err != nil {
  3160. return v, fmt.Errorf("querying old value for OldType: %w", err)
  3161. }
  3162. return oldValue.Type, nil
  3163. }
  3164. // AddType adds i to the "type" field.
  3165. func (m *LabelMutation) AddType(i int) {
  3166. if m.add_type != nil {
  3167. *m.add_type += i
  3168. } else {
  3169. m.add_type = &i
  3170. }
  3171. }
  3172. // AddedType returns the value that was added to the "type" field in this mutation.
  3173. func (m *LabelMutation) AddedType() (r int, exists bool) {
  3174. v := m.add_type
  3175. if v == nil {
  3176. return
  3177. }
  3178. return *v, true
  3179. }
  3180. // ResetType resets all changes to the "type" field.
  3181. func (m *LabelMutation) ResetType() {
  3182. m._type = nil
  3183. m.add_type = nil
  3184. }
  3185. // SetName sets the "name" field.
  3186. func (m *LabelMutation) SetName(s string) {
  3187. m.name = &s
  3188. }
  3189. // Name returns the value of the "name" field in the mutation.
  3190. func (m *LabelMutation) Name() (r string, exists bool) {
  3191. v := m.name
  3192. if v == nil {
  3193. return
  3194. }
  3195. return *v, true
  3196. }
  3197. // OldName returns the old "name" field's value of the Label entity.
  3198. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  3199. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3200. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  3201. if !m.op.Is(OpUpdateOne) {
  3202. return v, errors.New("OldName is only allowed on UpdateOne operations")
  3203. }
  3204. if m.id == nil || m.oldValue == nil {
  3205. return v, errors.New("OldName requires an ID field in the mutation")
  3206. }
  3207. oldValue, err := m.oldValue(ctx)
  3208. if err != nil {
  3209. return v, fmt.Errorf("querying old value for OldName: %w", err)
  3210. }
  3211. return oldValue.Name, nil
  3212. }
  3213. // ResetName resets all changes to the "name" field.
  3214. func (m *LabelMutation) ResetName() {
  3215. m.name = nil
  3216. }
  3217. // SetFrom sets the "from" field.
  3218. func (m *LabelMutation) SetFrom(i int) {
  3219. m.from = &i
  3220. m.addfrom = nil
  3221. }
  3222. // From returns the value of the "from" field in the mutation.
  3223. func (m *LabelMutation) From() (r int, exists bool) {
  3224. v := m.from
  3225. if v == nil {
  3226. return
  3227. }
  3228. return *v, true
  3229. }
  3230. // OldFrom returns the old "from" field's value of the Label entity.
  3231. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  3232. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3233. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  3234. if !m.op.Is(OpUpdateOne) {
  3235. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  3236. }
  3237. if m.id == nil || m.oldValue == nil {
  3238. return v, errors.New("OldFrom requires an ID field in the mutation")
  3239. }
  3240. oldValue, err := m.oldValue(ctx)
  3241. if err != nil {
  3242. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  3243. }
  3244. return oldValue.From, nil
  3245. }
  3246. // AddFrom adds i to the "from" field.
  3247. func (m *LabelMutation) AddFrom(i int) {
  3248. if m.addfrom != nil {
  3249. *m.addfrom += i
  3250. } else {
  3251. m.addfrom = &i
  3252. }
  3253. }
  3254. // AddedFrom returns the value that was added to the "from" field in this mutation.
  3255. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  3256. v := m.addfrom
  3257. if v == nil {
  3258. return
  3259. }
  3260. return *v, true
  3261. }
  3262. // ResetFrom resets all changes to the "from" field.
  3263. func (m *LabelMutation) ResetFrom() {
  3264. m.from = nil
  3265. m.addfrom = nil
  3266. }
  3267. // SetMode sets the "mode" field.
  3268. func (m *LabelMutation) SetMode(i int) {
  3269. m.mode = &i
  3270. m.addmode = nil
  3271. }
  3272. // Mode returns the value of the "mode" field in the mutation.
  3273. func (m *LabelMutation) Mode() (r int, exists bool) {
  3274. v := m.mode
  3275. if v == nil {
  3276. return
  3277. }
  3278. return *v, true
  3279. }
  3280. // OldMode returns the old "mode" field's value of the Label entity.
  3281. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  3282. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3283. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  3284. if !m.op.Is(OpUpdateOne) {
  3285. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  3286. }
  3287. if m.id == nil || m.oldValue == nil {
  3288. return v, errors.New("OldMode requires an ID field in the mutation")
  3289. }
  3290. oldValue, err := m.oldValue(ctx)
  3291. if err != nil {
  3292. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  3293. }
  3294. return oldValue.Mode, nil
  3295. }
  3296. // AddMode adds i to the "mode" field.
  3297. func (m *LabelMutation) AddMode(i int) {
  3298. if m.addmode != nil {
  3299. *m.addmode += i
  3300. } else {
  3301. m.addmode = &i
  3302. }
  3303. }
  3304. // AddedMode returns the value that was added to the "mode" field in this mutation.
  3305. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  3306. v := m.addmode
  3307. if v == nil {
  3308. return
  3309. }
  3310. return *v, true
  3311. }
  3312. // ResetMode resets all changes to the "mode" field.
  3313. func (m *LabelMutation) ResetMode() {
  3314. m.mode = nil
  3315. m.addmode = nil
  3316. }
  3317. // SetConditions sets the "conditions" field.
  3318. func (m *LabelMutation) SetConditions(s string) {
  3319. m.conditions = &s
  3320. }
  3321. // Conditions returns the value of the "conditions" field in the mutation.
  3322. func (m *LabelMutation) Conditions() (r string, exists bool) {
  3323. v := m.conditions
  3324. if v == nil {
  3325. return
  3326. }
  3327. return *v, true
  3328. }
  3329. // OldConditions returns the old "conditions" field's value of the Label entity.
  3330. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  3331. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3332. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  3333. if !m.op.Is(OpUpdateOne) {
  3334. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  3335. }
  3336. if m.id == nil || m.oldValue == nil {
  3337. return v, errors.New("OldConditions requires an ID field in the mutation")
  3338. }
  3339. oldValue, err := m.oldValue(ctx)
  3340. if err != nil {
  3341. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  3342. }
  3343. return oldValue.Conditions, nil
  3344. }
  3345. // ClearConditions clears the value of the "conditions" field.
  3346. func (m *LabelMutation) ClearConditions() {
  3347. m.conditions = nil
  3348. m.clearedFields[label.FieldConditions] = struct{}{}
  3349. }
  3350. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  3351. func (m *LabelMutation) ConditionsCleared() bool {
  3352. _, ok := m.clearedFields[label.FieldConditions]
  3353. return ok
  3354. }
  3355. // ResetConditions resets all changes to the "conditions" field.
  3356. func (m *LabelMutation) ResetConditions() {
  3357. m.conditions = nil
  3358. delete(m.clearedFields, label.FieldConditions)
  3359. }
  3360. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  3361. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  3362. if m.label_relationships == nil {
  3363. m.label_relationships = make(map[uint64]struct{})
  3364. }
  3365. for i := range ids {
  3366. m.label_relationships[ids[i]] = struct{}{}
  3367. }
  3368. }
  3369. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  3370. func (m *LabelMutation) ClearLabelRelationships() {
  3371. m.clearedlabel_relationships = true
  3372. }
  3373. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  3374. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  3375. return m.clearedlabel_relationships
  3376. }
  3377. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  3378. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  3379. if m.removedlabel_relationships == nil {
  3380. m.removedlabel_relationships = make(map[uint64]struct{})
  3381. }
  3382. for i := range ids {
  3383. delete(m.label_relationships, ids[i])
  3384. m.removedlabel_relationships[ids[i]] = struct{}{}
  3385. }
  3386. }
  3387. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  3388. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  3389. for id := range m.removedlabel_relationships {
  3390. ids = append(ids, id)
  3391. }
  3392. return
  3393. }
  3394. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  3395. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  3396. for id := range m.label_relationships {
  3397. ids = append(ids, id)
  3398. }
  3399. return
  3400. }
  3401. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  3402. func (m *LabelMutation) ResetLabelRelationships() {
  3403. m.label_relationships = nil
  3404. m.clearedlabel_relationships = false
  3405. m.removedlabel_relationships = nil
  3406. }
  3407. // Where appends a list predicates to the LabelMutation builder.
  3408. func (m *LabelMutation) Where(ps ...predicate.Label) {
  3409. m.predicates = append(m.predicates, ps...)
  3410. }
  3411. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  3412. // users can use type-assertion to append predicates that do not depend on any generated package.
  3413. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  3414. p := make([]predicate.Label, len(ps))
  3415. for i := range ps {
  3416. p[i] = ps[i]
  3417. }
  3418. m.Where(p...)
  3419. }
  3420. // Op returns the operation name.
  3421. func (m *LabelMutation) Op() Op {
  3422. return m.op
  3423. }
  3424. // SetOp allows setting the mutation operation.
  3425. func (m *LabelMutation) SetOp(op Op) {
  3426. m.op = op
  3427. }
  3428. // Type returns the node type of this mutation (Label).
  3429. func (m *LabelMutation) Type() string {
  3430. return m.typ
  3431. }
  3432. // Fields returns all fields that were changed during this mutation. Note that in
  3433. // order to get all numeric fields that were incremented/decremented, call
  3434. // AddedFields().
  3435. func (m *LabelMutation) Fields() []string {
  3436. fields := make([]string, 0, 9)
  3437. if m.created_at != nil {
  3438. fields = append(fields, label.FieldCreatedAt)
  3439. }
  3440. if m.updated_at != nil {
  3441. fields = append(fields, label.FieldUpdatedAt)
  3442. }
  3443. if m.status != nil {
  3444. fields = append(fields, label.FieldStatus)
  3445. }
  3446. if m.deleted_at != nil {
  3447. fields = append(fields, label.FieldDeletedAt)
  3448. }
  3449. if m._type != nil {
  3450. fields = append(fields, label.FieldType)
  3451. }
  3452. if m.name != nil {
  3453. fields = append(fields, label.FieldName)
  3454. }
  3455. if m.from != nil {
  3456. fields = append(fields, label.FieldFrom)
  3457. }
  3458. if m.mode != nil {
  3459. fields = append(fields, label.FieldMode)
  3460. }
  3461. if m.conditions != nil {
  3462. fields = append(fields, label.FieldConditions)
  3463. }
  3464. return fields
  3465. }
  3466. // Field returns the value of a field with the given name. The second boolean
  3467. // return value indicates that this field was not set, or was not defined in the
  3468. // schema.
  3469. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  3470. switch name {
  3471. case label.FieldCreatedAt:
  3472. return m.CreatedAt()
  3473. case label.FieldUpdatedAt:
  3474. return m.UpdatedAt()
  3475. case label.FieldStatus:
  3476. return m.Status()
  3477. case label.FieldDeletedAt:
  3478. return m.DeletedAt()
  3479. case label.FieldType:
  3480. return m.GetType()
  3481. case label.FieldName:
  3482. return m.Name()
  3483. case label.FieldFrom:
  3484. return m.From()
  3485. case label.FieldMode:
  3486. return m.Mode()
  3487. case label.FieldConditions:
  3488. return m.Conditions()
  3489. }
  3490. return nil, false
  3491. }
  3492. // OldField returns the old value of the field from the database. An error is
  3493. // returned if the mutation operation is not UpdateOne, or the query to the
  3494. // database failed.
  3495. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3496. switch name {
  3497. case label.FieldCreatedAt:
  3498. return m.OldCreatedAt(ctx)
  3499. case label.FieldUpdatedAt:
  3500. return m.OldUpdatedAt(ctx)
  3501. case label.FieldStatus:
  3502. return m.OldStatus(ctx)
  3503. case label.FieldDeletedAt:
  3504. return m.OldDeletedAt(ctx)
  3505. case label.FieldType:
  3506. return m.OldType(ctx)
  3507. case label.FieldName:
  3508. return m.OldName(ctx)
  3509. case label.FieldFrom:
  3510. return m.OldFrom(ctx)
  3511. case label.FieldMode:
  3512. return m.OldMode(ctx)
  3513. case label.FieldConditions:
  3514. return m.OldConditions(ctx)
  3515. }
  3516. return nil, fmt.Errorf("unknown Label field %s", name)
  3517. }
  3518. // SetField sets the value of a field with the given name. It returns an error if
  3519. // the field is not defined in the schema, or if the type mismatched the field
  3520. // type.
  3521. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  3522. switch name {
  3523. case label.FieldCreatedAt:
  3524. v, ok := value.(time.Time)
  3525. if !ok {
  3526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3527. }
  3528. m.SetCreatedAt(v)
  3529. return nil
  3530. case label.FieldUpdatedAt:
  3531. v, ok := value.(time.Time)
  3532. if !ok {
  3533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3534. }
  3535. m.SetUpdatedAt(v)
  3536. return nil
  3537. case label.FieldStatus:
  3538. v, ok := value.(uint8)
  3539. if !ok {
  3540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3541. }
  3542. m.SetStatus(v)
  3543. return nil
  3544. case label.FieldDeletedAt:
  3545. v, ok := value.(time.Time)
  3546. if !ok {
  3547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3548. }
  3549. m.SetDeletedAt(v)
  3550. return nil
  3551. case label.FieldType:
  3552. v, ok := value.(int)
  3553. if !ok {
  3554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3555. }
  3556. m.SetType(v)
  3557. return nil
  3558. case label.FieldName:
  3559. v, ok := value.(string)
  3560. if !ok {
  3561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3562. }
  3563. m.SetName(v)
  3564. return nil
  3565. case label.FieldFrom:
  3566. v, ok := value.(int)
  3567. if !ok {
  3568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3569. }
  3570. m.SetFrom(v)
  3571. return nil
  3572. case label.FieldMode:
  3573. v, ok := value.(int)
  3574. if !ok {
  3575. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3576. }
  3577. m.SetMode(v)
  3578. return nil
  3579. case label.FieldConditions:
  3580. v, ok := value.(string)
  3581. if !ok {
  3582. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3583. }
  3584. m.SetConditions(v)
  3585. return nil
  3586. }
  3587. return fmt.Errorf("unknown Label field %s", name)
  3588. }
  3589. // AddedFields returns all numeric fields that were incremented/decremented during
  3590. // this mutation.
  3591. func (m *LabelMutation) AddedFields() []string {
  3592. var fields []string
  3593. if m.addstatus != nil {
  3594. fields = append(fields, label.FieldStatus)
  3595. }
  3596. if m.add_type != nil {
  3597. fields = append(fields, label.FieldType)
  3598. }
  3599. if m.addfrom != nil {
  3600. fields = append(fields, label.FieldFrom)
  3601. }
  3602. if m.addmode != nil {
  3603. fields = append(fields, label.FieldMode)
  3604. }
  3605. return fields
  3606. }
  3607. // AddedField returns the numeric value that was incremented/decremented on a field
  3608. // with the given name. The second boolean return value indicates that this field
  3609. // was not set, or was not defined in the schema.
  3610. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  3611. switch name {
  3612. case label.FieldStatus:
  3613. return m.AddedStatus()
  3614. case label.FieldType:
  3615. return m.AddedType()
  3616. case label.FieldFrom:
  3617. return m.AddedFrom()
  3618. case label.FieldMode:
  3619. return m.AddedMode()
  3620. }
  3621. return nil, false
  3622. }
  3623. // AddField adds the value to the field with the given name. It returns an error if
  3624. // the field is not defined in the schema, or if the type mismatched the field
  3625. // type.
  3626. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  3627. switch name {
  3628. case label.FieldStatus:
  3629. v, ok := value.(int8)
  3630. if !ok {
  3631. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3632. }
  3633. m.AddStatus(v)
  3634. return nil
  3635. case label.FieldType:
  3636. v, ok := value.(int)
  3637. if !ok {
  3638. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3639. }
  3640. m.AddType(v)
  3641. return nil
  3642. case label.FieldFrom:
  3643. v, ok := value.(int)
  3644. if !ok {
  3645. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3646. }
  3647. m.AddFrom(v)
  3648. return nil
  3649. case label.FieldMode:
  3650. v, ok := value.(int)
  3651. if !ok {
  3652. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3653. }
  3654. m.AddMode(v)
  3655. return nil
  3656. }
  3657. return fmt.Errorf("unknown Label numeric field %s", name)
  3658. }
  3659. // ClearedFields returns all nullable fields that were cleared during this
  3660. // mutation.
  3661. func (m *LabelMutation) ClearedFields() []string {
  3662. var fields []string
  3663. if m.FieldCleared(label.FieldStatus) {
  3664. fields = append(fields, label.FieldStatus)
  3665. }
  3666. if m.FieldCleared(label.FieldDeletedAt) {
  3667. fields = append(fields, label.FieldDeletedAt)
  3668. }
  3669. if m.FieldCleared(label.FieldConditions) {
  3670. fields = append(fields, label.FieldConditions)
  3671. }
  3672. return fields
  3673. }
  3674. // FieldCleared returns a boolean indicating if a field with the given name was
  3675. // cleared in this mutation.
  3676. func (m *LabelMutation) FieldCleared(name string) bool {
  3677. _, ok := m.clearedFields[name]
  3678. return ok
  3679. }
  3680. // ClearField clears the value of the field with the given name. It returns an
  3681. // error if the field is not defined in the schema.
  3682. func (m *LabelMutation) ClearField(name string) error {
  3683. switch name {
  3684. case label.FieldStatus:
  3685. m.ClearStatus()
  3686. return nil
  3687. case label.FieldDeletedAt:
  3688. m.ClearDeletedAt()
  3689. return nil
  3690. case label.FieldConditions:
  3691. m.ClearConditions()
  3692. return nil
  3693. }
  3694. return fmt.Errorf("unknown Label nullable field %s", name)
  3695. }
  3696. // ResetField resets all changes in the mutation for the field with the given name.
  3697. // It returns an error if the field is not defined in the schema.
  3698. func (m *LabelMutation) ResetField(name string) error {
  3699. switch name {
  3700. case label.FieldCreatedAt:
  3701. m.ResetCreatedAt()
  3702. return nil
  3703. case label.FieldUpdatedAt:
  3704. m.ResetUpdatedAt()
  3705. return nil
  3706. case label.FieldStatus:
  3707. m.ResetStatus()
  3708. return nil
  3709. case label.FieldDeletedAt:
  3710. m.ResetDeletedAt()
  3711. return nil
  3712. case label.FieldType:
  3713. m.ResetType()
  3714. return nil
  3715. case label.FieldName:
  3716. m.ResetName()
  3717. return nil
  3718. case label.FieldFrom:
  3719. m.ResetFrom()
  3720. return nil
  3721. case label.FieldMode:
  3722. m.ResetMode()
  3723. return nil
  3724. case label.FieldConditions:
  3725. m.ResetConditions()
  3726. return nil
  3727. }
  3728. return fmt.Errorf("unknown Label field %s", name)
  3729. }
  3730. // AddedEdges returns all edge names that were set/added in this mutation.
  3731. func (m *LabelMutation) AddedEdges() []string {
  3732. edges := make([]string, 0, 1)
  3733. if m.label_relationships != nil {
  3734. edges = append(edges, label.EdgeLabelRelationships)
  3735. }
  3736. return edges
  3737. }
  3738. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3739. // name in this mutation.
  3740. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  3741. switch name {
  3742. case label.EdgeLabelRelationships:
  3743. ids := make([]ent.Value, 0, len(m.label_relationships))
  3744. for id := range m.label_relationships {
  3745. ids = append(ids, id)
  3746. }
  3747. return ids
  3748. }
  3749. return nil
  3750. }
  3751. // RemovedEdges returns all edge names that were removed in this mutation.
  3752. func (m *LabelMutation) RemovedEdges() []string {
  3753. edges := make([]string, 0, 1)
  3754. if m.removedlabel_relationships != nil {
  3755. edges = append(edges, label.EdgeLabelRelationships)
  3756. }
  3757. return edges
  3758. }
  3759. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3760. // the given name in this mutation.
  3761. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  3762. switch name {
  3763. case label.EdgeLabelRelationships:
  3764. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  3765. for id := range m.removedlabel_relationships {
  3766. ids = append(ids, id)
  3767. }
  3768. return ids
  3769. }
  3770. return nil
  3771. }
  3772. // ClearedEdges returns all edge names that were cleared in this mutation.
  3773. func (m *LabelMutation) ClearedEdges() []string {
  3774. edges := make([]string, 0, 1)
  3775. if m.clearedlabel_relationships {
  3776. edges = append(edges, label.EdgeLabelRelationships)
  3777. }
  3778. return edges
  3779. }
  3780. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3781. // was cleared in this mutation.
  3782. func (m *LabelMutation) EdgeCleared(name string) bool {
  3783. switch name {
  3784. case label.EdgeLabelRelationships:
  3785. return m.clearedlabel_relationships
  3786. }
  3787. return false
  3788. }
  3789. // ClearEdge clears the value of the edge with the given name. It returns an error
  3790. // if that edge is not defined in the schema.
  3791. func (m *LabelMutation) ClearEdge(name string) error {
  3792. switch name {
  3793. }
  3794. return fmt.Errorf("unknown Label unique edge %s", name)
  3795. }
  3796. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3797. // It returns an error if the edge is not defined in the schema.
  3798. func (m *LabelMutation) ResetEdge(name string) error {
  3799. switch name {
  3800. case label.EdgeLabelRelationships:
  3801. m.ResetLabelRelationships()
  3802. return nil
  3803. }
  3804. return fmt.Errorf("unknown Label edge %s", name)
  3805. }
  3806. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  3807. type LabelRelationshipMutation struct {
  3808. config
  3809. op Op
  3810. typ string
  3811. id *uint64
  3812. created_at *time.Time
  3813. updated_at *time.Time
  3814. status *uint8
  3815. addstatus *int8
  3816. deleted_at *time.Time
  3817. clearedFields map[string]struct{}
  3818. contacts *uint64
  3819. clearedcontacts bool
  3820. labels *uint64
  3821. clearedlabels bool
  3822. done bool
  3823. oldValue func(context.Context) (*LabelRelationship, error)
  3824. predicates []predicate.LabelRelationship
  3825. }
  3826. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  3827. // labelrelationshipOption allows management of the mutation configuration using functional options.
  3828. type labelrelationshipOption func(*LabelRelationshipMutation)
  3829. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  3830. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  3831. m := &LabelRelationshipMutation{
  3832. config: c,
  3833. op: op,
  3834. typ: TypeLabelRelationship,
  3835. clearedFields: make(map[string]struct{}),
  3836. }
  3837. for _, opt := range opts {
  3838. opt(m)
  3839. }
  3840. return m
  3841. }
  3842. // withLabelRelationshipID sets the ID field of the mutation.
  3843. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  3844. return func(m *LabelRelationshipMutation) {
  3845. var (
  3846. err error
  3847. once sync.Once
  3848. value *LabelRelationship
  3849. )
  3850. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  3851. once.Do(func() {
  3852. if m.done {
  3853. err = errors.New("querying old values post mutation is not allowed")
  3854. } else {
  3855. value, err = m.Client().LabelRelationship.Get(ctx, id)
  3856. }
  3857. })
  3858. return value, err
  3859. }
  3860. m.id = &id
  3861. }
  3862. }
  3863. // withLabelRelationship sets the old LabelRelationship of the mutation.
  3864. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  3865. return func(m *LabelRelationshipMutation) {
  3866. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  3867. return node, nil
  3868. }
  3869. m.id = &node.ID
  3870. }
  3871. }
  3872. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3873. // executed in a transaction (ent.Tx), a transactional client is returned.
  3874. func (m LabelRelationshipMutation) Client() *Client {
  3875. client := &Client{config: m.config}
  3876. client.init()
  3877. return client
  3878. }
  3879. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3880. // it returns an error otherwise.
  3881. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  3882. if _, ok := m.driver.(*txDriver); !ok {
  3883. return nil, errors.New("ent: mutation is not running in a transaction")
  3884. }
  3885. tx := &Tx{config: m.config}
  3886. tx.init()
  3887. return tx, nil
  3888. }
  3889. // SetID sets the value of the id field. Note that this
  3890. // operation is only accepted on creation of LabelRelationship entities.
  3891. func (m *LabelRelationshipMutation) SetID(id uint64) {
  3892. m.id = &id
  3893. }
  3894. // ID returns the ID value in the mutation. Note that the ID is only available
  3895. // if it was provided to the builder or after it was returned from the database.
  3896. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  3897. if m.id == nil {
  3898. return
  3899. }
  3900. return *m.id, true
  3901. }
  3902. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3903. // That means, if the mutation is applied within a transaction with an isolation level such
  3904. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3905. // or updated by the mutation.
  3906. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  3907. switch {
  3908. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3909. id, exists := m.ID()
  3910. if exists {
  3911. return []uint64{id}, nil
  3912. }
  3913. fallthrough
  3914. case m.op.Is(OpUpdate | OpDelete):
  3915. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  3916. default:
  3917. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3918. }
  3919. }
  3920. // SetCreatedAt sets the "created_at" field.
  3921. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  3922. m.created_at = &t
  3923. }
  3924. // CreatedAt returns the value of the "created_at" field in the mutation.
  3925. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  3926. v := m.created_at
  3927. if v == nil {
  3928. return
  3929. }
  3930. return *v, true
  3931. }
  3932. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  3933. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  3934. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3935. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3936. if !m.op.Is(OpUpdateOne) {
  3937. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3938. }
  3939. if m.id == nil || m.oldValue == nil {
  3940. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3941. }
  3942. oldValue, err := m.oldValue(ctx)
  3943. if err != nil {
  3944. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3945. }
  3946. return oldValue.CreatedAt, nil
  3947. }
  3948. // ResetCreatedAt resets all changes to the "created_at" field.
  3949. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  3950. m.created_at = nil
  3951. }
  3952. // SetUpdatedAt sets the "updated_at" field.
  3953. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  3954. m.updated_at = &t
  3955. }
  3956. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3957. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  3958. v := m.updated_at
  3959. if v == nil {
  3960. return
  3961. }
  3962. return *v, true
  3963. }
  3964. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  3965. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  3966. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3967. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3968. if !m.op.Is(OpUpdateOne) {
  3969. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3970. }
  3971. if m.id == nil || m.oldValue == nil {
  3972. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3973. }
  3974. oldValue, err := m.oldValue(ctx)
  3975. if err != nil {
  3976. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3977. }
  3978. return oldValue.UpdatedAt, nil
  3979. }
  3980. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3981. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  3982. m.updated_at = nil
  3983. }
  3984. // SetStatus sets the "status" field.
  3985. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  3986. m.status = &u
  3987. m.addstatus = nil
  3988. }
  3989. // Status returns the value of the "status" field in the mutation.
  3990. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  3991. v := m.status
  3992. if v == nil {
  3993. return
  3994. }
  3995. return *v, true
  3996. }
  3997. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  3998. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  3999. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4000. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  4001. if !m.op.Is(OpUpdateOne) {
  4002. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  4003. }
  4004. if m.id == nil || m.oldValue == nil {
  4005. return v, errors.New("OldStatus requires an ID field in the mutation")
  4006. }
  4007. oldValue, err := m.oldValue(ctx)
  4008. if err != nil {
  4009. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  4010. }
  4011. return oldValue.Status, nil
  4012. }
  4013. // AddStatus adds u to the "status" field.
  4014. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  4015. if m.addstatus != nil {
  4016. *m.addstatus += u
  4017. } else {
  4018. m.addstatus = &u
  4019. }
  4020. }
  4021. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4022. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  4023. v := m.addstatus
  4024. if v == nil {
  4025. return
  4026. }
  4027. return *v, true
  4028. }
  4029. // ClearStatus clears the value of the "status" field.
  4030. func (m *LabelRelationshipMutation) ClearStatus() {
  4031. m.status = nil
  4032. m.addstatus = nil
  4033. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  4034. }
  4035. // StatusCleared returns if the "status" field was cleared in this mutation.
  4036. func (m *LabelRelationshipMutation) StatusCleared() bool {
  4037. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  4038. return ok
  4039. }
  4040. // ResetStatus resets all changes to the "status" field.
  4041. func (m *LabelRelationshipMutation) ResetStatus() {
  4042. m.status = nil
  4043. m.addstatus = nil
  4044. delete(m.clearedFields, labelrelationship.FieldStatus)
  4045. }
  4046. // SetDeletedAt sets the "deleted_at" field.
  4047. func (m *LabelRelationshipMutation) SetDeletedAt(t time.Time) {
  4048. m.deleted_at = &t
  4049. }
  4050. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4051. func (m *LabelRelationshipMutation) DeletedAt() (r time.Time, exists bool) {
  4052. v := m.deleted_at
  4053. if v == nil {
  4054. return
  4055. }
  4056. return *v, true
  4057. }
  4058. // OldDeletedAt returns the old "deleted_at" field's value of the LabelRelationship entity.
  4059. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  4060. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4061. func (m *LabelRelationshipMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4062. if !m.op.Is(OpUpdateOne) {
  4063. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4064. }
  4065. if m.id == nil || m.oldValue == nil {
  4066. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4067. }
  4068. oldValue, err := m.oldValue(ctx)
  4069. if err != nil {
  4070. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4071. }
  4072. return oldValue.DeletedAt, nil
  4073. }
  4074. // ClearDeletedAt clears the value of the "deleted_at" field.
  4075. func (m *LabelRelationshipMutation) ClearDeletedAt() {
  4076. m.deleted_at = nil
  4077. m.clearedFields[labelrelationship.FieldDeletedAt] = struct{}{}
  4078. }
  4079. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4080. func (m *LabelRelationshipMutation) DeletedAtCleared() bool {
  4081. _, ok := m.clearedFields[labelrelationship.FieldDeletedAt]
  4082. return ok
  4083. }
  4084. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4085. func (m *LabelRelationshipMutation) ResetDeletedAt() {
  4086. m.deleted_at = nil
  4087. delete(m.clearedFields, labelrelationship.FieldDeletedAt)
  4088. }
  4089. // SetLabelID sets the "label_id" field.
  4090. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  4091. m.labels = &u
  4092. }
  4093. // LabelID returns the value of the "label_id" field in the mutation.
  4094. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  4095. v := m.labels
  4096. if v == nil {
  4097. return
  4098. }
  4099. return *v, true
  4100. }
  4101. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  4102. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  4103. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4104. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  4105. if !m.op.Is(OpUpdateOne) {
  4106. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  4107. }
  4108. if m.id == nil || m.oldValue == nil {
  4109. return v, errors.New("OldLabelID requires an ID field in the mutation")
  4110. }
  4111. oldValue, err := m.oldValue(ctx)
  4112. if err != nil {
  4113. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  4114. }
  4115. return oldValue.LabelID, nil
  4116. }
  4117. // ResetLabelID resets all changes to the "label_id" field.
  4118. func (m *LabelRelationshipMutation) ResetLabelID() {
  4119. m.labels = nil
  4120. }
  4121. // SetContactID sets the "contact_id" field.
  4122. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  4123. m.contacts = &u
  4124. }
  4125. // ContactID returns the value of the "contact_id" field in the mutation.
  4126. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  4127. v := m.contacts
  4128. if v == nil {
  4129. return
  4130. }
  4131. return *v, true
  4132. }
  4133. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  4134. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  4135. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4136. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  4137. if !m.op.Is(OpUpdateOne) {
  4138. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  4139. }
  4140. if m.id == nil || m.oldValue == nil {
  4141. return v, errors.New("OldContactID requires an ID field in the mutation")
  4142. }
  4143. oldValue, err := m.oldValue(ctx)
  4144. if err != nil {
  4145. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  4146. }
  4147. return oldValue.ContactID, nil
  4148. }
  4149. // ResetContactID resets all changes to the "contact_id" field.
  4150. func (m *LabelRelationshipMutation) ResetContactID() {
  4151. m.contacts = nil
  4152. }
  4153. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  4154. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  4155. m.contacts = &id
  4156. }
  4157. // ClearContacts clears the "contacts" edge to the Contact entity.
  4158. func (m *LabelRelationshipMutation) ClearContacts() {
  4159. m.clearedcontacts = true
  4160. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  4161. }
  4162. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  4163. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  4164. return m.clearedcontacts
  4165. }
  4166. // ContactsID returns the "contacts" edge ID in the mutation.
  4167. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  4168. if m.contacts != nil {
  4169. return *m.contacts, true
  4170. }
  4171. return
  4172. }
  4173. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  4174. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  4175. // ContactsID instead. It exists only for internal usage by the builders.
  4176. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  4177. if id := m.contacts; id != nil {
  4178. ids = append(ids, *id)
  4179. }
  4180. return
  4181. }
  4182. // ResetContacts resets all changes to the "contacts" edge.
  4183. func (m *LabelRelationshipMutation) ResetContacts() {
  4184. m.contacts = nil
  4185. m.clearedcontacts = false
  4186. }
  4187. // SetLabelsID sets the "labels" edge to the Label entity by id.
  4188. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  4189. m.labels = &id
  4190. }
  4191. // ClearLabels clears the "labels" edge to the Label entity.
  4192. func (m *LabelRelationshipMutation) ClearLabels() {
  4193. m.clearedlabels = true
  4194. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  4195. }
  4196. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  4197. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  4198. return m.clearedlabels
  4199. }
  4200. // LabelsID returns the "labels" edge ID in the mutation.
  4201. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  4202. if m.labels != nil {
  4203. return *m.labels, true
  4204. }
  4205. return
  4206. }
  4207. // LabelsIDs returns the "labels" edge IDs in the mutation.
  4208. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  4209. // LabelsID instead. It exists only for internal usage by the builders.
  4210. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  4211. if id := m.labels; id != nil {
  4212. ids = append(ids, *id)
  4213. }
  4214. return
  4215. }
  4216. // ResetLabels resets all changes to the "labels" edge.
  4217. func (m *LabelRelationshipMutation) ResetLabels() {
  4218. m.labels = nil
  4219. m.clearedlabels = false
  4220. }
  4221. // Where appends a list predicates to the LabelRelationshipMutation builder.
  4222. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  4223. m.predicates = append(m.predicates, ps...)
  4224. }
  4225. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  4226. // users can use type-assertion to append predicates that do not depend on any generated package.
  4227. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  4228. p := make([]predicate.LabelRelationship, len(ps))
  4229. for i := range ps {
  4230. p[i] = ps[i]
  4231. }
  4232. m.Where(p...)
  4233. }
  4234. // Op returns the operation name.
  4235. func (m *LabelRelationshipMutation) Op() Op {
  4236. return m.op
  4237. }
  4238. // SetOp allows setting the mutation operation.
  4239. func (m *LabelRelationshipMutation) SetOp(op Op) {
  4240. m.op = op
  4241. }
  4242. // Type returns the node type of this mutation (LabelRelationship).
  4243. func (m *LabelRelationshipMutation) Type() string {
  4244. return m.typ
  4245. }
  4246. // Fields returns all fields that were changed during this mutation. Note that in
  4247. // order to get all numeric fields that were incremented/decremented, call
  4248. // AddedFields().
  4249. func (m *LabelRelationshipMutation) Fields() []string {
  4250. fields := make([]string, 0, 6)
  4251. if m.created_at != nil {
  4252. fields = append(fields, labelrelationship.FieldCreatedAt)
  4253. }
  4254. if m.updated_at != nil {
  4255. fields = append(fields, labelrelationship.FieldUpdatedAt)
  4256. }
  4257. if m.status != nil {
  4258. fields = append(fields, labelrelationship.FieldStatus)
  4259. }
  4260. if m.deleted_at != nil {
  4261. fields = append(fields, labelrelationship.FieldDeletedAt)
  4262. }
  4263. if m.labels != nil {
  4264. fields = append(fields, labelrelationship.FieldLabelID)
  4265. }
  4266. if m.contacts != nil {
  4267. fields = append(fields, labelrelationship.FieldContactID)
  4268. }
  4269. return fields
  4270. }
  4271. // Field returns the value of a field with the given name. The second boolean
  4272. // return value indicates that this field was not set, or was not defined in the
  4273. // schema.
  4274. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  4275. switch name {
  4276. case labelrelationship.FieldCreatedAt:
  4277. return m.CreatedAt()
  4278. case labelrelationship.FieldUpdatedAt:
  4279. return m.UpdatedAt()
  4280. case labelrelationship.FieldStatus:
  4281. return m.Status()
  4282. case labelrelationship.FieldDeletedAt:
  4283. return m.DeletedAt()
  4284. case labelrelationship.FieldLabelID:
  4285. return m.LabelID()
  4286. case labelrelationship.FieldContactID:
  4287. return m.ContactID()
  4288. }
  4289. return nil, false
  4290. }
  4291. // OldField returns the old value of the field from the database. An error is
  4292. // returned if the mutation operation is not UpdateOne, or the query to the
  4293. // database failed.
  4294. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4295. switch name {
  4296. case labelrelationship.FieldCreatedAt:
  4297. return m.OldCreatedAt(ctx)
  4298. case labelrelationship.FieldUpdatedAt:
  4299. return m.OldUpdatedAt(ctx)
  4300. case labelrelationship.FieldStatus:
  4301. return m.OldStatus(ctx)
  4302. case labelrelationship.FieldDeletedAt:
  4303. return m.OldDeletedAt(ctx)
  4304. case labelrelationship.FieldLabelID:
  4305. return m.OldLabelID(ctx)
  4306. case labelrelationship.FieldContactID:
  4307. return m.OldContactID(ctx)
  4308. }
  4309. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  4310. }
  4311. // SetField sets the value of a field with the given name. It returns an error if
  4312. // the field is not defined in the schema, or if the type mismatched the field
  4313. // type.
  4314. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  4315. switch name {
  4316. case labelrelationship.FieldCreatedAt:
  4317. v, ok := value.(time.Time)
  4318. if !ok {
  4319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4320. }
  4321. m.SetCreatedAt(v)
  4322. return nil
  4323. case labelrelationship.FieldUpdatedAt:
  4324. v, ok := value.(time.Time)
  4325. if !ok {
  4326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4327. }
  4328. m.SetUpdatedAt(v)
  4329. return nil
  4330. case labelrelationship.FieldStatus:
  4331. v, ok := value.(uint8)
  4332. if !ok {
  4333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4334. }
  4335. m.SetStatus(v)
  4336. return nil
  4337. case labelrelationship.FieldDeletedAt:
  4338. v, ok := value.(time.Time)
  4339. if !ok {
  4340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4341. }
  4342. m.SetDeletedAt(v)
  4343. return nil
  4344. case labelrelationship.FieldLabelID:
  4345. v, ok := value.(uint64)
  4346. if !ok {
  4347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4348. }
  4349. m.SetLabelID(v)
  4350. return nil
  4351. case labelrelationship.FieldContactID:
  4352. v, ok := value.(uint64)
  4353. if !ok {
  4354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4355. }
  4356. m.SetContactID(v)
  4357. return nil
  4358. }
  4359. return fmt.Errorf("unknown LabelRelationship field %s", name)
  4360. }
  4361. // AddedFields returns all numeric fields that were incremented/decremented during
  4362. // this mutation.
  4363. func (m *LabelRelationshipMutation) AddedFields() []string {
  4364. var fields []string
  4365. if m.addstatus != nil {
  4366. fields = append(fields, labelrelationship.FieldStatus)
  4367. }
  4368. return fields
  4369. }
  4370. // AddedField returns the numeric value that was incremented/decremented on a field
  4371. // with the given name. The second boolean return value indicates that this field
  4372. // was not set, or was not defined in the schema.
  4373. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  4374. switch name {
  4375. case labelrelationship.FieldStatus:
  4376. return m.AddedStatus()
  4377. }
  4378. return nil, false
  4379. }
  4380. // AddField adds the value to the field with the given name. It returns an error if
  4381. // the field is not defined in the schema, or if the type mismatched the field
  4382. // type.
  4383. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  4384. switch name {
  4385. case labelrelationship.FieldStatus:
  4386. v, ok := value.(int8)
  4387. if !ok {
  4388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4389. }
  4390. m.AddStatus(v)
  4391. return nil
  4392. }
  4393. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  4394. }
  4395. // ClearedFields returns all nullable fields that were cleared during this
  4396. // mutation.
  4397. func (m *LabelRelationshipMutation) ClearedFields() []string {
  4398. var fields []string
  4399. if m.FieldCleared(labelrelationship.FieldStatus) {
  4400. fields = append(fields, labelrelationship.FieldStatus)
  4401. }
  4402. if m.FieldCleared(labelrelationship.FieldDeletedAt) {
  4403. fields = append(fields, labelrelationship.FieldDeletedAt)
  4404. }
  4405. return fields
  4406. }
  4407. // FieldCleared returns a boolean indicating if a field with the given name was
  4408. // cleared in this mutation.
  4409. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  4410. _, ok := m.clearedFields[name]
  4411. return ok
  4412. }
  4413. // ClearField clears the value of the field with the given name. It returns an
  4414. // error if the field is not defined in the schema.
  4415. func (m *LabelRelationshipMutation) ClearField(name string) error {
  4416. switch name {
  4417. case labelrelationship.FieldStatus:
  4418. m.ClearStatus()
  4419. return nil
  4420. case labelrelationship.FieldDeletedAt:
  4421. m.ClearDeletedAt()
  4422. return nil
  4423. }
  4424. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  4425. }
  4426. // ResetField resets all changes in the mutation for the field with the given name.
  4427. // It returns an error if the field is not defined in the schema.
  4428. func (m *LabelRelationshipMutation) ResetField(name string) error {
  4429. switch name {
  4430. case labelrelationship.FieldCreatedAt:
  4431. m.ResetCreatedAt()
  4432. return nil
  4433. case labelrelationship.FieldUpdatedAt:
  4434. m.ResetUpdatedAt()
  4435. return nil
  4436. case labelrelationship.FieldStatus:
  4437. m.ResetStatus()
  4438. return nil
  4439. case labelrelationship.FieldDeletedAt:
  4440. m.ResetDeletedAt()
  4441. return nil
  4442. case labelrelationship.FieldLabelID:
  4443. m.ResetLabelID()
  4444. return nil
  4445. case labelrelationship.FieldContactID:
  4446. m.ResetContactID()
  4447. return nil
  4448. }
  4449. return fmt.Errorf("unknown LabelRelationship field %s", name)
  4450. }
  4451. // AddedEdges returns all edge names that were set/added in this mutation.
  4452. func (m *LabelRelationshipMutation) AddedEdges() []string {
  4453. edges := make([]string, 0, 2)
  4454. if m.contacts != nil {
  4455. edges = append(edges, labelrelationship.EdgeContacts)
  4456. }
  4457. if m.labels != nil {
  4458. edges = append(edges, labelrelationship.EdgeLabels)
  4459. }
  4460. return edges
  4461. }
  4462. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4463. // name in this mutation.
  4464. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  4465. switch name {
  4466. case labelrelationship.EdgeContacts:
  4467. if id := m.contacts; id != nil {
  4468. return []ent.Value{*id}
  4469. }
  4470. case labelrelationship.EdgeLabels:
  4471. if id := m.labels; id != nil {
  4472. return []ent.Value{*id}
  4473. }
  4474. }
  4475. return nil
  4476. }
  4477. // RemovedEdges returns all edge names that were removed in this mutation.
  4478. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  4479. edges := make([]string, 0, 2)
  4480. return edges
  4481. }
  4482. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4483. // the given name in this mutation.
  4484. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  4485. return nil
  4486. }
  4487. // ClearedEdges returns all edge names that were cleared in this mutation.
  4488. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  4489. edges := make([]string, 0, 2)
  4490. if m.clearedcontacts {
  4491. edges = append(edges, labelrelationship.EdgeContacts)
  4492. }
  4493. if m.clearedlabels {
  4494. edges = append(edges, labelrelationship.EdgeLabels)
  4495. }
  4496. return edges
  4497. }
  4498. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4499. // was cleared in this mutation.
  4500. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  4501. switch name {
  4502. case labelrelationship.EdgeContacts:
  4503. return m.clearedcontacts
  4504. case labelrelationship.EdgeLabels:
  4505. return m.clearedlabels
  4506. }
  4507. return false
  4508. }
  4509. // ClearEdge clears the value of the edge with the given name. It returns an error
  4510. // if that edge is not defined in the schema.
  4511. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  4512. switch name {
  4513. case labelrelationship.EdgeContacts:
  4514. m.ClearContacts()
  4515. return nil
  4516. case labelrelationship.EdgeLabels:
  4517. m.ClearLabels()
  4518. return nil
  4519. }
  4520. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  4521. }
  4522. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4523. // It returns an error if the edge is not defined in the schema.
  4524. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  4525. switch name {
  4526. case labelrelationship.EdgeContacts:
  4527. m.ResetContacts()
  4528. return nil
  4529. case labelrelationship.EdgeLabels:
  4530. m.ResetLabels()
  4531. return nil
  4532. }
  4533. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  4534. }
  4535. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  4536. type MessageMutation struct {
  4537. config
  4538. op Op
  4539. typ string
  4540. id *int
  4541. wx_wxid *string
  4542. wxid *string
  4543. content *string
  4544. clearedFields map[string]struct{}
  4545. done bool
  4546. oldValue func(context.Context) (*Message, error)
  4547. predicates []predicate.Message
  4548. }
  4549. var _ ent.Mutation = (*MessageMutation)(nil)
  4550. // messageOption allows management of the mutation configuration using functional options.
  4551. type messageOption func(*MessageMutation)
  4552. // newMessageMutation creates new mutation for the Message entity.
  4553. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  4554. m := &MessageMutation{
  4555. config: c,
  4556. op: op,
  4557. typ: TypeMessage,
  4558. clearedFields: make(map[string]struct{}),
  4559. }
  4560. for _, opt := range opts {
  4561. opt(m)
  4562. }
  4563. return m
  4564. }
  4565. // withMessageID sets the ID field of the mutation.
  4566. func withMessageID(id int) messageOption {
  4567. return func(m *MessageMutation) {
  4568. var (
  4569. err error
  4570. once sync.Once
  4571. value *Message
  4572. )
  4573. m.oldValue = func(ctx context.Context) (*Message, error) {
  4574. once.Do(func() {
  4575. if m.done {
  4576. err = errors.New("querying old values post mutation is not allowed")
  4577. } else {
  4578. value, err = m.Client().Message.Get(ctx, id)
  4579. }
  4580. })
  4581. return value, err
  4582. }
  4583. m.id = &id
  4584. }
  4585. }
  4586. // withMessage sets the old Message of the mutation.
  4587. func withMessage(node *Message) messageOption {
  4588. return func(m *MessageMutation) {
  4589. m.oldValue = func(context.Context) (*Message, error) {
  4590. return node, nil
  4591. }
  4592. m.id = &node.ID
  4593. }
  4594. }
  4595. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4596. // executed in a transaction (ent.Tx), a transactional client is returned.
  4597. func (m MessageMutation) Client() *Client {
  4598. client := &Client{config: m.config}
  4599. client.init()
  4600. return client
  4601. }
  4602. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4603. // it returns an error otherwise.
  4604. func (m MessageMutation) Tx() (*Tx, error) {
  4605. if _, ok := m.driver.(*txDriver); !ok {
  4606. return nil, errors.New("ent: mutation is not running in a transaction")
  4607. }
  4608. tx := &Tx{config: m.config}
  4609. tx.init()
  4610. return tx, nil
  4611. }
  4612. // ID returns the ID value in the mutation. Note that the ID is only available
  4613. // if it was provided to the builder or after it was returned from the database.
  4614. func (m *MessageMutation) ID() (id int, exists bool) {
  4615. if m.id == nil {
  4616. return
  4617. }
  4618. return *m.id, true
  4619. }
  4620. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4621. // That means, if the mutation is applied within a transaction with an isolation level such
  4622. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4623. // or updated by the mutation.
  4624. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  4625. switch {
  4626. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4627. id, exists := m.ID()
  4628. if exists {
  4629. return []int{id}, nil
  4630. }
  4631. fallthrough
  4632. case m.op.Is(OpUpdate | OpDelete):
  4633. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  4634. default:
  4635. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4636. }
  4637. }
  4638. // SetWxWxid sets the "wx_wxid" field.
  4639. func (m *MessageMutation) SetWxWxid(s string) {
  4640. m.wx_wxid = &s
  4641. }
  4642. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  4643. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  4644. v := m.wx_wxid
  4645. if v == nil {
  4646. return
  4647. }
  4648. return *v, true
  4649. }
  4650. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  4651. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  4652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4653. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  4654. if !m.op.Is(OpUpdateOne) {
  4655. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  4656. }
  4657. if m.id == nil || m.oldValue == nil {
  4658. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  4659. }
  4660. oldValue, err := m.oldValue(ctx)
  4661. if err != nil {
  4662. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  4663. }
  4664. return oldValue.WxWxid, nil
  4665. }
  4666. // ClearWxWxid clears the value of the "wx_wxid" field.
  4667. func (m *MessageMutation) ClearWxWxid() {
  4668. m.wx_wxid = nil
  4669. m.clearedFields[message.FieldWxWxid] = struct{}{}
  4670. }
  4671. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  4672. func (m *MessageMutation) WxWxidCleared() bool {
  4673. _, ok := m.clearedFields[message.FieldWxWxid]
  4674. return ok
  4675. }
  4676. // ResetWxWxid resets all changes to the "wx_wxid" field.
  4677. func (m *MessageMutation) ResetWxWxid() {
  4678. m.wx_wxid = nil
  4679. delete(m.clearedFields, message.FieldWxWxid)
  4680. }
  4681. // SetWxid sets the "wxid" field.
  4682. func (m *MessageMutation) SetWxid(s string) {
  4683. m.wxid = &s
  4684. }
  4685. // Wxid returns the value of the "wxid" field in the mutation.
  4686. func (m *MessageMutation) Wxid() (r string, exists bool) {
  4687. v := m.wxid
  4688. if v == nil {
  4689. return
  4690. }
  4691. return *v, true
  4692. }
  4693. // OldWxid returns the old "wxid" field's value of the Message entity.
  4694. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  4695. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4696. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  4697. if !m.op.Is(OpUpdateOne) {
  4698. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  4699. }
  4700. if m.id == nil || m.oldValue == nil {
  4701. return v, errors.New("OldWxid requires an ID field in the mutation")
  4702. }
  4703. oldValue, err := m.oldValue(ctx)
  4704. if err != nil {
  4705. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  4706. }
  4707. return oldValue.Wxid, nil
  4708. }
  4709. // ResetWxid resets all changes to the "wxid" field.
  4710. func (m *MessageMutation) ResetWxid() {
  4711. m.wxid = nil
  4712. }
  4713. // SetContent sets the "content" field.
  4714. func (m *MessageMutation) SetContent(s string) {
  4715. m.content = &s
  4716. }
  4717. // Content returns the value of the "content" field in the mutation.
  4718. func (m *MessageMutation) Content() (r string, exists bool) {
  4719. v := m.content
  4720. if v == nil {
  4721. return
  4722. }
  4723. return *v, true
  4724. }
  4725. // OldContent returns the old "content" field's value of the Message entity.
  4726. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  4727. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4728. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  4729. if !m.op.Is(OpUpdateOne) {
  4730. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  4731. }
  4732. if m.id == nil || m.oldValue == nil {
  4733. return v, errors.New("OldContent requires an ID field in the mutation")
  4734. }
  4735. oldValue, err := m.oldValue(ctx)
  4736. if err != nil {
  4737. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  4738. }
  4739. return oldValue.Content, nil
  4740. }
  4741. // ResetContent resets all changes to the "content" field.
  4742. func (m *MessageMutation) ResetContent() {
  4743. m.content = nil
  4744. }
  4745. // Where appends a list predicates to the MessageMutation builder.
  4746. func (m *MessageMutation) Where(ps ...predicate.Message) {
  4747. m.predicates = append(m.predicates, ps...)
  4748. }
  4749. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  4750. // users can use type-assertion to append predicates that do not depend on any generated package.
  4751. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  4752. p := make([]predicate.Message, len(ps))
  4753. for i := range ps {
  4754. p[i] = ps[i]
  4755. }
  4756. m.Where(p...)
  4757. }
  4758. // Op returns the operation name.
  4759. func (m *MessageMutation) Op() Op {
  4760. return m.op
  4761. }
  4762. // SetOp allows setting the mutation operation.
  4763. func (m *MessageMutation) SetOp(op Op) {
  4764. m.op = op
  4765. }
  4766. // Type returns the node type of this mutation (Message).
  4767. func (m *MessageMutation) Type() string {
  4768. return m.typ
  4769. }
  4770. // Fields returns all fields that were changed during this mutation. Note that in
  4771. // order to get all numeric fields that were incremented/decremented, call
  4772. // AddedFields().
  4773. func (m *MessageMutation) Fields() []string {
  4774. fields := make([]string, 0, 3)
  4775. if m.wx_wxid != nil {
  4776. fields = append(fields, message.FieldWxWxid)
  4777. }
  4778. if m.wxid != nil {
  4779. fields = append(fields, message.FieldWxid)
  4780. }
  4781. if m.content != nil {
  4782. fields = append(fields, message.FieldContent)
  4783. }
  4784. return fields
  4785. }
  4786. // Field returns the value of a field with the given name. The second boolean
  4787. // return value indicates that this field was not set, or was not defined in the
  4788. // schema.
  4789. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  4790. switch name {
  4791. case message.FieldWxWxid:
  4792. return m.WxWxid()
  4793. case message.FieldWxid:
  4794. return m.Wxid()
  4795. case message.FieldContent:
  4796. return m.Content()
  4797. }
  4798. return nil, false
  4799. }
  4800. // OldField returns the old value of the field from the database. An error is
  4801. // returned if the mutation operation is not UpdateOne, or the query to the
  4802. // database failed.
  4803. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4804. switch name {
  4805. case message.FieldWxWxid:
  4806. return m.OldWxWxid(ctx)
  4807. case message.FieldWxid:
  4808. return m.OldWxid(ctx)
  4809. case message.FieldContent:
  4810. return m.OldContent(ctx)
  4811. }
  4812. return nil, fmt.Errorf("unknown Message field %s", name)
  4813. }
  4814. // SetField sets the value of a field with the given name. It returns an error if
  4815. // the field is not defined in the schema, or if the type mismatched the field
  4816. // type.
  4817. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  4818. switch name {
  4819. case message.FieldWxWxid:
  4820. v, ok := value.(string)
  4821. if !ok {
  4822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4823. }
  4824. m.SetWxWxid(v)
  4825. return nil
  4826. case message.FieldWxid:
  4827. v, ok := value.(string)
  4828. if !ok {
  4829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4830. }
  4831. m.SetWxid(v)
  4832. return nil
  4833. case message.FieldContent:
  4834. v, ok := value.(string)
  4835. if !ok {
  4836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4837. }
  4838. m.SetContent(v)
  4839. return nil
  4840. }
  4841. return fmt.Errorf("unknown Message field %s", name)
  4842. }
  4843. // AddedFields returns all numeric fields that were incremented/decremented during
  4844. // this mutation.
  4845. func (m *MessageMutation) AddedFields() []string {
  4846. return nil
  4847. }
  4848. // AddedField returns the numeric value that was incremented/decremented on a field
  4849. // with the given name. The second boolean return value indicates that this field
  4850. // was not set, or was not defined in the schema.
  4851. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  4852. return nil, false
  4853. }
  4854. // AddField adds the value to the field with the given name. It returns an error if
  4855. // the field is not defined in the schema, or if the type mismatched the field
  4856. // type.
  4857. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  4858. switch name {
  4859. }
  4860. return fmt.Errorf("unknown Message numeric field %s", name)
  4861. }
  4862. // ClearedFields returns all nullable fields that were cleared during this
  4863. // mutation.
  4864. func (m *MessageMutation) ClearedFields() []string {
  4865. var fields []string
  4866. if m.FieldCleared(message.FieldWxWxid) {
  4867. fields = append(fields, message.FieldWxWxid)
  4868. }
  4869. return fields
  4870. }
  4871. // FieldCleared returns a boolean indicating if a field with the given name was
  4872. // cleared in this mutation.
  4873. func (m *MessageMutation) FieldCleared(name string) bool {
  4874. _, ok := m.clearedFields[name]
  4875. return ok
  4876. }
  4877. // ClearField clears the value of the field with the given name. It returns an
  4878. // error if the field is not defined in the schema.
  4879. func (m *MessageMutation) ClearField(name string) error {
  4880. switch name {
  4881. case message.FieldWxWxid:
  4882. m.ClearWxWxid()
  4883. return nil
  4884. }
  4885. return fmt.Errorf("unknown Message nullable field %s", name)
  4886. }
  4887. // ResetField resets all changes in the mutation for the field with the given name.
  4888. // It returns an error if the field is not defined in the schema.
  4889. func (m *MessageMutation) ResetField(name string) error {
  4890. switch name {
  4891. case message.FieldWxWxid:
  4892. m.ResetWxWxid()
  4893. return nil
  4894. case message.FieldWxid:
  4895. m.ResetWxid()
  4896. return nil
  4897. case message.FieldContent:
  4898. m.ResetContent()
  4899. return nil
  4900. }
  4901. return fmt.Errorf("unknown Message field %s", name)
  4902. }
  4903. // AddedEdges returns all edge names that were set/added in this mutation.
  4904. func (m *MessageMutation) AddedEdges() []string {
  4905. edges := make([]string, 0, 0)
  4906. return edges
  4907. }
  4908. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4909. // name in this mutation.
  4910. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  4911. return nil
  4912. }
  4913. // RemovedEdges returns all edge names that were removed in this mutation.
  4914. func (m *MessageMutation) RemovedEdges() []string {
  4915. edges := make([]string, 0, 0)
  4916. return edges
  4917. }
  4918. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4919. // the given name in this mutation.
  4920. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  4921. return nil
  4922. }
  4923. // ClearedEdges returns all edge names that were cleared in this mutation.
  4924. func (m *MessageMutation) ClearedEdges() []string {
  4925. edges := make([]string, 0, 0)
  4926. return edges
  4927. }
  4928. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4929. // was cleared in this mutation.
  4930. func (m *MessageMutation) EdgeCleared(name string) bool {
  4931. return false
  4932. }
  4933. // ClearEdge clears the value of the edge with the given name. It returns an error
  4934. // if that edge is not defined in the schema.
  4935. func (m *MessageMutation) ClearEdge(name string) error {
  4936. return fmt.Errorf("unknown Message unique edge %s", name)
  4937. }
  4938. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4939. // It returns an error if the edge is not defined in the schema.
  4940. func (m *MessageMutation) ResetEdge(name string) error {
  4941. return fmt.Errorf("unknown Message edge %s", name)
  4942. }
  4943. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  4944. type MessageRecordsMutation struct {
  4945. config
  4946. op Op
  4947. typ string
  4948. id *uint64
  4949. created_at *time.Time
  4950. updated_at *time.Time
  4951. status *uint8
  4952. addstatus *int8
  4953. deleted_at *time.Time
  4954. bot_wxid *string
  4955. contact_type *int
  4956. addcontact_type *int
  4957. contact_wxid *string
  4958. content_type *int
  4959. addcontent_type *int
  4960. content *string
  4961. meta *custom_types.Meta
  4962. error_detail *string
  4963. send_time *time.Time
  4964. source_type *int
  4965. addsource_type *int
  4966. clearedFields map[string]struct{}
  4967. sop_stage *uint64
  4968. clearedsop_stage bool
  4969. sop_node *uint64
  4970. clearedsop_node bool
  4971. message_contact *uint64
  4972. clearedmessage_contact bool
  4973. done bool
  4974. oldValue func(context.Context) (*MessageRecords, error)
  4975. predicates []predicate.MessageRecords
  4976. }
  4977. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  4978. // messagerecordsOption allows management of the mutation configuration using functional options.
  4979. type messagerecordsOption func(*MessageRecordsMutation)
  4980. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  4981. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  4982. m := &MessageRecordsMutation{
  4983. config: c,
  4984. op: op,
  4985. typ: TypeMessageRecords,
  4986. clearedFields: make(map[string]struct{}),
  4987. }
  4988. for _, opt := range opts {
  4989. opt(m)
  4990. }
  4991. return m
  4992. }
  4993. // withMessageRecordsID sets the ID field of the mutation.
  4994. func withMessageRecordsID(id uint64) messagerecordsOption {
  4995. return func(m *MessageRecordsMutation) {
  4996. var (
  4997. err error
  4998. once sync.Once
  4999. value *MessageRecords
  5000. )
  5001. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  5002. once.Do(func() {
  5003. if m.done {
  5004. err = errors.New("querying old values post mutation is not allowed")
  5005. } else {
  5006. value, err = m.Client().MessageRecords.Get(ctx, id)
  5007. }
  5008. })
  5009. return value, err
  5010. }
  5011. m.id = &id
  5012. }
  5013. }
  5014. // withMessageRecords sets the old MessageRecords of the mutation.
  5015. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  5016. return func(m *MessageRecordsMutation) {
  5017. m.oldValue = func(context.Context) (*MessageRecords, error) {
  5018. return node, nil
  5019. }
  5020. m.id = &node.ID
  5021. }
  5022. }
  5023. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5024. // executed in a transaction (ent.Tx), a transactional client is returned.
  5025. func (m MessageRecordsMutation) Client() *Client {
  5026. client := &Client{config: m.config}
  5027. client.init()
  5028. return client
  5029. }
  5030. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5031. // it returns an error otherwise.
  5032. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  5033. if _, ok := m.driver.(*txDriver); !ok {
  5034. return nil, errors.New("ent: mutation is not running in a transaction")
  5035. }
  5036. tx := &Tx{config: m.config}
  5037. tx.init()
  5038. return tx, nil
  5039. }
  5040. // SetID sets the value of the id field. Note that this
  5041. // operation is only accepted on creation of MessageRecords entities.
  5042. func (m *MessageRecordsMutation) SetID(id uint64) {
  5043. m.id = &id
  5044. }
  5045. // ID returns the ID value in the mutation. Note that the ID is only available
  5046. // if it was provided to the builder or after it was returned from the database.
  5047. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  5048. if m.id == nil {
  5049. return
  5050. }
  5051. return *m.id, true
  5052. }
  5053. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5054. // That means, if the mutation is applied within a transaction with an isolation level such
  5055. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5056. // or updated by the mutation.
  5057. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  5058. switch {
  5059. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5060. id, exists := m.ID()
  5061. if exists {
  5062. return []uint64{id}, nil
  5063. }
  5064. fallthrough
  5065. case m.op.Is(OpUpdate | OpDelete):
  5066. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  5067. default:
  5068. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5069. }
  5070. }
  5071. // SetCreatedAt sets the "created_at" field.
  5072. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  5073. m.created_at = &t
  5074. }
  5075. // CreatedAt returns the value of the "created_at" field in the mutation.
  5076. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  5077. v := m.created_at
  5078. if v == nil {
  5079. return
  5080. }
  5081. return *v, true
  5082. }
  5083. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  5084. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5085. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5086. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5087. if !m.op.Is(OpUpdateOne) {
  5088. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5089. }
  5090. if m.id == nil || m.oldValue == nil {
  5091. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5092. }
  5093. oldValue, err := m.oldValue(ctx)
  5094. if err != nil {
  5095. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5096. }
  5097. return oldValue.CreatedAt, nil
  5098. }
  5099. // ResetCreatedAt resets all changes to the "created_at" field.
  5100. func (m *MessageRecordsMutation) ResetCreatedAt() {
  5101. m.created_at = nil
  5102. }
  5103. // SetUpdatedAt sets the "updated_at" field.
  5104. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  5105. m.updated_at = &t
  5106. }
  5107. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5108. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  5109. v := m.updated_at
  5110. if v == nil {
  5111. return
  5112. }
  5113. return *v, true
  5114. }
  5115. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  5116. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5117. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5118. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5119. if !m.op.Is(OpUpdateOne) {
  5120. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5121. }
  5122. if m.id == nil || m.oldValue == nil {
  5123. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5124. }
  5125. oldValue, err := m.oldValue(ctx)
  5126. if err != nil {
  5127. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5128. }
  5129. return oldValue.UpdatedAt, nil
  5130. }
  5131. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5132. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  5133. m.updated_at = nil
  5134. }
  5135. // SetStatus sets the "status" field.
  5136. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  5137. m.status = &u
  5138. m.addstatus = nil
  5139. }
  5140. // Status returns the value of the "status" field in the mutation.
  5141. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  5142. v := m.status
  5143. if v == nil {
  5144. return
  5145. }
  5146. return *v, true
  5147. }
  5148. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  5149. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5151. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  5152. if !m.op.Is(OpUpdateOne) {
  5153. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5154. }
  5155. if m.id == nil || m.oldValue == nil {
  5156. return v, errors.New("OldStatus requires an ID field in the mutation")
  5157. }
  5158. oldValue, err := m.oldValue(ctx)
  5159. if err != nil {
  5160. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5161. }
  5162. return oldValue.Status, nil
  5163. }
  5164. // AddStatus adds u to the "status" field.
  5165. func (m *MessageRecordsMutation) AddStatus(u int8) {
  5166. if m.addstatus != nil {
  5167. *m.addstatus += u
  5168. } else {
  5169. m.addstatus = &u
  5170. }
  5171. }
  5172. // AddedStatus returns the value that was added to the "status" field in this mutation.
  5173. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  5174. v := m.addstatus
  5175. if v == nil {
  5176. return
  5177. }
  5178. return *v, true
  5179. }
  5180. // ClearStatus clears the value of the "status" field.
  5181. func (m *MessageRecordsMutation) ClearStatus() {
  5182. m.status = nil
  5183. m.addstatus = nil
  5184. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  5185. }
  5186. // StatusCleared returns if the "status" field was cleared in this mutation.
  5187. func (m *MessageRecordsMutation) StatusCleared() bool {
  5188. _, ok := m.clearedFields[messagerecords.FieldStatus]
  5189. return ok
  5190. }
  5191. // ResetStatus resets all changes to the "status" field.
  5192. func (m *MessageRecordsMutation) ResetStatus() {
  5193. m.status = nil
  5194. m.addstatus = nil
  5195. delete(m.clearedFields, messagerecords.FieldStatus)
  5196. }
  5197. // SetDeletedAt sets the "deleted_at" field.
  5198. func (m *MessageRecordsMutation) SetDeletedAt(t time.Time) {
  5199. m.deleted_at = &t
  5200. }
  5201. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5202. func (m *MessageRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  5203. v := m.deleted_at
  5204. if v == nil {
  5205. return
  5206. }
  5207. return *v, true
  5208. }
  5209. // OldDeletedAt returns the old "deleted_at" field's value of the MessageRecords entity.
  5210. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5211. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5212. func (m *MessageRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5213. if !m.op.Is(OpUpdateOne) {
  5214. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5215. }
  5216. if m.id == nil || m.oldValue == nil {
  5217. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5218. }
  5219. oldValue, err := m.oldValue(ctx)
  5220. if err != nil {
  5221. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5222. }
  5223. return oldValue.DeletedAt, nil
  5224. }
  5225. // ClearDeletedAt clears the value of the "deleted_at" field.
  5226. func (m *MessageRecordsMutation) ClearDeletedAt() {
  5227. m.deleted_at = nil
  5228. m.clearedFields[messagerecords.FieldDeletedAt] = struct{}{}
  5229. }
  5230. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5231. func (m *MessageRecordsMutation) DeletedAtCleared() bool {
  5232. _, ok := m.clearedFields[messagerecords.FieldDeletedAt]
  5233. return ok
  5234. }
  5235. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5236. func (m *MessageRecordsMutation) ResetDeletedAt() {
  5237. m.deleted_at = nil
  5238. delete(m.clearedFields, messagerecords.FieldDeletedAt)
  5239. }
  5240. // SetBotWxid sets the "bot_wxid" field.
  5241. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  5242. m.bot_wxid = &s
  5243. }
  5244. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  5245. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  5246. v := m.bot_wxid
  5247. if v == nil {
  5248. return
  5249. }
  5250. return *v, true
  5251. }
  5252. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  5253. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5255. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  5256. if !m.op.Is(OpUpdateOne) {
  5257. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  5258. }
  5259. if m.id == nil || m.oldValue == nil {
  5260. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  5261. }
  5262. oldValue, err := m.oldValue(ctx)
  5263. if err != nil {
  5264. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  5265. }
  5266. return oldValue.BotWxid, nil
  5267. }
  5268. // ResetBotWxid resets all changes to the "bot_wxid" field.
  5269. func (m *MessageRecordsMutation) ResetBotWxid() {
  5270. m.bot_wxid = nil
  5271. }
  5272. // SetContactID sets the "contact_id" field.
  5273. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  5274. m.message_contact = &u
  5275. }
  5276. // ContactID returns the value of the "contact_id" field in the mutation.
  5277. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  5278. v := m.message_contact
  5279. if v == nil {
  5280. return
  5281. }
  5282. return *v, true
  5283. }
  5284. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  5285. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5286. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5287. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  5288. if !m.op.Is(OpUpdateOne) {
  5289. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  5290. }
  5291. if m.id == nil || m.oldValue == nil {
  5292. return v, errors.New("OldContactID requires an ID field in the mutation")
  5293. }
  5294. oldValue, err := m.oldValue(ctx)
  5295. if err != nil {
  5296. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  5297. }
  5298. return oldValue.ContactID, nil
  5299. }
  5300. // ClearContactID clears the value of the "contact_id" field.
  5301. func (m *MessageRecordsMutation) ClearContactID() {
  5302. m.message_contact = nil
  5303. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  5304. }
  5305. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  5306. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  5307. _, ok := m.clearedFields[messagerecords.FieldContactID]
  5308. return ok
  5309. }
  5310. // ResetContactID resets all changes to the "contact_id" field.
  5311. func (m *MessageRecordsMutation) ResetContactID() {
  5312. m.message_contact = nil
  5313. delete(m.clearedFields, messagerecords.FieldContactID)
  5314. }
  5315. // SetContactType sets the "contact_type" field.
  5316. func (m *MessageRecordsMutation) SetContactType(i int) {
  5317. m.contact_type = &i
  5318. m.addcontact_type = nil
  5319. }
  5320. // ContactType returns the value of the "contact_type" field in the mutation.
  5321. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  5322. v := m.contact_type
  5323. if v == nil {
  5324. return
  5325. }
  5326. return *v, true
  5327. }
  5328. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  5329. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5330. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5331. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  5332. if !m.op.Is(OpUpdateOne) {
  5333. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  5334. }
  5335. if m.id == nil || m.oldValue == nil {
  5336. return v, errors.New("OldContactType requires an ID field in the mutation")
  5337. }
  5338. oldValue, err := m.oldValue(ctx)
  5339. if err != nil {
  5340. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  5341. }
  5342. return oldValue.ContactType, nil
  5343. }
  5344. // AddContactType adds i to the "contact_type" field.
  5345. func (m *MessageRecordsMutation) AddContactType(i int) {
  5346. if m.addcontact_type != nil {
  5347. *m.addcontact_type += i
  5348. } else {
  5349. m.addcontact_type = &i
  5350. }
  5351. }
  5352. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  5353. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  5354. v := m.addcontact_type
  5355. if v == nil {
  5356. return
  5357. }
  5358. return *v, true
  5359. }
  5360. // ResetContactType resets all changes to the "contact_type" field.
  5361. func (m *MessageRecordsMutation) ResetContactType() {
  5362. m.contact_type = nil
  5363. m.addcontact_type = nil
  5364. }
  5365. // SetContactWxid sets the "contact_wxid" field.
  5366. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  5367. m.contact_wxid = &s
  5368. }
  5369. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  5370. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  5371. v := m.contact_wxid
  5372. if v == nil {
  5373. return
  5374. }
  5375. return *v, true
  5376. }
  5377. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  5378. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5379. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5380. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  5381. if !m.op.Is(OpUpdateOne) {
  5382. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  5383. }
  5384. if m.id == nil || m.oldValue == nil {
  5385. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  5386. }
  5387. oldValue, err := m.oldValue(ctx)
  5388. if err != nil {
  5389. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  5390. }
  5391. return oldValue.ContactWxid, nil
  5392. }
  5393. // ResetContactWxid resets all changes to the "contact_wxid" field.
  5394. func (m *MessageRecordsMutation) ResetContactWxid() {
  5395. m.contact_wxid = nil
  5396. }
  5397. // SetContentType sets the "content_type" field.
  5398. func (m *MessageRecordsMutation) SetContentType(i int) {
  5399. m.content_type = &i
  5400. m.addcontent_type = nil
  5401. }
  5402. // ContentType returns the value of the "content_type" field in the mutation.
  5403. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  5404. v := m.content_type
  5405. if v == nil {
  5406. return
  5407. }
  5408. return *v, true
  5409. }
  5410. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  5411. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5412. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5413. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  5414. if !m.op.Is(OpUpdateOne) {
  5415. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  5416. }
  5417. if m.id == nil || m.oldValue == nil {
  5418. return v, errors.New("OldContentType requires an ID field in the mutation")
  5419. }
  5420. oldValue, err := m.oldValue(ctx)
  5421. if err != nil {
  5422. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  5423. }
  5424. return oldValue.ContentType, nil
  5425. }
  5426. // AddContentType adds i to the "content_type" field.
  5427. func (m *MessageRecordsMutation) AddContentType(i int) {
  5428. if m.addcontent_type != nil {
  5429. *m.addcontent_type += i
  5430. } else {
  5431. m.addcontent_type = &i
  5432. }
  5433. }
  5434. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  5435. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  5436. v := m.addcontent_type
  5437. if v == nil {
  5438. return
  5439. }
  5440. return *v, true
  5441. }
  5442. // ResetContentType resets all changes to the "content_type" field.
  5443. func (m *MessageRecordsMutation) ResetContentType() {
  5444. m.content_type = nil
  5445. m.addcontent_type = nil
  5446. }
  5447. // SetContent sets the "content" field.
  5448. func (m *MessageRecordsMutation) SetContent(s string) {
  5449. m.content = &s
  5450. }
  5451. // Content returns the value of the "content" field in the mutation.
  5452. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  5453. v := m.content
  5454. if v == nil {
  5455. return
  5456. }
  5457. return *v, true
  5458. }
  5459. // OldContent returns the old "content" field's value of the MessageRecords entity.
  5460. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5461. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5462. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  5463. if !m.op.Is(OpUpdateOne) {
  5464. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  5465. }
  5466. if m.id == nil || m.oldValue == nil {
  5467. return v, errors.New("OldContent requires an ID field in the mutation")
  5468. }
  5469. oldValue, err := m.oldValue(ctx)
  5470. if err != nil {
  5471. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  5472. }
  5473. return oldValue.Content, nil
  5474. }
  5475. // ResetContent resets all changes to the "content" field.
  5476. func (m *MessageRecordsMutation) ResetContent() {
  5477. m.content = nil
  5478. }
  5479. // SetMeta sets the "meta" field.
  5480. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  5481. m.meta = &ct
  5482. }
  5483. // Meta returns the value of the "meta" field in the mutation.
  5484. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  5485. v := m.meta
  5486. if v == nil {
  5487. return
  5488. }
  5489. return *v, true
  5490. }
  5491. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  5492. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5494. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  5495. if !m.op.Is(OpUpdateOne) {
  5496. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  5497. }
  5498. if m.id == nil || m.oldValue == nil {
  5499. return v, errors.New("OldMeta requires an ID field in the mutation")
  5500. }
  5501. oldValue, err := m.oldValue(ctx)
  5502. if err != nil {
  5503. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  5504. }
  5505. return oldValue.Meta, nil
  5506. }
  5507. // ClearMeta clears the value of the "meta" field.
  5508. func (m *MessageRecordsMutation) ClearMeta() {
  5509. m.meta = nil
  5510. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  5511. }
  5512. // MetaCleared returns if the "meta" field was cleared in this mutation.
  5513. func (m *MessageRecordsMutation) MetaCleared() bool {
  5514. _, ok := m.clearedFields[messagerecords.FieldMeta]
  5515. return ok
  5516. }
  5517. // ResetMeta resets all changes to the "meta" field.
  5518. func (m *MessageRecordsMutation) ResetMeta() {
  5519. m.meta = nil
  5520. delete(m.clearedFields, messagerecords.FieldMeta)
  5521. }
  5522. // SetErrorDetail sets the "error_detail" field.
  5523. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  5524. m.error_detail = &s
  5525. }
  5526. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  5527. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  5528. v := m.error_detail
  5529. if v == nil {
  5530. return
  5531. }
  5532. return *v, true
  5533. }
  5534. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  5535. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5537. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  5538. if !m.op.Is(OpUpdateOne) {
  5539. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  5540. }
  5541. if m.id == nil || m.oldValue == nil {
  5542. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  5543. }
  5544. oldValue, err := m.oldValue(ctx)
  5545. if err != nil {
  5546. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  5547. }
  5548. return oldValue.ErrorDetail, nil
  5549. }
  5550. // ResetErrorDetail resets all changes to the "error_detail" field.
  5551. func (m *MessageRecordsMutation) ResetErrorDetail() {
  5552. m.error_detail = nil
  5553. }
  5554. // SetSendTime sets the "send_time" field.
  5555. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  5556. m.send_time = &t
  5557. }
  5558. // SendTime returns the value of the "send_time" field in the mutation.
  5559. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  5560. v := m.send_time
  5561. if v == nil {
  5562. return
  5563. }
  5564. return *v, true
  5565. }
  5566. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  5567. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5568. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5569. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  5570. if !m.op.Is(OpUpdateOne) {
  5571. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  5572. }
  5573. if m.id == nil || m.oldValue == nil {
  5574. return v, errors.New("OldSendTime requires an ID field in the mutation")
  5575. }
  5576. oldValue, err := m.oldValue(ctx)
  5577. if err != nil {
  5578. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  5579. }
  5580. return oldValue.SendTime, nil
  5581. }
  5582. // ClearSendTime clears the value of the "send_time" field.
  5583. func (m *MessageRecordsMutation) ClearSendTime() {
  5584. m.send_time = nil
  5585. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  5586. }
  5587. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  5588. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  5589. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  5590. return ok
  5591. }
  5592. // ResetSendTime resets all changes to the "send_time" field.
  5593. func (m *MessageRecordsMutation) ResetSendTime() {
  5594. m.send_time = nil
  5595. delete(m.clearedFields, messagerecords.FieldSendTime)
  5596. }
  5597. // SetSourceType sets the "source_type" field.
  5598. func (m *MessageRecordsMutation) SetSourceType(i int) {
  5599. m.source_type = &i
  5600. m.addsource_type = nil
  5601. }
  5602. // SourceType returns the value of the "source_type" field in the mutation.
  5603. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  5604. v := m.source_type
  5605. if v == nil {
  5606. return
  5607. }
  5608. return *v, true
  5609. }
  5610. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  5611. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5612. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5613. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  5614. if !m.op.Is(OpUpdateOne) {
  5615. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  5616. }
  5617. if m.id == nil || m.oldValue == nil {
  5618. return v, errors.New("OldSourceType requires an ID field in the mutation")
  5619. }
  5620. oldValue, err := m.oldValue(ctx)
  5621. if err != nil {
  5622. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  5623. }
  5624. return oldValue.SourceType, nil
  5625. }
  5626. // AddSourceType adds i to the "source_type" field.
  5627. func (m *MessageRecordsMutation) AddSourceType(i int) {
  5628. if m.addsource_type != nil {
  5629. *m.addsource_type += i
  5630. } else {
  5631. m.addsource_type = &i
  5632. }
  5633. }
  5634. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  5635. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  5636. v := m.addsource_type
  5637. if v == nil {
  5638. return
  5639. }
  5640. return *v, true
  5641. }
  5642. // ResetSourceType resets all changes to the "source_type" field.
  5643. func (m *MessageRecordsMutation) ResetSourceType() {
  5644. m.source_type = nil
  5645. m.addsource_type = nil
  5646. }
  5647. // SetSourceID sets the "source_id" field.
  5648. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  5649. m.sop_stage = &u
  5650. }
  5651. // SourceID returns the value of the "source_id" field in the mutation.
  5652. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  5653. v := m.sop_stage
  5654. if v == nil {
  5655. return
  5656. }
  5657. return *v, true
  5658. }
  5659. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  5660. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5661. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5662. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  5663. if !m.op.Is(OpUpdateOne) {
  5664. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  5665. }
  5666. if m.id == nil || m.oldValue == nil {
  5667. return v, errors.New("OldSourceID requires an ID field in the mutation")
  5668. }
  5669. oldValue, err := m.oldValue(ctx)
  5670. if err != nil {
  5671. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  5672. }
  5673. return oldValue.SourceID, nil
  5674. }
  5675. // ClearSourceID clears the value of the "source_id" field.
  5676. func (m *MessageRecordsMutation) ClearSourceID() {
  5677. m.sop_stage = nil
  5678. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  5679. }
  5680. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  5681. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  5682. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  5683. return ok
  5684. }
  5685. // ResetSourceID resets all changes to the "source_id" field.
  5686. func (m *MessageRecordsMutation) ResetSourceID() {
  5687. m.sop_stage = nil
  5688. delete(m.clearedFields, messagerecords.FieldSourceID)
  5689. }
  5690. // SetSubSourceID sets the "sub_source_id" field.
  5691. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  5692. m.sop_node = &u
  5693. }
  5694. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  5695. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  5696. v := m.sop_node
  5697. if v == nil {
  5698. return
  5699. }
  5700. return *v, true
  5701. }
  5702. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  5703. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5704. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5705. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  5706. if !m.op.Is(OpUpdateOne) {
  5707. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  5708. }
  5709. if m.id == nil || m.oldValue == nil {
  5710. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  5711. }
  5712. oldValue, err := m.oldValue(ctx)
  5713. if err != nil {
  5714. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  5715. }
  5716. return oldValue.SubSourceID, nil
  5717. }
  5718. // ClearSubSourceID clears the value of the "sub_source_id" field.
  5719. func (m *MessageRecordsMutation) ClearSubSourceID() {
  5720. m.sop_node = nil
  5721. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  5722. }
  5723. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  5724. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  5725. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  5726. return ok
  5727. }
  5728. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  5729. func (m *MessageRecordsMutation) ResetSubSourceID() {
  5730. m.sop_node = nil
  5731. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  5732. }
  5733. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  5734. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  5735. m.sop_stage = &id
  5736. }
  5737. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  5738. func (m *MessageRecordsMutation) ClearSopStage() {
  5739. m.clearedsop_stage = true
  5740. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  5741. }
  5742. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  5743. func (m *MessageRecordsMutation) SopStageCleared() bool {
  5744. return m.SourceIDCleared() || m.clearedsop_stage
  5745. }
  5746. // SopStageID returns the "sop_stage" edge ID in the mutation.
  5747. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  5748. if m.sop_stage != nil {
  5749. return *m.sop_stage, true
  5750. }
  5751. return
  5752. }
  5753. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  5754. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  5755. // SopStageID instead. It exists only for internal usage by the builders.
  5756. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  5757. if id := m.sop_stage; id != nil {
  5758. ids = append(ids, *id)
  5759. }
  5760. return
  5761. }
  5762. // ResetSopStage resets all changes to the "sop_stage" edge.
  5763. func (m *MessageRecordsMutation) ResetSopStage() {
  5764. m.sop_stage = nil
  5765. m.clearedsop_stage = false
  5766. }
  5767. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  5768. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  5769. m.sop_node = &id
  5770. }
  5771. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  5772. func (m *MessageRecordsMutation) ClearSopNode() {
  5773. m.clearedsop_node = true
  5774. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  5775. }
  5776. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  5777. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  5778. return m.SubSourceIDCleared() || m.clearedsop_node
  5779. }
  5780. // SopNodeID returns the "sop_node" edge ID in the mutation.
  5781. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  5782. if m.sop_node != nil {
  5783. return *m.sop_node, true
  5784. }
  5785. return
  5786. }
  5787. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  5788. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  5789. // SopNodeID instead. It exists only for internal usage by the builders.
  5790. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  5791. if id := m.sop_node; id != nil {
  5792. ids = append(ids, *id)
  5793. }
  5794. return
  5795. }
  5796. // ResetSopNode resets all changes to the "sop_node" edge.
  5797. func (m *MessageRecordsMutation) ResetSopNode() {
  5798. m.sop_node = nil
  5799. m.clearedsop_node = false
  5800. }
  5801. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  5802. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  5803. m.message_contact = &id
  5804. }
  5805. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  5806. func (m *MessageRecordsMutation) ClearMessageContact() {
  5807. m.clearedmessage_contact = true
  5808. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  5809. }
  5810. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  5811. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  5812. return m.ContactIDCleared() || m.clearedmessage_contact
  5813. }
  5814. // MessageContactID returns the "message_contact" edge ID in the mutation.
  5815. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  5816. if m.message_contact != nil {
  5817. return *m.message_contact, true
  5818. }
  5819. return
  5820. }
  5821. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  5822. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  5823. // MessageContactID instead. It exists only for internal usage by the builders.
  5824. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  5825. if id := m.message_contact; id != nil {
  5826. ids = append(ids, *id)
  5827. }
  5828. return
  5829. }
  5830. // ResetMessageContact resets all changes to the "message_contact" edge.
  5831. func (m *MessageRecordsMutation) ResetMessageContact() {
  5832. m.message_contact = nil
  5833. m.clearedmessage_contact = false
  5834. }
  5835. // Where appends a list predicates to the MessageRecordsMutation builder.
  5836. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  5837. m.predicates = append(m.predicates, ps...)
  5838. }
  5839. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  5840. // users can use type-assertion to append predicates that do not depend on any generated package.
  5841. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  5842. p := make([]predicate.MessageRecords, len(ps))
  5843. for i := range ps {
  5844. p[i] = ps[i]
  5845. }
  5846. m.Where(p...)
  5847. }
  5848. // Op returns the operation name.
  5849. func (m *MessageRecordsMutation) Op() Op {
  5850. return m.op
  5851. }
  5852. // SetOp allows setting the mutation operation.
  5853. func (m *MessageRecordsMutation) SetOp(op Op) {
  5854. m.op = op
  5855. }
  5856. // Type returns the node type of this mutation (MessageRecords).
  5857. func (m *MessageRecordsMutation) Type() string {
  5858. return m.typ
  5859. }
  5860. // Fields returns all fields that were changed during this mutation. Note that in
  5861. // order to get all numeric fields that were incremented/decremented, call
  5862. // AddedFields().
  5863. func (m *MessageRecordsMutation) Fields() []string {
  5864. fields := make([]string, 0, 16)
  5865. if m.created_at != nil {
  5866. fields = append(fields, messagerecords.FieldCreatedAt)
  5867. }
  5868. if m.updated_at != nil {
  5869. fields = append(fields, messagerecords.FieldUpdatedAt)
  5870. }
  5871. if m.status != nil {
  5872. fields = append(fields, messagerecords.FieldStatus)
  5873. }
  5874. if m.deleted_at != nil {
  5875. fields = append(fields, messagerecords.FieldDeletedAt)
  5876. }
  5877. if m.bot_wxid != nil {
  5878. fields = append(fields, messagerecords.FieldBotWxid)
  5879. }
  5880. if m.message_contact != nil {
  5881. fields = append(fields, messagerecords.FieldContactID)
  5882. }
  5883. if m.contact_type != nil {
  5884. fields = append(fields, messagerecords.FieldContactType)
  5885. }
  5886. if m.contact_wxid != nil {
  5887. fields = append(fields, messagerecords.FieldContactWxid)
  5888. }
  5889. if m.content_type != nil {
  5890. fields = append(fields, messagerecords.FieldContentType)
  5891. }
  5892. if m.content != nil {
  5893. fields = append(fields, messagerecords.FieldContent)
  5894. }
  5895. if m.meta != nil {
  5896. fields = append(fields, messagerecords.FieldMeta)
  5897. }
  5898. if m.error_detail != nil {
  5899. fields = append(fields, messagerecords.FieldErrorDetail)
  5900. }
  5901. if m.send_time != nil {
  5902. fields = append(fields, messagerecords.FieldSendTime)
  5903. }
  5904. if m.source_type != nil {
  5905. fields = append(fields, messagerecords.FieldSourceType)
  5906. }
  5907. if m.sop_stage != nil {
  5908. fields = append(fields, messagerecords.FieldSourceID)
  5909. }
  5910. if m.sop_node != nil {
  5911. fields = append(fields, messagerecords.FieldSubSourceID)
  5912. }
  5913. return fields
  5914. }
  5915. // Field returns the value of a field with the given name. The second boolean
  5916. // return value indicates that this field was not set, or was not defined in the
  5917. // schema.
  5918. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  5919. switch name {
  5920. case messagerecords.FieldCreatedAt:
  5921. return m.CreatedAt()
  5922. case messagerecords.FieldUpdatedAt:
  5923. return m.UpdatedAt()
  5924. case messagerecords.FieldStatus:
  5925. return m.Status()
  5926. case messagerecords.FieldDeletedAt:
  5927. return m.DeletedAt()
  5928. case messagerecords.FieldBotWxid:
  5929. return m.BotWxid()
  5930. case messagerecords.FieldContactID:
  5931. return m.ContactID()
  5932. case messagerecords.FieldContactType:
  5933. return m.ContactType()
  5934. case messagerecords.FieldContactWxid:
  5935. return m.ContactWxid()
  5936. case messagerecords.FieldContentType:
  5937. return m.ContentType()
  5938. case messagerecords.FieldContent:
  5939. return m.Content()
  5940. case messagerecords.FieldMeta:
  5941. return m.Meta()
  5942. case messagerecords.FieldErrorDetail:
  5943. return m.ErrorDetail()
  5944. case messagerecords.FieldSendTime:
  5945. return m.SendTime()
  5946. case messagerecords.FieldSourceType:
  5947. return m.SourceType()
  5948. case messagerecords.FieldSourceID:
  5949. return m.SourceID()
  5950. case messagerecords.FieldSubSourceID:
  5951. return m.SubSourceID()
  5952. }
  5953. return nil, false
  5954. }
  5955. // OldField returns the old value of the field from the database. An error is
  5956. // returned if the mutation operation is not UpdateOne, or the query to the
  5957. // database failed.
  5958. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5959. switch name {
  5960. case messagerecords.FieldCreatedAt:
  5961. return m.OldCreatedAt(ctx)
  5962. case messagerecords.FieldUpdatedAt:
  5963. return m.OldUpdatedAt(ctx)
  5964. case messagerecords.FieldStatus:
  5965. return m.OldStatus(ctx)
  5966. case messagerecords.FieldDeletedAt:
  5967. return m.OldDeletedAt(ctx)
  5968. case messagerecords.FieldBotWxid:
  5969. return m.OldBotWxid(ctx)
  5970. case messagerecords.FieldContactID:
  5971. return m.OldContactID(ctx)
  5972. case messagerecords.FieldContactType:
  5973. return m.OldContactType(ctx)
  5974. case messagerecords.FieldContactWxid:
  5975. return m.OldContactWxid(ctx)
  5976. case messagerecords.FieldContentType:
  5977. return m.OldContentType(ctx)
  5978. case messagerecords.FieldContent:
  5979. return m.OldContent(ctx)
  5980. case messagerecords.FieldMeta:
  5981. return m.OldMeta(ctx)
  5982. case messagerecords.FieldErrorDetail:
  5983. return m.OldErrorDetail(ctx)
  5984. case messagerecords.FieldSendTime:
  5985. return m.OldSendTime(ctx)
  5986. case messagerecords.FieldSourceType:
  5987. return m.OldSourceType(ctx)
  5988. case messagerecords.FieldSourceID:
  5989. return m.OldSourceID(ctx)
  5990. case messagerecords.FieldSubSourceID:
  5991. return m.OldSubSourceID(ctx)
  5992. }
  5993. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  5994. }
  5995. // SetField sets the value of a field with the given name. It returns an error if
  5996. // the field is not defined in the schema, or if the type mismatched the field
  5997. // type.
  5998. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  5999. switch name {
  6000. case messagerecords.FieldCreatedAt:
  6001. v, ok := value.(time.Time)
  6002. if !ok {
  6003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6004. }
  6005. m.SetCreatedAt(v)
  6006. return nil
  6007. case messagerecords.FieldUpdatedAt:
  6008. v, ok := value.(time.Time)
  6009. if !ok {
  6010. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6011. }
  6012. m.SetUpdatedAt(v)
  6013. return nil
  6014. case messagerecords.FieldStatus:
  6015. v, ok := value.(uint8)
  6016. if !ok {
  6017. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6018. }
  6019. m.SetStatus(v)
  6020. return nil
  6021. case messagerecords.FieldDeletedAt:
  6022. v, ok := value.(time.Time)
  6023. if !ok {
  6024. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6025. }
  6026. m.SetDeletedAt(v)
  6027. return nil
  6028. case messagerecords.FieldBotWxid:
  6029. v, ok := value.(string)
  6030. if !ok {
  6031. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6032. }
  6033. m.SetBotWxid(v)
  6034. return nil
  6035. case messagerecords.FieldContactID:
  6036. v, ok := value.(uint64)
  6037. if !ok {
  6038. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6039. }
  6040. m.SetContactID(v)
  6041. return nil
  6042. case messagerecords.FieldContactType:
  6043. v, ok := value.(int)
  6044. if !ok {
  6045. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6046. }
  6047. m.SetContactType(v)
  6048. return nil
  6049. case messagerecords.FieldContactWxid:
  6050. v, ok := value.(string)
  6051. if !ok {
  6052. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6053. }
  6054. m.SetContactWxid(v)
  6055. return nil
  6056. case messagerecords.FieldContentType:
  6057. v, ok := value.(int)
  6058. if !ok {
  6059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6060. }
  6061. m.SetContentType(v)
  6062. return nil
  6063. case messagerecords.FieldContent:
  6064. v, ok := value.(string)
  6065. if !ok {
  6066. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6067. }
  6068. m.SetContent(v)
  6069. return nil
  6070. case messagerecords.FieldMeta:
  6071. v, ok := value.(custom_types.Meta)
  6072. if !ok {
  6073. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6074. }
  6075. m.SetMeta(v)
  6076. return nil
  6077. case messagerecords.FieldErrorDetail:
  6078. v, ok := value.(string)
  6079. if !ok {
  6080. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6081. }
  6082. m.SetErrorDetail(v)
  6083. return nil
  6084. case messagerecords.FieldSendTime:
  6085. v, ok := value.(time.Time)
  6086. if !ok {
  6087. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6088. }
  6089. m.SetSendTime(v)
  6090. return nil
  6091. case messagerecords.FieldSourceType:
  6092. v, ok := value.(int)
  6093. if !ok {
  6094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6095. }
  6096. m.SetSourceType(v)
  6097. return nil
  6098. case messagerecords.FieldSourceID:
  6099. v, ok := value.(uint64)
  6100. if !ok {
  6101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6102. }
  6103. m.SetSourceID(v)
  6104. return nil
  6105. case messagerecords.FieldSubSourceID:
  6106. v, ok := value.(uint64)
  6107. if !ok {
  6108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6109. }
  6110. m.SetSubSourceID(v)
  6111. return nil
  6112. }
  6113. return fmt.Errorf("unknown MessageRecords field %s", name)
  6114. }
  6115. // AddedFields returns all numeric fields that were incremented/decremented during
  6116. // this mutation.
  6117. func (m *MessageRecordsMutation) AddedFields() []string {
  6118. var fields []string
  6119. if m.addstatus != nil {
  6120. fields = append(fields, messagerecords.FieldStatus)
  6121. }
  6122. if m.addcontact_type != nil {
  6123. fields = append(fields, messagerecords.FieldContactType)
  6124. }
  6125. if m.addcontent_type != nil {
  6126. fields = append(fields, messagerecords.FieldContentType)
  6127. }
  6128. if m.addsource_type != nil {
  6129. fields = append(fields, messagerecords.FieldSourceType)
  6130. }
  6131. return fields
  6132. }
  6133. // AddedField returns the numeric value that was incremented/decremented on a field
  6134. // with the given name. The second boolean return value indicates that this field
  6135. // was not set, or was not defined in the schema.
  6136. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  6137. switch name {
  6138. case messagerecords.FieldStatus:
  6139. return m.AddedStatus()
  6140. case messagerecords.FieldContactType:
  6141. return m.AddedContactType()
  6142. case messagerecords.FieldContentType:
  6143. return m.AddedContentType()
  6144. case messagerecords.FieldSourceType:
  6145. return m.AddedSourceType()
  6146. }
  6147. return nil, false
  6148. }
  6149. // AddField adds the value to the field with the given name. It returns an error if
  6150. // the field is not defined in the schema, or if the type mismatched the field
  6151. // type.
  6152. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  6153. switch name {
  6154. case messagerecords.FieldStatus:
  6155. v, ok := value.(int8)
  6156. if !ok {
  6157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6158. }
  6159. m.AddStatus(v)
  6160. return nil
  6161. case messagerecords.FieldContactType:
  6162. v, ok := value.(int)
  6163. if !ok {
  6164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6165. }
  6166. m.AddContactType(v)
  6167. return nil
  6168. case messagerecords.FieldContentType:
  6169. v, ok := value.(int)
  6170. if !ok {
  6171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6172. }
  6173. m.AddContentType(v)
  6174. return nil
  6175. case messagerecords.FieldSourceType:
  6176. v, ok := value.(int)
  6177. if !ok {
  6178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6179. }
  6180. m.AddSourceType(v)
  6181. return nil
  6182. }
  6183. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  6184. }
  6185. // ClearedFields returns all nullable fields that were cleared during this
  6186. // mutation.
  6187. func (m *MessageRecordsMutation) ClearedFields() []string {
  6188. var fields []string
  6189. if m.FieldCleared(messagerecords.FieldStatus) {
  6190. fields = append(fields, messagerecords.FieldStatus)
  6191. }
  6192. if m.FieldCleared(messagerecords.FieldDeletedAt) {
  6193. fields = append(fields, messagerecords.FieldDeletedAt)
  6194. }
  6195. if m.FieldCleared(messagerecords.FieldContactID) {
  6196. fields = append(fields, messagerecords.FieldContactID)
  6197. }
  6198. if m.FieldCleared(messagerecords.FieldMeta) {
  6199. fields = append(fields, messagerecords.FieldMeta)
  6200. }
  6201. if m.FieldCleared(messagerecords.FieldSendTime) {
  6202. fields = append(fields, messagerecords.FieldSendTime)
  6203. }
  6204. if m.FieldCleared(messagerecords.FieldSourceID) {
  6205. fields = append(fields, messagerecords.FieldSourceID)
  6206. }
  6207. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  6208. fields = append(fields, messagerecords.FieldSubSourceID)
  6209. }
  6210. return fields
  6211. }
  6212. // FieldCleared returns a boolean indicating if a field with the given name was
  6213. // cleared in this mutation.
  6214. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  6215. _, ok := m.clearedFields[name]
  6216. return ok
  6217. }
  6218. // ClearField clears the value of the field with the given name. It returns an
  6219. // error if the field is not defined in the schema.
  6220. func (m *MessageRecordsMutation) ClearField(name string) error {
  6221. switch name {
  6222. case messagerecords.FieldStatus:
  6223. m.ClearStatus()
  6224. return nil
  6225. case messagerecords.FieldDeletedAt:
  6226. m.ClearDeletedAt()
  6227. return nil
  6228. case messagerecords.FieldContactID:
  6229. m.ClearContactID()
  6230. return nil
  6231. case messagerecords.FieldMeta:
  6232. m.ClearMeta()
  6233. return nil
  6234. case messagerecords.FieldSendTime:
  6235. m.ClearSendTime()
  6236. return nil
  6237. case messagerecords.FieldSourceID:
  6238. m.ClearSourceID()
  6239. return nil
  6240. case messagerecords.FieldSubSourceID:
  6241. m.ClearSubSourceID()
  6242. return nil
  6243. }
  6244. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  6245. }
  6246. // ResetField resets all changes in the mutation for the field with the given name.
  6247. // It returns an error if the field is not defined in the schema.
  6248. func (m *MessageRecordsMutation) ResetField(name string) error {
  6249. switch name {
  6250. case messagerecords.FieldCreatedAt:
  6251. m.ResetCreatedAt()
  6252. return nil
  6253. case messagerecords.FieldUpdatedAt:
  6254. m.ResetUpdatedAt()
  6255. return nil
  6256. case messagerecords.FieldStatus:
  6257. m.ResetStatus()
  6258. return nil
  6259. case messagerecords.FieldDeletedAt:
  6260. m.ResetDeletedAt()
  6261. return nil
  6262. case messagerecords.FieldBotWxid:
  6263. m.ResetBotWxid()
  6264. return nil
  6265. case messagerecords.FieldContactID:
  6266. m.ResetContactID()
  6267. return nil
  6268. case messagerecords.FieldContactType:
  6269. m.ResetContactType()
  6270. return nil
  6271. case messagerecords.FieldContactWxid:
  6272. m.ResetContactWxid()
  6273. return nil
  6274. case messagerecords.FieldContentType:
  6275. m.ResetContentType()
  6276. return nil
  6277. case messagerecords.FieldContent:
  6278. m.ResetContent()
  6279. return nil
  6280. case messagerecords.FieldMeta:
  6281. m.ResetMeta()
  6282. return nil
  6283. case messagerecords.FieldErrorDetail:
  6284. m.ResetErrorDetail()
  6285. return nil
  6286. case messagerecords.FieldSendTime:
  6287. m.ResetSendTime()
  6288. return nil
  6289. case messagerecords.FieldSourceType:
  6290. m.ResetSourceType()
  6291. return nil
  6292. case messagerecords.FieldSourceID:
  6293. m.ResetSourceID()
  6294. return nil
  6295. case messagerecords.FieldSubSourceID:
  6296. m.ResetSubSourceID()
  6297. return nil
  6298. }
  6299. return fmt.Errorf("unknown MessageRecords field %s", name)
  6300. }
  6301. // AddedEdges returns all edge names that were set/added in this mutation.
  6302. func (m *MessageRecordsMutation) AddedEdges() []string {
  6303. edges := make([]string, 0, 3)
  6304. if m.sop_stage != nil {
  6305. edges = append(edges, messagerecords.EdgeSopStage)
  6306. }
  6307. if m.sop_node != nil {
  6308. edges = append(edges, messagerecords.EdgeSopNode)
  6309. }
  6310. if m.message_contact != nil {
  6311. edges = append(edges, messagerecords.EdgeMessageContact)
  6312. }
  6313. return edges
  6314. }
  6315. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6316. // name in this mutation.
  6317. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  6318. switch name {
  6319. case messagerecords.EdgeSopStage:
  6320. if id := m.sop_stage; id != nil {
  6321. return []ent.Value{*id}
  6322. }
  6323. case messagerecords.EdgeSopNode:
  6324. if id := m.sop_node; id != nil {
  6325. return []ent.Value{*id}
  6326. }
  6327. case messagerecords.EdgeMessageContact:
  6328. if id := m.message_contact; id != nil {
  6329. return []ent.Value{*id}
  6330. }
  6331. }
  6332. return nil
  6333. }
  6334. // RemovedEdges returns all edge names that were removed in this mutation.
  6335. func (m *MessageRecordsMutation) RemovedEdges() []string {
  6336. edges := make([]string, 0, 3)
  6337. return edges
  6338. }
  6339. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6340. // the given name in this mutation.
  6341. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  6342. return nil
  6343. }
  6344. // ClearedEdges returns all edge names that were cleared in this mutation.
  6345. func (m *MessageRecordsMutation) ClearedEdges() []string {
  6346. edges := make([]string, 0, 3)
  6347. if m.clearedsop_stage {
  6348. edges = append(edges, messagerecords.EdgeSopStage)
  6349. }
  6350. if m.clearedsop_node {
  6351. edges = append(edges, messagerecords.EdgeSopNode)
  6352. }
  6353. if m.clearedmessage_contact {
  6354. edges = append(edges, messagerecords.EdgeMessageContact)
  6355. }
  6356. return edges
  6357. }
  6358. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6359. // was cleared in this mutation.
  6360. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  6361. switch name {
  6362. case messagerecords.EdgeSopStage:
  6363. return m.clearedsop_stage
  6364. case messagerecords.EdgeSopNode:
  6365. return m.clearedsop_node
  6366. case messagerecords.EdgeMessageContact:
  6367. return m.clearedmessage_contact
  6368. }
  6369. return false
  6370. }
  6371. // ClearEdge clears the value of the edge with the given name. It returns an error
  6372. // if that edge is not defined in the schema.
  6373. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  6374. switch name {
  6375. case messagerecords.EdgeSopStage:
  6376. m.ClearSopStage()
  6377. return nil
  6378. case messagerecords.EdgeSopNode:
  6379. m.ClearSopNode()
  6380. return nil
  6381. case messagerecords.EdgeMessageContact:
  6382. m.ClearMessageContact()
  6383. return nil
  6384. }
  6385. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  6386. }
  6387. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6388. // It returns an error if the edge is not defined in the schema.
  6389. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  6390. switch name {
  6391. case messagerecords.EdgeSopStage:
  6392. m.ResetSopStage()
  6393. return nil
  6394. case messagerecords.EdgeSopNode:
  6395. m.ResetSopNode()
  6396. return nil
  6397. case messagerecords.EdgeMessageContact:
  6398. m.ResetMessageContact()
  6399. return nil
  6400. }
  6401. return fmt.Errorf("unknown MessageRecords edge %s", name)
  6402. }
  6403. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  6404. type ServerMutation struct {
  6405. config
  6406. op Op
  6407. typ string
  6408. id *uint64
  6409. created_at *time.Time
  6410. updated_at *time.Time
  6411. status *uint8
  6412. addstatus *int8
  6413. deleted_at *time.Time
  6414. name *string
  6415. public_ip *string
  6416. private_ip *string
  6417. admin_port *string
  6418. clearedFields map[string]struct{}
  6419. wxs map[uint64]struct{}
  6420. removedwxs map[uint64]struct{}
  6421. clearedwxs bool
  6422. done bool
  6423. oldValue func(context.Context) (*Server, error)
  6424. predicates []predicate.Server
  6425. }
  6426. var _ ent.Mutation = (*ServerMutation)(nil)
  6427. // serverOption allows management of the mutation configuration using functional options.
  6428. type serverOption func(*ServerMutation)
  6429. // newServerMutation creates new mutation for the Server entity.
  6430. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  6431. m := &ServerMutation{
  6432. config: c,
  6433. op: op,
  6434. typ: TypeServer,
  6435. clearedFields: make(map[string]struct{}),
  6436. }
  6437. for _, opt := range opts {
  6438. opt(m)
  6439. }
  6440. return m
  6441. }
  6442. // withServerID sets the ID field of the mutation.
  6443. func withServerID(id uint64) serverOption {
  6444. return func(m *ServerMutation) {
  6445. var (
  6446. err error
  6447. once sync.Once
  6448. value *Server
  6449. )
  6450. m.oldValue = func(ctx context.Context) (*Server, error) {
  6451. once.Do(func() {
  6452. if m.done {
  6453. err = errors.New("querying old values post mutation is not allowed")
  6454. } else {
  6455. value, err = m.Client().Server.Get(ctx, id)
  6456. }
  6457. })
  6458. return value, err
  6459. }
  6460. m.id = &id
  6461. }
  6462. }
  6463. // withServer sets the old Server of the mutation.
  6464. func withServer(node *Server) serverOption {
  6465. return func(m *ServerMutation) {
  6466. m.oldValue = func(context.Context) (*Server, error) {
  6467. return node, nil
  6468. }
  6469. m.id = &node.ID
  6470. }
  6471. }
  6472. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6473. // executed in a transaction (ent.Tx), a transactional client is returned.
  6474. func (m ServerMutation) Client() *Client {
  6475. client := &Client{config: m.config}
  6476. client.init()
  6477. return client
  6478. }
  6479. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6480. // it returns an error otherwise.
  6481. func (m ServerMutation) Tx() (*Tx, error) {
  6482. if _, ok := m.driver.(*txDriver); !ok {
  6483. return nil, errors.New("ent: mutation is not running in a transaction")
  6484. }
  6485. tx := &Tx{config: m.config}
  6486. tx.init()
  6487. return tx, nil
  6488. }
  6489. // SetID sets the value of the id field. Note that this
  6490. // operation is only accepted on creation of Server entities.
  6491. func (m *ServerMutation) SetID(id uint64) {
  6492. m.id = &id
  6493. }
  6494. // ID returns the ID value in the mutation. Note that the ID is only available
  6495. // if it was provided to the builder or after it was returned from the database.
  6496. func (m *ServerMutation) ID() (id uint64, exists bool) {
  6497. if m.id == nil {
  6498. return
  6499. }
  6500. return *m.id, true
  6501. }
  6502. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6503. // That means, if the mutation is applied within a transaction with an isolation level such
  6504. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6505. // or updated by the mutation.
  6506. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  6507. switch {
  6508. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6509. id, exists := m.ID()
  6510. if exists {
  6511. return []uint64{id}, nil
  6512. }
  6513. fallthrough
  6514. case m.op.Is(OpUpdate | OpDelete):
  6515. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  6516. default:
  6517. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6518. }
  6519. }
  6520. // SetCreatedAt sets the "created_at" field.
  6521. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  6522. m.created_at = &t
  6523. }
  6524. // CreatedAt returns the value of the "created_at" field in the mutation.
  6525. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  6526. v := m.created_at
  6527. if v == nil {
  6528. return
  6529. }
  6530. return *v, true
  6531. }
  6532. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  6533. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  6534. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6535. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6536. if !m.op.Is(OpUpdateOne) {
  6537. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6538. }
  6539. if m.id == nil || m.oldValue == nil {
  6540. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6541. }
  6542. oldValue, err := m.oldValue(ctx)
  6543. if err != nil {
  6544. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6545. }
  6546. return oldValue.CreatedAt, nil
  6547. }
  6548. // ResetCreatedAt resets all changes to the "created_at" field.
  6549. func (m *ServerMutation) ResetCreatedAt() {
  6550. m.created_at = nil
  6551. }
  6552. // SetUpdatedAt sets the "updated_at" field.
  6553. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  6554. m.updated_at = &t
  6555. }
  6556. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6557. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  6558. v := m.updated_at
  6559. if v == nil {
  6560. return
  6561. }
  6562. return *v, true
  6563. }
  6564. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  6565. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  6566. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6567. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6568. if !m.op.Is(OpUpdateOne) {
  6569. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6570. }
  6571. if m.id == nil || m.oldValue == nil {
  6572. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6573. }
  6574. oldValue, err := m.oldValue(ctx)
  6575. if err != nil {
  6576. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6577. }
  6578. return oldValue.UpdatedAt, nil
  6579. }
  6580. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6581. func (m *ServerMutation) ResetUpdatedAt() {
  6582. m.updated_at = nil
  6583. }
  6584. // SetStatus sets the "status" field.
  6585. func (m *ServerMutation) SetStatus(u uint8) {
  6586. m.status = &u
  6587. m.addstatus = nil
  6588. }
  6589. // Status returns the value of the "status" field in the mutation.
  6590. func (m *ServerMutation) Status() (r uint8, exists bool) {
  6591. v := m.status
  6592. if v == nil {
  6593. return
  6594. }
  6595. return *v, true
  6596. }
  6597. // OldStatus returns the old "status" field's value of the Server entity.
  6598. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  6599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6600. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  6601. if !m.op.Is(OpUpdateOne) {
  6602. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  6603. }
  6604. if m.id == nil || m.oldValue == nil {
  6605. return v, errors.New("OldStatus requires an ID field in the mutation")
  6606. }
  6607. oldValue, err := m.oldValue(ctx)
  6608. if err != nil {
  6609. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  6610. }
  6611. return oldValue.Status, nil
  6612. }
  6613. // AddStatus adds u to the "status" field.
  6614. func (m *ServerMutation) AddStatus(u int8) {
  6615. if m.addstatus != nil {
  6616. *m.addstatus += u
  6617. } else {
  6618. m.addstatus = &u
  6619. }
  6620. }
  6621. // AddedStatus returns the value that was added to the "status" field in this mutation.
  6622. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  6623. v := m.addstatus
  6624. if v == nil {
  6625. return
  6626. }
  6627. return *v, true
  6628. }
  6629. // ClearStatus clears the value of the "status" field.
  6630. func (m *ServerMutation) ClearStatus() {
  6631. m.status = nil
  6632. m.addstatus = nil
  6633. m.clearedFields[server.FieldStatus] = struct{}{}
  6634. }
  6635. // StatusCleared returns if the "status" field was cleared in this mutation.
  6636. func (m *ServerMutation) StatusCleared() bool {
  6637. _, ok := m.clearedFields[server.FieldStatus]
  6638. return ok
  6639. }
  6640. // ResetStatus resets all changes to the "status" field.
  6641. func (m *ServerMutation) ResetStatus() {
  6642. m.status = nil
  6643. m.addstatus = nil
  6644. delete(m.clearedFields, server.FieldStatus)
  6645. }
  6646. // SetDeletedAt sets the "deleted_at" field.
  6647. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  6648. m.deleted_at = &t
  6649. }
  6650. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6651. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  6652. v := m.deleted_at
  6653. if v == nil {
  6654. return
  6655. }
  6656. return *v, true
  6657. }
  6658. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  6659. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  6660. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6661. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6662. if !m.op.Is(OpUpdateOne) {
  6663. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6664. }
  6665. if m.id == nil || m.oldValue == nil {
  6666. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6667. }
  6668. oldValue, err := m.oldValue(ctx)
  6669. if err != nil {
  6670. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6671. }
  6672. return oldValue.DeletedAt, nil
  6673. }
  6674. // ClearDeletedAt clears the value of the "deleted_at" field.
  6675. func (m *ServerMutation) ClearDeletedAt() {
  6676. m.deleted_at = nil
  6677. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  6678. }
  6679. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6680. func (m *ServerMutation) DeletedAtCleared() bool {
  6681. _, ok := m.clearedFields[server.FieldDeletedAt]
  6682. return ok
  6683. }
  6684. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6685. func (m *ServerMutation) ResetDeletedAt() {
  6686. m.deleted_at = nil
  6687. delete(m.clearedFields, server.FieldDeletedAt)
  6688. }
  6689. // SetName sets the "name" field.
  6690. func (m *ServerMutation) SetName(s string) {
  6691. m.name = &s
  6692. }
  6693. // Name returns the value of the "name" field in the mutation.
  6694. func (m *ServerMutation) Name() (r string, exists bool) {
  6695. v := m.name
  6696. if v == nil {
  6697. return
  6698. }
  6699. return *v, true
  6700. }
  6701. // OldName returns the old "name" field's value of the Server entity.
  6702. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  6703. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6704. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  6705. if !m.op.Is(OpUpdateOne) {
  6706. return v, errors.New("OldName is only allowed on UpdateOne operations")
  6707. }
  6708. if m.id == nil || m.oldValue == nil {
  6709. return v, errors.New("OldName requires an ID field in the mutation")
  6710. }
  6711. oldValue, err := m.oldValue(ctx)
  6712. if err != nil {
  6713. return v, fmt.Errorf("querying old value for OldName: %w", err)
  6714. }
  6715. return oldValue.Name, nil
  6716. }
  6717. // ResetName resets all changes to the "name" field.
  6718. func (m *ServerMutation) ResetName() {
  6719. m.name = nil
  6720. }
  6721. // SetPublicIP sets the "public_ip" field.
  6722. func (m *ServerMutation) SetPublicIP(s string) {
  6723. m.public_ip = &s
  6724. }
  6725. // PublicIP returns the value of the "public_ip" field in the mutation.
  6726. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  6727. v := m.public_ip
  6728. if v == nil {
  6729. return
  6730. }
  6731. return *v, true
  6732. }
  6733. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  6734. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  6735. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6736. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  6737. if !m.op.Is(OpUpdateOne) {
  6738. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  6739. }
  6740. if m.id == nil || m.oldValue == nil {
  6741. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  6742. }
  6743. oldValue, err := m.oldValue(ctx)
  6744. if err != nil {
  6745. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  6746. }
  6747. return oldValue.PublicIP, nil
  6748. }
  6749. // ResetPublicIP resets all changes to the "public_ip" field.
  6750. func (m *ServerMutation) ResetPublicIP() {
  6751. m.public_ip = nil
  6752. }
  6753. // SetPrivateIP sets the "private_ip" field.
  6754. func (m *ServerMutation) SetPrivateIP(s string) {
  6755. m.private_ip = &s
  6756. }
  6757. // PrivateIP returns the value of the "private_ip" field in the mutation.
  6758. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  6759. v := m.private_ip
  6760. if v == nil {
  6761. return
  6762. }
  6763. return *v, true
  6764. }
  6765. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  6766. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  6767. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6768. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  6769. if !m.op.Is(OpUpdateOne) {
  6770. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  6771. }
  6772. if m.id == nil || m.oldValue == nil {
  6773. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  6774. }
  6775. oldValue, err := m.oldValue(ctx)
  6776. if err != nil {
  6777. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  6778. }
  6779. return oldValue.PrivateIP, nil
  6780. }
  6781. // ResetPrivateIP resets all changes to the "private_ip" field.
  6782. func (m *ServerMutation) ResetPrivateIP() {
  6783. m.private_ip = nil
  6784. }
  6785. // SetAdminPort sets the "admin_port" field.
  6786. func (m *ServerMutation) SetAdminPort(s string) {
  6787. m.admin_port = &s
  6788. }
  6789. // AdminPort returns the value of the "admin_port" field in the mutation.
  6790. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  6791. v := m.admin_port
  6792. if v == nil {
  6793. return
  6794. }
  6795. return *v, true
  6796. }
  6797. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  6798. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  6799. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6800. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  6801. if !m.op.Is(OpUpdateOne) {
  6802. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  6803. }
  6804. if m.id == nil || m.oldValue == nil {
  6805. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  6806. }
  6807. oldValue, err := m.oldValue(ctx)
  6808. if err != nil {
  6809. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  6810. }
  6811. return oldValue.AdminPort, nil
  6812. }
  6813. // ResetAdminPort resets all changes to the "admin_port" field.
  6814. func (m *ServerMutation) ResetAdminPort() {
  6815. m.admin_port = nil
  6816. }
  6817. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  6818. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  6819. if m.wxs == nil {
  6820. m.wxs = make(map[uint64]struct{})
  6821. }
  6822. for i := range ids {
  6823. m.wxs[ids[i]] = struct{}{}
  6824. }
  6825. }
  6826. // ClearWxs clears the "wxs" edge to the Wx entity.
  6827. func (m *ServerMutation) ClearWxs() {
  6828. m.clearedwxs = true
  6829. }
  6830. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  6831. func (m *ServerMutation) WxsCleared() bool {
  6832. return m.clearedwxs
  6833. }
  6834. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  6835. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  6836. if m.removedwxs == nil {
  6837. m.removedwxs = make(map[uint64]struct{})
  6838. }
  6839. for i := range ids {
  6840. delete(m.wxs, ids[i])
  6841. m.removedwxs[ids[i]] = struct{}{}
  6842. }
  6843. }
  6844. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  6845. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  6846. for id := range m.removedwxs {
  6847. ids = append(ids, id)
  6848. }
  6849. return
  6850. }
  6851. // WxsIDs returns the "wxs" edge IDs in the mutation.
  6852. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  6853. for id := range m.wxs {
  6854. ids = append(ids, id)
  6855. }
  6856. return
  6857. }
  6858. // ResetWxs resets all changes to the "wxs" edge.
  6859. func (m *ServerMutation) ResetWxs() {
  6860. m.wxs = nil
  6861. m.clearedwxs = false
  6862. m.removedwxs = nil
  6863. }
  6864. // Where appends a list predicates to the ServerMutation builder.
  6865. func (m *ServerMutation) Where(ps ...predicate.Server) {
  6866. m.predicates = append(m.predicates, ps...)
  6867. }
  6868. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  6869. // users can use type-assertion to append predicates that do not depend on any generated package.
  6870. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  6871. p := make([]predicate.Server, len(ps))
  6872. for i := range ps {
  6873. p[i] = ps[i]
  6874. }
  6875. m.Where(p...)
  6876. }
  6877. // Op returns the operation name.
  6878. func (m *ServerMutation) Op() Op {
  6879. return m.op
  6880. }
  6881. // SetOp allows setting the mutation operation.
  6882. func (m *ServerMutation) SetOp(op Op) {
  6883. m.op = op
  6884. }
  6885. // Type returns the node type of this mutation (Server).
  6886. func (m *ServerMutation) Type() string {
  6887. return m.typ
  6888. }
  6889. // Fields returns all fields that were changed during this mutation. Note that in
  6890. // order to get all numeric fields that were incremented/decremented, call
  6891. // AddedFields().
  6892. func (m *ServerMutation) Fields() []string {
  6893. fields := make([]string, 0, 8)
  6894. if m.created_at != nil {
  6895. fields = append(fields, server.FieldCreatedAt)
  6896. }
  6897. if m.updated_at != nil {
  6898. fields = append(fields, server.FieldUpdatedAt)
  6899. }
  6900. if m.status != nil {
  6901. fields = append(fields, server.FieldStatus)
  6902. }
  6903. if m.deleted_at != nil {
  6904. fields = append(fields, server.FieldDeletedAt)
  6905. }
  6906. if m.name != nil {
  6907. fields = append(fields, server.FieldName)
  6908. }
  6909. if m.public_ip != nil {
  6910. fields = append(fields, server.FieldPublicIP)
  6911. }
  6912. if m.private_ip != nil {
  6913. fields = append(fields, server.FieldPrivateIP)
  6914. }
  6915. if m.admin_port != nil {
  6916. fields = append(fields, server.FieldAdminPort)
  6917. }
  6918. return fields
  6919. }
  6920. // Field returns the value of a field with the given name. The second boolean
  6921. // return value indicates that this field was not set, or was not defined in the
  6922. // schema.
  6923. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  6924. switch name {
  6925. case server.FieldCreatedAt:
  6926. return m.CreatedAt()
  6927. case server.FieldUpdatedAt:
  6928. return m.UpdatedAt()
  6929. case server.FieldStatus:
  6930. return m.Status()
  6931. case server.FieldDeletedAt:
  6932. return m.DeletedAt()
  6933. case server.FieldName:
  6934. return m.Name()
  6935. case server.FieldPublicIP:
  6936. return m.PublicIP()
  6937. case server.FieldPrivateIP:
  6938. return m.PrivateIP()
  6939. case server.FieldAdminPort:
  6940. return m.AdminPort()
  6941. }
  6942. return nil, false
  6943. }
  6944. // OldField returns the old value of the field from the database. An error is
  6945. // returned if the mutation operation is not UpdateOne, or the query to the
  6946. // database failed.
  6947. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6948. switch name {
  6949. case server.FieldCreatedAt:
  6950. return m.OldCreatedAt(ctx)
  6951. case server.FieldUpdatedAt:
  6952. return m.OldUpdatedAt(ctx)
  6953. case server.FieldStatus:
  6954. return m.OldStatus(ctx)
  6955. case server.FieldDeletedAt:
  6956. return m.OldDeletedAt(ctx)
  6957. case server.FieldName:
  6958. return m.OldName(ctx)
  6959. case server.FieldPublicIP:
  6960. return m.OldPublicIP(ctx)
  6961. case server.FieldPrivateIP:
  6962. return m.OldPrivateIP(ctx)
  6963. case server.FieldAdminPort:
  6964. return m.OldAdminPort(ctx)
  6965. }
  6966. return nil, fmt.Errorf("unknown Server field %s", name)
  6967. }
  6968. // SetField sets the value of a field with the given name. It returns an error if
  6969. // the field is not defined in the schema, or if the type mismatched the field
  6970. // type.
  6971. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  6972. switch name {
  6973. case server.FieldCreatedAt:
  6974. v, ok := value.(time.Time)
  6975. if !ok {
  6976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6977. }
  6978. m.SetCreatedAt(v)
  6979. return nil
  6980. case server.FieldUpdatedAt:
  6981. v, ok := value.(time.Time)
  6982. if !ok {
  6983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6984. }
  6985. m.SetUpdatedAt(v)
  6986. return nil
  6987. case server.FieldStatus:
  6988. v, ok := value.(uint8)
  6989. if !ok {
  6990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6991. }
  6992. m.SetStatus(v)
  6993. return nil
  6994. case server.FieldDeletedAt:
  6995. v, ok := value.(time.Time)
  6996. if !ok {
  6997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6998. }
  6999. m.SetDeletedAt(v)
  7000. return nil
  7001. case server.FieldName:
  7002. v, ok := value.(string)
  7003. if !ok {
  7004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7005. }
  7006. m.SetName(v)
  7007. return nil
  7008. case server.FieldPublicIP:
  7009. v, ok := value.(string)
  7010. if !ok {
  7011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7012. }
  7013. m.SetPublicIP(v)
  7014. return nil
  7015. case server.FieldPrivateIP:
  7016. v, ok := value.(string)
  7017. if !ok {
  7018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7019. }
  7020. m.SetPrivateIP(v)
  7021. return nil
  7022. case server.FieldAdminPort:
  7023. v, ok := value.(string)
  7024. if !ok {
  7025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7026. }
  7027. m.SetAdminPort(v)
  7028. return nil
  7029. }
  7030. return fmt.Errorf("unknown Server field %s", name)
  7031. }
  7032. // AddedFields returns all numeric fields that were incremented/decremented during
  7033. // this mutation.
  7034. func (m *ServerMutation) AddedFields() []string {
  7035. var fields []string
  7036. if m.addstatus != nil {
  7037. fields = append(fields, server.FieldStatus)
  7038. }
  7039. return fields
  7040. }
  7041. // AddedField returns the numeric value that was incremented/decremented on a field
  7042. // with the given name. The second boolean return value indicates that this field
  7043. // was not set, or was not defined in the schema.
  7044. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  7045. switch name {
  7046. case server.FieldStatus:
  7047. return m.AddedStatus()
  7048. }
  7049. return nil, false
  7050. }
  7051. // AddField adds the value to the field with the given name. It returns an error if
  7052. // the field is not defined in the schema, or if the type mismatched the field
  7053. // type.
  7054. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  7055. switch name {
  7056. case server.FieldStatus:
  7057. v, ok := value.(int8)
  7058. if !ok {
  7059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7060. }
  7061. m.AddStatus(v)
  7062. return nil
  7063. }
  7064. return fmt.Errorf("unknown Server numeric field %s", name)
  7065. }
  7066. // ClearedFields returns all nullable fields that were cleared during this
  7067. // mutation.
  7068. func (m *ServerMutation) ClearedFields() []string {
  7069. var fields []string
  7070. if m.FieldCleared(server.FieldStatus) {
  7071. fields = append(fields, server.FieldStatus)
  7072. }
  7073. if m.FieldCleared(server.FieldDeletedAt) {
  7074. fields = append(fields, server.FieldDeletedAt)
  7075. }
  7076. return fields
  7077. }
  7078. // FieldCleared returns a boolean indicating if a field with the given name was
  7079. // cleared in this mutation.
  7080. func (m *ServerMutation) FieldCleared(name string) bool {
  7081. _, ok := m.clearedFields[name]
  7082. return ok
  7083. }
  7084. // ClearField clears the value of the field with the given name. It returns an
  7085. // error if the field is not defined in the schema.
  7086. func (m *ServerMutation) ClearField(name string) error {
  7087. switch name {
  7088. case server.FieldStatus:
  7089. m.ClearStatus()
  7090. return nil
  7091. case server.FieldDeletedAt:
  7092. m.ClearDeletedAt()
  7093. return nil
  7094. }
  7095. return fmt.Errorf("unknown Server nullable field %s", name)
  7096. }
  7097. // ResetField resets all changes in the mutation for the field with the given name.
  7098. // It returns an error if the field is not defined in the schema.
  7099. func (m *ServerMutation) ResetField(name string) error {
  7100. switch name {
  7101. case server.FieldCreatedAt:
  7102. m.ResetCreatedAt()
  7103. return nil
  7104. case server.FieldUpdatedAt:
  7105. m.ResetUpdatedAt()
  7106. return nil
  7107. case server.FieldStatus:
  7108. m.ResetStatus()
  7109. return nil
  7110. case server.FieldDeletedAt:
  7111. m.ResetDeletedAt()
  7112. return nil
  7113. case server.FieldName:
  7114. m.ResetName()
  7115. return nil
  7116. case server.FieldPublicIP:
  7117. m.ResetPublicIP()
  7118. return nil
  7119. case server.FieldPrivateIP:
  7120. m.ResetPrivateIP()
  7121. return nil
  7122. case server.FieldAdminPort:
  7123. m.ResetAdminPort()
  7124. return nil
  7125. }
  7126. return fmt.Errorf("unknown Server field %s", name)
  7127. }
  7128. // AddedEdges returns all edge names that were set/added in this mutation.
  7129. func (m *ServerMutation) AddedEdges() []string {
  7130. edges := make([]string, 0, 1)
  7131. if m.wxs != nil {
  7132. edges = append(edges, server.EdgeWxs)
  7133. }
  7134. return edges
  7135. }
  7136. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7137. // name in this mutation.
  7138. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  7139. switch name {
  7140. case server.EdgeWxs:
  7141. ids := make([]ent.Value, 0, len(m.wxs))
  7142. for id := range m.wxs {
  7143. ids = append(ids, id)
  7144. }
  7145. return ids
  7146. }
  7147. return nil
  7148. }
  7149. // RemovedEdges returns all edge names that were removed in this mutation.
  7150. func (m *ServerMutation) RemovedEdges() []string {
  7151. edges := make([]string, 0, 1)
  7152. if m.removedwxs != nil {
  7153. edges = append(edges, server.EdgeWxs)
  7154. }
  7155. return edges
  7156. }
  7157. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7158. // the given name in this mutation.
  7159. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  7160. switch name {
  7161. case server.EdgeWxs:
  7162. ids := make([]ent.Value, 0, len(m.removedwxs))
  7163. for id := range m.removedwxs {
  7164. ids = append(ids, id)
  7165. }
  7166. return ids
  7167. }
  7168. return nil
  7169. }
  7170. // ClearedEdges returns all edge names that were cleared in this mutation.
  7171. func (m *ServerMutation) ClearedEdges() []string {
  7172. edges := make([]string, 0, 1)
  7173. if m.clearedwxs {
  7174. edges = append(edges, server.EdgeWxs)
  7175. }
  7176. return edges
  7177. }
  7178. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7179. // was cleared in this mutation.
  7180. func (m *ServerMutation) EdgeCleared(name string) bool {
  7181. switch name {
  7182. case server.EdgeWxs:
  7183. return m.clearedwxs
  7184. }
  7185. return false
  7186. }
  7187. // ClearEdge clears the value of the edge with the given name. It returns an error
  7188. // if that edge is not defined in the schema.
  7189. func (m *ServerMutation) ClearEdge(name string) error {
  7190. switch name {
  7191. }
  7192. return fmt.Errorf("unknown Server unique edge %s", name)
  7193. }
  7194. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7195. // It returns an error if the edge is not defined in the schema.
  7196. func (m *ServerMutation) ResetEdge(name string) error {
  7197. switch name {
  7198. case server.EdgeWxs:
  7199. m.ResetWxs()
  7200. return nil
  7201. }
  7202. return fmt.Errorf("unknown Server edge %s", name)
  7203. }
  7204. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  7205. type SopNodeMutation struct {
  7206. config
  7207. op Op
  7208. typ string
  7209. id *uint64
  7210. created_at *time.Time
  7211. updated_at *time.Time
  7212. status *uint8
  7213. addstatus *int8
  7214. deleted_at *time.Time
  7215. parent_id *uint64
  7216. addparent_id *int64
  7217. name *string
  7218. condition_type *int
  7219. addcondition_type *int
  7220. condition_list *[]string
  7221. appendcondition_list []string
  7222. no_reply_condition *uint64
  7223. addno_reply_condition *int64
  7224. action_message *[]custom_types.Action
  7225. appendaction_message []custom_types.Action
  7226. action_label *[]uint64
  7227. appendaction_label []uint64
  7228. clearedFields map[string]struct{}
  7229. sop_stage *uint64
  7230. clearedsop_stage bool
  7231. node_messages map[uint64]struct{}
  7232. removednode_messages map[uint64]struct{}
  7233. clearednode_messages bool
  7234. done bool
  7235. oldValue func(context.Context) (*SopNode, error)
  7236. predicates []predicate.SopNode
  7237. }
  7238. var _ ent.Mutation = (*SopNodeMutation)(nil)
  7239. // sopnodeOption allows management of the mutation configuration using functional options.
  7240. type sopnodeOption func(*SopNodeMutation)
  7241. // newSopNodeMutation creates new mutation for the SopNode entity.
  7242. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  7243. m := &SopNodeMutation{
  7244. config: c,
  7245. op: op,
  7246. typ: TypeSopNode,
  7247. clearedFields: make(map[string]struct{}),
  7248. }
  7249. for _, opt := range opts {
  7250. opt(m)
  7251. }
  7252. return m
  7253. }
  7254. // withSopNodeID sets the ID field of the mutation.
  7255. func withSopNodeID(id uint64) sopnodeOption {
  7256. return func(m *SopNodeMutation) {
  7257. var (
  7258. err error
  7259. once sync.Once
  7260. value *SopNode
  7261. )
  7262. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  7263. once.Do(func() {
  7264. if m.done {
  7265. err = errors.New("querying old values post mutation is not allowed")
  7266. } else {
  7267. value, err = m.Client().SopNode.Get(ctx, id)
  7268. }
  7269. })
  7270. return value, err
  7271. }
  7272. m.id = &id
  7273. }
  7274. }
  7275. // withSopNode sets the old SopNode of the mutation.
  7276. func withSopNode(node *SopNode) sopnodeOption {
  7277. return func(m *SopNodeMutation) {
  7278. m.oldValue = func(context.Context) (*SopNode, error) {
  7279. return node, nil
  7280. }
  7281. m.id = &node.ID
  7282. }
  7283. }
  7284. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7285. // executed in a transaction (ent.Tx), a transactional client is returned.
  7286. func (m SopNodeMutation) Client() *Client {
  7287. client := &Client{config: m.config}
  7288. client.init()
  7289. return client
  7290. }
  7291. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7292. // it returns an error otherwise.
  7293. func (m SopNodeMutation) Tx() (*Tx, error) {
  7294. if _, ok := m.driver.(*txDriver); !ok {
  7295. return nil, errors.New("ent: mutation is not running in a transaction")
  7296. }
  7297. tx := &Tx{config: m.config}
  7298. tx.init()
  7299. return tx, nil
  7300. }
  7301. // SetID sets the value of the id field. Note that this
  7302. // operation is only accepted on creation of SopNode entities.
  7303. func (m *SopNodeMutation) SetID(id uint64) {
  7304. m.id = &id
  7305. }
  7306. // ID returns the ID value in the mutation. Note that the ID is only available
  7307. // if it was provided to the builder or after it was returned from the database.
  7308. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  7309. if m.id == nil {
  7310. return
  7311. }
  7312. return *m.id, true
  7313. }
  7314. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7315. // That means, if the mutation is applied within a transaction with an isolation level such
  7316. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7317. // or updated by the mutation.
  7318. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  7319. switch {
  7320. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7321. id, exists := m.ID()
  7322. if exists {
  7323. return []uint64{id}, nil
  7324. }
  7325. fallthrough
  7326. case m.op.Is(OpUpdate | OpDelete):
  7327. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  7328. default:
  7329. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7330. }
  7331. }
  7332. // SetCreatedAt sets the "created_at" field.
  7333. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  7334. m.created_at = &t
  7335. }
  7336. // CreatedAt returns the value of the "created_at" field in the mutation.
  7337. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  7338. v := m.created_at
  7339. if v == nil {
  7340. return
  7341. }
  7342. return *v, true
  7343. }
  7344. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  7345. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  7346. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7347. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7348. if !m.op.Is(OpUpdateOne) {
  7349. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7350. }
  7351. if m.id == nil || m.oldValue == nil {
  7352. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7353. }
  7354. oldValue, err := m.oldValue(ctx)
  7355. if err != nil {
  7356. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7357. }
  7358. return oldValue.CreatedAt, nil
  7359. }
  7360. // ResetCreatedAt resets all changes to the "created_at" field.
  7361. func (m *SopNodeMutation) ResetCreatedAt() {
  7362. m.created_at = nil
  7363. }
  7364. // SetUpdatedAt sets the "updated_at" field.
  7365. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  7366. m.updated_at = &t
  7367. }
  7368. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7369. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  7370. v := m.updated_at
  7371. if v == nil {
  7372. return
  7373. }
  7374. return *v, true
  7375. }
  7376. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  7377. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  7378. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7379. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7380. if !m.op.Is(OpUpdateOne) {
  7381. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7382. }
  7383. if m.id == nil || m.oldValue == nil {
  7384. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7385. }
  7386. oldValue, err := m.oldValue(ctx)
  7387. if err != nil {
  7388. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7389. }
  7390. return oldValue.UpdatedAt, nil
  7391. }
  7392. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7393. func (m *SopNodeMutation) ResetUpdatedAt() {
  7394. m.updated_at = nil
  7395. }
  7396. // SetStatus sets the "status" field.
  7397. func (m *SopNodeMutation) SetStatus(u uint8) {
  7398. m.status = &u
  7399. m.addstatus = nil
  7400. }
  7401. // Status returns the value of the "status" field in the mutation.
  7402. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  7403. v := m.status
  7404. if v == nil {
  7405. return
  7406. }
  7407. return *v, true
  7408. }
  7409. // OldStatus returns the old "status" field's value of the SopNode entity.
  7410. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  7411. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7412. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7413. if !m.op.Is(OpUpdateOne) {
  7414. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7415. }
  7416. if m.id == nil || m.oldValue == nil {
  7417. return v, errors.New("OldStatus requires an ID field in the mutation")
  7418. }
  7419. oldValue, err := m.oldValue(ctx)
  7420. if err != nil {
  7421. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7422. }
  7423. return oldValue.Status, nil
  7424. }
  7425. // AddStatus adds u to the "status" field.
  7426. func (m *SopNodeMutation) AddStatus(u int8) {
  7427. if m.addstatus != nil {
  7428. *m.addstatus += u
  7429. } else {
  7430. m.addstatus = &u
  7431. }
  7432. }
  7433. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7434. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  7435. v := m.addstatus
  7436. if v == nil {
  7437. return
  7438. }
  7439. return *v, true
  7440. }
  7441. // ClearStatus clears the value of the "status" field.
  7442. func (m *SopNodeMutation) ClearStatus() {
  7443. m.status = nil
  7444. m.addstatus = nil
  7445. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  7446. }
  7447. // StatusCleared returns if the "status" field was cleared in this mutation.
  7448. func (m *SopNodeMutation) StatusCleared() bool {
  7449. _, ok := m.clearedFields[sopnode.FieldStatus]
  7450. return ok
  7451. }
  7452. // ResetStatus resets all changes to the "status" field.
  7453. func (m *SopNodeMutation) ResetStatus() {
  7454. m.status = nil
  7455. m.addstatus = nil
  7456. delete(m.clearedFields, sopnode.FieldStatus)
  7457. }
  7458. // SetDeletedAt sets the "deleted_at" field.
  7459. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  7460. m.deleted_at = &t
  7461. }
  7462. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7463. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  7464. v := m.deleted_at
  7465. if v == nil {
  7466. return
  7467. }
  7468. return *v, true
  7469. }
  7470. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  7471. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  7472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7473. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7474. if !m.op.Is(OpUpdateOne) {
  7475. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7476. }
  7477. if m.id == nil || m.oldValue == nil {
  7478. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7479. }
  7480. oldValue, err := m.oldValue(ctx)
  7481. if err != nil {
  7482. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7483. }
  7484. return oldValue.DeletedAt, nil
  7485. }
  7486. // ClearDeletedAt clears the value of the "deleted_at" field.
  7487. func (m *SopNodeMutation) ClearDeletedAt() {
  7488. m.deleted_at = nil
  7489. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  7490. }
  7491. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7492. func (m *SopNodeMutation) DeletedAtCleared() bool {
  7493. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  7494. return ok
  7495. }
  7496. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7497. func (m *SopNodeMutation) ResetDeletedAt() {
  7498. m.deleted_at = nil
  7499. delete(m.clearedFields, sopnode.FieldDeletedAt)
  7500. }
  7501. // SetStageID sets the "stage_id" field.
  7502. func (m *SopNodeMutation) SetStageID(u uint64) {
  7503. m.sop_stage = &u
  7504. }
  7505. // StageID returns the value of the "stage_id" field in the mutation.
  7506. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  7507. v := m.sop_stage
  7508. if v == nil {
  7509. return
  7510. }
  7511. return *v, true
  7512. }
  7513. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  7514. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  7515. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7516. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  7517. if !m.op.Is(OpUpdateOne) {
  7518. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  7519. }
  7520. if m.id == nil || m.oldValue == nil {
  7521. return v, errors.New("OldStageID requires an ID field in the mutation")
  7522. }
  7523. oldValue, err := m.oldValue(ctx)
  7524. if err != nil {
  7525. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  7526. }
  7527. return oldValue.StageID, nil
  7528. }
  7529. // ResetStageID resets all changes to the "stage_id" field.
  7530. func (m *SopNodeMutation) ResetStageID() {
  7531. m.sop_stage = nil
  7532. }
  7533. // SetParentID sets the "parent_id" field.
  7534. func (m *SopNodeMutation) SetParentID(u uint64) {
  7535. m.parent_id = &u
  7536. m.addparent_id = nil
  7537. }
  7538. // ParentID returns the value of the "parent_id" field in the mutation.
  7539. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  7540. v := m.parent_id
  7541. if v == nil {
  7542. return
  7543. }
  7544. return *v, true
  7545. }
  7546. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  7547. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  7548. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7549. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  7550. if !m.op.Is(OpUpdateOne) {
  7551. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  7552. }
  7553. if m.id == nil || m.oldValue == nil {
  7554. return v, errors.New("OldParentID requires an ID field in the mutation")
  7555. }
  7556. oldValue, err := m.oldValue(ctx)
  7557. if err != nil {
  7558. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  7559. }
  7560. return oldValue.ParentID, nil
  7561. }
  7562. // AddParentID adds u to the "parent_id" field.
  7563. func (m *SopNodeMutation) AddParentID(u int64) {
  7564. if m.addparent_id != nil {
  7565. *m.addparent_id += u
  7566. } else {
  7567. m.addparent_id = &u
  7568. }
  7569. }
  7570. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  7571. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  7572. v := m.addparent_id
  7573. if v == nil {
  7574. return
  7575. }
  7576. return *v, true
  7577. }
  7578. // ResetParentID resets all changes to the "parent_id" field.
  7579. func (m *SopNodeMutation) ResetParentID() {
  7580. m.parent_id = nil
  7581. m.addparent_id = nil
  7582. }
  7583. // SetName sets the "name" field.
  7584. func (m *SopNodeMutation) SetName(s string) {
  7585. m.name = &s
  7586. }
  7587. // Name returns the value of the "name" field in the mutation.
  7588. func (m *SopNodeMutation) Name() (r string, exists bool) {
  7589. v := m.name
  7590. if v == nil {
  7591. return
  7592. }
  7593. return *v, true
  7594. }
  7595. // OldName returns the old "name" field's value of the SopNode entity.
  7596. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  7597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7598. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  7599. if !m.op.Is(OpUpdateOne) {
  7600. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7601. }
  7602. if m.id == nil || m.oldValue == nil {
  7603. return v, errors.New("OldName requires an ID field in the mutation")
  7604. }
  7605. oldValue, err := m.oldValue(ctx)
  7606. if err != nil {
  7607. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7608. }
  7609. return oldValue.Name, nil
  7610. }
  7611. // ResetName resets all changes to the "name" field.
  7612. func (m *SopNodeMutation) ResetName() {
  7613. m.name = nil
  7614. }
  7615. // SetConditionType sets the "condition_type" field.
  7616. func (m *SopNodeMutation) SetConditionType(i int) {
  7617. m.condition_type = &i
  7618. m.addcondition_type = nil
  7619. }
  7620. // ConditionType returns the value of the "condition_type" field in the mutation.
  7621. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  7622. v := m.condition_type
  7623. if v == nil {
  7624. return
  7625. }
  7626. return *v, true
  7627. }
  7628. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  7629. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  7630. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7631. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  7632. if !m.op.Is(OpUpdateOne) {
  7633. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  7634. }
  7635. if m.id == nil || m.oldValue == nil {
  7636. return v, errors.New("OldConditionType requires an ID field in the mutation")
  7637. }
  7638. oldValue, err := m.oldValue(ctx)
  7639. if err != nil {
  7640. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  7641. }
  7642. return oldValue.ConditionType, nil
  7643. }
  7644. // AddConditionType adds i to the "condition_type" field.
  7645. func (m *SopNodeMutation) AddConditionType(i int) {
  7646. if m.addcondition_type != nil {
  7647. *m.addcondition_type += i
  7648. } else {
  7649. m.addcondition_type = &i
  7650. }
  7651. }
  7652. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  7653. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  7654. v := m.addcondition_type
  7655. if v == nil {
  7656. return
  7657. }
  7658. return *v, true
  7659. }
  7660. // ResetConditionType resets all changes to the "condition_type" field.
  7661. func (m *SopNodeMutation) ResetConditionType() {
  7662. m.condition_type = nil
  7663. m.addcondition_type = nil
  7664. }
  7665. // SetConditionList sets the "condition_list" field.
  7666. func (m *SopNodeMutation) SetConditionList(s []string) {
  7667. m.condition_list = &s
  7668. m.appendcondition_list = nil
  7669. }
  7670. // ConditionList returns the value of the "condition_list" field in the mutation.
  7671. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  7672. v := m.condition_list
  7673. if v == nil {
  7674. return
  7675. }
  7676. return *v, true
  7677. }
  7678. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  7679. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  7680. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7681. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  7682. if !m.op.Is(OpUpdateOne) {
  7683. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  7684. }
  7685. if m.id == nil || m.oldValue == nil {
  7686. return v, errors.New("OldConditionList requires an ID field in the mutation")
  7687. }
  7688. oldValue, err := m.oldValue(ctx)
  7689. if err != nil {
  7690. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  7691. }
  7692. return oldValue.ConditionList, nil
  7693. }
  7694. // AppendConditionList adds s to the "condition_list" field.
  7695. func (m *SopNodeMutation) AppendConditionList(s []string) {
  7696. m.appendcondition_list = append(m.appendcondition_list, s...)
  7697. }
  7698. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  7699. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  7700. if len(m.appendcondition_list) == 0 {
  7701. return nil, false
  7702. }
  7703. return m.appendcondition_list, true
  7704. }
  7705. // ClearConditionList clears the value of the "condition_list" field.
  7706. func (m *SopNodeMutation) ClearConditionList() {
  7707. m.condition_list = nil
  7708. m.appendcondition_list = nil
  7709. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  7710. }
  7711. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  7712. func (m *SopNodeMutation) ConditionListCleared() bool {
  7713. _, ok := m.clearedFields[sopnode.FieldConditionList]
  7714. return ok
  7715. }
  7716. // ResetConditionList resets all changes to the "condition_list" field.
  7717. func (m *SopNodeMutation) ResetConditionList() {
  7718. m.condition_list = nil
  7719. m.appendcondition_list = nil
  7720. delete(m.clearedFields, sopnode.FieldConditionList)
  7721. }
  7722. // SetNoReplyCondition sets the "no_reply_condition" field.
  7723. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  7724. m.no_reply_condition = &u
  7725. m.addno_reply_condition = nil
  7726. }
  7727. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  7728. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  7729. v := m.no_reply_condition
  7730. if v == nil {
  7731. return
  7732. }
  7733. return *v, true
  7734. }
  7735. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  7736. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  7737. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7738. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  7739. if !m.op.Is(OpUpdateOne) {
  7740. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  7741. }
  7742. if m.id == nil || m.oldValue == nil {
  7743. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  7744. }
  7745. oldValue, err := m.oldValue(ctx)
  7746. if err != nil {
  7747. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  7748. }
  7749. return oldValue.NoReplyCondition, nil
  7750. }
  7751. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  7752. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  7753. if m.addno_reply_condition != nil {
  7754. *m.addno_reply_condition += u
  7755. } else {
  7756. m.addno_reply_condition = &u
  7757. }
  7758. }
  7759. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  7760. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  7761. v := m.addno_reply_condition
  7762. if v == nil {
  7763. return
  7764. }
  7765. return *v, true
  7766. }
  7767. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  7768. func (m *SopNodeMutation) ResetNoReplyCondition() {
  7769. m.no_reply_condition = nil
  7770. m.addno_reply_condition = nil
  7771. }
  7772. // SetActionMessage sets the "action_message" field.
  7773. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  7774. m.action_message = &ct
  7775. m.appendaction_message = nil
  7776. }
  7777. // ActionMessage returns the value of the "action_message" field in the mutation.
  7778. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  7779. v := m.action_message
  7780. if v == nil {
  7781. return
  7782. }
  7783. return *v, true
  7784. }
  7785. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  7786. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  7787. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7788. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  7789. if !m.op.Is(OpUpdateOne) {
  7790. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  7791. }
  7792. if m.id == nil || m.oldValue == nil {
  7793. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  7794. }
  7795. oldValue, err := m.oldValue(ctx)
  7796. if err != nil {
  7797. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  7798. }
  7799. return oldValue.ActionMessage, nil
  7800. }
  7801. // AppendActionMessage adds ct to the "action_message" field.
  7802. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  7803. m.appendaction_message = append(m.appendaction_message, ct...)
  7804. }
  7805. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  7806. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  7807. if len(m.appendaction_message) == 0 {
  7808. return nil, false
  7809. }
  7810. return m.appendaction_message, true
  7811. }
  7812. // ClearActionMessage clears the value of the "action_message" field.
  7813. func (m *SopNodeMutation) ClearActionMessage() {
  7814. m.action_message = nil
  7815. m.appendaction_message = nil
  7816. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  7817. }
  7818. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  7819. func (m *SopNodeMutation) ActionMessageCleared() bool {
  7820. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  7821. return ok
  7822. }
  7823. // ResetActionMessage resets all changes to the "action_message" field.
  7824. func (m *SopNodeMutation) ResetActionMessage() {
  7825. m.action_message = nil
  7826. m.appendaction_message = nil
  7827. delete(m.clearedFields, sopnode.FieldActionMessage)
  7828. }
  7829. // SetActionLabel sets the "action_label" field.
  7830. func (m *SopNodeMutation) SetActionLabel(u []uint64) {
  7831. m.action_label = &u
  7832. m.appendaction_label = nil
  7833. }
  7834. // ActionLabel returns the value of the "action_label" field in the mutation.
  7835. func (m *SopNodeMutation) ActionLabel() (r []uint64, exists bool) {
  7836. v := m.action_label
  7837. if v == nil {
  7838. return
  7839. }
  7840. return *v, true
  7841. }
  7842. // OldActionLabel returns the old "action_label" field's value of the SopNode entity.
  7843. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  7844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7845. func (m *SopNodeMutation) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  7846. if !m.op.Is(OpUpdateOne) {
  7847. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  7848. }
  7849. if m.id == nil || m.oldValue == nil {
  7850. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  7851. }
  7852. oldValue, err := m.oldValue(ctx)
  7853. if err != nil {
  7854. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  7855. }
  7856. return oldValue.ActionLabel, nil
  7857. }
  7858. // AppendActionLabel adds u to the "action_label" field.
  7859. func (m *SopNodeMutation) AppendActionLabel(u []uint64) {
  7860. m.appendaction_label = append(m.appendaction_label, u...)
  7861. }
  7862. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  7863. func (m *SopNodeMutation) AppendedActionLabel() ([]uint64, bool) {
  7864. if len(m.appendaction_label) == 0 {
  7865. return nil, false
  7866. }
  7867. return m.appendaction_label, true
  7868. }
  7869. // ClearActionLabel clears the value of the "action_label" field.
  7870. func (m *SopNodeMutation) ClearActionLabel() {
  7871. m.action_label = nil
  7872. m.appendaction_label = nil
  7873. m.clearedFields[sopnode.FieldActionLabel] = struct{}{}
  7874. }
  7875. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  7876. func (m *SopNodeMutation) ActionLabelCleared() bool {
  7877. _, ok := m.clearedFields[sopnode.FieldActionLabel]
  7878. return ok
  7879. }
  7880. // ResetActionLabel resets all changes to the "action_label" field.
  7881. func (m *SopNodeMutation) ResetActionLabel() {
  7882. m.action_label = nil
  7883. m.appendaction_label = nil
  7884. delete(m.clearedFields, sopnode.FieldActionLabel)
  7885. }
  7886. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  7887. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  7888. m.sop_stage = &id
  7889. }
  7890. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  7891. func (m *SopNodeMutation) ClearSopStage() {
  7892. m.clearedsop_stage = true
  7893. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  7894. }
  7895. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  7896. func (m *SopNodeMutation) SopStageCleared() bool {
  7897. return m.clearedsop_stage
  7898. }
  7899. // SopStageID returns the "sop_stage" edge ID in the mutation.
  7900. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  7901. if m.sop_stage != nil {
  7902. return *m.sop_stage, true
  7903. }
  7904. return
  7905. }
  7906. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  7907. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  7908. // SopStageID instead. It exists only for internal usage by the builders.
  7909. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  7910. if id := m.sop_stage; id != nil {
  7911. ids = append(ids, *id)
  7912. }
  7913. return
  7914. }
  7915. // ResetSopStage resets all changes to the "sop_stage" edge.
  7916. func (m *SopNodeMutation) ResetSopStage() {
  7917. m.sop_stage = nil
  7918. m.clearedsop_stage = false
  7919. }
  7920. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  7921. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  7922. if m.node_messages == nil {
  7923. m.node_messages = make(map[uint64]struct{})
  7924. }
  7925. for i := range ids {
  7926. m.node_messages[ids[i]] = struct{}{}
  7927. }
  7928. }
  7929. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  7930. func (m *SopNodeMutation) ClearNodeMessages() {
  7931. m.clearednode_messages = true
  7932. }
  7933. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  7934. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  7935. return m.clearednode_messages
  7936. }
  7937. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  7938. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  7939. if m.removednode_messages == nil {
  7940. m.removednode_messages = make(map[uint64]struct{})
  7941. }
  7942. for i := range ids {
  7943. delete(m.node_messages, ids[i])
  7944. m.removednode_messages[ids[i]] = struct{}{}
  7945. }
  7946. }
  7947. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  7948. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  7949. for id := range m.removednode_messages {
  7950. ids = append(ids, id)
  7951. }
  7952. return
  7953. }
  7954. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  7955. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  7956. for id := range m.node_messages {
  7957. ids = append(ids, id)
  7958. }
  7959. return
  7960. }
  7961. // ResetNodeMessages resets all changes to the "node_messages" edge.
  7962. func (m *SopNodeMutation) ResetNodeMessages() {
  7963. m.node_messages = nil
  7964. m.clearednode_messages = false
  7965. m.removednode_messages = nil
  7966. }
  7967. // Where appends a list predicates to the SopNodeMutation builder.
  7968. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  7969. m.predicates = append(m.predicates, ps...)
  7970. }
  7971. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  7972. // users can use type-assertion to append predicates that do not depend on any generated package.
  7973. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  7974. p := make([]predicate.SopNode, len(ps))
  7975. for i := range ps {
  7976. p[i] = ps[i]
  7977. }
  7978. m.Where(p...)
  7979. }
  7980. // Op returns the operation name.
  7981. func (m *SopNodeMutation) Op() Op {
  7982. return m.op
  7983. }
  7984. // SetOp allows setting the mutation operation.
  7985. func (m *SopNodeMutation) SetOp(op Op) {
  7986. m.op = op
  7987. }
  7988. // Type returns the node type of this mutation (SopNode).
  7989. func (m *SopNodeMutation) Type() string {
  7990. return m.typ
  7991. }
  7992. // Fields returns all fields that were changed during this mutation. Note that in
  7993. // order to get all numeric fields that were incremented/decremented, call
  7994. // AddedFields().
  7995. func (m *SopNodeMutation) Fields() []string {
  7996. fields := make([]string, 0, 12)
  7997. if m.created_at != nil {
  7998. fields = append(fields, sopnode.FieldCreatedAt)
  7999. }
  8000. if m.updated_at != nil {
  8001. fields = append(fields, sopnode.FieldUpdatedAt)
  8002. }
  8003. if m.status != nil {
  8004. fields = append(fields, sopnode.FieldStatus)
  8005. }
  8006. if m.deleted_at != nil {
  8007. fields = append(fields, sopnode.FieldDeletedAt)
  8008. }
  8009. if m.sop_stage != nil {
  8010. fields = append(fields, sopnode.FieldStageID)
  8011. }
  8012. if m.parent_id != nil {
  8013. fields = append(fields, sopnode.FieldParentID)
  8014. }
  8015. if m.name != nil {
  8016. fields = append(fields, sopnode.FieldName)
  8017. }
  8018. if m.condition_type != nil {
  8019. fields = append(fields, sopnode.FieldConditionType)
  8020. }
  8021. if m.condition_list != nil {
  8022. fields = append(fields, sopnode.FieldConditionList)
  8023. }
  8024. if m.no_reply_condition != nil {
  8025. fields = append(fields, sopnode.FieldNoReplyCondition)
  8026. }
  8027. if m.action_message != nil {
  8028. fields = append(fields, sopnode.FieldActionMessage)
  8029. }
  8030. if m.action_label != nil {
  8031. fields = append(fields, sopnode.FieldActionLabel)
  8032. }
  8033. return fields
  8034. }
  8035. // Field returns the value of a field with the given name. The second boolean
  8036. // return value indicates that this field was not set, or was not defined in the
  8037. // schema.
  8038. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  8039. switch name {
  8040. case sopnode.FieldCreatedAt:
  8041. return m.CreatedAt()
  8042. case sopnode.FieldUpdatedAt:
  8043. return m.UpdatedAt()
  8044. case sopnode.FieldStatus:
  8045. return m.Status()
  8046. case sopnode.FieldDeletedAt:
  8047. return m.DeletedAt()
  8048. case sopnode.FieldStageID:
  8049. return m.StageID()
  8050. case sopnode.FieldParentID:
  8051. return m.ParentID()
  8052. case sopnode.FieldName:
  8053. return m.Name()
  8054. case sopnode.FieldConditionType:
  8055. return m.ConditionType()
  8056. case sopnode.FieldConditionList:
  8057. return m.ConditionList()
  8058. case sopnode.FieldNoReplyCondition:
  8059. return m.NoReplyCondition()
  8060. case sopnode.FieldActionMessage:
  8061. return m.ActionMessage()
  8062. case sopnode.FieldActionLabel:
  8063. return m.ActionLabel()
  8064. }
  8065. return nil, false
  8066. }
  8067. // OldField returns the old value of the field from the database. An error is
  8068. // returned if the mutation operation is not UpdateOne, or the query to the
  8069. // database failed.
  8070. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8071. switch name {
  8072. case sopnode.FieldCreatedAt:
  8073. return m.OldCreatedAt(ctx)
  8074. case sopnode.FieldUpdatedAt:
  8075. return m.OldUpdatedAt(ctx)
  8076. case sopnode.FieldStatus:
  8077. return m.OldStatus(ctx)
  8078. case sopnode.FieldDeletedAt:
  8079. return m.OldDeletedAt(ctx)
  8080. case sopnode.FieldStageID:
  8081. return m.OldStageID(ctx)
  8082. case sopnode.FieldParentID:
  8083. return m.OldParentID(ctx)
  8084. case sopnode.FieldName:
  8085. return m.OldName(ctx)
  8086. case sopnode.FieldConditionType:
  8087. return m.OldConditionType(ctx)
  8088. case sopnode.FieldConditionList:
  8089. return m.OldConditionList(ctx)
  8090. case sopnode.FieldNoReplyCondition:
  8091. return m.OldNoReplyCondition(ctx)
  8092. case sopnode.FieldActionMessage:
  8093. return m.OldActionMessage(ctx)
  8094. case sopnode.FieldActionLabel:
  8095. return m.OldActionLabel(ctx)
  8096. }
  8097. return nil, fmt.Errorf("unknown SopNode field %s", name)
  8098. }
  8099. // SetField sets the value of a field with the given name. It returns an error if
  8100. // the field is not defined in the schema, or if the type mismatched the field
  8101. // type.
  8102. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  8103. switch name {
  8104. case sopnode.FieldCreatedAt:
  8105. v, ok := value.(time.Time)
  8106. if !ok {
  8107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8108. }
  8109. m.SetCreatedAt(v)
  8110. return nil
  8111. case sopnode.FieldUpdatedAt:
  8112. v, ok := value.(time.Time)
  8113. if !ok {
  8114. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8115. }
  8116. m.SetUpdatedAt(v)
  8117. return nil
  8118. case sopnode.FieldStatus:
  8119. v, ok := value.(uint8)
  8120. if !ok {
  8121. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8122. }
  8123. m.SetStatus(v)
  8124. return nil
  8125. case sopnode.FieldDeletedAt:
  8126. v, ok := value.(time.Time)
  8127. if !ok {
  8128. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8129. }
  8130. m.SetDeletedAt(v)
  8131. return nil
  8132. case sopnode.FieldStageID:
  8133. v, ok := value.(uint64)
  8134. if !ok {
  8135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8136. }
  8137. m.SetStageID(v)
  8138. return nil
  8139. case sopnode.FieldParentID:
  8140. v, ok := value.(uint64)
  8141. if !ok {
  8142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8143. }
  8144. m.SetParentID(v)
  8145. return nil
  8146. case sopnode.FieldName:
  8147. v, ok := value.(string)
  8148. if !ok {
  8149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8150. }
  8151. m.SetName(v)
  8152. return nil
  8153. case sopnode.FieldConditionType:
  8154. v, ok := value.(int)
  8155. if !ok {
  8156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8157. }
  8158. m.SetConditionType(v)
  8159. return nil
  8160. case sopnode.FieldConditionList:
  8161. v, ok := value.([]string)
  8162. if !ok {
  8163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8164. }
  8165. m.SetConditionList(v)
  8166. return nil
  8167. case sopnode.FieldNoReplyCondition:
  8168. v, ok := value.(uint64)
  8169. if !ok {
  8170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8171. }
  8172. m.SetNoReplyCondition(v)
  8173. return nil
  8174. case sopnode.FieldActionMessage:
  8175. v, ok := value.([]custom_types.Action)
  8176. if !ok {
  8177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8178. }
  8179. m.SetActionMessage(v)
  8180. return nil
  8181. case sopnode.FieldActionLabel:
  8182. v, ok := value.([]uint64)
  8183. if !ok {
  8184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8185. }
  8186. m.SetActionLabel(v)
  8187. return nil
  8188. }
  8189. return fmt.Errorf("unknown SopNode field %s", name)
  8190. }
  8191. // AddedFields returns all numeric fields that were incremented/decremented during
  8192. // this mutation.
  8193. func (m *SopNodeMutation) AddedFields() []string {
  8194. var fields []string
  8195. if m.addstatus != nil {
  8196. fields = append(fields, sopnode.FieldStatus)
  8197. }
  8198. if m.addparent_id != nil {
  8199. fields = append(fields, sopnode.FieldParentID)
  8200. }
  8201. if m.addcondition_type != nil {
  8202. fields = append(fields, sopnode.FieldConditionType)
  8203. }
  8204. if m.addno_reply_condition != nil {
  8205. fields = append(fields, sopnode.FieldNoReplyCondition)
  8206. }
  8207. return fields
  8208. }
  8209. // AddedField returns the numeric value that was incremented/decremented on a field
  8210. // with the given name. The second boolean return value indicates that this field
  8211. // was not set, or was not defined in the schema.
  8212. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  8213. switch name {
  8214. case sopnode.FieldStatus:
  8215. return m.AddedStatus()
  8216. case sopnode.FieldParentID:
  8217. return m.AddedParentID()
  8218. case sopnode.FieldConditionType:
  8219. return m.AddedConditionType()
  8220. case sopnode.FieldNoReplyCondition:
  8221. return m.AddedNoReplyCondition()
  8222. }
  8223. return nil, false
  8224. }
  8225. // AddField adds the value to the field with the given name. It returns an error if
  8226. // the field is not defined in the schema, or if the type mismatched the field
  8227. // type.
  8228. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  8229. switch name {
  8230. case sopnode.FieldStatus:
  8231. v, ok := value.(int8)
  8232. if !ok {
  8233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8234. }
  8235. m.AddStatus(v)
  8236. return nil
  8237. case sopnode.FieldParentID:
  8238. v, ok := value.(int64)
  8239. if !ok {
  8240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8241. }
  8242. m.AddParentID(v)
  8243. return nil
  8244. case sopnode.FieldConditionType:
  8245. v, ok := value.(int)
  8246. if !ok {
  8247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8248. }
  8249. m.AddConditionType(v)
  8250. return nil
  8251. case sopnode.FieldNoReplyCondition:
  8252. v, ok := value.(int64)
  8253. if !ok {
  8254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8255. }
  8256. m.AddNoReplyCondition(v)
  8257. return nil
  8258. }
  8259. return fmt.Errorf("unknown SopNode numeric field %s", name)
  8260. }
  8261. // ClearedFields returns all nullable fields that were cleared during this
  8262. // mutation.
  8263. func (m *SopNodeMutation) ClearedFields() []string {
  8264. var fields []string
  8265. if m.FieldCleared(sopnode.FieldStatus) {
  8266. fields = append(fields, sopnode.FieldStatus)
  8267. }
  8268. if m.FieldCleared(sopnode.FieldDeletedAt) {
  8269. fields = append(fields, sopnode.FieldDeletedAt)
  8270. }
  8271. if m.FieldCleared(sopnode.FieldConditionList) {
  8272. fields = append(fields, sopnode.FieldConditionList)
  8273. }
  8274. if m.FieldCleared(sopnode.FieldActionMessage) {
  8275. fields = append(fields, sopnode.FieldActionMessage)
  8276. }
  8277. if m.FieldCleared(sopnode.FieldActionLabel) {
  8278. fields = append(fields, sopnode.FieldActionLabel)
  8279. }
  8280. return fields
  8281. }
  8282. // FieldCleared returns a boolean indicating if a field with the given name was
  8283. // cleared in this mutation.
  8284. func (m *SopNodeMutation) FieldCleared(name string) bool {
  8285. _, ok := m.clearedFields[name]
  8286. return ok
  8287. }
  8288. // ClearField clears the value of the field with the given name. It returns an
  8289. // error if the field is not defined in the schema.
  8290. func (m *SopNodeMutation) ClearField(name string) error {
  8291. switch name {
  8292. case sopnode.FieldStatus:
  8293. m.ClearStatus()
  8294. return nil
  8295. case sopnode.FieldDeletedAt:
  8296. m.ClearDeletedAt()
  8297. return nil
  8298. case sopnode.FieldConditionList:
  8299. m.ClearConditionList()
  8300. return nil
  8301. case sopnode.FieldActionMessage:
  8302. m.ClearActionMessage()
  8303. return nil
  8304. case sopnode.FieldActionLabel:
  8305. m.ClearActionLabel()
  8306. return nil
  8307. }
  8308. return fmt.Errorf("unknown SopNode nullable field %s", name)
  8309. }
  8310. // ResetField resets all changes in the mutation for the field with the given name.
  8311. // It returns an error if the field is not defined in the schema.
  8312. func (m *SopNodeMutation) ResetField(name string) error {
  8313. switch name {
  8314. case sopnode.FieldCreatedAt:
  8315. m.ResetCreatedAt()
  8316. return nil
  8317. case sopnode.FieldUpdatedAt:
  8318. m.ResetUpdatedAt()
  8319. return nil
  8320. case sopnode.FieldStatus:
  8321. m.ResetStatus()
  8322. return nil
  8323. case sopnode.FieldDeletedAt:
  8324. m.ResetDeletedAt()
  8325. return nil
  8326. case sopnode.FieldStageID:
  8327. m.ResetStageID()
  8328. return nil
  8329. case sopnode.FieldParentID:
  8330. m.ResetParentID()
  8331. return nil
  8332. case sopnode.FieldName:
  8333. m.ResetName()
  8334. return nil
  8335. case sopnode.FieldConditionType:
  8336. m.ResetConditionType()
  8337. return nil
  8338. case sopnode.FieldConditionList:
  8339. m.ResetConditionList()
  8340. return nil
  8341. case sopnode.FieldNoReplyCondition:
  8342. m.ResetNoReplyCondition()
  8343. return nil
  8344. case sopnode.FieldActionMessage:
  8345. m.ResetActionMessage()
  8346. return nil
  8347. case sopnode.FieldActionLabel:
  8348. m.ResetActionLabel()
  8349. return nil
  8350. }
  8351. return fmt.Errorf("unknown SopNode field %s", name)
  8352. }
  8353. // AddedEdges returns all edge names that were set/added in this mutation.
  8354. func (m *SopNodeMutation) AddedEdges() []string {
  8355. edges := make([]string, 0, 2)
  8356. if m.sop_stage != nil {
  8357. edges = append(edges, sopnode.EdgeSopStage)
  8358. }
  8359. if m.node_messages != nil {
  8360. edges = append(edges, sopnode.EdgeNodeMessages)
  8361. }
  8362. return edges
  8363. }
  8364. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8365. // name in this mutation.
  8366. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  8367. switch name {
  8368. case sopnode.EdgeSopStage:
  8369. if id := m.sop_stage; id != nil {
  8370. return []ent.Value{*id}
  8371. }
  8372. case sopnode.EdgeNodeMessages:
  8373. ids := make([]ent.Value, 0, len(m.node_messages))
  8374. for id := range m.node_messages {
  8375. ids = append(ids, id)
  8376. }
  8377. return ids
  8378. }
  8379. return nil
  8380. }
  8381. // RemovedEdges returns all edge names that were removed in this mutation.
  8382. func (m *SopNodeMutation) RemovedEdges() []string {
  8383. edges := make([]string, 0, 2)
  8384. if m.removednode_messages != nil {
  8385. edges = append(edges, sopnode.EdgeNodeMessages)
  8386. }
  8387. return edges
  8388. }
  8389. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8390. // the given name in this mutation.
  8391. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  8392. switch name {
  8393. case sopnode.EdgeNodeMessages:
  8394. ids := make([]ent.Value, 0, len(m.removednode_messages))
  8395. for id := range m.removednode_messages {
  8396. ids = append(ids, id)
  8397. }
  8398. return ids
  8399. }
  8400. return nil
  8401. }
  8402. // ClearedEdges returns all edge names that were cleared in this mutation.
  8403. func (m *SopNodeMutation) ClearedEdges() []string {
  8404. edges := make([]string, 0, 2)
  8405. if m.clearedsop_stage {
  8406. edges = append(edges, sopnode.EdgeSopStage)
  8407. }
  8408. if m.clearednode_messages {
  8409. edges = append(edges, sopnode.EdgeNodeMessages)
  8410. }
  8411. return edges
  8412. }
  8413. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8414. // was cleared in this mutation.
  8415. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  8416. switch name {
  8417. case sopnode.EdgeSopStage:
  8418. return m.clearedsop_stage
  8419. case sopnode.EdgeNodeMessages:
  8420. return m.clearednode_messages
  8421. }
  8422. return false
  8423. }
  8424. // ClearEdge clears the value of the edge with the given name. It returns an error
  8425. // if that edge is not defined in the schema.
  8426. func (m *SopNodeMutation) ClearEdge(name string) error {
  8427. switch name {
  8428. case sopnode.EdgeSopStage:
  8429. m.ClearSopStage()
  8430. return nil
  8431. }
  8432. return fmt.Errorf("unknown SopNode unique edge %s", name)
  8433. }
  8434. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8435. // It returns an error if the edge is not defined in the schema.
  8436. func (m *SopNodeMutation) ResetEdge(name string) error {
  8437. switch name {
  8438. case sopnode.EdgeSopStage:
  8439. m.ResetSopStage()
  8440. return nil
  8441. case sopnode.EdgeNodeMessages:
  8442. m.ResetNodeMessages()
  8443. return nil
  8444. }
  8445. return fmt.Errorf("unknown SopNode edge %s", name)
  8446. }
  8447. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  8448. type SopStageMutation struct {
  8449. config
  8450. op Op
  8451. typ string
  8452. id *uint64
  8453. created_at *time.Time
  8454. updated_at *time.Time
  8455. status *uint8
  8456. addstatus *int8
  8457. deleted_at *time.Time
  8458. name *string
  8459. condition_type *int
  8460. addcondition_type *int
  8461. condition_operator *int
  8462. addcondition_operator *int
  8463. condition_list *[]custom_types.Condition
  8464. appendcondition_list []custom_types.Condition
  8465. action_message *[]custom_types.Action
  8466. appendaction_message []custom_types.Action
  8467. action_label *[]uint64
  8468. appendaction_label []uint64
  8469. index_sort *int
  8470. addindex_sort *int
  8471. clearedFields map[string]struct{}
  8472. sop_task *uint64
  8473. clearedsop_task bool
  8474. stage_nodes map[uint64]struct{}
  8475. removedstage_nodes map[uint64]struct{}
  8476. clearedstage_nodes bool
  8477. stage_messages map[uint64]struct{}
  8478. removedstage_messages map[uint64]struct{}
  8479. clearedstage_messages bool
  8480. done bool
  8481. oldValue func(context.Context) (*SopStage, error)
  8482. predicates []predicate.SopStage
  8483. }
  8484. var _ ent.Mutation = (*SopStageMutation)(nil)
  8485. // sopstageOption allows management of the mutation configuration using functional options.
  8486. type sopstageOption func(*SopStageMutation)
  8487. // newSopStageMutation creates new mutation for the SopStage entity.
  8488. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  8489. m := &SopStageMutation{
  8490. config: c,
  8491. op: op,
  8492. typ: TypeSopStage,
  8493. clearedFields: make(map[string]struct{}),
  8494. }
  8495. for _, opt := range opts {
  8496. opt(m)
  8497. }
  8498. return m
  8499. }
  8500. // withSopStageID sets the ID field of the mutation.
  8501. func withSopStageID(id uint64) sopstageOption {
  8502. return func(m *SopStageMutation) {
  8503. var (
  8504. err error
  8505. once sync.Once
  8506. value *SopStage
  8507. )
  8508. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  8509. once.Do(func() {
  8510. if m.done {
  8511. err = errors.New("querying old values post mutation is not allowed")
  8512. } else {
  8513. value, err = m.Client().SopStage.Get(ctx, id)
  8514. }
  8515. })
  8516. return value, err
  8517. }
  8518. m.id = &id
  8519. }
  8520. }
  8521. // withSopStage sets the old SopStage of the mutation.
  8522. func withSopStage(node *SopStage) sopstageOption {
  8523. return func(m *SopStageMutation) {
  8524. m.oldValue = func(context.Context) (*SopStage, error) {
  8525. return node, nil
  8526. }
  8527. m.id = &node.ID
  8528. }
  8529. }
  8530. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8531. // executed in a transaction (ent.Tx), a transactional client is returned.
  8532. func (m SopStageMutation) Client() *Client {
  8533. client := &Client{config: m.config}
  8534. client.init()
  8535. return client
  8536. }
  8537. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8538. // it returns an error otherwise.
  8539. func (m SopStageMutation) Tx() (*Tx, error) {
  8540. if _, ok := m.driver.(*txDriver); !ok {
  8541. return nil, errors.New("ent: mutation is not running in a transaction")
  8542. }
  8543. tx := &Tx{config: m.config}
  8544. tx.init()
  8545. return tx, nil
  8546. }
  8547. // SetID sets the value of the id field. Note that this
  8548. // operation is only accepted on creation of SopStage entities.
  8549. func (m *SopStageMutation) SetID(id uint64) {
  8550. m.id = &id
  8551. }
  8552. // ID returns the ID value in the mutation. Note that the ID is only available
  8553. // if it was provided to the builder or after it was returned from the database.
  8554. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  8555. if m.id == nil {
  8556. return
  8557. }
  8558. return *m.id, true
  8559. }
  8560. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8561. // That means, if the mutation is applied within a transaction with an isolation level such
  8562. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8563. // or updated by the mutation.
  8564. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  8565. switch {
  8566. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8567. id, exists := m.ID()
  8568. if exists {
  8569. return []uint64{id}, nil
  8570. }
  8571. fallthrough
  8572. case m.op.Is(OpUpdate | OpDelete):
  8573. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  8574. default:
  8575. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8576. }
  8577. }
  8578. // SetCreatedAt sets the "created_at" field.
  8579. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  8580. m.created_at = &t
  8581. }
  8582. // CreatedAt returns the value of the "created_at" field in the mutation.
  8583. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  8584. v := m.created_at
  8585. if v == nil {
  8586. return
  8587. }
  8588. return *v, true
  8589. }
  8590. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  8591. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  8592. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8593. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8594. if !m.op.Is(OpUpdateOne) {
  8595. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8596. }
  8597. if m.id == nil || m.oldValue == nil {
  8598. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8599. }
  8600. oldValue, err := m.oldValue(ctx)
  8601. if err != nil {
  8602. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8603. }
  8604. return oldValue.CreatedAt, nil
  8605. }
  8606. // ResetCreatedAt resets all changes to the "created_at" field.
  8607. func (m *SopStageMutation) ResetCreatedAt() {
  8608. m.created_at = nil
  8609. }
  8610. // SetUpdatedAt sets the "updated_at" field.
  8611. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  8612. m.updated_at = &t
  8613. }
  8614. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8615. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  8616. v := m.updated_at
  8617. if v == nil {
  8618. return
  8619. }
  8620. return *v, true
  8621. }
  8622. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  8623. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  8624. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8625. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8626. if !m.op.Is(OpUpdateOne) {
  8627. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8628. }
  8629. if m.id == nil || m.oldValue == nil {
  8630. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8631. }
  8632. oldValue, err := m.oldValue(ctx)
  8633. if err != nil {
  8634. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8635. }
  8636. return oldValue.UpdatedAt, nil
  8637. }
  8638. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8639. func (m *SopStageMutation) ResetUpdatedAt() {
  8640. m.updated_at = nil
  8641. }
  8642. // SetStatus sets the "status" field.
  8643. func (m *SopStageMutation) SetStatus(u uint8) {
  8644. m.status = &u
  8645. m.addstatus = nil
  8646. }
  8647. // Status returns the value of the "status" field in the mutation.
  8648. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  8649. v := m.status
  8650. if v == nil {
  8651. return
  8652. }
  8653. return *v, true
  8654. }
  8655. // OldStatus returns the old "status" field's value of the SopStage entity.
  8656. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  8657. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8658. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  8659. if !m.op.Is(OpUpdateOne) {
  8660. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  8661. }
  8662. if m.id == nil || m.oldValue == nil {
  8663. return v, errors.New("OldStatus requires an ID field in the mutation")
  8664. }
  8665. oldValue, err := m.oldValue(ctx)
  8666. if err != nil {
  8667. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  8668. }
  8669. return oldValue.Status, nil
  8670. }
  8671. // AddStatus adds u to the "status" field.
  8672. func (m *SopStageMutation) AddStatus(u int8) {
  8673. if m.addstatus != nil {
  8674. *m.addstatus += u
  8675. } else {
  8676. m.addstatus = &u
  8677. }
  8678. }
  8679. // AddedStatus returns the value that was added to the "status" field in this mutation.
  8680. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  8681. v := m.addstatus
  8682. if v == nil {
  8683. return
  8684. }
  8685. return *v, true
  8686. }
  8687. // ClearStatus clears the value of the "status" field.
  8688. func (m *SopStageMutation) ClearStatus() {
  8689. m.status = nil
  8690. m.addstatus = nil
  8691. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  8692. }
  8693. // StatusCleared returns if the "status" field was cleared in this mutation.
  8694. func (m *SopStageMutation) StatusCleared() bool {
  8695. _, ok := m.clearedFields[sopstage.FieldStatus]
  8696. return ok
  8697. }
  8698. // ResetStatus resets all changes to the "status" field.
  8699. func (m *SopStageMutation) ResetStatus() {
  8700. m.status = nil
  8701. m.addstatus = nil
  8702. delete(m.clearedFields, sopstage.FieldStatus)
  8703. }
  8704. // SetDeletedAt sets the "deleted_at" field.
  8705. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  8706. m.deleted_at = &t
  8707. }
  8708. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8709. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  8710. v := m.deleted_at
  8711. if v == nil {
  8712. return
  8713. }
  8714. return *v, true
  8715. }
  8716. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  8717. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  8718. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8719. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8720. if !m.op.Is(OpUpdateOne) {
  8721. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8722. }
  8723. if m.id == nil || m.oldValue == nil {
  8724. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8725. }
  8726. oldValue, err := m.oldValue(ctx)
  8727. if err != nil {
  8728. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8729. }
  8730. return oldValue.DeletedAt, nil
  8731. }
  8732. // ClearDeletedAt clears the value of the "deleted_at" field.
  8733. func (m *SopStageMutation) ClearDeletedAt() {
  8734. m.deleted_at = nil
  8735. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  8736. }
  8737. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8738. func (m *SopStageMutation) DeletedAtCleared() bool {
  8739. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  8740. return ok
  8741. }
  8742. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8743. func (m *SopStageMutation) ResetDeletedAt() {
  8744. m.deleted_at = nil
  8745. delete(m.clearedFields, sopstage.FieldDeletedAt)
  8746. }
  8747. // SetTaskID sets the "task_id" field.
  8748. func (m *SopStageMutation) SetTaskID(u uint64) {
  8749. m.sop_task = &u
  8750. }
  8751. // TaskID returns the value of the "task_id" field in the mutation.
  8752. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  8753. v := m.sop_task
  8754. if v == nil {
  8755. return
  8756. }
  8757. return *v, true
  8758. }
  8759. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  8760. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  8761. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8762. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  8763. if !m.op.Is(OpUpdateOne) {
  8764. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  8765. }
  8766. if m.id == nil || m.oldValue == nil {
  8767. return v, errors.New("OldTaskID requires an ID field in the mutation")
  8768. }
  8769. oldValue, err := m.oldValue(ctx)
  8770. if err != nil {
  8771. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  8772. }
  8773. return oldValue.TaskID, nil
  8774. }
  8775. // ResetTaskID resets all changes to the "task_id" field.
  8776. func (m *SopStageMutation) ResetTaskID() {
  8777. m.sop_task = nil
  8778. }
  8779. // SetName sets the "name" field.
  8780. func (m *SopStageMutation) SetName(s string) {
  8781. m.name = &s
  8782. }
  8783. // Name returns the value of the "name" field in the mutation.
  8784. func (m *SopStageMutation) Name() (r string, exists bool) {
  8785. v := m.name
  8786. if v == nil {
  8787. return
  8788. }
  8789. return *v, true
  8790. }
  8791. // OldName returns the old "name" field's value of the SopStage entity.
  8792. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  8793. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8794. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  8795. if !m.op.Is(OpUpdateOne) {
  8796. return v, errors.New("OldName is only allowed on UpdateOne operations")
  8797. }
  8798. if m.id == nil || m.oldValue == nil {
  8799. return v, errors.New("OldName requires an ID field in the mutation")
  8800. }
  8801. oldValue, err := m.oldValue(ctx)
  8802. if err != nil {
  8803. return v, fmt.Errorf("querying old value for OldName: %w", err)
  8804. }
  8805. return oldValue.Name, nil
  8806. }
  8807. // ResetName resets all changes to the "name" field.
  8808. func (m *SopStageMutation) ResetName() {
  8809. m.name = nil
  8810. }
  8811. // SetConditionType sets the "condition_type" field.
  8812. func (m *SopStageMutation) SetConditionType(i int) {
  8813. m.condition_type = &i
  8814. m.addcondition_type = nil
  8815. }
  8816. // ConditionType returns the value of the "condition_type" field in the mutation.
  8817. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  8818. v := m.condition_type
  8819. if v == nil {
  8820. return
  8821. }
  8822. return *v, true
  8823. }
  8824. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  8825. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  8826. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8827. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  8828. if !m.op.Is(OpUpdateOne) {
  8829. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  8830. }
  8831. if m.id == nil || m.oldValue == nil {
  8832. return v, errors.New("OldConditionType requires an ID field in the mutation")
  8833. }
  8834. oldValue, err := m.oldValue(ctx)
  8835. if err != nil {
  8836. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  8837. }
  8838. return oldValue.ConditionType, nil
  8839. }
  8840. // AddConditionType adds i to the "condition_type" field.
  8841. func (m *SopStageMutation) AddConditionType(i int) {
  8842. if m.addcondition_type != nil {
  8843. *m.addcondition_type += i
  8844. } else {
  8845. m.addcondition_type = &i
  8846. }
  8847. }
  8848. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  8849. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  8850. v := m.addcondition_type
  8851. if v == nil {
  8852. return
  8853. }
  8854. return *v, true
  8855. }
  8856. // ResetConditionType resets all changes to the "condition_type" field.
  8857. func (m *SopStageMutation) ResetConditionType() {
  8858. m.condition_type = nil
  8859. m.addcondition_type = nil
  8860. }
  8861. // SetConditionOperator sets the "condition_operator" field.
  8862. func (m *SopStageMutation) SetConditionOperator(i int) {
  8863. m.condition_operator = &i
  8864. m.addcondition_operator = nil
  8865. }
  8866. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  8867. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  8868. v := m.condition_operator
  8869. if v == nil {
  8870. return
  8871. }
  8872. return *v, true
  8873. }
  8874. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  8875. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  8876. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8877. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  8878. if !m.op.Is(OpUpdateOne) {
  8879. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  8880. }
  8881. if m.id == nil || m.oldValue == nil {
  8882. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  8883. }
  8884. oldValue, err := m.oldValue(ctx)
  8885. if err != nil {
  8886. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  8887. }
  8888. return oldValue.ConditionOperator, nil
  8889. }
  8890. // AddConditionOperator adds i to the "condition_operator" field.
  8891. func (m *SopStageMutation) AddConditionOperator(i int) {
  8892. if m.addcondition_operator != nil {
  8893. *m.addcondition_operator += i
  8894. } else {
  8895. m.addcondition_operator = &i
  8896. }
  8897. }
  8898. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  8899. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  8900. v := m.addcondition_operator
  8901. if v == nil {
  8902. return
  8903. }
  8904. return *v, true
  8905. }
  8906. // ResetConditionOperator resets all changes to the "condition_operator" field.
  8907. func (m *SopStageMutation) ResetConditionOperator() {
  8908. m.condition_operator = nil
  8909. m.addcondition_operator = nil
  8910. }
  8911. // SetConditionList sets the "condition_list" field.
  8912. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  8913. m.condition_list = &ct
  8914. m.appendcondition_list = nil
  8915. }
  8916. // ConditionList returns the value of the "condition_list" field in the mutation.
  8917. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  8918. v := m.condition_list
  8919. if v == nil {
  8920. return
  8921. }
  8922. return *v, true
  8923. }
  8924. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  8925. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  8926. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8927. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  8928. if !m.op.Is(OpUpdateOne) {
  8929. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  8930. }
  8931. if m.id == nil || m.oldValue == nil {
  8932. return v, errors.New("OldConditionList requires an ID field in the mutation")
  8933. }
  8934. oldValue, err := m.oldValue(ctx)
  8935. if err != nil {
  8936. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  8937. }
  8938. return oldValue.ConditionList, nil
  8939. }
  8940. // AppendConditionList adds ct to the "condition_list" field.
  8941. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  8942. m.appendcondition_list = append(m.appendcondition_list, ct...)
  8943. }
  8944. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  8945. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  8946. if len(m.appendcondition_list) == 0 {
  8947. return nil, false
  8948. }
  8949. return m.appendcondition_list, true
  8950. }
  8951. // ResetConditionList resets all changes to the "condition_list" field.
  8952. func (m *SopStageMutation) ResetConditionList() {
  8953. m.condition_list = nil
  8954. m.appendcondition_list = nil
  8955. }
  8956. // SetActionMessage sets the "action_message" field.
  8957. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  8958. m.action_message = &ct
  8959. m.appendaction_message = nil
  8960. }
  8961. // ActionMessage returns the value of the "action_message" field in the mutation.
  8962. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  8963. v := m.action_message
  8964. if v == nil {
  8965. return
  8966. }
  8967. return *v, true
  8968. }
  8969. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  8970. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  8971. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8972. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  8973. if !m.op.Is(OpUpdateOne) {
  8974. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  8975. }
  8976. if m.id == nil || m.oldValue == nil {
  8977. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  8978. }
  8979. oldValue, err := m.oldValue(ctx)
  8980. if err != nil {
  8981. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  8982. }
  8983. return oldValue.ActionMessage, nil
  8984. }
  8985. // AppendActionMessage adds ct to the "action_message" field.
  8986. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  8987. m.appendaction_message = append(m.appendaction_message, ct...)
  8988. }
  8989. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  8990. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  8991. if len(m.appendaction_message) == 0 {
  8992. return nil, false
  8993. }
  8994. return m.appendaction_message, true
  8995. }
  8996. // ClearActionMessage clears the value of the "action_message" field.
  8997. func (m *SopStageMutation) ClearActionMessage() {
  8998. m.action_message = nil
  8999. m.appendaction_message = nil
  9000. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  9001. }
  9002. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  9003. func (m *SopStageMutation) ActionMessageCleared() bool {
  9004. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  9005. return ok
  9006. }
  9007. // ResetActionMessage resets all changes to the "action_message" field.
  9008. func (m *SopStageMutation) ResetActionMessage() {
  9009. m.action_message = nil
  9010. m.appendaction_message = nil
  9011. delete(m.clearedFields, sopstage.FieldActionMessage)
  9012. }
  9013. // SetActionLabel sets the "action_label" field.
  9014. func (m *SopStageMutation) SetActionLabel(u []uint64) {
  9015. m.action_label = &u
  9016. m.appendaction_label = nil
  9017. }
  9018. // ActionLabel returns the value of the "action_label" field in the mutation.
  9019. func (m *SopStageMutation) ActionLabel() (r []uint64, exists bool) {
  9020. v := m.action_label
  9021. if v == nil {
  9022. return
  9023. }
  9024. return *v, true
  9025. }
  9026. // OldActionLabel returns the old "action_label" field's value of the SopStage entity.
  9027. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  9028. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9029. func (m *SopStageMutation) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  9030. if !m.op.Is(OpUpdateOne) {
  9031. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  9032. }
  9033. if m.id == nil || m.oldValue == nil {
  9034. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  9035. }
  9036. oldValue, err := m.oldValue(ctx)
  9037. if err != nil {
  9038. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  9039. }
  9040. return oldValue.ActionLabel, nil
  9041. }
  9042. // AppendActionLabel adds u to the "action_label" field.
  9043. func (m *SopStageMutation) AppendActionLabel(u []uint64) {
  9044. m.appendaction_label = append(m.appendaction_label, u...)
  9045. }
  9046. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  9047. func (m *SopStageMutation) AppendedActionLabel() ([]uint64, bool) {
  9048. if len(m.appendaction_label) == 0 {
  9049. return nil, false
  9050. }
  9051. return m.appendaction_label, true
  9052. }
  9053. // ClearActionLabel clears the value of the "action_label" field.
  9054. func (m *SopStageMutation) ClearActionLabel() {
  9055. m.action_label = nil
  9056. m.appendaction_label = nil
  9057. m.clearedFields[sopstage.FieldActionLabel] = struct{}{}
  9058. }
  9059. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  9060. func (m *SopStageMutation) ActionLabelCleared() bool {
  9061. _, ok := m.clearedFields[sopstage.FieldActionLabel]
  9062. return ok
  9063. }
  9064. // ResetActionLabel resets all changes to the "action_label" field.
  9065. func (m *SopStageMutation) ResetActionLabel() {
  9066. m.action_label = nil
  9067. m.appendaction_label = nil
  9068. delete(m.clearedFields, sopstage.FieldActionLabel)
  9069. }
  9070. // SetIndexSort sets the "index_sort" field.
  9071. func (m *SopStageMutation) SetIndexSort(i int) {
  9072. m.index_sort = &i
  9073. m.addindex_sort = nil
  9074. }
  9075. // IndexSort returns the value of the "index_sort" field in the mutation.
  9076. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  9077. v := m.index_sort
  9078. if v == nil {
  9079. return
  9080. }
  9081. return *v, true
  9082. }
  9083. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  9084. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  9085. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9086. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  9087. if !m.op.Is(OpUpdateOne) {
  9088. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  9089. }
  9090. if m.id == nil || m.oldValue == nil {
  9091. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  9092. }
  9093. oldValue, err := m.oldValue(ctx)
  9094. if err != nil {
  9095. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  9096. }
  9097. return oldValue.IndexSort, nil
  9098. }
  9099. // AddIndexSort adds i to the "index_sort" field.
  9100. func (m *SopStageMutation) AddIndexSort(i int) {
  9101. if m.addindex_sort != nil {
  9102. *m.addindex_sort += i
  9103. } else {
  9104. m.addindex_sort = &i
  9105. }
  9106. }
  9107. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  9108. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  9109. v := m.addindex_sort
  9110. if v == nil {
  9111. return
  9112. }
  9113. return *v, true
  9114. }
  9115. // ClearIndexSort clears the value of the "index_sort" field.
  9116. func (m *SopStageMutation) ClearIndexSort() {
  9117. m.index_sort = nil
  9118. m.addindex_sort = nil
  9119. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  9120. }
  9121. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  9122. func (m *SopStageMutation) IndexSortCleared() bool {
  9123. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  9124. return ok
  9125. }
  9126. // ResetIndexSort resets all changes to the "index_sort" field.
  9127. func (m *SopStageMutation) ResetIndexSort() {
  9128. m.index_sort = nil
  9129. m.addindex_sort = nil
  9130. delete(m.clearedFields, sopstage.FieldIndexSort)
  9131. }
  9132. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  9133. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  9134. m.sop_task = &id
  9135. }
  9136. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  9137. func (m *SopStageMutation) ClearSopTask() {
  9138. m.clearedsop_task = true
  9139. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  9140. }
  9141. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  9142. func (m *SopStageMutation) SopTaskCleared() bool {
  9143. return m.clearedsop_task
  9144. }
  9145. // SopTaskID returns the "sop_task" edge ID in the mutation.
  9146. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  9147. if m.sop_task != nil {
  9148. return *m.sop_task, true
  9149. }
  9150. return
  9151. }
  9152. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  9153. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  9154. // SopTaskID instead. It exists only for internal usage by the builders.
  9155. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  9156. if id := m.sop_task; id != nil {
  9157. ids = append(ids, *id)
  9158. }
  9159. return
  9160. }
  9161. // ResetSopTask resets all changes to the "sop_task" edge.
  9162. func (m *SopStageMutation) ResetSopTask() {
  9163. m.sop_task = nil
  9164. m.clearedsop_task = false
  9165. }
  9166. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  9167. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  9168. if m.stage_nodes == nil {
  9169. m.stage_nodes = make(map[uint64]struct{})
  9170. }
  9171. for i := range ids {
  9172. m.stage_nodes[ids[i]] = struct{}{}
  9173. }
  9174. }
  9175. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  9176. func (m *SopStageMutation) ClearStageNodes() {
  9177. m.clearedstage_nodes = true
  9178. }
  9179. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  9180. func (m *SopStageMutation) StageNodesCleared() bool {
  9181. return m.clearedstage_nodes
  9182. }
  9183. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  9184. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  9185. if m.removedstage_nodes == nil {
  9186. m.removedstage_nodes = make(map[uint64]struct{})
  9187. }
  9188. for i := range ids {
  9189. delete(m.stage_nodes, ids[i])
  9190. m.removedstage_nodes[ids[i]] = struct{}{}
  9191. }
  9192. }
  9193. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  9194. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  9195. for id := range m.removedstage_nodes {
  9196. ids = append(ids, id)
  9197. }
  9198. return
  9199. }
  9200. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  9201. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  9202. for id := range m.stage_nodes {
  9203. ids = append(ids, id)
  9204. }
  9205. return
  9206. }
  9207. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  9208. func (m *SopStageMutation) ResetStageNodes() {
  9209. m.stage_nodes = nil
  9210. m.clearedstage_nodes = false
  9211. m.removedstage_nodes = nil
  9212. }
  9213. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  9214. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  9215. if m.stage_messages == nil {
  9216. m.stage_messages = make(map[uint64]struct{})
  9217. }
  9218. for i := range ids {
  9219. m.stage_messages[ids[i]] = struct{}{}
  9220. }
  9221. }
  9222. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  9223. func (m *SopStageMutation) ClearStageMessages() {
  9224. m.clearedstage_messages = true
  9225. }
  9226. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  9227. func (m *SopStageMutation) StageMessagesCleared() bool {
  9228. return m.clearedstage_messages
  9229. }
  9230. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  9231. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  9232. if m.removedstage_messages == nil {
  9233. m.removedstage_messages = make(map[uint64]struct{})
  9234. }
  9235. for i := range ids {
  9236. delete(m.stage_messages, ids[i])
  9237. m.removedstage_messages[ids[i]] = struct{}{}
  9238. }
  9239. }
  9240. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  9241. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  9242. for id := range m.removedstage_messages {
  9243. ids = append(ids, id)
  9244. }
  9245. return
  9246. }
  9247. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  9248. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  9249. for id := range m.stage_messages {
  9250. ids = append(ids, id)
  9251. }
  9252. return
  9253. }
  9254. // ResetStageMessages resets all changes to the "stage_messages" edge.
  9255. func (m *SopStageMutation) ResetStageMessages() {
  9256. m.stage_messages = nil
  9257. m.clearedstage_messages = false
  9258. m.removedstage_messages = nil
  9259. }
  9260. // Where appends a list predicates to the SopStageMutation builder.
  9261. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  9262. m.predicates = append(m.predicates, ps...)
  9263. }
  9264. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  9265. // users can use type-assertion to append predicates that do not depend on any generated package.
  9266. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  9267. p := make([]predicate.SopStage, len(ps))
  9268. for i := range ps {
  9269. p[i] = ps[i]
  9270. }
  9271. m.Where(p...)
  9272. }
  9273. // Op returns the operation name.
  9274. func (m *SopStageMutation) Op() Op {
  9275. return m.op
  9276. }
  9277. // SetOp allows setting the mutation operation.
  9278. func (m *SopStageMutation) SetOp(op Op) {
  9279. m.op = op
  9280. }
  9281. // Type returns the node type of this mutation (SopStage).
  9282. func (m *SopStageMutation) Type() string {
  9283. return m.typ
  9284. }
  9285. // Fields returns all fields that were changed during this mutation. Note that in
  9286. // order to get all numeric fields that were incremented/decremented, call
  9287. // AddedFields().
  9288. func (m *SopStageMutation) Fields() []string {
  9289. fields := make([]string, 0, 12)
  9290. if m.created_at != nil {
  9291. fields = append(fields, sopstage.FieldCreatedAt)
  9292. }
  9293. if m.updated_at != nil {
  9294. fields = append(fields, sopstage.FieldUpdatedAt)
  9295. }
  9296. if m.status != nil {
  9297. fields = append(fields, sopstage.FieldStatus)
  9298. }
  9299. if m.deleted_at != nil {
  9300. fields = append(fields, sopstage.FieldDeletedAt)
  9301. }
  9302. if m.sop_task != nil {
  9303. fields = append(fields, sopstage.FieldTaskID)
  9304. }
  9305. if m.name != nil {
  9306. fields = append(fields, sopstage.FieldName)
  9307. }
  9308. if m.condition_type != nil {
  9309. fields = append(fields, sopstage.FieldConditionType)
  9310. }
  9311. if m.condition_operator != nil {
  9312. fields = append(fields, sopstage.FieldConditionOperator)
  9313. }
  9314. if m.condition_list != nil {
  9315. fields = append(fields, sopstage.FieldConditionList)
  9316. }
  9317. if m.action_message != nil {
  9318. fields = append(fields, sopstage.FieldActionMessage)
  9319. }
  9320. if m.action_label != nil {
  9321. fields = append(fields, sopstage.FieldActionLabel)
  9322. }
  9323. if m.index_sort != nil {
  9324. fields = append(fields, sopstage.FieldIndexSort)
  9325. }
  9326. return fields
  9327. }
  9328. // Field returns the value of a field with the given name. The second boolean
  9329. // return value indicates that this field was not set, or was not defined in the
  9330. // schema.
  9331. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  9332. switch name {
  9333. case sopstage.FieldCreatedAt:
  9334. return m.CreatedAt()
  9335. case sopstage.FieldUpdatedAt:
  9336. return m.UpdatedAt()
  9337. case sopstage.FieldStatus:
  9338. return m.Status()
  9339. case sopstage.FieldDeletedAt:
  9340. return m.DeletedAt()
  9341. case sopstage.FieldTaskID:
  9342. return m.TaskID()
  9343. case sopstage.FieldName:
  9344. return m.Name()
  9345. case sopstage.FieldConditionType:
  9346. return m.ConditionType()
  9347. case sopstage.FieldConditionOperator:
  9348. return m.ConditionOperator()
  9349. case sopstage.FieldConditionList:
  9350. return m.ConditionList()
  9351. case sopstage.FieldActionMessage:
  9352. return m.ActionMessage()
  9353. case sopstage.FieldActionLabel:
  9354. return m.ActionLabel()
  9355. case sopstage.FieldIndexSort:
  9356. return m.IndexSort()
  9357. }
  9358. return nil, false
  9359. }
  9360. // OldField returns the old value of the field from the database. An error is
  9361. // returned if the mutation operation is not UpdateOne, or the query to the
  9362. // database failed.
  9363. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9364. switch name {
  9365. case sopstage.FieldCreatedAt:
  9366. return m.OldCreatedAt(ctx)
  9367. case sopstage.FieldUpdatedAt:
  9368. return m.OldUpdatedAt(ctx)
  9369. case sopstage.FieldStatus:
  9370. return m.OldStatus(ctx)
  9371. case sopstage.FieldDeletedAt:
  9372. return m.OldDeletedAt(ctx)
  9373. case sopstage.FieldTaskID:
  9374. return m.OldTaskID(ctx)
  9375. case sopstage.FieldName:
  9376. return m.OldName(ctx)
  9377. case sopstage.FieldConditionType:
  9378. return m.OldConditionType(ctx)
  9379. case sopstage.FieldConditionOperator:
  9380. return m.OldConditionOperator(ctx)
  9381. case sopstage.FieldConditionList:
  9382. return m.OldConditionList(ctx)
  9383. case sopstage.FieldActionMessage:
  9384. return m.OldActionMessage(ctx)
  9385. case sopstage.FieldActionLabel:
  9386. return m.OldActionLabel(ctx)
  9387. case sopstage.FieldIndexSort:
  9388. return m.OldIndexSort(ctx)
  9389. }
  9390. return nil, fmt.Errorf("unknown SopStage field %s", name)
  9391. }
  9392. // SetField sets the value of a field with the given name. It returns an error if
  9393. // the field is not defined in the schema, or if the type mismatched the field
  9394. // type.
  9395. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  9396. switch name {
  9397. case sopstage.FieldCreatedAt:
  9398. v, ok := value.(time.Time)
  9399. if !ok {
  9400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9401. }
  9402. m.SetCreatedAt(v)
  9403. return nil
  9404. case sopstage.FieldUpdatedAt:
  9405. v, ok := value.(time.Time)
  9406. if !ok {
  9407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9408. }
  9409. m.SetUpdatedAt(v)
  9410. return nil
  9411. case sopstage.FieldStatus:
  9412. v, ok := value.(uint8)
  9413. if !ok {
  9414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9415. }
  9416. m.SetStatus(v)
  9417. return nil
  9418. case sopstage.FieldDeletedAt:
  9419. v, ok := value.(time.Time)
  9420. if !ok {
  9421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9422. }
  9423. m.SetDeletedAt(v)
  9424. return nil
  9425. case sopstage.FieldTaskID:
  9426. v, ok := value.(uint64)
  9427. if !ok {
  9428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9429. }
  9430. m.SetTaskID(v)
  9431. return nil
  9432. case sopstage.FieldName:
  9433. v, ok := value.(string)
  9434. if !ok {
  9435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9436. }
  9437. m.SetName(v)
  9438. return nil
  9439. case sopstage.FieldConditionType:
  9440. v, ok := value.(int)
  9441. if !ok {
  9442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9443. }
  9444. m.SetConditionType(v)
  9445. return nil
  9446. case sopstage.FieldConditionOperator:
  9447. v, ok := value.(int)
  9448. if !ok {
  9449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9450. }
  9451. m.SetConditionOperator(v)
  9452. return nil
  9453. case sopstage.FieldConditionList:
  9454. v, ok := value.([]custom_types.Condition)
  9455. if !ok {
  9456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9457. }
  9458. m.SetConditionList(v)
  9459. return nil
  9460. case sopstage.FieldActionMessage:
  9461. v, ok := value.([]custom_types.Action)
  9462. if !ok {
  9463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9464. }
  9465. m.SetActionMessage(v)
  9466. return nil
  9467. case sopstage.FieldActionLabel:
  9468. v, ok := value.([]uint64)
  9469. if !ok {
  9470. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9471. }
  9472. m.SetActionLabel(v)
  9473. return nil
  9474. case sopstage.FieldIndexSort:
  9475. v, ok := value.(int)
  9476. if !ok {
  9477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9478. }
  9479. m.SetIndexSort(v)
  9480. return nil
  9481. }
  9482. return fmt.Errorf("unknown SopStage field %s", name)
  9483. }
  9484. // AddedFields returns all numeric fields that were incremented/decremented during
  9485. // this mutation.
  9486. func (m *SopStageMutation) AddedFields() []string {
  9487. var fields []string
  9488. if m.addstatus != nil {
  9489. fields = append(fields, sopstage.FieldStatus)
  9490. }
  9491. if m.addcondition_type != nil {
  9492. fields = append(fields, sopstage.FieldConditionType)
  9493. }
  9494. if m.addcondition_operator != nil {
  9495. fields = append(fields, sopstage.FieldConditionOperator)
  9496. }
  9497. if m.addindex_sort != nil {
  9498. fields = append(fields, sopstage.FieldIndexSort)
  9499. }
  9500. return fields
  9501. }
  9502. // AddedField returns the numeric value that was incremented/decremented on a field
  9503. // with the given name. The second boolean return value indicates that this field
  9504. // was not set, or was not defined in the schema.
  9505. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  9506. switch name {
  9507. case sopstage.FieldStatus:
  9508. return m.AddedStatus()
  9509. case sopstage.FieldConditionType:
  9510. return m.AddedConditionType()
  9511. case sopstage.FieldConditionOperator:
  9512. return m.AddedConditionOperator()
  9513. case sopstage.FieldIndexSort:
  9514. return m.AddedIndexSort()
  9515. }
  9516. return nil, false
  9517. }
  9518. // AddField adds the value to the field with the given name. It returns an error if
  9519. // the field is not defined in the schema, or if the type mismatched the field
  9520. // type.
  9521. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  9522. switch name {
  9523. case sopstage.FieldStatus:
  9524. v, ok := value.(int8)
  9525. if !ok {
  9526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9527. }
  9528. m.AddStatus(v)
  9529. return nil
  9530. case sopstage.FieldConditionType:
  9531. v, ok := value.(int)
  9532. if !ok {
  9533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9534. }
  9535. m.AddConditionType(v)
  9536. return nil
  9537. case sopstage.FieldConditionOperator:
  9538. v, ok := value.(int)
  9539. if !ok {
  9540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9541. }
  9542. m.AddConditionOperator(v)
  9543. return nil
  9544. case sopstage.FieldIndexSort:
  9545. v, ok := value.(int)
  9546. if !ok {
  9547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9548. }
  9549. m.AddIndexSort(v)
  9550. return nil
  9551. }
  9552. return fmt.Errorf("unknown SopStage numeric field %s", name)
  9553. }
  9554. // ClearedFields returns all nullable fields that were cleared during this
  9555. // mutation.
  9556. func (m *SopStageMutation) ClearedFields() []string {
  9557. var fields []string
  9558. if m.FieldCleared(sopstage.FieldStatus) {
  9559. fields = append(fields, sopstage.FieldStatus)
  9560. }
  9561. if m.FieldCleared(sopstage.FieldDeletedAt) {
  9562. fields = append(fields, sopstage.FieldDeletedAt)
  9563. }
  9564. if m.FieldCleared(sopstage.FieldActionMessage) {
  9565. fields = append(fields, sopstage.FieldActionMessage)
  9566. }
  9567. if m.FieldCleared(sopstage.FieldActionLabel) {
  9568. fields = append(fields, sopstage.FieldActionLabel)
  9569. }
  9570. if m.FieldCleared(sopstage.FieldIndexSort) {
  9571. fields = append(fields, sopstage.FieldIndexSort)
  9572. }
  9573. return fields
  9574. }
  9575. // FieldCleared returns a boolean indicating if a field with the given name was
  9576. // cleared in this mutation.
  9577. func (m *SopStageMutation) FieldCleared(name string) bool {
  9578. _, ok := m.clearedFields[name]
  9579. return ok
  9580. }
  9581. // ClearField clears the value of the field with the given name. It returns an
  9582. // error if the field is not defined in the schema.
  9583. func (m *SopStageMutation) ClearField(name string) error {
  9584. switch name {
  9585. case sopstage.FieldStatus:
  9586. m.ClearStatus()
  9587. return nil
  9588. case sopstage.FieldDeletedAt:
  9589. m.ClearDeletedAt()
  9590. return nil
  9591. case sopstage.FieldActionMessage:
  9592. m.ClearActionMessage()
  9593. return nil
  9594. case sopstage.FieldActionLabel:
  9595. m.ClearActionLabel()
  9596. return nil
  9597. case sopstage.FieldIndexSort:
  9598. m.ClearIndexSort()
  9599. return nil
  9600. }
  9601. return fmt.Errorf("unknown SopStage nullable field %s", name)
  9602. }
  9603. // ResetField resets all changes in the mutation for the field with the given name.
  9604. // It returns an error if the field is not defined in the schema.
  9605. func (m *SopStageMutation) ResetField(name string) error {
  9606. switch name {
  9607. case sopstage.FieldCreatedAt:
  9608. m.ResetCreatedAt()
  9609. return nil
  9610. case sopstage.FieldUpdatedAt:
  9611. m.ResetUpdatedAt()
  9612. return nil
  9613. case sopstage.FieldStatus:
  9614. m.ResetStatus()
  9615. return nil
  9616. case sopstage.FieldDeletedAt:
  9617. m.ResetDeletedAt()
  9618. return nil
  9619. case sopstage.FieldTaskID:
  9620. m.ResetTaskID()
  9621. return nil
  9622. case sopstage.FieldName:
  9623. m.ResetName()
  9624. return nil
  9625. case sopstage.FieldConditionType:
  9626. m.ResetConditionType()
  9627. return nil
  9628. case sopstage.FieldConditionOperator:
  9629. m.ResetConditionOperator()
  9630. return nil
  9631. case sopstage.FieldConditionList:
  9632. m.ResetConditionList()
  9633. return nil
  9634. case sopstage.FieldActionMessage:
  9635. m.ResetActionMessage()
  9636. return nil
  9637. case sopstage.FieldActionLabel:
  9638. m.ResetActionLabel()
  9639. return nil
  9640. case sopstage.FieldIndexSort:
  9641. m.ResetIndexSort()
  9642. return nil
  9643. }
  9644. return fmt.Errorf("unknown SopStage field %s", name)
  9645. }
  9646. // AddedEdges returns all edge names that were set/added in this mutation.
  9647. func (m *SopStageMutation) AddedEdges() []string {
  9648. edges := make([]string, 0, 3)
  9649. if m.sop_task != nil {
  9650. edges = append(edges, sopstage.EdgeSopTask)
  9651. }
  9652. if m.stage_nodes != nil {
  9653. edges = append(edges, sopstage.EdgeStageNodes)
  9654. }
  9655. if m.stage_messages != nil {
  9656. edges = append(edges, sopstage.EdgeStageMessages)
  9657. }
  9658. return edges
  9659. }
  9660. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9661. // name in this mutation.
  9662. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  9663. switch name {
  9664. case sopstage.EdgeSopTask:
  9665. if id := m.sop_task; id != nil {
  9666. return []ent.Value{*id}
  9667. }
  9668. case sopstage.EdgeStageNodes:
  9669. ids := make([]ent.Value, 0, len(m.stage_nodes))
  9670. for id := range m.stage_nodes {
  9671. ids = append(ids, id)
  9672. }
  9673. return ids
  9674. case sopstage.EdgeStageMessages:
  9675. ids := make([]ent.Value, 0, len(m.stage_messages))
  9676. for id := range m.stage_messages {
  9677. ids = append(ids, id)
  9678. }
  9679. return ids
  9680. }
  9681. return nil
  9682. }
  9683. // RemovedEdges returns all edge names that were removed in this mutation.
  9684. func (m *SopStageMutation) RemovedEdges() []string {
  9685. edges := make([]string, 0, 3)
  9686. if m.removedstage_nodes != nil {
  9687. edges = append(edges, sopstage.EdgeStageNodes)
  9688. }
  9689. if m.removedstage_messages != nil {
  9690. edges = append(edges, sopstage.EdgeStageMessages)
  9691. }
  9692. return edges
  9693. }
  9694. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9695. // the given name in this mutation.
  9696. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  9697. switch name {
  9698. case sopstage.EdgeStageNodes:
  9699. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  9700. for id := range m.removedstage_nodes {
  9701. ids = append(ids, id)
  9702. }
  9703. return ids
  9704. case sopstage.EdgeStageMessages:
  9705. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  9706. for id := range m.removedstage_messages {
  9707. ids = append(ids, id)
  9708. }
  9709. return ids
  9710. }
  9711. return nil
  9712. }
  9713. // ClearedEdges returns all edge names that were cleared in this mutation.
  9714. func (m *SopStageMutation) ClearedEdges() []string {
  9715. edges := make([]string, 0, 3)
  9716. if m.clearedsop_task {
  9717. edges = append(edges, sopstage.EdgeSopTask)
  9718. }
  9719. if m.clearedstage_nodes {
  9720. edges = append(edges, sopstage.EdgeStageNodes)
  9721. }
  9722. if m.clearedstage_messages {
  9723. edges = append(edges, sopstage.EdgeStageMessages)
  9724. }
  9725. return edges
  9726. }
  9727. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9728. // was cleared in this mutation.
  9729. func (m *SopStageMutation) EdgeCleared(name string) bool {
  9730. switch name {
  9731. case sopstage.EdgeSopTask:
  9732. return m.clearedsop_task
  9733. case sopstage.EdgeStageNodes:
  9734. return m.clearedstage_nodes
  9735. case sopstage.EdgeStageMessages:
  9736. return m.clearedstage_messages
  9737. }
  9738. return false
  9739. }
  9740. // ClearEdge clears the value of the edge with the given name. It returns an error
  9741. // if that edge is not defined in the schema.
  9742. func (m *SopStageMutation) ClearEdge(name string) error {
  9743. switch name {
  9744. case sopstage.EdgeSopTask:
  9745. m.ClearSopTask()
  9746. return nil
  9747. }
  9748. return fmt.Errorf("unknown SopStage unique edge %s", name)
  9749. }
  9750. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9751. // It returns an error if the edge is not defined in the schema.
  9752. func (m *SopStageMutation) ResetEdge(name string) error {
  9753. switch name {
  9754. case sopstage.EdgeSopTask:
  9755. m.ResetSopTask()
  9756. return nil
  9757. case sopstage.EdgeStageNodes:
  9758. m.ResetStageNodes()
  9759. return nil
  9760. case sopstage.EdgeStageMessages:
  9761. m.ResetStageMessages()
  9762. return nil
  9763. }
  9764. return fmt.Errorf("unknown SopStage edge %s", name)
  9765. }
  9766. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  9767. type SopTaskMutation struct {
  9768. config
  9769. op Op
  9770. typ string
  9771. id *uint64
  9772. created_at *time.Time
  9773. updated_at *time.Time
  9774. status *uint8
  9775. addstatus *int8
  9776. deleted_at *time.Time
  9777. name *string
  9778. bot_wxid_list *[]string
  9779. appendbot_wxid_list []string
  9780. _type *int
  9781. add_type *int
  9782. plan_start_time *time.Time
  9783. plan_end_time *time.Time
  9784. creator_id *string
  9785. clearedFields map[string]struct{}
  9786. task_stages map[uint64]struct{}
  9787. removedtask_stages map[uint64]struct{}
  9788. clearedtask_stages bool
  9789. done bool
  9790. oldValue func(context.Context) (*SopTask, error)
  9791. predicates []predicate.SopTask
  9792. }
  9793. var _ ent.Mutation = (*SopTaskMutation)(nil)
  9794. // soptaskOption allows management of the mutation configuration using functional options.
  9795. type soptaskOption func(*SopTaskMutation)
  9796. // newSopTaskMutation creates new mutation for the SopTask entity.
  9797. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  9798. m := &SopTaskMutation{
  9799. config: c,
  9800. op: op,
  9801. typ: TypeSopTask,
  9802. clearedFields: make(map[string]struct{}),
  9803. }
  9804. for _, opt := range opts {
  9805. opt(m)
  9806. }
  9807. return m
  9808. }
  9809. // withSopTaskID sets the ID field of the mutation.
  9810. func withSopTaskID(id uint64) soptaskOption {
  9811. return func(m *SopTaskMutation) {
  9812. var (
  9813. err error
  9814. once sync.Once
  9815. value *SopTask
  9816. )
  9817. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  9818. once.Do(func() {
  9819. if m.done {
  9820. err = errors.New("querying old values post mutation is not allowed")
  9821. } else {
  9822. value, err = m.Client().SopTask.Get(ctx, id)
  9823. }
  9824. })
  9825. return value, err
  9826. }
  9827. m.id = &id
  9828. }
  9829. }
  9830. // withSopTask sets the old SopTask of the mutation.
  9831. func withSopTask(node *SopTask) soptaskOption {
  9832. return func(m *SopTaskMutation) {
  9833. m.oldValue = func(context.Context) (*SopTask, error) {
  9834. return node, nil
  9835. }
  9836. m.id = &node.ID
  9837. }
  9838. }
  9839. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9840. // executed in a transaction (ent.Tx), a transactional client is returned.
  9841. func (m SopTaskMutation) Client() *Client {
  9842. client := &Client{config: m.config}
  9843. client.init()
  9844. return client
  9845. }
  9846. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9847. // it returns an error otherwise.
  9848. func (m SopTaskMutation) Tx() (*Tx, error) {
  9849. if _, ok := m.driver.(*txDriver); !ok {
  9850. return nil, errors.New("ent: mutation is not running in a transaction")
  9851. }
  9852. tx := &Tx{config: m.config}
  9853. tx.init()
  9854. return tx, nil
  9855. }
  9856. // SetID sets the value of the id field. Note that this
  9857. // operation is only accepted on creation of SopTask entities.
  9858. func (m *SopTaskMutation) SetID(id uint64) {
  9859. m.id = &id
  9860. }
  9861. // ID returns the ID value in the mutation. Note that the ID is only available
  9862. // if it was provided to the builder or after it was returned from the database.
  9863. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  9864. if m.id == nil {
  9865. return
  9866. }
  9867. return *m.id, true
  9868. }
  9869. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9870. // That means, if the mutation is applied within a transaction with an isolation level such
  9871. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9872. // or updated by the mutation.
  9873. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  9874. switch {
  9875. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9876. id, exists := m.ID()
  9877. if exists {
  9878. return []uint64{id}, nil
  9879. }
  9880. fallthrough
  9881. case m.op.Is(OpUpdate | OpDelete):
  9882. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  9883. default:
  9884. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9885. }
  9886. }
  9887. // SetCreatedAt sets the "created_at" field.
  9888. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  9889. m.created_at = &t
  9890. }
  9891. // CreatedAt returns the value of the "created_at" field in the mutation.
  9892. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  9893. v := m.created_at
  9894. if v == nil {
  9895. return
  9896. }
  9897. return *v, true
  9898. }
  9899. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  9900. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  9901. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9902. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9903. if !m.op.Is(OpUpdateOne) {
  9904. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9905. }
  9906. if m.id == nil || m.oldValue == nil {
  9907. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9908. }
  9909. oldValue, err := m.oldValue(ctx)
  9910. if err != nil {
  9911. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9912. }
  9913. return oldValue.CreatedAt, nil
  9914. }
  9915. // ResetCreatedAt resets all changes to the "created_at" field.
  9916. func (m *SopTaskMutation) ResetCreatedAt() {
  9917. m.created_at = nil
  9918. }
  9919. // SetUpdatedAt sets the "updated_at" field.
  9920. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  9921. m.updated_at = &t
  9922. }
  9923. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9924. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  9925. v := m.updated_at
  9926. if v == nil {
  9927. return
  9928. }
  9929. return *v, true
  9930. }
  9931. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  9932. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  9933. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9934. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9935. if !m.op.Is(OpUpdateOne) {
  9936. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9937. }
  9938. if m.id == nil || m.oldValue == nil {
  9939. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9940. }
  9941. oldValue, err := m.oldValue(ctx)
  9942. if err != nil {
  9943. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9944. }
  9945. return oldValue.UpdatedAt, nil
  9946. }
  9947. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9948. func (m *SopTaskMutation) ResetUpdatedAt() {
  9949. m.updated_at = nil
  9950. }
  9951. // SetStatus sets the "status" field.
  9952. func (m *SopTaskMutation) SetStatus(u uint8) {
  9953. m.status = &u
  9954. m.addstatus = nil
  9955. }
  9956. // Status returns the value of the "status" field in the mutation.
  9957. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  9958. v := m.status
  9959. if v == nil {
  9960. return
  9961. }
  9962. return *v, true
  9963. }
  9964. // OldStatus returns the old "status" field's value of the SopTask entity.
  9965. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  9966. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9967. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  9968. if !m.op.Is(OpUpdateOne) {
  9969. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9970. }
  9971. if m.id == nil || m.oldValue == nil {
  9972. return v, errors.New("OldStatus requires an ID field in the mutation")
  9973. }
  9974. oldValue, err := m.oldValue(ctx)
  9975. if err != nil {
  9976. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9977. }
  9978. return oldValue.Status, nil
  9979. }
  9980. // AddStatus adds u to the "status" field.
  9981. func (m *SopTaskMutation) AddStatus(u int8) {
  9982. if m.addstatus != nil {
  9983. *m.addstatus += u
  9984. } else {
  9985. m.addstatus = &u
  9986. }
  9987. }
  9988. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9989. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  9990. v := m.addstatus
  9991. if v == nil {
  9992. return
  9993. }
  9994. return *v, true
  9995. }
  9996. // ClearStatus clears the value of the "status" field.
  9997. func (m *SopTaskMutation) ClearStatus() {
  9998. m.status = nil
  9999. m.addstatus = nil
  10000. m.clearedFields[soptask.FieldStatus] = struct{}{}
  10001. }
  10002. // StatusCleared returns if the "status" field was cleared in this mutation.
  10003. func (m *SopTaskMutation) StatusCleared() bool {
  10004. _, ok := m.clearedFields[soptask.FieldStatus]
  10005. return ok
  10006. }
  10007. // ResetStatus resets all changes to the "status" field.
  10008. func (m *SopTaskMutation) ResetStatus() {
  10009. m.status = nil
  10010. m.addstatus = nil
  10011. delete(m.clearedFields, soptask.FieldStatus)
  10012. }
  10013. // SetDeletedAt sets the "deleted_at" field.
  10014. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  10015. m.deleted_at = &t
  10016. }
  10017. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10018. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  10019. v := m.deleted_at
  10020. if v == nil {
  10021. return
  10022. }
  10023. return *v, true
  10024. }
  10025. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  10026. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  10027. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10028. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10029. if !m.op.Is(OpUpdateOne) {
  10030. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10031. }
  10032. if m.id == nil || m.oldValue == nil {
  10033. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10034. }
  10035. oldValue, err := m.oldValue(ctx)
  10036. if err != nil {
  10037. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10038. }
  10039. return oldValue.DeletedAt, nil
  10040. }
  10041. // ClearDeletedAt clears the value of the "deleted_at" field.
  10042. func (m *SopTaskMutation) ClearDeletedAt() {
  10043. m.deleted_at = nil
  10044. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  10045. }
  10046. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10047. func (m *SopTaskMutation) DeletedAtCleared() bool {
  10048. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  10049. return ok
  10050. }
  10051. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10052. func (m *SopTaskMutation) ResetDeletedAt() {
  10053. m.deleted_at = nil
  10054. delete(m.clearedFields, soptask.FieldDeletedAt)
  10055. }
  10056. // SetName sets the "name" field.
  10057. func (m *SopTaskMutation) SetName(s string) {
  10058. m.name = &s
  10059. }
  10060. // Name returns the value of the "name" field in the mutation.
  10061. func (m *SopTaskMutation) Name() (r string, exists bool) {
  10062. v := m.name
  10063. if v == nil {
  10064. return
  10065. }
  10066. return *v, true
  10067. }
  10068. // OldName returns the old "name" field's value of the SopTask entity.
  10069. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  10070. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10071. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  10072. if !m.op.Is(OpUpdateOne) {
  10073. return v, errors.New("OldName is only allowed on UpdateOne operations")
  10074. }
  10075. if m.id == nil || m.oldValue == nil {
  10076. return v, errors.New("OldName requires an ID field in the mutation")
  10077. }
  10078. oldValue, err := m.oldValue(ctx)
  10079. if err != nil {
  10080. return v, fmt.Errorf("querying old value for OldName: %w", err)
  10081. }
  10082. return oldValue.Name, nil
  10083. }
  10084. // ResetName resets all changes to the "name" field.
  10085. func (m *SopTaskMutation) ResetName() {
  10086. m.name = nil
  10087. }
  10088. // SetBotWxidList sets the "bot_wxid_list" field.
  10089. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  10090. m.bot_wxid_list = &s
  10091. m.appendbot_wxid_list = nil
  10092. }
  10093. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  10094. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  10095. v := m.bot_wxid_list
  10096. if v == nil {
  10097. return
  10098. }
  10099. return *v, true
  10100. }
  10101. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  10102. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  10103. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10104. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  10105. if !m.op.Is(OpUpdateOne) {
  10106. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  10107. }
  10108. if m.id == nil || m.oldValue == nil {
  10109. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  10110. }
  10111. oldValue, err := m.oldValue(ctx)
  10112. if err != nil {
  10113. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  10114. }
  10115. return oldValue.BotWxidList, nil
  10116. }
  10117. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  10118. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  10119. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  10120. }
  10121. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  10122. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  10123. if len(m.appendbot_wxid_list) == 0 {
  10124. return nil, false
  10125. }
  10126. return m.appendbot_wxid_list, true
  10127. }
  10128. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  10129. func (m *SopTaskMutation) ClearBotWxidList() {
  10130. m.bot_wxid_list = nil
  10131. m.appendbot_wxid_list = nil
  10132. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  10133. }
  10134. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  10135. func (m *SopTaskMutation) BotWxidListCleared() bool {
  10136. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  10137. return ok
  10138. }
  10139. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  10140. func (m *SopTaskMutation) ResetBotWxidList() {
  10141. m.bot_wxid_list = nil
  10142. m.appendbot_wxid_list = nil
  10143. delete(m.clearedFields, soptask.FieldBotWxidList)
  10144. }
  10145. // SetType sets the "type" field.
  10146. func (m *SopTaskMutation) SetType(i int) {
  10147. m._type = &i
  10148. m.add_type = nil
  10149. }
  10150. // GetType returns the value of the "type" field in the mutation.
  10151. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  10152. v := m._type
  10153. if v == nil {
  10154. return
  10155. }
  10156. return *v, true
  10157. }
  10158. // OldType returns the old "type" field's value of the SopTask entity.
  10159. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  10160. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10161. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  10162. if !m.op.Is(OpUpdateOne) {
  10163. return v, errors.New("OldType is only allowed on UpdateOne operations")
  10164. }
  10165. if m.id == nil || m.oldValue == nil {
  10166. return v, errors.New("OldType requires an ID field in the mutation")
  10167. }
  10168. oldValue, err := m.oldValue(ctx)
  10169. if err != nil {
  10170. return v, fmt.Errorf("querying old value for OldType: %w", err)
  10171. }
  10172. return oldValue.Type, nil
  10173. }
  10174. // AddType adds i to the "type" field.
  10175. func (m *SopTaskMutation) AddType(i int) {
  10176. if m.add_type != nil {
  10177. *m.add_type += i
  10178. } else {
  10179. m.add_type = &i
  10180. }
  10181. }
  10182. // AddedType returns the value that was added to the "type" field in this mutation.
  10183. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  10184. v := m.add_type
  10185. if v == nil {
  10186. return
  10187. }
  10188. return *v, true
  10189. }
  10190. // ResetType resets all changes to the "type" field.
  10191. func (m *SopTaskMutation) ResetType() {
  10192. m._type = nil
  10193. m.add_type = nil
  10194. }
  10195. // SetPlanStartTime sets the "plan_start_time" field.
  10196. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  10197. m.plan_start_time = &t
  10198. }
  10199. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  10200. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  10201. v := m.plan_start_time
  10202. if v == nil {
  10203. return
  10204. }
  10205. return *v, true
  10206. }
  10207. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  10208. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  10209. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10210. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  10211. if !m.op.Is(OpUpdateOne) {
  10212. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  10213. }
  10214. if m.id == nil || m.oldValue == nil {
  10215. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  10216. }
  10217. oldValue, err := m.oldValue(ctx)
  10218. if err != nil {
  10219. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  10220. }
  10221. return oldValue.PlanStartTime, nil
  10222. }
  10223. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  10224. func (m *SopTaskMutation) ClearPlanStartTime() {
  10225. m.plan_start_time = nil
  10226. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  10227. }
  10228. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  10229. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  10230. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  10231. return ok
  10232. }
  10233. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  10234. func (m *SopTaskMutation) ResetPlanStartTime() {
  10235. m.plan_start_time = nil
  10236. delete(m.clearedFields, soptask.FieldPlanStartTime)
  10237. }
  10238. // SetPlanEndTime sets the "plan_end_time" field.
  10239. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  10240. m.plan_end_time = &t
  10241. }
  10242. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  10243. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  10244. v := m.plan_end_time
  10245. if v == nil {
  10246. return
  10247. }
  10248. return *v, true
  10249. }
  10250. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  10251. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  10252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10253. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  10254. if !m.op.Is(OpUpdateOne) {
  10255. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  10256. }
  10257. if m.id == nil || m.oldValue == nil {
  10258. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  10259. }
  10260. oldValue, err := m.oldValue(ctx)
  10261. if err != nil {
  10262. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  10263. }
  10264. return oldValue.PlanEndTime, nil
  10265. }
  10266. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  10267. func (m *SopTaskMutation) ClearPlanEndTime() {
  10268. m.plan_end_time = nil
  10269. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  10270. }
  10271. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  10272. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  10273. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  10274. return ok
  10275. }
  10276. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  10277. func (m *SopTaskMutation) ResetPlanEndTime() {
  10278. m.plan_end_time = nil
  10279. delete(m.clearedFields, soptask.FieldPlanEndTime)
  10280. }
  10281. // SetCreatorID sets the "creator_id" field.
  10282. func (m *SopTaskMutation) SetCreatorID(s string) {
  10283. m.creator_id = &s
  10284. }
  10285. // CreatorID returns the value of the "creator_id" field in the mutation.
  10286. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  10287. v := m.creator_id
  10288. if v == nil {
  10289. return
  10290. }
  10291. return *v, true
  10292. }
  10293. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  10294. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  10295. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10296. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  10297. if !m.op.Is(OpUpdateOne) {
  10298. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  10299. }
  10300. if m.id == nil || m.oldValue == nil {
  10301. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  10302. }
  10303. oldValue, err := m.oldValue(ctx)
  10304. if err != nil {
  10305. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  10306. }
  10307. return oldValue.CreatorID, nil
  10308. }
  10309. // ClearCreatorID clears the value of the "creator_id" field.
  10310. func (m *SopTaskMutation) ClearCreatorID() {
  10311. m.creator_id = nil
  10312. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  10313. }
  10314. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  10315. func (m *SopTaskMutation) CreatorIDCleared() bool {
  10316. _, ok := m.clearedFields[soptask.FieldCreatorID]
  10317. return ok
  10318. }
  10319. // ResetCreatorID resets all changes to the "creator_id" field.
  10320. func (m *SopTaskMutation) ResetCreatorID() {
  10321. m.creator_id = nil
  10322. delete(m.clearedFields, soptask.FieldCreatorID)
  10323. }
  10324. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  10325. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  10326. if m.task_stages == nil {
  10327. m.task_stages = make(map[uint64]struct{})
  10328. }
  10329. for i := range ids {
  10330. m.task_stages[ids[i]] = struct{}{}
  10331. }
  10332. }
  10333. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  10334. func (m *SopTaskMutation) ClearTaskStages() {
  10335. m.clearedtask_stages = true
  10336. }
  10337. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  10338. func (m *SopTaskMutation) TaskStagesCleared() bool {
  10339. return m.clearedtask_stages
  10340. }
  10341. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  10342. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  10343. if m.removedtask_stages == nil {
  10344. m.removedtask_stages = make(map[uint64]struct{})
  10345. }
  10346. for i := range ids {
  10347. delete(m.task_stages, ids[i])
  10348. m.removedtask_stages[ids[i]] = struct{}{}
  10349. }
  10350. }
  10351. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  10352. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  10353. for id := range m.removedtask_stages {
  10354. ids = append(ids, id)
  10355. }
  10356. return
  10357. }
  10358. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  10359. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  10360. for id := range m.task_stages {
  10361. ids = append(ids, id)
  10362. }
  10363. return
  10364. }
  10365. // ResetTaskStages resets all changes to the "task_stages" edge.
  10366. func (m *SopTaskMutation) ResetTaskStages() {
  10367. m.task_stages = nil
  10368. m.clearedtask_stages = false
  10369. m.removedtask_stages = nil
  10370. }
  10371. // Where appends a list predicates to the SopTaskMutation builder.
  10372. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  10373. m.predicates = append(m.predicates, ps...)
  10374. }
  10375. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  10376. // users can use type-assertion to append predicates that do not depend on any generated package.
  10377. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  10378. p := make([]predicate.SopTask, len(ps))
  10379. for i := range ps {
  10380. p[i] = ps[i]
  10381. }
  10382. m.Where(p...)
  10383. }
  10384. // Op returns the operation name.
  10385. func (m *SopTaskMutation) Op() Op {
  10386. return m.op
  10387. }
  10388. // SetOp allows setting the mutation operation.
  10389. func (m *SopTaskMutation) SetOp(op Op) {
  10390. m.op = op
  10391. }
  10392. // Type returns the node type of this mutation (SopTask).
  10393. func (m *SopTaskMutation) Type() string {
  10394. return m.typ
  10395. }
  10396. // Fields returns all fields that were changed during this mutation. Note that in
  10397. // order to get all numeric fields that were incremented/decremented, call
  10398. // AddedFields().
  10399. func (m *SopTaskMutation) Fields() []string {
  10400. fields := make([]string, 0, 10)
  10401. if m.created_at != nil {
  10402. fields = append(fields, soptask.FieldCreatedAt)
  10403. }
  10404. if m.updated_at != nil {
  10405. fields = append(fields, soptask.FieldUpdatedAt)
  10406. }
  10407. if m.status != nil {
  10408. fields = append(fields, soptask.FieldStatus)
  10409. }
  10410. if m.deleted_at != nil {
  10411. fields = append(fields, soptask.FieldDeletedAt)
  10412. }
  10413. if m.name != nil {
  10414. fields = append(fields, soptask.FieldName)
  10415. }
  10416. if m.bot_wxid_list != nil {
  10417. fields = append(fields, soptask.FieldBotWxidList)
  10418. }
  10419. if m._type != nil {
  10420. fields = append(fields, soptask.FieldType)
  10421. }
  10422. if m.plan_start_time != nil {
  10423. fields = append(fields, soptask.FieldPlanStartTime)
  10424. }
  10425. if m.plan_end_time != nil {
  10426. fields = append(fields, soptask.FieldPlanEndTime)
  10427. }
  10428. if m.creator_id != nil {
  10429. fields = append(fields, soptask.FieldCreatorID)
  10430. }
  10431. return fields
  10432. }
  10433. // Field returns the value of a field with the given name. The second boolean
  10434. // return value indicates that this field was not set, or was not defined in the
  10435. // schema.
  10436. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  10437. switch name {
  10438. case soptask.FieldCreatedAt:
  10439. return m.CreatedAt()
  10440. case soptask.FieldUpdatedAt:
  10441. return m.UpdatedAt()
  10442. case soptask.FieldStatus:
  10443. return m.Status()
  10444. case soptask.FieldDeletedAt:
  10445. return m.DeletedAt()
  10446. case soptask.FieldName:
  10447. return m.Name()
  10448. case soptask.FieldBotWxidList:
  10449. return m.BotWxidList()
  10450. case soptask.FieldType:
  10451. return m.GetType()
  10452. case soptask.FieldPlanStartTime:
  10453. return m.PlanStartTime()
  10454. case soptask.FieldPlanEndTime:
  10455. return m.PlanEndTime()
  10456. case soptask.FieldCreatorID:
  10457. return m.CreatorID()
  10458. }
  10459. return nil, false
  10460. }
  10461. // OldField returns the old value of the field from the database. An error is
  10462. // returned if the mutation operation is not UpdateOne, or the query to the
  10463. // database failed.
  10464. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10465. switch name {
  10466. case soptask.FieldCreatedAt:
  10467. return m.OldCreatedAt(ctx)
  10468. case soptask.FieldUpdatedAt:
  10469. return m.OldUpdatedAt(ctx)
  10470. case soptask.FieldStatus:
  10471. return m.OldStatus(ctx)
  10472. case soptask.FieldDeletedAt:
  10473. return m.OldDeletedAt(ctx)
  10474. case soptask.FieldName:
  10475. return m.OldName(ctx)
  10476. case soptask.FieldBotWxidList:
  10477. return m.OldBotWxidList(ctx)
  10478. case soptask.FieldType:
  10479. return m.OldType(ctx)
  10480. case soptask.FieldPlanStartTime:
  10481. return m.OldPlanStartTime(ctx)
  10482. case soptask.FieldPlanEndTime:
  10483. return m.OldPlanEndTime(ctx)
  10484. case soptask.FieldCreatorID:
  10485. return m.OldCreatorID(ctx)
  10486. }
  10487. return nil, fmt.Errorf("unknown SopTask field %s", name)
  10488. }
  10489. // SetField sets the value of a field with the given name. It returns an error if
  10490. // the field is not defined in the schema, or if the type mismatched the field
  10491. // type.
  10492. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  10493. switch name {
  10494. case soptask.FieldCreatedAt:
  10495. v, ok := value.(time.Time)
  10496. if !ok {
  10497. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10498. }
  10499. m.SetCreatedAt(v)
  10500. return nil
  10501. case soptask.FieldUpdatedAt:
  10502. v, ok := value.(time.Time)
  10503. if !ok {
  10504. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10505. }
  10506. m.SetUpdatedAt(v)
  10507. return nil
  10508. case soptask.FieldStatus:
  10509. v, ok := value.(uint8)
  10510. if !ok {
  10511. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10512. }
  10513. m.SetStatus(v)
  10514. return nil
  10515. case soptask.FieldDeletedAt:
  10516. v, ok := value.(time.Time)
  10517. if !ok {
  10518. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10519. }
  10520. m.SetDeletedAt(v)
  10521. return nil
  10522. case soptask.FieldName:
  10523. v, ok := value.(string)
  10524. if !ok {
  10525. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10526. }
  10527. m.SetName(v)
  10528. return nil
  10529. case soptask.FieldBotWxidList:
  10530. v, ok := value.([]string)
  10531. if !ok {
  10532. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10533. }
  10534. m.SetBotWxidList(v)
  10535. return nil
  10536. case soptask.FieldType:
  10537. v, ok := value.(int)
  10538. if !ok {
  10539. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10540. }
  10541. m.SetType(v)
  10542. return nil
  10543. case soptask.FieldPlanStartTime:
  10544. v, ok := value.(time.Time)
  10545. if !ok {
  10546. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10547. }
  10548. m.SetPlanStartTime(v)
  10549. return nil
  10550. case soptask.FieldPlanEndTime:
  10551. v, ok := value.(time.Time)
  10552. if !ok {
  10553. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10554. }
  10555. m.SetPlanEndTime(v)
  10556. return nil
  10557. case soptask.FieldCreatorID:
  10558. v, ok := value.(string)
  10559. if !ok {
  10560. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10561. }
  10562. m.SetCreatorID(v)
  10563. return nil
  10564. }
  10565. return fmt.Errorf("unknown SopTask field %s", name)
  10566. }
  10567. // AddedFields returns all numeric fields that were incremented/decremented during
  10568. // this mutation.
  10569. func (m *SopTaskMutation) AddedFields() []string {
  10570. var fields []string
  10571. if m.addstatus != nil {
  10572. fields = append(fields, soptask.FieldStatus)
  10573. }
  10574. if m.add_type != nil {
  10575. fields = append(fields, soptask.FieldType)
  10576. }
  10577. return fields
  10578. }
  10579. // AddedField returns the numeric value that was incremented/decremented on a field
  10580. // with the given name. The second boolean return value indicates that this field
  10581. // was not set, or was not defined in the schema.
  10582. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  10583. switch name {
  10584. case soptask.FieldStatus:
  10585. return m.AddedStatus()
  10586. case soptask.FieldType:
  10587. return m.AddedType()
  10588. }
  10589. return nil, false
  10590. }
  10591. // AddField adds the value to the field with the given name. It returns an error if
  10592. // the field is not defined in the schema, or if the type mismatched the field
  10593. // type.
  10594. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  10595. switch name {
  10596. case soptask.FieldStatus:
  10597. v, ok := value.(int8)
  10598. if !ok {
  10599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10600. }
  10601. m.AddStatus(v)
  10602. return nil
  10603. case soptask.FieldType:
  10604. v, ok := value.(int)
  10605. if !ok {
  10606. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10607. }
  10608. m.AddType(v)
  10609. return nil
  10610. }
  10611. return fmt.Errorf("unknown SopTask numeric field %s", name)
  10612. }
  10613. // ClearedFields returns all nullable fields that were cleared during this
  10614. // mutation.
  10615. func (m *SopTaskMutation) ClearedFields() []string {
  10616. var fields []string
  10617. if m.FieldCleared(soptask.FieldStatus) {
  10618. fields = append(fields, soptask.FieldStatus)
  10619. }
  10620. if m.FieldCleared(soptask.FieldDeletedAt) {
  10621. fields = append(fields, soptask.FieldDeletedAt)
  10622. }
  10623. if m.FieldCleared(soptask.FieldBotWxidList) {
  10624. fields = append(fields, soptask.FieldBotWxidList)
  10625. }
  10626. if m.FieldCleared(soptask.FieldPlanStartTime) {
  10627. fields = append(fields, soptask.FieldPlanStartTime)
  10628. }
  10629. if m.FieldCleared(soptask.FieldPlanEndTime) {
  10630. fields = append(fields, soptask.FieldPlanEndTime)
  10631. }
  10632. if m.FieldCleared(soptask.FieldCreatorID) {
  10633. fields = append(fields, soptask.FieldCreatorID)
  10634. }
  10635. return fields
  10636. }
  10637. // FieldCleared returns a boolean indicating if a field with the given name was
  10638. // cleared in this mutation.
  10639. func (m *SopTaskMutation) FieldCleared(name string) bool {
  10640. _, ok := m.clearedFields[name]
  10641. return ok
  10642. }
  10643. // ClearField clears the value of the field with the given name. It returns an
  10644. // error if the field is not defined in the schema.
  10645. func (m *SopTaskMutation) ClearField(name string) error {
  10646. switch name {
  10647. case soptask.FieldStatus:
  10648. m.ClearStatus()
  10649. return nil
  10650. case soptask.FieldDeletedAt:
  10651. m.ClearDeletedAt()
  10652. return nil
  10653. case soptask.FieldBotWxidList:
  10654. m.ClearBotWxidList()
  10655. return nil
  10656. case soptask.FieldPlanStartTime:
  10657. m.ClearPlanStartTime()
  10658. return nil
  10659. case soptask.FieldPlanEndTime:
  10660. m.ClearPlanEndTime()
  10661. return nil
  10662. case soptask.FieldCreatorID:
  10663. m.ClearCreatorID()
  10664. return nil
  10665. }
  10666. return fmt.Errorf("unknown SopTask nullable field %s", name)
  10667. }
  10668. // ResetField resets all changes in the mutation for the field with the given name.
  10669. // It returns an error if the field is not defined in the schema.
  10670. func (m *SopTaskMutation) ResetField(name string) error {
  10671. switch name {
  10672. case soptask.FieldCreatedAt:
  10673. m.ResetCreatedAt()
  10674. return nil
  10675. case soptask.FieldUpdatedAt:
  10676. m.ResetUpdatedAt()
  10677. return nil
  10678. case soptask.FieldStatus:
  10679. m.ResetStatus()
  10680. return nil
  10681. case soptask.FieldDeletedAt:
  10682. m.ResetDeletedAt()
  10683. return nil
  10684. case soptask.FieldName:
  10685. m.ResetName()
  10686. return nil
  10687. case soptask.FieldBotWxidList:
  10688. m.ResetBotWxidList()
  10689. return nil
  10690. case soptask.FieldType:
  10691. m.ResetType()
  10692. return nil
  10693. case soptask.FieldPlanStartTime:
  10694. m.ResetPlanStartTime()
  10695. return nil
  10696. case soptask.FieldPlanEndTime:
  10697. m.ResetPlanEndTime()
  10698. return nil
  10699. case soptask.FieldCreatorID:
  10700. m.ResetCreatorID()
  10701. return nil
  10702. }
  10703. return fmt.Errorf("unknown SopTask field %s", name)
  10704. }
  10705. // AddedEdges returns all edge names that were set/added in this mutation.
  10706. func (m *SopTaskMutation) AddedEdges() []string {
  10707. edges := make([]string, 0, 1)
  10708. if m.task_stages != nil {
  10709. edges = append(edges, soptask.EdgeTaskStages)
  10710. }
  10711. return edges
  10712. }
  10713. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10714. // name in this mutation.
  10715. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  10716. switch name {
  10717. case soptask.EdgeTaskStages:
  10718. ids := make([]ent.Value, 0, len(m.task_stages))
  10719. for id := range m.task_stages {
  10720. ids = append(ids, id)
  10721. }
  10722. return ids
  10723. }
  10724. return nil
  10725. }
  10726. // RemovedEdges returns all edge names that were removed in this mutation.
  10727. func (m *SopTaskMutation) RemovedEdges() []string {
  10728. edges := make([]string, 0, 1)
  10729. if m.removedtask_stages != nil {
  10730. edges = append(edges, soptask.EdgeTaskStages)
  10731. }
  10732. return edges
  10733. }
  10734. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10735. // the given name in this mutation.
  10736. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  10737. switch name {
  10738. case soptask.EdgeTaskStages:
  10739. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  10740. for id := range m.removedtask_stages {
  10741. ids = append(ids, id)
  10742. }
  10743. return ids
  10744. }
  10745. return nil
  10746. }
  10747. // ClearedEdges returns all edge names that were cleared in this mutation.
  10748. func (m *SopTaskMutation) ClearedEdges() []string {
  10749. edges := make([]string, 0, 1)
  10750. if m.clearedtask_stages {
  10751. edges = append(edges, soptask.EdgeTaskStages)
  10752. }
  10753. return edges
  10754. }
  10755. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10756. // was cleared in this mutation.
  10757. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  10758. switch name {
  10759. case soptask.EdgeTaskStages:
  10760. return m.clearedtask_stages
  10761. }
  10762. return false
  10763. }
  10764. // ClearEdge clears the value of the edge with the given name. It returns an error
  10765. // if that edge is not defined in the schema.
  10766. func (m *SopTaskMutation) ClearEdge(name string) error {
  10767. switch name {
  10768. }
  10769. return fmt.Errorf("unknown SopTask unique edge %s", name)
  10770. }
  10771. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10772. // It returns an error if the edge is not defined in the schema.
  10773. func (m *SopTaskMutation) ResetEdge(name string) error {
  10774. switch name {
  10775. case soptask.EdgeTaskStages:
  10776. m.ResetTaskStages()
  10777. return nil
  10778. }
  10779. return fmt.Errorf("unknown SopTask edge %s", name)
  10780. }
  10781. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  10782. type WxMutation struct {
  10783. config
  10784. op Op
  10785. typ string
  10786. id *uint64
  10787. created_at *time.Time
  10788. updated_at *time.Time
  10789. status *uint8
  10790. addstatus *int8
  10791. deleted_at *time.Time
  10792. port *string
  10793. process_id *string
  10794. callback *string
  10795. wxid *string
  10796. account *string
  10797. nickname *string
  10798. tel *string
  10799. head_big *string
  10800. clearedFields map[string]struct{}
  10801. server *uint64
  10802. clearedserver bool
  10803. done bool
  10804. oldValue func(context.Context) (*Wx, error)
  10805. predicates []predicate.Wx
  10806. }
  10807. var _ ent.Mutation = (*WxMutation)(nil)
  10808. // wxOption allows management of the mutation configuration using functional options.
  10809. type wxOption func(*WxMutation)
  10810. // newWxMutation creates new mutation for the Wx entity.
  10811. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  10812. m := &WxMutation{
  10813. config: c,
  10814. op: op,
  10815. typ: TypeWx,
  10816. clearedFields: make(map[string]struct{}),
  10817. }
  10818. for _, opt := range opts {
  10819. opt(m)
  10820. }
  10821. return m
  10822. }
  10823. // withWxID sets the ID field of the mutation.
  10824. func withWxID(id uint64) wxOption {
  10825. return func(m *WxMutation) {
  10826. var (
  10827. err error
  10828. once sync.Once
  10829. value *Wx
  10830. )
  10831. m.oldValue = func(ctx context.Context) (*Wx, error) {
  10832. once.Do(func() {
  10833. if m.done {
  10834. err = errors.New("querying old values post mutation is not allowed")
  10835. } else {
  10836. value, err = m.Client().Wx.Get(ctx, id)
  10837. }
  10838. })
  10839. return value, err
  10840. }
  10841. m.id = &id
  10842. }
  10843. }
  10844. // withWx sets the old Wx of the mutation.
  10845. func withWx(node *Wx) wxOption {
  10846. return func(m *WxMutation) {
  10847. m.oldValue = func(context.Context) (*Wx, error) {
  10848. return node, nil
  10849. }
  10850. m.id = &node.ID
  10851. }
  10852. }
  10853. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10854. // executed in a transaction (ent.Tx), a transactional client is returned.
  10855. func (m WxMutation) Client() *Client {
  10856. client := &Client{config: m.config}
  10857. client.init()
  10858. return client
  10859. }
  10860. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10861. // it returns an error otherwise.
  10862. func (m WxMutation) Tx() (*Tx, error) {
  10863. if _, ok := m.driver.(*txDriver); !ok {
  10864. return nil, errors.New("ent: mutation is not running in a transaction")
  10865. }
  10866. tx := &Tx{config: m.config}
  10867. tx.init()
  10868. return tx, nil
  10869. }
  10870. // SetID sets the value of the id field. Note that this
  10871. // operation is only accepted on creation of Wx entities.
  10872. func (m *WxMutation) SetID(id uint64) {
  10873. m.id = &id
  10874. }
  10875. // ID returns the ID value in the mutation. Note that the ID is only available
  10876. // if it was provided to the builder or after it was returned from the database.
  10877. func (m *WxMutation) ID() (id uint64, exists bool) {
  10878. if m.id == nil {
  10879. return
  10880. }
  10881. return *m.id, true
  10882. }
  10883. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10884. // That means, if the mutation is applied within a transaction with an isolation level such
  10885. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10886. // or updated by the mutation.
  10887. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  10888. switch {
  10889. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10890. id, exists := m.ID()
  10891. if exists {
  10892. return []uint64{id}, nil
  10893. }
  10894. fallthrough
  10895. case m.op.Is(OpUpdate | OpDelete):
  10896. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  10897. default:
  10898. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10899. }
  10900. }
  10901. // SetCreatedAt sets the "created_at" field.
  10902. func (m *WxMutation) SetCreatedAt(t time.Time) {
  10903. m.created_at = &t
  10904. }
  10905. // CreatedAt returns the value of the "created_at" field in the mutation.
  10906. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  10907. v := m.created_at
  10908. if v == nil {
  10909. return
  10910. }
  10911. return *v, true
  10912. }
  10913. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  10914. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  10915. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10916. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10917. if !m.op.Is(OpUpdateOne) {
  10918. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10919. }
  10920. if m.id == nil || m.oldValue == nil {
  10921. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10922. }
  10923. oldValue, err := m.oldValue(ctx)
  10924. if err != nil {
  10925. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10926. }
  10927. return oldValue.CreatedAt, nil
  10928. }
  10929. // ResetCreatedAt resets all changes to the "created_at" field.
  10930. func (m *WxMutation) ResetCreatedAt() {
  10931. m.created_at = nil
  10932. }
  10933. // SetUpdatedAt sets the "updated_at" field.
  10934. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  10935. m.updated_at = &t
  10936. }
  10937. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10938. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  10939. v := m.updated_at
  10940. if v == nil {
  10941. return
  10942. }
  10943. return *v, true
  10944. }
  10945. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  10946. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  10947. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10948. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10949. if !m.op.Is(OpUpdateOne) {
  10950. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10951. }
  10952. if m.id == nil || m.oldValue == nil {
  10953. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10954. }
  10955. oldValue, err := m.oldValue(ctx)
  10956. if err != nil {
  10957. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10958. }
  10959. return oldValue.UpdatedAt, nil
  10960. }
  10961. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10962. func (m *WxMutation) ResetUpdatedAt() {
  10963. m.updated_at = nil
  10964. }
  10965. // SetStatus sets the "status" field.
  10966. func (m *WxMutation) SetStatus(u uint8) {
  10967. m.status = &u
  10968. m.addstatus = nil
  10969. }
  10970. // Status returns the value of the "status" field in the mutation.
  10971. func (m *WxMutation) Status() (r uint8, exists bool) {
  10972. v := m.status
  10973. if v == nil {
  10974. return
  10975. }
  10976. return *v, true
  10977. }
  10978. // OldStatus returns the old "status" field's value of the Wx entity.
  10979. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  10980. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10981. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  10982. if !m.op.Is(OpUpdateOne) {
  10983. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  10984. }
  10985. if m.id == nil || m.oldValue == nil {
  10986. return v, errors.New("OldStatus requires an ID field in the mutation")
  10987. }
  10988. oldValue, err := m.oldValue(ctx)
  10989. if err != nil {
  10990. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  10991. }
  10992. return oldValue.Status, nil
  10993. }
  10994. // AddStatus adds u to the "status" field.
  10995. func (m *WxMutation) AddStatus(u int8) {
  10996. if m.addstatus != nil {
  10997. *m.addstatus += u
  10998. } else {
  10999. m.addstatus = &u
  11000. }
  11001. }
  11002. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11003. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  11004. v := m.addstatus
  11005. if v == nil {
  11006. return
  11007. }
  11008. return *v, true
  11009. }
  11010. // ClearStatus clears the value of the "status" field.
  11011. func (m *WxMutation) ClearStatus() {
  11012. m.status = nil
  11013. m.addstatus = nil
  11014. m.clearedFields[wx.FieldStatus] = struct{}{}
  11015. }
  11016. // StatusCleared returns if the "status" field was cleared in this mutation.
  11017. func (m *WxMutation) StatusCleared() bool {
  11018. _, ok := m.clearedFields[wx.FieldStatus]
  11019. return ok
  11020. }
  11021. // ResetStatus resets all changes to the "status" field.
  11022. func (m *WxMutation) ResetStatus() {
  11023. m.status = nil
  11024. m.addstatus = nil
  11025. delete(m.clearedFields, wx.FieldStatus)
  11026. }
  11027. // SetDeletedAt sets the "deleted_at" field.
  11028. func (m *WxMutation) SetDeletedAt(t time.Time) {
  11029. m.deleted_at = &t
  11030. }
  11031. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11032. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  11033. v := m.deleted_at
  11034. if v == nil {
  11035. return
  11036. }
  11037. return *v, true
  11038. }
  11039. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  11040. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  11041. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11042. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11043. if !m.op.Is(OpUpdateOne) {
  11044. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11045. }
  11046. if m.id == nil || m.oldValue == nil {
  11047. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11048. }
  11049. oldValue, err := m.oldValue(ctx)
  11050. if err != nil {
  11051. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11052. }
  11053. return oldValue.DeletedAt, nil
  11054. }
  11055. // ClearDeletedAt clears the value of the "deleted_at" field.
  11056. func (m *WxMutation) ClearDeletedAt() {
  11057. m.deleted_at = nil
  11058. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  11059. }
  11060. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11061. func (m *WxMutation) DeletedAtCleared() bool {
  11062. _, ok := m.clearedFields[wx.FieldDeletedAt]
  11063. return ok
  11064. }
  11065. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11066. func (m *WxMutation) ResetDeletedAt() {
  11067. m.deleted_at = nil
  11068. delete(m.clearedFields, wx.FieldDeletedAt)
  11069. }
  11070. // SetServerID sets the "server_id" field.
  11071. func (m *WxMutation) SetServerID(u uint64) {
  11072. m.server = &u
  11073. }
  11074. // ServerID returns the value of the "server_id" field in the mutation.
  11075. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  11076. v := m.server
  11077. if v == nil {
  11078. return
  11079. }
  11080. return *v, true
  11081. }
  11082. // OldServerID returns the old "server_id" field's value of the Wx entity.
  11083. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  11084. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11085. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  11086. if !m.op.Is(OpUpdateOne) {
  11087. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  11088. }
  11089. if m.id == nil || m.oldValue == nil {
  11090. return v, errors.New("OldServerID requires an ID field in the mutation")
  11091. }
  11092. oldValue, err := m.oldValue(ctx)
  11093. if err != nil {
  11094. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  11095. }
  11096. return oldValue.ServerID, nil
  11097. }
  11098. // ClearServerID clears the value of the "server_id" field.
  11099. func (m *WxMutation) ClearServerID() {
  11100. m.server = nil
  11101. m.clearedFields[wx.FieldServerID] = struct{}{}
  11102. }
  11103. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  11104. func (m *WxMutation) ServerIDCleared() bool {
  11105. _, ok := m.clearedFields[wx.FieldServerID]
  11106. return ok
  11107. }
  11108. // ResetServerID resets all changes to the "server_id" field.
  11109. func (m *WxMutation) ResetServerID() {
  11110. m.server = nil
  11111. delete(m.clearedFields, wx.FieldServerID)
  11112. }
  11113. // SetPort sets the "port" field.
  11114. func (m *WxMutation) SetPort(s string) {
  11115. m.port = &s
  11116. }
  11117. // Port returns the value of the "port" field in the mutation.
  11118. func (m *WxMutation) Port() (r string, exists bool) {
  11119. v := m.port
  11120. if v == nil {
  11121. return
  11122. }
  11123. return *v, true
  11124. }
  11125. // OldPort returns the old "port" field's value of the Wx entity.
  11126. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  11127. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11128. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  11129. if !m.op.Is(OpUpdateOne) {
  11130. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  11131. }
  11132. if m.id == nil || m.oldValue == nil {
  11133. return v, errors.New("OldPort requires an ID field in the mutation")
  11134. }
  11135. oldValue, err := m.oldValue(ctx)
  11136. if err != nil {
  11137. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  11138. }
  11139. return oldValue.Port, nil
  11140. }
  11141. // ResetPort resets all changes to the "port" field.
  11142. func (m *WxMutation) ResetPort() {
  11143. m.port = nil
  11144. }
  11145. // SetProcessID sets the "process_id" field.
  11146. func (m *WxMutation) SetProcessID(s string) {
  11147. m.process_id = &s
  11148. }
  11149. // ProcessID returns the value of the "process_id" field in the mutation.
  11150. func (m *WxMutation) ProcessID() (r string, exists bool) {
  11151. v := m.process_id
  11152. if v == nil {
  11153. return
  11154. }
  11155. return *v, true
  11156. }
  11157. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  11158. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  11159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11160. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  11161. if !m.op.Is(OpUpdateOne) {
  11162. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  11163. }
  11164. if m.id == nil || m.oldValue == nil {
  11165. return v, errors.New("OldProcessID requires an ID field in the mutation")
  11166. }
  11167. oldValue, err := m.oldValue(ctx)
  11168. if err != nil {
  11169. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  11170. }
  11171. return oldValue.ProcessID, nil
  11172. }
  11173. // ResetProcessID resets all changes to the "process_id" field.
  11174. func (m *WxMutation) ResetProcessID() {
  11175. m.process_id = nil
  11176. }
  11177. // SetCallback sets the "callback" field.
  11178. func (m *WxMutation) SetCallback(s string) {
  11179. m.callback = &s
  11180. }
  11181. // Callback returns the value of the "callback" field in the mutation.
  11182. func (m *WxMutation) Callback() (r string, exists bool) {
  11183. v := m.callback
  11184. if v == nil {
  11185. return
  11186. }
  11187. return *v, true
  11188. }
  11189. // OldCallback returns the old "callback" field's value of the Wx entity.
  11190. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  11191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11192. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  11193. if !m.op.Is(OpUpdateOne) {
  11194. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  11195. }
  11196. if m.id == nil || m.oldValue == nil {
  11197. return v, errors.New("OldCallback requires an ID field in the mutation")
  11198. }
  11199. oldValue, err := m.oldValue(ctx)
  11200. if err != nil {
  11201. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  11202. }
  11203. return oldValue.Callback, nil
  11204. }
  11205. // ResetCallback resets all changes to the "callback" field.
  11206. func (m *WxMutation) ResetCallback() {
  11207. m.callback = nil
  11208. }
  11209. // SetWxid sets the "wxid" field.
  11210. func (m *WxMutation) SetWxid(s string) {
  11211. m.wxid = &s
  11212. }
  11213. // Wxid returns the value of the "wxid" field in the mutation.
  11214. func (m *WxMutation) Wxid() (r string, exists bool) {
  11215. v := m.wxid
  11216. if v == nil {
  11217. return
  11218. }
  11219. return *v, true
  11220. }
  11221. // OldWxid returns the old "wxid" field's value of the Wx entity.
  11222. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  11223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11224. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  11225. if !m.op.Is(OpUpdateOne) {
  11226. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  11227. }
  11228. if m.id == nil || m.oldValue == nil {
  11229. return v, errors.New("OldWxid requires an ID field in the mutation")
  11230. }
  11231. oldValue, err := m.oldValue(ctx)
  11232. if err != nil {
  11233. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  11234. }
  11235. return oldValue.Wxid, nil
  11236. }
  11237. // ResetWxid resets all changes to the "wxid" field.
  11238. func (m *WxMutation) ResetWxid() {
  11239. m.wxid = nil
  11240. }
  11241. // SetAccount sets the "account" field.
  11242. func (m *WxMutation) SetAccount(s string) {
  11243. m.account = &s
  11244. }
  11245. // Account returns the value of the "account" field in the mutation.
  11246. func (m *WxMutation) Account() (r string, exists bool) {
  11247. v := m.account
  11248. if v == nil {
  11249. return
  11250. }
  11251. return *v, true
  11252. }
  11253. // OldAccount returns the old "account" field's value of the Wx entity.
  11254. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  11255. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11256. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  11257. if !m.op.Is(OpUpdateOne) {
  11258. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  11259. }
  11260. if m.id == nil || m.oldValue == nil {
  11261. return v, errors.New("OldAccount requires an ID field in the mutation")
  11262. }
  11263. oldValue, err := m.oldValue(ctx)
  11264. if err != nil {
  11265. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  11266. }
  11267. return oldValue.Account, nil
  11268. }
  11269. // ResetAccount resets all changes to the "account" field.
  11270. func (m *WxMutation) ResetAccount() {
  11271. m.account = nil
  11272. }
  11273. // SetNickname sets the "nickname" field.
  11274. func (m *WxMutation) SetNickname(s string) {
  11275. m.nickname = &s
  11276. }
  11277. // Nickname returns the value of the "nickname" field in the mutation.
  11278. func (m *WxMutation) Nickname() (r string, exists bool) {
  11279. v := m.nickname
  11280. if v == nil {
  11281. return
  11282. }
  11283. return *v, true
  11284. }
  11285. // OldNickname returns the old "nickname" field's value of the Wx entity.
  11286. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  11287. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11288. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  11289. if !m.op.Is(OpUpdateOne) {
  11290. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  11291. }
  11292. if m.id == nil || m.oldValue == nil {
  11293. return v, errors.New("OldNickname requires an ID field in the mutation")
  11294. }
  11295. oldValue, err := m.oldValue(ctx)
  11296. if err != nil {
  11297. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  11298. }
  11299. return oldValue.Nickname, nil
  11300. }
  11301. // ResetNickname resets all changes to the "nickname" field.
  11302. func (m *WxMutation) ResetNickname() {
  11303. m.nickname = nil
  11304. }
  11305. // SetTel sets the "tel" field.
  11306. func (m *WxMutation) SetTel(s string) {
  11307. m.tel = &s
  11308. }
  11309. // Tel returns the value of the "tel" field in the mutation.
  11310. func (m *WxMutation) Tel() (r string, exists bool) {
  11311. v := m.tel
  11312. if v == nil {
  11313. return
  11314. }
  11315. return *v, true
  11316. }
  11317. // OldTel returns the old "tel" field's value of the Wx entity.
  11318. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  11319. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11320. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  11321. if !m.op.Is(OpUpdateOne) {
  11322. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  11323. }
  11324. if m.id == nil || m.oldValue == nil {
  11325. return v, errors.New("OldTel requires an ID field in the mutation")
  11326. }
  11327. oldValue, err := m.oldValue(ctx)
  11328. if err != nil {
  11329. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  11330. }
  11331. return oldValue.Tel, nil
  11332. }
  11333. // ResetTel resets all changes to the "tel" field.
  11334. func (m *WxMutation) ResetTel() {
  11335. m.tel = nil
  11336. }
  11337. // SetHeadBig sets the "head_big" field.
  11338. func (m *WxMutation) SetHeadBig(s string) {
  11339. m.head_big = &s
  11340. }
  11341. // HeadBig returns the value of the "head_big" field in the mutation.
  11342. func (m *WxMutation) HeadBig() (r string, exists bool) {
  11343. v := m.head_big
  11344. if v == nil {
  11345. return
  11346. }
  11347. return *v, true
  11348. }
  11349. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  11350. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  11351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11352. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  11353. if !m.op.Is(OpUpdateOne) {
  11354. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  11355. }
  11356. if m.id == nil || m.oldValue == nil {
  11357. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  11358. }
  11359. oldValue, err := m.oldValue(ctx)
  11360. if err != nil {
  11361. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  11362. }
  11363. return oldValue.HeadBig, nil
  11364. }
  11365. // ResetHeadBig resets all changes to the "head_big" field.
  11366. func (m *WxMutation) ResetHeadBig() {
  11367. m.head_big = nil
  11368. }
  11369. // ClearServer clears the "server" edge to the Server entity.
  11370. func (m *WxMutation) ClearServer() {
  11371. m.clearedserver = true
  11372. m.clearedFields[wx.FieldServerID] = struct{}{}
  11373. }
  11374. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  11375. func (m *WxMutation) ServerCleared() bool {
  11376. return m.ServerIDCleared() || m.clearedserver
  11377. }
  11378. // ServerIDs returns the "server" edge IDs in the mutation.
  11379. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  11380. // ServerID instead. It exists only for internal usage by the builders.
  11381. func (m *WxMutation) ServerIDs() (ids []uint64) {
  11382. if id := m.server; id != nil {
  11383. ids = append(ids, *id)
  11384. }
  11385. return
  11386. }
  11387. // ResetServer resets all changes to the "server" edge.
  11388. func (m *WxMutation) ResetServer() {
  11389. m.server = nil
  11390. m.clearedserver = false
  11391. }
  11392. // Where appends a list predicates to the WxMutation builder.
  11393. func (m *WxMutation) Where(ps ...predicate.Wx) {
  11394. m.predicates = append(m.predicates, ps...)
  11395. }
  11396. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  11397. // users can use type-assertion to append predicates that do not depend on any generated package.
  11398. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  11399. p := make([]predicate.Wx, len(ps))
  11400. for i := range ps {
  11401. p[i] = ps[i]
  11402. }
  11403. m.Where(p...)
  11404. }
  11405. // Op returns the operation name.
  11406. func (m *WxMutation) Op() Op {
  11407. return m.op
  11408. }
  11409. // SetOp allows setting the mutation operation.
  11410. func (m *WxMutation) SetOp(op Op) {
  11411. m.op = op
  11412. }
  11413. // Type returns the node type of this mutation (Wx).
  11414. func (m *WxMutation) Type() string {
  11415. return m.typ
  11416. }
  11417. // Fields returns all fields that were changed during this mutation. Note that in
  11418. // order to get all numeric fields that were incremented/decremented, call
  11419. // AddedFields().
  11420. func (m *WxMutation) Fields() []string {
  11421. fields := make([]string, 0, 13)
  11422. if m.created_at != nil {
  11423. fields = append(fields, wx.FieldCreatedAt)
  11424. }
  11425. if m.updated_at != nil {
  11426. fields = append(fields, wx.FieldUpdatedAt)
  11427. }
  11428. if m.status != nil {
  11429. fields = append(fields, wx.FieldStatus)
  11430. }
  11431. if m.deleted_at != nil {
  11432. fields = append(fields, wx.FieldDeletedAt)
  11433. }
  11434. if m.server != nil {
  11435. fields = append(fields, wx.FieldServerID)
  11436. }
  11437. if m.port != nil {
  11438. fields = append(fields, wx.FieldPort)
  11439. }
  11440. if m.process_id != nil {
  11441. fields = append(fields, wx.FieldProcessID)
  11442. }
  11443. if m.callback != nil {
  11444. fields = append(fields, wx.FieldCallback)
  11445. }
  11446. if m.wxid != nil {
  11447. fields = append(fields, wx.FieldWxid)
  11448. }
  11449. if m.account != nil {
  11450. fields = append(fields, wx.FieldAccount)
  11451. }
  11452. if m.nickname != nil {
  11453. fields = append(fields, wx.FieldNickname)
  11454. }
  11455. if m.tel != nil {
  11456. fields = append(fields, wx.FieldTel)
  11457. }
  11458. if m.head_big != nil {
  11459. fields = append(fields, wx.FieldHeadBig)
  11460. }
  11461. return fields
  11462. }
  11463. // Field returns the value of a field with the given name. The second boolean
  11464. // return value indicates that this field was not set, or was not defined in the
  11465. // schema.
  11466. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  11467. switch name {
  11468. case wx.FieldCreatedAt:
  11469. return m.CreatedAt()
  11470. case wx.FieldUpdatedAt:
  11471. return m.UpdatedAt()
  11472. case wx.FieldStatus:
  11473. return m.Status()
  11474. case wx.FieldDeletedAt:
  11475. return m.DeletedAt()
  11476. case wx.FieldServerID:
  11477. return m.ServerID()
  11478. case wx.FieldPort:
  11479. return m.Port()
  11480. case wx.FieldProcessID:
  11481. return m.ProcessID()
  11482. case wx.FieldCallback:
  11483. return m.Callback()
  11484. case wx.FieldWxid:
  11485. return m.Wxid()
  11486. case wx.FieldAccount:
  11487. return m.Account()
  11488. case wx.FieldNickname:
  11489. return m.Nickname()
  11490. case wx.FieldTel:
  11491. return m.Tel()
  11492. case wx.FieldHeadBig:
  11493. return m.HeadBig()
  11494. }
  11495. return nil, false
  11496. }
  11497. // OldField returns the old value of the field from the database. An error is
  11498. // returned if the mutation operation is not UpdateOne, or the query to the
  11499. // database failed.
  11500. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11501. switch name {
  11502. case wx.FieldCreatedAt:
  11503. return m.OldCreatedAt(ctx)
  11504. case wx.FieldUpdatedAt:
  11505. return m.OldUpdatedAt(ctx)
  11506. case wx.FieldStatus:
  11507. return m.OldStatus(ctx)
  11508. case wx.FieldDeletedAt:
  11509. return m.OldDeletedAt(ctx)
  11510. case wx.FieldServerID:
  11511. return m.OldServerID(ctx)
  11512. case wx.FieldPort:
  11513. return m.OldPort(ctx)
  11514. case wx.FieldProcessID:
  11515. return m.OldProcessID(ctx)
  11516. case wx.FieldCallback:
  11517. return m.OldCallback(ctx)
  11518. case wx.FieldWxid:
  11519. return m.OldWxid(ctx)
  11520. case wx.FieldAccount:
  11521. return m.OldAccount(ctx)
  11522. case wx.FieldNickname:
  11523. return m.OldNickname(ctx)
  11524. case wx.FieldTel:
  11525. return m.OldTel(ctx)
  11526. case wx.FieldHeadBig:
  11527. return m.OldHeadBig(ctx)
  11528. }
  11529. return nil, fmt.Errorf("unknown Wx field %s", name)
  11530. }
  11531. // SetField sets the value of a field with the given name. It returns an error if
  11532. // the field is not defined in the schema, or if the type mismatched the field
  11533. // type.
  11534. func (m *WxMutation) SetField(name string, value ent.Value) error {
  11535. switch name {
  11536. case wx.FieldCreatedAt:
  11537. v, ok := value.(time.Time)
  11538. if !ok {
  11539. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11540. }
  11541. m.SetCreatedAt(v)
  11542. return nil
  11543. case wx.FieldUpdatedAt:
  11544. v, ok := value.(time.Time)
  11545. if !ok {
  11546. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11547. }
  11548. m.SetUpdatedAt(v)
  11549. return nil
  11550. case wx.FieldStatus:
  11551. v, ok := value.(uint8)
  11552. if !ok {
  11553. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11554. }
  11555. m.SetStatus(v)
  11556. return nil
  11557. case wx.FieldDeletedAt:
  11558. v, ok := value.(time.Time)
  11559. if !ok {
  11560. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11561. }
  11562. m.SetDeletedAt(v)
  11563. return nil
  11564. case wx.FieldServerID:
  11565. v, ok := value.(uint64)
  11566. if !ok {
  11567. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11568. }
  11569. m.SetServerID(v)
  11570. return nil
  11571. case wx.FieldPort:
  11572. v, ok := value.(string)
  11573. if !ok {
  11574. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11575. }
  11576. m.SetPort(v)
  11577. return nil
  11578. case wx.FieldProcessID:
  11579. v, ok := value.(string)
  11580. if !ok {
  11581. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11582. }
  11583. m.SetProcessID(v)
  11584. return nil
  11585. case wx.FieldCallback:
  11586. v, ok := value.(string)
  11587. if !ok {
  11588. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11589. }
  11590. m.SetCallback(v)
  11591. return nil
  11592. case wx.FieldWxid:
  11593. v, ok := value.(string)
  11594. if !ok {
  11595. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11596. }
  11597. m.SetWxid(v)
  11598. return nil
  11599. case wx.FieldAccount:
  11600. v, ok := value.(string)
  11601. if !ok {
  11602. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11603. }
  11604. m.SetAccount(v)
  11605. return nil
  11606. case wx.FieldNickname:
  11607. v, ok := value.(string)
  11608. if !ok {
  11609. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11610. }
  11611. m.SetNickname(v)
  11612. return nil
  11613. case wx.FieldTel:
  11614. v, ok := value.(string)
  11615. if !ok {
  11616. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11617. }
  11618. m.SetTel(v)
  11619. return nil
  11620. case wx.FieldHeadBig:
  11621. v, ok := value.(string)
  11622. if !ok {
  11623. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11624. }
  11625. m.SetHeadBig(v)
  11626. return nil
  11627. }
  11628. return fmt.Errorf("unknown Wx field %s", name)
  11629. }
  11630. // AddedFields returns all numeric fields that were incremented/decremented during
  11631. // this mutation.
  11632. func (m *WxMutation) AddedFields() []string {
  11633. var fields []string
  11634. if m.addstatus != nil {
  11635. fields = append(fields, wx.FieldStatus)
  11636. }
  11637. return fields
  11638. }
  11639. // AddedField returns the numeric value that was incremented/decremented on a field
  11640. // with the given name. The second boolean return value indicates that this field
  11641. // was not set, or was not defined in the schema.
  11642. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  11643. switch name {
  11644. case wx.FieldStatus:
  11645. return m.AddedStatus()
  11646. }
  11647. return nil, false
  11648. }
  11649. // AddField adds the value to the field with the given name. It returns an error if
  11650. // the field is not defined in the schema, or if the type mismatched the field
  11651. // type.
  11652. func (m *WxMutation) AddField(name string, value ent.Value) error {
  11653. switch name {
  11654. case wx.FieldStatus:
  11655. v, ok := value.(int8)
  11656. if !ok {
  11657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11658. }
  11659. m.AddStatus(v)
  11660. return nil
  11661. }
  11662. return fmt.Errorf("unknown Wx numeric field %s", name)
  11663. }
  11664. // ClearedFields returns all nullable fields that were cleared during this
  11665. // mutation.
  11666. func (m *WxMutation) ClearedFields() []string {
  11667. var fields []string
  11668. if m.FieldCleared(wx.FieldStatus) {
  11669. fields = append(fields, wx.FieldStatus)
  11670. }
  11671. if m.FieldCleared(wx.FieldDeletedAt) {
  11672. fields = append(fields, wx.FieldDeletedAt)
  11673. }
  11674. if m.FieldCleared(wx.FieldServerID) {
  11675. fields = append(fields, wx.FieldServerID)
  11676. }
  11677. return fields
  11678. }
  11679. // FieldCleared returns a boolean indicating if a field with the given name was
  11680. // cleared in this mutation.
  11681. func (m *WxMutation) FieldCleared(name string) bool {
  11682. _, ok := m.clearedFields[name]
  11683. return ok
  11684. }
  11685. // ClearField clears the value of the field with the given name. It returns an
  11686. // error if the field is not defined in the schema.
  11687. func (m *WxMutation) ClearField(name string) error {
  11688. switch name {
  11689. case wx.FieldStatus:
  11690. m.ClearStatus()
  11691. return nil
  11692. case wx.FieldDeletedAt:
  11693. m.ClearDeletedAt()
  11694. return nil
  11695. case wx.FieldServerID:
  11696. m.ClearServerID()
  11697. return nil
  11698. }
  11699. return fmt.Errorf("unknown Wx nullable field %s", name)
  11700. }
  11701. // ResetField resets all changes in the mutation for the field with the given name.
  11702. // It returns an error if the field is not defined in the schema.
  11703. func (m *WxMutation) ResetField(name string) error {
  11704. switch name {
  11705. case wx.FieldCreatedAt:
  11706. m.ResetCreatedAt()
  11707. return nil
  11708. case wx.FieldUpdatedAt:
  11709. m.ResetUpdatedAt()
  11710. return nil
  11711. case wx.FieldStatus:
  11712. m.ResetStatus()
  11713. return nil
  11714. case wx.FieldDeletedAt:
  11715. m.ResetDeletedAt()
  11716. return nil
  11717. case wx.FieldServerID:
  11718. m.ResetServerID()
  11719. return nil
  11720. case wx.FieldPort:
  11721. m.ResetPort()
  11722. return nil
  11723. case wx.FieldProcessID:
  11724. m.ResetProcessID()
  11725. return nil
  11726. case wx.FieldCallback:
  11727. m.ResetCallback()
  11728. return nil
  11729. case wx.FieldWxid:
  11730. m.ResetWxid()
  11731. return nil
  11732. case wx.FieldAccount:
  11733. m.ResetAccount()
  11734. return nil
  11735. case wx.FieldNickname:
  11736. m.ResetNickname()
  11737. return nil
  11738. case wx.FieldTel:
  11739. m.ResetTel()
  11740. return nil
  11741. case wx.FieldHeadBig:
  11742. m.ResetHeadBig()
  11743. return nil
  11744. }
  11745. return fmt.Errorf("unknown Wx field %s", name)
  11746. }
  11747. // AddedEdges returns all edge names that were set/added in this mutation.
  11748. func (m *WxMutation) AddedEdges() []string {
  11749. edges := make([]string, 0, 1)
  11750. if m.server != nil {
  11751. edges = append(edges, wx.EdgeServer)
  11752. }
  11753. return edges
  11754. }
  11755. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11756. // name in this mutation.
  11757. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  11758. switch name {
  11759. case wx.EdgeServer:
  11760. if id := m.server; id != nil {
  11761. return []ent.Value{*id}
  11762. }
  11763. }
  11764. return nil
  11765. }
  11766. // RemovedEdges returns all edge names that were removed in this mutation.
  11767. func (m *WxMutation) RemovedEdges() []string {
  11768. edges := make([]string, 0, 1)
  11769. return edges
  11770. }
  11771. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11772. // the given name in this mutation.
  11773. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  11774. return nil
  11775. }
  11776. // ClearedEdges returns all edge names that were cleared in this mutation.
  11777. func (m *WxMutation) ClearedEdges() []string {
  11778. edges := make([]string, 0, 1)
  11779. if m.clearedserver {
  11780. edges = append(edges, wx.EdgeServer)
  11781. }
  11782. return edges
  11783. }
  11784. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11785. // was cleared in this mutation.
  11786. func (m *WxMutation) EdgeCleared(name string) bool {
  11787. switch name {
  11788. case wx.EdgeServer:
  11789. return m.clearedserver
  11790. }
  11791. return false
  11792. }
  11793. // ClearEdge clears the value of the edge with the given name. It returns an error
  11794. // if that edge is not defined in the schema.
  11795. func (m *WxMutation) ClearEdge(name string) error {
  11796. switch name {
  11797. case wx.EdgeServer:
  11798. m.ClearServer()
  11799. return nil
  11800. }
  11801. return fmt.Errorf("unknown Wx unique edge %s", name)
  11802. }
  11803. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11804. // It returns an error if the edge is not defined in the schema.
  11805. func (m *WxMutation) ResetEdge(name string) error {
  11806. switch name {
  11807. case wx.EdgeServer:
  11808. m.ResetServer()
  11809. return nil
  11810. }
  11811. return fmt.Errorf("unknown Wx edge %s", name)
  11812. }