mutation.go 323 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072
  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/contact"
  10. "wechat-api/ent/custom_types"
  11. "wechat-api/ent/label"
  12. "wechat-api/ent/labelrelationship"
  13. "wechat-api/ent/message"
  14. "wechat-api/ent/messagerecords"
  15. "wechat-api/ent/predicate"
  16. "wechat-api/ent/server"
  17. "wechat-api/ent/sopnode"
  18. "wechat-api/ent/sopstage"
  19. "wechat-api/ent/soptask"
  20. "wechat-api/ent/wx"
  21. "entgo.io/ent"
  22. "entgo.io/ent/dialect/sql"
  23. )
  24. const (
  25. // Operation types.
  26. OpCreate = ent.OpCreate
  27. OpDelete = ent.OpDelete
  28. OpDeleteOne = ent.OpDeleteOne
  29. OpUpdate = ent.OpUpdate
  30. OpUpdateOne = ent.OpUpdateOne
  31. // Node types.
  32. TypeContact = "Contact"
  33. TypeLabel = "Label"
  34. TypeLabelRelationship = "LabelRelationship"
  35. TypeMessage = "Message"
  36. TypeMessageRecords = "MessageRecords"
  37. TypeServer = "Server"
  38. TypeSopNode = "SopNode"
  39. TypeSopStage = "SopStage"
  40. TypeSopTask = "SopTask"
  41. TypeWx = "Wx"
  42. )
  43. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  44. type ContactMutation struct {
  45. config
  46. op Op
  47. typ string
  48. id *uint64
  49. created_at *time.Time
  50. updated_at *time.Time
  51. status *uint8
  52. addstatus *int8
  53. deleted_at *time.Time
  54. wx_wxid *string
  55. _type *int
  56. add_type *int
  57. wxid *string
  58. account *string
  59. nickname *string
  60. markname *string
  61. headimg *string
  62. sex *int
  63. addsex *int
  64. starrole *string
  65. dontseeit *int
  66. adddontseeit *int
  67. dontseeme *int
  68. adddontseeme *int
  69. lag *string
  70. gid *string
  71. gname *string
  72. v3 *string
  73. clearedFields map[string]struct{}
  74. contact_relationships map[uint64]struct{}
  75. removedcontact_relationships map[uint64]struct{}
  76. clearedcontact_relationships bool
  77. done bool
  78. oldValue func(context.Context) (*Contact, error)
  79. predicates []predicate.Contact
  80. }
  81. var _ ent.Mutation = (*ContactMutation)(nil)
  82. // contactOption allows management of the mutation configuration using functional options.
  83. type contactOption func(*ContactMutation)
  84. // newContactMutation creates new mutation for the Contact entity.
  85. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  86. m := &ContactMutation{
  87. config: c,
  88. op: op,
  89. typ: TypeContact,
  90. clearedFields: make(map[string]struct{}),
  91. }
  92. for _, opt := range opts {
  93. opt(m)
  94. }
  95. return m
  96. }
  97. // withContactID sets the ID field of the mutation.
  98. func withContactID(id uint64) contactOption {
  99. return func(m *ContactMutation) {
  100. var (
  101. err error
  102. once sync.Once
  103. value *Contact
  104. )
  105. m.oldValue = func(ctx context.Context) (*Contact, error) {
  106. once.Do(func() {
  107. if m.done {
  108. err = errors.New("querying old values post mutation is not allowed")
  109. } else {
  110. value, err = m.Client().Contact.Get(ctx, id)
  111. }
  112. })
  113. return value, err
  114. }
  115. m.id = &id
  116. }
  117. }
  118. // withContact sets the old Contact of the mutation.
  119. func withContact(node *Contact) contactOption {
  120. return func(m *ContactMutation) {
  121. m.oldValue = func(context.Context) (*Contact, error) {
  122. return node, nil
  123. }
  124. m.id = &node.ID
  125. }
  126. }
  127. // Client returns a new `ent.Client` from the mutation. If the mutation was
  128. // executed in a transaction (ent.Tx), a transactional client is returned.
  129. func (m ContactMutation) Client() *Client {
  130. client := &Client{config: m.config}
  131. client.init()
  132. return client
  133. }
  134. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  135. // it returns an error otherwise.
  136. func (m ContactMutation) Tx() (*Tx, error) {
  137. if _, ok := m.driver.(*txDriver); !ok {
  138. return nil, errors.New("ent: mutation is not running in a transaction")
  139. }
  140. tx := &Tx{config: m.config}
  141. tx.init()
  142. return tx, nil
  143. }
  144. // SetID sets the value of the id field. Note that this
  145. // operation is only accepted on creation of Contact entities.
  146. func (m *ContactMutation) SetID(id uint64) {
  147. m.id = &id
  148. }
  149. // ID returns the ID value in the mutation. Note that the ID is only available
  150. // if it was provided to the builder or after it was returned from the database.
  151. func (m *ContactMutation) ID() (id uint64, exists bool) {
  152. if m.id == nil {
  153. return
  154. }
  155. return *m.id, true
  156. }
  157. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  158. // That means, if the mutation is applied within a transaction with an isolation level such
  159. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  160. // or updated by the mutation.
  161. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  162. switch {
  163. case m.op.Is(OpUpdateOne | OpDeleteOne):
  164. id, exists := m.ID()
  165. if exists {
  166. return []uint64{id}, nil
  167. }
  168. fallthrough
  169. case m.op.Is(OpUpdate | OpDelete):
  170. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  171. default:
  172. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  173. }
  174. }
  175. // SetCreatedAt sets the "created_at" field.
  176. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  177. m.created_at = &t
  178. }
  179. // CreatedAt returns the value of the "created_at" field in the mutation.
  180. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  181. v := m.created_at
  182. if v == nil {
  183. return
  184. }
  185. return *v, true
  186. }
  187. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  188. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  189. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  190. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  191. if !m.op.Is(OpUpdateOne) {
  192. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  193. }
  194. if m.id == nil || m.oldValue == nil {
  195. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  196. }
  197. oldValue, err := m.oldValue(ctx)
  198. if err != nil {
  199. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  200. }
  201. return oldValue.CreatedAt, nil
  202. }
  203. // ResetCreatedAt resets all changes to the "created_at" field.
  204. func (m *ContactMutation) ResetCreatedAt() {
  205. m.created_at = nil
  206. }
  207. // SetUpdatedAt sets the "updated_at" field.
  208. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  209. m.updated_at = &t
  210. }
  211. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  212. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  213. v := m.updated_at
  214. if v == nil {
  215. return
  216. }
  217. return *v, true
  218. }
  219. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  220. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  222. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  223. if !m.op.Is(OpUpdateOne) {
  224. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  225. }
  226. if m.id == nil || m.oldValue == nil {
  227. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  228. }
  229. oldValue, err := m.oldValue(ctx)
  230. if err != nil {
  231. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  232. }
  233. return oldValue.UpdatedAt, nil
  234. }
  235. // ResetUpdatedAt resets all changes to the "updated_at" field.
  236. func (m *ContactMutation) ResetUpdatedAt() {
  237. m.updated_at = nil
  238. }
  239. // SetStatus sets the "status" field.
  240. func (m *ContactMutation) SetStatus(u uint8) {
  241. m.status = &u
  242. m.addstatus = nil
  243. }
  244. // Status returns the value of the "status" field in the mutation.
  245. func (m *ContactMutation) Status() (r uint8, exists bool) {
  246. v := m.status
  247. if v == nil {
  248. return
  249. }
  250. return *v, true
  251. }
  252. // OldStatus returns the old "status" field's value of the Contact entity.
  253. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  255. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  256. if !m.op.Is(OpUpdateOne) {
  257. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  258. }
  259. if m.id == nil || m.oldValue == nil {
  260. return v, errors.New("OldStatus requires an ID field in the mutation")
  261. }
  262. oldValue, err := m.oldValue(ctx)
  263. if err != nil {
  264. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  265. }
  266. return oldValue.Status, nil
  267. }
  268. // AddStatus adds u to the "status" field.
  269. func (m *ContactMutation) AddStatus(u int8) {
  270. if m.addstatus != nil {
  271. *m.addstatus += u
  272. } else {
  273. m.addstatus = &u
  274. }
  275. }
  276. // AddedStatus returns the value that was added to the "status" field in this mutation.
  277. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  278. v := m.addstatus
  279. if v == nil {
  280. return
  281. }
  282. return *v, true
  283. }
  284. // ClearStatus clears the value of the "status" field.
  285. func (m *ContactMutation) ClearStatus() {
  286. m.status = nil
  287. m.addstatus = nil
  288. m.clearedFields[contact.FieldStatus] = struct{}{}
  289. }
  290. // StatusCleared returns if the "status" field was cleared in this mutation.
  291. func (m *ContactMutation) StatusCleared() bool {
  292. _, ok := m.clearedFields[contact.FieldStatus]
  293. return ok
  294. }
  295. // ResetStatus resets all changes to the "status" field.
  296. func (m *ContactMutation) ResetStatus() {
  297. m.status = nil
  298. m.addstatus = nil
  299. delete(m.clearedFields, contact.FieldStatus)
  300. }
  301. // SetDeletedAt sets the "deleted_at" field.
  302. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  303. m.deleted_at = &t
  304. }
  305. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  306. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  307. v := m.deleted_at
  308. if v == nil {
  309. return
  310. }
  311. return *v, true
  312. }
  313. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  314. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  316. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  317. if !m.op.Is(OpUpdateOne) {
  318. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  319. }
  320. if m.id == nil || m.oldValue == nil {
  321. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  322. }
  323. oldValue, err := m.oldValue(ctx)
  324. if err != nil {
  325. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  326. }
  327. return oldValue.DeletedAt, nil
  328. }
  329. // ClearDeletedAt clears the value of the "deleted_at" field.
  330. func (m *ContactMutation) ClearDeletedAt() {
  331. m.deleted_at = nil
  332. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  333. }
  334. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  335. func (m *ContactMutation) DeletedAtCleared() bool {
  336. _, ok := m.clearedFields[contact.FieldDeletedAt]
  337. return ok
  338. }
  339. // ResetDeletedAt resets all changes to the "deleted_at" field.
  340. func (m *ContactMutation) ResetDeletedAt() {
  341. m.deleted_at = nil
  342. delete(m.clearedFields, contact.FieldDeletedAt)
  343. }
  344. // SetWxWxid sets the "wx_wxid" field.
  345. func (m *ContactMutation) SetWxWxid(s string) {
  346. m.wx_wxid = &s
  347. }
  348. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  349. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  350. v := m.wx_wxid
  351. if v == nil {
  352. return
  353. }
  354. return *v, true
  355. }
  356. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  357. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  359. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  360. if !m.op.Is(OpUpdateOne) {
  361. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  362. }
  363. if m.id == nil || m.oldValue == nil {
  364. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  365. }
  366. oldValue, err := m.oldValue(ctx)
  367. if err != nil {
  368. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  369. }
  370. return oldValue.WxWxid, nil
  371. }
  372. // ClearWxWxid clears the value of the "wx_wxid" field.
  373. func (m *ContactMutation) ClearWxWxid() {
  374. m.wx_wxid = nil
  375. m.clearedFields[contact.FieldWxWxid] = struct{}{}
  376. }
  377. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  378. func (m *ContactMutation) WxWxidCleared() bool {
  379. _, ok := m.clearedFields[contact.FieldWxWxid]
  380. return ok
  381. }
  382. // ResetWxWxid resets all changes to the "wx_wxid" field.
  383. func (m *ContactMutation) ResetWxWxid() {
  384. m.wx_wxid = nil
  385. delete(m.clearedFields, contact.FieldWxWxid)
  386. }
  387. // SetType sets the "type" field.
  388. func (m *ContactMutation) SetType(i int) {
  389. m._type = &i
  390. m.add_type = nil
  391. }
  392. // GetType returns the value of the "type" field in the mutation.
  393. func (m *ContactMutation) GetType() (r int, exists bool) {
  394. v := m._type
  395. if v == nil {
  396. return
  397. }
  398. return *v, true
  399. }
  400. // OldType returns the old "type" field's value of the Contact entity.
  401. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  402. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  403. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  404. if !m.op.Is(OpUpdateOne) {
  405. return v, errors.New("OldType is only allowed on UpdateOne operations")
  406. }
  407. if m.id == nil || m.oldValue == nil {
  408. return v, errors.New("OldType requires an ID field in the mutation")
  409. }
  410. oldValue, err := m.oldValue(ctx)
  411. if err != nil {
  412. return v, fmt.Errorf("querying old value for OldType: %w", err)
  413. }
  414. return oldValue.Type, nil
  415. }
  416. // AddType adds i to the "type" field.
  417. func (m *ContactMutation) AddType(i int) {
  418. if m.add_type != nil {
  419. *m.add_type += i
  420. } else {
  421. m.add_type = &i
  422. }
  423. }
  424. // AddedType returns the value that was added to the "type" field in this mutation.
  425. func (m *ContactMutation) AddedType() (r int, exists bool) {
  426. v := m.add_type
  427. if v == nil {
  428. return
  429. }
  430. return *v, true
  431. }
  432. // ClearType clears the value of the "type" field.
  433. func (m *ContactMutation) ClearType() {
  434. m._type = nil
  435. m.add_type = nil
  436. m.clearedFields[contact.FieldType] = struct{}{}
  437. }
  438. // TypeCleared returns if the "type" field was cleared in this mutation.
  439. func (m *ContactMutation) TypeCleared() bool {
  440. _, ok := m.clearedFields[contact.FieldType]
  441. return ok
  442. }
  443. // ResetType resets all changes to the "type" field.
  444. func (m *ContactMutation) ResetType() {
  445. m._type = nil
  446. m.add_type = nil
  447. delete(m.clearedFields, contact.FieldType)
  448. }
  449. // SetWxid sets the "wxid" field.
  450. func (m *ContactMutation) SetWxid(s string) {
  451. m.wxid = &s
  452. }
  453. // Wxid returns the value of the "wxid" field in the mutation.
  454. func (m *ContactMutation) Wxid() (r string, exists bool) {
  455. v := m.wxid
  456. if v == nil {
  457. return
  458. }
  459. return *v, true
  460. }
  461. // OldWxid returns the old "wxid" field's value of the Contact entity.
  462. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  463. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  464. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  465. if !m.op.Is(OpUpdateOne) {
  466. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  467. }
  468. if m.id == nil || m.oldValue == nil {
  469. return v, errors.New("OldWxid requires an ID field in the mutation")
  470. }
  471. oldValue, err := m.oldValue(ctx)
  472. if err != nil {
  473. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  474. }
  475. return oldValue.Wxid, nil
  476. }
  477. // ResetWxid resets all changes to the "wxid" field.
  478. func (m *ContactMutation) ResetWxid() {
  479. m.wxid = nil
  480. }
  481. // SetAccount sets the "account" field.
  482. func (m *ContactMutation) SetAccount(s string) {
  483. m.account = &s
  484. }
  485. // Account returns the value of the "account" field in the mutation.
  486. func (m *ContactMutation) Account() (r string, exists bool) {
  487. v := m.account
  488. if v == nil {
  489. return
  490. }
  491. return *v, true
  492. }
  493. // OldAccount returns the old "account" field's value of the Contact entity.
  494. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  496. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  497. if !m.op.Is(OpUpdateOne) {
  498. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  499. }
  500. if m.id == nil || m.oldValue == nil {
  501. return v, errors.New("OldAccount requires an ID field in the mutation")
  502. }
  503. oldValue, err := m.oldValue(ctx)
  504. if err != nil {
  505. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  506. }
  507. return oldValue.Account, nil
  508. }
  509. // ResetAccount resets all changes to the "account" field.
  510. func (m *ContactMutation) ResetAccount() {
  511. m.account = nil
  512. }
  513. // SetNickname sets the "nickname" field.
  514. func (m *ContactMutation) SetNickname(s string) {
  515. m.nickname = &s
  516. }
  517. // Nickname returns the value of the "nickname" field in the mutation.
  518. func (m *ContactMutation) Nickname() (r string, exists bool) {
  519. v := m.nickname
  520. if v == nil {
  521. return
  522. }
  523. return *v, true
  524. }
  525. // OldNickname returns the old "nickname" field's value of the Contact entity.
  526. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  527. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  528. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  529. if !m.op.Is(OpUpdateOne) {
  530. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  531. }
  532. if m.id == nil || m.oldValue == nil {
  533. return v, errors.New("OldNickname requires an ID field in the mutation")
  534. }
  535. oldValue, err := m.oldValue(ctx)
  536. if err != nil {
  537. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  538. }
  539. return oldValue.Nickname, nil
  540. }
  541. // ResetNickname resets all changes to the "nickname" field.
  542. func (m *ContactMutation) ResetNickname() {
  543. m.nickname = nil
  544. }
  545. // SetMarkname sets the "markname" field.
  546. func (m *ContactMutation) SetMarkname(s string) {
  547. m.markname = &s
  548. }
  549. // Markname returns the value of the "markname" field in the mutation.
  550. func (m *ContactMutation) Markname() (r string, exists bool) {
  551. v := m.markname
  552. if v == nil {
  553. return
  554. }
  555. return *v, true
  556. }
  557. // OldMarkname returns the old "markname" field's value of the Contact entity.
  558. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  559. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  560. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  561. if !m.op.Is(OpUpdateOne) {
  562. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  563. }
  564. if m.id == nil || m.oldValue == nil {
  565. return v, errors.New("OldMarkname requires an ID field in the mutation")
  566. }
  567. oldValue, err := m.oldValue(ctx)
  568. if err != nil {
  569. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  570. }
  571. return oldValue.Markname, nil
  572. }
  573. // ResetMarkname resets all changes to the "markname" field.
  574. func (m *ContactMutation) ResetMarkname() {
  575. m.markname = nil
  576. }
  577. // SetHeadimg sets the "headimg" field.
  578. func (m *ContactMutation) SetHeadimg(s string) {
  579. m.headimg = &s
  580. }
  581. // Headimg returns the value of the "headimg" field in the mutation.
  582. func (m *ContactMutation) Headimg() (r string, exists bool) {
  583. v := m.headimg
  584. if v == nil {
  585. return
  586. }
  587. return *v, true
  588. }
  589. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  590. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  591. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  592. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  593. if !m.op.Is(OpUpdateOne) {
  594. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  595. }
  596. if m.id == nil || m.oldValue == nil {
  597. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  598. }
  599. oldValue, err := m.oldValue(ctx)
  600. if err != nil {
  601. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  602. }
  603. return oldValue.Headimg, nil
  604. }
  605. // ResetHeadimg resets all changes to the "headimg" field.
  606. func (m *ContactMutation) ResetHeadimg() {
  607. m.headimg = nil
  608. }
  609. // SetSex sets the "sex" field.
  610. func (m *ContactMutation) SetSex(i int) {
  611. m.sex = &i
  612. m.addsex = nil
  613. }
  614. // Sex returns the value of the "sex" field in the mutation.
  615. func (m *ContactMutation) Sex() (r int, exists bool) {
  616. v := m.sex
  617. if v == nil {
  618. return
  619. }
  620. return *v, true
  621. }
  622. // OldSex returns the old "sex" field's value of the Contact entity.
  623. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  624. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  625. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  626. if !m.op.Is(OpUpdateOne) {
  627. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  628. }
  629. if m.id == nil || m.oldValue == nil {
  630. return v, errors.New("OldSex requires an ID field in the mutation")
  631. }
  632. oldValue, err := m.oldValue(ctx)
  633. if err != nil {
  634. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  635. }
  636. return oldValue.Sex, nil
  637. }
  638. // AddSex adds i to the "sex" field.
  639. func (m *ContactMutation) AddSex(i int) {
  640. if m.addsex != nil {
  641. *m.addsex += i
  642. } else {
  643. m.addsex = &i
  644. }
  645. }
  646. // AddedSex returns the value that was added to the "sex" field in this mutation.
  647. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  648. v := m.addsex
  649. if v == nil {
  650. return
  651. }
  652. return *v, true
  653. }
  654. // ResetSex resets all changes to the "sex" field.
  655. func (m *ContactMutation) ResetSex() {
  656. m.sex = nil
  657. m.addsex = nil
  658. }
  659. // SetStarrole sets the "starrole" field.
  660. func (m *ContactMutation) SetStarrole(s string) {
  661. m.starrole = &s
  662. }
  663. // Starrole returns the value of the "starrole" field in the mutation.
  664. func (m *ContactMutation) Starrole() (r string, exists bool) {
  665. v := m.starrole
  666. if v == nil {
  667. return
  668. }
  669. return *v, true
  670. }
  671. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  672. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  673. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  674. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  675. if !m.op.Is(OpUpdateOne) {
  676. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  677. }
  678. if m.id == nil || m.oldValue == nil {
  679. return v, errors.New("OldStarrole requires an ID field in the mutation")
  680. }
  681. oldValue, err := m.oldValue(ctx)
  682. if err != nil {
  683. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  684. }
  685. return oldValue.Starrole, nil
  686. }
  687. // ResetStarrole resets all changes to the "starrole" field.
  688. func (m *ContactMutation) ResetStarrole() {
  689. m.starrole = nil
  690. }
  691. // SetDontseeit sets the "dontseeit" field.
  692. func (m *ContactMutation) SetDontseeit(i int) {
  693. m.dontseeit = &i
  694. m.adddontseeit = nil
  695. }
  696. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  697. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  698. v := m.dontseeit
  699. if v == nil {
  700. return
  701. }
  702. return *v, true
  703. }
  704. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  705. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  706. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  707. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  708. if !m.op.Is(OpUpdateOne) {
  709. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  710. }
  711. if m.id == nil || m.oldValue == nil {
  712. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  713. }
  714. oldValue, err := m.oldValue(ctx)
  715. if err != nil {
  716. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  717. }
  718. return oldValue.Dontseeit, nil
  719. }
  720. // AddDontseeit adds i to the "dontseeit" field.
  721. func (m *ContactMutation) AddDontseeit(i int) {
  722. if m.adddontseeit != nil {
  723. *m.adddontseeit += i
  724. } else {
  725. m.adddontseeit = &i
  726. }
  727. }
  728. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  729. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  730. v := m.adddontseeit
  731. if v == nil {
  732. return
  733. }
  734. return *v, true
  735. }
  736. // ResetDontseeit resets all changes to the "dontseeit" field.
  737. func (m *ContactMutation) ResetDontseeit() {
  738. m.dontseeit = nil
  739. m.adddontseeit = nil
  740. }
  741. // SetDontseeme sets the "dontseeme" field.
  742. func (m *ContactMutation) SetDontseeme(i int) {
  743. m.dontseeme = &i
  744. m.adddontseeme = nil
  745. }
  746. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  747. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  748. v := m.dontseeme
  749. if v == nil {
  750. return
  751. }
  752. return *v, true
  753. }
  754. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  755. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  756. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  757. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  758. if !m.op.Is(OpUpdateOne) {
  759. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  760. }
  761. if m.id == nil || m.oldValue == nil {
  762. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  763. }
  764. oldValue, err := m.oldValue(ctx)
  765. if err != nil {
  766. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  767. }
  768. return oldValue.Dontseeme, nil
  769. }
  770. // AddDontseeme adds i to the "dontseeme" field.
  771. func (m *ContactMutation) AddDontseeme(i int) {
  772. if m.adddontseeme != nil {
  773. *m.adddontseeme += i
  774. } else {
  775. m.adddontseeme = &i
  776. }
  777. }
  778. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  779. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  780. v := m.adddontseeme
  781. if v == nil {
  782. return
  783. }
  784. return *v, true
  785. }
  786. // ResetDontseeme resets all changes to the "dontseeme" field.
  787. func (m *ContactMutation) ResetDontseeme() {
  788. m.dontseeme = nil
  789. m.adddontseeme = nil
  790. }
  791. // SetLag sets the "lag" field.
  792. func (m *ContactMutation) SetLag(s string) {
  793. m.lag = &s
  794. }
  795. // Lag returns the value of the "lag" field in the mutation.
  796. func (m *ContactMutation) Lag() (r string, exists bool) {
  797. v := m.lag
  798. if v == nil {
  799. return
  800. }
  801. return *v, true
  802. }
  803. // OldLag returns the old "lag" field's value of the Contact entity.
  804. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  805. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  806. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  807. if !m.op.Is(OpUpdateOne) {
  808. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  809. }
  810. if m.id == nil || m.oldValue == nil {
  811. return v, errors.New("OldLag requires an ID field in the mutation")
  812. }
  813. oldValue, err := m.oldValue(ctx)
  814. if err != nil {
  815. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  816. }
  817. return oldValue.Lag, nil
  818. }
  819. // ResetLag resets all changes to the "lag" field.
  820. func (m *ContactMutation) ResetLag() {
  821. m.lag = nil
  822. }
  823. // SetGid sets the "gid" field.
  824. func (m *ContactMutation) SetGid(s string) {
  825. m.gid = &s
  826. }
  827. // Gid returns the value of the "gid" field in the mutation.
  828. func (m *ContactMutation) Gid() (r string, exists bool) {
  829. v := m.gid
  830. if v == nil {
  831. return
  832. }
  833. return *v, true
  834. }
  835. // OldGid returns the old "gid" field's value of the Contact entity.
  836. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  837. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  838. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  839. if !m.op.Is(OpUpdateOne) {
  840. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  841. }
  842. if m.id == nil || m.oldValue == nil {
  843. return v, errors.New("OldGid requires an ID field in the mutation")
  844. }
  845. oldValue, err := m.oldValue(ctx)
  846. if err != nil {
  847. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  848. }
  849. return oldValue.Gid, nil
  850. }
  851. // ResetGid resets all changes to the "gid" field.
  852. func (m *ContactMutation) ResetGid() {
  853. m.gid = nil
  854. }
  855. // SetGname sets the "gname" field.
  856. func (m *ContactMutation) SetGname(s string) {
  857. m.gname = &s
  858. }
  859. // Gname returns the value of the "gname" field in the mutation.
  860. func (m *ContactMutation) Gname() (r string, exists bool) {
  861. v := m.gname
  862. if v == nil {
  863. return
  864. }
  865. return *v, true
  866. }
  867. // OldGname returns the old "gname" field's value of the Contact entity.
  868. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  870. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  871. if !m.op.Is(OpUpdateOne) {
  872. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  873. }
  874. if m.id == nil || m.oldValue == nil {
  875. return v, errors.New("OldGname requires an ID field in the mutation")
  876. }
  877. oldValue, err := m.oldValue(ctx)
  878. if err != nil {
  879. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  880. }
  881. return oldValue.Gname, nil
  882. }
  883. // ResetGname resets all changes to the "gname" field.
  884. func (m *ContactMutation) ResetGname() {
  885. m.gname = nil
  886. }
  887. // SetV3 sets the "v3" field.
  888. func (m *ContactMutation) SetV3(s string) {
  889. m.v3 = &s
  890. }
  891. // V3 returns the value of the "v3" field in the mutation.
  892. func (m *ContactMutation) V3() (r string, exists bool) {
  893. v := m.v3
  894. if v == nil {
  895. return
  896. }
  897. return *v, true
  898. }
  899. // OldV3 returns the old "v3" field's value of the Contact entity.
  900. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  901. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  902. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  903. if !m.op.Is(OpUpdateOne) {
  904. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  905. }
  906. if m.id == nil || m.oldValue == nil {
  907. return v, errors.New("OldV3 requires an ID field in the mutation")
  908. }
  909. oldValue, err := m.oldValue(ctx)
  910. if err != nil {
  911. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  912. }
  913. return oldValue.V3, nil
  914. }
  915. // ResetV3 resets all changes to the "v3" field.
  916. func (m *ContactMutation) ResetV3() {
  917. m.v3 = nil
  918. }
  919. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  920. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  921. if m.contact_relationships == nil {
  922. m.contact_relationships = make(map[uint64]struct{})
  923. }
  924. for i := range ids {
  925. m.contact_relationships[ids[i]] = struct{}{}
  926. }
  927. }
  928. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  929. func (m *ContactMutation) ClearContactRelationships() {
  930. m.clearedcontact_relationships = true
  931. }
  932. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  933. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  934. return m.clearedcontact_relationships
  935. }
  936. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  937. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  938. if m.removedcontact_relationships == nil {
  939. m.removedcontact_relationships = make(map[uint64]struct{})
  940. }
  941. for i := range ids {
  942. delete(m.contact_relationships, ids[i])
  943. m.removedcontact_relationships[ids[i]] = struct{}{}
  944. }
  945. }
  946. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  947. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  948. for id := range m.removedcontact_relationships {
  949. ids = append(ids, id)
  950. }
  951. return
  952. }
  953. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  954. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  955. for id := range m.contact_relationships {
  956. ids = append(ids, id)
  957. }
  958. return
  959. }
  960. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  961. func (m *ContactMutation) ResetContactRelationships() {
  962. m.contact_relationships = nil
  963. m.clearedcontact_relationships = false
  964. m.removedcontact_relationships = nil
  965. }
  966. // Where appends a list predicates to the ContactMutation builder.
  967. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  968. m.predicates = append(m.predicates, ps...)
  969. }
  970. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  971. // users can use type-assertion to append predicates that do not depend on any generated package.
  972. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  973. p := make([]predicate.Contact, len(ps))
  974. for i := range ps {
  975. p[i] = ps[i]
  976. }
  977. m.Where(p...)
  978. }
  979. // Op returns the operation name.
  980. func (m *ContactMutation) Op() Op {
  981. return m.op
  982. }
  983. // SetOp allows setting the mutation operation.
  984. func (m *ContactMutation) SetOp(op Op) {
  985. m.op = op
  986. }
  987. // Type returns the node type of this mutation (Contact).
  988. func (m *ContactMutation) Type() string {
  989. return m.typ
  990. }
  991. // Fields returns all fields that were changed during this mutation. Note that in
  992. // order to get all numeric fields that were incremented/decremented, call
  993. // AddedFields().
  994. func (m *ContactMutation) Fields() []string {
  995. fields := make([]string, 0, 19)
  996. if m.created_at != nil {
  997. fields = append(fields, contact.FieldCreatedAt)
  998. }
  999. if m.updated_at != nil {
  1000. fields = append(fields, contact.FieldUpdatedAt)
  1001. }
  1002. if m.status != nil {
  1003. fields = append(fields, contact.FieldStatus)
  1004. }
  1005. if m.deleted_at != nil {
  1006. fields = append(fields, contact.FieldDeletedAt)
  1007. }
  1008. if m.wx_wxid != nil {
  1009. fields = append(fields, contact.FieldWxWxid)
  1010. }
  1011. if m._type != nil {
  1012. fields = append(fields, contact.FieldType)
  1013. }
  1014. if m.wxid != nil {
  1015. fields = append(fields, contact.FieldWxid)
  1016. }
  1017. if m.account != nil {
  1018. fields = append(fields, contact.FieldAccount)
  1019. }
  1020. if m.nickname != nil {
  1021. fields = append(fields, contact.FieldNickname)
  1022. }
  1023. if m.markname != nil {
  1024. fields = append(fields, contact.FieldMarkname)
  1025. }
  1026. if m.headimg != nil {
  1027. fields = append(fields, contact.FieldHeadimg)
  1028. }
  1029. if m.sex != nil {
  1030. fields = append(fields, contact.FieldSex)
  1031. }
  1032. if m.starrole != nil {
  1033. fields = append(fields, contact.FieldStarrole)
  1034. }
  1035. if m.dontseeit != nil {
  1036. fields = append(fields, contact.FieldDontseeit)
  1037. }
  1038. if m.dontseeme != nil {
  1039. fields = append(fields, contact.FieldDontseeme)
  1040. }
  1041. if m.lag != nil {
  1042. fields = append(fields, contact.FieldLag)
  1043. }
  1044. if m.gid != nil {
  1045. fields = append(fields, contact.FieldGid)
  1046. }
  1047. if m.gname != nil {
  1048. fields = append(fields, contact.FieldGname)
  1049. }
  1050. if m.v3 != nil {
  1051. fields = append(fields, contact.FieldV3)
  1052. }
  1053. return fields
  1054. }
  1055. // Field returns the value of a field with the given name. The second boolean
  1056. // return value indicates that this field was not set, or was not defined in the
  1057. // schema.
  1058. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  1059. switch name {
  1060. case contact.FieldCreatedAt:
  1061. return m.CreatedAt()
  1062. case contact.FieldUpdatedAt:
  1063. return m.UpdatedAt()
  1064. case contact.FieldStatus:
  1065. return m.Status()
  1066. case contact.FieldDeletedAt:
  1067. return m.DeletedAt()
  1068. case contact.FieldWxWxid:
  1069. return m.WxWxid()
  1070. case contact.FieldType:
  1071. return m.GetType()
  1072. case contact.FieldWxid:
  1073. return m.Wxid()
  1074. case contact.FieldAccount:
  1075. return m.Account()
  1076. case contact.FieldNickname:
  1077. return m.Nickname()
  1078. case contact.FieldMarkname:
  1079. return m.Markname()
  1080. case contact.FieldHeadimg:
  1081. return m.Headimg()
  1082. case contact.FieldSex:
  1083. return m.Sex()
  1084. case contact.FieldStarrole:
  1085. return m.Starrole()
  1086. case contact.FieldDontseeit:
  1087. return m.Dontseeit()
  1088. case contact.FieldDontseeme:
  1089. return m.Dontseeme()
  1090. case contact.FieldLag:
  1091. return m.Lag()
  1092. case contact.FieldGid:
  1093. return m.Gid()
  1094. case contact.FieldGname:
  1095. return m.Gname()
  1096. case contact.FieldV3:
  1097. return m.V3()
  1098. }
  1099. return nil, false
  1100. }
  1101. // OldField returns the old value of the field from the database. An error is
  1102. // returned if the mutation operation is not UpdateOne, or the query to the
  1103. // database failed.
  1104. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1105. switch name {
  1106. case contact.FieldCreatedAt:
  1107. return m.OldCreatedAt(ctx)
  1108. case contact.FieldUpdatedAt:
  1109. return m.OldUpdatedAt(ctx)
  1110. case contact.FieldStatus:
  1111. return m.OldStatus(ctx)
  1112. case contact.FieldDeletedAt:
  1113. return m.OldDeletedAt(ctx)
  1114. case contact.FieldWxWxid:
  1115. return m.OldWxWxid(ctx)
  1116. case contact.FieldType:
  1117. return m.OldType(ctx)
  1118. case contact.FieldWxid:
  1119. return m.OldWxid(ctx)
  1120. case contact.FieldAccount:
  1121. return m.OldAccount(ctx)
  1122. case contact.FieldNickname:
  1123. return m.OldNickname(ctx)
  1124. case contact.FieldMarkname:
  1125. return m.OldMarkname(ctx)
  1126. case contact.FieldHeadimg:
  1127. return m.OldHeadimg(ctx)
  1128. case contact.FieldSex:
  1129. return m.OldSex(ctx)
  1130. case contact.FieldStarrole:
  1131. return m.OldStarrole(ctx)
  1132. case contact.FieldDontseeit:
  1133. return m.OldDontseeit(ctx)
  1134. case contact.FieldDontseeme:
  1135. return m.OldDontseeme(ctx)
  1136. case contact.FieldLag:
  1137. return m.OldLag(ctx)
  1138. case contact.FieldGid:
  1139. return m.OldGid(ctx)
  1140. case contact.FieldGname:
  1141. return m.OldGname(ctx)
  1142. case contact.FieldV3:
  1143. return m.OldV3(ctx)
  1144. }
  1145. return nil, fmt.Errorf("unknown Contact field %s", name)
  1146. }
  1147. // SetField sets the value of a field with the given name. It returns an error if
  1148. // the field is not defined in the schema, or if the type mismatched the field
  1149. // type.
  1150. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  1151. switch name {
  1152. case contact.FieldCreatedAt:
  1153. v, ok := value.(time.Time)
  1154. if !ok {
  1155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1156. }
  1157. m.SetCreatedAt(v)
  1158. return nil
  1159. case contact.FieldUpdatedAt:
  1160. v, ok := value.(time.Time)
  1161. if !ok {
  1162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1163. }
  1164. m.SetUpdatedAt(v)
  1165. return nil
  1166. case contact.FieldStatus:
  1167. v, ok := value.(uint8)
  1168. if !ok {
  1169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1170. }
  1171. m.SetStatus(v)
  1172. return nil
  1173. case contact.FieldDeletedAt:
  1174. v, ok := value.(time.Time)
  1175. if !ok {
  1176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1177. }
  1178. m.SetDeletedAt(v)
  1179. return nil
  1180. case contact.FieldWxWxid:
  1181. v, ok := value.(string)
  1182. if !ok {
  1183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1184. }
  1185. m.SetWxWxid(v)
  1186. return nil
  1187. case contact.FieldType:
  1188. v, ok := value.(int)
  1189. if !ok {
  1190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1191. }
  1192. m.SetType(v)
  1193. return nil
  1194. case contact.FieldWxid:
  1195. v, ok := value.(string)
  1196. if !ok {
  1197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1198. }
  1199. m.SetWxid(v)
  1200. return nil
  1201. case contact.FieldAccount:
  1202. v, ok := value.(string)
  1203. if !ok {
  1204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1205. }
  1206. m.SetAccount(v)
  1207. return nil
  1208. case contact.FieldNickname:
  1209. v, ok := value.(string)
  1210. if !ok {
  1211. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1212. }
  1213. m.SetNickname(v)
  1214. return nil
  1215. case contact.FieldMarkname:
  1216. v, ok := value.(string)
  1217. if !ok {
  1218. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1219. }
  1220. m.SetMarkname(v)
  1221. return nil
  1222. case contact.FieldHeadimg:
  1223. v, ok := value.(string)
  1224. if !ok {
  1225. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1226. }
  1227. m.SetHeadimg(v)
  1228. return nil
  1229. case contact.FieldSex:
  1230. v, ok := value.(int)
  1231. if !ok {
  1232. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1233. }
  1234. m.SetSex(v)
  1235. return nil
  1236. case contact.FieldStarrole:
  1237. v, ok := value.(string)
  1238. if !ok {
  1239. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1240. }
  1241. m.SetStarrole(v)
  1242. return nil
  1243. case contact.FieldDontseeit:
  1244. v, ok := value.(int)
  1245. if !ok {
  1246. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1247. }
  1248. m.SetDontseeit(v)
  1249. return nil
  1250. case contact.FieldDontseeme:
  1251. v, ok := value.(int)
  1252. if !ok {
  1253. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1254. }
  1255. m.SetDontseeme(v)
  1256. return nil
  1257. case contact.FieldLag:
  1258. v, ok := value.(string)
  1259. if !ok {
  1260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1261. }
  1262. m.SetLag(v)
  1263. return nil
  1264. case contact.FieldGid:
  1265. v, ok := value.(string)
  1266. if !ok {
  1267. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1268. }
  1269. m.SetGid(v)
  1270. return nil
  1271. case contact.FieldGname:
  1272. v, ok := value.(string)
  1273. if !ok {
  1274. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1275. }
  1276. m.SetGname(v)
  1277. return nil
  1278. case contact.FieldV3:
  1279. v, ok := value.(string)
  1280. if !ok {
  1281. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1282. }
  1283. m.SetV3(v)
  1284. return nil
  1285. }
  1286. return fmt.Errorf("unknown Contact field %s", name)
  1287. }
  1288. // AddedFields returns all numeric fields that were incremented/decremented during
  1289. // this mutation.
  1290. func (m *ContactMutation) AddedFields() []string {
  1291. var fields []string
  1292. if m.addstatus != nil {
  1293. fields = append(fields, contact.FieldStatus)
  1294. }
  1295. if m.add_type != nil {
  1296. fields = append(fields, contact.FieldType)
  1297. }
  1298. if m.addsex != nil {
  1299. fields = append(fields, contact.FieldSex)
  1300. }
  1301. if m.adddontseeit != nil {
  1302. fields = append(fields, contact.FieldDontseeit)
  1303. }
  1304. if m.adddontseeme != nil {
  1305. fields = append(fields, contact.FieldDontseeme)
  1306. }
  1307. return fields
  1308. }
  1309. // AddedField returns the numeric value that was incremented/decremented on a field
  1310. // with the given name. The second boolean return value indicates that this field
  1311. // was not set, or was not defined in the schema.
  1312. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  1313. switch name {
  1314. case contact.FieldStatus:
  1315. return m.AddedStatus()
  1316. case contact.FieldType:
  1317. return m.AddedType()
  1318. case contact.FieldSex:
  1319. return m.AddedSex()
  1320. case contact.FieldDontseeit:
  1321. return m.AddedDontseeit()
  1322. case contact.FieldDontseeme:
  1323. return m.AddedDontseeme()
  1324. }
  1325. return nil, false
  1326. }
  1327. // AddField adds the value to the field with the given name. It returns an error if
  1328. // the field is not defined in the schema, or if the type mismatched the field
  1329. // type.
  1330. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  1331. switch name {
  1332. case contact.FieldStatus:
  1333. v, ok := value.(int8)
  1334. if !ok {
  1335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1336. }
  1337. m.AddStatus(v)
  1338. return nil
  1339. case contact.FieldType:
  1340. v, ok := value.(int)
  1341. if !ok {
  1342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1343. }
  1344. m.AddType(v)
  1345. return nil
  1346. case contact.FieldSex:
  1347. v, ok := value.(int)
  1348. if !ok {
  1349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1350. }
  1351. m.AddSex(v)
  1352. return nil
  1353. case contact.FieldDontseeit:
  1354. v, ok := value.(int)
  1355. if !ok {
  1356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1357. }
  1358. m.AddDontseeit(v)
  1359. return nil
  1360. case contact.FieldDontseeme:
  1361. v, ok := value.(int)
  1362. if !ok {
  1363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1364. }
  1365. m.AddDontseeme(v)
  1366. return nil
  1367. }
  1368. return fmt.Errorf("unknown Contact numeric field %s", name)
  1369. }
  1370. // ClearedFields returns all nullable fields that were cleared during this
  1371. // mutation.
  1372. func (m *ContactMutation) ClearedFields() []string {
  1373. var fields []string
  1374. if m.FieldCleared(contact.FieldStatus) {
  1375. fields = append(fields, contact.FieldStatus)
  1376. }
  1377. if m.FieldCleared(contact.FieldDeletedAt) {
  1378. fields = append(fields, contact.FieldDeletedAt)
  1379. }
  1380. if m.FieldCleared(contact.FieldWxWxid) {
  1381. fields = append(fields, contact.FieldWxWxid)
  1382. }
  1383. if m.FieldCleared(contact.FieldType) {
  1384. fields = append(fields, contact.FieldType)
  1385. }
  1386. return fields
  1387. }
  1388. // FieldCleared returns a boolean indicating if a field with the given name was
  1389. // cleared in this mutation.
  1390. func (m *ContactMutation) FieldCleared(name string) bool {
  1391. _, ok := m.clearedFields[name]
  1392. return ok
  1393. }
  1394. // ClearField clears the value of the field with the given name. It returns an
  1395. // error if the field is not defined in the schema.
  1396. func (m *ContactMutation) ClearField(name string) error {
  1397. switch name {
  1398. case contact.FieldStatus:
  1399. m.ClearStatus()
  1400. return nil
  1401. case contact.FieldDeletedAt:
  1402. m.ClearDeletedAt()
  1403. return nil
  1404. case contact.FieldWxWxid:
  1405. m.ClearWxWxid()
  1406. return nil
  1407. case contact.FieldType:
  1408. m.ClearType()
  1409. return nil
  1410. }
  1411. return fmt.Errorf("unknown Contact nullable field %s", name)
  1412. }
  1413. // ResetField resets all changes in the mutation for the field with the given name.
  1414. // It returns an error if the field is not defined in the schema.
  1415. func (m *ContactMutation) ResetField(name string) error {
  1416. switch name {
  1417. case contact.FieldCreatedAt:
  1418. m.ResetCreatedAt()
  1419. return nil
  1420. case contact.FieldUpdatedAt:
  1421. m.ResetUpdatedAt()
  1422. return nil
  1423. case contact.FieldStatus:
  1424. m.ResetStatus()
  1425. return nil
  1426. case contact.FieldDeletedAt:
  1427. m.ResetDeletedAt()
  1428. return nil
  1429. case contact.FieldWxWxid:
  1430. m.ResetWxWxid()
  1431. return nil
  1432. case contact.FieldType:
  1433. m.ResetType()
  1434. return nil
  1435. case contact.FieldWxid:
  1436. m.ResetWxid()
  1437. return nil
  1438. case contact.FieldAccount:
  1439. m.ResetAccount()
  1440. return nil
  1441. case contact.FieldNickname:
  1442. m.ResetNickname()
  1443. return nil
  1444. case contact.FieldMarkname:
  1445. m.ResetMarkname()
  1446. return nil
  1447. case contact.FieldHeadimg:
  1448. m.ResetHeadimg()
  1449. return nil
  1450. case contact.FieldSex:
  1451. m.ResetSex()
  1452. return nil
  1453. case contact.FieldStarrole:
  1454. m.ResetStarrole()
  1455. return nil
  1456. case contact.FieldDontseeit:
  1457. m.ResetDontseeit()
  1458. return nil
  1459. case contact.FieldDontseeme:
  1460. m.ResetDontseeme()
  1461. return nil
  1462. case contact.FieldLag:
  1463. m.ResetLag()
  1464. return nil
  1465. case contact.FieldGid:
  1466. m.ResetGid()
  1467. return nil
  1468. case contact.FieldGname:
  1469. m.ResetGname()
  1470. return nil
  1471. case contact.FieldV3:
  1472. m.ResetV3()
  1473. return nil
  1474. }
  1475. return fmt.Errorf("unknown Contact field %s", name)
  1476. }
  1477. // AddedEdges returns all edge names that were set/added in this mutation.
  1478. func (m *ContactMutation) AddedEdges() []string {
  1479. edges := make([]string, 0, 1)
  1480. if m.contact_relationships != nil {
  1481. edges = append(edges, contact.EdgeContactRelationships)
  1482. }
  1483. return edges
  1484. }
  1485. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1486. // name in this mutation.
  1487. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  1488. switch name {
  1489. case contact.EdgeContactRelationships:
  1490. ids := make([]ent.Value, 0, len(m.contact_relationships))
  1491. for id := range m.contact_relationships {
  1492. ids = append(ids, id)
  1493. }
  1494. return ids
  1495. }
  1496. return nil
  1497. }
  1498. // RemovedEdges returns all edge names that were removed in this mutation.
  1499. func (m *ContactMutation) RemovedEdges() []string {
  1500. edges := make([]string, 0, 1)
  1501. if m.removedcontact_relationships != nil {
  1502. edges = append(edges, contact.EdgeContactRelationships)
  1503. }
  1504. return edges
  1505. }
  1506. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1507. // the given name in this mutation.
  1508. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  1509. switch name {
  1510. case contact.EdgeContactRelationships:
  1511. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  1512. for id := range m.removedcontact_relationships {
  1513. ids = append(ids, id)
  1514. }
  1515. return ids
  1516. }
  1517. return nil
  1518. }
  1519. // ClearedEdges returns all edge names that were cleared in this mutation.
  1520. func (m *ContactMutation) ClearedEdges() []string {
  1521. edges := make([]string, 0, 1)
  1522. if m.clearedcontact_relationships {
  1523. edges = append(edges, contact.EdgeContactRelationships)
  1524. }
  1525. return edges
  1526. }
  1527. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1528. // was cleared in this mutation.
  1529. func (m *ContactMutation) EdgeCleared(name string) bool {
  1530. switch name {
  1531. case contact.EdgeContactRelationships:
  1532. return m.clearedcontact_relationships
  1533. }
  1534. return false
  1535. }
  1536. // ClearEdge clears the value of the edge with the given name. It returns an error
  1537. // if that edge is not defined in the schema.
  1538. func (m *ContactMutation) ClearEdge(name string) error {
  1539. switch name {
  1540. }
  1541. return fmt.Errorf("unknown Contact unique edge %s", name)
  1542. }
  1543. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1544. // It returns an error if the edge is not defined in the schema.
  1545. func (m *ContactMutation) ResetEdge(name string) error {
  1546. switch name {
  1547. case contact.EdgeContactRelationships:
  1548. m.ResetContactRelationships()
  1549. return nil
  1550. }
  1551. return fmt.Errorf("unknown Contact edge %s", name)
  1552. }
  1553. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  1554. type LabelMutation struct {
  1555. config
  1556. op Op
  1557. typ string
  1558. id *uint64
  1559. created_at *time.Time
  1560. updated_at *time.Time
  1561. status *uint8
  1562. addstatus *int8
  1563. deleted_at *time.Time
  1564. _type *int
  1565. add_type *int
  1566. name *string
  1567. from *int
  1568. addfrom *int
  1569. mode *int
  1570. addmode *int
  1571. conditions *string
  1572. clearedFields map[string]struct{}
  1573. label_relationships map[uint64]struct{}
  1574. removedlabel_relationships map[uint64]struct{}
  1575. clearedlabel_relationships bool
  1576. done bool
  1577. oldValue func(context.Context) (*Label, error)
  1578. predicates []predicate.Label
  1579. }
  1580. var _ ent.Mutation = (*LabelMutation)(nil)
  1581. // labelOption allows management of the mutation configuration using functional options.
  1582. type labelOption func(*LabelMutation)
  1583. // newLabelMutation creates new mutation for the Label entity.
  1584. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  1585. m := &LabelMutation{
  1586. config: c,
  1587. op: op,
  1588. typ: TypeLabel,
  1589. clearedFields: make(map[string]struct{}),
  1590. }
  1591. for _, opt := range opts {
  1592. opt(m)
  1593. }
  1594. return m
  1595. }
  1596. // withLabelID sets the ID field of the mutation.
  1597. func withLabelID(id uint64) labelOption {
  1598. return func(m *LabelMutation) {
  1599. var (
  1600. err error
  1601. once sync.Once
  1602. value *Label
  1603. )
  1604. m.oldValue = func(ctx context.Context) (*Label, error) {
  1605. once.Do(func() {
  1606. if m.done {
  1607. err = errors.New("querying old values post mutation is not allowed")
  1608. } else {
  1609. value, err = m.Client().Label.Get(ctx, id)
  1610. }
  1611. })
  1612. return value, err
  1613. }
  1614. m.id = &id
  1615. }
  1616. }
  1617. // withLabel sets the old Label of the mutation.
  1618. func withLabel(node *Label) labelOption {
  1619. return func(m *LabelMutation) {
  1620. m.oldValue = func(context.Context) (*Label, error) {
  1621. return node, nil
  1622. }
  1623. m.id = &node.ID
  1624. }
  1625. }
  1626. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1627. // executed in a transaction (ent.Tx), a transactional client is returned.
  1628. func (m LabelMutation) Client() *Client {
  1629. client := &Client{config: m.config}
  1630. client.init()
  1631. return client
  1632. }
  1633. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1634. // it returns an error otherwise.
  1635. func (m LabelMutation) Tx() (*Tx, error) {
  1636. if _, ok := m.driver.(*txDriver); !ok {
  1637. return nil, errors.New("ent: mutation is not running in a transaction")
  1638. }
  1639. tx := &Tx{config: m.config}
  1640. tx.init()
  1641. return tx, nil
  1642. }
  1643. // SetID sets the value of the id field. Note that this
  1644. // operation is only accepted on creation of Label entities.
  1645. func (m *LabelMutation) SetID(id uint64) {
  1646. m.id = &id
  1647. }
  1648. // ID returns the ID value in the mutation. Note that the ID is only available
  1649. // if it was provided to the builder or after it was returned from the database.
  1650. func (m *LabelMutation) ID() (id uint64, exists bool) {
  1651. if m.id == nil {
  1652. return
  1653. }
  1654. return *m.id, true
  1655. }
  1656. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1657. // That means, if the mutation is applied within a transaction with an isolation level such
  1658. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1659. // or updated by the mutation.
  1660. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  1661. switch {
  1662. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1663. id, exists := m.ID()
  1664. if exists {
  1665. return []uint64{id}, nil
  1666. }
  1667. fallthrough
  1668. case m.op.Is(OpUpdate | OpDelete):
  1669. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  1670. default:
  1671. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1672. }
  1673. }
  1674. // SetCreatedAt sets the "created_at" field.
  1675. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  1676. m.created_at = &t
  1677. }
  1678. // CreatedAt returns the value of the "created_at" field in the mutation.
  1679. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  1680. v := m.created_at
  1681. if v == nil {
  1682. return
  1683. }
  1684. return *v, true
  1685. }
  1686. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  1687. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  1688. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1689. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  1690. if !m.op.Is(OpUpdateOne) {
  1691. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  1692. }
  1693. if m.id == nil || m.oldValue == nil {
  1694. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  1695. }
  1696. oldValue, err := m.oldValue(ctx)
  1697. if err != nil {
  1698. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  1699. }
  1700. return oldValue.CreatedAt, nil
  1701. }
  1702. // ResetCreatedAt resets all changes to the "created_at" field.
  1703. func (m *LabelMutation) ResetCreatedAt() {
  1704. m.created_at = nil
  1705. }
  1706. // SetUpdatedAt sets the "updated_at" field.
  1707. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  1708. m.updated_at = &t
  1709. }
  1710. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  1711. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  1712. v := m.updated_at
  1713. if v == nil {
  1714. return
  1715. }
  1716. return *v, true
  1717. }
  1718. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  1719. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  1720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1721. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  1722. if !m.op.Is(OpUpdateOne) {
  1723. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  1724. }
  1725. if m.id == nil || m.oldValue == nil {
  1726. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  1727. }
  1728. oldValue, err := m.oldValue(ctx)
  1729. if err != nil {
  1730. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  1731. }
  1732. return oldValue.UpdatedAt, nil
  1733. }
  1734. // ResetUpdatedAt resets all changes to the "updated_at" field.
  1735. func (m *LabelMutation) ResetUpdatedAt() {
  1736. m.updated_at = nil
  1737. }
  1738. // SetStatus sets the "status" field.
  1739. func (m *LabelMutation) SetStatus(u uint8) {
  1740. m.status = &u
  1741. m.addstatus = nil
  1742. }
  1743. // Status returns the value of the "status" field in the mutation.
  1744. func (m *LabelMutation) Status() (r uint8, exists bool) {
  1745. v := m.status
  1746. if v == nil {
  1747. return
  1748. }
  1749. return *v, true
  1750. }
  1751. // OldStatus returns the old "status" field's value of the Label entity.
  1752. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  1753. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1754. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  1755. if !m.op.Is(OpUpdateOne) {
  1756. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  1757. }
  1758. if m.id == nil || m.oldValue == nil {
  1759. return v, errors.New("OldStatus requires an ID field in the mutation")
  1760. }
  1761. oldValue, err := m.oldValue(ctx)
  1762. if err != nil {
  1763. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  1764. }
  1765. return oldValue.Status, nil
  1766. }
  1767. // AddStatus adds u to the "status" field.
  1768. func (m *LabelMutation) AddStatus(u int8) {
  1769. if m.addstatus != nil {
  1770. *m.addstatus += u
  1771. } else {
  1772. m.addstatus = &u
  1773. }
  1774. }
  1775. // AddedStatus returns the value that was added to the "status" field in this mutation.
  1776. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  1777. v := m.addstatus
  1778. if v == nil {
  1779. return
  1780. }
  1781. return *v, true
  1782. }
  1783. // ClearStatus clears the value of the "status" field.
  1784. func (m *LabelMutation) ClearStatus() {
  1785. m.status = nil
  1786. m.addstatus = nil
  1787. m.clearedFields[label.FieldStatus] = struct{}{}
  1788. }
  1789. // StatusCleared returns if the "status" field was cleared in this mutation.
  1790. func (m *LabelMutation) StatusCleared() bool {
  1791. _, ok := m.clearedFields[label.FieldStatus]
  1792. return ok
  1793. }
  1794. // ResetStatus resets all changes to the "status" field.
  1795. func (m *LabelMutation) ResetStatus() {
  1796. m.status = nil
  1797. m.addstatus = nil
  1798. delete(m.clearedFields, label.FieldStatus)
  1799. }
  1800. // SetDeletedAt sets the "deleted_at" field.
  1801. func (m *LabelMutation) SetDeletedAt(t time.Time) {
  1802. m.deleted_at = &t
  1803. }
  1804. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  1805. func (m *LabelMutation) DeletedAt() (r time.Time, exists bool) {
  1806. v := m.deleted_at
  1807. if v == nil {
  1808. return
  1809. }
  1810. return *v, true
  1811. }
  1812. // OldDeletedAt returns the old "deleted_at" field's value of the Label entity.
  1813. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  1814. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1815. func (m *LabelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  1816. if !m.op.Is(OpUpdateOne) {
  1817. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  1818. }
  1819. if m.id == nil || m.oldValue == nil {
  1820. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  1821. }
  1822. oldValue, err := m.oldValue(ctx)
  1823. if err != nil {
  1824. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  1825. }
  1826. return oldValue.DeletedAt, nil
  1827. }
  1828. // ClearDeletedAt clears the value of the "deleted_at" field.
  1829. func (m *LabelMutation) ClearDeletedAt() {
  1830. m.deleted_at = nil
  1831. m.clearedFields[label.FieldDeletedAt] = struct{}{}
  1832. }
  1833. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  1834. func (m *LabelMutation) DeletedAtCleared() bool {
  1835. _, ok := m.clearedFields[label.FieldDeletedAt]
  1836. return ok
  1837. }
  1838. // ResetDeletedAt resets all changes to the "deleted_at" field.
  1839. func (m *LabelMutation) ResetDeletedAt() {
  1840. m.deleted_at = nil
  1841. delete(m.clearedFields, label.FieldDeletedAt)
  1842. }
  1843. // SetType sets the "type" field.
  1844. func (m *LabelMutation) SetType(i int) {
  1845. m._type = &i
  1846. m.add_type = nil
  1847. }
  1848. // GetType returns the value of the "type" field in the mutation.
  1849. func (m *LabelMutation) GetType() (r int, exists bool) {
  1850. v := m._type
  1851. if v == nil {
  1852. return
  1853. }
  1854. return *v, true
  1855. }
  1856. // OldType returns the old "type" field's value of the Label entity.
  1857. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  1858. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1859. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  1860. if !m.op.Is(OpUpdateOne) {
  1861. return v, errors.New("OldType is only allowed on UpdateOne operations")
  1862. }
  1863. if m.id == nil || m.oldValue == nil {
  1864. return v, errors.New("OldType requires an ID field in the mutation")
  1865. }
  1866. oldValue, err := m.oldValue(ctx)
  1867. if err != nil {
  1868. return v, fmt.Errorf("querying old value for OldType: %w", err)
  1869. }
  1870. return oldValue.Type, nil
  1871. }
  1872. // AddType adds i to the "type" field.
  1873. func (m *LabelMutation) AddType(i int) {
  1874. if m.add_type != nil {
  1875. *m.add_type += i
  1876. } else {
  1877. m.add_type = &i
  1878. }
  1879. }
  1880. // AddedType returns the value that was added to the "type" field in this mutation.
  1881. func (m *LabelMutation) AddedType() (r int, exists bool) {
  1882. v := m.add_type
  1883. if v == nil {
  1884. return
  1885. }
  1886. return *v, true
  1887. }
  1888. // ResetType resets all changes to the "type" field.
  1889. func (m *LabelMutation) ResetType() {
  1890. m._type = nil
  1891. m.add_type = nil
  1892. }
  1893. // SetName sets the "name" field.
  1894. func (m *LabelMutation) SetName(s string) {
  1895. m.name = &s
  1896. }
  1897. // Name returns the value of the "name" field in the mutation.
  1898. func (m *LabelMutation) Name() (r string, exists bool) {
  1899. v := m.name
  1900. if v == nil {
  1901. return
  1902. }
  1903. return *v, true
  1904. }
  1905. // OldName returns the old "name" field's value of the Label entity.
  1906. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  1907. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1908. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  1909. if !m.op.Is(OpUpdateOne) {
  1910. return v, errors.New("OldName is only allowed on UpdateOne operations")
  1911. }
  1912. if m.id == nil || m.oldValue == nil {
  1913. return v, errors.New("OldName requires an ID field in the mutation")
  1914. }
  1915. oldValue, err := m.oldValue(ctx)
  1916. if err != nil {
  1917. return v, fmt.Errorf("querying old value for OldName: %w", err)
  1918. }
  1919. return oldValue.Name, nil
  1920. }
  1921. // ResetName resets all changes to the "name" field.
  1922. func (m *LabelMutation) ResetName() {
  1923. m.name = nil
  1924. }
  1925. // SetFrom sets the "from" field.
  1926. func (m *LabelMutation) SetFrom(i int) {
  1927. m.from = &i
  1928. m.addfrom = nil
  1929. }
  1930. // From returns the value of the "from" field in the mutation.
  1931. func (m *LabelMutation) From() (r int, exists bool) {
  1932. v := m.from
  1933. if v == nil {
  1934. return
  1935. }
  1936. return *v, true
  1937. }
  1938. // OldFrom returns the old "from" field's value of the Label entity.
  1939. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  1940. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1941. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  1942. if !m.op.Is(OpUpdateOne) {
  1943. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  1944. }
  1945. if m.id == nil || m.oldValue == nil {
  1946. return v, errors.New("OldFrom requires an ID field in the mutation")
  1947. }
  1948. oldValue, err := m.oldValue(ctx)
  1949. if err != nil {
  1950. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  1951. }
  1952. return oldValue.From, nil
  1953. }
  1954. // AddFrom adds i to the "from" field.
  1955. func (m *LabelMutation) AddFrom(i int) {
  1956. if m.addfrom != nil {
  1957. *m.addfrom += i
  1958. } else {
  1959. m.addfrom = &i
  1960. }
  1961. }
  1962. // AddedFrom returns the value that was added to the "from" field in this mutation.
  1963. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  1964. v := m.addfrom
  1965. if v == nil {
  1966. return
  1967. }
  1968. return *v, true
  1969. }
  1970. // ResetFrom resets all changes to the "from" field.
  1971. func (m *LabelMutation) ResetFrom() {
  1972. m.from = nil
  1973. m.addfrom = nil
  1974. }
  1975. // SetMode sets the "mode" field.
  1976. func (m *LabelMutation) SetMode(i int) {
  1977. m.mode = &i
  1978. m.addmode = nil
  1979. }
  1980. // Mode returns the value of the "mode" field in the mutation.
  1981. func (m *LabelMutation) Mode() (r int, exists bool) {
  1982. v := m.mode
  1983. if v == nil {
  1984. return
  1985. }
  1986. return *v, true
  1987. }
  1988. // OldMode returns the old "mode" field's value of the Label entity.
  1989. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  1990. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1991. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  1992. if !m.op.Is(OpUpdateOne) {
  1993. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  1994. }
  1995. if m.id == nil || m.oldValue == nil {
  1996. return v, errors.New("OldMode requires an ID field in the mutation")
  1997. }
  1998. oldValue, err := m.oldValue(ctx)
  1999. if err != nil {
  2000. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  2001. }
  2002. return oldValue.Mode, nil
  2003. }
  2004. // AddMode adds i to the "mode" field.
  2005. func (m *LabelMutation) AddMode(i int) {
  2006. if m.addmode != nil {
  2007. *m.addmode += i
  2008. } else {
  2009. m.addmode = &i
  2010. }
  2011. }
  2012. // AddedMode returns the value that was added to the "mode" field in this mutation.
  2013. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  2014. v := m.addmode
  2015. if v == nil {
  2016. return
  2017. }
  2018. return *v, true
  2019. }
  2020. // ResetMode resets all changes to the "mode" field.
  2021. func (m *LabelMutation) ResetMode() {
  2022. m.mode = nil
  2023. m.addmode = nil
  2024. }
  2025. // SetConditions sets the "conditions" field.
  2026. func (m *LabelMutation) SetConditions(s string) {
  2027. m.conditions = &s
  2028. }
  2029. // Conditions returns the value of the "conditions" field in the mutation.
  2030. func (m *LabelMutation) Conditions() (r string, exists bool) {
  2031. v := m.conditions
  2032. if v == nil {
  2033. return
  2034. }
  2035. return *v, true
  2036. }
  2037. // OldConditions returns the old "conditions" field's value of the Label entity.
  2038. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  2039. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2040. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  2041. if !m.op.Is(OpUpdateOne) {
  2042. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  2043. }
  2044. if m.id == nil || m.oldValue == nil {
  2045. return v, errors.New("OldConditions requires an ID field in the mutation")
  2046. }
  2047. oldValue, err := m.oldValue(ctx)
  2048. if err != nil {
  2049. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  2050. }
  2051. return oldValue.Conditions, nil
  2052. }
  2053. // ClearConditions clears the value of the "conditions" field.
  2054. func (m *LabelMutation) ClearConditions() {
  2055. m.conditions = nil
  2056. m.clearedFields[label.FieldConditions] = struct{}{}
  2057. }
  2058. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  2059. func (m *LabelMutation) ConditionsCleared() bool {
  2060. _, ok := m.clearedFields[label.FieldConditions]
  2061. return ok
  2062. }
  2063. // ResetConditions resets all changes to the "conditions" field.
  2064. func (m *LabelMutation) ResetConditions() {
  2065. m.conditions = nil
  2066. delete(m.clearedFields, label.FieldConditions)
  2067. }
  2068. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  2069. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  2070. if m.label_relationships == nil {
  2071. m.label_relationships = make(map[uint64]struct{})
  2072. }
  2073. for i := range ids {
  2074. m.label_relationships[ids[i]] = struct{}{}
  2075. }
  2076. }
  2077. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  2078. func (m *LabelMutation) ClearLabelRelationships() {
  2079. m.clearedlabel_relationships = true
  2080. }
  2081. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  2082. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  2083. return m.clearedlabel_relationships
  2084. }
  2085. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  2086. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  2087. if m.removedlabel_relationships == nil {
  2088. m.removedlabel_relationships = make(map[uint64]struct{})
  2089. }
  2090. for i := range ids {
  2091. delete(m.label_relationships, ids[i])
  2092. m.removedlabel_relationships[ids[i]] = struct{}{}
  2093. }
  2094. }
  2095. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  2096. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  2097. for id := range m.removedlabel_relationships {
  2098. ids = append(ids, id)
  2099. }
  2100. return
  2101. }
  2102. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  2103. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  2104. for id := range m.label_relationships {
  2105. ids = append(ids, id)
  2106. }
  2107. return
  2108. }
  2109. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  2110. func (m *LabelMutation) ResetLabelRelationships() {
  2111. m.label_relationships = nil
  2112. m.clearedlabel_relationships = false
  2113. m.removedlabel_relationships = nil
  2114. }
  2115. // Where appends a list predicates to the LabelMutation builder.
  2116. func (m *LabelMutation) Where(ps ...predicate.Label) {
  2117. m.predicates = append(m.predicates, ps...)
  2118. }
  2119. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  2120. // users can use type-assertion to append predicates that do not depend on any generated package.
  2121. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  2122. p := make([]predicate.Label, len(ps))
  2123. for i := range ps {
  2124. p[i] = ps[i]
  2125. }
  2126. m.Where(p...)
  2127. }
  2128. // Op returns the operation name.
  2129. func (m *LabelMutation) Op() Op {
  2130. return m.op
  2131. }
  2132. // SetOp allows setting the mutation operation.
  2133. func (m *LabelMutation) SetOp(op Op) {
  2134. m.op = op
  2135. }
  2136. // Type returns the node type of this mutation (Label).
  2137. func (m *LabelMutation) Type() string {
  2138. return m.typ
  2139. }
  2140. // Fields returns all fields that were changed during this mutation. Note that in
  2141. // order to get all numeric fields that were incremented/decremented, call
  2142. // AddedFields().
  2143. func (m *LabelMutation) Fields() []string {
  2144. fields := make([]string, 0, 9)
  2145. if m.created_at != nil {
  2146. fields = append(fields, label.FieldCreatedAt)
  2147. }
  2148. if m.updated_at != nil {
  2149. fields = append(fields, label.FieldUpdatedAt)
  2150. }
  2151. if m.status != nil {
  2152. fields = append(fields, label.FieldStatus)
  2153. }
  2154. if m.deleted_at != nil {
  2155. fields = append(fields, label.FieldDeletedAt)
  2156. }
  2157. if m._type != nil {
  2158. fields = append(fields, label.FieldType)
  2159. }
  2160. if m.name != nil {
  2161. fields = append(fields, label.FieldName)
  2162. }
  2163. if m.from != nil {
  2164. fields = append(fields, label.FieldFrom)
  2165. }
  2166. if m.mode != nil {
  2167. fields = append(fields, label.FieldMode)
  2168. }
  2169. if m.conditions != nil {
  2170. fields = append(fields, label.FieldConditions)
  2171. }
  2172. return fields
  2173. }
  2174. // Field returns the value of a field with the given name. The second boolean
  2175. // return value indicates that this field was not set, or was not defined in the
  2176. // schema.
  2177. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  2178. switch name {
  2179. case label.FieldCreatedAt:
  2180. return m.CreatedAt()
  2181. case label.FieldUpdatedAt:
  2182. return m.UpdatedAt()
  2183. case label.FieldStatus:
  2184. return m.Status()
  2185. case label.FieldDeletedAt:
  2186. return m.DeletedAt()
  2187. case label.FieldType:
  2188. return m.GetType()
  2189. case label.FieldName:
  2190. return m.Name()
  2191. case label.FieldFrom:
  2192. return m.From()
  2193. case label.FieldMode:
  2194. return m.Mode()
  2195. case label.FieldConditions:
  2196. return m.Conditions()
  2197. }
  2198. return nil, false
  2199. }
  2200. // OldField returns the old value of the field from the database. An error is
  2201. // returned if the mutation operation is not UpdateOne, or the query to the
  2202. // database failed.
  2203. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2204. switch name {
  2205. case label.FieldCreatedAt:
  2206. return m.OldCreatedAt(ctx)
  2207. case label.FieldUpdatedAt:
  2208. return m.OldUpdatedAt(ctx)
  2209. case label.FieldStatus:
  2210. return m.OldStatus(ctx)
  2211. case label.FieldDeletedAt:
  2212. return m.OldDeletedAt(ctx)
  2213. case label.FieldType:
  2214. return m.OldType(ctx)
  2215. case label.FieldName:
  2216. return m.OldName(ctx)
  2217. case label.FieldFrom:
  2218. return m.OldFrom(ctx)
  2219. case label.FieldMode:
  2220. return m.OldMode(ctx)
  2221. case label.FieldConditions:
  2222. return m.OldConditions(ctx)
  2223. }
  2224. return nil, fmt.Errorf("unknown Label field %s", name)
  2225. }
  2226. // SetField sets the value of a field with the given name. It returns an error if
  2227. // the field is not defined in the schema, or if the type mismatched the field
  2228. // type.
  2229. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  2230. switch name {
  2231. case label.FieldCreatedAt:
  2232. v, ok := value.(time.Time)
  2233. if !ok {
  2234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2235. }
  2236. m.SetCreatedAt(v)
  2237. return nil
  2238. case label.FieldUpdatedAt:
  2239. v, ok := value.(time.Time)
  2240. if !ok {
  2241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2242. }
  2243. m.SetUpdatedAt(v)
  2244. return nil
  2245. case label.FieldStatus:
  2246. v, ok := value.(uint8)
  2247. if !ok {
  2248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2249. }
  2250. m.SetStatus(v)
  2251. return nil
  2252. case label.FieldDeletedAt:
  2253. v, ok := value.(time.Time)
  2254. if !ok {
  2255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2256. }
  2257. m.SetDeletedAt(v)
  2258. return nil
  2259. case label.FieldType:
  2260. v, ok := value.(int)
  2261. if !ok {
  2262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2263. }
  2264. m.SetType(v)
  2265. return nil
  2266. case label.FieldName:
  2267. v, ok := value.(string)
  2268. if !ok {
  2269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2270. }
  2271. m.SetName(v)
  2272. return nil
  2273. case label.FieldFrom:
  2274. v, ok := value.(int)
  2275. if !ok {
  2276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2277. }
  2278. m.SetFrom(v)
  2279. return nil
  2280. case label.FieldMode:
  2281. v, ok := value.(int)
  2282. if !ok {
  2283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2284. }
  2285. m.SetMode(v)
  2286. return nil
  2287. case label.FieldConditions:
  2288. v, ok := value.(string)
  2289. if !ok {
  2290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2291. }
  2292. m.SetConditions(v)
  2293. return nil
  2294. }
  2295. return fmt.Errorf("unknown Label field %s", name)
  2296. }
  2297. // AddedFields returns all numeric fields that were incremented/decremented during
  2298. // this mutation.
  2299. func (m *LabelMutation) AddedFields() []string {
  2300. var fields []string
  2301. if m.addstatus != nil {
  2302. fields = append(fields, label.FieldStatus)
  2303. }
  2304. if m.add_type != nil {
  2305. fields = append(fields, label.FieldType)
  2306. }
  2307. if m.addfrom != nil {
  2308. fields = append(fields, label.FieldFrom)
  2309. }
  2310. if m.addmode != nil {
  2311. fields = append(fields, label.FieldMode)
  2312. }
  2313. return fields
  2314. }
  2315. // AddedField returns the numeric value that was incremented/decremented on a field
  2316. // with the given name. The second boolean return value indicates that this field
  2317. // was not set, or was not defined in the schema.
  2318. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  2319. switch name {
  2320. case label.FieldStatus:
  2321. return m.AddedStatus()
  2322. case label.FieldType:
  2323. return m.AddedType()
  2324. case label.FieldFrom:
  2325. return m.AddedFrom()
  2326. case label.FieldMode:
  2327. return m.AddedMode()
  2328. }
  2329. return nil, false
  2330. }
  2331. // AddField adds the value to the field with the given name. It returns an error if
  2332. // the field is not defined in the schema, or if the type mismatched the field
  2333. // type.
  2334. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  2335. switch name {
  2336. case label.FieldStatus:
  2337. v, ok := value.(int8)
  2338. if !ok {
  2339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2340. }
  2341. m.AddStatus(v)
  2342. return nil
  2343. case label.FieldType:
  2344. v, ok := value.(int)
  2345. if !ok {
  2346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2347. }
  2348. m.AddType(v)
  2349. return nil
  2350. case label.FieldFrom:
  2351. v, ok := value.(int)
  2352. if !ok {
  2353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2354. }
  2355. m.AddFrom(v)
  2356. return nil
  2357. case label.FieldMode:
  2358. v, ok := value.(int)
  2359. if !ok {
  2360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2361. }
  2362. m.AddMode(v)
  2363. return nil
  2364. }
  2365. return fmt.Errorf("unknown Label numeric field %s", name)
  2366. }
  2367. // ClearedFields returns all nullable fields that were cleared during this
  2368. // mutation.
  2369. func (m *LabelMutation) ClearedFields() []string {
  2370. var fields []string
  2371. if m.FieldCleared(label.FieldStatus) {
  2372. fields = append(fields, label.FieldStatus)
  2373. }
  2374. if m.FieldCleared(label.FieldDeletedAt) {
  2375. fields = append(fields, label.FieldDeletedAt)
  2376. }
  2377. if m.FieldCleared(label.FieldConditions) {
  2378. fields = append(fields, label.FieldConditions)
  2379. }
  2380. return fields
  2381. }
  2382. // FieldCleared returns a boolean indicating if a field with the given name was
  2383. // cleared in this mutation.
  2384. func (m *LabelMutation) FieldCleared(name string) bool {
  2385. _, ok := m.clearedFields[name]
  2386. return ok
  2387. }
  2388. // ClearField clears the value of the field with the given name. It returns an
  2389. // error if the field is not defined in the schema.
  2390. func (m *LabelMutation) ClearField(name string) error {
  2391. switch name {
  2392. case label.FieldStatus:
  2393. m.ClearStatus()
  2394. return nil
  2395. case label.FieldDeletedAt:
  2396. m.ClearDeletedAt()
  2397. return nil
  2398. case label.FieldConditions:
  2399. m.ClearConditions()
  2400. return nil
  2401. }
  2402. return fmt.Errorf("unknown Label nullable field %s", name)
  2403. }
  2404. // ResetField resets all changes in the mutation for the field with the given name.
  2405. // It returns an error if the field is not defined in the schema.
  2406. func (m *LabelMutation) ResetField(name string) error {
  2407. switch name {
  2408. case label.FieldCreatedAt:
  2409. m.ResetCreatedAt()
  2410. return nil
  2411. case label.FieldUpdatedAt:
  2412. m.ResetUpdatedAt()
  2413. return nil
  2414. case label.FieldStatus:
  2415. m.ResetStatus()
  2416. return nil
  2417. case label.FieldDeletedAt:
  2418. m.ResetDeletedAt()
  2419. return nil
  2420. case label.FieldType:
  2421. m.ResetType()
  2422. return nil
  2423. case label.FieldName:
  2424. m.ResetName()
  2425. return nil
  2426. case label.FieldFrom:
  2427. m.ResetFrom()
  2428. return nil
  2429. case label.FieldMode:
  2430. m.ResetMode()
  2431. return nil
  2432. case label.FieldConditions:
  2433. m.ResetConditions()
  2434. return nil
  2435. }
  2436. return fmt.Errorf("unknown Label field %s", name)
  2437. }
  2438. // AddedEdges returns all edge names that were set/added in this mutation.
  2439. func (m *LabelMutation) AddedEdges() []string {
  2440. edges := make([]string, 0, 1)
  2441. if m.label_relationships != nil {
  2442. edges = append(edges, label.EdgeLabelRelationships)
  2443. }
  2444. return edges
  2445. }
  2446. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2447. // name in this mutation.
  2448. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  2449. switch name {
  2450. case label.EdgeLabelRelationships:
  2451. ids := make([]ent.Value, 0, len(m.label_relationships))
  2452. for id := range m.label_relationships {
  2453. ids = append(ids, id)
  2454. }
  2455. return ids
  2456. }
  2457. return nil
  2458. }
  2459. // RemovedEdges returns all edge names that were removed in this mutation.
  2460. func (m *LabelMutation) RemovedEdges() []string {
  2461. edges := make([]string, 0, 1)
  2462. if m.removedlabel_relationships != nil {
  2463. edges = append(edges, label.EdgeLabelRelationships)
  2464. }
  2465. return edges
  2466. }
  2467. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2468. // the given name in this mutation.
  2469. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  2470. switch name {
  2471. case label.EdgeLabelRelationships:
  2472. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  2473. for id := range m.removedlabel_relationships {
  2474. ids = append(ids, id)
  2475. }
  2476. return ids
  2477. }
  2478. return nil
  2479. }
  2480. // ClearedEdges returns all edge names that were cleared in this mutation.
  2481. func (m *LabelMutation) ClearedEdges() []string {
  2482. edges := make([]string, 0, 1)
  2483. if m.clearedlabel_relationships {
  2484. edges = append(edges, label.EdgeLabelRelationships)
  2485. }
  2486. return edges
  2487. }
  2488. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2489. // was cleared in this mutation.
  2490. func (m *LabelMutation) EdgeCleared(name string) bool {
  2491. switch name {
  2492. case label.EdgeLabelRelationships:
  2493. return m.clearedlabel_relationships
  2494. }
  2495. return false
  2496. }
  2497. // ClearEdge clears the value of the edge with the given name. It returns an error
  2498. // if that edge is not defined in the schema.
  2499. func (m *LabelMutation) ClearEdge(name string) error {
  2500. switch name {
  2501. }
  2502. return fmt.Errorf("unknown Label unique edge %s", name)
  2503. }
  2504. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2505. // It returns an error if the edge is not defined in the schema.
  2506. func (m *LabelMutation) ResetEdge(name string) error {
  2507. switch name {
  2508. case label.EdgeLabelRelationships:
  2509. m.ResetLabelRelationships()
  2510. return nil
  2511. }
  2512. return fmt.Errorf("unknown Label edge %s", name)
  2513. }
  2514. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  2515. type LabelRelationshipMutation struct {
  2516. config
  2517. op Op
  2518. typ string
  2519. id *uint64
  2520. created_at *time.Time
  2521. updated_at *time.Time
  2522. status *uint8
  2523. addstatus *int8
  2524. deleted_at *time.Time
  2525. clearedFields map[string]struct{}
  2526. contacts *uint64
  2527. clearedcontacts bool
  2528. labels *uint64
  2529. clearedlabels bool
  2530. done bool
  2531. oldValue func(context.Context) (*LabelRelationship, error)
  2532. predicates []predicate.LabelRelationship
  2533. }
  2534. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  2535. // labelrelationshipOption allows management of the mutation configuration using functional options.
  2536. type labelrelationshipOption func(*LabelRelationshipMutation)
  2537. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  2538. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  2539. m := &LabelRelationshipMutation{
  2540. config: c,
  2541. op: op,
  2542. typ: TypeLabelRelationship,
  2543. clearedFields: make(map[string]struct{}),
  2544. }
  2545. for _, opt := range opts {
  2546. opt(m)
  2547. }
  2548. return m
  2549. }
  2550. // withLabelRelationshipID sets the ID field of the mutation.
  2551. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  2552. return func(m *LabelRelationshipMutation) {
  2553. var (
  2554. err error
  2555. once sync.Once
  2556. value *LabelRelationship
  2557. )
  2558. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  2559. once.Do(func() {
  2560. if m.done {
  2561. err = errors.New("querying old values post mutation is not allowed")
  2562. } else {
  2563. value, err = m.Client().LabelRelationship.Get(ctx, id)
  2564. }
  2565. })
  2566. return value, err
  2567. }
  2568. m.id = &id
  2569. }
  2570. }
  2571. // withLabelRelationship sets the old LabelRelationship of the mutation.
  2572. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  2573. return func(m *LabelRelationshipMutation) {
  2574. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  2575. return node, nil
  2576. }
  2577. m.id = &node.ID
  2578. }
  2579. }
  2580. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2581. // executed in a transaction (ent.Tx), a transactional client is returned.
  2582. func (m LabelRelationshipMutation) Client() *Client {
  2583. client := &Client{config: m.config}
  2584. client.init()
  2585. return client
  2586. }
  2587. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2588. // it returns an error otherwise.
  2589. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  2590. if _, ok := m.driver.(*txDriver); !ok {
  2591. return nil, errors.New("ent: mutation is not running in a transaction")
  2592. }
  2593. tx := &Tx{config: m.config}
  2594. tx.init()
  2595. return tx, nil
  2596. }
  2597. // SetID sets the value of the id field. Note that this
  2598. // operation is only accepted on creation of LabelRelationship entities.
  2599. func (m *LabelRelationshipMutation) SetID(id uint64) {
  2600. m.id = &id
  2601. }
  2602. // ID returns the ID value in the mutation. Note that the ID is only available
  2603. // if it was provided to the builder or after it was returned from the database.
  2604. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  2605. if m.id == nil {
  2606. return
  2607. }
  2608. return *m.id, true
  2609. }
  2610. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2611. // That means, if the mutation is applied within a transaction with an isolation level such
  2612. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2613. // or updated by the mutation.
  2614. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  2615. switch {
  2616. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2617. id, exists := m.ID()
  2618. if exists {
  2619. return []uint64{id}, nil
  2620. }
  2621. fallthrough
  2622. case m.op.Is(OpUpdate | OpDelete):
  2623. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  2624. default:
  2625. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2626. }
  2627. }
  2628. // SetCreatedAt sets the "created_at" field.
  2629. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  2630. m.created_at = &t
  2631. }
  2632. // CreatedAt returns the value of the "created_at" field in the mutation.
  2633. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  2634. v := m.created_at
  2635. if v == nil {
  2636. return
  2637. }
  2638. return *v, true
  2639. }
  2640. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  2641. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  2642. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2643. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2644. if !m.op.Is(OpUpdateOne) {
  2645. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2646. }
  2647. if m.id == nil || m.oldValue == nil {
  2648. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2649. }
  2650. oldValue, err := m.oldValue(ctx)
  2651. if err != nil {
  2652. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2653. }
  2654. return oldValue.CreatedAt, nil
  2655. }
  2656. // ResetCreatedAt resets all changes to the "created_at" field.
  2657. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  2658. m.created_at = nil
  2659. }
  2660. // SetUpdatedAt sets the "updated_at" field.
  2661. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  2662. m.updated_at = &t
  2663. }
  2664. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2665. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  2666. v := m.updated_at
  2667. if v == nil {
  2668. return
  2669. }
  2670. return *v, true
  2671. }
  2672. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  2673. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  2674. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2675. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2676. if !m.op.Is(OpUpdateOne) {
  2677. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2678. }
  2679. if m.id == nil || m.oldValue == nil {
  2680. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2681. }
  2682. oldValue, err := m.oldValue(ctx)
  2683. if err != nil {
  2684. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2685. }
  2686. return oldValue.UpdatedAt, nil
  2687. }
  2688. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2689. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  2690. m.updated_at = nil
  2691. }
  2692. // SetStatus sets the "status" field.
  2693. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  2694. m.status = &u
  2695. m.addstatus = nil
  2696. }
  2697. // Status returns the value of the "status" field in the mutation.
  2698. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  2699. v := m.status
  2700. if v == nil {
  2701. return
  2702. }
  2703. return *v, true
  2704. }
  2705. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  2706. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  2707. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2708. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  2709. if !m.op.Is(OpUpdateOne) {
  2710. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  2711. }
  2712. if m.id == nil || m.oldValue == nil {
  2713. return v, errors.New("OldStatus requires an ID field in the mutation")
  2714. }
  2715. oldValue, err := m.oldValue(ctx)
  2716. if err != nil {
  2717. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  2718. }
  2719. return oldValue.Status, nil
  2720. }
  2721. // AddStatus adds u to the "status" field.
  2722. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  2723. if m.addstatus != nil {
  2724. *m.addstatus += u
  2725. } else {
  2726. m.addstatus = &u
  2727. }
  2728. }
  2729. // AddedStatus returns the value that was added to the "status" field in this mutation.
  2730. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  2731. v := m.addstatus
  2732. if v == nil {
  2733. return
  2734. }
  2735. return *v, true
  2736. }
  2737. // ClearStatus clears the value of the "status" field.
  2738. func (m *LabelRelationshipMutation) ClearStatus() {
  2739. m.status = nil
  2740. m.addstatus = nil
  2741. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  2742. }
  2743. // StatusCleared returns if the "status" field was cleared in this mutation.
  2744. func (m *LabelRelationshipMutation) StatusCleared() bool {
  2745. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  2746. return ok
  2747. }
  2748. // ResetStatus resets all changes to the "status" field.
  2749. func (m *LabelRelationshipMutation) ResetStatus() {
  2750. m.status = nil
  2751. m.addstatus = nil
  2752. delete(m.clearedFields, labelrelationship.FieldStatus)
  2753. }
  2754. // SetDeletedAt sets the "deleted_at" field.
  2755. func (m *LabelRelationshipMutation) SetDeletedAt(t time.Time) {
  2756. m.deleted_at = &t
  2757. }
  2758. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2759. func (m *LabelRelationshipMutation) DeletedAt() (r time.Time, exists bool) {
  2760. v := m.deleted_at
  2761. if v == nil {
  2762. return
  2763. }
  2764. return *v, true
  2765. }
  2766. // OldDeletedAt returns the old "deleted_at" field's value of the LabelRelationship entity.
  2767. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  2768. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2769. func (m *LabelRelationshipMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2770. if !m.op.Is(OpUpdateOne) {
  2771. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2772. }
  2773. if m.id == nil || m.oldValue == nil {
  2774. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2775. }
  2776. oldValue, err := m.oldValue(ctx)
  2777. if err != nil {
  2778. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2779. }
  2780. return oldValue.DeletedAt, nil
  2781. }
  2782. // ClearDeletedAt clears the value of the "deleted_at" field.
  2783. func (m *LabelRelationshipMutation) ClearDeletedAt() {
  2784. m.deleted_at = nil
  2785. m.clearedFields[labelrelationship.FieldDeletedAt] = struct{}{}
  2786. }
  2787. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2788. func (m *LabelRelationshipMutation) DeletedAtCleared() bool {
  2789. _, ok := m.clearedFields[labelrelationship.FieldDeletedAt]
  2790. return ok
  2791. }
  2792. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2793. func (m *LabelRelationshipMutation) ResetDeletedAt() {
  2794. m.deleted_at = nil
  2795. delete(m.clearedFields, labelrelationship.FieldDeletedAt)
  2796. }
  2797. // SetLabelID sets the "label_id" field.
  2798. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  2799. m.labels = &u
  2800. }
  2801. // LabelID returns the value of the "label_id" field in the mutation.
  2802. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  2803. v := m.labels
  2804. if v == nil {
  2805. return
  2806. }
  2807. return *v, true
  2808. }
  2809. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  2810. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  2811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2812. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  2813. if !m.op.Is(OpUpdateOne) {
  2814. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  2815. }
  2816. if m.id == nil || m.oldValue == nil {
  2817. return v, errors.New("OldLabelID requires an ID field in the mutation")
  2818. }
  2819. oldValue, err := m.oldValue(ctx)
  2820. if err != nil {
  2821. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  2822. }
  2823. return oldValue.LabelID, nil
  2824. }
  2825. // ResetLabelID resets all changes to the "label_id" field.
  2826. func (m *LabelRelationshipMutation) ResetLabelID() {
  2827. m.labels = nil
  2828. }
  2829. // SetContactID sets the "contact_id" field.
  2830. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  2831. m.contacts = &u
  2832. }
  2833. // ContactID returns the value of the "contact_id" field in the mutation.
  2834. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  2835. v := m.contacts
  2836. if v == nil {
  2837. return
  2838. }
  2839. return *v, true
  2840. }
  2841. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  2842. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  2843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2844. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  2845. if !m.op.Is(OpUpdateOne) {
  2846. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  2847. }
  2848. if m.id == nil || m.oldValue == nil {
  2849. return v, errors.New("OldContactID requires an ID field in the mutation")
  2850. }
  2851. oldValue, err := m.oldValue(ctx)
  2852. if err != nil {
  2853. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  2854. }
  2855. return oldValue.ContactID, nil
  2856. }
  2857. // ResetContactID resets all changes to the "contact_id" field.
  2858. func (m *LabelRelationshipMutation) ResetContactID() {
  2859. m.contacts = nil
  2860. }
  2861. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  2862. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  2863. m.contacts = &id
  2864. }
  2865. // ClearContacts clears the "contacts" edge to the Contact entity.
  2866. func (m *LabelRelationshipMutation) ClearContacts() {
  2867. m.clearedcontacts = true
  2868. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  2869. }
  2870. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  2871. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  2872. return m.clearedcontacts
  2873. }
  2874. // ContactsID returns the "contacts" edge ID in the mutation.
  2875. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  2876. if m.contacts != nil {
  2877. return *m.contacts, true
  2878. }
  2879. return
  2880. }
  2881. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  2882. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  2883. // ContactsID instead. It exists only for internal usage by the builders.
  2884. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  2885. if id := m.contacts; id != nil {
  2886. ids = append(ids, *id)
  2887. }
  2888. return
  2889. }
  2890. // ResetContacts resets all changes to the "contacts" edge.
  2891. func (m *LabelRelationshipMutation) ResetContacts() {
  2892. m.contacts = nil
  2893. m.clearedcontacts = false
  2894. }
  2895. // SetLabelsID sets the "labels" edge to the Label entity by id.
  2896. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  2897. m.labels = &id
  2898. }
  2899. // ClearLabels clears the "labels" edge to the Label entity.
  2900. func (m *LabelRelationshipMutation) ClearLabels() {
  2901. m.clearedlabels = true
  2902. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  2903. }
  2904. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  2905. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  2906. return m.clearedlabels
  2907. }
  2908. // LabelsID returns the "labels" edge ID in the mutation.
  2909. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  2910. if m.labels != nil {
  2911. return *m.labels, true
  2912. }
  2913. return
  2914. }
  2915. // LabelsIDs returns the "labels" edge IDs in the mutation.
  2916. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  2917. // LabelsID instead. It exists only for internal usage by the builders.
  2918. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  2919. if id := m.labels; id != nil {
  2920. ids = append(ids, *id)
  2921. }
  2922. return
  2923. }
  2924. // ResetLabels resets all changes to the "labels" edge.
  2925. func (m *LabelRelationshipMutation) ResetLabels() {
  2926. m.labels = nil
  2927. m.clearedlabels = false
  2928. }
  2929. // Where appends a list predicates to the LabelRelationshipMutation builder.
  2930. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  2931. m.predicates = append(m.predicates, ps...)
  2932. }
  2933. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  2934. // users can use type-assertion to append predicates that do not depend on any generated package.
  2935. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  2936. p := make([]predicate.LabelRelationship, len(ps))
  2937. for i := range ps {
  2938. p[i] = ps[i]
  2939. }
  2940. m.Where(p...)
  2941. }
  2942. // Op returns the operation name.
  2943. func (m *LabelRelationshipMutation) Op() Op {
  2944. return m.op
  2945. }
  2946. // SetOp allows setting the mutation operation.
  2947. func (m *LabelRelationshipMutation) SetOp(op Op) {
  2948. m.op = op
  2949. }
  2950. // Type returns the node type of this mutation (LabelRelationship).
  2951. func (m *LabelRelationshipMutation) Type() string {
  2952. return m.typ
  2953. }
  2954. // Fields returns all fields that were changed during this mutation. Note that in
  2955. // order to get all numeric fields that were incremented/decremented, call
  2956. // AddedFields().
  2957. func (m *LabelRelationshipMutation) Fields() []string {
  2958. fields := make([]string, 0, 6)
  2959. if m.created_at != nil {
  2960. fields = append(fields, labelrelationship.FieldCreatedAt)
  2961. }
  2962. if m.updated_at != nil {
  2963. fields = append(fields, labelrelationship.FieldUpdatedAt)
  2964. }
  2965. if m.status != nil {
  2966. fields = append(fields, labelrelationship.FieldStatus)
  2967. }
  2968. if m.deleted_at != nil {
  2969. fields = append(fields, labelrelationship.FieldDeletedAt)
  2970. }
  2971. if m.labels != nil {
  2972. fields = append(fields, labelrelationship.FieldLabelID)
  2973. }
  2974. if m.contacts != nil {
  2975. fields = append(fields, labelrelationship.FieldContactID)
  2976. }
  2977. return fields
  2978. }
  2979. // Field returns the value of a field with the given name. The second boolean
  2980. // return value indicates that this field was not set, or was not defined in the
  2981. // schema.
  2982. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  2983. switch name {
  2984. case labelrelationship.FieldCreatedAt:
  2985. return m.CreatedAt()
  2986. case labelrelationship.FieldUpdatedAt:
  2987. return m.UpdatedAt()
  2988. case labelrelationship.FieldStatus:
  2989. return m.Status()
  2990. case labelrelationship.FieldDeletedAt:
  2991. return m.DeletedAt()
  2992. case labelrelationship.FieldLabelID:
  2993. return m.LabelID()
  2994. case labelrelationship.FieldContactID:
  2995. return m.ContactID()
  2996. }
  2997. return nil, false
  2998. }
  2999. // OldField returns the old value of the field from the database. An error is
  3000. // returned if the mutation operation is not UpdateOne, or the query to the
  3001. // database failed.
  3002. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3003. switch name {
  3004. case labelrelationship.FieldCreatedAt:
  3005. return m.OldCreatedAt(ctx)
  3006. case labelrelationship.FieldUpdatedAt:
  3007. return m.OldUpdatedAt(ctx)
  3008. case labelrelationship.FieldStatus:
  3009. return m.OldStatus(ctx)
  3010. case labelrelationship.FieldDeletedAt:
  3011. return m.OldDeletedAt(ctx)
  3012. case labelrelationship.FieldLabelID:
  3013. return m.OldLabelID(ctx)
  3014. case labelrelationship.FieldContactID:
  3015. return m.OldContactID(ctx)
  3016. }
  3017. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  3018. }
  3019. // SetField sets the value of a field with the given name. It returns an error if
  3020. // the field is not defined in the schema, or if the type mismatched the field
  3021. // type.
  3022. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  3023. switch name {
  3024. case labelrelationship.FieldCreatedAt:
  3025. v, ok := value.(time.Time)
  3026. if !ok {
  3027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3028. }
  3029. m.SetCreatedAt(v)
  3030. return nil
  3031. case labelrelationship.FieldUpdatedAt:
  3032. v, ok := value.(time.Time)
  3033. if !ok {
  3034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3035. }
  3036. m.SetUpdatedAt(v)
  3037. return nil
  3038. case labelrelationship.FieldStatus:
  3039. v, ok := value.(uint8)
  3040. if !ok {
  3041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3042. }
  3043. m.SetStatus(v)
  3044. return nil
  3045. case labelrelationship.FieldDeletedAt:
  3046. v, ok := value.(time.Time)
  3047. if !ok {
  3048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3049. }
  3050. m.SetDeletedAt(v)
  3051. return nil
  3052. case labelrelationship.FieldLabelID:
  3053. v, ok := value.(uint64)
  3054. if !ok {
  3055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3056. }
  3057. m.SetLabelID(v)
  3058. return nil
  3059. case labelrelationship.FieldContactID:
  3060. v, ok := value.(uint64)
  3061. if !ok {
  3062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3063. }
  3064. m.SetContactID(v)
  3065. return nil
  3066. }
  3067. return fmt.Errorf("unknown LabelRelationship field %s", name)
  3068. }
  3069. // AddedFields returns all numeric fields that were incremented/decremented during
  3070. // this mutation.
  3071. func (m *LabelRelationshipMutation) AddedFields() []string {
  3072. var fields []string
  3073. if m.addstatus != nil {
  3074. fields = append(fields, labelrelationship.FieldStatus)
  3075. }
  3076. return fields
  3077. }
  3078. // AddedField returns the numeric value that was incremented/decremented on a field
  3079. // with the given name. The second boolean return value indicates that this field
  3080. // was not set, or was not defined in the schema.
  3081. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  3082. switch name {
  3083. case labelrelationship.FieldStatus:
  3084. return m.AddedStatus()
  3085. }
  3086. return nil, false
  3087. }
  3088. // AddField adds the value to the field with the given name. It returns an error if
  3089. // the field is not defined in the schema, or if the type mismatched the field
  3090. // type.
  3091. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  3092. switch name {
  3093. case labelrelationship.FieldStatus:
  3094. v, ok := value.(int8)
  3095. if !ok {
  3096. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3097. }
  3098. m.AddStatus(v)
  3099. return nil
  3100. }
  3101. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  3102. }
  3103. // ClearedFields returns all nullable fields that were cleared during this
  3104. // mutation.
  3105. func (m *LabelRelationshipMutation) ClearedFields() []string {
  3106. var fields []string
  3107. if m.FieldCleared(labelrelationship.FieldStatus) {
  3108. fields = append(fields, labelrelationship.FieldStatus)
  3109. }
  3110. if m.FieldCleared(labelrelationship.FieldDeletedAt) {
  3111. fields = append(fields, labelrelationship.FieldDeletedAt)
  3112. }
  3113. return fields
  3114. }
  3115. // FieldCleared returns a boolean indicating if a field with the given name was
  3116. // cleared in this mutation.
  3117. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  3118. _, ok := m.clearedFields[name]
  3119. return ok
  3120. }
  3121. // ClearField clears the value of the field with the given name. It returns an
  3122. // error if the field is not defined in the schema.
  3123. func (m *LabelRelationshipMutation) ClearField(name string) error {
  3124. switch name {
  3125. case labelrelationship.FieldStatus:
  3126. m.ClearStatus()
  3127. return nil
  3128. case labelrelationship.FieldDeletedAt:
  3129. m.ClearDeletedAt()
  3130. return nil
  3131. }
  3132. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  3133. }
  3134. // ResetField resets all changes in the mutation for the field with the given name.
  3135. // It returns an error if the field is not defined in the schema.
  3136. func (m *LabelRelationshipMutation) ResetField(name string) error {
  3137. switch name {
  3138. case labelrelationship.FieldCreatedAt:
  3139. m.ResetCreatedAt()
  3140. return nil
  3141. case labelrelationship.FieldUpdatedAt:
  3142. m.ResetUpdatedAt()
  3143. return nil
  3144. case labelrelationship.FieldStatus:
  3145. m.ResetStatus()
  3146. return nil
  3147. case labelrelationship.FieldDeletedAt:
  3148. m.ResetDeletedAt()
  3149. return nil
  3150. case labelrelationship.FieldLabelID:
  3151. m.ResetLabelID()
  3152. return nil
  3153. case labelrelationship.FieldContactID:
  3154. m.ResetContactID()
  3155. return nil
  3156. }
  3157. return fmt.Errorf("unknown LabelRelationship field %s", name)
  3158. }
  3159. // AddedEdges returns all edge names that were set/added in this mutation.
  3160. func (m *LabelRelationshipMutation) AddedEdges() []string {
  3161. edges := make([]string, 0, 2)
  3162. if m.contacts != nil {
  3163. edges = append(edges, labelrelationship.EdgeContacts)
  3164. }
  3165. if m.labels != nil {
  3166. edges = append(edges, labelrelationship.EdgeLabels)
  3167. }
  3168. return edges
  3169. }
  3170. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3171. // name in this mutation.
  3172. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  3173. switch name {
  3174. case labelrelationship.EdgeContacts:
  3175. if id := m.contacts; id != nil {
  3176. return []ent.Value{*id}
  3177. }
  3178. case labelrelationship.EdgeLabels:
  3179. if id := m.labels; id != nil {
  3180. return []ent.Value{*id}
  3181. }
  3182. }
  3183. return nil
  3184. }
  3185. // RemovedEdges returns all edge names that were removed in this mutation.
  3186. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  3187. edges := make([]string, 0, 2)
  3188. return edges
  3189. }
  3190. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3191. // the given name in this mutation.
  3192. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  3193. return nil
  3194. }
  3195. // ClearedEdges returns all edge names that were cleared in this mutation.
  3196. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  3197. edges := make([]string, 0, 2)
  3198. if m.clearedcontacts {
  3199. edges = append(edges, labelrelationship.EdgeContacts)
  3200. }
  3201. if m.clearedlabels {
  3202. edges = append(edges, labelrelationship.EdgeLabels)
  3203. }
  3204. return edges
  3205. }
  3206. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3207. // was cleared in this mutation.
  3208. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  3209. switch name {
  3210. case labelrelationship.EdgeContacts:
  3211. return m.clearedcontacts
  3212. case labelrelationship.EdgeLabels:
  3213. return m.clearedlabels
  3214. }
  3215. return false
  3216. }
  3217. // ClearEdge clears the value of the edge with the given name. It returns an error
  3218. // if that edge is not defined in the schema.
  3219. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  3220. switch name {
  3221. case labelrelationship.EdgeContacts:
  3222. m.ClearContacts()
  3223. return nil
  3224. case labelrelationship.EdgeLabels:
  3225. m.ClearLabels()
  3226. return nil
  3227. }
  3228. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  3229. }
  3230. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3231. // It returns an error if the edge is not defined in the schema.
  3232. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  3233. switch name {
  3234. case labelrelationship.EdgeContacts:
  3235. m.ResetContacts()
  3236. return nil
  3237. case labelrelationship.EdgeLabels:
  3238. m.ResetLabels()
  3239. return nil
  3240. }
  3241. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  3242. }
  3243. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  3244. type MessageMutation struct {
  3245. config
  3246. op Op
  3247. typ string
  3248. id *int
  3249. wx_wxid *string
  3250. wxid *string
  3251. content *string
  3252. clearedFields map[string]struct{}
  3253. done bool
  3254. oldValue func(context.Context) (*Message, error)
  3255. predicates []predicate.Message
  3256. }
  3257. var _ ent.Mutation = (*MessageMutation)(nil)
  3258. // messageOption allows management of the mutation configuration using functional options.
  3259. type messageOption func(*MessageMutation)
  3260. // newMessageMutation creates new mutation for the Message entity.
  3261. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  3262. m := &MessageMutation{
  3263. config: c,
  3264. op: op,
  3265. typ: TypeMessage,
  3266. clearedFields: make(map[string]struct{}),
  3267. }
  3268. for _, opt := range opts {
  3269. opt(m)
  3270. }
  3271. return m
  3272. }
  3273. // withMessageID sets the ID field of the mutation.
  3274. func withMessageID(id int) messageOption {
  3275. return func(m *MessageMutation) {
  3276. var (
  3277. err error
  3278. once sync.Once
  3279. value *Message
  3280. )
  3281. m.oldValue = func(ctx context.Context) (*Message, error) {
  3282. once.Do(func() {
  3283. if m.done {
  3284. err = errors.New("querying old values post mutation is not allowed")
  3285. } else {
  3286. value, err = m.Client().Message.Get(ctx, id)
  3287. }
  3288. })
  3289. return value, err
  3290. }
  3291. m.id = &id
  3292. }
  3293. }
  3294. // withMessage sets the old Message of the mutation.
  3295. func withMessage(node *Message) messageOption {
  3296. return func(m *MessageMutation) {
  3297. m.oldValue = func(context.Context) (*Message, error) {
  3298. return node, nil
  3299. }
  3300. m.id = &node.ID
  3301. }
  3302. }
  3303. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3304. // executed in a transaction (ent.Tx), a transactional client is returned.
  3305. func (m MessageMutation) Client() *Client {
  3306. client := &Client{config: m.config}
  3307. client.init()
  3308. return client
  3309. }
  3310. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3311. // it returns an error otherwise.
  3312. func (m MessageMutation) Tx() (*Tx, error) {
  3313. if _, ok := m.driver.(*txDriver); !ok {
  3314. return nil, errors.New("ent: mutation is not running in a transaction")
  3315. }
  3316. tx := &Tx{config: m.config}
  3317. tx.init()
  3318. return tx, nil
  3319. }
  3320. // ID returns the ID value in the mutation. Note that the ID is only available
  3321. // if it was provided to the builder or after it was returned from the database.
  3322. func (m *MessageMutation) ID() (id int, exists bool) {
  3323. if m.id == nil {
  3324. return
  3325. }
  3326. return *m.id, true
  3327. }
  3328. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3329. // That means, if the mutation is applied within a transaction with an isolation level such
  3330. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3331. // or updated by the mutation.
  3332. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  3333. switch {
  3334. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3335. id, exists := m.ID()
  3336. if exists {
  3337. return []int{id}, nil
  3338. }
  3339. fallthrough
  3340. case m.op.Is(OpUpdate | OpDelete):
  3341. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  3342. default:
  3343. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3344. }
  3345. }
  3346. // SetWxWxid sets the "wx_wxid" field.
  3347. func (m *MessageMutation) SetWxWxid(s string) {
  3348. m.wx_wxid = &s
  3349. }
  3350. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  3351. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  3352. v := m.wx_wxid
  3353. if v == nil {
  3354. return
  3355. }
  3356. return *v, true
  3357. }
  3358. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  3359. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  3360. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3361. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  3362. if !m.op.Is(OpUpdateOne) {
  3363. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  3364. }
  3365. if m.id == nil || m.oldValue == nil {
  3366. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  3367. }
  3368. oldValue, err := m.oldValue(ctx)
  3369. if err != nil {
  3370. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  3371. }
  3372. return oldValue.WxWxid, nil
  3373. }
  3374. // ClearWxWxid clears the value of the "wx_wxid" field.
  3375. func (m *MessageMutation) ClearWxWxid() {
  3376. m.wx_wxid = nil
  3377. m.clearedFields[message.FieldWxWxid] = struct{}{}
  3378. }
  3379. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  3380. func (m *MessageMutation) WxWxidCleared() bool {
  3381. _, ok := m.clearedFields[message.FieldWxWxid]
  3382. return ok
  3383. }
  3384. // ResetWxWxid resets all changes to the "wx_wxid" field.
  3385. func (m *MessageMutation) ResetWxWxid() {
  3386. m.wx_wxid = nil
  3387. delete(m.clearedFields, message.FieldWxWxid)
  3388. }
  3389. // SetWxid sets the "wxid" field.
  3390. func (m *MessageMutation) SetWxid(s string) {
  3391. m.wxid = &s
  3392. }
  3393. // Wxid returns the value of the "wxid" field in the mutation.
  3394. func (m *MessageMutation) Wxid() (r string, exists bool) {
  3395. v := m.wxid
  3396. if v == nil {
  3397. return
  3398. }
  3399. return *v, true
  3400. }
  3401. // OldWxid returns the old "wxid" field's value of the Message entity.
  3402. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  3403. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3404. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  3405. if !m.op.Is(OpUpdateOne) {
  3406. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  3407. }
  3408. if m.id == nil || m.oldValue == nil {
  3409. return v, errors.New("OldWxid requires an ID field in the mutation")
  3410. }
  3411. oldValue, err := m.oldValue(ctx)
  3412. if err != nil {
  3413. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  3414. }
  3415. return oldValue.Wxid, nil
  3416. }
  3417. // ResetWxid resets all changes to the "wxid" field.
  3418. func (m *MessageMutation) ResetWxid() {
  3419. m.wxid = nil
  3420. }
  3421. // SetContent sets the "content" field.
  3422. func (m *MessageMutation) SetContent(s string) {
  3423. m.content = &s
  3424. }
  3425. // Content returns the value of the "content" field in the mutation.
  3426. func (m *MessageMutation) Content() (r string, exists bool) {
  3427. v := m.content
  3428. if v == nil {
  3429. return
  3430. }
  3431. return *v, true
  3432. }
  3433. // OldContent returns the old "content" field's value of the Message entity.
  3434. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  3435. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3436. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  3437. if !m.op.Is(OpUpdateOne) {
  3438. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  3439. }
  3440. if m.id == nil || m.oldValue == nil {
  3441. return v, errors.New("OldContent requires an ID field in the mutation")
  3442. }
  3443. oldValue, err := m.oldValue(ctx)
  3444. if err != nil {
  3445. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  3446. }
  3447. return oldValue.Content, nil
  3448. }
  3449. // ResetContent resets all changes to the "content" field.
  3450. func (m *MessageMutation) ResetContent() {
  3451. m.content = nil
  3452. }
  3453. // Where appends a list predicates to the MessageMutation builder.
  3454. func (m *MessageMutation) Where(ps ...predicate.Message) {
  3455. m.predicates = append(m.predicates, ps...)
  3456. }
  3457. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  3458. // users can use type-assertion to append predicates that do not depend on any generated package.
  3459. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  3460. p := make([]predicate.Message, len(ps))
  3461. for i := range ps {
  3462. p[i] = ps[i]
  3463. }
  3464. m.Where(p...)
  3465. }
  3466. // Op returns the operation name.
  3467. func (m *MessageMutation) Op() Op {
  3468. return m.op
  3469. }
  3470. // SetOp allows setting the mutation operation.
  3471. func (m *MessageMutation) SetOp(op Op) {
  3472. m.op = op
  3473. }
  3474. // Type returns the node type of this mutation (Message).
  3475. func (m *MessageMutation) Type() string {
  3476. return m.typ
  3477. }
  3478. // Fields returns all fields that were changed during this mutation. Note that in
  3479. // order to get all numeric fields that were incremented/decremented, call
  3480. // AddedFields().
  3481. func (m *MessageMutation) Fields() []string {
  3482. fields := make([]string, 0, 3)
  3483. if m.wx_wxid != nil {
  3484. fields = append(fields, message.FieldWxWxid)
  3485. }
  3486. if m.wxid != nil {
  3487. fields = append(fields, message.FieldWxid)
  3488. }
  3489. if m.content != nil {
  3490. fields = append(fields, message.FieldContent)
  3491. }
  3492. return fields
  3493. }
  3494. // Field returns the value of a field with the given name. The second boolean
  3495. // return value indicates that this field was not set, or was not defined in the
  3496. // schema.
  3497. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  3498. switch name {
  3499. case message.FieldWxWxid:
  3500. return m.WxWxid()
  3501. case message.FieldWxid:
  3502. return m.Wxid()
  3503. case message.FieldContent:
  3504. return m.Content()
  3505. }
  3506. return nil, false
  3507. }
  3508. // OldField returns the old value of the field from the database. An error is
  3509. // returned if the mutation operation is not UpdateOne, or the query to the
  3510. // database failed.
  3511. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3512. switch name {
  3513. case message.FieldWxWxid:
  3514. return m.OldWxWxid(ctx)
  3515. case message.FieldWxid:
  3516. return m.OldWxid(ctx)
  3517. case message.FieldContent:
  3518. return m.OldContent(ctx)
  3519. }
  3520. return nil, fmt.Errorf("unknown Message field %s", name)
  3521. }
  3522. // SetField sets the value of a field with the given name. It returns an error if
  3523. // the field is not defined in the schema, or if the type mismatched the field
  3524. // type.
  3525. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  3526. switch name {
  3527. case message.FieldWxWxid:
  3528. v, ok := value.(string)
  3529. if !ok {
  3530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3531. }
  3532. m.SetWxWxid(v)
  3533. return nil
  3534. case message.FieldWxid:
  3535. v, ok := value.(string)
  3536. if !ok {
  3537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3538. }
  3539. m.SetWxid(v)
  3540. return nil
  3541. case message.FieldContent:
  3542. v, ok := value.(string)
  3543. if !ok {
  3544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3545. }
  3546. m.SetContent(v)
  3547. return nil
  3548. }
  3549. return fmt.Errorf("unknown Message field %s", name)
  3550. }
  3551. // AddedFields returns all numeric fields that were incremented/decremented during
  3552. // this mutation.
  3553. func (m *MessageMutation) AddedFields() []string {
  3554. return nil
  3555. }
  3556. // AddedField returns the numeric value that was incremented/decremented on a field
  3557. // with the given name. The second boolean return value indicates that this field
  3558. // was not set, or was not defined in the schema.
  3559. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  3560. return nil, false
  3561. }
  3562. // AddField adds the value to the field with the given name. It returns an error if
  3563. // the field is not defined in the schema, or if the type mismatched the field
  3564. // type.
  3565. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  3566. switch name {
  3567. }
  3568. return fmt.Errorf("unknown Message numeric field %s", name)
  3569. }
  3570. // ClearedFields returns all nullable fields that were cleared during this
  3571. // mutation.
  3572. func (m *MessageMutation) ClearedFields() []string {
  3573. var fields []string
  3574. if m.FieldCleared(message.FieldWxWxid) {
  3575. fields = append(fields, message.FieldWxWxid)
  3576. }
  3577. return fields
  3578. }
  3579. // FieldCleared returns a boolean indicating if a field with the given name was
  3580. // cleared in this mutation.
  3581. func (m *MessageMutation) FieldCleared(name string) bool {
  3582. _, ok := m.clearedFields[name]
  3583. return ok
  3584. }
  3585. // ClearField clears the value of the field with the given name. It returns an
  3586. // error if the field is not defined in the schema.
  3587. func (m *MessageMutation) ClearField(name string) error {
  3588. switch name {
  3589. case message.FieldWxWxid:
  3590. m.ClearWxWxid()
  3591. return nil
  3592. }
  3593. return fmt.Errorf("unknown Message nullable field %s", name)
  3594. }
  3595. // ResetField resets all changes in the mutation for the field with the given name.
  3596. // It returns an error if the field is not defined in the schema.
  3597. func (m *MessageMutation) ResetField(name string) error {
  3598. switch name {
  3599. case message.FieldWxWxid:
  3600. m.ResetWxWxid()
  3601. return nil
  3602. case message.FieldWxid:
  3603. m.ResetWxid()
  3604. return nil
  3605. case message.FieldContent:
  3606. m.ResetContent()
  3607. return nil
  3608. }
  3609. return fmt.Errorf("unknown Message field %s", name)
  3610. }
  3611. // AddedEdges returns all edge names that were set/added in this mutation.
  3612. func (m *MessageMutation) AddedEdges() []string {
  3613. edges := make([]string, 0, 0)
  3614. return edges
  3615. }
  3616. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3617. // name in this mutation.
  3618. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  3619. return nil
  3620. }
  3621. // RemovedEdges returns all edge names that were removed in this mutation.
  3622. func (m *MessageMutation) RemovedEdges() []string {
  3623. edges := make([]string, 0, 0)
  3624. return edges
  3625. }
  3626. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3627. // the given name in this mutation.
  3628. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  3629. return nil
  3630. }
  3631. // ClearedEdges returns all edge names that were cleared in this mutation.
  3632. func (m *MessageMutation) ClearedEdges() []string {
  3633. edges := make([]string, 0, 0)
  3634. return edges
  3635. }
  3636. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3637. // was cleared in this mutation.
  3638. func (m *MessageMutation) EdgeCleared(name string) bool {
  3639. return false
  3640. }
  3641. // ClearEdge clears the value of the edge with the given name. It returns an error
  3642. // if that edge is not defined in the schema.
  3643. func (m *MessageMutation) ClearEdge(name string) error {
  3644. return fmt.Errorf("unknown Message unique edge %s", name)
  3645. }
  3646. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3647. // It returns an error if the edge is not defined in the schema.
  3648. func (m *MessageMutation) ResetEdge(name string) error {
  3649. return fmt.Errorf("unknown Message edge %s", name)
  3650. }
  3651. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  3652. type MessageRecordsMutation struct {
  3653. config
  3654. op Op
  3655. typ string
  3656. id *uint64
  3657. created_at *time.Time
  3658. updated_at *time.Time
  3659. status *uint8
  3660. addstatus *int8
  3661. deleted_at *time.Time
  3662. bot_wxid *string
  3663. contact_id *int
  3664. addcontact_id *int
  3665. contact_type *int
  3666. addcontact_type *int
  3667. contact_wxid *string
  3668. content_type *int
  3669. addcontent_type *int
  3670. content *string
  3671. error_detail *string
  3672. send_time *time.Time
  3673. source_type *int
  3674. addsource_type *int
  3675. source_id *int
  3676. addsource_id *int
  3677. sub_source_id *int
  3678. addsub_source_id *int
  3679. clearedFields map[string]struct{}
  3680. done bool
  3681. oldValue func(context.Context) (*MessageRecords, error)
  3682. predicates []predicate.MessageRecords
  3683. }
  3684. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  3685. // messagerecordsOption allows management of the mutation configuration using functional options.
  3686. type messagerecordsOption func(*MessageRecordsMutation)
  3687. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  3688. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  3689. m := &MessageRecordsMutation{
  3690. config: c,
  3691. op: op,
  3692. typ: TypeMessageRecords,
  3693. clearedFields: make(map[string]struct{}),
  3694. }
  3695. for _, opt := range opts {
  3696. opt(m)
  3697. }
  3698. return m
  3699. }
  3700. // withMessageRecordsID sets the ID field of the mutation.
  3701. func withMessageRecordsID(id uint64) messagerecordsOption {
  3702. return func(m *MessageRecordsMutation) {
  3703. var (
  3704. err error
  3705. once sync.Once
  3706. value *MessageRecords
  3707. )
  3708. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  3709. once.Do(func() {
  3710. if m.done {
  3711. err = errors.New("querying old values post mutation is not allowed")
  3712. } else {
  3713. value, err = m.Client().MessageRecords.Get(ctx, id)
  3714. }
  3715. })
  3716. return value, err
  3717. }
  3718. m.id = &id
  3719. }
  3720. }
  3721. // withMessageRecords sets the old MessageRecords of the mutation.
  3722. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  3723. return func(m *MessageRecordsMutation) {
  3724. m.oldValue = func(context.Context) (*MessageRecords, error) {
  3725. return node, nil
  3726. }
  3727. m.id = &node.ID
  3728. }
  3729. }
  3730. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3731. // executed in a transaction (ent.Tx), a transactional client is returned.
  3732. func (m MessageRecordsMutation) Client() *Client {
  3733. client := &Client{config: m.config}
  3734. client.init()
  3735. return client
  3736. }
  3737. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3738. // it returns an error otherwise.
  3739. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  3740. if _, ok := m.driver.(*txDriver); !ok {
  3741. return nil, errors.New("ent: mutation is not running in a transaction")
  3742. }
  3743. tx := &Tx{config: m.config}
  3744. tx.init()
  3745. return tx, nil
  3746. }
  3747. // SetID sets the value of the id field. Note that this
  3748. // operation is only accepted on creation of MessageRecords entities.
  3749. func (m *MessageRecordsMutation) SetID(id uint64) {
  3750. m.id = &id
  3751. }
  3752. // ID returns the ID value in the mutation. Note that the ID is only available
  3753. // if it was provided to the builder or after it was returned from the database.
  3754. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  3755. if m.id == nil {
  3756. return
  3757. }
  3758. return *m.id, true
  3759. }
  3760. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3761. // That means, if the mutation is applied within a transaction with an isolation level such
  3762. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3763. // or updated by the mutation.
  3764. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  3765. switch {
  3766. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3767. id, exists := m.ID()
  3768. if exists {
  3769. return []uint64{id}, nil
  3770. }
  3771. fallthrough
  3772. case m.op.Is(OpUpdate | OpDelete):
  3773. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  3774. default:
  3775. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3776. }
  3777. }
  3778. // SetCreatedAt sets the "created_at" field.
  3779. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  3780. m.created_at = &t
  3781. }
  3782. // CreatedAt returns the value of the "created_at" field in the mutation.
  3783. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  3784. v := m.created_at
  3785. if v == nil {
  3786. return
  3787. }
  3788. return *v, true
  3789. }
  3790. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  3791. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  3792. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3793. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3794. if !m.op.Is(OpUpdateOne) {
  3795. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3796. }
  3797. if m.id == nil || m.oldValue == nil {
  3798. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3799. }
  3800. oldValue, err := m.oldValue(ctx)
  3801. if err != nil {
  3802. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3803. }
  3804. return oldValue.CreatedAt, nil
  3805. }
  3806. // ResetCreatedAt resets all changes to the "created_at" field.
  3807. func (m *MessageRecordsMutation) ResetCreatedAt() {
  3808. m.created_at = nil
  3809. }
  3810. // SetUpdatedAt sets the "updated_at" field.
  3811. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  3812. m.updated_at = &t
  3813. }
  3814. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3815. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  3816. v := m.updated_at
  3817. if v == nil {
  3818. return
  3819. }
  3820. return *v, true
  3821. }
  3822. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  3823. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  3824. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3825. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3826. if !m.op.Is(OpUpdateOne) {
  3827. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3828. }
  3829. if m.id == nil || m.oldValue == nil {
  3830. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3831. }
  3832. oldValue, err := m.oldValue(ctx)
  3833. if err != nil {
  3834. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3835. }
  3836. return oldValue.UpdatedAt, nil
  3837. }
  3838. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3839. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  3840. m.updated_at = nil
  3841. }
  3842. // SetStatus sets the "status" field.
  3843. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  3844. m.status = &u
  3845. m.addstatus = nil
  3846. }
  3847. // Status returns the value of the "status" field in the mutation.
  3848. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  3849. v := m.status
  3850. if v == nil {
  3851. return
  3852. }
  3853. return *v, true
  3854. }
  3855. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  3856. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  3857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3858. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  3859. if !m.op.Is(OpUpdateOne) {
  3860. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3861. }
  3862. if m.id == nil || m.oldValue == nil {
  3863. return v, errors.New("OldStatus requires an ID field in the mutation")
  3864. }
  3865. oldValue, err := m.oldValue(ctx)
  3866. if err != nil {
  3867. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3868. }
  3869. return oldValue.Status, nil
  3870. }
  3871. // AddStatus adds u to the "status" field.
  3872. func (m *MessageRecordsMutation) AddStatus(u int8) {
  3873. if m.addstatus != nil {
  3874. *m.addstatus += u
  3875. } else {
  3876. m.addstatus = &u
  3877. }
  3878. }
  3879. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3880. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  3881. v := m.addstatus
  3882. if v == nil {
  3883. return
  3884. }
  3885. return *v, true
  3886. }
  3887. // ClearStatus clears the value of the "status" field.
  3888. func (m *MessageRecordsMutation) ClearStatus() {
  3889. m.status = nil
  3890. m.addstatus = nil
  3891. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  3892. }
  3893. // StatusCleared returns if the "status" field was cleared in this mutation.
  3894. func (m *MessageRecordsMutation) StatusCleared() bool {
  3895. _, ok := m.clearedFields[messagerecords.FieldStatus]
  3896. return ok
  3897. }
  3898. // ResetStatus resets all changes to the "status" field.
  3899. func (m *MessageRecordsMutation) ResetStatus() {
  3900. m.status = nil
  3901. m.addstatus = nil
  3902. delete(m.clearedFields, messagerecords.FieldStatus)
  3903. }
  3904. // SetDeletedAt sets the "deleted_at" field.
  3905. func (m *MessageRecordsMutation) SetDeletedAt(t time.Time) {
  3906. m.deleted_at = &t
  3907. }
  3908. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3909. func (m *MessageRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  3910. v := m.deleted_at
  3911. if v == nil {
  3912. return
  3913. }
  3914. return *v, true
  3915. }
  3916. // OldDeletedAt returns the old "deleted_at" field's value of the MessageRecords entity.
  3917. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  3918. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3919. func (m *MessageRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3920. if !m.op.Is(OpUpdateOne) {
  3921. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3922. }
  3923. if m.id == nil || m.oldValue == nil {
  3924. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3925. }
  3926. oldValue, err := m.oldValue(ctx)
  3927. if err != nil {
  3928. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3929. }
  3930. return oldValue.DeletedAt, nil
  3931. }
  3932. // ClearDeletedAt clears the value of the "deleted_at" field.
  3933. func (m *MessageRecordsMutation) ClearDeletedAt() {
  3934. m.deleted_at = nil
  3935. m.clearedFields[messagerecords.FieldDeletedAt] = struct{}{}
  3936. }
  3937. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3938. func (m *MessageRecordsMutation) DeletedAtCleared() bool {
  3939. _, ok := m.clearedFields[messagerecords.FieldDeletedAt]
  3940. return ok
  3941. }
  3942. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3943. func (m *MessageRecordsMutation) ResetDeletedAt() {
  3944. m.deleted_at = nil
  3945. delete(m.clearedFields, messagerecords.FieldDeletedAt)
  3946. }
  3947. // SetBotWxid sets the "bot_wxid" field.
  3948. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  3949. m.bot_wxid = &s
  3950. }
  3951. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  3952. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  3953. v := m.bot_wxid
  3954. if v == nil {
  3955. return
  3956. }
  3957. return *v, true
  3958. }
  3959. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  3960. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  3961. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3962. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  3963. if !m.op.Is(OpUpdateOne) {
  3964. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  3965. }
  3966. if m.id == nil || m.oldValue == nil {
  3967. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  3968. }
  3969. oldValue, err := m.oldValue(ctx)
  3970. if err != nil {
  3971. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  3972. }
  3973. return oldValue.BotWxid, nil
  3974. }
  3975. // ResetBotWxid resets all changes to the "bot_wxid" field.
  3976. func (m *MessageRecordsMutation) ResetBotWxid() {
  3977. m.bot_wxid = nil
  3978. }
  3979. // SetContactID sets the "contact_id" field.
  3980. func (m *MessageRecordsMutation) SetContactID(i int) {
  3981. m.contact_id = &i
  3982. m.addcontact_id = nil
  3983. }
  3984. // ContactID returns the value of the "contact_id" field in the mutation.
  3985. func (m *MessageRecordsMutation) ContactID() (r int, exists bool) {
  3986. v := m.contact_id
  3987. if v == nil {
  3988. return
  3989. }
  3990. return *v, true
  3991. }
  3992. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  3993. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  3994. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3995. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v int, err error) {
  3996. if !m.op.Is(OpUpdateOne) {
  3997. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  3998. }
  3999. if m.id == nil || m.oldValue == nil {
  4000. return v, errors.New("OldContactID requires an ID field in the mutation")
  4001. }
  4002. oldValue, err := m.oldValue(ctx)
  4003. if err != nil {
  4004. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  4005. }
  4006. return oldValue.ContactID, nil
  4007. }
  4008. // AddContactID adds i to the "contact_id" field.
  4009. func (m *MessageRecordsMutation) AddContactID(i int) {
  4010. if m.addcontact_id != nil {
  4011. *m.addcontact_id += i
  4012. } else {
  4013. m.addcontact_id = &i
  4014. }
  4015. }
  4016. // AddedContactID returns the value that was added to the "contact_id" field in this mutation.
  4017. func (m *MessageRecordsMutation) AddedContactID() (r int, exists bool) {
  4018. v := m.addcontact_id
  4019. if v == nil {
  4020. return
  4021. }
  4022. return *v, true
  4023. }
  4024. // ResetContactID resets all changes to the "contact_id" field.
  4025. func (m *MessageRecordsMutation) ResetContactID() {
  4026. m.contact_id = nil
  4027. m.addcontact_id = nil
  4028. }
  4029. // SetContactType sets the "contact_type" field.
  4030. func (m *MessageRecordsMutation) SetContactType(i int) {
  4031. m.contact_type = &i
  4032. m.addcontact_type = nil
  4033. }
  4034. // ContactType returns the value of the "contact_type" field in the mutation.
  4035. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  4036. v := m.contact_type
  4037. if v == nil {
  4038. return
  4039. }
  4040. return *v, true
  4041. }
  4042. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  4043. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  4044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4045. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  4046. if !m.op.Is(OpUpdateOne) {
  4047. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  4048. }
  4049. if m.id == nil || m.oldValue == nil {
  4050. return v, errors.New("OldContactType requires an ID field in the mutation")
  4051. }
  4052. oldValue, err := m.oldValue(ctx)
  4053. if err != nil {
  4054. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  4055. }
  4056. return oldValue.ContactType, nil
  4057. }
  4058. // AddContactType adds i to the "contact_type" field.
  4059. func (m *MessageRecordsMutation) AddContactType(i int) {
  4060. if m.addcontact_type != nil {
  4061. *m.addcontact_type += i
  4062. } else {
  4063. m.addcontact_type = &i
  4064. }
  4065. }
  4066. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  4067. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  4068. v := m.addcontact_type
  4069. if v == nil {
  4070. return
  4071. }
  4072. return *v, true
  4073. }
  4074. // ResetContactType resets all changes to the "contact_type" field.
  4075. func (m *MessageRecordsMutation) ResetContactType() {
  4076. m.contact_type = nil
  4077. m.addcontact_type = nil
  4078. }
  4079. // SetContactWxid sets the "contact_wxid" field.
  4080. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  4081. m.contact_wxid = &s
  4082. }
  4083. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  4084. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  4085. v := m.contact_wxid
  4086. if v == nil {
  4087. return
  4088. }
  4089. return *v, true
  4090. }
  4091. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  4092. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  4093. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4094. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  4095. if !m.op.Is(OpUpdateOne) {
  4096. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  4097. }
  4098. if m.id == nil || m.oldValue == nil {
  4099. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  4100. }
  4101. oldValue, err := m.oldValue(ctx)
  4102. if err != nil {
  4103. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  4104. }
  4105. return oldValue.ContactWxid, nil
  4106. }
  4107. // ResetContactWxid resets all changes to the "contact_wxid" field.
  4108. func (m *MessageRecordsMutation) ResetContactWxid() {
  4109. m.contact_wxid = nil
  4110. }
  4111. // SetContentType sets the "content_type" field.
  4112. func (m *MessageRecordsMutation) SetContentType(i int) {
  4113. m.content_type = &i
  4114. m.addcontent_type = nil
  4115. }
  4116. // ContentType returns the value of the "content_type" field in the mutation.
  4117. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  4118. v := m.content_type
  4119. if v == nil {
  4120. return
  4121. }
  4122. return *v, true
  4123. }
  4124. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  4125. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  4126. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4127. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  4128. if !m.op.Is(OpUpdateOne) {
  4129. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  4130. }
  4131. if m.id == nil || m.oldValue == nil {
  4132. return v, errors.New("OldContentType requires an ID field in the mutation")
  4133. }
  4134. oldValue, err := m.oldValue(ctx)
  4135. if err != nil {
  4136. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  4137. }
  4138. return oldValue.ContentType, nil
  4139. }
  4140. // AddContentType adds i to the "content_type" field.
  4141. func (m *MessageRecordsMutation) AddContentType(i int) {
  4142. if m.addcontent_type != nil {
  4143. *m.addcontent_type += i
  4144. } else {
  4145. m.addcontent_type = &i
  4146. }
  4147. }
  4148. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  4149. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  4150. v := m.addcontent_type
  4151. if v == nil {
  4152. return
  4153. }
  4154. return *v, true
  4155. }
  4156. // ResetContentType resets all changes to the "content_type" field.
  4157. func (m *MessageRecordsMutation) ResetContentType() {
  4158. m.content_type = nil
  4159. m.addcontent_type = nil
  4160. }
  4161. // SetContent sets the "content" field.
  4162. func (m *MessageRecordsMutation) SetContent(s string) {
  4163. m.content = &s
  4164. }
  4165. // Content returns the value of the "content" field in the mutation.
  4166. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  4167. v := m.content
  4168. if v == nil {
  4169. return
  4170. }
  4171. return *v, true
  4172. }
  4173. // OldContent returns the old "content" field's value of the MessageRecords entity.
  4174. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  4175. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4176. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  4177. if !m.op.Is(OpUpdateOne) {
  4178. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  4179. }
  4180. if m.id == nil || m.oldValue == nil {
  4181. return v, errors.New("OldContent requires an ID field in the mutation")
  4182. }
  4183. oldValue, err := m.oldValue(ctx)
  4184. if err != nil {
  4185. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  4186. }
  4187. return oldValue.Content, nil
  4188. }
  4189. // ResetContent resets all changes to the "content" field.
  4190. func (m *MessageRecordsMutation) ResetContent() {
  4191. m.content = nil
  4192. }
  4193. // SetErrorDetail sets the "error_detail" field.
  4194. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  4195. m.error_detail = &s
  4196. }
  4197. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  4198. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  4199. v := m.error_detail
  4200. if v == nil {
  4201. return
  4202. }
  4203. return *v, true
  4204. }
  4205. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  4206. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  4207. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4208. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  4209. if !m.op.Is(OpUpdateOne) {
  4210. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  4211. }
  4212. if m.id == nil || m.oldValue == nil {
  4213. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  4214. }
  4215. oldValue, err := m.oldValue(ctx)
  4216. if err != nil {
  4217. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  4218. }
  4219. return oldValue.ErrorDetail, nil
  4220. }
  4221. // ResetErrorDetail resets all changes to the "error_detail" field.
  4222. func (m *MessageRecordsMutation) ResetErrorDetail() {
  4223. m.error_detail = nil
  4224. }
  4225. // SetSendTime sets the "send_time" field.
  4226. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  4227. m.send_time = &t
  4228. }
  4229. // SendTime returns the value of the "send_time" field in the mutation.
  4230. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  4231. v := m.send_time
  4232. if v == nil {
  4233. return
  4234. }
  4235. return *v, true
  4236. }
  4237. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  4238. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  4239. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4240. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  4241. if !m.op.Is(OpUpdateOne) {
  4242. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  4243. }
  4244. if m.id == nil || m.oldValue == nil {
  4245. return v, errors.New("OldSendTime requires an ID field in the mutation")
  4246. }
  4247. oldValue, err := m.oldValue(ctx)
  4248. if err != nil {
  4249. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  4250. }
  4251. return oldValue.SendTime, nil
  4252. }
  4253. // ClearSendTime clears the value of the "send_time" field.
  4254. func (m *MessageRecordsMutation) ClearSendTime() {
  4255. m.send_time = nil
  4256. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  4257. }
  4258. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  4259. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  4260. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  4261. return ok
  4262. }
  4263. // ResetSendTime resets all changes to the "send_time" field.
  4264. func (m *MessageRecordsMutation) ResetSendTime() {
  4265. m.send_time = nil
  4266. delete(m.clearedFields, messagerecords.FieldSendTime)
  4267. }
  4268. // SetSourceType sets the "source_type" field.
  4269. func (m *MessageRecordsMutation) SetSourceType(i int) {
  4270. m.source_type = &i
  4271. m.addsource_type = nil
  4272. }
  4273. // SourceType returns the value of the "source_type" field in the mutation.
  4274. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  4275. v := m.source_type
  4276. if v == nil {
  4277. return
  4278. }
  4279. return *v, true
  4280. }
  4281. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  4282. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  4283. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4284. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  4285. if !m.op.Is(OpUpdateOne) {
  4286. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  4287. }
  4288. if m.id == nil || m.oldValue == nil {
  4289. return v, errors.New("OldSourceType requires an ID field in the mutation")
  4290. }
  4291. oldValue, err := m.oldValue(ctx)
  4292. if err != nil {
  4293. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  4294. }
  4295. return oldValue.SourceType, nil
  4296. }
  4297. // AddSourceType adds i to the "source_type" field.
  4298. func (m *MessageRecordsMutation) AddSourceType(i int) {
  4299. if m.addsource_type != nil {
  4300. *m.addsource_type += i
  4301. } else {
  4302. m.addsource_type = &i
  4303. }
  4304. }
  4305. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  4306. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  4307. v := m.addsource_type
  4308. if v == nil {
  4309. return
  4310. }
  4311. return *v, true
  4312. }
  4313. // ResetSourceType resets all changes to the "source_type" field.
  4314. func (m *MessageRecordsMutation) ResetSourceType() {
  4315. m.source_type = nil
  4316. m.addsource_type = nil
  4317. }
  4318. // SetSourceID sets the "source_id" field.
  4319. func (m *MessageRecordsMutation) SetSourceID(i int) {
  4320. m.source_id = &i
  4321. m.addsource_id = nil
  4322. }
  4323. // SourceID returns the value of the "source_id" field in the mutation.
  4324. func (m *MessageRecordsMutation) SourceID() (r int, exists bool) {
  4325. v := m.source_id
  4326. if v == nil {
  4327. return
  4328. }
  4329. return *v, true
  4330. }
  4331. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  4332. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  4333. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4334. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v int, err error) {
  4335. if !m.op.Is(OpUpdateOne) {
  4336. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  4337. }
  4338. if m.id == nil || m.oldValue == nil {
  4339. return v, errors.New("OldSourceID requires an ID field in the mutation")
  4340. }
  4341. oldValue, err := m.oldValue(ctx)
  4342. if err != nil {
  4343. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  4344. }
  4345. return oldValue.SourceID, nil
  4346. }
  4347. // AddSourceID adds i to the "source_id" field.
  4348. func (m *MessageRecordsMutation) AddSourceID(i int) {
  4349. if m.addsource_id != nil {
  4350. *m.addsource_id += i
  4351. } else {
  4352. m.addsource_id = &i
  4353. }
  4354. }
  4355. // AddedSourceID returns the value that was added to the "source_id" field in this mutation.
  4356. func (m *MessageRecordsMutation) AddedSourceID() (r int, exists bool) {
  4357. v := m.addsource_id
  4358. if v == nil {
  4359. return
  4360. }
  4361. return *v, true
  4362. }
  4363. // ResetSourceID resets all changes to the "source_id" field.
  4364. func (m *MessageRecordsMutation) ResetSourceID() {
  4365. m.source_id = nil
  4366. m.addsource_id = nil
  4367. }
  4368. // SetSubSourceID sets the "sub_source_id" field.
  4369. func (m *MessageRecordsMutation) SetSubSourceID(i int) {
  4370. m.sub_source_id = &i
  4371. m.addsub_source_id = nil
  4372. }
  4373. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  4374. func (m *MessageRecordsMutation) SubSourceID() (r int, exists bool) {
  4375. v := m.sub_source_id
  4376. if v == nil {
  4377. return
  4378. }
  4379. return *v, true
  4380. }
  4381. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  4382. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  4383. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4384. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v int, err error) {
  4385. if !m.op.Is(OpUpdateOne) {
  4386. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  4387. }
  4388. if m.id == nil || m.oldValue == nil {
  4389. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  4390. }
  4391. oldValue, err := m.oldValue(ctx)
  4392. if err != nil {
  4393. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  4394. }
  4395. return oldValue.SubSourceID, nil
  4396. }
  4397. // AddSubSourceID adds i to the "sub_source_id" field.
  4398. func (m *MessageRecordsMutation) AddSubSourceID(i int) {
  4399. if m.addsub_source_id != nil {
  4400. *m.addsub_source_id += i
  4401. } else {
  4402. m.addsub_source_id = &i
  4403. }
  4404. }
  4405. // AddedSubSourceID returns the value that was added to the "sub_source_id" field in this mutation.
  4406. func (m *MessageRecordsMutation) AddedSubSourceID() (r int, exists bool) {
  4407. v := m.addsub_source_id
  4408. if v == nil {
  4409. return
  4410. }
  4411. return *v, true
  4412. }
  4413. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  4414. func (m *MessageRecordsMutation) ResetSubSourceID() {
  4415. m.sub_source_id = nil
  4416. m.addsub_source_id = nil
  4417. }
  4418. // Where appends a list predicates to the MessageRecordsMutation builder.
  4419. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  4420. m.predicates = append(m.predicates, ps...)
  4421. }
  4422. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  4423. // users can use type-assertion to append predicates that do not depend on any generated package.
  4424. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  4425. p := make([]predicate.MessageRecords, len(ps))
  4426. for i := range ps {
  4427. p[i] = ps[i]
  4428. }
  4429. m.Where(p...)
  4430. }
  4431. // Op returns the operation name.
  4432. func (m *MessageRecordsMutation) Op() Op {
  4433. return m.op
  4434. }
  4435. // SetOp allows setting the mutation operation.
  4436. func (m *MessageRecordsMutation) SetOp(op Op) {
  4437. m.op = op
  4438. }
  4439. // Type returns the node type of this mutation (MessageRecords).
  4440. func (m *MessageRecordsMutation) Type() string {
  4441. return m.typ
  4442. }
  4443. // Fields returns all fields that were changed during this mutation. Note that in
  4444. // order to get all numeric fields that were incremented/decremented, call
  4445. // AddedFields().
  4446. func (m *MessageRecordsMutation) Fields() []string {
  4447. fields := make([]string, 0, 15)
  4448. if m.created_at != nil {
  4449. fields = append(fields, messagerecords.FieldCreatedAt)
  4450. }
  4451. if m.updated_at != nil {
  4452. fields = append(fields, messagerecords.FieldUpdatedAt)
  4453. }
  4454. if m.status != nil {
  4455. fields = append(fields, messagerecords.FieldStatus)
  4456. }
  4457. if m.deleted_at != nil {
  4458. fields = append(fields, messagerecords.FieldDeletedAt)
  4459. }
  4460. if m.bot_wxid != nil {
  4461. fields = append(fields, messagerecords.FieldBotWxid)
  4462. }
  4463. if m.contact_id != nil {
  4464. fields = append(fields, messagerecords.FieldContactID)
  4465. }
  4466. if m.contact_type != nil {
  4467. fields = append(fields, messagerecords.FieldContactType)
  4468. }
  4469. if m.contact_wxid != nil {
  4470. fields = append(fields, messagerecords.FieldContactWxid)
  4471. }
  4472. if m.content_type != nil {
  4473. fields = append(fields, messagerecords.FieldContentType)
  4474. }
  4475. if m.content != nil {
  4476. fields = append(fields, messagerecords.FieldContent)
  4477. }
  4478. if m.error_detail != nil {
  4479. fields = append(fields, messagerecords.FieldErrorDetail)
  4480. }
  4481. if m.send_time != nil {
  4482. fields = append(fields, messagerecords.FieldSendTime)
  4483. }
  4484. if m.source_type != nil {
  4485. fields = append(fields, messagerecords.FieldSourceType)
  4486. }
  4487. if m.source_id != nil {
  4488. fields = append(fields, messagerecords.FieldSourceID)
  4489. }
  4490. if m.sub_source_id != nil {
  4491. fields = append(fields, messagerecords.FieldSubSourceID)
  4492. }
  4493. return fields
  4494. }
  4495. // Field returns the value of a field with the given name. The second boolean
  4496. // return value indicates that this field was not set, or was not defined in the
  4497. // schema.
  4498. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  4499. switch name {
  4500. case messagerecords.FieldCreatedAt:
  4501. return m.CreatedAt()
  4502. case messagerecords.FieldUpdatedAt:
  4503. return m.UpdatedAt()
  4504. case messagerecords.FieldStatus:
  4505. return m.Status()
  4506. case messagerecords.FieldDeletedAt:
  4507. return m.DeletedAt()
  4508. case messagerecords.FieldBotWxid:
  4509. return m.BotWxid()
  4510. case messagerecords.FieldContactID:
  4511. return m.ContactID()
  4512. case messagerecords.FieldContactType:
  4513. return m.ContactType()
  4514. case messagerecords.FieldContactWxid:
  4515. return m.ContactWxid()
  4516. case messagerecords.FieldContentType:
  4517. return m.ContentType()
  4518. case messagerecords.FieldContent:
  4519. return m.Content()
  4520. case messagerecords.FieldErrorDetail:
  4521. return m.ErrorDetail()
  4522. case messagerecords.FieldSendTime:
  4523. return m.SendTime()
  4524. case messagerecords.FieldSourceType:
  4525. return m.SourceType()
  4526. case messagerecords.FieldSourceID:
  4527. return m.SourceID()
  4528. case messagerecords.FieldSubSourceID:
  4529. return m.SubSourceID()
  4530. }
  4531. return nil, false
  4532. }
  4533. // OldField returns the old value of the field from the database. An error is
  4534. // returned if the mutation operation is not UpdateOne, or the query to the
  4535. // database failed.
  4536. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4537. switch name {
  4538. case messagerecords.FieldCreatedAt:
  4539. return m.OldCreatedAt(ctx)
  4540. case messagerecords.FieldUpdatedAt:
  4541. return m.OldUpdatedAt(ctx)
  4542. case messagerecords.FieldStatus:
  4543. return m.OldStatus(ctx)
  4544. case messagerecords.FieldDeletedAt:
  4545. return m.OldDeletedAt(ctx)
  4546. case messagerecords.FieldBotWxid:
  4547. return m.OldBotWxid(ctx)
  4548. case messagerecords.FieldContactID:
  4549. return m.OldContactID(ctx)
  4550. case messagerecords.FieldContactType:
  4551. return m.OldContactType(ctx)
  4552. case messagerecords.FieldContactWxid:
  4553. return m.OldContactWxid(ctx)
  4554. case messagerecords.FieldContentType:
  4555. return m.OldContentType(ctx)
  4556. case messagerecords.FieldContent:
  4557. return m.OldContent(ctx)
  4558. case messagerecords.FieldErrorDetail:
  4559. return m.OldErrorDetail(ctx)
  4560. case messagerecords.FieldSendTime:
  4561. return m.OldSendTime(ctx)
  4562. case messagerecords.FieldSourceType:
  4563. return m.OldSourceType(ctx)
  4564. case messagerecords.FieldSourceID:
  4565. return m.OldSourceID(ctx)
  4566. case messagerecords.FieldSubSourceID:
  4567. return m.OldSubSourceID(ctx)
  4568. }
  4569. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  4570. }
  4571. // SetField sets the value of a field with the given name. It returns an error if
  4572. // the field is not defined in the schema, or if the type mismatched the field
  4573. // type.
  4574. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  4575. switch name {
  4576. case messagerecords.FieldCreatedAt:
  4577. v, ok := value.(time.Time)
  4578. if !ok {
  4579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4580. }
  4581. m.SetCreatedAt(v)
  4582. return nil
  4583. case messagerecords.FieldUpdatedAt:
  4584. v, ok := value.(time.Time)
  4585. if !ok {
  4586. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4587. }
  4588. m.SetUpdatedAt(v)
  4589. return nil
  4590. case messagerecords.FieldStatus:
  4591. v, ok := value.(uint8)
  4592. if !ok {
  4593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4594. }
  4595. m.SetStatus(v)
  4596. return nil
  4597. case messagerecords.FieldDeletedAt:
  4598. v, ok := value.(time.Time)
  4599. if !ok {
  4600. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4601. }
  4602. m.SetDeletedAt(v)
  4603. return nil
  4604. case messagerecords.FieldBotWxid:
  4605. v, ok := value.(string)
  4606. if !ok {
  4607. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4608. }
  4609. m.SetBotWxid(v)
  4610. return nil
  4611. case messagerecords.FieldContactID:
  4612. v, ok := value.(int)
  4613. if !ok {
  4614. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4615. }
  4616. m.SetContactID(v)
  4617. return nil
  4618. case messagerecords.FieldContactType:
  4619. v, ok := value.(int)
  4620. if !ok {
  4621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4622. }
  4623. m.SetContactType(v)
  4624. return nil
  4625. case messagerecords.FieldContactWxid:
  4626. v, ok := value.(string)
  4627. if !ok {
  4628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4629. }
  4630. m.SetContactWxid(v)
  4631. return nil
  4632. case messagerecords.FieldContentType:
  4633. v, ok := value.(int)
  4634. if !ok {
  4635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4636. }
  4637. m.SetContentType(v)
  4638. return nil
  4639. case messagerecords.FieldContent:
  4640. v, ok := value.(string)
  4641. if !ok {
  4642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4643. }
  4644. m.SetContent(v)
  4645. return nil
  4646. case messagerecords.FieldErrorDetail:
  4647. v, ok := value.(string)
  4648. if !ok {
  4649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4650. }
  4651. m.SetErrorDetail(v)
  4652. return nil
  4653. case messagerecords.FieldSendTime:
  4654. v, ok := value.(time.Time)
  4655. if !ok {
  4656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4657. }
  4658. m.SetSendTime(v)
  4659. return nil
  4660. case messagerecords.FieldSourceType:
  4661. v, ok := value.(int)
  4662. if !ok {
  4663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4664. }
  4665. m.SetSourceType(v)
  4666. return nil
  4667. case messagerecords.FieldSourceID:
  4668. v, ok := value.(int)
  4669. if !ok {
  4670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4671. }
  4672. m.SetSourceID(v)
  4673. return nil
  4674. case messagerecords.FieldSubSourceID:
  4675. v, ok := value.(int)
  4676. if !ok {
  4677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4678. }
  4679. m.SetSubSourceID(v)
  4680. return nil
  4681. }
  4682. return fmt.Errorf("unknown MessageRecords field %s", name)
  4683. }
  4684. // AddedFields returns all numeric fields that were incremented/decremented during
  4685. // this mutation.
  4686. func (m *MessageRecordsMutation) AddedFields() []string {
  4687. var fields []string
  4688. if m.addstatus != nil {
  4689. fields = append(fields, messagerecords.FieldStatus)
  4690. }
  4691. if m.addcontact_id != nil {
  4692. fields = append(fields, messagerecords.FieldContactID)
  4693. }
  4694. if m.addcontact_type != nil {
  4695. fields = append(fields, messagerecords.FieldContactType)
  4696. }
  4697. if m.addcontent_type != nil {
  4698. fields = append(fields, messagerecords.FieldContentType)
  4699. }
  4700. if m.addsource_type != nil {
  4701. fields = append(fields, messagerecords.FieldSourceType)
  4702. }
  4703. if m.addsource_id != nil {
  4704. fields = append(fields, messagerecords.FieldSourceID)
  4705. }
  4706. if m.addsub_source_id != nil {
  4707. fields = append(fields, messagerecords.FieldSubSourceID)
  4708. }
  4709. return fields
  4710. }
  4711. // AddedField returns the numeric value that was incremented/decremented on a field
  4712. // with the given name. The second boolean return value indicates that this field
  4713. // was not set, or was not defined in the schema.
  4714. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  4715. switch name {
  4716. case messagerecords.FieldStatus:
  4717. return m.AddedStatus()
  4718. case messagerecords.FieldContactID:
  4719. return m.AddedContactID()
  4720. case messagerecords.FieldContactType:
  4721. return m.AddedContactType()
  4722. case messagerecords.FieldContentType:
  4723. return m.AddedContentType()
  4724. case messagerecords.FieldSourceType:
  4725. return m.AddedSourceType()
  4726. case messagerecords.FieldSourceID:
  4727. return m.AddedSourceID()
  4728. case messagerecords.FieldSubSourceID:
  4729. return m.AddedSubSourceID()
  4730. }
  4731. return nil, false
  4732. }
  4733. // AddField adds the value to the field with the given name. It returns an error if
  4734. // the field is not defined in the schema, or if the type mismatched the field
  4735. // type.
  4736. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  4737. switch name {
  4738. case messagerecords.FieldStatus:
  4739. v, ok := value.(int8)
  4740. if !ok {
  4741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4742. }
  4743. m.AddStatus(v)
  4744. return nil
  4745. case messagerecords.FieldContactID:
  4746. v, ok := value.(int)
  4747. if !ok {
  4748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4749. }
  4750. m.AddContactID(v)
  4751. return nil
  4752. case messagerecords.FieldContactType:
  4753. v, ok := value.(int)
  4754. if !ok {
  4755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4756. }
  4757. m.AddContactType(v)
  4758. return nil
  4759. case messagerecords.FieldContentType:
  4760. v, ok := value.(int)
  4761. if !ok {
  4762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4763. }
  4764. m.AddContentType(v)
  4765. return nil
  4766. case messagerecords.FieldSourceType:
  4767. v, ok := value.(int)
  4768. if !ok {
  4769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4770. }
  4771. m.AddSourceType(v)
  4772. return nil
  4773. case messagerecords.FieldSourceID:
  4774. v, ok := value.(int)
  4775. if !ok {
  4776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4777. }
  4778. m.AddSourceID(v)
  4779. return nil
  4780. case messagerecords.FieldSubSourceID:
  4781. v, ok := value.(int)
  4782. if !ok {
  4783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4784. }
  4785. m.AddSubSourceID(v)
  4786. return nil
  4787. }
  4788. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  4789. }
  4790. // ClearedFields returns all nullable fields that were cleared during this
  4791. // mutation.
  4792. func (m *MessageRecordsMutation) ClearedFields() []string {
  4793. var fields []string
  4794. if m.FieldCleared(messagerecords.FieldStatus) {
  4795. fields = append(fields, messagerecords.FieldStatus)
  4796. }
  4797. if m.FieldCleared(messagerecords.FieldDeletedAt) {
  4798. fields = append(fields, messagerecords.FieldDeletedAt)
  4799. }
  4800. if m.FieldCleared(messagerecords.FieldSendTime) {
  4801. fields = append(fields, messagerecords.FieldSendTime)
  4802. }
  4803. return fields
  4804. }
  4805. // FieldCleared returns a boolean indicating if a field with the given name was
  4806. // cleared in this mutation.
  4807. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  4808. _, ok := m.clearedFields[name]
  4809. return ok
  4810. }
  4811. // ClearField clears the value of the field with the given name. It returns an
  4812. // error if the field is not defined in the schema.
  4813. func (m *MessageRecordsMutation) ClearField(name string) error {
  4814. switch name {
  4815. case messagerecords.FieldStatus:
  4816. m.ClearStatus()
  4817. return nil
  4818. case messagerecords.FieldDeletedAt:
  4819. m.ClearDeletedAt()
  4820. return nil
  4821. case messagerecords.FieldSendTime:
  4822. m.ClearSendTime()
  4823. return nil
  4824. }
  4825. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  4826. }
  4827. // ResetField resets all changes in the mutation for the field with the given name.
  4828. // It returns an error if the field is not defined in the schema.
  4829. func (m *MessageRecordsMutation) ResetField(name string) error {
  4830. switch name {
  4831. case messagerecords.FieldCreatedAt:
  4832. m.ResetCreatedAt()
  4833. return nil
  4834. case messagerecords.FieldUpdatedAt:
  4835. m.ResetUpdatedAt()
  4836. return nil
  4837. case messagerecords.FieldStatus:
  4838. m.ResetStatus()
  4839. return nil
  4840. case messagerecords.FieldDeletedAt:
  4841. m.ResetDeletedAt()
  4842. return nil
  4843. case messagerecords.FieldBotWxid:
  4844. m.ResetBotWxid()
  4845. return nil
  4846. case messagerecords.FieldContactID:
  4847. m.ResetContactID()
  4848. return nil
  4849. case messagerecords.FieldContactType:
  4850. m.ResetContactType()
  4851. return nil
  4852. case messagerecords.FieldContactWxid:
  4853. m.ResetContactWxid()
  4854. return nil
  4855. case messagerecords.FieldContentType:
  4856. m.ResetContentType()
  4857. return nil
  4858. case messagerecords.FieldContent:
  4859. m.ResetContent()
  4860. return nil
  4861. case messagerecords.FieldErrorDetail:
  4862. m.ResetErrorDetail()
  4863. return nil
  4864. case messagerecords.FieldSendTime:
  4865. m.ResetSendTime()
  4866. return nil
  4867. case messagerecords.FieldSourceType:
  4868. m.ResetSourceType()
  4869. return nil
  4870. case messagerecords.FieldSourceID:
  4871. m.ResetSourceID()
  4872. return nil
  4873. case messagerecords.FieldSubSourceID:
  4874. m.ResetSubSourceID()
  4875. return nil
  4876. }
  4877. return fmt.Errorf("unknown MessageRecords field %s", name)
  4878. }
  4879. // AddedEdges returns all edge names that were set/added in this mutation.
  4880. func (m *MessageRecordsMutation) AddedEdges() []string {
  4881. edges := make([]string, 0, 0)
  4882. return edges
  4883. }
  4884. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4885. // name in this mutation.
  4886. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  4887. return nil
  4888. }
  4889. // RemovedEdges returns all edge names that were removed in this mutation.
  4890. func (m *MessageRecordsMutation) RemovedEdges() []string {
  4891. edges := make([]string, 0, 0)
  4892. return edges
  4893. }
  4894. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4895. // the given name in this mutation.
  4896. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  4897. return nil
  4898. }
  4899. // ClearedEdges returns all edge names that were cleared in this mutation.
  4900. func (m *MessageRecordsMutation) ClearedEdges() []string {
  4901. edges := make([]string, 0, 0)
  4902. return edges
  4903. }
  4904. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4905. // was cleared in this mutation.
  4906. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  4907. return false
  4908. }
  4909. // ClearEdge clears the value of the edge with the given name. It returns an error
  4910. // if that edge is not defined in the schema.
  4911. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  4912. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  4913. }
  4914. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4915. // It returns an error if the edge is not defined in the schema.
  4916. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  4917. return fmt.Errorf("unknown MessageRecords edge %s", name)
  4918. }
  4919. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  4920. type ServerMutation struct {
  4921. config
  4922. op Op
  4923. typ string
  4924. id *uint64
  4925. created_at *time.Time
  4926. updated_at *time.Time
  4927. status *uint8
  4928. addstatus *int8
  4929. deleted_at *time.Time
  4930. name *string
  4931. public_ip *string
  4932. private_ip *string
  4933. admin_port *string
  4934. clearedFields map[string]struct{}
  4935. wxs map[uint64]struct{}
  4936. removedwxs map[uint64]struct{}
  4937. clearedwxs bool
  4938. done bool
  4939. oldValue func(context.Context) (*Server, error)
  4940. predicates []predicate.Server
  4941. }
  4942. var _ ent.Mutation = (*ServerMutation)(nil)
  4943. // serverOption allows management of the mutation configuration using functional options.
  4944. type serverOption func(*ServerMutation)
  4945. // newServerMutation creates new mutation for the Server entity.
  4946. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  4947. m := &ServerMutation{
  4948. config: c,
  4949. op: op,
  4950. typ: TypeServer,
  4951. clearedFields: make(map[string]struct{}),
  4952. }
  4953. for _, opt := range opts {
  4954. opt(m)
  4955. }
  4956. return m
  4957. }
  4958. // withServerID sets the ID field of the mutation.
  4959. func withServerID(id uint64) serverOption {
  4960. return func(m *ServerMutation) {
  4961. var (
  4962. err error
  4963. once sync.Once
  4964. value *Server
  4965. )
  4966. m.oldValue = func(ctx context.Context) (*Server, error) {
  4967. once.Do(func() {
  4968. if m.done {
  4969. err = errors.New("querying old values post mutation is not allowed")
  4970. } else {
  4971. value, err = m.Client().Server.Get(ctx, id)
  4972. }
  4973. })
  4974. return value, err
  4975. }
  4976. m.id = &id
  4977. }
  4978. }
  4979. // withServer sets the old Server of the mutation.
  4980. func withServer(node *Server) serverOption {
  4981. return func(m *ServerMutation) {
  4982. m.oldValue = func(context.Context) (*Server, error) {
  4983. return node, nil
  4984. }
  4985. m.id = &node.ID
  4986. }
  4987. }
  4988. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4989. // executed in a transaction (ent.Tx), a transactional client is returned.
  4990. func (m ServerMutation) Client() *Client {
  4991. client := &Client{config: m.config}
  4992. client.init()
  4993. return client
  4994. }
  4995. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4996. // it returns an error otherwise.
  4997. func (m ServerMutation) Tx() (*Tx, error) {
  4998. if _, ok := m.driver.(*txDriver); !ok {
  4999. return nil, errors.New("ent: mutation is not running in a transaction")
  5000. }
  5001. tx := &Tx{config: m.config}
  5002. tx.init()
  5003. return tx, nil
  5004. }
  5005. // SetID sets the value of the id field. Note that this
  5006. // operation is only accepted on creation of Server entities.
  5007. func (m *ServerMutation) SetID(id uint64) {
  5008. m.id = &id
  5009. }
  5010. // ID returns the ID value in the mutation. Note that the ID is only available
  5011. // if it was provided to the builder or after it was returned from the database.
  5012. func (m *ServerMutation) ID() (id uint64, exists bool) {
  5013. if m.id == nil {
  5014. return
  5015. }
  5016. return *m.id, true
  5017. }
  5018. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5019. // That means, if the mutation is applied within a transaction with an isolation level such
  5020. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5021. // or updated by the mutation.
  5022. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  5023. switch {
  5024. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5025. id, exists := m.ID()
  5026. if exists {
  5027. return []uint64{id}, nil
  5028. }
  5029. fallthrough
  5030. case m.op.Is(OpUpdate | OpDelete):
  5031. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  5032. default:
  5033. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5034. }
  5035. }
  5036. // SetCreatedAt sets the "created_at" field.
  5037. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  5038. m.created_at = &t
  5039. }
  5040. // CreatedAt returns the value of the "created_at" field in the mutation.
  5041. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  5042. v := m.created_at
  5043. if v == nil {
  5044. return
  5045. }
  5046. return *v, true
  5047. }
  5048. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  5049. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  5050. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5051. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5052. if !m.op.Is(OpUpdateOne) {
  5053. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5054. }
  5055. if m.id == nil || m.oldValue == nil {
  5056. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5057. }
  5058. oldValue, err := m.oldValue(ctx)
  5059. if err != nil {
  5060. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5061. }
  5062. return oldValue.CreatedAt, nil
  5063. }
  5064. // ResetCreatedAt resets all changes to the "created_at" field.
  5065. func (m *ServerMutation) ResetCreatedAt() {
  5066. m.created_at = nil
  5067. }
  5068. // SetUpdatedAt sets the "updated_at" field.
  5069. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  5070. m.updated_at = &t
  5071. }
  5072. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5073. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  5074. v := m.updated_at
  5075. if v == nil {
  5076. return
  5077. }
  5078. return *v, true
  5079. }
  5080. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  5081. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  5082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5083. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5084. if !m.op.Is(OpUpdateOne) {
  5085. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5086. }
  5087. if m.id == nil || m.oldValue == nil {
  5088. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5089. }
  5090. oldValue, err := m.oldValue(ctx)
  5091. if err != nil {
  5092. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5093. }
  5094. return oldValue.UpdatedAt, nil
  5095. }
  5096. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5097. func (m *ServerMutation) ResetUpdatedAt() {
  5098. m.updated_at = nil
  5099. }
  5100. // SetStatus sets the "status" field.
  5101. func (m *ServerMutation) SetStatus(u uint8) {
  5102. m.status = &u
  5103. m.addstatus = nil
  5104. }
  5105. // Status returns the value of the "status" field in the mutation.
  5106. func (m *ServerMutation) Status() (r uint8, exists bool) {
  5107. v := m.status
  5108. if v == nil {
  5109. return
  5110. }
  5111. return *v, true
  5112. }
  5113. // OldStatus returns the old "status" field's value of the Server entity.
  5114. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  5115. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5116. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  5117. if !m.op.Is(OpUpdateOne) {
  5118. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5119. }
  5120. if m.id == nil || m.oldValue == nil {
  5121. return v, errors.New("OldStatus requires an ID field in the mutation")
  5122. }
  5123. oldValue, err := m.oldValue(ctx)
  5124. if err != nil {
  5125. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5126. }
  5127. return oldValue.Status, nil
  5128. }
  5129. // AddStatus adds u to the "status" field.
  5130. func (m *ServerMutation) AddStatus(u int8) {
  5131. if m.addstatus != nil {
  5132. *m.addstatus += u
  5133. } else {
  5134. m.addstatus = &u
  5135. }
  5136. }
  5137. // AddedStatus returns the value that was added to the "status" field in this mutation.
  5138. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  5139. v := m.addstatus
  5140. if v == nil {
  5141. return
  5142. }
  5143. return *v, true
  5144. }
  5145. // ClearStatus clears the value of the "status" field.
  5146. func (m *ServerMutation) ClearStatus() {
  5147. m.status = nil
  5148. m.addstatus = nil
  5149. m.clearedFields[server.FieldStatus] = struct{}{}
  5150. }
  5151. // StatusCleared returns if the "status" field was cleared in this mutation.
  5152. func (m *ServerMutation) StatusCleared() bool {
  5153. _, ok := m.clearedFields[server.FieldStatus]
  5154. return ok
  5155. }
  5156. // ResetStatus resets all changes to the "status" field.
  5157. func (m *ServerMutation) ResetStatus() {
  5158. m.status = nil
  5159. m.addstatus = nil
  5160. delete(m.clearedFields, server.FieldStatus)
  5161. }
  5162. // SetDeletedAt sets the "deleted_at" field.
  5163. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  5164. m.deleted_at = &t
  5165. }
  5166. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5167. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  5168. v := m.deleted_at
  5169. if v == nil {
  5170. return
  5171. }
  5172. return *v, true
  5173. }
  5174. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  5175. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  5176. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5177. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5178. if !m.op.Is(OpUpdateOne) {
  5179. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5180. }
  5181. if m.id == nil || m.oldValue == nil {
  5182. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5183. }
  5184. oldValue, err := m.oldValue(ctx)
  5185. if err != nil {
  5186. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5187. }
  5188. return oldValue.DeletedAt, nil
  5189. }
  5190. // ClearDeletedAt clears the value of the "deleted_at" field.
  5191. func (m *ServerMutation) ClearDeletedAt() {
  5192. m.deleted_at = nil
  5193. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  5194. }
  5195. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5196. func (m *ServerMutation) DeletedAtCleared() bool {
  5197. _, ok := m.clearedFields[server.FieldDeletedAt]
  5198. return ok
  5199. }
  5200. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5201. func (m *ServerMutation) ResetDeletedAt() {
  5202. m.deleted_at = nil
  5203. delete(m.clearedFields, server.FieldDeletedAt)
  5204. }
  5205. // SetName sets the "name" field.
  5206. func (m *ServerMutation) SetName(s string) {
  5207. m.name = &s
  5208. }
  5209. // Name returns the value of the "name" field in the mutation.
  5210. func (m *ServerMutation) Name() (r string, exists bool) {
  5211. v := m.name
  5212. if v == nil {
  5213. return
  5214. }
  5215. return *v, true
  5216. }
  5217. // OldName returns the old "name" field's value of the Server entity.
  5218. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  5219. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5220. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  5221. if !m.op.Is(OpUpdateOne) {
  5222. return v, errors.New("OldName is only allowed on UpdateOne operations")
  5223. }
  5224. if m.id == nil || m.oldValue == nil {
  5225. return v, errors.New("OldName requires an ID field in the mutation")
  5226. }
  5227. oldValue, err := m.oldValue(ctx)
  5228. if err != nil {
  5229. return v, fmt.Errorf("querying old value for OldName: %w", err)
  5230. }
  5231. return oldValue.Name, nil
  5232. }
  5233. // ResetName resets all changes to the "name" field.
  5234. func (m *ServerMutation) ResetName() {
  5235. m.name = nil
  5236. }
  5237. // SetPublicIP sets the "public_ip" field.
  5238. func (m *ServerMutation) SetPublicIP(s string) {
  5239. m.public_ip = &s
  5240. }
  5241. // PublicIP returns the value of the "public_ip" field in the mutation.
  5242. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  5243. v := m.public_ip
  5244. if v == nil {
  5245. return
  5246. }
  5247. return *v, true
  5248. }
  5249. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  5250. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  5251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5252. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  5253. if !m.op.Is(OpUpdateOne) {
  5254. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  5255. }
  5256. if m.id == nil || m.oldValue == nil {
  5257. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  5258. }
  5259. oldValue, err := m.oldValue(ctx)
  5260. if err != nil {
  5261. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  5262. }
  5263. return oldValue.PublicIP, nil
  5264. }
  5265. // ResetPublicIP resets all changes to the "public_ip" field.
  5266. func (m *ServerMutation) ResetPublicIP() {
  5267. m.public_ip = nil
  5268. }
  5269. // SetPrivateIP sets the "private_ip" field.
  5270. func (m *ServerMutation) SetPrivateIP(s string) {
  5271. m.private_ip = &s
  5272. }
  5273. // PrivateIP returns the value of the "private_ip" field in the mutation.
  5274. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  5275. v := m.private_ip
  5276. if v == nil {
  5277. return
  5278. }
  5279. return *v, true
  5280. }
  5281. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  5282. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  5283. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5284. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  5285. if !m.op.Is(OpUpdateOne) {
  5286. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  5287. }
  5288. if m.id == nil || m.oldValue == nil {
  5289. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  5290. }
  5291. oldValue, err := m.oldValue(ctx)
  5292. if err != nil {
  5293. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  5294. }
  5295. return oldValue.PrivateIP, nil
  5296. }
  5297. // ResetPrivateIP resets all changes to the "private_ip" field.
  5298. func (m *ServerMutation) ResetPrivateIP() {
  5299. m.private_ip = nil
  5300. }
  5301. // SetAdminPort sets the "admin_port" field.
  5302. func (m *ServerMutation) SetAdminPort(s string) {
  5303. m.admin_port = &s
  5304. }
  5305. // AdminPort returns the value of the "admin_port" field in the mutation.
  5306. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  5307. v := m.admin_port
  5308. if v == nil {
  5309. return
  5310. }
  5311. return *v, true
  5312. }
  5313. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  5314. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  5315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5316. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  5317. if !m.op.Is(OpUpdateOne) {
  5318. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  5319. }
  5320. if m.id == nil || m.oldValue == nil {
  5321. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  5322. }
  5323. oldValue, err := m.oldValue(ctx)
  5324. if err != nil {
  5325. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  5326. }
  5327. return oldValue.AdminPort, nil
  5328. }
  5329. // ResetAdminPort resets all changes to the "admin_port" field.
  5330. func (m *ServerMutation) ResetAdminPort() {
  5331. m.admin_port = nil
  5332. }
  5333. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  5334. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  5335. if m.wxs == nil {
  5336. m.wxs = make(map[uint64]struct{})
  5337. }
  5338. for i := range ids {
  5339. m.wxs[ids[i]] = struct{}{}
  5340. }
  5341. }
  5342. // ClearWxs clears the "wxs" edge to the Wx entity.
  5343. func (m *ServerMutation) ClearWxs() {
  5344. m.clearedwxs = true
  5345. }
  5346. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  5347. func (m *ServerMutation) WxsCleared() bool {
  5348. return m.clearedwxs
  5349. }
  5350. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  5351. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  5352. if m.removedwxs == nil {
  5353. m.removedwxs = make(map[uint64]struct{})
  5354. }
  5355. for i := range ids {
  5356. delete(m.wxs, ids[i])
  5357. m.removedwxs[ids[i]] = struct{}{}
  5358. }
  5359. }
  5360. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  5361. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  5362. for id := range m.removedwxs {
  5363. ids = append(ids, id)
  5364. }
  5365. return
  5366. }
  5367. // WxsIDs returns the "wxs" edge IDs in the mutation.
  5368. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  5369. for id := range m.wxs {
  5370. ids = append(ids, id)
  5371. }
  5372. return
  5373. }
  5374. // ResetWxs resets all changes to the "wxs" edge.
  5375. func (m *ServerMutation) ResetWxs() {
  5376. m.wxs = nil
  5377. m.clearedwxs = false
  5378. m.removedwxs = nil
  5379. }
  5380. // Where appends a list predicates to the ServerMutation builder.
  5381. func (m *ServerMutation) Where(ps ...predicate.Server) {
  5382. m.predicates = append(m.predicates, ps...)
  5383. }
  5384. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  5385. // users can use type-assertion to append predicates that do not depend on any generated package.
  5386. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  5387. p := make([]predicate.Server, len(ps))
  5388. for i := range ps {
  5389. p[i] = ps[i]
  5390. }
  5391. m.Where(p...)
  5392. }
  5393. // Op returns the operation name.
  5394. func (m *ServerMutation) Op() Op {
  5395. return m.op
  5396. }
  5397. // SetOp allows setting the mutation operation.
  5398. func (m *ServerMutation) SetOp(op Op) {
  5399. m.op = op
  5400. }
  5401. // Type returns the node type of this mutation (Server).
  5402. func (m *ServerMutation) Type() string {
  5403. return m.typ
  5404. }
  5405. // Fields returns all fields that were changed during this mutation. Note that in
  5406. // order to get all numeric fields that were incremented/decremented, call
  5407. // AddedFields().
  5408. func (m *ServerMutation) Fields() []string {
  5409. fields := make([]string, 0, 8)
  5410. if m.created_at != nil {
  5411. fields = append(fields, server.FieldCreatedAt)
  5412. }
  5413. if m.updated_at != nil {
  5414. fields = append(fields, server.FieldUpdatedAt)
  5415. }
  5416. if m.status != nil {
  5417. fields = append(fields, server.FieldStatus)
  5418. }
  5419. if m.deleted_at != nil {
  5420. fields = append(fields, server.FieldDeletedAt)
  5421. }
  5422. if m.name != nil {
  5423. fields = append(fields, server.FieldName)
  5424. }
  5425. if m.public_ip != nil {
  5426. fields = append(fields, server.FieldPublicIP)
  5427. }
  5428. if m.private_ip != nil {
  5429. fields = append(fields, server.FieldPrivateIP)
  5430. }
  5431. if m.admin_port != nil {
  5432. fields = append(fields, server.FieldAdminPort)
  5433. }
  5434. return fields
  5435. }
  5436. // Field returns the value of a field with the given name. The second boolean
  5437. // return value indicates that this field was not set, or was not defined in the
  5438. // schema.
  5439. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  5440. switch name {
  5441. case server.FieldCreatedAt:
  5442. return m.CreatedAt()
  5443. case server.FieldUpdatedAt:
  5444. return m.UpdatedAt()
  5445. case server.FieldStatus:
  5446. return m.Status()
  5447. case server.FieldDeletedAt:
  5448. return m.DeletedAt()
  5449. case server.FieldName:
  5450. return m.Name()
  5451. case server.FieldPublicIP:
  5452. return m.PublicIP()
  5453. case server.FieldPrivateIP:
  5454. return m.PrivateIP()
  5455. case server.FieldAdminPort:
  5456. return m.AdminPort()
  5457. }
  5458. return nil, false
  5459. }
  5460. // OldField returns the old value of the field from the database. An error is
  5461. // returned if the mutation operation is not UpdateOne, or the query to the
  5462. // database failed.
  5463. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5464. switch name {
  5465. case server.FieldCreatedAt:
  5466. return m.OldCreatedAt(ctx)
  5467. case server.FieldUpdatedAt:
  5468. return m.OldUpdatedAt(ctx)
  5469. case server.FieldStatus:
  5470. return m.OldStatus(ctx)
  5471. case server.FieldDeletedAt:
  5472. return m.OldDeletedAt(ctx)
  5473. case server.FieldName:
  5474. return m.OldName(ctx)
  5475. case server.FieldPublicIP:
  5476. return m.OldPublicIP(ctx)
  5477. case server.FieldPrivateIP:
  5478. return m.OldPrivateIP(ctx)
  5479. case server.FieldAdminPort:
  5480. return m.OldAdminPort(ctx)
  5481. }
  5482. return nil, fmt.Errorf("unknown Server field %s", name)
  5483. }
  5484. // SetField sets the value of a field with the given name. It returns an error if
  5485. // the field is not defined in the schema, or if the type mismatched the field
  5486. // type.
  5487. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  5488. switch name {
  5489. case server.FieldCreatedAt:
  5490. v, ok := value.(time.Time)
  5491. if !ok {
  5492. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5493. }
  5494. m.SetCreatedAt(v)
  5495. return nil
  5496. case server.FieldUpdatedAt:
  5497. v, ok := value.(time.Time)
  5498. if !ok {
  5499. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5500. }
  5501. m.SetUpdatedAt(v)
  5502. return nil
  5503. case server.FieldStatus:
  5504. v, ok := value.(uint8)
  5505. if !ok {
  5506. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5507. }
  5508. m.SetStatus(v)
  5509. return nil
  5510. case server.FieldDeletedAt:
  5511. v, ok := value.(time.Time)
  5512. if !ok {
  5513. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5514. }
  5515. m.SetDeletedAt(v)
  5516. return nil
  5517. case server.FieldName:
  5518. v, ok := value.(string)
  5519. if !ok {
  5520. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5521. }
  5522. m.SetName(v)
  5523. return nil
  5524. case server.FieldPublicIP:
  5525. v, ok := value.(string)
  5526. if !ok {
  5527. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5528. }
  5529. m.SetPublicIP(v)
  5530. return nil
  5531. case server.FieldPrivateIP:
  5532. v, ok := value.(string)
  5533. if !ok {
  5534. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5535. }
  5536. m.SetPrivateIP(v)
  5537. return nil
  5538. case server.FieldAdminPort:
  5539. v, ok := value.(string)
  5540. if !ok {
  5541. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5542. }
  5543. m.SetAdminPort(v)
  5544. return nil
  5545. }
  5546. return fmt.Errorf("unknown Server field %s", name)
  5547. }
  5548. // AddedFields returns all numeric fields that were incremented/decremented during
  5549. // this mutation.
  5550. func (m *ServerMutation) AddedFields() []string {
  5551. var fields []string
  5552. if m.addstatus != nil {
  5553. fields = append(fields, server.FieldStatus)
  5554. }
  5555. return fields
  5556. }
  5557. // AddedField returns the numeric value that was incremented/decremented on a field
  5558. // with the given name. The second boolean return value indicates that this field
  5559. // was not set, or was not defined in the schema.
  5560. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  5561. switch name {
  5562. case server.FieldStatus:
  5563. return m.AddedStatus()
  5564. }
  5565. return nil, false
  5566. }
  5567. // AddField adds the value to the field with the given name. It returns an error if
  5568. // the field is not defined in the schema, or if the type mismatched the field
  5569. // type.
  5570. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  5571. switch name {
  5572. case server.FieldStatus:
  5573. v, ok := value.(int8)
  5574. if !ok {
  5575. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5576. }
  5577. m.AddStatus(v)
  5578. return nil
  5579. }
  5580. return fmt.Errorf("unknown Server numeric field %s", name)
  5581. }
  5582. // ClearedFields returns all nullable fields that were cleared during this
  5583. // mutation.
  5584. func (m *ServerMutation) ClearedFields() []string {
  5585. var fields []string
  5586. if m.FieldCleared(server.FieldStatus) {
  5587. fields = append(fields, server.FieldStatus)
  5588. }
  5589. if m.FieldCleared(server.FieldDeletedAt) {
  5590. fields = append(fields, server.FieldDeletedAt)
  5591. }
  5592. return fields
  5593. }
  5594. // FieldCleared returns a boolean indicating if a field with the given name was
  5595. // cleared in this mutation.
  5596. func (m *ServerMutation) FieldCleared(name string) bool {
  5597. _, ok := m.clearedFields[name]
  5598. return ok
  5599. }
  5600. // ClearField clears the value of the field with the given name. It returns an
  5601. // error if the field is not defined in the schema.
  5602. func (m *ServerMutation) ClearField(name string) error {
  5603. switch name {
  5604. case server.FieldStatus:
  5605. m.ClearStatus()
  5606. return nil
  5607. case server.FieldDeletedAt:
  5608. m.ClearDeletedAt()
  5609. return nil
  5610. }
  5611. return fmt.Errorf("unknown Server nullable field %s", name)
  5612. }
  5613. // ResetField resets all changes in the mutation for the field with the given name.
  5614. // It returns an error if the field is not defined in the schema.
  5615. func (m *ServerMutation) ResetField(name string) error {
  5616. switch name {
  5617. case server.FieldCreatedAt:
  5618. m.ResetCreatedAt()
  5619. return nil
  5620. case server.FieldUpdatedAt:
  5621. m.ResetUpdatedAt()
  5622. return nil
  5623. case server.FieldStatus:
  5624. m.ResetStatus()
  5625. return nil
  5626. case server.FieldDeletedAt:
  5627. m.ResetDeletedAt()
  5628. return nil
  5629. case server.FieldName:
  5630. m.ResetName()
  5631. return nil
  5632. case server.FieldPublicIP:
  5633. m.ResetPublicIP()
  5634. return nil
  5635. case server.FieldPrivateIP:
  5636. m.ResetPrivateIP()
  5637. return nil
  5638. case server.FieldAdminPort:
  5639. m.ResetAdminPort()
  5640. return nil
  5641. }
  5642. return fmt.Errorf("unknown Server field %s", name)
  5643. }
  5644. // AddedEdges returns all edge names that were set/added in this mutation.
  5645. func (m *ServerMutation) AddedEdges() []string {
  5646. edges := make([]string, 0, 1)
  5647. if m.wxs != nil {
  5648. edges = append(edges, server.EdgeWxs)
  5649. }
  5650. return edges
  5651. }
  5652. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5653. // name in this mutation.
  5654. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  5655. switch name {
  5656. case server.EdgeWxs:
  5657. ids := make([]ent.Value, 0, len(m.wxs))
  5658. for id := range m.wxs {
  5659. ids = append(ids, id)
  5660. }
  5661. return ids
  5662. }
  5663. return nil
  5664. }
  5665. // RemovedEdges returns all edge names that were removed in this mutation.
  5666. func (m *ServerMutation) RemovedEdges() []string {
  5667. edges := make([]string, 0, 1)
  5668. if m.removedwxs != nil {
  5669. edges = append(edges, server.EdgeWxs)
  5670. }
  5671. return edges
  5672. }
  5673. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5674. // the given name in this mutation.
  5675. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  5676. switch name {
  5677. case server.EdgeWxs:
  5678. ids := make([]ent.Value, 0, len(m.removedwxs))
  5679. for id := range m.removedwxs {
  5680. ids = append(ids, id)
  5681. }
  5682. return ids
  5683. }
  5684. return nil
  5685. }
  5686. // ClearedEdges returns all edge names that were cleared in this mutation.
  5687. func (m *ServerMutation) ClearedEdges() []string {
  5688. edges := make([]string, 0, 1)
  5689. if m.clearedwxs {
  5690. edges = append(edges, server.EdgeWxs)
  5691. }
  5692. return edges
  5693. }
  5694. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5695. // was cleared in this mutation.
  5696. func (m *ServerMutation) EdgeCleared(name string) bool {
  5697. switch name {
  5698. case server.EdgeWxs:
  5699. return m.clearedwxs
  5700. }
  5701. return false
  5702. }
  5703. // ClearEdge clears the value of the edge with the given name. It returns an error
  5704. // if that edge is not defined in the schema.
  5705. func (m *ServerMutation) ClearEdge(name string) error {
  5706. switch name {
  5707. }
  5708. return fmt.Errorf("unknown Server unique edge %s", name)
  5709. }
  5710. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5711. // It returns an error if the edge is not defined in the schema.
  5712. func (m *ServerMutation) ResetEdge(name string) error {
  5713. switch name {
  5714. case server.EdgeWxs:
  5715. m.ResetWxs()
  5716. return nil
  5717. }
  5718. return fmt.Errorf("unknown Server edge %s", name)
  5719. }
  5720. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  5721. type SopNodeMutation struct {
  5722. config
  5723. op Op
  5724. typ string
  5725. id *uint64
  5726. created_at *time.Time
  5727. updated_at *time.Time
  5728. status *uint8
  5729. addstatus *int8
  5730. deleted_at *time.Time
  5731. parent_id *uint64
  5732. addparent_id *int64
  5733. name *string
  5734. condition_type *int
  5735. addcondition_type *int
  5736. condition_list *[]string
  5737. appendcondition_list []string
  5738. action_message *[]custom_types.Action
  5739. appendaction_message []custom_types.Action
  5740. action_label *[]int
  5741. appendaction_label []int
  5742. clearedFields map[string]struct{}
  5743. sop_stage *uint64
  5744. clearedsop_stage bool
  5745. done bool
  5746. oldValue func(context.Context) (*SopNode, error)
  5747. predicates []predicate.SopNode
  5748. }
  5749. var _ ent.Mutation = (*SopNodeMutation)(nil)
  5750. // sopnodeOption allows management of the mutation configuration using functional options.
  5751. type sopnodeOption func(*SopNodeMutation)
  5752. // newSopNodeMutation creates new mutation for the SopNode entity.
  5753. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  5754. m := &SopNodeMutation{
  5755. config: c,
  5756. op: op,
  5757. typ: TypeSopNode,
  5758. clearedFields: make(map[string]struct{}),
  5759. }
  5760. for _, opt := range opts {
  5761. opt(m)
  5762. }
  5763. return m
  5764. }
  5765. // withSopNodeID sets the ID field of the mutation.
  5766. func withSopNodeID(id uint64) sopnodeOption {
  5767. return func(m *SopNodeMutation) {
  5768. var (
  5769. err error
  5770. once sync.Once
  5771. value *SopNode
  5772. )
  5773. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  5774. once.Do(func() {
  5775. if m.done {
  5776. err = errors.New("querying old values post mutation is not allowed")
  5777. } else {
  5778. value, err = m.Client().SopNode.Get(ctx, id)
  5779. }
  5780. })
  5781. return value, err
  5782. }
  5783. m.id = &id
  5784. }
  5785. }
  5786. // withSopNode sets the old SopNode of the mutation.
  5787. func withSopNode(node *SopNode) sopnodeOption {
  5788. return func(m *SopNodeMutation) {
  5789. m.oldValue = func(context.Context) (*SopNode, error) {
  5790. return node, nil
  5791. }
  5792. m.id = &node.ID
  5793. }
  5794. }
  5795. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5796. // executed in a transaction (ent.Tx), a transactional client is returned.
  5797. func (m SopNodeMutation) Client() *Client {
  5798. client := &Client{config: m.config}
  5799. client.init()
  5800. return client
  5801. }
  5802. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5803. // it returns an error otherwise.
  5804. func (m SopNodeMutation) Tx() (*Tx, error) {
  5805. if _, ok := m.driver.(*txDriver); !ok {
  5806. return nil, errors.New("ent: mutation is not running in a transaction")
  5807. }
  5808. tx := &Tx{config: m.config}
  5809. tx.init()
  5810. return tx, nil
  5811. }
  5812. // SetID sets the value of the id field. Note that this
  5813. // operation is only accepted on creation of SopNode entities.
  5814. func (m *SopNodeMutation) SetID(id uint64) {
  5815. m.id = &id
  5816. }
  5817. // ID returns the ID value in the mutation. Note that the ID is only available
  5818. // if it was provided to the builder or after it was returned from the database.
  5819. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  5820. if m.id == nil {
  5821. return
  5822. }
  5823. return *m.id, true
  5824. }
  5825. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5826. // That means, if the mutation is applied within a transaction with an isolation level such
  5827. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5828. // or updated by the mutation.
  5829. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  5830. switch {
  5831. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5832. id, exists := m.ID()
  5833. if exists {
  5834. return []uint64{id}, nil
  5835. }
  5836. fallthrough
  5837. case m.op.Is(OpUpdate | OpDelete):
  5838. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  5839. default:
  5840. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5841. }
  5842. }
  5843. // SetCreatedAt sets the "created_at" field.
  5844. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  5845. m.created_at = &t
  5846. }
  5847. // CreatedAt returns the value of the "created_at" field in the mutation.
  5848. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  5849. v := m.created_at
  5850. if v == nil {
  5851. return
  5852. }
  5853. return *v, true
  5854. }
  5855. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  5856. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  5857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5858. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5859. if !m.op.Is(OpUpdateOne) {
  5860. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5861. }
  5862. if m.id == nil || m.oldValue == nil {
  5863. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5864. }
  5865. oldValue, err := m.oldValue(ctx)
  5866. if err != nil {
  5867. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5868. }
  5869. return oldValue.CreatedAt, nil
  5870. }
  5871. // ResetCreatedAt resets all changes to the "created_at" field.
  5872. func (m *SopNodeMutation) ResetCreatedAt() {
  5873. m.created_at = nil
  5874. }
  5875. // SetUpdatedAt sets the "updated_at" field.
  5876. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  5877. m.updated_at = &t
  5878. }
  5879. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5880. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  5881. v := m.updated_at
  5882. if v == nil {
  5883. return
  5884. }
  5885. return *v, true
  5886. }
  5887. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  5888. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  5889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5890. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5891. if !m.op.Is(OpUpdateOne) {
  5892. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5893. }
  5894. if m.id == nil || m.oldValue == nil {
  5895. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5896. }
  5897. oldValue, err := m.oldValue(ctx)
  5898. if err != nil {
  5899. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5900. }
  5901. return oldValue.UpdatedAt, nil
  5902. }
  5903. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5904. func (m *SopNodeMutation) ResetUpdatedAt() {
  5905. m.updated_at = nil
  5906. }
  5907. // SetStatus sets the "status" field.
  5908. func (m *SopNodeMutation) SetStatus(u uint8) {
  5909. m.status = &u
  5910. m.addstatus = nil
  5911. }
  5912. // Status returns the value of the "status" field in the mutation.
  5913. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  5914. v := m.status
  5915. if v == nil {
  5916. return
  5917. }
  5918. return *v, true
  5919. }
  5920. // OldStatus returns the old "status" field's value of the SopNode entity.
  5921. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  5922. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5923. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  5924. if !m.op.Is(OpUpdateOne) {
  5925. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5926. }
  5927. if m.id == nil || m.oldValue == nil {
  5928. return v, errors.New("OldStatus requires an ID field in the mutation")
  5929. }
  5930. oldValue, err := m.oldValue(ctx)
  5931. if err != nil {
  5932. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5933. }
  5934. return oldValue.Status, nil
  5935. }
  5936. // AddStatus adds u to the "status" field.
  5937. func (m *SopNodeMutation) AddStatus(u int8) {
  5938. if m.addstatus != nil {
  5939. *m.addstatus += u
  5940. } else {
  5941. m.addstatus = &u
  5942. }
  5943. }
  5944. // AddedStatus returns the value that was added to the "status" field in this mutation.
  5945. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  5946. v := m.addstatus
  5947. if v == nil {
  5948. return
  5949. }
  5950. return *v, true
  5951. }
  5952. // ClearStatus clears the value of the "status" field.
  5953. func (m *SopNodeMutation) ClearStatus() {
  5954. m.status = nil
  5955. m.addstatus = nil
  5956. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  5957. }
  5958. // StatusCleared returns if the "status" field was cleared in this mutation.
  5959. func (m *SopNodeMutation) StatusCleared() bool {
  5960. _, ok := m.clearedFields[sopnode.FieldStatus]
  5961. return ok
  5962. }
  5963. // ResetStatus resets all changes to the "status" field.
  5964. func (m *SopNodeMutation) ResetStatus() {
  5965. m.status = nil
  5966. m.addstatus = nil
  5967. delete(m.clearedFields, sopnode.FieldStatus)
  5968. }
  5969. // SetDeletedAt sets the "deleted_at" field.
  5970. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  5971. m.deleted_at = &t
  5972. }
  5973. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5974. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  5975. v := m.deleted_at
  5976. if v == nil {
  5977. return
  5978. }
  5979. return *v, true
  5980. }
  5981. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  5982. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  5983. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5984. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5985. if !m.op.Is(OpUpdateOne) {
  5986. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5987. }
  5988. if m.id == nil || m.oldValue == nil {
  5989. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5990. }
  5991. oldValue, err := m.oldValue(ctx)
  5992. if err != nil {
  5993. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5994. }
  5995. return oldValue.DeletedAt, nil
  5996. }
  5997. // ClearDeletedAt clears the value of the "deleted_at" field.
  5998. func (m *SopNodeMutation) ClearDeletedAt() {
  5999. m.deleted_at = nil
  6000. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  6001. }
  6002. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6003. func (m *SopNodeMutation) DeletedAtCleared() bool {
  6004. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  6005. return ok
  6006. }
  6007. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6008. func (m *SopNodeMutation) ResetDeletedAt() {
  6009. m.deleted_at = nil
  6010. delete(m.clearedFields, sopnode.FieldDeletedAt)
  6011. }
  6012. // SetStageID sets the "stage_id" field.
  6013. func (m *SopNodeMutation) SetStageID(u uint64) {
  6014. m.sop_stage = &u
  6015. }
  6016. // StageID returns the value of the "stage_id" field in the mutation.
  6017. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  6018. v := m.sop_stage
  6019. if v == nil {
  6020. return
  6021. }
  6022. return *v, true
  6023. }
  6024. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  6025. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  6026. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6027. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  6028. if !m.op.Is(OpUpdateOne) {
  6029. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  6030. }
  6031. if m.id == nil || m.oldValue == nil {
  6032. return v, errors.New("OldStageID requires an ID field in the mutation")
  6033. }
  6034. oldValue, err := m.oldValue(ctx)
  6035. if err != nil {
  6036. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  6037. }
  6038. return oldValue.StageID, nil
  6039. }
  6040. // ResetStageID resets all changes to the "stage_id" field.
  6041. func (m *SopNodeMutation) ResetStageID() {
  6042. m.sop_stage = nil
  6043. }
  6044. // SetParentID sets the "parent_id" field.
  6045. func (m *SopNodeMutation) SetParentID(u uint64) {
  6046. m.parent_id = &u
  6047. m.addparent_id = nil
  6048. }
  6049. // ParentID returns the value of the "parent_id" field in the mutation.
  6050. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  6051. v := m.parent_id
  6052. if v == nil {
  6053. return
  6054. }
  6055. return *v, true
  6056. }
  6057. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  6058. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  6059. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6060. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  6061. if !m.op.Is(OpUpdateOne) {
  6062. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  6063. }
  6064. if m.id == nil || m.oldValue == nil {
  6065. return v, errors.New("OldParentID requires an ID field in the mutation")
  6066. }
  6067. oldValue, err := m.oldValue(ctx)
  6068. if err != nil {
  6069. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  6070. }
  6071. return oldValue.ParentID, nil
  6072. }
  6073. // AddParentID adds u to the "parent_id" field.
  6074. func (m *SopNodeMutation) AddParentID(u int64) {
  6075. if m.addparent_id != nil {
  6076. *m.addparent_id += u
  6077. } else {
  6078. m.addparent_id = &u
  6079. }
  6080. }
  6081. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  6082. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  6083. v := m.addparent_id
  6084. if v == nil {
  6085. return
  6086. }
  6087. return *v, true
  6088. }
  6089. // ResetParentID resets all changes to the "parent_id" field.
  6090. func (m *SopNodeMutation) ResetParentID() {
  6091. m.parent_id = nil
  6092. m.addparent_id = nil
  6093. }
  6094. // SetName sets the "name" field.
  6095. func (m *SopNodeMutation) SetName(s string) {
  6096. m.name = &s
  6097. }
  6098. // Name returns the value of the "name" field in the mutation.
  6099. func (m *SopNodeMutation) Name() (r string, exists bool) {
  6100. v := m.name
  6101. if v == nil {
  6102. return
  6103. }
  6104. return *v, true
  6105. }
  6106. // OldName returns the old "name" field's value of the SopNode entity.
  6107. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  6108. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6109. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  6110. if !m.op.Is(OpUpdateOne) {
  6111. return v, errors.New("OldName is only allowed on UpdateOne operations")
  6112. }
  6113. if m.id == nil || m.oldValue == nil {
  6114. return v, errors.New("OldName requires an ID field in the mutation")
  6115. }
  6116. oldValue, err := m.oldValue(ctx)
  6117. if err != nil {
  6118. return v, fmt.Errorf("querying old value for OldName: %w", err)
  6119. }
  6120. return oldValue.Name, nil
  6121. }
  6122. // ResetName resets all changes to the "name" field.
  6123. func (m *SopNodeMutation) ResetName() {
  6124. m.name = nil
  6125. }
  6126. // SetConditionType sets the "condition_type" field.
  6127. func (m *SopNodeMutation) SetConditionType(i int) {
  6128. m.condition_type = &i
  6129. m.addcondition_type = nil
  6130. }
  6131. // ConditionType returns the value of the "condition_type" field in the mutation.
  6132. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  6133. v := m.condition_type
  6134. if v == nil {
  6135. return
  6136. }
  6137. return *v, true
  6138. }
  6139. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  6140. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  6141. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6142. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  6143. if !m.op.Is(OpUpdateOne) {
  6144. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  6145. }
  6146. if m.id == nil || m.oldValue == nil {
  6147. return v, errors.New("OldConditionType requires an ID field in the mutation")
  6148. }
  6149. oldValue, err := m.oldValue(ctx)
  6150. if err != nil {
  6151. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  6152. }
  6153. return oldValue.ConditionType, nil
  6154. }
  6155. // AddConditionType adds i to the "condition_type" field.
  6156. func (m *SopNodeMutation) AddConditionType(i int) {
  6157. if m.addcondition_type != nil {
  6158. *m.addcondition_type += i
  6159. } else {
  6160. m.addcondition_type = &i
  6161. }
  6162. }
  6163. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  6164. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  6165. v := m.addcondition_type
  6166. if v == nil {
  6167. return
  6168. }
  6169. return *v, true
  6170. }
  6171. // ResetConditionType resets all changes to the "condition_type" field.
  6172. func (m *SopNodeMutation) ResetConditionType() {
  6173. m.condition_type = nil
  6174. m.addcondition_type = nil
  6175. }
  6176. // SetConditionList sets the "condition_list" field.
  6177. func (m *SopNodeMutation) SetConditionList(s []string) {
  6178. m.condition_list = &s
  6179. m.appendcondition_list = nil
  6180. }
  6181. // ConditionList returns the value of the "condition_list" field in the mutation.
  6182. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  6183. v := m.condition_list
  6184. if v == nil {
  6185. return
  6186. }
  6187. return *v, true
  6188. }
  6189. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  6190. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  6191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6192. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  6193. if !m.op.Is(OpUpdateOne) {
  6194. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  6195. }
  6196. if m.id == nil || m.oldValue == nil {
  6197. return v, errors.New("OldConditionList requires an ID field in the mutation")
  6198. }
  6199. oldValue, err := m.oldValue(ctx)
  6200. if err != nil {
  6201. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  6202. }
  6203. return oldValue.ConditionList, nil
  6204. }
  6205. // AppendConditionList adds s to the "condition_list" field.
  6206. func (m *SopNodeMutation) AppendConditionList(s []string) {
  6207. m.appendcondition_list = append(m.appendcondition_list, s...)
  6208. }
  6209. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  6210. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  6211. if len(m.appendcondition_list) == 0 {
  6212. return nil, false
  6213. }
  6214. return m.appendcondition_list, true
  6215. }
  6216. // ClearConditionList clears the value of the "condition_list" field.
  6217. func (m *SopNodeMutation) ClearConditionList() {
  6218. m.condition_list = nil
  6219. m.appendcondition_list = nil
  6220. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  6221. }
  6222. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  6223. func (m *SopNodeMutation) ConditionListCleared() bool {
  6224. _, ok := m.clearedFields[sopnode.FieldConditionList]
  6225. return ok
  6226. }
  6227. // ResetConditionList resets all changes to the "condition_list" field.
  6228. func (m *SopNodeMutation) ResetConditionList() {
  6229. m.condition_list = nil
  6230. m.appendcondition_list = nil
  6231. delete(m.clearedFields, sopnode.FieldConditionList)
  6232. }
  6233. // SetActionMessage sets the "action_message" field.
  6234. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  6235. m.action_message = &ct
  6236. m.appendaction_message = nil
  6237. }
  6238. // ActionMessage returns the value of the "action_message" field in the mutation.
  6239. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  6240. v := m.action_message
  6241. if v == nil {
  6242. return
  6243. }
  6244. return *v, true
  6245. }
  6246. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  6247. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  6248. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6249. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  6250. if !m.op.Is(OpUpdateOne) {
  6251. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  6252. }
  6253. if m.id == nil || m.oldValue == nil {
  6254. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  6255. }
  6256. oldValue, err := m.oldValue(ctx)
  6257. if err != nil {
  6258. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  6259. }
  6260. return oldValue.ActionMessage, nil
  6261. }
  6262. // AppendActionMessage adds ct to the "action_message" field.
  6263. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  6264. m.appendaction_message = append(m.appendaction_message, ct...)
  6265. }
  6266. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  6267. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  6268. if len(m.appendaction_message) == 0 {
  6269. return nil, false
  6270. }
  6271. return m.appendaction_message, true
  6272. }
  6273. // ClearActionMessage clears the value of the "action_message" field.
  6274. func (m *SopNodeMutation) ClearActionMessage() {
  6275. m.action_message = nil
  6276. m.appendaction_message = nil
  6277. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  6278. }
  6279. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  6280. func (m *SopNodeMutation) ActionMessageCleared() bool {
  6281. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  6282. return ok
  6283. }
  6284. // ResetActionMessage resets all changes to the "action_message" field.
  6285. func (m *SopNodeMutation) ResetActionMessage() {
  6286. m.action_message = nil
  6287. m.appendaction_message = nil
  6288. delete(m.clearedFields, sopnode.FieldActionMessage)
  6289. }
  6290. // SetActionLabel sets the "action_label" field.
  6291. func (m *SopNodeMutation) SetActionLabel(i []int) {
  6292. m.action_label = &i
  6293. m.appendaction_label = nil
  6294. }
  6295. // ActionLabel returns the value of the "action_label" field in the mutation.
  6296. func (m *SopNodeMutation) ActionLabel() (r []int, exists bool) {
  6297. v := m.action_label
  6298. if v == nil {
  6299. return
  6300. }
  6301. return *v, true
  6302. }
  6303. // OldActionLabel returns the old "action_label" field's value of the SopNode entity.
  6304. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  6305. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6306. func (m *SopNodeMutation) OldActionLabel(ctx context.Context) (v []int, err error) {
  6307. if !m.op.Is(OpUpdateOne) {
  6308. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  6309. }
  6310. if m.id == nil || m.oldValue == nil {
  6311. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  6312. }
  6313. oldValue, err := m.oldValue(ctx)
  6314. if err != nil {
  6315. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  6316. }
  6317. return oldValue.ActionLabel, nil
  6318. }
  6319. // AppendActionLabel adds i to the "action_label" field.
  6320. func (m *SopNodeMutation) AppendActionLabel(i []int) {
  6321. m.appendaction_label = append(m.appendaction_label, i...)
  6322. }
  6323. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  6324. func (m *SopNodeMutation) AppendedActionLabel() ([]int, bool) {
  6325. if len(m.appendaction_label) == 0 {
  6326. return nil, false
  6327. }
  6328. return m.appendaction_label, true
  6329. }
  6330. // ClearActionLabel clears the value of the "action_label" field.
  6331. func (m *SopNodeMutation) ClearActionLabel() {
  6332. m.action_label = nil
  6333. m.appendaction_label = nil
  6334. m.clearedFields[sopnode.FieldActionLabel] = struct{}{}
  6335. }
  6336. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  6337. func (m *SopNodeMutation) ActionLabelCleared() bool {
  6338. _, ok := m.clearedFields[sopnode.FieldActionLabel]
  6339. return ok
  6340. }
  6341. // ResetActionLabel resets all changes to the "action_label" field.
  6342. func (m *SopNodeMutation) ResetActionLabel() {
  6343. m.action_label = nil
  6344. m.appendaction_label = nil
  6345. delete(m.clearedFields, sopnode.FieldActionLabel)
  6346. }
  6347. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  6348. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  6349. m.sop_stage = &id
  6350. }
  6351. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  6352. func (m *SopNodeMutation) ClearSopStage() {
  6353. m.clearedsop_stage = true
  6354. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  6355. }
  6356. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  6357. func (m *SopNodeMutation) SopStageCleared() bool {
  6358. return m.clearedsop_stage
  6359. }
  6360. // SopStageID returns the "sop_stage" edge ID in the mutation.
  6361. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  6362. if m.sop_stage != nil {
  6363. return *m.sop_stage, true
  6364. }
  6365. return
  6366. }
  6367. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  6368. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  6369. // SopStageID instead. It exists only for internal usage by the builders.
  6370. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  6371. if id := m.sop_stage; id != nil {
  6372. ids = append(ids, *id)
  6373. }
  6374. return
  6375. }
  6376. // ResetSopStage resets all changes to the "sop_stage" edge.
  6377. func (m *SopNodeMutation) ResetSopStage() {
  6378. m.sop_stage = nil
  6379. m.clearedsop_stage = false
  6380. }
  6381. // Where appends a list predicates to the SopNodeMutation builder.
  6382. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  6383. m.predicates = append(m.predicates, ps...)
  6384. }
  6385. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  6386. // users can use type-assertion to append predicates that do not depend on any generated package.
  6387. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  6388. p := make([]predicate.SopNode, len(ps))
  6389. for i := range ps {
  6390. p[i] = ps[i]
  6391. }
  6392. m.Where(p...)
  6393. }
  6394. // Op returns the operation name.
  6395. func (m *SopNodeMutation) Op() Op {
  6396. return m.op
  6397. }
  6398. // SetOp allows setting the mutation operation.
  6399. func (m *SopNodeMutation) SetOp(op Op) {
  6400. m.op = op
  6401. }
  6402. // Type returns the node type of this mutation (SopNode).
  6403. func (m *SopNodeMutation) Type() string {
  6404. return m.typ
  6405. }
  6406. // Fields returns all fields that were changed during this mutation. Note that in
  6407. // order to get all numeric fields that were incremented/decremented, call
  6408. // AddedFields().
  6409. func (m *SopNodeMutation) Fields() []string {
  6410. fields := make([]string, 0, 11)
  6411. if m.created_at != nil {
  6412. fields = append(fields, sopnode.FieldCreatedAt)
  6413. }
  6414. if m.updated_at != nil {
  6415. fields = append(fields, sopnode.FieldUpdatedAt)
  6416. }
  6417. if m.status != nil {
  6418. fields = append(fields, sopnode.FieldStatus)
  6419. }
  6420. if m.deleted_at != nil {
  6421. fields = append(fields, sopnode.FieldDeletedAt)
  6422. }
  6423. if m.sop_stage != nil {
  6424. fields = append(fields, sopnode.FieldStageID)
  6425. }
  6426. if m.parent_id != nil {
  6427. fields = append(fields, sopnode.FieldParentID)
  6428. }
  6429. if m.name != nil {
  6430. fields = append(fields, sopnode.FieldName)
  6431. }
  6432. if m.condition_type != nil {
  6433. fields = append(fields, sopnode.FieldConditionType)
  6434. }
  6435. if m.condition_list != nil {
  6436. fields = append(fields, sopnode.FieldConditionList)
  6437. }
  6438. if m.action_message != nil {
  6439. fields = append(fields, sopnode.FieldActionMessage)
  6440. }
  6441. if m.action_label != nil {
  6442. fields = append(fields, sopnode.FieldActionLabel)
  6443. }
  6444. return fields
  6445. }
  6446. // Field returns the value of a field with the given name. The second boolean
  6447. // return value indicates that this field was not set, or was not defined in the
  6448. // schema.
  6449. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  6450. switch name {
  6451. case sopnode.FieldCreatedAt:
  6452. return m.CreatedAt()
  6453. case sopnode.FieldUpdatedAt:
  6454. return m.UpdatedAt()
  6455. case sopnode.FieldStatus:
  6456. return m.Status()
  6457. case sopnode.FieldDeletedAt:
  6458. return m.DeletedAt()
  6459. case sopnode.FieldStageID:
  6460. return m.StageID()
  6461. case sopnode.FieldParentID:
  6462. return m.ParentID()
  6463. case sopnode.FieldName:
  6464. return m.Name()
  6465. case sopnode.FieldConditionType:
  6466. return m.ConditionType()
  6467. case sopnode.FieldConditionList:
  6468. return m.ConditionList()
  6469. case sopnode.FieldActionMessage:
  6470. return m.ActionMessage()
  6471. case sopnode.FieldActionLabel:
  6472. return m.ActionLabel()
  6473. }
  6474. return nil, false
  6475. }
  6476. // OldField returns the old value of the field from the database. An error is
  6477. // returned if the mutation operation is not UpdateOne, or the query to the
  6478. // database failed.
  6479. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6480. switch name {
  6481. case sopnode.FieldCreatedAt:
  6482. return m.OldCreatedAt(ctx)
  6483. case sopnode.FieldUpdatedAt:
  6484. return m.OldUpdatedAt(ctx)
  6485. case sopnode.FieldStatus:
  6486. return m.OldStatus(ctx)
  6487. case sopnode.FieldDeletedAt:
  6488. return m.OldDeletedAt(ctx)
  6489. case sopnode.FieldStageID:
  6490. return m.OldStageID(ctx)
  6491. case sopnode.FieldParentID:
  6492. return m.OldParentID(ctx)
  6493. case sopnode.FieldName:
  6494. return m.OldName(ctx)
  6495. case sopnode.FieldConditionType:
  6496. return m.OldConditionType(ctx)
  6497. case sopnode.FieldConditionList:
  6498. return m.OldConditionList(ctx)
  6499. case sopnode.FieldActionMessage:
  6500. return m.OldActionMessage(ctx)
  6501. case sopnode.FieldActionLabel:
  6502. return m.OldActionLabel(ctx)
  6503. }
  6504. return nil, fmt.Errorf("unknown SopNode field %s", name)
  6505. }
  6506. // SetField sets the value of a field with the given name. It returns an error if
  6507. // the field is not defined in the schema, or if the type mismatched the field
  6508. // type.
  6509. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  6510. switch name {
  6511. case sopnode.FieldCreatedAt:
  6512. v, ok := value.(time.Time)
  6513. if !ok {
  6514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6515. }
  6516. m.SetCreatedAt(v)
  6517. return nil
  6518. case sopnode.FieldUpdatedAt:
  6519. v, ok := value.(time.Time)
  6520. if !ok {
  6521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6522. }
  6523. m.SetUpdatedAt(v)
  6524. return nil
  6525. case sopnode.FieldStatus:
  6526. v, ok := value.(uint8)
  6527. if !ok {
  6528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6529. }
  6530. m.SetStatus(v)
  6531. return nil
  6532. case sopnode.FieldDeletedAt:
  6533. v, ok := value.(time.Time)
  6534. if !ok {
  6535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6536. }
  6537. m.SetDeletedAt(v)
  6538. return nil
  6539. case sopnode.FieldStageID:
  6540. v, ok := value.(uint64)
  6541. if !ok {
  6542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6543. }
  6544. m.SetStageID(v)
  6545. return nil
  6546. case sopnode.FieldParentID:
  6547. v, ok := value.(uint64)
  6548. if !ok {
  6549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6550. }
  6551. m.SetParentID(v)
  6552. return nil
  6553. case sopnode.FieldName:
  6554. v, ok := value.(string)
  6555. if !ok {
  6556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6557. }
  6558. m.SetName(v)
  6559. return nil
  6560. case sopnode.FieldConditionType:
  6561. v, ok := value.(int)
  6562. if !ok {
  6563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6564. }
  6565. m.SetConditionType(v)
  6566. return nil
  6567. case sopnode.FieldConditionList:
  6568. v, ok := value.([]string)
  6569. if !ok {
  6570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6571. }
  6572. m.SetConditionList(v)
  6573. return nil
  6574. case sopnode.FieldActionMessage:
  6575. v, ok := value.([]custom_types.Action)
  6576. if !ok {
  6577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6578. }
  6579. m.SetActionMessage(v)
  6580. return nil
  6581. case sopnode.FieldActionLabel:
  6582. v, ok := value.([]int)
  6583. if !ok {
  6584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6585. }
  6586. m.SetActionLabel(v)
  6587. return nil
  6588. }
  6589. return fmt.Errorf("unknown SopNode field %s", name)
  6590. }
  6591. // AddedFields returns all numeric fields that were incremented/decremented during
  6592. // this mutation.
  6593. func (m *SopNodeMutation) AddedFields() []string {
  6594. var fields []string
  6595. if m.addstatus != nil {
  6596. fields = append(fields, sopnode.FieldStatus)
  6597. }
  6598. if m.addparent_id != nil {
  6599. fields = append(fields, sopnode.FieldParentID)
  6600. }
  6601. if m.addcondition_type != nil {
  6602. fields = append(fields, sopnode.FieldConditionType)
  6603. }
  6604. return fields
  6605. }
  6606. // AddedField returns the numeric value that was incremented/decremented on a field
  6607. // with the given name. The second boolean return value indicates that this field
  6608. // was not set, or was not defined in the schema.
  6609. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  6610. switch name {
  6611. case sopnode.FieldStatus:
  6612. return m.AddedStatus()
  6613. case sopnode.FieldParentID:
  6614. return m.AddedParentID()
  6615. case sopnode.FieldConditionType:
  6616. return m.AddedConditionType()
  6617. }
  6618. return nil, false
  6619. }
  6620. // AddField adds the value to the field with the given name. It returns an error if
  6621. // the field is not defined in the schema, or if the type mismatched the field
  6622. // type.
  6623. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  6624. switch name {
  6625. case sopnode.FieldStatus:
  6626. v, ok := value.(int8)
  6627. if !ok {
  6628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6629. }
  6630. m.AddStatus(v)
  6631. return nil
  6632. case sopnode.FieldParentID:
  6633. v, ok := value.(int64)
  6634. if !ok {
  6635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6636. }
  6637. m.AddParentID(v)
  6638. return nil
  6639. case sopnode.FieldConditionType:
  6640. v, ok := value.(int)
  6641. if !ok {
  6642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6643. }
  6644. m.AddConditionType(v)
  6645. return nil
  6646. }
  6647. return fmt.Errorf("unknown SopNode numeric field %s", name)
  6648. }
  6649. // ClearedFields returns all nullable fields that were cleared during this
  6650. // mutation.
  6651. func (m *SopNodeMutation) ClearedFields() []string {
  6652. var fields []string
  6653. if m.FieldCleared(sopnode.FieldStatus) {
  6654. fields = append(fields, sopnode.FieldStatus)
  6655. }
  6656. if m.FieldCleared(sopnode.FieldDeletedAt) {
  6657. fields = append(fields, sopnode.FieldDeletedAt)
  6658. }
  6659. if m.FieldCleared(sopnode.FieldConditionList) {
  6660. fields = append(fields, sopnode.FieldConditionList)
  6661. }
  6662. if m.FieldCleared(sopnode.FieldActionMessage) {
  6663. fields = append(fields, sopnode.FieldActionMessage)
  6664. }
  6665. if m.FieldCleared(sopnode.FieldActionLabel) {
  6666. fields = append(fields, sopnode.FieldActionLabel)
  6667. }
  6668. return fields
  6669. }
  6670. // FieldCleared returns a boolean indicating if a field with the given name was
  6671. // cleared in this mutation.
  6672. func (m *SopNodeMutation) FieldCleared(name string) bool {
  6673. _, ok := m.clearedFields[name]
  6674. return ok
  6675. }
  6676. // ClearField clears the value of the field with the given name. It returns an
  6677. // error if the field is not defined in the schema.
  6678. func (m *SopNodeMutation) ClearField(name string) error {
  6679. switch name {
  6680. case sopnode.FieldStatus:
  6681. m.ClearStatus()
  6682. return nil
  6683. case sopnode.FieldDeletedAt:
  6684. m.ClearDeletedAt()
  6685. return nil
  6686. case sopnode.FieldConditionList:
  6687. m.ClearConditionList()
  6688. return nil
  6689. case sopnode.FieldActionMessage:
  6690. m.ClearActionMessage()
  6691. return nil
  6692. case sopnode.FieldActionLabel:
  6693. m.ClearActionLabel()
  6694. return nil
  6695. }
  6696. return fmt.Errorf("unknown SopNode nullable field %s", name)
  6697. }
  6698. // ResetField resets all changes in the mutation for the field with the given name.
  6699. // It returns an error if the field is not defined in the schema.
  6700. func (m *SopNodeMutation) ResetField(name string) error {
  6701. switch name {
  6702. case sopnode.FieldCreatedAt:
  6703. m.ResetCreatedAt()
  6704. return nil
  6705. case sopnode.FieldUpdatedAt:
  6706. m.ResetUpdatedAt()
  6707. return nil
  6708. case sopnode.FieldStatus:
  6709. m.ResetStatus()
  6710. return nil
  6711. case sopnode.FieldDeletedAt:
  6712. m.ResetDeletedAt()
  6713. return nil
  6714. case sopnode.FieldStageID:
  6715. m.ResetStageID()
  6716. return nil
  6717. case sopnode.FieldParentID:
  6718. m.ResetParentID()
  6719. return nil
  6720. case sopnode.FieldName:
  6721. m.ResetName()
  6722. return nil
  6723. case sopnode.FieldConditionType:
  6724. m.ResetConditionType()
  6725. return nil
  6726. case sopnode.FieldConditionList:
  6727. m.ResetConditionList()
  6728. return nil
  6729. case sopnode.FieldActionMessage:
  6730. m.ResetActionMessage()
  6731. return nil
  6732. case sopnode.FieldActionLabel:
  6733. m.ResetActionLabel()
  6734. return nil
  6735. }
  6736. return fmt.Errorf("unknown SopNode field %s", name)
  6737. }
  6738. // AddedEdges returns all edge names that were set/added in this mutation.
  6739. func (m *SopNodeMutation) AddedEdges() []string {
  6740. edges := make([]string, 0, 1)
  6741. if m.sop_stage != nil {
  6742. edges = append(edges, sopnode.EdgeSopStage)
  6743. }
  6744. return edges
  6745. }
  6746. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6747. // name in this mutation.
  6748. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  6749. switch name {
  6750. case sopnode.EdgeSopStage:
  6751. if id := m.sop_stage; id != nil {
  6752. return []ent.Value{*id}
  6753. }
  6754. }
  6755. return nil
  6756. }
  6757. // RemovedEdges returns all edge names that were removed in this mutation.
  6758. func (m *SopNodeMutation) RemovedEdges() []string {
  6759. edges := make([]string, 0, 1)
  6760. return edges
  6761. }
  6762. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6763. // the given name in this mutation.
  6764. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  6765. return nil
  6766. }
  6767. // ClearedEdges returns all edge names that were cleared in this mutation.
  6768. func (m *SopNodeMutation) ClearedEdges() []string {
  6769. edges := make([]string, 0, 1)
  6770. if m.clearedsop_stage {
  6771. edges = append(edges, sopnode.EdgeSopStage)
  6772. }
  6773. return edges
  6774. }
  6775. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6776. // was cleared in this mutation.
  6777. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  6778. switch name {
  6779. case sopnode.EdgeSopStage:
  6780. return m.clearedsop_stage
  6781. }
  6782. return false
  6783. }
  6784. // ClearEdge clears the value of the edge with the given name. It returns an error
  6785. // if that edge is not defined in the schema.
  6786. func (m *SopNodeMutation) ClearEdge(name string) error {
  6787. switch name {
  6788. case sopnode.EdgeSopStage:
  6789. m.ClearSopStage()
  6790. return nil
  6791. }
  6792. return fmt.Errorf("unknown SopNode unique edge %s", name)
  6793. }
  6794. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6795. // It returns an error if the edge is not defined in the schema.
  6796. func (m *SopNodeMutation) ResetEdge(name string) error {
  6797. switch name {
  6798. case sopnode.EdgeSopStage:
  6799. m.ResetSopStage()
  6800. return nil
  6801. }
  6802. return fmt.Errorf("unknown SopNode edge %s", name)
  6803. }
  6804. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  6805. type SopStageMutation struct {
  6806. config
  6807. op Op
  6808. typ string
  6809. id *uint64
  6810. created_at *time.Time
  6811. updated_at *time.Time
  6812. status *uint8
  6813. addstatus *int8
  6814. deleted_at *time.Time
  6815. name *string
  6816. condition_type *int
  6817. addcondition_type *int
  6818. condition_operator *int
  6819. addcondition_operator *int
  6820. condition_list *[]custom_types.Condition
  6821. appendcondition_list []custom_types.Condition
  6822. action_message *[]custom_types.Action
  6823. appendaction_message []custom_types.Action
  6824. action_label *[]int
  6825. appendaction_label []int
  6826. index_sort *int
  6827. addindex_sort *int
  6828. clearedFields map[string]struct{}
  6829. sop_task *uint64
  6830. clearedsop_task bool
  6831. stage_nodes map[uint64]struct{}
  6832. removedstage_nodes map[uint64]struct{}
  6833. clearedstage_nodes bool
  6834. done bool
  6835. oldValue func(context.Context) (*SopStage, error)
  6836. predicates []predicate.SopStage
  6837. }
  6838. var _ ent.Mutation = (*SopStageMutation)(nil)
  6839. // sopstageOption allows management of the mutation configuration using functional options.
  6840. type sopstageOption func(*SopStageMutation)
  6841. // newSopStageMutation creates new mutation for the SopStage entity.
  6842. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  6843. m := &SopStageMutation{
  6844. config: c,
  6845. op: op,
  6846. typ: TypeSopStage,
  6847. clearedFields: make(map[string]struct{}),
  6848. }
  6849. for _, opt := range opts {
  6850. opt(m)
  6851. }
  6852. return m
  6853. }
  6854. // withSopStageID sets the ID field of the mutation.
  6855. func withSopStageID(id uint64) sopstageOption {
  6856. return func(m *SopStageMutation) {
  6857. var (
  6858. err error
  6859. once sync.Once
  6860. value *SopStage
  6861. )
  6862. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  6863. once.Do(func() {
  6864. if m.done {
  6865. err = errors.New("querying old values post mutation is not allowed")
  6866. } else {
  6867. value, err = m.Client().SopStage.Get(ctx, id)
  6868. }
  6869. })
  6870. return value, err
  6871. }
  6872. m.id = &id
  6873. }
  6874. }
  6875. // withSopStage sets the old SopStage of the mutation.
  6876. func withSopStage(node *SopStage) sopstageOption {
  6877. return func(m *SopStageMutation) {
  6878. m.oldValue = func(context.Context) (*SopStage, error) {
  6879. return node, nil
  6880. }
  6881. m.id = &node.ID
  6882. }
  6883. }
  6884. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6885. // executed in a transaction (ent.Tx), a transactional client is returned.
  6886. func (m SopStageMutation) Client() *Client {
  6887. client := &Client{config: m.config}
  6888. client.init()
  6889. return client
  6890. }
  6891. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6892. // it returns an error otherwise.
  6893. func (m SopStageMutation) Tx() (*Tx, error) {
  6894. if _, ok := m.driver.(*txDriver); !ok {
  6895. return nil, errors.New("ent: mutation is not running in a transaction")
  6896. }
  6897. tx := &Tx{config: m.config}
  6898. tx.init()
  6899. return tx, nil
  6900. }
  6901. // SetID sets the value of the id field. Note that this
  6902. // operation is only accepted on creation of SopStage entities.
  6903. func (m *SopStageMutation) SetID(id uint64) {
  6904. m.id = &id
  6905. }
  6906. // ID returns the ID value in the mutation. Note that the ID is only available
  6907. // if it was provided to the builder or after it was returned from the database.
  6908. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  6909. if m.id == nil {
  6910. return
  6911. }
  6912. return *m.id, true
  6913. }
  6914. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6915. // That means, if the mutation is applied within a transaction with an isolation level such
  6916. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6917. // or updated by the mutation.
  6918. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  6919. switch {
  6920. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6921. id, exists := m.ID()
  6922. if exists {
  6923. return []uint64{id}, nil
  6924. }
  6925. fallthrough
  6926. case m.op.Is(OpUpdate | OpDelete):
  6927. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  6928. default:
  6929. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6930. }
  6931. }
  6932. // SetCreatedAt sets the "created_at" field.
  6933. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  6934. m.created_at = &t
  6935. }
  6936. // CreatedAt returns the value of the "created_at" field in the mutation.
  6937. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  6938. v := m.created_at
  6939. if v == nil {
  6940. return
  6941. }
  6942. return *v, true
  6943. }
  6944. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  6945. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  6946. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6947. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6948. if !m.op.Is(OpUpdateOne) {
  6949. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6950. }
  6951. if m.id == nil || m.oldValue == nil {
  6952. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6953. }
  6954. oldValue, err := m.oldValue(ctx)
  6955. if err != nil {
  6956. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6957. }
  6958. return oldValue.CreatedAt, nil
  6959. }
  6960. // ResetCreatedAt resets all changes to the "created_at" field.
  6961. func (m *SopStageMutation) ResetCreatedAt() {
  6962. m.created_at = nil
  6963. }
  6964. // SetUpdatedAt sets the "updated_at" field.
  6965. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  6966. m.updated_at = &t
  6967. }
  6968. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6969. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  6970. v := m.updated_at
  6971. if v == nil {
  6972. return
  6973. }
  6974. return *v, true
  6975. }
  6976. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  6977. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  6978. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6979. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6980. if !m.op.Is(OpUpdateOne) {
  6981. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6982. }
  6983. if m.id == nil || m.oldValue == nil {
  6984. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6985. }
  6986. oldValue, err := m.oldValue(ctx)
  6987. if err != nil {
  6988. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6989. }
  6990. return oldValue.UpdatedAt, nil
  6991. }
  6992. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6993. func (m *SopStageMutation) ResetUpdatedAt() {
  6994. m.updated_at = nil
  6995. }
  6996. // SetStatus sets the "status" field.
  6997. func (m *SopStageMutation) SetStatus(u uint8) {
  6998. m.status = &u
  6999. m.addstatus = nil
  7000. }
  7001. // Status returns the value of the "status" field in the mutation.
  7002. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  7003. v := m.status
  7004. if v == nil {
  7005. return
  7006. }
  7007. return *v, true
  7008. }
  7009. // OldStatus returns the old "status" field's value of the SopStage entity.
  7010. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  7011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7012. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7013. if !m.op.Is(OpUpdateOne) {
  7014. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7015. }
  7016. if m.id == nil || m.oldValue == nil {
  7017. return v, errors.New("OldStatus requires an ID field in the mutation")
  7018. }
  7019. oldValue, err := m.oldValue(ctx)
  7020. if err != nil {
  7021. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7022. }
  7023. return oldValue.Status, nil
  7024. }
  7025. // AddStatus adds u to the "status" field.
  7026. func (m *SopStageMutation) AddStatus(u int8) {
  7027. if m.addstatus != nil {
  7028. *m.addstatus += u
  7029. } else {
  7030. m.addstatus = &u
  7031. }
  7032. }
  7033. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7034. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  7035. v := m.addstatus
  7036. if v == nil {
  7037. return
  7038. }
  7039. return *v, true
  7040. }
  7041. // ClearStatus clears the value of the "status" field.
  7042. func (m *SopStageMutation) ClearStatus() {
  7043. m.status = nil
  7044. m.addstatus = nil
  7045. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  7046. }
  7047. // StatusCleared returns if the "status" field was cleared in this mutation.
  7048. func (m *SopStageMutation) StatusCleared() bool {
  7049. _, ok := m.clearedFields[sopstage.FieldStatus]
  7050. return ok
  7051. }
  7052. // ResetStatus resets all changes to the "status" field.
  7053. func (m *SopStageMutation) ResetStatus() {
  7054. m.status = nil
  7055. m.addstatus = nil
  7056. delete(m.clearedFields, sopstage.FieldStatus)
  7057. }
  7058. // SetDeletedAt sets the "deleted_at" field.
  7059. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  7060. m.deleted_at = &t
  7061. }
  7062. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7063. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  7064. v := m.deleted_at
  7065. if v == nil {
  7066. return
  7067. }
  7068. return *v, true
  7069. }
  7070. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  7071. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  7072. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7073. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7074. if !m.op.Is(OpUpdateOne) {
  7075. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7076. }
  7077. if m.id == nil || m.oldValue == nil {
  7078. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7079. }
  7080. oldValue, err := m.oldValue(ctx)
  7081. if err != nil {
  7082. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7083. }
  7084. return oldValue.DeletedAt, nil
  7085. }
  7086. // ClearDeletedAt clears the value of the "deleted_at" field.
  7087. func (m *SopStageMutation) ClearDeletedAt() {
  7088. m.deleted_at = nil
  7089. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  7090. }
  7091. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7092. func (m *SopStageMutation) DeletedAtCleared() bool {
  7093. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  7094. return ok
  7095. }
  7096. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7097. func (m *SopStageMutation) ResetDeletedAt() {
  7098. m.deleted_at = nil
  7099. delete(m.clearedFields, sopstage.FieldDeletedAt)
  7100. }
  7101. // SetTaskID sets the "task_id" field.
  7102. func (m *SopStageMutation) SetTaskID(u uint64) {
  7103. m.sop_task = &u
  7104. }
  7105. // TaskID returns the value of the "task_id" field in the mutation.
  7106. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  7107. v := m.sop_task
  7108. if v == nil {
  7109. return
  7110. }
  7111. return *v, true
  7112. }
  7113. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  7114. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  7115. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7116. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  7117. if !m.op.Is(OpUpdateOne) {
  7118. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  7119. }
  7120. if m.id == nil || m.oldValue == nil {
  7121. return v, errors.New("OldTaskID requires an ID field in the mutation")
  7122. }
  7123. oldValue, err := m.oldValue(ctx)
  7124. if err != nil {
  7125. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  7126. }
  7127. return oldValue.TaskID, nil
  7128. }
  7129. // ResetTaskID resets all changes to the "task_id" field.
  7130. func (m *SopStageMutation) ResetTaskID() {
  7131. m.sop_task = nil
  7132. }
  7133. // SetName sets the "name" field.
  7134. func (m *SopStageMutation) SetName(s string) {
  7135. m.name = &s
  7136. }
  7137. // Name returns the value of the "name" field in the mutation.
  7138. func (m *SopStageMutation) Name() (r string, exists bool) {
  7139. v := m.name
  7140. if v == nil {
  7141. return
  7142. }
  7143. return *v, true
  7144. }
  7145. // OldName returns the old "name" field's value of the SopStage entity.
  7146. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  7147. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7148. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  7149. if !m.op.Is(OpUpdateOne) {
  7150. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7151. }
  7152. if m.id == nil || m.oldValue == nil {
  7153. return v, errors.New("OldName requires an ID field in the mutation")
  7154. }
  7155. oldValue, err := m.oldValue(ctx)
  7156. if err != nil {
  7157. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7158. }
  7159. return oldValue.Name, nil
  7160. }
  7161. // ResetName resets all changes to the "name" field.
  7162. func (m *SopStageMutation) ResetName() {
  7163. m.name = nil
  7164. }
  7165. // SetConditionType sets the "condition_type" field.
  7166. func (m *SopStageMutation) SetConditionType(i int) {
  7167. m.condition_type = &i
  7168. m.addcondition_type = nil
  7169. }
  7170. // ConditionType returns the value of the "condition_type" field in the mutation.
  7171. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  7172. v := m.condition_type
  7173. if v == nil {
  7174. return
  7175. }
  7176. return *v, true
  7177. }
  7178. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  7179. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  7180. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7181. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  7182. if !m.op.Is(OpUpdateOne) {
  7183. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  7184. }
  7185. if m.id == nil || m.oldValue == nil {
  7186. return v, errors.New("OldConditionType requires an ID field in the mutation")
  7187. }
  7188. oldValue, err := m.oldValue(ctx)
  7189. if err != nil {
  7190. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  7191. }
  7192. return oldValue.ConditionType, nil
  7193. }
  7194. // AddConditionType adds i to the "condition_type" field.
  7195. func (m *SopStageMutation) AddConditionType(i int) {
  7196. if m.addcondition_type != nil {
  7197. *m.addcondition_type += i
  7198. } else {
  7199. m.addcondition_type = &i
  7200. }
  7201. }
  7202. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  7203. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  7204. v := m.addcondition_type
  7205. if v == nil {
  7206. return
  7207. }
  7208. return *v, true
  7209. }
  7210. // ResetConditionType resets all changes to the "condition_type" field.
  7211. func (m *SopStageMutation) ResetConditionType() {
  7212. m.condition_type = nil
  7213. m.addcondition_type = nil
  7214. }
  7215. // SetConditionOperator sets the "condition_operator" field.
  7216. func (m *SopStageMutation) SetConditionOperator(i int) {
  7217. m.condition_operator = &i
  7218. m.addcondition_operator = nil
  7219. }
  7220. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  7221. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  7222. v := m.condition_operator
  7223. if v == nil {
  7224. return
  7225. }
  7226. return *v, true
  7227. }
  7228. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  7229. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  7230. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7231. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  7232. if !m.op.Is(OpUpdateOne) {
  7233. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  7234. }
  7235. if m.id == nil || m.oldValue == nil {
  7236. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  7237. }
  7238. oldValue, err := m.oldValue(ctx)
  7239. if err != nil {
  7240. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  7241. }
  7242. return oldValue.ConditionOperator, nil
  7243. }
  7244. // AddConditionOperator adds i to the "condition_operator" field.
  7245. func (m *SopStageMutation) AddConditionOperator(i int) {
  7246. if m.addcondition_operator != nil {
  7247. *m.addcondition_operator += i
  7248. } else {
  7249. m.addcondition_operator = &i
  7250. }
  7251. }
  7252. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  7253. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  7254. v := m.addcondition_operator
  7255. if v == nil {
  7256. return
  7257. }
  7258. return *v, true
  7259. }
  7260. // ResetConditionOperator resets all changes to the "condition_operator" field.
  7261. func (m *SopStageMutation) ResetConditionOperator() {
  7262. m.condition_operator = nil
  7263. m.addcondition_operator = nil
  7264. }
  7265. // SetConditionList sets the "condition_list" field.
  7266. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  7267. m.condition_list = &ct
  7268. m.appendcondition_list = nil
  7269. }
  7270. // ConditionList returns the value of the "condition_list" field in the mutation.
  7271. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  7272. v := m.condition_list
  7273. if v == nil {
  7274. return
  7275. }
  7276. return *v, true
  7277. }
  7278. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  7279. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  7280. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7281. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  7282. if !m.op.Is(OpUpdateOne) {
  7283. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  7284. }
  7285. if m.id == nil || m.oldValue == nil {
  7286. return v, errors.New("OldConditionList requires an ID field in the mutation")
  7287. }
  7288. oldValue, err := m.oldValue(ctx)
  7289. if err != nil {
  7290. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  7291. }
  7292. return oldValue.ConditionList, nil
  7293. }
  7294. // AppendConditionList adds ct to the "condition_list" field.
  7295. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  7296. m.appendcondition_list = append(m.appendcondition_list, ct...)
  7297. }
  7298. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  7299. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  7300. if len(m.appendcondition_list) == 0 {
  7301. return nil, false
  7302. }
  7303. return m.appendcondition_list, true
  7304. }
  7305. // ResetConditionList resets all changes to the "condition_list" field.
  7306. func (m *SopStageMutation) ResetConditionList() {
  7307. m.condition_list = nil
  7308. m.appendcondition_list = nil
  7309. }
  7310. // SetActionMessage sets the "action_message" field.
  7311. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  7312. m.action_message = &ct
  7313. m.appendaction_message = nil
  7314. }
  7315. // ActionMessage returns the value of the "action_message" field in the mutation.
  7316. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  7317. v := m.action_message
  7318. if v == nil {
  7319. return
  7320. }
  7321. return *v, true
  7322. }
  7323. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  7324. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  7325. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7326. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  7327. if !m.op.Is(OpUpdateOne) {
  7328. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  7329. }
  7330. if m.id == nil || m.oldValue == nil {
  7331. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  7332. }
  7333. oldValue, err := m.oldValue(ctx)
  7334. if err != nil {
  7335. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  7336. }
  7337. return oldValue.ActionMessage, nil
  7338. }
  7339. // AppendActionMessage adds ct to the "action_message" field.
  7340. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  7341. m.appendaction_message = append(m.appendaction_message, ct...)
  7342. }
  7343. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  7344. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  7345. if len(m.appendaction_message) == 0 {
  7346. return nil, false
  7347. }
  7348. return m.appendaction_message, true
  7349. }
  7350. // ClearActionMessage clears the value of the "action_message" field.
  7351. func (m *SopStageMutation) ClearActionMessage() {
  7352. m.action_message = nil
  7353. m.appendaction_message = nil
  7354. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  7355. }
  7356. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  7357. func (m *SopStageMutation) ActionMessageCleared() bool {
  7358. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  7359. return ok
  7360. }
  7361. // ResetActionMessage resets all changes to the "action_message" field.
  7362. func (m *SopStageMutation) ResetActionMessage() {
  7363. m.action_message = nil
  7364. m.appendaction_message = nil
  7365. delete(m.clearedFields, sopstage.FieldActionMessage)
  7366. }
  7367. // SetActionLabel sets the "action_label" field.
  7368. func (m *SopStageMutation) SetActionLabel(i []int) {
  7369. m.action_label = &i
  7370. m.appendaction_label = nil
  7371. }
  7372. // ActionLabel returns the value of the "action_label" field in the mutation.
  7373. func (m *SopStageMutation) ActionLabel() (r []int, exists bool) {
  7374. v := m.action_label
  7375. if v == nil {
  7376. return
  7377. }
  7378. return *v, true
  7379. }
  7380. // OldActionLabel returns the old "action_label" field's value of the SopStage entity.
  7381. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  7382. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7383. func (m *SopStageMutation) OldActionLabel(ctx context.Context) (v []int, err error) {
  7384. if !m.op.Is(OpUpdateOne) {
  7385. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  7386. }
  7387. if m.id == nil || m.oldValue == nil {
  7388. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  7389. }
  7390. oldValue, err := m.oldValue(ctx)
  7391. if err != nil {
  7392. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  7393. }
  7394. return oldValue.ActionLabel, nil
  7395. }
  7396. // AppendActionLabel adds i to the "action_label" field.
  7397. func (m *SopStageMutation) AppendActionLabel(i []int) {
  7398. m.appendaction_label = append(m.appendaction_label, i...)
  7399. }
  7400. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  7401. func (m *SopStageMutation) AppendedActionLabel() ([]int, bool) {
  7402. if len(m.appendaction_label) == 0 {
  7403. return nil, false
  7404. }
  7405. return m.appendaction_label, true
  7406. }
  7407. // ClearActionLabel clears the value of the "action_label" field.
  7408. func (m *SopStageMutation) ClearActionLabel() {
  7409. m.action_label = nil
  7410. m.appendaction_label = nil
  7411. m.clearedFields[sopstage.FieldActionLabel] = struct{}{}
  7412. }
  7413. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  7414. func (m *SopStageMutation) ActionLabelCleared() bool {
  7415. _, ok := m.clearedFields[sopstage.FieldActionLabel]
  7416. return ok
  7417. }
  7418. // ResetActionLabel resets all changes to the "action_label" field.
  7419. func (m *SopStageMutation) ResetActionLabel() {
  7420. m.action_label = nil
  7421. m.appendaction_label = nil
  7422. delete(m.clearedFields, sopstage.FieldActionLabel)
  7423. }
  7424. // SetIndexSort sets the "index_sort" field.
  7425. func (m *SopStageMutation) SetIndexSort(i int) {
  7426. m.index_sort = &i
  7427. m.addindex_sort = nil
  7428. }
  7429. // IndexSort returns the value of the "index_sort" field in the mutation.
  7430. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  7431. v := m.index_sort
  7432. if v == nil {
  7433. return
  7434. }
  7435. return *v, true
  7436. }
  7437. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  7438. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  7439. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7440. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  7441. if !m.op.Is(OpUpdateOne) {
  7442. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  7443. }
  7444. if m.id == nil || m.oldValue == nil {
  7445. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  7446. }
  7447. oldValue, err := m.oldValue(ctx)
  7448. if err != nil {
  7449. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  7450. }
  7451. return oldValue.IndexSort, nil
  7452. }
  7453. // AddIndexSort adds i to the "index_sort" field.
  7454. func (m *SopStageMutation) AddIndexSort(i int) {
  7455. if m.addindex_sort != nil {
  7456. *m.addindex_sort += i
  7457. } else {
  7458. m.addindex_sort = &i
  7459. }
  7460. }
  7461. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  7462. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  7463. v := m.addindex_sort
  7464. if v == nil {
  7465. return
  7466. }
  7467. return *v, true
  7468. }
  7469. // ClearIndexSort clears the value of the "index_sort" field.
  7470. func (m *SopStageMutation) ClearIndexSort() {
  7471. m.index_sort = nil
  7472. m.addindex_sort = nil
  7473. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  7474. }
  7475. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  7476. func (m *SopStageMutation) IndexSortCleared() bool {
  7477. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  7478. return ok
  7479. }
  7480. // ResetIndexSort resets all changes to the "index_sort" field.
  7481. func (m *SopStageMutation) ResetIndexSort() {
  7482. m.index_sort = nil
  7483. m.addindex_sort = nil
  7484. delete(m.clearedFields, sopstage.FieldIndexSort)
  7485. }
  7486. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  7487. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  7488. m.sop_task = &id
  7489. }
  7490. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  7491. func (m *SopStageMutation) ClearSopTask() {
  7492. m.clearedsop_task = true
  7493. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  7494. }
  7495. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  7496. func (m *SopStageMutation) SopTaskCleared() bool {
  7497. return m.clearedsop_task
  7498. }
  7499. // SopTaskID returns the "sop_task" edge ID in the mutation.
  7500. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  7501. if m.sop_task != nil {
  7502. return *m.sop_task, true
  7503. }
  7504. return
  7505. }
  7506. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  7507. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  7508. // SopTaskID instead. It exists only for internal usage by the builders.
  7509. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  7510. if id := m.sop_task; id != nil {
  7511. ids = append(ids, *id)
  7512. }
  7513. return
  7514. }
  7515. // ResetSopTask resets all changes to the "sop_task" edge.
  7516. func (m *SopStageMutation) ResetSopTask() {
  7517. m.sop_task = nil
  7518. m.clearedsop_task = false
  7519. }
  7520. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  7521. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  7522. if m.stage_nodes == nil {
  7523. m.stage_nodes = make(map[uint64]struct{})
  7524. }
  7525. for i := range ids {
  7526. m.stage_nodes[ids[i]] = struct{}{}
  7527. }
  7528. }
  7529. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  7530. func (m *SopStageMutation) ClearStageNodes() {
  7531. m.clearedstage_nodes = true
  7532. }
  7533. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  7534. func (m *SopStageMutation) StageNodesCleared() bool {
  7535. return m.clearedstage_nodes
  7536. }
  7537. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  7538. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  7539. if m.removedstage_nodes == nil {
  7540. m.removedstage_nodes = make(map[uint64]struct{})
  7541. }
  7542. for i := range ids {
  7543. delete(m.stage_nodes, ids[i])
  7544. m.removedstage_nodes[ids[i]] = struct{}{}
  7545. }
  7546. }
  7547. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  7548. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  7549. for id := range m.removedstage_nodes {
  7550. ids = append(ids, id)
  7551. }
  7552. return
  7553. }
  7554. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  7555. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  7556. for id := range m.stage_nodes {
  7557. ids = append(ids, id)
  7558. }
  7559. return
  7560. }
  7561. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  7562. func (m *SopStageMutation) ResetStageNodes() {
  7563. m.stage_nodes = nil
  7564. m.clearedstage_nodes = false
  7565. m.removedstage_nodes = nil
  7566. }
  7567. // Where appends a list predicates to the SopStageMutation builder.
  7568. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  7569. m.predicates = append(m.predicates, ps...)
  7570. }
  7571. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  7572. // users can use type-assertion to append predicates that do not depend on any generated package.
  7573. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  7574. p := make([]predicate.SopStage, len(ps))
  7575. for i := range ps {
  7576. p[i] = ps[i]
  7577. }
  7578. m.Where(p...)
  7579. }
  7580. // Op returns the operation name.
  7581. func (m *SopStageMutation) Op() Op {
  7582. return m.op
  7583. }
  7584. // SetOp allows setting the mutation operation.
  7585. func (m *SopStageMutation) SetOp(op Op) {
  7586. m.op = op
  7587. }
  7588. // Type returns the node type of this mutation (SopStage).
  7589. func (m *SopStageMutation) Type() string {
  7590. return m.typ
  7591. }
  7592. // Fields returns all fields that were changed during this mutation. Note that in
  7593. // order to get all numeric fields that were incremented/decremented, call
  7594. // AddedFields().
  7595. func (m *SopStageMutation) Fields() []string {
  7596. fields := make([]string, 0, 12)
  7597. if m.created_at != nil {
  7598. fields = append(fields, sopstage.FieldCreatedAt)
  7599. }
  7600. if m.updated_at != nil {
  7601. fields = append(fields, sopstage.FieldUpdatedAt)
  7602. }
  7603. if m.status != nil {
  7604. fields = append(fields, sopstage.FieldStatus)
  7605. }
  7606. if m.deleted_at != nil {
  7607. fields = append(fields, sopstage.FieldDeletedAt)
  7608. }
  7609. if m.sop_task != nil {
  7610. fields = append(fields, sopstage.FieldTaskID)
  7611. }
  7612. if m.name != nil {
  7613. fields = append(fields, sopstage.FieldName)
  7614. }
  7615. if m.condition_type != nil {
  7616. fields = append(fields, sopstage.FieldConditionType)
  7617. }
  7618. if m.condition_operator != nil {
  7619. fields = append(fields, sopstage.FieldConditionOperator)
  7620. }
  7621. if m.condition_list != nil {
  7622. fields = append(fields, sopstage.FieldConditionList)
  7623. }
  7624. if m.action_message != nil {
  7625. fields = append(fields, sopstage.FieldActionMessage)
  7626. }
  7627. if m.action_label != nil {
  7628. fields = append(fields, sopstage.FieldActionLabel)
  7629. }
  7630. if m.index_sort != nil {
  7631. fields = append(fields, sopstage.FieldIndexSort)
  7632. }
  7633. return fields
  7634. }
  7635. // Field returns the value of a field with the given name. The second boolean
  7636. // return value indicates that this field was not set, or was not defined in the
  7637. // schema.
  7638. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  7639. switch name {
  7640. case sopstage.FieldCreatedAt:
  7641. return m.CreatedAt()
  7642. case sopstage.FieldUpdatedAt:
  7643. return m.UpdatedAt()
  7644. case sopstage.FieldStatus:
  7645. return m.Status()
  7646. case sopstage.FieldDeletedAt:
  7647. return m.DeletedAt()
  7648. case sopstage.FieldTaskID:
  7649. return m.TaskID()
  7650. case sopstage.FieldName:
  7651. return m.Name()
  7652. case sopstage.FieldConditionType:
  7653. return m.ConditionType()
  7654. case sopstage.FieldConditionOperator:
  7655. return m.ConditionOperator()
  7656. case sopstage.FieldConditionList:
  7657. return m.ConditionList()
  7658. case sopstage.FieldActionMessage:
  7659. return m.ActionMessage()
  7660. case sopstage.FieldActionLabel:
  7661. return m.ActionLabel()
  7662. case sopstage.FieldIndexSort:
  7663. return m.IndexSort()
  7664. }
  7665. return nil, false
  7666. }
  7667. // OldField returns the old value of the field from the database. An error is
  7668. // returned if the mutation operation is not UpdateOne, or the query to the
  7669. // database failed.
  7670. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7671. switch name {
  7672. case sopstage.FieldCreatedAt:
  7673. return m.OldCreatedAt(ctx)
  7674. case sopstage.FieldUpdatedAt:
  7675. return m.OldUpdatedAt(ctx)
  7676. case sopstage.FieldStatus:
  7677. return m.OldStatus(ctx)
  7678. case sopstage.FieldDeletedAt:
  7679. return m.OldDeletedAt(ctx)
  7680. case sopstage.FieldTaskID:
  7681. return m.OldTaskID(ctx)
  7682. case sopstage.FieldName:
  7683. return m.OldName(ctx)
  7684. case sopstage.FieldConditionType:
  7685. return m.OldConditionType(ctx)
  7686. case sopstage.FieldConditionOperator:
  7687. return m.OldConditionOperator(ctx)
  7688. case sopstage.FieldConditionList:
  7689. return m.OldConditionList(ctx)
  7690. case sopstage.FieldActionMessage:
  7691. return m.OldActionMessage(ctx)
  7692. case sopstage.FieldActionLabel:
  7693. return m.OldActionLabel(ctx)
  7694. case sopstage.FieldIndexSort:
  7695. return m.OldIndexSort(ctx)
  7696. }
  7697. return nil, fmt.Errorf("unknown SopStage field %s", name)
  7698. }
  7699. // SetField sets the value of a field with the given name. It returns an error if
  7700. // the field is not defined in the schema, or if the type mismatched the field
  7701. // type.
  7702. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  7703. switch name {
  7704. case sopstage.FieldCreatedAt:
  7705. v, ok := value.(time.Time)
  7706. if !ok {
  7707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7708. }
  7709. m.SetCreatedAt(v)
  7710. return nil
  7711. case sopstage.FieldUpdatedAt:
  7712. v, ok := value.(time.Time)
  7713. if !ok {
  7714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7715. }
  7716. m.SetUpdatedAt(v)
  7717. return nil
  7718. case sopstage.FieldStatus:
  7719. v, ok := value.(uint8)
  7720. if !ok {
  7721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7722. }
  7723. m.SetStatus(v)
  7724. return nil
  7725. case sopstage.FieldDeletedAt:
  7726. v, ok := value.(time.Time)
  7727. if !ok {
  7728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7729. }
  7730. m.SetDeletedAt(v)
  7731. return nil
  7732. case sopstage.FieldTaskID:
  7733. v, ok := value.(uint64)
  7734. if !ok {
  7735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7736. }
  7737. m.SetTaskID(v)
  7738. return nil
  7739. case sopstage.FieldName:
  7740. v, ok := value.(string)
  7741. if !ok {
  7742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7743. }
  7744. m.SetName(v)
  7745. return nil
  7746. case sopstage.FieldConditionType:
  7747. v, ok := value.(int)
  7748. if !ok {
  7749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7750. }
  7751. m.SetConditionType(v)
  7752. return nil
  7753. case sopstage.FieldConditionOperator:
  7754. v, ok := value.(int)
  7755. if !ok {
  7756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7757. }
  7758. m.SetConditionOperator(v)
  7759. return nil
  7760. case sopstage.FieldConditionList:
  7761. v, ok := value.([]custom_types.Condition)
  7762. if !ok {
  7763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7764. }
  7765. m.SetConditionList(v)
  7766. return nil
  7767. case sopstage.FieldActionMessage:
  7768. v, ok := value.([]custom_types.Action)
  7769. if !ok {
  7770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7771. }
  7772. m.SetActionMessage(v)
  7773. return nil
  7774. case sopstage.FieldActionLabel:
  7775. v, ok := value.([]int)
  7776. if !ok {
  7777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7778. }
  7779. m.SetActionLabel(v)
  7780. return nil
  7781. case sopstage.FieldIndexSort:
  7782. v, ok := value.(int)
  7783. if !ok {
  7784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7785. }
  7786. m.SetIndexSort(v)
  7787. return nil
  7788. }
  7789. return fmt.Errorf("unknown SopStage field %s", name)
  7790. }
  7791. // AddedFields returns all numeric fields that were incremented/decremented during
  7792. // this mutation.
  7793. func (m *SopStageMutation) AddedFields() []string {
  7794. var fields []string
  7795. if m.addstatus != nil {
  7796. fields = append(fields, sopstage.FieldStatus)
  7797. }
  7798. if m.addcondition_type != nil {
  7799. fields = append(fields, sopstage.FieldConditionType)
  7800. }
  7801. if m.addcondition_operator != nil {
  7802. fields = append(fields, sopstage.FieldConditionOperator)
  7803. }
  7804. if m.addindex_sort != nil {
  7805. fields = append(fields, sopstage.FieldIndexSort)
  7806. }
  7807. return fields
  7808. }
  7809. // AddedField returns the numeric value that was incremented/decremented on a field
  7810. // with the given name. The second boolean return value indicates that this field
  7811. // was not set, or was not defined in the schema.
  7812. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  7813. switch name {
  7814. case sopstage.FieldStatus:
  7815. return m.AddedStatus()
  7816. case sopstage.FieldConditionType:
  7817. return m.AddedConditionType()
  7818. case sopstage.FieldConditionOperator:
  7819. return m.AddedConditionOperator()
  7820. case sopstage.FieldIndexSort:
  7821. return m.AddedIndexSort()
  7822. }
  7823. return nil, false
  7824. }
  7825. // AddField adds the value to the field with the given name. It returns an error if
  7826. // the field is not defined in the schema, or if the type mismatched the field
  7827. // type.
  7828. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  7829. switch name {
  7830. case sopstage.FieldStatus:
  7831. v, ok := value.(int8)
  7832. if !ok {
  7833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7834. }
  7835. m.AddStatus(v)
  7836. return nil
  7837. case sopstage.FieldConditionType:
  7838. v, ok := value.(int)
  7839. if !ok {
  7840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7841. }
  7842. m.AddConditionType(v)
  7843. return nil
  7844. case sopstage.FieldConditionOperator:
  7845. v, ok := value.(int)
  7846. if !ok {
  7847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7848. }
  7849. m.AddConditionOperator(v)
  7850. return nil
  7851. case sopstage.FieldIndexSort:
  7852. v, ok := value.(int)
  7853. if !ok {
  7854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7855. }
  7856. m.AddIndexSort(v)
  7857. return nil
  7858. }
  7859. return fmt.Errorf("unknown SopStage numeric field %s", name)
  7860. }
  7861. // ClearedFields returns all nullable fields that were cleared during this
  7862. // mutation.
  7863. func (m *SopStageMutation) ClearedFields() []string {
  7864. var fields []string
  7865. if m.FieldCleared(sopstage.FieldStatus) {
  7866. fields = append(fields, sopstage.FieldStatus)
  7867. }
  7868. if m.FieldCleared(sopstage.FieldDeletedAt) {
  7869. fields = append(fields, sopstage.FieldDeletedAt)
  7870. }
  7871. if m.FieldCleared(sopstage.FieldActionMessage) {
  7872. fields = append(fields, sopstage.FieldActionMessage)
  7873. }
  7874. if m.FieldCleared(sopstage.FieldActionLabel) {
  7875. fields = append(fields, sopstage.FieldActionLabel)
  7876. }
  7877. if m.FieldCleared(sopstage.FieldIndexSort) {
  7878. fields = append(fields, sopstage.FieldIndexSort)
  7879. }
  7880. return fields
  7881. }
  7882. // FieldCleared returns a boolean indicating if a field with the given name was
  7883. // cleared in this mutation.
  7884. func (m *SopStageMutation) FieldCleared(name string) bool {
  7885. _, ok := m.clearedFields[name]
  7886. return ok
  7887. }
  7888. // ClearField clears the value of the field with the given name. It returns an
  7889. // error if the field is not defined in the schema.
  7890. func (m *SopStageMutation) ClearField(name string) error {
  7891. switch name {
  7892. case sopstage.FieldStatus:
  7893. m.ClearStatus()
  7894. return nil
  7895. case sopstage.FieldDeletedAt:
  7896. m.ClearDeletedAt()
  7897. return nil
  7898. case sopstage.FieldActionMessage:
  7899. m.ClearActionMessage()
  7900. return nil
  7901. case sopstage.FieldActionLabel:
  7902. m.ClearActionLabel()
  7903. return nil
  7904. case sopstage.FieldIndexSort:
  7905. m.ClearIndexSort()
  7906. return nil
  7907. }
  7908. return fmt.Errorf("unknown SopStage nullable field %s", name)
  7909. }
  7910. // ResetField resets all changes in the mutation for the field with the given name.
  7911. // It returns an error if the field is not defined in the schema.
  7912. func (m *SopStageMutation) ResetField(name string) error {
  7913. switch name {
  7914. case sopstage.FieldCreatedAt:
  7915. m.ResetCreatedAt()
  7916. return nil
  7917. case sopstage.FieldUpdatedAt:
  7918. m.ResetUpdatedAt()
  7919. return nil
  7920. case sopstage.FieldStatus:
  7921. m.ResetStatus()
  7922. return nil
  7923. case sopstage.FieldDeletedAt:
  7924. m.ResetDeletedAt()
  7925. return nil
  7926. case sopstage.FieldTaskID:
  7927. m.ResetTaskID()
  7928. return nil
  7929. case sopstage.FieldName:
  7930. m.ResetName()
  7931. return nil
  7932. case sopstage.FieldConditionType:
  7933. m.ResetConditionType()
  7934. return nil
  7935. case sopstage.FieldConditionOperator:
  7936. m.ResetConditionOperator()
  7937. return nil
  7938. case sopstage.FieldConditionList:
  7939. m.ResetConditionList()
  7940. return nil
  7941. case sopstage.FieldActionMessage:
  7942. m.ResetActionMessage()
  7943. return nil
  7944. case sopstage.FieldActionLabel:
  7945. m.ResetActionLabel()
  7946. return nil
  7947. case sopstage.FieldIndexSort:
  7948. m.ResetIndexSort()
  7949. return nil
  7950. }
  7951. return fmt.Errorf("unknown SopStage field %s", name)
  7952. }
  7953. // AddedEdges returns all edge names that were set/added in this mutation.
  7954. func (m *SopStageMutation) AddedEdges() []string {
  7955. edges := make([]string, 0, 2)
  7956. if m.sop_task != nil {
  7957. edges = append(edges, sopstage.EdgeSopTask)
  7958. }
  7959. if m.stage_nodes != nil {
  7960. edges = append(edges, sopstage.EdgeStageNodes)
  7961. }
  7962. return edges
  7963. }
  7964. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7965. // name in this mutation.
  7966. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  7967. switch name {
  7968. case sopstage.EdgeSopTask:
  7969. if id := m.sop_task; id != nil {
  7970. return []ent.Value{*id}
  7971. }
  7972. case sopstage.EdgeStageNodes:
  7973. ids := make([]ent.Value, 0, len(m.stage_nodes))
  7974. for id := range m.stage_nodes {
  7975. ids = append(ids, id)
  7976. }
  7977. return ids
  7978. }
  7979. return nil
  7980. }
  7981. // RemovedEdges returns all edge names that were removed in this mutation.
  7982. func (m *SopStageMutation) RemovedEdges() []string {
  7983. edges := make([]string, 0, 2)
  7984. if m.removedstage_nodes != nil {
  7985. edges = append(edges, sopstage.EdgeStageNodes)
  7986. }
  7987. return edges
  7988. }
  7989. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7990. // the given name in this mutation.
  7991. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  7992. switch name {
  7993. case sopstage.EdgeStageNodes:
  7994. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  7995. for id := range m.removedstage_nodes {
  7996. ids = append(ids, id)
  7997. }
  7998. return ids
  7999. }
  8000. return nil
  8001. }
  8002. // ClearedEdges returns all edge names that were cleared in this mutation.
  8003. func (m *SopStageMutation) ClearedEdges() []string {
  8004. edges := make([]string, 0, 2)
  8005. if m.clearedsop_task {
  8006. edges = append(edges, sopstage.EdgeSopTask)
  8007. }
  8008. if m.clearedstage_nodes {
  8009. edges = append(edges, sopstage.EdgeStageNodes)
  8010. }
  8011. return edges
  8012. }
  8013. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8014. // was cleared in this mutation.
  8015. func (m *SopStageMutation) EdgeCleared(name string) bool {
  8016. switch name {
  8017. case sopstage.EdgeSopTask:
  8018. return m.clearedsop_task
  8019. case sopstage.EdgeStageNodes:
  8020. return m.clearedstage_nodes
  8021. }
  8022. return false
  8023. }
  8024. // ClearEdge clears the value of the edge with the given name. It returns an error
  8025. // if that edge is not defined in the schema.
  8026. func (m *SopStageMutation) ClearEdge(name string) error {
  8027. switch name {
  8028. case sopstage.EdgeSopTask:
  8029. m.ClearSopTask()
  8030. return nil
  8031. }
  8032. return fmt.Errorf("unknown SopStage unique edge %s", name)
  8033. }
  8034. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8035. // It returns an error if the edge is not defined in the schema.
  8036. func (m *SopStageMutation) ResetEdge(name string) error {
  8037. switch name {
  8038. case sopstage.EdgeSopTask:
  8039. m.ResetSopTask()
  8040. return nil
  8041. case sopstage.EdgeStageNodes:
  8042. m.ResetStageNodes()
  8043. return nil
  8044. }
  8045. return fmt.Errorf("unknown SopStage edge %s", name)
  8046. }
  8047. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  8048. type SopTaskMutation struct {
  8049. config
  8050. op Op
  8051. typ string
  8052. id *uint64
  8053. created_at *time.Time
  8054. updated_at *time.Time
  8055. status *uint8
  8056. addstatus *int8
  8057. deleted_at *time.Time
  8058. name *string
  8059. bot_wxid_list *[]string
  8060. appendbot_wxid_list []string
  8061. _type *int
  8062. add_type *int
  8063. plan_start_time *time.Time
  8064. plan_end_time *time.Time
  8065. creator_id *string
  8066. clearedFields map[string]struct{}
  8067. task_stages map[uint64]struct{}
  8068. removedtask_stages map[uint64]struct{}
  8069. clearedtask_stages bool
  8070. done bool
  8071. oldValue func(context.Context) (*SopTask, error)
  8072. predicates []predicate.SopTask
  8073. }
  8074. var _ ent.Mutation = (*SopTaskMutation)(nil)
  8075. // soptaskOption allows management of the mutation configuration using functional options.
  8076. type soptaskOption func(*SopTaskMutation)
  8077. // newSopTaskMutation creates new mutation for the SopTask entity.
  8078. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  8079. m := &SopTaskMutation{
  8080. config: c,
  8081. op: op,
  8082. typ: TypeSopTask,
  8083. clearedFields: make(map[string]struct{}),
  8084. }
  8085. for _, opt := range opts {
  8086. opt(m)
  8087. }
  8088. return m
  8089. }
  8090. // withSopTaskID sets the ID field of the mutation.
  8091. func withSopTaskID(id uint64) soptaskOption {
  8092. return func(m *SopTaskMutation) {
  8093. var (
  8094. err error
  8095. once sync.Once
  8096. value *SopTask
  8097. )
  8098. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  8099. once.Do(func() {
  8100. if m.done {
  8101. err = errors.New("querying old values post mutation is not allowed")
  8102. } else {
  8103. value, err = m.Client().SopTask.Get(ctx, id)
  8104. }
  8105. })
  8106. return value, err
  8107. }
  8108. m.id = &id
  8109. }
  8110. }
  8111. // withSopTask sets the old SopTask of the mutation.
  8112. func withSopTask(node *SopTask) soptaskOption {
  8113. return func(m *SopTaskMutation) {
  8114. m.oldValue = func(context.Context) (*SopTask, error) {
  8115. return node, nil
  8116. }
  8117. m.id = &node.ID
  8118. }
  8119. }
  8120. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8121. // executed in a transaction (ent.Tx), a transactional client is returned.
  8122. func (m SopTaskMutation) Client() *Client {
  8123. client := &Client{config: m.config}
  8124. client.init()
  8125. return client
  8126. }
  8127. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8128. // it returns an error otherwise.
  8129. func (m SopTaskMutation) Tx() (*Tx, error) {
  8130. if _, ok := m.driver.(*txDriver); !ok {
  8131. return nil, errors.New("ent: mutation is not running in a transaction")
  8132. }
  8133. tx := &Tx{config: m.config}
  8134. tx.init()
  8135. return tx, nil
  8136. }
  8137. // SetID sets the value of the id field. Note that this
  8138. // operation is only accepted on creation of SopTask entities.
  8139. func (m *SopTaskMutation) SetID(id uint64) {
  8140. m.id = &id
  8141. }
  8142. // ID returns the ID value in the mutation. Note that the ID is only available
  8143. // if it was provided to the builder or after it was returned from the database.
  8144. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  8145. if m.id == nil {
  8146. return
  8147. }
  8148. return *m.id, true
  8149. }
  8150. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8151. // That means, if the mutation is applied within a transaction with an isolation level such
  8152. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8153. // or updated by the mutation.
  8154. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  8155. switch {
  8156. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8157. id, exists := m.ID()
  8158. if exists {
  8159. return []uint64{id}, nil
  8160. }
  8161. fallthrough
  8162. case m.op.Is(OpUpdate | OpDelete):
  8163. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  8164. default:
  8165. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8166. }
  8167. }
  8168. // SetCreatedAt sets the "created_at" field.
  8169. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  8170. m.created_at = &t
  8171. }
  8172. // CreatedAt returns the value of the "created_at" field in the mutation.
  8173. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  8174. v := m.created_at
  8175. if v == nil {
  8176. return
  8177. }
  8178. return *v, true
  8179. }
  8180. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  8181. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  8182. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8183. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8184. if !m.op.Is(OpUpdateOne) {
  8185. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8186. }
  8187. if m.id == nil || m.oldValue == nil {
  8188. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8189. }
  8190. oldValue, err := m.oldValue(ctx)
  8191. if err != nil {
  8192. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8193. }
  8194. return oldValue.CreatedAt, nil
  8195. }
  8196. // ResetCreatedAt resets all changes to the "created_at" field.
  8197. func (m *SopTaskMutation) ResetCreatedAt() {
  8198. m.created_at = nil
  8199. }
  8200. // SetUpdatedAt sets the "updated_at" field.
  8201. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  8202. m.updated_at = &t
  8203. }
  8204. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8205. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  8206. v := m.updated_at
  8207. if v == nil {
  8208. return
  8209. }
  8210. return *v, true
  8211. }
  8212. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  8213. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  8214. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8215. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8216. if !m.op.Is(OpUpdateOne) {
  8217. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8218. }
  8219. if m.id == nil || m.oldValue == nil {
  8220. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8221. }
  8222. oldValue, err := m.oldValue(ctx)
  8223. if err != nil {
  8224. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8225. }
  8226. return oldValue.UpdatedAt, nil
  8227. }
  8228. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8229. func (m *SopTaskMutation) ResetUpdatedAt() {
  8230. m.updated_at = nil
  8231. }
  8232. // SetStatus sets the "status" field.
  8233. func (m *SopTaskMutation) SetStatus(u uint8) {
  8234. m.status = &u
  8235. m.addstatus = nil
  8236. }
  8237. // Status returns the value of the "status" field in the mutation.
  8238. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  8239. v := m.status
  8240. if v == nil {
  8241. return
  8242. }
  8243. return *v, true
  8244. }
  8245. // OldStatus returns the old "status" field's value of the SopTask entity.
  8246. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  8247. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8248. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  8249. if !m.op.Is(OpUpdateOne) {
  8250. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  8251. }
  8252. if m.id == nil || m.oldValue == nil {
  8253. return v, errors.New("OldStatus requires an ID field in the mutation")
  8254. }
  8255. oldValue, err := m.oldValue(ctx)
  8256. if err != nil {
  8257. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  8258. }
  8259. return oldValue.Status, nil
  8260. }
  8261. // AddStatus adds u to the "status" field.
  8262. func (m *SopTaskMutation) AddStatus(u int8) {
  8263. if m.addstatus != nil {
  8264. *m.addstatus += u
  8265. } else {
  8266. m.addstatus = &u
  8267. }
  8268. }
  8269. // AddedStatus returns the value that was added to the "status" field in this mutation.
  8270. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  8271. v := m.addstatus
  8272. if v == nil {
  8273. return
  8274. }
  8275. return *v, true
  8276. }
  8277. // ClearStatus clears the value of the "status" field.
  8278. func (m *SopTaskMutation) ClearStatus() {
  8279. m.status = nil
  8280. m.addstatus = nil
  8281. m.clearedFields[soptask.FieldStatus] = struct{}{}
  8282. }
  8283. // StatusCleared returns if the "status" field was cleared in this mutation.
  8284. func (m *SopTaskMutation) StatusCleared() bool {
  8285. _, ok := m.clearedFields[soptask.FieldStatus]
  8286. return ok
  8287. }
  8288. // ResetStatus resets all changes to the "status" field.
  8289. func (m *SopTaskMutation) ResetStatus() {
  8290. m.status = nil
  8291. m.addstatus = nil
  8292. delete(m.clearedFields, soptask.FieldStatus)
  8293. }
  8294. // SetDeletedAt sets the "deleted_at" field.
  8295. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  8296. m.deleted_at = &t
  8297. }
  8298. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8299. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  8300. v := m.deleted_at
  8301. if v == nil {
  8302. return
  8303. }
  8304. return *v, true
  8305. }
  8306. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  8307. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  8308. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8309. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8310. if !m.op.Is(OpUpdateOne) {
  8311. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8312. }
  8313. if m.id == nil || m.oldValue == nil {
  8314. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8315. }
  8316. oldValue, err := m.oldValue(ctx)
  8317. if err != nil {
  8318. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8319. }
  8320. return oldValue.DeletedAt, nil
  8321. }
  8322. // ClearDeletedAt clears the value of the "deleted_at" field.
  8323. func (m *SopTaskMutation) ClearDeletedAt() {
  8324. m.deleted_at = nil
  8325. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  8326. }
  8327. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8328. func (m *SopTaskMutation) DeletedAtCleared() bool {
  8329. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  8330. return ok
  8331. }
  8332. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8333. func (m *SopTaskMutation) ResetDeletedAt() {
  8334. m.deleted_at = nil
  8335. delete(m.clearedFields, soptask.FieldDeletedAt)
  8336. }
  8337. // SetName sets the "name" field.
  8338. func (m *SopTaskMutation) SetName(s string) {
  8339. m.name = &s
  8340. }
  8341. // Name returns the value of the "name" field in the mutation.
  8342. func (m *SopTaskMutation) Name() (r string, exists bool) {
  8343. v := m.name
  8344. if v == nil {
  8345. return
  8346. }
  8347. return *v, true
  8348. }
  8349. // OldName returns the old "name" field's value of the SopTask entity.
  8350. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  8351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8352. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  8353. if !m.op.Is(OpUpdateOne) {
  8354. return v, errors.New("OldName is only allowed on UpdateOne operations")
  8355. }
  8356. if m.id == nil || m.oldValue == nil {
  8357. return v, errors.New("OldName requires an ID field in the mutation")
  8358. }
  8359. oldValue, err := m.oldValue(ctx)
  8360. if err != nil {
  8361. return v, fmt.Errorf("querying old value for OldName: %w", err)
  8362. }
  8363. return oldValue.Name, nil
  8364. }
  8365. // ResetName resets all changes to the "name" field.
  8366. func (m *SopTaskMutation) ResetName() {
  8367. m.name = nil
  8368. }
  8369. // SetBotWxidList sets the "bot_wxid_list" field.
  8370. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  8371. m.bot_wxid_list = &s
  8372. m.appendbot_wxid_list = nil
  8373. }
  8374. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  8375. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  8376. v := m.bot_wxid_list
  8377. if v == nil {
  8378. return
  8379. }
  8380. return *v, true
  8381. }
  8382. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  8383. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  8384. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8385. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  8386. if !m.op.Is(OpUpdateOne) {
  8387. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  8388. }
  8389. if m.id == nil || m.oldValue == nil {
  8390. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  8391. }
  8392. oldValue, err := m.oldValue(ctx)
  8393. if err != nil {
  8394. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  8395. }
  8396. return oldValue.BotWxidList, nil
  8397. }
  8398. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  8399. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  8400. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  8401. }
  8402. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  8403. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  8404. if len(m.appendbot_wxid_list) == 0 {
  8405. return nil, false
  8406. }
  8407. return m.appendbot_wxid_list, true
  8408. }
  8409. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  8410. func (m *SopTaskMutation) ClearBotWxidList() {
  8411. m.bot_wxid_list = nil
  8412. m.appendbot_wxid_list = nil
  8413. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  8414. }
  8415. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  8416. func (m *SopTaskMutation) BotWxidListCleared() bool {
  8417. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  8418. return ok
  8419. }
  8420. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  8421. func (m *SopTaskMutation) ResetBotWxidList() {
  8422. m.bot_wxid_list = nil
  8423. m.appendbot_wxid_list = nil
  8424. delete(m.clearedFields, soptask.FieldBotWxidList)
  8425. }
  8426. // SetType sets the "type" field.
  8427. func (m *SopTaskMutation) SetType(i int) {
  8428. m._type = &i
  8429. m.add_type = nil
  8430. }
  8431. // GetType returns the value of the "type" field in the mutation.
  8432. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  8433. v := m._type
  8434. if v == nil {
  8435. return
  8436. }
  8437. return *v, true
  8438. }
  8439. // OldType returns the old "type" field's value of the SopTask entity.
  8440. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  8441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8442. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  8443. if !m.op.Is(OpUpdateOne) {
  8444. return v, errors.New("OldType is only allowed on UpdateOne operations")
  8445. }
  8446. if m.id == nil || m.oldValue == nil {
  8447. return v, errors.New("OldType requires an ID field in the mutation")
  8448. }
  8449. oldValue, err := m.oldValue(ctx)
  8450. if err != nil {
  8451. return v, fmt.Errorf("querying old value for OldType: %w", err)
  8452. }
  8453. return oldValue.Type, nil
  8454. }
  8455. // AddType adds i to the "type" field.
  8456. func (m *SopTaskMutation) AddType(i int) {
  8457. if m.add_type != nil {
  8458. *m.add_type += i
  8459. } else {
  8460. m.add_type = &i
  8461. }
  8462. }
  8463. // AddedType returns the value that was added to the "type" field in this mutation.
  8464. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  8465. v := m.add_type
  8466. if v == nil {
  8467. return
  8468. }
  8469. return *v, true
  8470. }
  8471. // ResetType resets all changes to the "type" field.
  8472. func (m *SopTaskMutation) ResetType() {
  8473. m._type = nil
  8474. m.add_type = nil
  8475. }
  8476. // SetPlanStartTime sets the "plan_start_time" field.
  8477. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  8478. m.plan_start_time = &t
  8479. }
  8480. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  8481. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  8482. v := m.plan_start_time
  8483. if v == nil {
  8484. return
  8485. }
  8486. return *v, true
  8487. }
  8488. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  8489. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  8490. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8491. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  8492. if !m.op.Is(OpUpdateOne) {
  8493. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  8494. }
  8495. if m.id == nil || m.oldValue == nil {
  8496. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  8497. }
  8498. oldValue, err := m.oldValue(ctx)
  8499. if err != nil {
  8500. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  8501. }
  8502. return oldValue.PlanStartTime, nil
  8503. }
  8504. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  8505. func (m *SopTaskMutation) ClearPlanStartTime() {
  8506. m.plan_start_time = nil
  8507. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  8508. }
  8509. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  8510. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  8511. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  8512. return ok
  8513. }
  8514. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  8515. func (m *SopTaskMutation) ResetPlanStartTime() {
  8516. m.plan_start_time = nil
  8517. delete(m.clearedFields, soptask.FieldPlanStartTime)
  8518. }
  8519. // SetPlanEndTime sets the "plan_end_time" field.
  8520. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  8521. m.plan_end_time = &t
  8522. }
  8523. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  8524. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  8525. v := m.plan_end_time
  8526. if v == nil {
  8527. return
  8528. }
  8529. return *v, true
  8530. }
  8531. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  8532. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  8533. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8534. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  8535. if !m.op.Is(OpUpdateOne) {
  8536. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  8537. }
  8538. if m.id == nil || m.oldValue == nil {
  8539. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  8540. }
  8541. oldValue, err := m.oldValue(ctx)
  8542. if err != nil {
  8543. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  8544. }
  8545. return oldValue.PlanEndTime, nil
  8546. }
  8547. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  8548. func (m *SopTaskMutation) ClearPlanEndTime() {
  8549. m.plan_end_time = nil
  8550. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  8551. }
  8552. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  8553. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  8554. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  8555. return ok
  8556. }
  8557. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  8558. func (m *SopTaskMutation) ResetPlanEndTime() {
  8559. m.plan_end_time = nil
  8560. delete(m.clearedFields, soptask.FieldPlanEndTime)
  8561. }
  8562. // SetCreatorID sets the "creator_id" field.
  8563. func (m *SopTaskMutation) SetCreatorID(s string) {
  8564. m.creator_id = &s
  8565. }
  8566. // CreatorID returns the value of the "creator_id" field in the mutation.
  8567. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  8568. v := m.creator_id
  8569. if v == nil {
  8570. return
  8571. }
  8572. return *v, true
  8573. }
  8574. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  8575. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  8576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8577. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  8578. if !m.op.Is(OpUpdateOne) {
  8579. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  8580. }
  8581. if m.id == nil || m.oldValue == nil {
  8582. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  8583. }
  8584. oldValue, err := m.oldValue(ctx)
  8585. if err != nil {
  8586. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  8587. }
  8588. return oldValue.CreatorID, nil
  8589. }
  8590. // ClearCreatorID clears the value of the "creator_id" field.
  8591. func (m *SopTaskMutation) ClearCreatorID() {
  8592. m.creator_id = nil
  8593. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  8594. }
  8595. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  8596. func (m *SopTaskMutation) CreatorIDCleared() bool {
  8597. _, ok := m.clearedFields[soptask.FieldCreatorID]
  8598. return ok
  8599. }
  8600. // ResetCreatorID resets all changes to the "creator_id" field.
  8601. func (m *SopTaskMutation) ResetCreatorID() {
  8602. m.creator_id = nil
  8603. delete(m.clearedFields, soptask.FieldCreatorID)
  8604. }
  8605. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  8606. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  8607. if m.task_stages == nil {
  8608. m.task_stages = make(map[uint64]struct{})
  8609. }
  8610. for i := range ids {
  8611. m.task_stages[ids[i]] = struct{}{}
  8612. }
  8613. }
  8614. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  8615. func (m *SopTaskMutation) ClearTaskStages() {
  8616. m.clearedtask_stages = true
  8617. }
  8618. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  8619. func (m *SopTaskMutation) TaskStagesCleared() bool {
  8620. return m.clearedtask_stages
  8621. }
  8622. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  8623. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  8624. if m.removedtask_stages == nil {
  8625. m.removedtask_stages = make(map[uint64]struct{})
  8626. }
  8627. for i := range ids {
  8628. delete(m.task_stages, ids[i])
  8629. m.removedtask_stages[ids[i]] = struct{}{}
  8630. }
  8631. }
  8632. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  8633. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  8634. for id := range m.removedtask_stages {
  8635. ids = append(ids, id)
  8636. }
  8637. return
  8638. }
  8639. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  8640. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  8641. for id := range m.task_stages {
  8642. ids = append(ids, id)
  8643. }
  8644. return
  8645. }
  8646. // ResetTaskStages resets all changes to the "task_stages" edge.
  8647. func (m *SopTaskMutation) ResetTaskStages() {
  8648. m.task_stages = nil
  8649. m.clearedtask_stages = false
  8650. m.removedtask_stages = nil
  8651. }
  8652. // Where appends a list predicates to the SopTaskMutation builder.
  8653. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  8654. m.predicates = append(m.predicates, ps...)
  8655. }
  8656. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  8657. // users can use type-assertion to append predicates that do not depend on any generated package.
  8658. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  8659. p := make([]predicate.SopTask, len(ps))
  8660. for i := range ps {
  8661. p[i] = ps[i]
  8662. }
  8663. m.Where(p...)
  8664. }
  8665. // Op returns the operation name.
  8666. func (m *SopTaskMutation) Op() Op {
  8667. return m.op
  8668. }
  8669. // SetOp allows setting the mutation operation.
  8670. func (m *SopTaskMutation) SetOp(op Op) {
  8671. m.op = op
  8672. }
  8673. // Type returns the node type of this mutation (SopTask).
  8674. func (m *SopTaskMutation) Type() string {
  8675. return m.typ
  8676. }
  8677. // Fields returns all fields that were changed during this mutation. Note that in
  8678. // order to get all numeric fields that were incremented/decremented, call
  8679. // AddedFields().
  8680. func (m *SopTaskMutation) Fields() []string {
  8681. fields := make([]string, 0, 10)
  8682. if m.created_at != nil {
  8683. fields = append(fields, soptask.FieldCreatedAt)
  8684. }
  8685. if m.updated_at != nil {
  8686. fields = append(fields, soptask.FieldUpdatedAt)
  8687. }
  8688. if m.status != nil {
  8689. fields = append(fields, soptask.FieldStatus)
  8690. }
  8691. if m.deleted_at != nil {
  8692. fields = append(fields, soptask.FieldDeletedAt)
  8693. }
  8694. if m.name != nil {
  8695. fields = append(fields, soptask.FieldName)
  8696. }
  8697. if m.bot_wxid_list != nil {
  8698. fields = append(fields, soptask.FieldBotWxidList)
  8699. }
  8700. if m._type != nil {
  8701. fields = append(fields, soptask.FieldType)
  8702. }
  8703. if m.plan_start_time != nil {
  8704. fields = append(fields, soptask.FieldPlanStartTime)
  8705. }
  8706. if m.plan_end_time != nil {
  8707. fields = append(fields, soptask.FieldPlanEndTime)
  8708. }
  8709. if m.creator_id != nil {
  8710. fields = append(fields, soptask.FieldCreatorID)
  8711. }
  8712. return fields
  8713. }
  8714. // Field returns the value of a field with the given name. The second boolean
  8715. // return value indicates that this field was not set, or was not defined in the
  8716. // schema.
  8717. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  8718. switch name {
  8719. case soptask.FieldCreatedAt:
  8720. return m.CreatedAt()
  8721. case soptask.FieldUpdatedAt:
  8722. return m.UpdatedAt()
  8723. case soptask.FieldStatus:
  8724. return m.Status()
  8725. case soptask.FieldDeletedAt:
  8726. return m.DeletedAt()
  8727. case soptask.FieldName:
  8728. return m.Name()
  8729. case soptask.FieldBotWxidList:
  8730. return m.BotWxidList()
  8731. case soptask.FieldType:
  8732. return m.GetType()
  8733. case soptask.FieldPlanStartTime:
  8734. return m.PlanStartTime()
  8735. case soptask.FieldPlanEndTime:
  8736. return m.PlanEndTime()
  8737. case soptask.FieldCreatorID:
  8738. return m.CreatorID()
  8739. }
  8740. return nil, false
  8741. }
  8742. // OldField returns the old value of the field from the database. An error is
  8743. // returned if the mutation operation is not UpdateOne, or the query to the
  8744. // database failed.
  8745. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8746. switch name {
  8747. case soptask.FieldCreatedAt:
  8748. return m.OldCreatedAt(ctx)
  8749. case soptask.FieldUpdatedAt:
  8750. return m.OldUpdatedAt(ctx)
  8751. case soptask.FieldStatus:
  8752. return m.OldStatus(ctx)
  8753. case soptask.FieldDeletedAt:
  8754. return m.OldDeletedAt(ctx)
  8755. case soptask.FieldName:
  8756. return m.OldName(ctx)
  8757. case soptask.FieldBotWxidList:
  8758. return m.OldBotWxidList(ctx)
  8759. case soptask.FieldType:
  8760. return m.OldType(ctx)
  8761. case soptask.FieldPlanStartTime:
  8762. return m.OldPlanStartTime(ctx)
  8763. case soptask.FieldPlanEndTime:
  8764. return m.OldPlanEndTime(ctx)
  8765. case soptask.FieldCreatorID:
  8766. return m.OldCreatorID(ctx)
  8767. }
  8768. return nil, fmt.Errorf("unknown SopTask field %s", name)
  8769. }
  8770. // SetField sets the value of a field with the given name. It returns an error if
  8771. // the field is not defined in the schema, or if the type mismatched the field
  8772. // type.
  8773. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  8774. switch name {
  8775. case soptask.FieldCreatedAt:
  8776. v, ok := value.(time.Time)
  8777. if !ok {
  8778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8779. }
  8780. m.SetCreatedAt(v)
  8781. return nil
  8782. case soptask.FieldUpdatedAt:
  8783. v, ok := value.(time.Time)
  8784. if !ok {
  8785. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8786. }
  8787. m.SetUpdatedAt(v)
  8788. return nil
  8789. case soptask.FieldStatus:
  8790. v, ok := value.(uint8)
  8791. if !ok {
  8792. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8793. }
  8794. m.SetStatus(v)
  8795. return nil
  8796. case soptask.FieldDeletedAt:
  8797. v, ok := value.(time.Time)
  8798. if !ok {
  8799. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8800. }
  8801. m.SetDeletedAt(v)
  8802. return nil
  8803. case soptask.FieldName:
  8804. v, ok := value.(string)
  8805. if !ok {
  8806. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8807. }
  8808. m.SetName(v)
  8809. return nil
  8810. case soptask.FieldBotWxidList:
  8811. v, ok := value.([]string)
  8812. if !ok {
  8813. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8814. }
  8815. m.SetBotWxidList(v)
  8816. return nil
  8817. case soptask.FieldType:
  8818. v, ok := value.(int)
  8819. if !ok {
  8820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8821. }
  8822. m.SetType(v)
  8823. return nil
  8824. case soptask.FieldPlanStartTime:
  8825. v, ok := value.(time.Time)
  8826. if !ok {
  8827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8828. }
  8829. m.SetPlanStartTime(v)
  8830. return nil
  8831. case soptask.FieldPlanEndTime:
  8832. v, ok := value.(time.Time)
  8833. if !ok {
  8834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8835. }
  8836. m.SetPlanEndTime(v)
  8837. return nil
  8838. case soptask.FieldCreatorID:
  8839. v, ok := value.(string)
  8840. if !ok {
  8841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8842. }
  8843. m.SetCreatorID(v)
  8844. return nil
  8845. }
  8846. return fmt.Errorf("unknown SopTask field %s", name)
  8847. }
  8848. // AddedFields returns all numeric fields that were incremented/decremented during
  8849. // this mutation.
  8850. func (m *SopTaskMutation) AddedFields() []string {
  8851. var fields []string
  8852. if m.addstatus != nil {
  8853. fields = append(fields, soptask.FieldStatus)
  8854. }
  8855. if m.add_type != nil {
  8856. fields = append(fields, soptask.FieldType)
  8857. }
  8858. return fields
  8859. }
  8860. // AddedField returns the numeric value that was incremented/decremented on a field
  8861. // with the given name. The second boolean return value indicates that this field
  8862. // was not set, or was not defined in the schema.
  8863. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  8864. switch name {
  8865. case soptask.FieldStatus:
  8866. return m.AddedStatus()
  8867. case soptask.FieldType:
  8868. return m.AddedType()
  8869. }
  8870. return nil, false
  8871. }
  8872. // AddField adds the value to the field with the given name. It returns an error if
  8873. // the field is not defined in the schema, or if the type mismatched the field
  8874. // type.
  8875. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  8876. switch name {
  8877. case soptask.FieldStatus:
  8878. v, ok := value.(int8)
  8879. if !ok {
  8880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8881. }
  8882. m.AddStatus(v)
  8883. return nil
  8884. case soptask.FieldType:
  8885. v, ok := value.(int)
  8886. if !ok {
  8887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8888. }
  8889. m.AddType(v)
  8890. return nil
  8891. }
  8892. return fmt.Errorf("unknown SopTask numeric field %s", name)
  8893. }
  8894. // ClearedFields returns all nullable fields that were cleared during this
  8895. // mutation.
  8896. func (m *SopTaskMutation) ClearedFields() []string {
  8897. var fields []string
  8898. if m.FieldCleared(soptask.FieldStatus) {
  8899. fields = append(fields, soptask.FieldStatus)
  8900. }
  8901. if m.FieldCleared(soptask.FieldDeletedAt) {
  8902. fields = append(fields, soptask.FieldDeletedAt)
  8903. }
  8904. if m.FieldCleared(soptask.FieldBotWxidList) {
  8905. fields = append(fields, soptask.FieldBotWxidList)
  8906. }
  8907. if m.FieldCleared(soptask.FieldPlanStartTime) {
  8908. fields = append(fields, soptask.FieldPlanStartTime)
  8909. }
  8910. if m.FieldCleared(soptask.FieldPlanEndTime) {
  8911. fields = append(fields, soptask.FieldPlanEndTime)
  8912. }
  8913. if m.FieldCleared(soptask.FieldCreatorID) {
  8914. fields = append(fields, soptask.FieldCreatorID)
  8915. }
  8916. return fields
  8917. }
  8918. // FieldCleared returns a boolean indicating if a field with the given name was
  8919. // cleared in this mutation.
  8920. func (m *SopTaskMutation) FieldCleared(name string) bool {
  8921. _, ok := m.clearedFields[name]
  8922. return ok
  8923. }
  8924. // ClearField clears the value of the field with the given name. It returns an
  8925. // error if the field is not defined in the schema.
  8926. func (m *SopTaskMutation) ClearField(name string) error {
  8927. switch name {
  8928. case soptask.FieldStatus:
  8929. m.ClearStatus()
  8930. return nil
  8931. case soptask.FieldDeletedAt:
  8932. m.ClearDeletedAt()
  8933. return nil
  8934. case soptask.FieldBotWxidList:
  8935. m.ClearBotWxidList()
  8936. return nil
  8937. case soptask.FieldPlanStartTime:
  8938. m.ClearPlanStartTime()
  8939. return nil
  8940. case soptask.FieldPlanEndTime:
  8941. m.ClearPlanEndTime()
  8942. return nil
  8943. case soptask.FieldCreatorID:
  8944. m.ClearCreatorID()
  8945. return nil
  8946. }
  8947. return fmt.Errorf("unknown SopTask nullable field %s", name)
  8948. }
  8949. // ResetField resets all changes in the mutation for the field with the given name.
  8950. // It returns an error if the field is not defined in the schema.
  8951. func (m *SopTaskMutation) ResetField(name string) error {
  8952. switch name {
  8953. case soptask.FieldCreatedAt:
  8954. m.ResetCreatedAt()
  8955. return nil
  8956. case soptask.FieldUpdatedAt:
  8957. m.ResetUpdatedAt()
  8958. return nil
  8959. case soptask.FieldStatus:
  8960. m.ResetStatus()
  8961. return nil
  8962. case soptask.FieldDeletedAt:
  8963. m.ResetDeletedAt()
  8964. return nil
  8965. case soptask.FieldName:
  8966. m.ResetName()
  8967. return nil
  8968. case soptask.FieldBotWxidList:
  8969. m.ResetBotWxidList()
  8970. return nil
  8971. case soptask.FieldType:
  8972. m.ResetType()
  8973. return nil
  8974. case soptask.FieldPlanStartTime:
  8975. m.ResetPlanStartTime()
  8976. return nil
  8977. case soptask.FieldPlanEndTime:
  8978. m.ResetPlanEndTime()
  8979. return nil
  8980. case soptask.FieldCreatorID:
  8981. m.ResetCreatorID()
  8982. return nil
  8983. }
  8984. return fmt.Errorf("unknown SopTask field %s", name)
  8985. }
  8986. // AddedEdges returns all edge names that were set/added in this mutation.
  8987. func (m *SopTaskMutation) AddedEdges() []string {
  8988. edges := make([]string, 0, 1)
  8989. if m.task_stages != nil {
  8990. edges = append(edges, soptask.EdgeTaskStages)
  8991. }
  8992. return edges
  8993. }
  8994. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8995. // name in this mutation.
  8996. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  8997. switch name {
  8998. case soptask.EdgeTaskStages:
  8999. ids := make([]ent.Value, 0, len(m.task_stages))
  9000. for id := range m.task_stages {
  9001. ids = append(ids, id)
  9002. }
  9003. return ids
  9004. }
  9005. return nil
  9006. }
  9007. // RemovedEdges returns all edge names that were removed in this mutation.
  9008. func (m *SopTaskMutation) RemovedEdges() []string {
  9009. edges := make([]string, 0, 1)
  9010. if m.removedtask_stages != nil {
  9011. edges = append(edges, soptask.EdgeTaskStages)
  9012. }
  9013. return edges
  9014. }
  9015. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9016. // the given name in this mutation.
  9017. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  9018. switch name {
  9019. case soptask.EdgeTaskStages:
  9020. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  9021. for id := range m.removedtask_stages {
  9022. ids = append(ids, id)
  9023. }
  9024. return ids
  9025. }
  9026. return nil
  9027. }
  9028. // ClearedEdges returns all edge names that were cleared in this mutation.
  9029. func (m *SopTaskMutation) ClearedEdges() []string {
  9030. edges := make([]string, 0, 1)
  9031. if m.clearedtask_stages {
  9032. edges = append(edges, soptask.EdgeTaskStages)
  9033. }
  9034. return edges
  9035. }
  9036. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9037. // was cleared in this mutation.
  9038. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  9039. switch name {
  9040. case soptask.EdgeTaskStages:
  9041. return m.clearedtask_stages
  9042. }
  9043. return false
  9044. }
  9045. // ClearEdge clears the value of the edge with the given name. It returns an error
  9046. // if that edge is not defined in the schema.
  9047. func (m *SopTaskMutation) ClearEdge(name string) error {
  9048. switch name {
  9049. }
  9050. return fmt.Errorf("unknown SopTask unique edge %s", name)
  9051. }
  9052. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9053. // It returns an error if the edge is not defined in the schema.
  9054. func (m *SopTaskMutation) ResetEdge(name string) error {
  9055. switch name {
  9056. case soptask.EdgeTaskStages:
  9057. m.ResetTaskStages()
  9058. return nil
  9059. }
  9060. return fmt.Errorf("unknown SopTask edge %s", name)
  9061. }
  9062. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  9063. type WxMutation struct {
  9064. config
  9065. op Op
  9066. typ string
  9067. id *uint64
  9068. created_at *time.Time
  9069. updated_at *time.Time
  9070. status *uint8
  9071. addstatus *int8
  9072. deleted_at *time.Time
  9073. port *string
  9074. process_id *string
  9075. callback *string
  9076. wxid *string
  9077. account *string
  9078. nickname *string
  9079. tel *string
  9080. head_big *string
  9081. clearedFields map[string]struct{}
  9082. server *uint64
  9083. clearedserver bool
  9084. done bool
  9085. oldValue func(context.Context) (*Wx, error)
  9086. predicates []predicate.Wx
  9087. }
  9088. var _ ent.Mutation = (*WxMutation)(nil)
  9089. // wxOption allows management of the mutation configuration using functional options.
  9090. type wxOption func(*WxMutation)
  9091. // newWxMutation creates new mutation for the Wx entity.
  9092. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  9093. m := &WxMutation{
  9094. config: c,
  9095. op: op,
  9096. typ: TypeWx,
  9097. clearedFields: make(map[string]struct{}),
  9098. }
  9099. for _, opt := range opts {
  9100. opt(m)
  9101. }
  9102. return m
  9103. }
  9104. // withWxID sets the ID field of the mutation.
  9105. func withWxID(id uint64) wxOption {
  9106. return func(m *WxMutation) {
  9107. var (
  9108. err error
  9109. once sync.Once
  9110. value *Wx
  9111. )
  9112. m.oldValue = func(ctx context.Context) (*Wx, error) {
  9113. once.Do(func() {
  9114. if m.done {
  9115. err = errors.New("querying old values post mutation is not allowed")
  9116. } else {
  9117. value, err = m.Client().Wx.Get(ctx, id)
  9118. }
  9119. })
  9120. return value, err
  9121. }
  9122. m.id = &id
  9123. }
  9124. }
  9125. // withWx sets the old Wx of the mutation.
  9126. func withWx(node *Wx) wxOption {
  9127. return func(m *WxMutation) {
  9128. m.oldValue = func(context.Context) (*Wx, error) {
  9129. return node, nil
  9130. }
  9131. m.id = &node.ID
  9132. }
  9133. }
  9134. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9135. // executed in a transaction (ent.Tx), a transactional client is returned.
  9136. func (m WxMutation) Client() *Client {
  9137. client := &Client{config: m.config}
  9138. client.init()
  9139. return client
  9140. }
  9141. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9142. // it returns an error otherwise.
  9143. func (m WxMutation) Tx() (*Tx, error) {
  9144. if _, ok := m.driver.(*txDriver); !ok {
  9145. return nil, errors.New("ent: mutation is not running in a transaction")
  9146. }
  9147. tx := &Tx{config: m.config}
  9148. tx.init()
  9149. return tx, nil
  9150. }
  9151. // SetID sets the value of the id field. Note that this
  9152. // operation is only accepted on creation of Wx entities.
  9153. func (m *WxMutation) SetID(id uint64) {
  9154. m.id = &id
  9155. }
  9156. // ID returns the ID value in the mutation. Note that the ID is only available
  9157. // if it was provided to the builder or after it was returned from the database.
  9158. func (m *WxMutation) ID() (id uint64, exists bool) {
  9159. if m.id == nil {
  9160. return
  9161. }
  9162. return *m.id, true
  9163. }
  9164. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9165. // That means, if the mutation is applied within a transaction with an isolation level such
  9166. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9167. // or updated by the mutation.
  9168. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  9169. switch {
  9170. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9171. id, exists := m.ID()
  9172. if exists {
  9173. return []uint64{id}, nil
  9174. }
  9175. fallthrough
  9176. case m.op.Is(OpUpdate | OpDelete):
  9177. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  9178. default:
  9179. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9180. }
  9181. }
  9182. // SetCreatedAt sets the "created_at" field.
  9183. func (m *WxMutation) SetCreatedAt(t time.Time) {
  9184. m.created_at = &t
  9185. }
  9186. // CreatedAt returns the value of the "created_at" field in the mutation.
  9187. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  9188. v := m.created_at
  9189. if v == nil {
  9190. return
  9191. }
  9192. return *v, true
  9193. }
  9194. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  9195. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  9196. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9197. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9198. if !m.op.Is(OpUpdateOne) {
  9199. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9200. }
  9201. if m.id == nil || m.oldValue == nil {
  9202. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9203. }
  9204. oldValue, err := m.oldValue(ctx)
  9205. if err != nil {
  9206. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9207. }
  9208. return oldValue.CreatedAt, nil
  9209. }
  9210. // ResetCreatedAt resets all changes to the "created_at" field.
  9211. func (m *WxMutation) ResetCreatedAt() {
  9212. m.created_at = nil
  9213. }
  9214. // SetUpdatedAt sets the "updated_at" field.
  9215. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  9216. m.updated_at = &t
  9217. }
  9218. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9219. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  9220. v := m.updated_at
  9221. if v == nil {
  9222. return
  9223. }
  9224. return *v, true
  9225. }
  9226. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  9227. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  9228. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9229. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9230. if !m.op.Is(OpUpdateOne) {
  9231. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9232. }
  9233. if m.id == nil || m.oldValue == nil {
  9234. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9235. }
  9236. oldValue, err := m.oldValue(ctx)
  9237. if err != nil {
  9238. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9239. }
  9240. return oldValue.UpdatedAt, nil
  9241. }
  9242. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9243. func (m *WxMutation) ResetUpdatedAt() {
  9244. m.updated_at = nil
  9245. }
  9246. // SetStatus sets the "status" field.
  9247. func (m *WxMutation) SetStatus(u uint8) {
  9248. m.status = &u
  9249. m.addstatus = nil
  9250. }
  9251. // Status returns the value of the "status" field in the mutation.
  9252. func (m *WxMutation) Status() (r uint8, exists bool) {
  9253. v := m.status
  9254. if v == nil {
  9255. return
  9256. }
  9257. return *v, true
  9258. }
  9259. // OldStatus returns the old "status" field's value of the Wx entity.
  9260. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  9261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9262. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  9263. if !m.op.Is(OpUpdateOne) {
  9264. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9265. }
  9266. if m.id == nil || m.oldValue == nil {
  9267. return v, errors.New("OldStatus requires an ID field in the mutation")
  9268. }
  9269. oldValue, err := m.oldValue(ctx)
  9270. if err != nil {
  9271. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9272. }
  9273. return oldValue.Status, nil
  9274. }
  9275. // AddStatus adds u to the "status" field.
  9276. func (m *WxMutation) AddStatus(u int8) {
  9277. if m.addstatus != nil {
  9278. *m.addstatus += u
  9279. } else {
  9280. m.addstatus = &u
  9281. }
  9282. }
  9283. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9284. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  9285. v := m.addstatus
  9286. if v == nil {
  9287. return
  9288. }
  9289. return *v, true
  9290. }
  9291. // ClearStatus clears the value of the "status" field.
  9292. func (m *WxMutation) ClearStatus() {
  9293. m.status = nil
  9294. m.addstatus = nil
  9295. m.clearedFields[wx.FieldStatus] = struct{}{}
  9296. }
  9297. // StatusCleared returns if the "status" field was cleared in this mutation.
  9298. func (m *WxMutation) StatusCleared() bool {
  9299. _, ok := m.clearedFields[wx.FieldStatus]
  9300. return ok
  9301. }
  9302. // ResetStatus resets all changes to the "status" field.
  9303. func (m *WxMutation) ResetStatus() {
  9304. m.status = nil
  9305. m.addstatus = nil
  9306. delete(m.clearedFields, wx.FieldStatus)
  9307. }
  9308. // SetDeletedAt sets the "deleted_at" field.
  9309. func (m *WxMutation) SetDeletedAt(t time.Time) {
  9310. m.deleted_at = &t
  9311. }
  9312. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9313. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  9314. v := m.deleted_at
  9315. if v == nil {
  9316. return
  9317. }
  9318. return *v, true
  9319. }
  9320. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  9321. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  9322. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9323. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9324. if !m.op.Is(OpUpdateOne) {
  9325. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9326. }
  9327. if m.id == nil || m.oldValue == nil {
  9328. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9329. }
  9330. oldValue, err := m.oldValue(ctx)
  9331. if err != nil {
  9332. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9333. }
  9334. return oldValue.DeletedAt, nil
  9335. }
  9336. // ClearDeletedAt clears the value of the "deleted_at" field.
  9337. func (m *WxMutation) ClearDeletedAt() {
  9338. m.deleted_at = nil
  9339. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  9340. }
  9341. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9342. func (m *WxMutation) DeletedAtCleared() bool {
  9343. _, ok := m.clearedFields[wx.FieldDeletedAt]
  9344. return ok
  9345. }
  9346. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9347. func (m *WxMutation) ResetDeletedAt() {
  9348. m.deleted_at = nil
  9349. delete(m.clearedFields, wx.FieldDeletedAt)
  9350. }
  9351. // SetServerID sets the "server_id" field.
  9352. func (m *WxMutation) SetServerID(u uint64) {
  9353. m.server = &u
  9354. }
  9355. // ServerID returns the value of the "server_id" field in the mutation.
  9356. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  9357. v := m.server
  9358. if v == nil {
  9359. return
  9360. }
  9361. return *v, true
  9362. }
  9363. // OldServerID returns the old "server_id" field's value of the Wx entity.
  9364. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  9365. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9366. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  9367. if !m.op.Is(OpUpdateOne) {
  9368. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  9369. }
  9370. if m.id == nil || m.oldValue == nil {
  9371. return v, errors.New("OldServerID requires an ID field in the mutation")
  9372. }
  9373. oldValue, err := m.oldValue(ctx)
  9374. if err != nil {
  9375. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  9376. }
  9377. return oldValue.ServerID, nil
  9378. }
  9379. // ClearServerID clears the value of the "server_id" field.
  9380. func (m *WxMutation) ClearServerID() {
  9381. m.server = nil
  9382. m.clearedFields[wx.FieldServerID] = struct{}{}
  9383. }
  9384. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  9385. func (m *WxMutation) ServerIDCleared() bool {
  9386. _, ok := m.clearedFields[wx.FieldServerID]
  9387. return ok
  9388. }
  9389. // ResetServerID resets all changes to the "server_id" field.
  9390. func (m *WxMutation) ResetServerID() {
  9391. m.server = nil
  9392. delete(m.clearedFields, wx.FieldServerID)
  9393. }
  9394. // SetPort sets the "port" field.
  9395. func (m *WxMutation) SetPort(s string) {
  9396. m.port = &s
  9397. }
  9398. // Port returns the value of the "port" field in the mutation.
  9399. func (m *WxMutation) Port() (r string, exists bool) {
  9400. v := m.port
  9401. if v == nil {
  9402. return
  9403. }
  9404. return *v, true
  9405. }
  9406. // OldPort returns the old "port" field's value of the Wx entity.
  9407. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  9408. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9409. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  9410. if !m.op.Is(OpUpdateOne) {
  9411. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  9412. }
  9413. if m.id == nil || m.oldValue == nil {
  9414. return v, errors.New("OldPort requires an ID field in the mutation")
  9415. }
  9416. oldValue, err := m.oldValue(ctx)
  9417. if err != nil {
  9418. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  9419. }
  9420. return oldValue.Port, nil
  9421. }
  9422. // ResetPort resets all changes to the "port" field.
  9423. func (m *WxMutation) ResetPort() {
  9424. m.port = nil
  9425. }
  9426. // SetProcessID sets the "process_id" field.
  9427. func (m *WxMutation) SetProcessID(s string) {
  9428. m.process_id = &s
  9429. }
  9430. // ProcessID returns the value of the "process_id" field in the mutation.
  9431. func (m *WxMutation) ProcessID() (r string, exists bool) {
  9432. v := m.process_id
  9433. if v == nil {
  9434. return
  9435. }
  9436. return *v, true
  9437. }
  9438. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  9439. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  9440. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9441. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  9442. if !m.op.Is(OpUpdateOne) {
  9443. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  9444. }
  9445. if m.id == nil || m.oldValue == nil {
  9446. return v, errors.New("OldProcessID requires an ID field in the mutation")
  9447. }
  9448. oldValue, err := m.oldValue(ctx)
  9449. if err != nil {
  9450. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  9451. }
  9452. return oldValue.ProcessID, nil
  9453. }
  9454. // ResetProcessID resets all changes to the "process_id" field.
  9455. func (m *WxMutation) ResetProcessID() {
  9456. m.process_id = nil
  9457. }
  9458. // SetCallback sets the "callback" field.
  9459. func (m *WxMutation) SetCallback(s string) {
  9460. m.callback = &s
  9461. }
  9462. // Callback returns the value of the "callback" field in the mutation.
  9463. func (m *WxMutation) Callback() (r string, exists bool) {
  9464. v := m.callback
  9465. if v == nil {
  9466. return
  9467. }
  9468. return *v, true
  9469. }
  9470. // OldCallback returns the old "callback" field's value of the Wx entity.
  9471. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  9472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9473. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  9474. if !m.op.Is(OpUpdateOne) {
  9475. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  9476. }
  9477. if m.id == nil || m.oldValue == nil {
  9478. return v, errors.New("OldCallback requires an ID field in the mutation")
  9479. }
  9480. oldValue, err := m.oldValue(ctx)
  9481. if err != nil {
  9482. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  9483. }
  9484. return oldValue.Callback, nil
  9485. }
  9486. // ResetCallback resets all changes to the "callback" field.
  9487. func (m *WxMutation) ResetCallback() {
  9488. m.callback = nil
  9489. }
  9490. // SetWxid sets the "wxid" field.
  9491. func (m *WxMutation) SetWxid(s string) {
  9492. m.wxid = &s
  9493. }
  9494. // Wxid returns the value of the "wxid" field in the mutation.
  9495. func (m *WxMutation) Wxid() (r string, exists bool) {
  9496. v := m.wxid
  9497. if v == nil {
  9498. return
  9499. }
  9500. return *v, true
  9501. }
  9502. // OldWxid returns the old "wxid" field's value of the Wx entity.
  9503. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  9504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9505. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  9506. if !m.op.Is(OpUpdateOne) {
  9507. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  9508. }
  9509. if m.id == nil || m.oldValue == nil {
  9510. return v, errors.New("OldWxid requires an ID field in the mutation")
  9511. }
  9512. oldValue, err := m.oldValue(ctx)
  9513. if err != nil {
  9514. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  9515. }
  9516. return oldValue.Wxid, nil
  9517. }
  9518. // ResetWxid resets all changes to the "wxid" field.
  9519. func (m *WxMutation) ResetWxid() {
  9520. m.wxid = nil
  9521. }
  9522. // SetAccount sets the "account" field.
  9523. func (m *WxMutation) SetAccount(s string) {
  9524. m.account = &s
  9525. }
  9526. // Account returns the value of the "account" field in the mutation.
  9527. func (m *WxMutation) Account() (r string, exists bool) {
  9528. v := m.account
  9529. if v == nil {
  9530. return
  9531. }
  9532. return *v, true
  9533. }
  9534. // OldAccount returns the old "account" field's value of the Wx entity.
  9535. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  9536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9537. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  9538. if !m.op.Is(OpUpdateOne) {
  9539. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  9540. }
  9541. if m.id == nil || m.oldValue == nil {
  9542. return v, errors.New("OldAccount requires an ID field in the mutation")
  9543. }
  9544. oldValue, err := m.oldValue(ctx)
  9545. if err != nil {
  9546. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  9547. }
  9548. return oldValue.Account, nil
  9549. }
  9550. // ResetAccount resets all changes to the "account" field.
  9551. func (m *WxMutation) ResetAccount() {
  9552. m.account = nil
  9553. }
  9554. // SetNickname sets the "nickname" field.
  9555. func (m *WxMutation) SetNickname(s string) {
  9556. m.nickname = &s
  9557. }
  9558. // Nickname returns the value of the "nickname" field in the mutation.
  9559. func (m *WxMutation) Nickname() (r string, exists bool) {
  9560. v := m.nickname
  9561. if v == nil {
  9562. return
  9563. }
  9564. return *v, true
  9565. }
  9566. // OldNickname returns the old "nickname" field's value of the Wx entity.
  9567. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  9568. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9569. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  9570. if !m.op.Is(OpUpdateOne) {
  9571. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  9572. }
  9573. if m.id == nil || m.oldValue == nil {
  9574. return v, errors.New("OldNickname requires an ID field in the mutation")
  9575. }
  9576. oldValue, err := m.oldValue(ctx)
  9577. if err != nil {
  9578. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  9579. }
  9580. return oldValue.Nickname, nil
  9581. }
  9582. // ResetNickname resets all changes to the "nickname" field.
  9583. func (m *WxMutation) ResetNickname() {
  9584. m.nickname = nil
  9585. }
  9586. // SetTel sets the "tel" field.
  9587. func (m *WxMutation) SetTel(s string) {
  9588. m.tel = &s
  9589. }
  9590. // Tel returns the value of the "tel" field in the mutation.
  9591. func (m *WxMutation) Tel() (r string, exists bool) {
  9592. v := m.tel
  9593. if v == nil {
  9594. return
  9595. }
  9596. return *v, true
  9597. }
  9598. // OldTel returns the old "tel" field's value of the Wx entity.
  9599. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  9600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9601. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  9602. if !m.op.Is(OpUpdateOne) {
  9603. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  9604. }
  9605. if m.id == nil || m.oldValue == nil {
  9606. return v, errors.New("OldTel requires an ID field in the mutation")
  9607. }
  9608. oldValue, err := m.oldValue(ctx)
  9609. if err != nil {
  9610. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  9611. }
  9612. return oldValue.Tel, nil
  9613. }
  9614. // ResetTel resets all changes to the "tel" field.
  9615. func (m *WxMutation) ResetTel() {
  9616. m.tel = nil
  9617. }
  9618. // SetHeadBig sets the "head_big" field.
  9619. func (m *WxMutation) SetHeadBig(s string) {
  9620. m.head_big = &s
  9621. }
  9622. // HeadBig returns the value of the "head_big" field in the mutation.
  9623. func (m *WxMutation) HeadBig() (r string, exists bool) {
  9624. v := m.head_big
  9625. if v == nil {
  9626. return
  9627. }
  9628. return *v, true
  9629. }
  9630. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  9631. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  9632. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9633. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  9634. if !m.op.Is(OpUpdateOne) {
  9635. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  9636. }
  9637. if m.id == nil || m.oldValue == nil {
  9638. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  9639. }
  9640. oldValue, err := m.oldValue(ctx)
  9641. if err != nil {
  9642. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  9643. }
  9644. return oldValue.HeadBig, nil
  9645. }
  9646. // ResetHeadBig resets all changes to the "head_big" field.
  9647. func (m *WxMutation) ResetHeadBig() {
  9648. m.head_big = nil
  9649. }
  9650. // ClearServer clears the "server" edge to the Server entity.
  9651. func (m *WxMutation) ClearServer() {
  9652. m.clearedserver = true
  9653. m.clearedFields[wx.FieldServerID] = struct{}{}
  9654. }
  9655. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  9656. func (m *WxMutation) ServerCleared() bool {
  9657. return m.ServerIDCleared() || m.clearedserver
  9658. }
  9659. // ServerIDs returns the "server" edge IDs in the mutation.
  9660. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  9661. // ServerID instead. It exists only for internal usage by the builders.
  9662. func (m *WxMutation) ServerIDs() (ids []uint64) {
  9663. if id := m.server; id != nil {
  9664. ids = append(ids, *id)
  9665. }
  9666. return
  9667. }
  9668. // ResetServer resets all changes to the "server" edge.
  9669. func (m *WxMutation) ResetServer() {
  9670. m.server = nil
  9671. m.clearedserver = false
  9672. }
  9673. // Where appends a list predicates to the WxMutation builder.
  9674. func (m *WxMutation) Where(ps ...predicate.Wx) {
  9675. m.predicates = append(m.predicates, ps...)
  9676. }
  9677. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  9678. // users can use type-assertion to append predicates that do not depend on any generated package.
  9679. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  9680. p := make([]predicate.Wx, len(ps))
  9681. for i := range ps {
  9682. p[i] = ps[i]
  9683. }
  9684. m.Where(p...)
  9685. }
  9686. // Op returns the operation name.
  9687. func (m *WxMutation) Op() Op {
  9688. return m.op
  9689. }
  9690. // SetOp allows setting the mutation operation.
  9691. func (m *WxMutation) SetOp(op Op) {
  9692. m.op = op
  9693. }
  9694. // Type returns the node type of this mutation (Wx).
  9695. func (m *WxMutation) Type() string {
  9696. return m.typ
  9697. }
  9698. // Fields returns all fields that were changed during this mutation. Note that in
  9699. // order to get all numeric fields that were incremented/decremented, call
  9700. // AddedFields().
  9701. func (m *WxMutation) Fields() []string {
  9702. fields := make([]string, 0, 13)
  9703. if m.created_at != nil {
  9704. fields = append(fields, wx.FieldCreatedAt)
  9705. }
  9706. if m.updated_at != nil {
  9707. fields = append(fields, wx.FieldUpdatedAt)
  9708. }
  9709. if m.status != nil {
  9710. fields = append(fields, wx.FieldStatus)
  9711. }
  9712. if m.deleted_at != nil {
  9713. fields = append(fields, wx.FieldDeletedAt)
  9714. }
  9715. if m.server != nil {
  9716. fields = append(fields, wx.FieldServerID)
  9717. }
  9718. if m.port != nil {
  9719. fields = append(fields, wx.FieldPort)
  9720. }
  9721. if m.process_id != nil {
  9722. fields = append(fields, wx.FieldProcessID)
  9723. }
  9724. if m.callback != nil {
  9725. fields = append(fields, wx.FieldCallback)
  9726. }
  9727. if m.wxid != nil {
  9728. fields = append(fields, wx.FieldWxid)
  9729. }
  9730. if m.account != nil {
  9731. fields = append(fields, wx.FieldAccount)
  9732. }
  9733. if m.nickname != nil {
  9734. fields = append(fields, wx.FieldNickname)
  9735. }
  9736. if m.tel != nil {
  9737. fields = append(fields, wx.FieldTel)
  9738. }
  9739. if m.head_big != nil {
  9740. fields = append(fields, wx.FieldHeadBig)
  9741. }
  9742. return fields
  9743. }
  9744. // Field returns the value of a field with the given name. The second boolean
  9745. // return value indicates that this field was not set, or was not defined in the
  9746. // schema.
  9747. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  9748. switch name {
  9749. case wx.FieldCreatedAt:
  9750. return m.CreatedAt()
  9751. case wx.FieldUpdatedAt:
  9752. return m.UpdatedAt()
  9753. case wx.FieldStatus:
  9754. return m.Status()
  9755. case wx.FieldDeletedAt:
  9756. return m.DeletedAt()
  9757. case wx.FieldServerID:
  9758. return m.ServerID()
  9759. case wx.FieldPort:
  9760. return m.Port()
  9761. case wx.FieldProcessID:
  9762. return m.ProcessID()
  9763. case wx.FieldCallback:
  9764. return m.Callback()
  9765. case wx.FieldWxid:
  9766. return m.Wxid()
  9767. case wx.FieldAccount:
  9768. return m.Account()
  9769. case wx.FieldNickname:
  9770. return m.Nickname()
  9771. case wx.FieldTel:
  9772. return m.Tel()
  9773. case wx.FieldHeadBig:
  9774. return m.HeadBig()
  9775. }
  9776. return nil, false
  9777. }
  9778. // OldField returns the old value of the field from the database. An error is
  9779. // returned if the mutation operation is not UpdateOne, or the query to the
  9780. // database failed.
  9781. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9782. switch name {
  9783. case wx.FieldCreatedAt:
  9784. return m.OldCreatedAt(ctx)
  9785. case wx.FieldUpdatedAt:
  9786. return m.OldUpdatedAt(ctx)
  9787. case wx.FieldStatus:
  9788. return m.OldStatus(ctx)
  9789. case wx.FieldDeletedAt:
  9790. return m.OldDeletedAt(ctx)
  9791. case wx.FieldServerID:
  9792. return m.OldServerID(ctx)
  9793. case wx.FieldPort:
  9794. return m.OldPort(ctx)
  9795. case wx.FieldProcessID:
  9796. return m.OldProcessID(ctx)
  9797. case wx.FieldCallback:
  9798. return m.OldCallback(ctx)
  9799. case wx.FieldWxid:
  9800. return m.OldWxid(ctx)
  9801. case wx.FieldAccount:
  9802. return m.OldAccount(ctx)
  9803. case wx.FieldNickname:
  9804. return m.OldNickname(ctx)
  9805. case wx.FieldTel:
  9806. return m.OldTel(ctx)
  9807. case wx.FieldHeadBig:
  9808. return m.OldHeadBig(ctx)
  9809. }
  9810. return nil, fmt.Errorf("unknown Wx field %s", name)
  9811. }
  9812. // SetField sets the value of a field with the given name. It returns an error if
  9813. // the field is not defined in the schema, or if the type mismatched the field
  9814. // type.
  9815. func (m *WxMutation) SetField(name string, value ent.Value) error {
  9816. switch name {
  9817. case wx.FieldCreatedAt:
  9818. v, ok := value.(time.Time)
  9819. if !ok {
  9820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9821. }
  9822. m.SetCreatedAt(v)
  9823. return nil
  9824. case wx.FieldUpdatedAt:
  9825. v, ok := value.(time.Time)
  9826. if !ok {
  9827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9828. }
  9829. m.SetUpdatedAt(v)
  9830. return nil
  9831. case wx.FieldStatus:
  9832. v, ok := value.(uint8)
  9833. if !ok {
  9834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9835. }
  9836. m.SetStatus(v)
  9837. return nil
  9838. case wx.FieldDeletedAt:
  9839. v, ok := value.(time.Time)
  9840. if !ok {
  9841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9842. }
  9843. m.SetDeletedAt(v)
  9844. return nil
  9845. case wx.FieldServerID:
  9846. v, ok := value.(uint64)
  9847. if !ok {
  9848. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9849. }
  9850. m.SetServerID(v)
  9851. return nil
  9852. case wx.FieldPort:
  9853. v, ok := value.(string)
  9854. if !ok {
  9855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9856. }
  9857. m.SetPort(v)
  9858. return nil
  9859. case wx.FieldProcessID:
  9860. v, ok := value.(string)
  9861. if !ok {
  9862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9863. }
  9864. m.SetProcessID(v)
  9865. return nil
  9866. case wx.FieldCallback:
  9867. v, ok := value.(string)
  9868. if !ok {
  9869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9870. }
  9871. m.SetCallback(v)
  9872. return nil
  9873. case wx.FieldWxid:
  9874. v, ok := value.(string)
  9875. if !ok {
  9876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9877. }
  9878. m.SetWxid(v)
  9879. return nil
  9880. case wx.FieldAccount:
  9881. v, ok := value.(string)
  9882. if !ok {
  9883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9884. }
  9885. m.SetAccount(v)
  9886. return nil
  9887. case wx.FieldNickname:
  9888. v, ok := value.(string)
  9889. if !ok {
  9890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9891. }
  9892. m.SetNickname(v)
  9893. return nil
  9894. case wx.FieldTel:
  9895. v, ok := value.(string)
  9896. if !ok {
  9897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9898. }
  9899. m.SetTel(v)
  9900. return nil
  9901. case wx.FieldHeadBig:
  9902. v, ok := value.(string)
  9903. if !ok {
  9904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9905. }
  9906. m.SetHeadBig(v)
  9907. return nil
  9908. }
  9909. return fmt.Errorf("unknown Wx field %s", name)
  9910. }
  9911. // AddedFields returns all numeric fields that were incremented/decremented during
  9912. // this mutation.
  9913. func (m *WxMutation) AddedFields() []string {
  9914. var fields []string
  9915. if m.addstatus != nil {
  9916. fields = append(fields, wx.FieldStatus)
  9917. }
  9918. return fields
  9919. }
  9920. // AddedField returns the numeric value that was incremented/decremented on a field
  9921. // with the given name. The second boolean return value indicates that this field
  9922. // was not set, or was not defined in the schema.
  9923. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  9924. switch name {
  9925. case wx.FieldStatus:
  9926. return m.AddedStatus()
  9927. }
  9928. return nil, false
  9929. }
  9930. // AddField adds the value to the field with the given name. It returns an error if
  9931. // the field is not defined in the schema, or if the type mismatched the field
  9932. // type.
  9933. func (m *WxMutation) AddField(name string, value ent.Value) error {
  9934. switch name {
  9935. case wx.FieldStatus:
  9936. v, ok := value.(int8)
  9937. if !ok {
  9938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9939. }
  9940. m.AddStatus(v)
  9941. return nil
  9942. }
  9943. return fmt.Errorf("unknown Wx numeric field %s", name)
  9944. }
  9945. // ClearedFields returns all nullable fields that were cleared during this
  9946. // mutation.
  9947. func (m *WxMutation) ClearedFields() []string {
  9948. var fields []string
  9949. if m.FieldCleared(wx.FieldStatus) {
  9950. fields = append(fields, wx.FieldStatus)
  9951. }
  9952. if m.FieldCleared(wx.FieldDeletedAt) {
  9953. fields = append(fields, wx.FieldDeletedAt)
  9954. }
  9955. if m.FieldCleared(wx.FieldServerID) {
  9956. fields = append(fields, wx.FieldServerID)
  9957. }
  9958. return fields
  9959. }
  9960. // FieldCleared returns a boolean indicating if a field with the given name was
  9961. // cleared in this mutation.
  9962. func (m *WxMutation) FieldCleared(name string) bool {
  9963. _, ok := m.clearedFields[name]
  9964. return ok
  9965. }
  9966. // ClearField clears the value of the field with the given name. It returns an
  9967. // error if the field is not defined in the schema.
  9968. func (m *WxMutation) ClearField(name string) error {
  9969. switch name {
  9970. case wx.FieldStatus:
  9971. m.ClearStatus()
  9972. return nil
  9973. case wx.FieldDeletedAt:
  9974. m.ClearDeletedAt()
  9975. return nil
  9976. case wx.FieldServerID:
  9977. m.ClearServerID()
  9978. return nil
  9979. }
  9980. return fmt.Errorf("unknown Wx nullable field %s", name)
  9981. }
  9982. // ResetField resets all changes in the mutation for the field with the given name.
  9983. // It returns an error if the field is not defined in the schema.
  9984. func (m *WxMutation) ResetField(name string) error {
  9985. switch name {
  9986. case wx.FieldCreatedAt:
  9987. m.ResetCreatedAt()
  9988. return nil
  9989. case wx.FieldUpdatedAt:
  9990. m.ResetUpdatedAt()
  9991. return nil
  9992. case wx.FieldStatus:
  9993. m.ResetStatus()
  9994. return nil
  9995. case wx.FieldDeletedAt:
  9996. m.ResetDeletedAt()
  9997. return nil
  9998. case wx.FieldServerID:
  9999. m.ResetServerID()
  10000. return nil
  10001. case wx.FieldPort:
  10002. m.ResetPort()
  10003. return nil
  10004. case wx.FieldProcessID:
  10005. m.ResetProcessID()
  10006. return nil
  10007. case wx.FieldCallback:
  10008. m.ResetCallback()
  10009. return nil
  10010. case wx.FieldWxid:
  10011. m.ResetWxid()
  10012. return nil
  10013. case wx.FieldAccount:
  10014. m.ResetAccount()
  10015. return nil
  10016. case wx.FieldNickname:
  10017. m.ResetNickname()
  10018. return nil
  10019. case wx.FieldTel:
  10020. m.ResetTel()
  10021. return nil
  10022. case wx.FieldHeadBig:
  10023. m.ResetHeadBig()
  10024. return nil
  10025. }
  10026. return fmt.Errorf("unknown Wx field %s", name)
  10027. }
  10028. // AddedEdges returns all edge names that were set/added in this mutation.
  10029. func (m *WxMutation) AddedEdges() []string {
  10030. edges := make([]string, 0, 1)
  10031. if m.server != nil {
  10032. edges = append(edges, wx.EdgeServer)
  10033. }
  10034. return edges
  10035. }
  10036. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10037. // name in this mutation.
  10038. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  10039. switch name {
  10040. case wx.EdgeServer:
  10041. if id := m.server; id != nil {
  10042. return []ent.Value{*id}
  10043. }
  10044. }
  10045. return nil
  10046. }
  10047. // RemovedEdges returns all edge names that were removed in this mutation.
  10048. func (m *WxMutation) RemovedEdges() []string {
  10049. edges := make([]string, 0, 1)
  10050. return edges
  10051. }
  10052. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10053. // the given name in this mutation.
  10054. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  10055. return nil
  10056. }
  10057. // ClearedEdges returns all edge names that were cleared in this mutation.
  10058. func (m *WxMutation) ClearedEdges() []string {
  10059. edges := make([]string, 0, 1)
  10060. if m.clearedserver {
  10061. edges = append(edges, wx.EdgeServer)
  10062. }
  10063. return edges
  10064. }
  10065. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10066. // was cleared in this mutation.
  10067. func (m *WxMutation) EdgeCleared(name string) bool {
  10068. switch name {
  10069. case wx.EdgeServer:
  10070. return m.clearedserver
  10071. }
  10072. return false
  10073. }
  10074. // ClearEdge clears the value of the edge with the given name. It returns an error
  10075. // if that edge is not defined in the schema.
  10076. func (m *WxMutation) ClearEdge(name string) error {
  10077. switch name {
  10078. case wx.EdgeServer:
  10079. m.ClearServer()
  10080. return nil
  10081. }
  10082. return fmt.Errorf("unknown Wx unique edge %s", name)
  10083. }
  10084. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10085. // It returns an error if the edge is not defined in the schema.
  10086. func (m *WxMutation) ResetEdge(name string) error {
  10087. switch name {
  10088. case wx.EdgeServer:
  10089. m.ResetServer()
  10090. return nil
  10091. }
  10092. return fmt.Errorf("unknown Wx edge %s", name)
  10093. }