mutation.go 424 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "sync"
  8. "time"
  9. "wechat-api/ent/batchmsg"
  10. "wechat-api/ent/contact"
  11. "wechat-api/ent/custom_types"
  12. "wechat-api/ent/label"
  13. "wechat-api/ent/labelrelationship"
  14. "wechat-api/ent/message"
  15. "wechat-api/ent/messagerecords"
  16. "wechat-api/ent/msg"
  17. "wechat-api/ent/predicate"
  18. "wechat-api/ent/server"
  19. "wechat-api/ent/sopnode"
  20. "wechat-api/ent/sopstage"
  21. "wechat-api/ent/soptask"
  22. "wechat-api/ent/wx"
  23. "entgo.io/ent"
  24. "entgo.io/ent/dialect/sql"
  25. )
  26. const (
  27. // Operation types.
  28. OpCreate = ent.OpCreate
  29. OpDelete = ent.OpDelete
  30. OpDeleteOne = ent.OpDeleteOne
  31. OpUpdate = ent.OpUpdate
  32. OpUpdateOne = ent.OpUpdateOne
  33. // Node types.
  34. TypeBatchMsg = "BatchMsg"
  35. TypeContact = "Contact"
  36. TypeLabel = "Label"
  37. TypeLabelRelationship = "LabelRelationship"
  38. TypeMessage = "Message"
  39. TypeMessageRecords = "MessageRecords"
  40. TypeMsg = "Msg"
  41. TypeServer = "Server"
  42. TypeSopNode = "SopNode"
  43. TypeSopStage = "SopStage"
  44. TypeSopTask = "SopTask"
  45. TypeWx = "Wx"
  46. )
  47. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  48. type BatchMsgMutation struct {
  49. config
  50. op Op
  51. typ string
  52. id *uint64
  53. created_at *time.Time
  54. updated_at *time.Time
  55. deleted_at *time.Time
  56. status *uint8
  57. addstatus *int8
  58. batch_no *string
  59. fromwxid *string
  60. msg *string
  61. tag *string
  62. total *int32
  63. addtotal *int32
  64. success *int32
  65. addsuccess *int32
  66. fail *int32
  67. addfail *int32
  68. start_time *time.Time
  69. stop_time *time.Time
  70. clearedFields map[string]struct{}
  71. done bool
  72. oldValue func(context.Context) (*BatchMsg, error)
  73. predicates []predicate.BatchMsg
  74. }
  75. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  76. // batchmsgOption allows management of the mutation configuration using functional options.
  77. type batchmsgOption func(*BatchMsgMutation)
  78. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  79. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  80. m := &BatchMsgMutation{
  81. config: c,
  82. op: op,
  83. typ: TypeBatchMsg,
  84. clearedFields: make(map[string]struct{}),
  85. }
  86. for _, opt := range opts {
  87. opt(m)
  88. }
  89. return m
  90. }
  91. // withBatchMsgID sets the ID field of the mutation.
  92. func withBatchMsgID(id uint64) batchmsgOption {
  93. return func(m *BatchMsgMutation) {
  94. var (
  95. err error
  96. once sync.Once
  97. value *BatchMsg
  98. )
  99. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  100. once.Do(func() {
  101. if m.done {
  102. err = errors.New("querying old values post mutation is not allowed")
  103. } else {
  104. value, err = m.Client().BatchMsg.Get(ctx, id)
  105. }
  106. })
  107. return value, err
  108. }
  109. m.id = &id
  110. }
  111. }
  112. // withBatchMsg sets the old BatchMsg of the mutation.
  113. func withBatchMsg(node *BatchMsg) batchmsgOption {
  114. return func(m *BatchMsgMutation) {
  115. m.oldValue = func(context.Context) (*BatchMsg, error) {
  116. return node, nil
  117. }
  118. m.id = &node.ID
  119. }
  120. }
  121. // Client returns a new `ent.Client` from the mutation. If the mutation was
  122. // executed in a transaction (ent.Tx), a transactional client is returned.
  123. func (m BatchMsgMutation) Client() *Client {
  124. client := &Client{config: m.config}
  125. client.init()
  126. return client
  127. }
  128. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  129. // it returns an error otherwise.
  130. func (m BatchMsgMutation) Tx() (*Tx, error) {
  131. if _, ok := m.driver.(*txDriver); !ok {
  132. return nil, errors.New("ent: mutation is not running in a transaction")
  133. }
  134. tx := &Tx{config: m.config}
  135. tx.init()
  136. return tx, nil
  137. }
  138. // SetID sets the value of the id field. Note that this
  139. // operation is only accepted on creation of BatchMsg entities.
  140. func (m *BatchMsgMutation) SetID(id uint64) {
  141. m.id = &id
  142. }
  143. // ID returns the ID value in the mutation. Note that the ID is only available
  144. // if it was provided to the builder or after it was returned from the database.
  145. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  146. if m.id == nil {
  147. return
  148. }
  149. return *m.id, true
  150. }
  151. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  152. // That means, if the mutation is applied within a transaction with an isolation level such
  153. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  154. // or updated by the mutation.
  155. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  156. switch {
  157. case m.op.Is(OpUpdateOne | OpDeleteOne):
  158. id, exists := m.ID()
  159. if exists {
  160. return []uint64{id}, nil
  161. }
  162. fallthrough
  163. case m.op.Is(OpUpdate | OpDelete):
  164. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  165. default:
  166. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  167. }
  168. }
  169. // SetCreatedAt sets the "created_at" field.
  170. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  171. m.created_at = &t
  172. }
  173. // CreatedAt returns the value of the "created_at" field in the mutation.
  174. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  175. v := m.created_at
  176. if v == nil {
  177. return
  178. }
  179. return *v, true
  180. }
  181. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  182. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  183. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  184. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  185. if !m.op.Is(OpUpdateOne) {
  186. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  187. }
  188. if m.id == nil || m.oldValue == nil {
  189. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  190. }
  191. oldValue, err := m.oldValue(ctx)
  192. if err != nil {
  193. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  194. }
  195. return oldValue.CreatedAt, nil
  196. }
  197. // ResetCreatedAt resets all changes to the "created_at" field.
  198. func (m *BatchMsgMutation) ResetCreatedAt() {
  199. m.created_at = nil
  200. }
  201. // SetUpdatedAt sets the "updated_at" field.
  202. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  203. m.updated_at = &t
  204. }
  205. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  206. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  207. v := m.updated_at
  208. if v == nil {
  209. return
  210. }
  211. return *v, true
  212. }
  213. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  214. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  215. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  216. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  217. if !m.op.Is(OpUpdateOne) {
  218. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  219. }
  220. if m.id == nil || m.oldValue == nil {
  221. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  222. }
  223. oldValue, err := m.oldValue(ctx)
  224. if err != nil {
  225. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  226. }
  227. return oldValue.UpdatedAt, nil
  228. }
  229. // ResetUpdatedAt resets all changes to the "updated_at" field.
  230. func (m *BatchMsgMutation) ResetUpdatedAt() {
  231. m.updated_at = nil
  232. }
  233. // SetDeletedAt sets the "deleted_at" field.
  234. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  235. m.deleted_at = &t
  236. }
  237. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  238. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  239. v := m.deleted_at
  240. if v == nil {
  241. return
  242. }
  243. return *v, true
  244. }
  245. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  246. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  247. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  248. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  249. if !m.op.Is(OpUpdateOne) {
  250. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  251. }
  252. if m.id == nil || m.oldValue == nil {
  253. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  254. }
  255. oldValue, err := m.oldValue(ctx)
  256. if err != nil {
  257. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  258. }
  259. return oldValue.DeletedAt, nil
  260. }
  261. // ClearDeletedAt clears the value of the "deleted_at" field.
  262. func (m *BatchMsgMutation) ClearDeletedAt() {
  263. m.deleted_at = nil
  264. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  265. }
  266. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  267. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  268. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  269. return ok
  270. }
  271. // ResetDeletedAt resets all changes to the "deleted_at" field.
  272. func (m *BatchMsgMutation) ResetDeletedAt() {
  273. m.deleted_at = nil
  274. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  275. }
  276. // SetStatus sets the "status" field.
  277. func (m *BatchMsgMutation) SetStatus(u uint8) {
  278. m.status = &u
  279. m.addstatus = nil
  280. }
  281. // Status returns the value of the "status" field in the mutation.
  282. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  283. v := m.status
  284. if v == nil {
  285. return
  286. }
  287. return *v, true
  288. }
  289. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  290. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  291. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  292. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  293. if !m.op.Is(OpUpdateOne) {
  294. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  295. }
  296. if m.id == nil || m.oldValue == nil {
  297. return v, errors.New("OldStatus requires an ID field in the mutation")
  298. }
  299. oldValue, err := m.oldValue(ctx)
  300. if err != nil {
  301. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  302. }
  303. return oldValue.Status, nil
  304. }
  305. // AddStatus adds u to the "status" field.
  306. func (m *BatchMsgMutation) AddStatus(u int8) {
  307. if m.addstatus != nil {
  308. *m.addstatus += u
  309. } else {
  310. m.addstatus = &u
  311. }
  312. }
  313. // AddedStatus returns the value that was added to the "status" field in this mutation.
  314. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  315. v := m.addstatus
  316. if v == nil {
  317. return
  318. }
  319. return *v, true
  320. }
  321. // ClearStatus clears the value of the "status" field.
  322. func (m *BatchMsgMutation) ClearStatus() {
  323. m.status = nil
  324. m.addstatus = nil
  325. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  326. }
  327. // StatusCleared returns if the "status" field was cleared in this mutation.
  328. func (m *BatchMsgMutation) StatusCleared() bool {
  329. _, ok := m.clearedFields[batchmsg.FieldStatus]
  330. return ok
  331. }
  332. // ResetStatus resets all changes to the "status" field.
  333. func (m *BatchMsgMutation) ResetStatus() {
  334. m.status = nil
  335. m.addstatus = nil
  336. delete(m.clearedFields, batchmsg.FieldStatus)
  337. }
  338. // SetBatchNo sets the "batch_no" field.
  339. func (m *BatchMsgMutation) SetBatchNo(s string) {
  340. m.batch_no = &s
  341. }
  342. // BatchNo returns the value of the "batch_no" field in the mutation.
  343. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  344. v := m.batch_no
  345. if v == nil {
  346. return
  347. }
  348. return *v, true
  349. }
  350. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  351. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  352. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  353. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  354. if !m.op.Is(OpUpdateOne) {
  355. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  356. }
  357. if m.id == nil || m.oldValue == nil {
  358. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  359. }
  360. oldValue, err := m.oldValue(ctx)
  361. if err != nil {
  362. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  363. }
  364. return oldValue.BatchNo, nil
  365. }
  366. // ClearBatchNo clears the value of the "batch_no" field.
  367. func (m *BatchMsgMutation) ClearBatchNo() {
  368. m.batch_no = nil
  369. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  370. }
  371. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  372. func (m *BatchMsgMutation) BatchNoCleared() bool {
  373. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  374. return ok
  375. }
  376. // ResetBatchNo resets all changes to the "batch_no" field.
  377. func (m *BatchMsgMutation) ResetBatchNo() {
  378. m.batch_no = nil
  379. delete(m.clearedFields, batchmsg.FieldBatchNo)
  380. }
  381. // SetFromwxid sets the "fromwxid" field.
  382. func (m *BatchMsgMutation) SetFromwxid(s string) {
  383. m.fromwxid = &s
  384. }
  385. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  386. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  387. v := m.fromwxid
  388. if v == nil {
  389. return
  390. }
  391. return *v, true
  392. }
  393. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  394. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  395. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  396. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  397. if !m.op.Is(OpUpdateOne) {
  398. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  399. }
  400. if m.id == nil || m.oldValue == nil {
  401. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  402. }
  403. oldValue, err := m.oldValue(ctx)
  404. if err != nil {
  405. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  406. }
  407. return oldValue.Fromwxid, nil
  408. }
  409. // ClearFromwxid clears the value of the "fromwxid" field.
  410. func (m *BatchMsgMutation) ClearFromwxid() {
  411. m.fromwxid = nil
  412. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  413. }
  414. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  415. func (m *BatchMsgMutation) FromwxidCleared() bool {
  416. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  417. return ok
  418. }
  419. // ResetFromwxid resets all changes to the "fromwxid" field.
  420. func (m *BatchMsgMutation) ResetFromwxid() {
  421. m.fromwxid = nil
  422. delete(m.clearedFields, batchmsg.FieldFromwxid)
  423. }
  424. // SetMsg sets the "msg" field.
  425. func (m *BatchMsgMutation) SetMsg(s string) {
  426. m.msg = &s
  427. }
  428. // Msg returns the value of the "msg" field in the mutation.
  429. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  430. v := m.msg
  431. if v == nil {
  432. return
  433. }
  434. return *v, true
  435. }
  436. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  437. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  438. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  439. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  440. if !m.op.Is(OpUpdateOne) {
  441. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  442. }
  443. if m.id == nil || m.oldValue == nil {
  444. return v, errors.New("OldMsg requires an ID field in the mutation")
  445. }
  446. oldValue, err := m.oldValue(ctx)
  447. if err != nil {
  448. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  449. }
  450. return oldValue.Msg, nil
  451. }
  452. // ClearMsg clears the value of the "msg" field.
  453. func (m *BatchMsgMutation) ClearMsg() {
  454. m.msg = nil
  455. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  456. }
  457. // MsgCleared returns if the "msg" field was cleared in this mutation.
  458. func (m *BatchMsgMutation) MsgCleared() bool {
  459. _, ok := m.clearedFields[batchmsg.FieldMsg]
  460. return ok
  461. }
  462. // ResetMsg resets all changes to the "msg" field.
  463. func (m *BatchMsgMutation) ResetMsg() {
  464. m.msg = nil
  465. delete(m.clearedFields, batchmsg.FieldMsg)
  466. }
  467. // SetTag sets the "tag" field.
  468. func (m *BatchMsgMutation) SetTag(s string) {
  469. m.tag = &s
  470. }
  471. // Tag returns the value of the "tag" field in the mutation.
  472. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  473. v := m.tag
  474. if v == nil {
  475. return
  476. }
  477. return *v, true
  478. }
  479. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  480. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  481. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  482. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  483. if !m.op.Is(OpUpdateOne) {
  484. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  485. }
  486. if m.id == nil || m.oldValue == nil {
  487. return v, errors.New("OldTag requires an ID field in the mutation")
  488. }
  489. oldValue, err := m.oldValue(ctx)
  490. if err != nil {
  491. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  492. }
  493. return oldValue.Tag, nil
  494. }
  495. // ClearTag clears the value of the "tag" field.
  496. func (m *BatchMsgMutation) ClearTag() {
  497. m.tag = nil
  498. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  499. }
  500. // TagCleared returns if the "tag" field was cleared in this mutation.
  501. func (m *BatchMsgMutation) TagCleared() bool {
  502. _, ok := m.clearedFields[batchmsg.FieldTag]
  503. return ok
  504. }
  505. // ResetTag resets all changes to the "tag" field.
  506. func (m *BatchMsgMutation) ResetTag() {
  507. m.tag = nil
  508. delete(m.clearedFields, batchmsg.FieldTag)
  509. }
  510. // SetTotal sets the "total" field.
  511. func (m *BatchMsgMutation) SetTotal(i int32) {
  512. m.total = &i
  513. m.addtotal = nil
  514. }
  515. // Total returns the value of the "total" field in the mutation.
  516. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  517. v := m.total
  518. if v == nil {
  519. return
  520. }
  521. return *v, true
  522. }
  523. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  524. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  526. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  527. if !m.op.Is(OpUpdateOne) {
  528. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  529. }
  530. if m.id == nil || m.oldValue == nil {
  531. return v, errors.New("OldTotal requires an ID field in the mutation")
  532. }
  533. oldValue, err := m.oldValue(ctx)
  534. if err != nil {
  535. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  536. }
  537. return oldValue.Total, nil
  538. }
  539. // AddTotal adds i to the "total" field.
  540. func (m *BatchMsgMutation) AddTotal(i int32) {
  541. if m.addtotal != nil {
  542. *m.addtotal += i
  543. } else {
  544. m.addtotal = &i
  545. }
  546. }
  547. // AddedTotal returns the value that was added to the "total" field in this mutation.
  548. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  549. v := m.addtotal
  550. if v == nil {
  551. return
  552. }
  553. return *v, true
  554. }
  555. // ClearTotal clears the value of the "total" field.
  556. func (m *BatchMsgMutation) ClearTotal() {
  557. m.total = nil
  558. m.addtotal = nil
  559. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  560. }
  561. // TotalCleared returns if the "total" field was cleared in this mutation.
  562. func (m *BatchMsgMutation) TotalCleared() bool {
  563. _, ok := m.clearedFields[batchmsg.FieldTotal]
  564. return ok
  565. }
  566. // ResetTotal resets all changes to the "total" field.
  567. func (m *BatchMsgMutation) ResetTotal() {
  568. m.total = nil
  569. m.addtotal = nil
  570. delete(m.clearedFields, batchmsg.FieldTotal)
  571. }
  572. // SetSuccess sets the "success" field.
  573. func (m *BatchMsgMutation) SetSuccess(i int32) {
  574. m.success = &i
  575. m.addsuccess = nil
  576. }
  577. // Success returns the value of the "success" field in the mutation.
  578. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  579. v := m.success
  580. if v == nil {
  581. return
  582. }
  583. return *v, true
  584. }
  585. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  586. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  587. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  588. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  589. if !m.op.Is(OpUpdateOne) {
  590. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  591. }
  592. if m.id == nil || m.oldValue == nil {
  593. return v, errors.New("OldSuccess requires an ID field in the mutation")
  594. }
  595. oldValue, err := m.oldValue(ctx)
  596. if err != nil {
  597. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  598. }
  599. return oldValue.Success, nil
  600. }
  601. // AddSuccess adds i to the "success" field.
  602. func (m *BatchMsgMutation) AddSuccess(i int32) {
  603. if m.addsuccess != nil {
  604. *m.addsuccess += i
  605. } else {
  606. m.addsuccess = &i
  607. }
  608. }
  609. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  610. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  611. v := m.addsuccess
  612. if v == nil {
  613. return
  614. }
  615. return *v, true
  616. }
  617. // ClearSuccess clears the value of the "success" field.
  618. func (m *BatchMsgMutation) ClearSuccess() {
  619. m.success = nil
  620. m.addsuccess = nil
  621. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  622. }
  623. // SuccessCleared returns if the "success" field was cleared in this mutation.
  624. func (m *BatchMsgMutation) SuccessCleared() bool {
  625. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  626. return ok
  627. }
  628. // ResetSuccess resets all changes to the "success" field.
  629. func (m *BatchMsgMutation) ResetSuccess() {
  630. m.success = nil
  631. m.addsuccess = nil
  632. delete(m.clearedFields, batchmsg.FieldSuccess)
  633. }
  634. // SetFail sets the "fail" field.
  635. func (m *BatchMsgMutation) SetFail(i int32) {
  636. m.fail = &i
  637. m.addfail = nil
  638. }
  639. // Fail returns the value of the "fail" field in the mutation.
  640. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  641. v := m.fail
  642. if v == nil {
  643. return
  644. }
  645. return *v, true
  646. }
  647. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  648. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  650. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  651. if !m.op.Is(OpUpdateOne) {
  652. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  653. }
  654. if m.id == nil || m.oldValue == nil {
  655. return v, errors.New("OldFail requires an ID field in the mutation")
  656. }
  657. oldValue, err := m.oldValue(ctx)
  658. if err != nil {
  659. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  660. }
  661. return oldValue.Fail, nil
  662. }
  663. // AddFail adds i to the "fail" field.
  664. func (m *BatchMsgMutation) AddFail(i int32) {
  665. if m.addfail != nil {
  666. *m.addfail += i
  667. } else {
  668. m.addfail = &i
  669. }
  670. }
  671. // AddedFail returns the value that was added to the "fail" field in this mutation.
  672. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  673. v := m.addfail
  674. if v == nil {
  675. return
  676. }
  677. return *v, true
  678. }
  679. // ClearFail clears the value of the "fail" field.
  680. func (m *BatchMsgMutation) ClearFail() {
  681. m.fail = nil
  682. m.addfail = nil
  683. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  684. }
  685. // FailCleared returns if the "fail" field was cleared in this mutation.
  686. func (m *BatchMsgMutation) FailCleared() bool {
  687. _, ok := m.clearedFields[batchmsg.FieldFail]
  688. return ok
  689. }
  690. // ResetFail resets all changes to the "fail" field.
  691. func (m *BatchMsgMutation) ResetFail() {
  692. m.fail = nil
  693. m.addfail = nil
  694. delete(m.clearedFields, batchmsg.FieldFail)
  695. }
  696. // SetStartTime sets the "start_time" field.
  697. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  698. m.start_time = &t
  699. }
  700. // StartTime returns the value of the "start_time" field in the mutation.
  701. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  702. v := m.start_time
  703. if v == nil {
  704. return
  705. }
  706. return *v, true
  707. }
  708. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  709. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  710. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  711. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  712. if !m.op.Is(OpUpdateOne) {
  713. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  714. }
  715. if m.id == nil || m.oldValue == nil {
  716. return v, errors.New("OldStartTime requires an ID field in the mutation")
  717. }
  718. oldValue, err := m.oldValue(ctx)
  719. if err != nil {
  720. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  721. }
  722. return oldValue.StartTime, nil
  723. }
  724. // ClearStartTime clears the value of the "start_time" field.
  725. func (m *BatchMsgMutation) ClearStartTime() {
  726. m.start_time = nil
  727. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  728. }
  729. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  730. func (m *BatchMsgMutation) StartTimeCleared() bool {
  731. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  732. return ok
  733. }
  734. // ResetStartTime resets all changes to the "start_time" field.
  735. func (m *BatchMsgMutation) ResetStartTime() {
  736. m.start_time = nil
  737. delete(m.clearedFields, batchmsg.FieldStartTime)
  738. }
  739. // SetStopTime sets the "stop_time" field.
  740. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  741. m.stop_time = &t
  742. }
  743. // StopTime returns the value of the "stop_time" field in the mutation.
  744. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  745. v := m.stop_time
  746. if v == nil {
  747. return
  748. }
  749. return *v, true
  750. }
  751. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  752. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  753. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  754. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  755. if !m.op.Is(OpUpdateOne) {
  756. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  757. }
  758. if m.id == nil || m.oldValue == nil {
  759. return v, errors.New("OldStopTime requires an ID field in the mutation")
  760. }
  761. oldValue, err := m.oldValue(ctx)
  762. if err != nil {
  763. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  764. }
  765. return oldValue.StopTime, nil
  766. }
  767. // ClearStopTime clears the value of the "stop_time" field.
  768. func (m *BatchMsgMutation) ClearStopTime() {
  769. m.stop_time = nil
  770. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  771. }
  772. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  773. func (m *BatchMsgMutation) StopTimeCleared() bool {
  774. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  775. return ok
  776. }
  777. // ResetStopTime resets all changes to the "stop_time" field.
  778. func (m *BatchMsgMutation) ResetStopTime() {
  779. m.stop_time = nil
  780. delete(m.clearedFields, batchmsg.FieldStopTime)
  781. }
  782. // Where appends a list predicates to the BatchMsgMutation builder.
  783. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  784. m.predicates = append(m.predicates, ps...)
  785. }
  786. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  787. // users can use type-assertion to append predicates that do not depend on any generated package.
  788. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  789. p := make([]predicate.BatchMsg, len(ps))
  790. for i := range ps {
  791. p[i] = ps[i]
  792. }
  793. m.Where(p...)
  794. }
  795. // Op returns the operation name.
  796. func (m *BatchMsgMutation) Op() Op {
  797. return m.op
  798. }
  799. // SetOp allows setting the mutation operation.
  800. func (m *BatchMsgMutation) SetOp(op Op) {
  801. m.op = op
  802. }
  803. // Type returns the node type of this mutation (BatchMsg).
  804. func (m *BatchMsgMutation) Type() string {
  805. return m.typ
  806. }
  807. // Fields returns all fields that were changed during this mutation. Note that in
  808. // order to get all numeric fields that were incremented/decremented, call
  809. // AddedFields().
  810. func (m *BatchMsgMutation) Fields() []string {
  811. fields := make([]string, 0, 13)
  812. if m.created_at != nil {
  813. fields = append(fields, batchmsg.FieldCreatedAt)
  814. }
  815. if m.updated_at != nil {
  816. fields = append(fields, batchmsg.FieldUpdatedAt)
  817. }
  818. if m.deleted_at != nil {
  819. fields = append(fields, batchmsg.FieldDeletedAt)
  820. }
  821. if m.status != nil {
  822. fields = append(fields, batchmsg.FieldStatus)
  823. }
  824. if m.batch_no != nil {
  825. fields = append(fields, batchmsg.FieldBatchNo)
  826. }
  827. if m.fromwxid != nil {
  828. fields = append(fields, batchmsg.FieldFromwxid)
  829. }
  830. if m.msg != nil {
  831. fields = append(fields, batchmsg.FieldMsg)
  832. }
  833. if m.tag != nil {
  834. fields = append(fields, batchmsg.FieldTag)
  835. }
  836. if m.total != nil {
  837. fields = append(fields, batchmsg.FieldTotal)
  838. }
  839. if m.success != nil {
  840. fields = append(fields, batchmsg.FieldSuccess)
  841. }
  842. if m.fail != nil {
  843. fields = append(fields, batchmsg.FieldFail)
  844. }
  845. if m.start_time != nil {
  846. fields = append(fields, batchmsg.FieldStartTime)
  847. }
  848. if m.stop_time != nil {
  849. fields = append(fields, batchmsg.FieldStopTime)
  850. }
  851. return fields
  852. }
  853. // Field returns the value of a field with the given name. The second boolean
  854. // return value indicates that this field was not set, or was not defined in the
  855. // schema.
  856. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  857. switch name {
  858. case batchmsg.FieldCreatedAt:
  859. return m.CreatedAt()
  860. case batchmsg.FieldUpdatedAt:
  861. return m.UpdatedAt()
  862. case batchmsg.FieldDeletedAt:
  863. return m.DeletedAt()
  864. case batchmsg.FieldStatus:
  865. return m.Status()
  866. case batchmsg.FieldBatchNo:
  867. return m.BatchNo()
  868. case batchmsg.FieldFromwxid:
  869. return m.Fromwxid()
  870. case batchmsg.FieldMsg:
  871. return m.Msg()
  872. case batchmsg.FieldTag:
  873. return m.Tag()
  874. case batchmsg.FieldTotal:
  875. return m.Total()
  876. case batchmsg.FieldSuccess:
  877. return m.Success()
  878. case batchmsg.FieldFail:
  879. return m.Fail()
  880. case batchmsg.FieldStartTime:
  881. return m.StartTime()
  882. case batchmsg.FieldStopTime:
  883. return m.StopTime()
  884. }
  885. return nil, false
  886. }
  887. // OldField returns the old value of the field from the database. An error is
  888. // returned if the mutation operation is not UpdateOne, or the query to the
  889. // database failed.
  890. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  891. switch name {
  892. case batchmsg.FieldCreatedAt:
  893. return m.OldCreatedAt(ctx)
  894. case batchmsg.FieldUpdatedAt:
  895. return m.OldUpdatedAt(ctx)
  896. case batchmsg.FieldDeletedAt:
  897. return m.OldDeletedAt(ctx)
  898. case batchmsg.FieldStatus:
  899. return m.OldStatus(ctx)
  900. case batchmsg.FieldBatchNo:
  901. return m.OldBatchNo(ctx)
  902. case batchmsg.FieldFromwxid:
  903. return m.OldFromwxid(ctx)
  904. case batchmsg.FieldMsg:
  905. return m.OldMsg(ctx)
  906. case batchmsg.FieldTag:
  907. return m.OldTag(ctx)
  908. case batchmsg.FieldTotal:
  909. return m.OldTotal(ctx)
  910. case batchmsg.FieldSuccess:
  911. return m.OldSuccess(ctx)
  912. case batchmsg.FieldFail:
  913. return m.OldFail(ctx)
  914. case batchmsg.FieldStartTime:
  915. return m.OldStartTime(ctx)
  916. case batchmsg.FieldStopTime:
  917. return m.OldStopTime(ctx)
  918. }
  919. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  920. }
  921. // SetField sets the value of a field with the given name. It returns an error if
  922. // the field is not defined in the schema, or if the type mismatched the field
  923. // type.
  924. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  925. switch name {
  926. case batchmsg.FieldCreatedAt:
  927. v, ok := value.(time.Time)
  928. if !ok {
  929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  930. }
  931. m.SetCreatedAt(v)
  932. return nil
  933. case batchmsg.FieldUpdatedAt:
  934. v, ok := value.(time.Time)
  935. if !ok {
  936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  937. }
  938. m.SetUpdatedAt(v)
  939. return nil
  940. case batchmsg.FieldDeletedAt:
  941. v, ok := value.(time.Time)
  942. if !ok {
  943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  944. }
  945. m.SetDeletedAt(v)
  946. return nil
  947. case batchmsg.FieldStatus:
  948. v, ok := value.(uint8)
  949. if !ok {
  950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  951. }
  952. m.SetStatus(v)
  953. return nil
  954. case batchmsg.FieldBatchNo:
  955. v, ok := value.(string)
  956. if !ok {
  957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  958. }
  959. m.SetBatchNo(v)
  960. return nil
  961. case batchmsg.FieldFromwxid:
  962. v, ok := value.(string)
  963. if !ok {
  964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  965. }
  966. m.SetFromwxid(v)
  967. return nil
  968. case batchmsg.FieldMsg:
  969. v, ok := value.(string)
  970. if !ok {
  971. return fmt.Errorf("unexpected type %T for field %s", value, name)
  972. }
  973. m.SetMsg(v)
  974. return nil
  975. case batchmsg.FieldTag:
  976. v, ok := value.(string)
  977. if !ok {
  978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  979. }
  980. m.SetTag(v)
  981. return nil
  982. case batchmsg.FieldTotal:
  983. v, ok := value.(int32)
  984. if !ok {
  985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  986. }
  987. m.SetTotal(v)
  988. return nil
  989. case batchmsg.FieldSuccess:
  990. v, ok := value.(int32)
  991. if !ok {
  992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  993. }
  994. m.SetSuccess(v)
  995. return nil
  996. case batchmsg.FieldFail:
  997. v, ok := value.(int32)
  998. if !ok {
  999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1000. }
  1001. m.SetFail(v)
  1002. return nil
  1003. case batchmsg.FieldStartTime:
  1004. v, ok := value.(time.Time)
  1005. if !ok {
  1006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1007. }
  1008. m.SetStartTime(v)
  1009. return nil
  1010. case batchmsg.FieldStopTime:
  1011. v, ok := value.(time.Time)
  1012. if !ok {
  1013. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1014. }
  1015. m.SetStopTime(v)
  1016. return nil
  1017. }
  1018. return fmt.Errorf("unknown BatchMsg field %s", name)
  1019. }
  1020. // AddedFields returns all numeric fields that were incremented/decremented during
  1021. // this mutation.
  1022. func (m *BatchMsgMutation) AddedFields() []string {
  1023. var fields []string
  1024. if m.addstatus != nil {
  1025. fields = append(fields, batchmsg.FieldStatus)
  1026. }
  1027. if m.addtotal != nil {
  1028. fields = append(fields, batchmsg.FieldTotal)
  1029. }
  1030. if m.addsuccess != nil {
  1031. fields = append(fields, batchmsg.FieldSuccess)
  1032. }
  1033. if m.addfail != nil {
  1034. fields = append(fields, batchmsg.FieldFail)
  1035. }
  1036. return fields
  1037. }
  1038. // AddedField returns the numeric value that was incremented/decremented on a field
  1039. // with the given name. The second boolean return value indicates that this field
  1040. // was not set, or was not defined in the schema.
  1041. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  1042. switch name {
  1043. case batchmsg.FieldStatus:
  1044. return m.AddedStatus()
  1045. case batchmsg.FieldTotal:
  1046. return m.AddedTotal()
  1047. case batchmsg.FieldSuccess:
  1048. return m.AddedSuccess()
  1049. case batchmsg.FieldFail:
  1050. return m.AddedFail()
  1051. }
  1052. return nil, false
  1053. }
  1054. // AddField adds the value to the field with the given name. It returns an error if
  1055. // the field is not defined in the schema, or if the type mismatched the field
  1056. // type.
  1057. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  1058. switch name {
  1059. case batchmsg.FieldStatus:
  1060. v, ok := value.(int8)
  1061. if !ok {
  1062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1063. }
  1064. m.AddStatus(v)
  1065. return nil
  1066. case batchmsg.FieldTotal:
  1067. v, ok := value.(int32)
  1068. if !ok {
  1069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1070. }
  1071. m.AddTotal(v)
  1072. return nil
  1073. case batchmsg.FieldSuccess:
  1074. v, ok := value.(int32)
  1075. if !ok {
  1076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1077. }
  1078. m.AddSuccess(v)
  1079. return nil
  1080. case batchmsg.FieldFail:
  1081. v, ok := value.(int32)
  1082. if !ok {
  1083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1084. }
  1085. m.AddFail(v)
  1086. return nil
  1087. }
  1088. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  1089. }
  1090. // ClearedFields returns all nullable fields that were cleared during this
  1091. // mutation.
  1092. func (m *BatchMsgMutation) ClearedFields() []string {
  1093. var fields []string
  1094. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  1095. fields = append(fields, batchmsg.FieldDeletedAt)
  1096. }
  1097. if m.FieldCleared(batchmsg.FieldStatus) {
  1098. fields = append(fields, batchmsg.FieldStatus)
  1099. }
  1100. if m.FieldCleared(batchmsg.FieldBatchNo) {
  1101. fields = append(fields, batchmsg.FieldBatchNo)
  1102. }
  1103. if m.FieldCleared(batchmsg.FieldFromwxid) {
  1104. fields = append(fields, batchmsg.FieldFromwxid)
  1105. }
  1106. if m.FieldCleared(batchmsg.FieldMsg) {
  1107. fields = append(fields, batchmsg.FieldMsg)
  1108. }
  1109. if m.FieldCleared(batchmsg.FieldTag) {
  1110. fields = append(fields, batchmsg.FieldTag)
  1111. }
  1112. if m.FieldCleared(batchmsg.FieldTotal) {
  1113. fields = append(fields, batchmsg.FieldTotal)
  1114. }
  1115. if m.FieldCleared(batchmsg.FieldSuccess) {
  1116. fields = append(fields, batchmsg.FieldSuccess)
  1117. }
  1118. if m.FieldCleared(batchmsg.FieldFail) {
  1119. fields = append(fields, batchmsg.FieldFail)
  1120. }
  1121. if m.FieldCleared(batchmsg.FieldStartTime) {
  1122. fields = append(fields, batchmsg.FieldStartTime)
  1123. }
  1124. if m.FieldCleared(batchmsg.FieldStopTime) {
  1125. fields = append(fields, batchmsg.FieldStopTime)
  1126. }
  1127. return fields
  1128. }
  1129. // FieldCleared returns a boolean indicating if a field with the given name was
  1130. // cleared in this mutation.
  1131. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  1132. _, ok := m.clearedFields[name]
  1133. return ok
  1134. }
  1135. // ClearField clears the value of the field with the given name. It returns an
  1136. // error if the field is not defined in the schema.
  1137. func (m *BatchMsgMutation) ClearField(name string) error {
  1138. switch name {
  1139. case batchmsg.FieldDeletedAt:
  1140. m.ClearDeletedAt()
  1141. return nil
  1142. case batchmsg.FieldStatus:
  1143. m.ClearStatus()
  1144. return nil
  1145. case batchmsg.FieldBatchNo:
  1146. m.ClearBatchNo()
  1147. return nil
  1148. case batchmsg.FieldFromwxid:
  1149. m.ClearFromwxid()
  1150. return nil
  1151. case batchmsg.FieldMsg:
  1152. m.ClearMsg()
  1153. return nil
  1154. case batchmsg.FieldTag:
  1155. m.ClearTag()
  1156. return nil
  1157. case batchmsg.FieldTotal:
  1158. m.ClearTotal()
  1159. return nil
  1160. case batchmsg.FieldSuccess:
  1161. m.ClearSuccess()
  1162. return nil
  1163. case batchmsg.FieldFail:
  1164. m.ClearFail()
  1165. return nil
  1166. case batchmsg.FieldStartTime:
  1167. m.ClearStartTime()
  1168. return nil
  1169. case batchmsg.FieldStopTime:
  1170. m.ClearStopTime()
  1171. return nil
  1172. }
  1173. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  1174. }
  1175. // ResetField resets all changes in the mutation for the field with the given name.
  1176. // It returns an error if the field is not defined in the schema.
  1177. func (m *BatchMsgMutation) ResetField(name string) error {
  1178. switch name {
  1179. case batchmsg.FieldCreatedAt:
  1180. m.ResetCreatedAt()
  1181. return nil
  1182. case batchmsg.FieldUpdatedAt:
  1183. m.ResetUpdatedAt()
  1184. return nil
  1185. case batchmsg.FieldDeletedAt:
  1186. m.ResetDeletedAt()
  1187. return nil
  1188. case batchmsg.FieldStatus:
  1189. m.ResetStatus()
  1190. return nil
  1191. case batchmsg.FieldBatchNo:
  1192. m.ResetBatchNo()
  1193. return nil
  1194. case batchmsg.FieldFromwxid:
  1195. m.ResetFromwxid()
  1196. return nil
  1197. case batchmsg.FieldMsg:
  1198. m.ResetMsg()
  1199. return nil
  1200. case batchmsg.FieldTag:
  1201. m.ResetTag()
  1202. return nil
  1203. case batchmsg.FieldTotal:
  1204. m.ResetTotal()
  1205. return nil
  1206. case batchmsg.FieldSuccess:
  1207. m.ResetSuccess()
  1208. return nil
  1209. case batchmsg.FieldFail:
  1210. m.ResetFail()
  1211. return nil
  1212. case batchmsg.FieldStartTime:
  1213. m.ResetStartTime()
  1214. return nil
  1215. case batchmsg.FieldStopTime:
  1216. m.ResetStopTime()
  1217. return nil
  1218. }
  1219. return fmt.Errorf("unknown BatchMsg field %s", name)
  1220. }
  1221. // AddedEdges returns all edge names that were set/added in this mutation.
  1222. func (m *BatchMsgMutation) AddedEdges() []string {
  1223. edges := make([]string, 0, 0)
  1224. return edges
  1225. }
  1226. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1227. // name in this mutation.
  1228. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  1229. return nil
  1230. }
  1231. // RemovedEdges returns all edge names that were removed in this mutation.
  1232. func (m *BatchMsgMutation) RemovedEdges() []string {
  1233. edges := make([]string, 0, 0)
  1234. return edges
  1235. }
  1236. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1237. // the given name in this mutation.
  1238. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  1239. return nil
  1240. }
  1241. // ClearedEdges returns all edge names that were cleared in this mutation.
  1242. func (m *BatchMsgMutation) ClearedEdges() []string {
  1243. edges := make([]string, 0, 0)
  1244. return edges
  1245. }
  1246. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1247. // was cleared in this mutation.
  1248. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  1249. return false
  1250. }
  1251. // ClearEdge clears the value of the edge with the given name. It returns an error
  1252. // if that edge is not defined in the schema.
  1253. func (m *BatchMsgMutation) ClearEdge(name string) error {
  1254. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  1255. }
  1256. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1257. // It returns an error if the edge is not defined in the schema.
  1258. func (m *BatchMsgMutation) ResetEdge(name string) error {
  1259. return fmt.Errorf("unknown BatchMsg edge %s", name)
  1260. }
  1261. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  1262. type ContactMutation struct {
  1263. config
  1264. op Op
  1265. typ string
  1266. id *uint64
  1267. created_at *time.Time
  1268. updated_at *time.Time
  1269. status *uint8
  1270. addstatus *int8
  1271. deleted_at *time.Time
  1272. wx_wxid *string
  1273. _type *int
  1274. add_type *int
  1275. wxid *string
  1276. account *string
  1277. nickname *string
  1278. markname *string
  1279. headimg *string
  1280. sex *int
  1281. addsex *int
  1282. starrole *string
  1283. dontseeit *int
  1284. adddontseeit *int
  1285. dontseeme *int
  1286. adddontseeme *int
  1287. lag *string
  1288. gid *string
  1289. gname *string
  1290. v3 *string
  1291. organization_id *uint64
  1292. addorganization_id *int64
  1293. clearedFields map[string]struct{}
  1294. contact_relationships map[uint64]struct{}
  1295. removedcontact_relationships map[uint64]struct{}
  1296. clearedcontact_relationships bool
  1297. contact_messages map[uint64]struct{}
  1298. removedcontact_messages map[uint64]struct{}
  1299. clearedcontact_messages bool
  1300. done bool
  1301. oldValue func(context.Context) (*Contact, error)
  1302. predicates []predicate.Contact
  1303. }
  1304. var _ ent.Mutation = (*ContactMutation)(nil)
  1305. // contactOption allows management of the mutation configuration using functional options.
  1306. type contactOption func(*ContactMutation)
  1307. // newContactMutation creates new mutation for the Contact entity.
  1308. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  1309. m := &ContactMutation{
  1310. config: c,
  1311. op: op,
  1312. typ: TypeContact,
  1313. clearedFields: make(map[string]struct{}),
  1314. }
  1315. for _, opt := range opts {
  1316. opt(m)
  1317. }
  1318. return m
  1319. }
  1320. // withContactID sets the ID field of the mutation.
  1321. func withContactID(id uint64) contactOption {
  1322. return func(m *ContactMutation) {
  1323. var (
  1324. err error
  1325. once sync.Once
  1326. value *Contact
  1327. )
  1328. m.oldValue = func(ctx context.Context) (*Contact, error) {
  1329. once.Do(func() {
  1330. if m.done {
  1331. err = errors.New("querying old values post mutation is not allowed")
  1332. } else {
  1333. value, err = m.Client().Contact.Get(ctx, id)
  1334. }
  1335. })
  1336. return value, err
  1337. }
  1338. m.id = &id
  1339. }
  1340. }
  1341. // withContact sets the old Contact of the mutation.
  1342. func withContact(node *Contact) contactOption {
  1343. return func(m *ContactMutation) {
  1344. m.oldValue = func(context.Context) (*Contact, error) {
  1345. return node, nil
  1346. }
  1347. m.id = &node.ID
  1348. }
  1349. }
  1350. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1351. // executed in a transaction (ent.Tx), a transactional client is returned.
  1352. func (m ContactMutation) Client() *Client {
  1353. client := &Client{config: m.config}
  1354. client.init()
  1355. return client
  1356. }
  1357. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1358. // it returns an error otherwise.
  1359. func (m ContactMutation) Tx() (*Tx, error) {
  1360. if _, ok := m.driver.(*txDriver); !ok {
  1361. return nil, errors.New("ent: mutation is not running in a transaction")
  1362. }
  1363. tx := &Tx{config: m.config}
  1364. tx.init()
  1365. return tx, nil
  1366. }
  1367. // SetID sets the value of the id field. Note that this
  1368. // operation is only accepted on creation of Contact entities.
  1369. func (m *ContactMutation) SetID(id uint64) {
  1370. m.id = &id
  1371. }
  1372. // ID returns the ID value in the mutation. Note that the ID is only available
  1373. // if it was provided to the builder or after it was returned from the database.
  1374. func (m *ContactMutation) ID() (id uint64, exists bool) {
  1375. if m.id == nil {
  1376. return
  1377. }
  1378. return *m.id, true
  1379. }
  1380. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1381. // That means, if the mutation is applied within a transaction with an isolation level such
  1382. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1383. // or updated by the mutation.
  1384. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  1385. switch {
  1386. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1387. id, exists := m.ID()
  1388. if exists {
  1389. return []uint64{id}, nil
  1390. }
  1391. fallthrough
  1392. case m.op.Is(OpUpdate | OpDelete):
  1393. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  1394. default:
  1395. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1396. }
  1397. }
  1398. // SetCreatedAt sets the "created_at" field.
  1399. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  1400. m.created_at = &t
  1401. }
  1402. // CreatedAt returns the value of the "created_at" field in the mutation.
  1403. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  1404. v := m.created_at
  1405. if v == nil {
  1406. return
  1407. }
  1408. return *v, true
  1409. }
  1410. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  1411. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1412. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1413. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  1414. if !m.op.Is(OpUpdateOne) {
  1415. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  1416. }
  1417. if m.id == nil || m.oldValue == nil {
  1418. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  1419. }
  1420. oldValue, err := m.oldValue(ctx)
  1421. if err != nil {
  1422. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  1423. }
  1424. return oldValue.CreatedAt, nil
  1425. }
  1426. // ResetCreatedAt resets all changes to the "created_at" field.
  1427. func (m *ContactMutation) ResetCreatedAt() {
  1428. m.created_at = nil
  1429. }
  1430. // SetUpdatedAt sets the "updated_at" field.
  1431. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  1432. m.updated_at = &t
  1433. }
  1434. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  1435. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  1436. v := m.updated_at
  1437. if v == nil {
  1438. return
  1439. }
  1440. return *v, true
  1441. }
  1442. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  1443. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1445. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  1446. if !m.op.Is(OpUpdateOne) {
  1447. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  1448. }
  1449. if m.id == nil || m.oldValue == nil {
  1450. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  1451. }
  1452. oldValue, err := m.oldValue(ctx)
  1453. if err != nil {
  1454. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  1455. }
  1456. return oldValue.UpdatedAt, nil
  1457. }
  1458. // ResetUpdatedAt resets all changes to the "updated_at" field.
  1459. func (m *ContactMutation) ResetUpdatedAt() {
  1460. m.updated_at = nil
  1461. }
  1462. // SetStatus sets the "status" field.
  1463. func (m *ContactMutation) SetStatus(u uint8) {
  1464. m.status = &u
  1465. m.addstatus = nil
  1466. }
  1467. // Status returns the value of the "status" field in the mutation.
  1468. func (m *ContactMutation) Status() (r uint8, exists bool) {
  1469. v := m.status
  1470. if v == nil {
  1471. return
  1472. }
  1473. return *v, true
  1474. }
  1475. // OldStatus returns the old "status" field's value of the Contact entity.
  1476. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1477. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1478. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  1479. if !m.op.Is(OpUpdateOne) {
  1480. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  1481. }
  1482. if m.id == nil || m.oldValue == nil {
  1483. return v, errors.New("OldStatus requires an ID field in the mutation")
  1484. }
  1485. oldValue, err := m.oldValue(ctx)
  1486. if err != nil {
  1487. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  1488. }
  1489. return oldValue.Status, nil
  1490. }
  1491. // AddStatus adds u to the "status" field.
  1492. func (m *ContactMutation) AddStatus(u int8) {
  1493. if m.addstatus != nil {
  1494. *m.addstatus += u
  1495. } else {
  1496. m.addstatus = &u
  1497. }
  1498. }
  1499. // AddedStatus returns the value that was added to the "status" field in this mutation.
  1500. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  1501. v := m.addstatus
  1502. if v == nil {
  1503. return
  1504. }
  1505. return *v, true
  1506. }
  1507. // ClearStatus clears the value of the "status" field.
  1508. func (m *ContactMutation) ClearStatus() {
  1509. m.status = nil
  1510. m.addstatus = nil
  1511. m.clearedFields[contact.FieldStatus] = struct{}{}
  1512. }
  1513. // StatusCleared returns if the "status" field was cleared in this mutation.
  1514. func (m *ContactMutation) StatusCleared() bool {
  1515. _, ok := m.clearedFields[contact.FieldStatus]
  1516. return ok
  1517. }
  1518. // ResetStatus resets all changes to the "status" field.
  1519. func (m *ContactMutation) ResetStatus() {
  1520. m.status = nil
  1521. m.addstatus = nil
  1522. delete(m.clearedFields, contact.FieldStatus)
  1523. }
  1524. // SetDeletedAt sets the "deleted_at" field.
  1525. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  1526. m.deleted_at = &t
  1527. }
  1528. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  1529. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  1530. v := m.deleted_at
  1531. if v == nil {
  1532. return
  1533. }
  1534. return *v, true
  1535. }
  1536. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  1537. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1538. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1539. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  1540. if !m.op.Is(OpUpdateOne) {
  1541. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  1542. }
  1543. if m.id == nil || m.oldValue == nil {
  1544. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  1545. }
  1546. oldValue, err := m.oldValue(ctx)
  1547. if err != nil {
  1548. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  1549. }
  1550. return oldValue.DeletedAt, nil
  1551. }
  1552. // ClearDeletedAt clears the value of the "deleted_at" field.
  1553. func (m *ContactMutation) ClearDeletedAt() {
  1554. m.deleted_at = nil
  1555. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  1556. }
  1557. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  1558. func (m *ContactMutation) DeletedAtCleared() bool {
  1559. _, ok := m.clearedFields[contact.FieldDeletedAt]
  1560. return ok
  1561. }
  1562. // ResetDeletedAt resets all changes to the "deleted_at" field.
  1563. func (m *ContactMutation) ResetDeletedAt() {
  1564. m.deleted_at = nil
  1565. delete(m.clearedFields, contact.FieldDeletedAt)
  1566. }
  1567. // SetWxWxid sets the "wx_wxid" field.
  1568. func (m *ContactMutation) SetWxWxid(s string) {
  1569. m.wx_wxid = &s
  1570. }
  1571. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  1572. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  1573. v := m.wx_wxid
  1574. if v == nil {
  1575. return
  1576. }
  1577. return *v, true
  1578. }
  1579. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  1580. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1581. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1582. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  1583. if !m.op.Is(OpUpdateOne) {
  1584. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  1585. }
  1586. if m.id == nil || m.oldValue == nil {
  1587. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  1588. }
  1589. oldValue, err := m.oldValue(ctx)
  1590. if err != nil {
  1591. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  1592. }
  1593. return oldValue.WxWxid, nil
  1594. }
  1595. // ClearWxWxid clears the value of the "wx_wxid" field.
  1596. func (m *ContactMutation) ClearWxWxid() {
  1597. m.wx_wxid = nil
  1598. m.clearedFields[contact.FieldWxWxid] = struct{}{}
  1599. }
  1600. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  1601. func (m *ContactMutation) WxWxidCleared() bool {
  1602. _, ok := m.clearedFields[contact.FieldWxWxid]
  1603. return ok
  1604. }
  1605. // ResetWxWxid resets all changes to the "wx_wxid" field.
  1606. func (m *ContactMutation) ResetWxWxid() {
  1607. m.wx_wxid = nil
  1608. delete(m.clearedFields, contact.FieldWxWxid)
  1609. }
  1610. // SetType sets the "type" field.
  1611. func (m *ContactMutation) SetType(i int) {
  1612. m._type = &i
  1613. m.add_type = nil
  1614. }
  1615. // GetType returns the value of the "type" field in the mutation.
  1616. func (m *ContactMutation) GetType() (r int, exists bool) {
  1617. v := m._type
  1618. if v == nil {
  1619. return
  1620. }
  1621. return *v, true
  1622. }
  1623. // OldType returns the old "type" field's value of the Contact entity.
  1624. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1626. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  1627. if !m.op.Is(OpUpdateOne) {
  1628. return v, errors.New("OldType is only allowed on UpdateOne operations")
  1629. }
  1630. if m.id == nil || m.oldValue == nil {
  1631. return v, errors.New("OldType requires an ID field in the mutation")
  1632. }
  1633. oldValue, err := m.oldValue(ctx)
  1634. if err != nil {
  1635. return v, fmt.Errorf("querying old value for OldType: %w", err)
  1636. }
  1637. return oldValue.Type, nil
  1638. }
  1639. // AddType adds i to the "type" field.
  1640. func (m *ContactMutation) AddType(i int) {
  1641. if m.add_type != nil {
  1642. *m.add_type += i
  1643. } else {
  1644. m.add_type = &i
  1645. }
  1646. }
  1647. // AddedType returns the value that was added to the "type" field in this mutation.
  1648. func (m *ContactMutation) AddedType() (r int, exists bool) {
  1649. v := m.add_type
  1650. if v == nil {
  1651. return
  1652. }
  1653. return *v, true
  1654. }
  1655. // ClearType clears the value of the "type" field.
  1656. func (m *ContactMutation) ClearType() {
  1657. m._type = nil
  1658. m.add_type = nil
  1659. m.clearedFields[contact.FieldType] = struct{}{}
  1660. }
  1661. // TypeCleared returns if the "type" field was cleared in this mutation.
  1662. func (m *ContactMutation) TypeCleared() bool {
  1663. _, ok := m.clearedFields[contact.FieldType]
  1664. return ok
  1665. }
  1666. // ResetType resets all changes to the "type" field.
  1667. func (m *ContactMutation) ResetType() {
  1668. m._type = nil
  1669. m.add_type = nil
  1670. delete(m.clearedFields, contact.FieldType)
  1671. }
  1672. // SetWxid sets the "wxid" field.
  1673. func (m *ContactMutation) SetWxid(s string) {
  1674. m.wxid = &s
  1675. }
  1676. // Wxid returns the value of the "wxid" field in the mutation.
  1677. func (m *ContactMutation) Wxid() (r string, exists bool) {
  1678. v := m.wxid
  1679. if v == nil {
  1680. return
  1681. }
  1682. return *v, true
  1683. }
  1684. // OldWxid returns the old "wxid" field's value of the Contact entity.
  1685. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1686. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1687. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  1688. if !m.op.Is(OpUpdateOne) {
  1689. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  1690. }
  1691. if m.id == nil || m.oldValue == nil {
  1692. return v, errors.New("OldWxid requires an ID field in the mutation")
  1693. }
  1694. oldValue, err := m.oldValue(ctx)
  1695. if err != nil {
  1696. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  1697. }
  1698. return oldValue.Wxid, nil
  1699. }
  1700. // ResetWxid resets all changes to the "wxid" field.
  1701. func (m *ContactMutation) ResetWxid() {
  1702. m.wxid = nil
  1703. }
  1704. // SetAccount sets the "account" field.
  1705. func (m *ContactMutation) SetAccount(s string) {
  1706. m.account = &s
  1707. }
  1708. // Account returns the value of the "account" field in the mutation.
  1709. func (m *ContactMutation) Account() (r string, exists bool) {
  1710. v := m.account
  1711. if v == nil {
  1712. return
  1713. }
  1714. return *v, true
  1715. }
  1716. // OldAccount returns the old "account" field's value of the Contact entity.
  1717. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1718. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1719. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  1720. if !m.op.Is(OpUpdateOne) {
  1721. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  1722. }
  1723. if m.id == nil || m.oldValue == nil {
  1724. return v, errors.New("OldAccount requires an ID field in the mutation")
  1725. }
  1726. oldValue, err := m.oldValue(ctx)
  1727. if err != nil {
  1728. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  1729. }
  1730. return oldValue.Account, nil
  1731. }
  1732. // ResetAccount resets all changes to the "account" field.
  1733. func (m *ContactMutation) ResetAccount() {
  1734. m.account = nil
  1735. }
  1736. // SetNickname sets the "nickname" field.
  1737. func (m *ContactMutation) SetNickname(s string) {
  1738. m.nickname = &s
  1739. }
  1740. // Nickname returns the value of the "nickname" field in the mutation.
  1741. func (m *ContactMutation) Nickname() (r string, exists bool) {
  1742. v := m.nickname
  1743. if v == nil {
  1744. return
  1745. }
  1746. return *v, true
  1747. }
  1748. // OldNickname returns the old "nickname" field's value of the Contact entity.
  1749. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1750. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1751. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  1752. if !m.op.Is(OpUpdateOne) {
  1753. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  1754. }
  1755. if m.id == nil || m.oldValue == nil {
  1756. return v, errors.New("OldNickname requires an ID field in the mutation")
  1757. }
  1758. oldValue, err := m.oldValue(ctx)
  1759. if err != nil {
  1760. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  1761. }
  1762. return oldValue.Nickname, nil
  1763. }
  1764. // ResetNickname resets all changes to the "nickname" field.
  1765. func (m *ContactMutation) ResetNickname() {
  1766. m.nickname = nil
  1767. }
  1768. // SetMarkname sets the "markname" field.
  1769. func (m *ContactMutation) SetMarkname(s string) {
  1770. m.markname = &s
  1771. }
  1772. // Markname returns the value of the "markname" field in the mutation.
  1773. func (m *ContactMutation) Markname() (r string, exists bool) {
  1774. v := m.markname
  1775. if v == nil {
  1776. return
  1777. }
  1778. return *v, true
  1779. }
  1780. // OldMarkname returns the old "markname" field's value of the Contact entity.
  1781. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1782. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1783. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  1784. if !m.op.Is(OpUpdateOne) {
  1785. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  1786. }
  1787. if m.id == nil || m.oldValue == nil {
  1788. return v, errors.New("OldMarkname requires an ID field in the mutation")
  1789. }
  1790. oldValue, err := m.oldValue(ctx)
  1791. if err != nil {
  1792. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  1793. }
  1794. return oldValue.Markname, nil
  1795. }
  1796. // ResetMarkname resets all changes to the "markname" field.
  1797. func (m *ContactMutation) ResetMarkname() {
  1798. m.markname = nil
  1799. }
  1800. // SetHeadimg sets the "headimg" field.
  1801. func (m *ContactMutation) SetHeadimg(s string) {
  1802. m.headimg = &s
  1803. }
  1804. // Headimg returns the value of the "headimg" field in the mutation.
  1805. func (m *ContactMutation) Headimg() (r string, exists bool) {
  1806. v := m.headimg
  1807. if v == nil {
  1808. return
  1809. }
  1810. return *v, true
  1811. }
  1812. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  1813. // If the Contact 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 *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  1816. if !m.op.Is(OpUpdateOne) {
  1817. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  1818. }
  1819. if m.id == nil || m.oldValue == nil {
  1820. return v, errors.New("OldHeadimg 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 OldHeadimg: %w", err)
  1825. }
  1826. return oldValue.Headimg, nil
  1827. }
  1828. // ResetHeadimg resets all changes to the "headimg" field.
  1829. func (m *ContactMutation) ResetHeadimg() {
  1830. m.headimg = nil
  1831. }
  1832. // SetSex sets the "sex" field.
  1833. func (m *ContactMutation) SetSex(i int) {
  1834. m.sex = &i
  1835. m.addsex = nil
  1836. }
  1837. // Sex returns the value of the "sex" field in the mutation.
  1838. func (m *ContactMutation) Sex() (r int, exists bool) {
  1839. v := m.sex
  1840. if v == nil {
  1841. return
  1842. }
  1843. return *v, true
  1844. }
  1845. // OldSex returns the old "sex" field's value of the Contact entity.
  1846. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1847. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1848. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  1849. if !m.op.Is(OpUpdateOne) {
  1850. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  1851. }
  1852. if m.id == nil || m.oldValue == nil {
  1853. return v, errors.New("OldSex requires an ID field in the mutation")
  1854. }
  1855. oldValue, err := m.oldValue(ctx)
  1856. if err != nil {
  1857. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  1858. }
  1859. return oldValue.Sex, nil
  1860. }
  1861. // AddSex adds i to the "sex" field.
  1862. func (m *ContactMutation) AddSex(i int) {
  1863. if m.addsex != nil {
  1864. *m.addsex += i
  1865. } else {
  1866. m.addsex = &i
  1867. }
  1868. }
  1869. // AddedSex returns the value that was added to the "sex" field in this mutation.
  1870. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  1871. v := m.addsex
  1872. if v == nil {
  1873. return
  1874. }
  1875. return *v, true
  1876. }
  1877. // ResetSex resets all changes to the "sex" field.
  1878. func (m *ContactMutation) ResetSex() {
  1879. m.sex = nil
  1880. m.addsex = nil
  1881. }
  1882. // SetStarrole sets the "starrole" field.
  1883. func (m *ContactMutation) SetStarrole(s string) {
  1884. m.starrole = &s
  1885. }
  1886. // Starrole returns the value of the "starrole" field in the mutation.
  1887. func (m *ContactMutation) Starrole() (r string, exists bool) {
  1888. v := m.starrole
  1889. if v == nil {
  1890. return
  1891. }
  1892. return *v, true
  1893. }
  1894. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  1895. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1896. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1897. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  1898. if !m.op.Is(OpUpdateOne) {
  1899. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  1900. }
  1901. if m.id == nil || m.oldValue == nil {
  1902. return v, errors.New("OldStarrole requires an ID field in the mutation")
  1903. }
  1904. oldValue, err := m.oldValue(ctx)
  1905. if err != nil {
  1906. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  1907. }
  1908. return oldValue.Starrole, nil
  1909. }
  1910. // ResetStarrole resets all changes to the "starrole" field.
  1911. func (m *ContactMutation) ResetStarrole() {
  1912. m.starrole = nil
  1913. }
  1914. // SetDontseeit sets the "dontseeit" field.
  1915. func (m *ContactMutation) SetDontseeit(i int) {
  1916. m.dontseeit = &i
  1917. m.adddontseeit = nil
  1918. }
  1919. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  1920. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  1921. v := m.dontseeit
  1922. if v == nil {
  1923. return
  1924. }
  1925. return *v, true
  1926. }
  1927. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  1928. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1929. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1930. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  1931. if !m.op.Is(OpUpdateOne) {
  1932. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  1933. }
  1934. if m.id == nil || m.oldValue == nil {
  1935. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  1936. }
  1937. oldValue, err := m.oldValue(ctx)
  1938. if err != nil {
  1939. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  1940. }
  1941. return oldValue.Dontseeit, nil
  1942. }
  1943. // AddDontseeit adds i to the "dontseeit" field.
  1944. func (m *ContactMutation) AddDontseeit(i int) {
  1945. if m.adddontseeit != nil {
  1946. *m.adddontseeit += i
  1947. } else {
  1948. m.adddontseeit = &i
  1949. }
  1950. }
  1951. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  1952. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  1953. v := m.adddontseeit
  1954. if v == nil {
  1955. return
  1956. }
  1957. return *v, true
  1958. }
  1959. // ResetDontseeit resets all changes to the "dontseeit" field.
  1960. func (m *ContactMutation) ResetDontseeit() {
  1961. m.dontseeit = nil
  1962. m.adddontseeit = nil
  1963. }
  1964. // SetDontseeme sets the "dontseeme" field.
  1965. func (m *ContactMutation) SetDontseeme(i int) {
  1966. m.dontseeme = &i
  1967. m.adddontseeme = nil
  1968. }
  1969. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  1970. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  1971. v := m.dontseeme
  1972. if v == nil {
  1973. return
  1974. }
  1975. return *v, true
  1976. }
  1977. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  1978. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1979. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1980. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  1981. if !m.op.Is(OpUpdateOne) {
  1982. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  1983. }
  1984. if m.id == nil || m.oldValue == nil {
  1985. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  1986. }
  1987. oldValue, err := m.oldValue(ctx)
  1988. if err != nil {
  1989. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  1990. }
  1991. return oldValue.Dontseeme, nil
  1992. }
  1993. // AddDontseeme adds i to the "dontseeme" field.
  1994. func (m *ContactMutation) AddDontseeme(i int) {
  1995. if m.adddontseeme != nil {
  1996. *m.adddontseeme += i
  1997. } else {
  1998. m.adddontseeme = &i
  1999. }
  2000. }
  2001. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  2002. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  2003. v := m.adddontseeme
  2004. if v == nil {
  2005. return
  2006. }
  2007. return *v, true
  2008. }
  2009. // ResetDontseeme resets all changes to the "dontseeme" field.
  2010. func (m *ContactMutation) ResetDontseeme() {
  2011. m.dontseeme = nil
  2012. m.adddontseeme = nil
  2013. }
  2014. // SetLag sets the "lag" field.
  2015. func (m *ContactMutation) SetLag(s string) {
  2016. m.lag = &s
  2017. }
  2018. // Lag returns the value of the "lag" field in the mutation.
  2019. func (m *ContactMutation) Lag() (r string, exists bool) {
  2020. v := m.lag
  2021. if v == nil {
  2022. return
  2023. }
  2024. return *v, true
  2025. }
  2026. // OldLag returns the old "lag" field's value of the Contact entity.
  2027. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2028. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2029. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  2030. if !m.op.Is(OpUpdateOne) {
  2031. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  2032. }
  2033. if m.id == nil || m.oldValue == nil {
  2034. return v, errors.New("OldLag requires an ID field in the mutation")
  2035. }
  2036. oldValue, err := m.oldValue(ctx)
  2037. if err != nil {
  2038. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  2039. }
  2040. return oldValue.Lag, nil
  2041. }
  2042. // ResetLag resets all changes to the "lag" field.
  2043. func (m *ContactMutation) ResetLag() {
  2044. m.lag = nil
  2045. }
  2046. // SetGid sets the "gid" field.
  2047. func (m *ContactMutation) SetGid(s string) {
  2048. m.gid = &s
  2049. }
  2050. // Gid returns the value of the "gid" field in the mutation.
  2051. func (m *ContactMutation) Gid() (r string, exists bool) {
  2052. v := m.gid
  2053. if v == nil {
  2054. return
  2055. }
  2056. return *v, true
  2057. }
  2058. // OldGid returns the old "gid" field's value of the Contact entity.
  2059. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2060. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2061. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  2062. if !m.op.Is(OpUpdateOne) {
  2063. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  2064. }
  2065. if m.id == nil || m.oldValue == nil {
  2066. return v, errors.New("OldGid requires an ID field in the mutation")
  2067. }
  2068. oldValue, err := m.oldValue(ctx)
  2069. if err != nil {
  2070. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  2071. }
  2072. return oldValue.Gid, nil
  2073. }
  2074. // ResetGid resets all changes to the "gid" field.
  2075. func (m *ContactMutation) ResetGid() {
  2076. m.gid = nil
  2077. }
  2078. // SetGname sets the "gname" field.
  2079. func (m *ContactMutation) SetGname(s string) {
  2080. m.gname = &s
  2081. }
  2082. // Gname returns the value of the "gname" field in the mutation.
  2083. func (m *ContactMutation) Gname() (r string, exists bool) {
  2084. v := m.gname
  2085. if v == nil {
  2086. return
  2087. }
  2088. return *v, true
  2089. }
  2090. // OldGname returns the old "gname" field's value of the Contact entity.
  2091. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2092. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2093. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  2094. if !m.op.Is(OpUpdateOne) {
  2095. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  2096. }
  2097. if m.id == nil || m.oldValue == nil {
  2098. return v, errors.New("OldGname requires an ID field in the mutation")
  2099. }
  2100. oldValue, err := m.oldValue(ctx)
  2101. if err != nil {
  2102. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  2103. }
  2104. return oldValue.Gname, nil
  2105. }
  2106. // ResetGname resets all changes to the "gname" field.
  2107. func (m *ContactMutation) ResetGname() {
  2108. m.gname = nil
  2109. }
  2110. // SetV3 sets the "v3" field.
  2111. func (m *ContactMutation) SetV3(s string) {
  2112. m.v3 = &s
  2113. }
  2114. // V3 returns the value of the "v3" field in the mutation.
  2115. func (m *ContactMutation) V3() (r string, exists bool) {
  2116. v := m.v3
  2117. if v == nil {
  2118. return
  2119. }
  2120. return *v, true
  2121. }
  2122. // OldV3 returns the old "v3" field's value of the Contact entity.
  2123. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2125. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  2126. if !m.op.Is(OpUpdateOne) {
  2127. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  2128. }
  2129. if m.id == nil || m.oldValue == nil {
  2130. return v, errors.New("OldV3 requires an ID field in the mutation")
  2131. }
  2132. oldValue, err := m.oldValue(ctx)
  2133. if err != nil {
  2134. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  2135. }
  2136. return oldValue.V3, nil
  2137. }
  2138. // ResetV3 resets all changes to the "v3" field.
  2139. func (m *ContactMutation) ResetV3() {
  2140. m.v3 = nil
  2141. }
  2142. // SetOrganizationID sets the "organization_id" field.
  2143. func (m *ContactMutation) SetOrganizationID(u uint64) {
  2144. m.organization_id = &u
  2145. m.addorganization_id = nil
  2146. }
  2147. // OrganizationID returns the value of the "organization_id" field in the mutation.
  2148. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  2149. v := m.organization_id
  2150. if v == nil {
  2151. return
  2152. }
  2153. return *v, true
  2154. }
  2155. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  2156. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2157. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2158. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  2159. if !m.op.Is(OpUpdateOne) {
  2160. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  2161. }
  2162. if m.id == nil || m.oldValue == nil {
  2163. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  2164. }
  2165. oldValue, err := m.oldValue(ctx)
  2166. if err != nil {
  2167. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  2168. }
  2169. return oldValue.OrganizationID, nil
  2170. }
  2171. // AddOrganizationID adds u to the "organization_id" field.
  2172. func (m *ContactMutation) AddOrganizationID(u int64) {
  2173. if m.addorganization_id != nil {
  2174. *m.addorganization_id += u
  2175. } else {
  2176. m.addorganization_id = &u
  2177. }
  2178. }
  2179. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  2180. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  2181. v := m.addorganization_id
  2182. if v == nil {
  2183. return
  2184. }
  2185. return *v, true
  2186. }
  2187. // ClearOrganizationID clears the value of the "organization_id" field.
  2188. func (m *ContactMutation) ClearOrganizationID() {
  2189. m.organization_id = nil
  2190. m.addorganization_id = nil
  2191. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  2192. }
  2193. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  2194. func (m *ContactMutation) OrganizationIDCleared() bool {
  2195. _, ok := m.clearedFields[contact.FieldOrganizationID]
  2196. return ok
  2197. }
  2198. // ResetOrganizationID resets all changes to the "organization_id" field.
  2199. func (m *ContactMutation) ResetOrganizationID() {
  2200. m.organization_id = nil
  2201. m.addorganization_id = nil
  2202. delete(m.clearedFields, contact.FieldOrganizationID)
  2203. }
  2204. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  2205. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  2206. if m.contact_relationships == nil {
  2207. m.contact_relationships = make(map[uint64]struct{})
  2208. }
  2209. for i := range ids {
  2210. m.contact_relationships[ids[i]] = struct{}{}
  2211. }
  2212. }
  2213. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  2214. func (m *ContactMutation) ClearContactRelationships() {
  2215. m.clearedcontact_relationships = true
  2216. }
  2217. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  2218. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  2219. return m.clearedcontact_relationships
  2220. }
  2221. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  2222. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  2223. if m.removedcontact_relationships == nil {
  2224. m.removedcontact_relationships = make(map[uint64]struct{})
  2225. }
  2226. for i := range ids {
  2227. delete(m.contact_relationships, ids[i])
  2228. m.removedcontact_relationships[ids[i]] = struct{}{}
  2229. }
  2230. }
  2231. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  2232. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  2233. for id := range m.removedcontact_relationships {
  2234. ids = append(ids, id)
  2235. }
  2236. return
  2237. }
  2238. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  2239. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  2240. for id := range m.contact_relationships {
  2241. ids = append(ids, id)
  2242. }
  2243. return
  2244. }
  2245. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  2246. func (m *ContactMutation) ResetContactRelationships() {
  2247. m.contact_relationships = nil
  2248. m.clearedcontact_relationships = false
  2249. m.removedcontact_relationships = nil
  2250. }
  2251. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  2252. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  2253. if m.contact_messages == nil {
  2254. m.contact_messages = make(map[uint64]struct{})
  2255. }
  2256. for i := range ids {
  2257. m.contact_messages[ids[i]] = struct{}{}
  2258. }
  2259. }
  2260. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  2261. func (m *ContactMutation) ClearContactMessages() {
  2262. m.clearedcontact_messages = true
  2263. }
  2264. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  2265. func (m *ContactMutation) ContactMessagesCleared() bool {
  2266. return m.clearedcontact_messages
  2267. }
  2268. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  2269. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  2270. if m.removedcontact_messages == nil {
  2271. m.removedcontact_messages = make(map[uint64]struct{})
  2272. }
  2273. for i := range ids {
  2274. delete(m.contact_messages, ids[i])
  2275. m.removedcontact_messages[ids[i]] = struct{}{}
  2276. }
  2277. }
  2278. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  2279. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  2280. for id := range m.removedcontact_messages {
  2281. ids = append(ids, id)
  2282. }
  2283. return
  2284. }
  2285. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  2286. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  2287. for id := range m.contact_messages {
  2288. ids = append(ids, id)
  2289. }
  2290. return
  2291. }
  2292. // ResetContactMessages resets all changes to the "contact_messages" edge.
  2293. func (m *ContactMutation) ResetContactMessages() {
  2294. m.contact_messages = nil
  2295. m.clearedcontact_messages = false
  2296. m.removedcontact_messages = nil
  2297. }
  2298. // Where appends a list predicates to the ContactMutation builder.
  2299. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  2300. m.predicates = append(m.predicates, ps...)
  2301. }
  2302. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  2303. // users can use type-assertion to append predicates that do not depend on any generated package.
  2304. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  2305. p := make([]predicate.Contact, len(ps))
  2306. for i := range ps {
  2307. p[i] = ps[i]
  2308. }
  2309. m.Where(p...)
  2310. }
  2311. // Op returns the operation name.
  2312. func (m *ContactMutation) Op() Op {
  2313. return m.op
  2314. }
  2315. // SetOp allows setting the mutation operation.
  2316. func (m *ContactMutation) SetOp(op Op) {
  2317. m.op = op
  2318. }
  2319. // Type returns the node type of this mutation (Contact).
  2320. func (m *ContactMutation) Type() string {
  2321. return m.typ
  2322. }
  2323. // Fields returns all fields that were changed during this mutation. Note that in
  2324. // order to get all numeric fields that were incremented/decremented, call
  2325. // AddedFields().
  2326. func (m *ContactMutation) Fields() []string {
  2327. fields := make([]string, 0, 20)
  2328. if m.created_at != nil {
  2329. fields = append(fields, contact.FieldCreatedAt)
  2330. }
  2331. if m.updated_at != nil {
  2332. fields = append(fields, contact.FieldUpdatedAt)
  2333. }
  2334. if m.status != nil {
  2335. fields = append(fields, contact.FieldStatus)
  2336. }
  2337. if m.deleted_at != nil {
  2338. fields = append(fields, contact.FieldDeletedAt)
  2339. }
  2340. if m.wx_wxid != nil {
  2341. fields = append(fields, contact.FieldWxWxid)
  2342. }
  2343. if m._type != nil {
  2344. fields = append(fields, contact.FieldType)
  2345. }
  2346. if m.wxid != nil {
  2347. fields = append(fields, contact.FieldWxid)
  2348. }
  2349. if m.account != nil {
  2350. fields = append(fields, contact.FieldAccount)
  2351. }
  2352. if m.nickname != nil {
  2353. fields = append(fields, contact.FieldNickname)
  2354. }
  2355. if m.markname != nil {
  2356. fields = append(fields, contact.FieldMarkname)
  2357. }
  2358. if m.headimg != nil {
  2359. fields = append(fields, contact.FieldHeadimg)
  2360. }
  2361. if m.sex != nil {
  2362. fields = append(fields, contact.FieldSex)
  2363. }
  2364. if m.starrole != nil {
  2365. fields = append(fields, contact.FieldStarrole)
  2366. }
  2367. if m.dontseeit != nil {
  2368. fields = append(fields, contact.FieldDontseeit)
  2369. }
  2370. if m.dontseeme != nil {
  2371. fields = append(fields, contact.FieldDontseeme)
  2372. }
  2373. if m.lag != nil {
  2374. fields = append(fields, contact.FieldLag)
  2375. }
  2376. if m.gid != nil {
  2377. fields = append(fields, contact.FieldGid)
  2378. }
  2379. if m.gname != nil {
  2380. fields = append(fields, contact.FieldGname)
  2381. }
  2382. if m.v3 != nil {
  2383. fields = append(fields, contact.FieldV3)
  2384. }
  2385. if m.organization_id != nil {
  2386. fields = append(fields, contact.FieldOrganizationID)
  2387. }
  2388. return fields
  2389. }
  2390. // Field returns the value of a field with the given name. The second boolean
  2391. // return value indicates that this field was not set, or was not defined in the
  2392. // schema.
  2393. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  2394. switch name {
  2395. case contact.FieldCreatedAt:
  2396. return m.CreatedAt()
  2397. case contact.FieldUpdatedAt:
  2398. return m.UpdatedAt()
  2399. case contact.FieldStatus:
  2400. return m.Status()
  2401. case contact.FieldDeletedAt:
  2402. return m.DeletedAt()
  2403. case contact.FieldWxWxid:
  2404. return m.WxWxid()
  2405. case contact.FieldType:
  2406. return m.GetType()
  2407. case contact.FieldWxid:
  2408. return m.Wxid()
  2409. case contact.FieldAccount:
  2410. return m.Account()
  2411. case contact.FieldNickname:
  2412. return m.Nickname()
  2413. case contact.FieldMarkname:
  2414. return m.Markname()
  2415. case contact.FieldHeadimg:
  2416. return m.Headimg()
  2417. case contact.FieldSex:
  2418. return m.Sex()
  2419. case contact.FieldStarrole:
  2420. return m.Starrole()
  2421. case contact.FieldDontseeit:
  2422. return m.Dontseeit()
  2423. case contact.FieldDontseeme:
  2424. return m.Dontseeme()
  2425. case contact.FieldLag:
  2426. return m.Lag()
  2427. case contact.FieldGid:
  2428. return m.Gid()
  2429. case contact.FieldGname:
  2430. return m.Gname()
  2431. case contact.FieldV3:
  2432. return m.V3()
  2433. case contact.FieldOrganizationID:
  2434. return m.OrganizationID()
  2435. }
  2436. return nil, false
  2437. }
  2438. // OldField returns the old value of the field from the database. An error is
  2439. // returned if the mutation operation is not UpdateOne, or the query to the
  2440. // database failed.
  2441. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2442. switch name {
  2443. case contact.FieldCreatedAt:
  2444. return m.OldCreatedAt(ctx)
  2445. case contact.FieldUpdatedAt:
  2446. return m.OldUpdatedAt(ctx)
  2447. case contact.FieldStatus:
  2448. return m.OldStatus(ctx)
  2449. case contact.FieldDeletedAt:
  2450. return m.OldDeletedAt(ctx)
  2451. case contact.FieldWxWxid:
  2452. return m.OldWxWxid(ctx)
  2453. case contact.FieldType:
  2454. return m.OldType(ctx)
  2455. case contact.FieldWxid:
  2456. return m.OldWxid(ctx)
  2457. case contact.FieldAccount:
  2458. return m.OldAccount(ctx)
  2459. case contact.FieldNickname:
  2460. return m.OldNickname(ctx)
  2461. case contact.FieldMarkname:
  2462. return m.OldMarkname(ctx)
  2463. case contact.FieldHeadimg:
  2464. return m.OldHeadimg(ctx)
  2465. case contact.FieldSex:
  2466. return m.OldSex(ctx)
  2467. case contact.FieldStarrole:
  2468. return m.OldStarrole(ctx)
  2469. case contact.FieldDontseeit:
  2470. return m.OldDontseeit(ctx)
  2471. case contact.FieldDontseeme:
  2472. return m.OldDontseeme(ctx)
  2473. case contact.FieldLag:
  2474. return m.OldLag(ctx)
  2475. case contact.FieldGid:
  2476. return m.OldGid(ctx)
  2477. case contact.FieldGname:
  2478. return m.OldGname(ctx)
  2479. case contact.FieldV3:
  2480. return m.OldV3(ctx)
  2481. case contact.FieldOrganizationID:
  2482. return m.OldOrganizationID(ctx)
  2483. }
  2484. return nil, fmt.Errorf("unknown Contact field %s", name)
  2485. }
  2486. // SetField sets the value of a field with the given name. It returns an error if
  2487. // the field is not defined in the schema, or if the type mismatched the field
  2488. // type.
  2489. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  2490. switch name {
  2491. case contact.FieldCreatedAt:
  2492. v, ok := value.(time.Time)
  2493. if !ok {
  2494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2495. }
  2496. m.SetCreatedAt(v)
  2497. return nil
  2498. case contact.FieldUpdatedAt:
  2499. v, ok := value.(time.Time)
  2500. if !ok {
  2501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2502. }
  2503. m.SetUpdatedAt(v)
  2504. return nil
  2505. case contact.FieldStatus:
  2506. v, ok := value.(uint8)
  2507. if !ok {
  2508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2509. }
  2510. m.SetStatus(v)
  2511. return nil
  2512. case contact.FieldDeletedAt:
  2513. v, ok := value.(time.Time)
  2514. if !ok {
  2515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2516. }
  2517. m.SetDeletedAt(v)
  2518. return nil
  2519. case contact.FieldWxWxid:
  2520. v, ok := value.(string)
  2521. if !ok {
  2522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2523. }
  2524. m.SetWxWxid(v)
  2525. return nil
  2526. case contact.FieldType:
  2527. v, ok := value.(int)
  2528. if !ok {
  2529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2530. }
  2531. m.SetType(v)
  2532. return nil
  2533. case contact.FieldWxid:
  2534. v, ok := value.(string)
  2535. if !ok {
  2536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2537. }
  2538. m.SetWxid(v)
  2539. return nil
  2540. case contact.FieldAccount:
  2541. v, ok := value.(string)
  2542. if !ok {
  2543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2544. }
  2545. m.SetAccount(v)
  2546. return nil
  2547. case contact.FieldNickname:
  2548. v, ok := value.(string)
  2549. if !ok {
  2550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2551. }
  2552. m.SetNickname(v)
  2553. return nil
  2554. case contact.FieldMarkname:
  2555. v, ok := value.(string)
  2556. if !ok {
  2557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2558. }
  2559. m.SetMarkname(v)
  2560. return nil
  2561. case contact.FieldHeadimg:
  2562. v, ok := value.(string)
  2563. if !ok {
  2564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2565. }
  2566. m.SetHeadimg(v)
  2567. return nil
  2568. case contact.FieldSex:
  2569. v, ok := value.(int)
  2570. if !ok {
  2571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2572. }
  2573. m.SetSex(v)
  2574. return nil
  2575. case contact.FieldStarrole:
  2576. v, ok := value.(string)
  2577. if !ok {
  2578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2579. }
  2580. m.SetStarrole(v)
  2581. return nil
  2582. case contact.FieldDontseeit:
  2583. v, ok := value.(int)
  2584. if !ok {
  2585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2586. }
  2587. m.SetDontseeit(v)
  2588. return nil
  2589. case contact.FieldDontseeme:
  2590. v, ok := value.(int)
  2591. if !ok {
  2592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2593. }
  2594. m.SetDontseeme(v)
  2595. return nil
  2596. case contact.FieldLag:
  2597. v, ok := value.(string)
  2598. if !ok {
  2599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2600. }
  2601. m.SetLag(v)
  2602. return nil
  2603. case contact.FieldGid:
  2604. v, ok := value.(string)
  2605. if !ok {
  2606. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2607. }
  2608. m.SetGid(v)
  2609. return nil
  2610. case contact.FieldGname:
  2611. v, ok := value.(string)
  2612. if !ok {
  2613. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2614. }
  2615. m.SetGname(v)
  2616. return nil
  2617. case contact.FieldV3:
  2618. v, ok := value.(string)
  2619. if !ok {
  2620. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2621. }
  2622. m.SetV3(v)
  2623. return nil
  2624. case contact.FieldOrganizationID:
  2625. v, ok := value.(uint64)
  2626. if !ok {
  2627. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2628. }
  2629. m.SetOrganizationID(v)
  2630. return nil
  2631. }
  2632. return fmt.Errorf("unknown Contact field %s", name)
  2633. }
  2634. // AddedFields returns all numeric fields that were incremented/decremented during
  2635. // this mutation.
  2636. func (m *ContactMutation) AddedFields() []string {
  2637. var fields []string
  2638. if m.addstatus != nil {
  2639. fields = append(fields, contact.FieldStatus)
  2640. }
  2641. if m.add_type != nil {
  2642. fields = append(fields, contact.FieldType)
  2643. }
  2644. if m.addsex != nil {
  2645. fields = append(fields, contact.FieldSex)
  2646. }
  2647. if m.adddontseeit != nil {
  2648. fields = append(fields, contact.FieldDontseeit)
  2649. }
  2650. if m.adddontseeme != nil {
  2651. fields = append(fields, contact.FieldDontseeme)
  2652. }
  2653. if m.addorganization_id != nil {
  2654. fields = append(fields, contact.FieldOrganizationID)
  2655. }
  2656. return fields
  2657. }
  2658. // AddedField returns the numeric value that was incremented/decremented on a field
  2659. // with the given name. The second boolean return value indicates that this field
  2660. // was not set, or was not defined in the schema.
  2661. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  2662. switch name {
  2663. case contact.FieldStatus:
  2664. return m.AddedStatus()
  2665. case contact.FieldType:
  2666. return m.AddedType()
  2667. case contact.FieldSex:
  2668. return m.AddedSex()
  2669. case contact.FieldDontseeit:
  2670. return m.AddedDontseeit()
  2671. case contact.FieldDontseeme:
  2672. return m.AddedDontseeme()
  2673. case contact.FieldOrganizationID:
  2674. return m.AddedOrganizationID()
  2675. }
  2676. return nil, false
  2677. }
  2678. // AddField adds the value to the field with the given name. It returns an error if
  2679. // the field is not defined in the schema, or if the type mismatched the field
  2680. // type.
  2681. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  2682. switch name {
  2683. case contact.FieldStatus:
  2684. v, ok := value.(int8)
  2685. if !ok {
  2686. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2687. }
  2688. m.AddStatus(v)
  2689. return nil
  2690. case contact.FieldType:
  2691. v, ok := value.(int)
  2692. if !ok {
  2693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2694. }
  2695. m.AddType(v)
  2696. return nil
  2697. case contact.FieldSex:
  2698. v, ok := value.(int)
  2699. if !ok {
  2700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2701. }
  2702. m.AddSex(v)
  2703. return nil
  2704. case contact.FieldDontseeit:
  2705. v, ok := value.(int)
  2706. if !ok {
  2707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2708. }
  2709. m.AddDontseeit(v)
  2710. return nil
  2711. case contact.FieldDontseeme:
  2712. v, ok := value.(int)
  2713. if !ok {
  2714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2715. }
  2716. m.AddDontseeme(v)
  2717. return nil
  2718. case contact.FieldOrganizationID:
  2719. v, ok := value.(int64)
  2720. if !ok {
  2721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2722. }
  2723. m.AddOrganizationID(v)
  2724. return nil
  2725. }
  2726. return fmt.Errorf("unknown Contact numeric field %s", name)
  2727. }
  2728. // ClearedFields returns all nullable fields that were cleared during this
  2729. // mutation.
  2730. func (m *ContactMutation) ClearedFields() []string {
  2731. var fields []string
  2732. if m.FieldCleared(contact.FieldStatus) {
  2733. fields = append(fields, contact.FieldStatus)
  2734. }
  2735. if m.FieldCleared(contact.FieldDeletedAt) {
  2736. fields = append(fields, contact.FieldDeletedAt)
  2737. }
  2738. if m.FieldCleared(contact.FieldWxWxid) {
  2739. fields = append(fields, contact.FieldWxWxid)
  2740. }
  2741. if m.FieldCleared(contact.FieldType) {
  2742. fields = append(fields, contact.FieldType)
  2743. }
  2744. if m.FieldCleared(contact.FieldOrganizationID) {
  2745. fields = append(fields, contact.FieldOrganizationID)
  2746. }
  2747. return fields
  2748. }
  2749. // FieldCleared returns a boolean indicating if a field with the given name was
  2750. // cleared in this mutation.
  2751. func (m *ContactMutation) FieldCleared(name string) bool {
  2752. _, ok := m.clearedFields[name]
  2753. return ok
  2754. }
  2755. // ClearField clears the value of the field with the given name. It returns an
  2756. // error if the field is not defined in the schema.
  2757. func (m *ContactMutation) ClearField(name string) error {
  2758. switch name {
  2759. case contact.FieldStatus:
  2760. m.ClearStatus()
  2761. return nil
  2762. case contact.FieldDeletedAt:
  2763. m.ClearDeletedAt()
  2764. return nil
  2765. case contact.FieldWxWxid:
  2766. m.ClearWxWxid()
  2767. return nil
  2768. case contact.FieldType:
  2769. m.ClearType()
  2770. return nil
  2771. case contact.FieldOrganizationID:
  2772. m.ClearOrganizationID()
  2773. return nil
  2774. }
  2775. return fmt.Errorf("unknown Contact nullable field %s", name)
  2776. }
  2777. // ResetField resets all changes in the mutation for the field with the given name.
  2778. // It returns an error if the field is not defined in the schema.
  2779. func (m *ContactMutation) ResetField(name string) error {
  2780. switch name {
  2781. case contact.FieldCreatedAt:
  2782. m.ResetCreatedAt()
  2783. return nil
  2784. case contact.FieldUpdatedAt:
  2785. m.ResetUpdatedAt()
  2786. return nil
  2787. case contact.FieldStatus:
  2788. m.ResetStatus()
  2789. return nil
  2790. case contact.FieldDeletedAt:
  2791. m.ResetDeletedAt()
  2792. return nil
  2793. case contact.FieldWxWxid:
  2794. m.ResetWxWxid()
  2795. return nil
  2796. case contact.FieldType:
  2797. m.ResetType()
  2798. return nil
  2799. case contact.FieldWxid:
  2800. m.ResetWxid()
  2801. return nil
  2802. case contact.FieldAccount:
  2803. m.ResetAccount()
  2804. return nil
  2805. case contact.FieldNickname:
  2806. m.ResetNickname()
  2807. return nil
  2808. case contact.FieldMarkname:
  2809. m.ResetMarkname()
  2810. return nil
  2811. case contact.FieldHeadimg:
  2812. m.ResetHeadimg()
  2813. return nil
  2814. case contact.FieldSex:
  2815. m.ResetSex()
  2816. return nil
  2817. case contact.FieldStarrole:
  2818. m.ResetStarrole()
  2819. return nil
  2820. case contact.FieldDontseeit:
  2821. m.ResetDontseeit()
  2822. return nil
  2823. case contact.FieldDontseeme:
  2824. m.ResetDontseeme()
  2825. return nil
  2826. case contact.FieldLag:
  2827. m.ResetLag()
  2828. return nil
  2829. case contact.FieldGid:
  2830. m.ResetGid()
  2831. return nil
  2832. case contact.FieldGname:
  2833. m.ResetGname()
  2834. return nil
  2835. case contact.FieldV3:
  2836. m.ResetV3()
  2837. return nil
  2838. case contact.FieldOrganizationID:
  2839. m.ResetOrganizationID()
  2840. return nil
  2841. }
  2842. return fmt.Errorf("unknown Contact field %s", name)
  2843. }
  2844. // AddedEdges returns all edge names that were set/added in this mutation.
  2845. func (m *ContactMutation) AddedEdges() []string {
  2846. edges := make([]string, 0, 2)
  2847. if m.contact_relationships != nil {
  2848. edges = append(edges, contact.EdgeContactRelationships)
  2849. }
  2850. if m.contact_messages != nil {
  2851. edges = append(edges, contact.EdgeContactMessages)
  2852. }
  2853. return edges
  2854. }
  2855. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2856. // name in this mutation.
  2857. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  2858. switch name {
  2859. case contact.EdgeContactRelationships:
  2860. ids := make([]ent.Value, 0, len(m.contact_relationships))
  2861. for id := range m.contact_relationships {
  2862. ids = append(ids, id)
  2863. }
  2864. return ids
  2865. case contact.EdgeContactMessages:
  2866. ids := make([]ent.Value, 0, len(m.contact_messages))
  2867. for id := range m.contact_messages {
  2868. ids = append(ids, id)
  2869. }
  2870. return ids
  2871. }
  2872. return nil
  2873. }
  2874. // RemovedEdges returns all edge names that were removed in this mutation.
  2875. func (m *ContactMutation) RemovedEdges() []string {
  2876. edges := make([]string, 0, 2)
  2877. if m.removedcontact_relationships != nil {
  2878. edges = append(edges, contact.EdgeContactRelationships)
  2879. }
  2880. if m.removedcontact_messages != nil {
  2881. edges = append(edges, contact.EdgeContactMessages)
  2882. }
  2883. return edges
  2884. }
  2885. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2886. // the given name in this mutation.
  2887. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  2888. switch name {
  2889. case contact.EdgeContactRelationships:
  2890. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  2891. for id := range m.removedcontact_relationships {
  2892. ids = append(ids, id)
  2893. }
  2894. return ids
  2895. case contact.EdgeContactMessages:
  2896. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  2897. for id := range m.removedcontact_messages {
  2898. ids = append(ids, id)
  2899. }
  2900. return ids
  2901. }
  2902. return nil
  2903. }
  2904. // ClearedEdges returns all edge names that were cleared in this mutation.
  2905. func (m *ContactMutation) ClearedEdges() []string {
  2906. edges := make([]string, 0, 2)
  2907. if m.clearedcontact_relationships {
  2908. edges = append(edges, contact.EdgeContactRelationships)
  2909. }
  2910. if m.clearedcontact_messages {
  2911. edges = append(edges, contact.EdgeContactMessages)
  2912. }
  2913. return edges
  2914. }
  2915. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2916. // was cleared in this mutation.
  2917. func (m *ContactMutation) EdgeCleared(name string) bool {
  2918. switch name {
  2919. case contact.EdgeContactRelationships:
  2920. return m.clearedcontact_relationships
  2921. case contact.EdgeContactMessages:
  2922. return m.clearedcontact_messages
  2923. }
  2924. return false
  2925. }
  2926. // ClearEdge clears the value of the edge with the given name. It returns an error
  2927. // if that edge is not defined in the schema.
  2928. func (m *ContactMutation) ClearEdge(name string) error {
  2929. switch name {
  2930. }
  2931. return fmt.Errorf("unknown Contact unique edge %s", name)
  2932. }
  2933. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2934. // It returns an error if the edge is not defined in the schema.
  2935. func (m *ContactMutation) ResetEdge(name string) error {
  2936. switch name {
  2937. case contact.EdgeContactRelationships:
  2938. m.ResetContactRelationships()
  2939. return nil
  2940. case contact.EdgeContactMessages:
  2941. m.ResetContactMessages()
  2942. return nil
  2943. }
  2944. return fmt.Errorf("unknown Contact edge %s", name)
  2945. }
  2946. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  2947. type LabelMutation struct {
  2948. config
  2949. op Op
  2950. typ string
  2951. id *uint64
  2952. created_at *time.Time
  2953. updated_at *time.Time
  2954. status *uint8
  2955. addstatus *int8
  2956. _type *int
  2957. add_type *int
  2958. name *string
  2959. from *int
  2960. addfrom *int
  2961. mode *int
  2962. addmode *int
  2963. conditions *string
  2964. organization_id *uint64
  2965. addorganization_id *int64
  2966. clearedFields map[string]struct{}
  2967. label_relationships map[uint64]struct{}
  2968. removedlabel_relationships map[uint64]struct{}
  2969. clearedlabel_relationships bool
  2970. done bool
  2971. oldValue func(context.Context) (*Label, error)
  2972. predicates []predicate.Label
  2973. }
  2974. var _ ent.Mutation = (*LabelMutation)(nil)
  2975. // labelOption allows management of the mutation configuration using functional options.
  2976. type labelOption func(*LabelMutation)
  2977. // newLabelMutation creates new mutation for the Label entity.
  2978. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  2979. m := &LabelMutation{
  2980. config: c,
  2981. op: op,
  2982. typ: TypeLabel,
  2983. clearedFields: make(map[string]struct{}),
  2984. }
  2985. for _, opt := range opts {
  2986. opt(m)
  2987. }
  2988. return m
  2989. }
  2990. // withLabelID sets the ID field of the mutation.
  2991. func withLabelID(id uint64) labelOption {
  2992. return func(m *LabelMutation) {
  2993. var (
  2994. err error
  2995. once sync.Once
  2996. value *Label
  2997. )
  2998. m.oldValue = func(ctx context.Context) (*Label, error) {
  2999. once.Do(func() {
  3000. if m.done {
  3001. err = errors.New("querying old values post mutation is not allowed")
  3002. } else {
  3003. value, err = m.Client().Label.Get(ctx, id)
  3004. }
  3005. })
  3006. return value, err
  3007. }
  3008. m.id = &id
  3009. }
  3010. }
  3011. // withLabel sets the old Label of the mutation.
  3012. func withLabel(node *Label) labelOption {
  3013. return func(m *LabelMutation) {
  3014. m.oldValue = func(context.Context) (*Label, error) {
  3015. return node, nil
  3016. }
  3017. m.id = &node.ID
  3018. }
  3019. }
  3020. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3021. // executed in a transaction (ent.Tx), a transactional client is returned.
  3022. func (m LabelMutation) Client() *Client {
  3023. client := &Client{config: m.config}
  3024. client.init()
  3025. return client
  3026. }
  3027. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3028. // it returns an error otherwise.
  3029. func (m LabelMutation) Tx() (*Tx, error) {
  3030. if _, ok := m.driver.(*txDriver); !ok {
  3031. return nil, errors.New("ent: mutation is not running in a transaction")
  3032. }
  3033. tx := &Tx{config: m.config}
  3034. tx.init()
  3035. return tx, nil
  3036. }
  3037. // SetID sets the value of the id field. Note that this
  3038. // operation is only accepted on creation of Label entities.
  3039. func (m *LabelMutation) SetID(id uint64) {
  3040. m.id = &id
  3041. }
  3042. // ID returns the ID value in the mutation. Note that the ID is only available
  3043. // if it was provided to the builder or after it was returned from the database.
  3044. func (m *LabelMutation) ID() (id uint64, exists bool) {
  3045. if m.id == nil {
  3046. return
  3047. }
  3048. return *m.id, true
  3049. }
  3050. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3051. // That means, if the mutation is applied within a transaction with an isolation level such
  3052. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3053. // or updated by the mutation.
  3054. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  3055. switch {
  3056. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3057. id, exists := m.ID()
  3058. if exists {
  3059. return []uint64{id}, nil
  3060. }
  3061. fallthrough
  3062. case m.op.Is(OpUpdate | OpDelete):
  3063. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  3064. default:
  3065. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3066. }
  3067. }
  3068. // SetCreatedAt sets the "created_at" field.
  3069. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  3070. m.created_at = &t
  3071. }
  3072. // CreatedAt returns the value of the "created_at" field in the mutation.
  3073. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  3074. v := m.created_at
  3075. if v == nil {
  3076. return
  3077. }
  3078. return *v, true
  3079. }
  3080. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  3081. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  3082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3083. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3084. if !m.op.Is(OpUpdateOne) {
  3085. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3086. }
  3087. if m.id == nil || m.oldValue == nil {
  3088. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3089. }
  3090. oldValue, err := m.oldValue(ctx)
  3091. if err != nil {
  3092. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3093. }
  3094. return oldValue.CreatedAt, nil
  3095. }
  3096. // ResetCreatedAt resets all changes to the "created_at" field.
  3097. func (m *LabelMutation) ResetCreatedAt() {
  3098. m.created_at = nil
  3099. }
  3100. // SetUpdatedAt sets the "updated_at" field.
  3101. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  3102. m.updated_at = &t
  3103. }
  3104. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3105. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  3106. v := m.updated_at
  3107. if v == nil {
  3108. return
  3109. }
  3110. return *v, true
  3111. }
  3112. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  3113. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  3114. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3115. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3116. if !m.op.Is(OpUpdateOne) {
  3117. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3118. }
  3119. if m.id == nil || m.oldValue == nil {
  3120. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3121. }
  3122. oldValue, err := m.oldValue(ctx)
  3123. if err != nil {
  3124. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3125. }
  3126. return oldValue.UpdatedAt, nil
  3127. }
  3128. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3129. func (m *LabelMutation) ResetUpdatedAt() {
  3130. m.updated_at = nil
  3131. }
  3132. // SetStatus sets the "status" field.
  3133. func (m *LabelMutation) SetStatus(u uint8) {
  3134. m.status = &u
  3135. m.addstatus = nil
  3136. }
  3137. // Status returns the value of the "status" field in the mutation.
  3138. func (m *LabelMutation) Status() (r uint8, exists bool) {
  3139. v := m.status
  3140. if v == nil {
  3141. return
  3142. }
  3143. return *v, true
  3144. }
  3145. // OldStatus returns the old "status" field's value of the Label entity.
  3146. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  3147. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3148. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  3149. if !m.op.Is(OpUpdateOne) {
  3150. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3151. }
  3152. if m.id == nil || m.oldValue == nil {
  3153. return v, errors.New("OldStatus requires an ID field in the mutation")
  3154. }
  3155. oldValue, err := m.oldValue(ctx)
  3156. if err != nil {
  3157. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3158. }
  3159. return oldValue.Status, nil
  3160. }
  3161. // AddStatus adds u to the "status" field.
  3162. func (m *LabelMutation) AddStatus(u int8) {
  3163. if m.addstatus != nil {
  3164. *m.addstatus += u
  3165. } else {
  3166. m.addstatus = &u
  3167. }
  3168. }
  3169. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3170. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  3171. v := m.addstatus
  3172. if v == nil {
  3173. return
  3174. }
  3175. return *v, true
  3176. }
  3177. // ClearStatus clears the value of the "status" field.
  3178. func (m *LabelMutation) ClearStatus() {
  3179. m.status = nil
  3180. m.addstatus = nil
  3181. m.clearedFields[label.FieldStatus] = struct{}{}
  3182. }
  3183. // StatusCleared returns if the "status" field was cleared in this mutation.
  3184. func (m *LabelMutation) StatusCleared() bool {
  3185. _, ok := m.clearedFields[label.FieldStatus]
  3186. return ok
  3187. }
  3188. // ResetStatus resets all changes to the "status" field.
  3189. func (m *LabelMutation) ResetStatus() {
  3190. m.status = nil
  3191. m.addstatus = nil
  3192. delete(m.clearedFields, label.FieldStatus)
  3193. }
  3194. // SetType sets the "type" field.
  3195. func (m *LabelMutation) SetType(i int) {
  3196. m._type = &i
  3197. m.add_type = nil
  3198. }
  3199. // GetType returns the value of the "type" field in the mutation.
  3200. func (m *LabelMutation) GetType() (r int, exists bool) {
  3201. v := m._type
  3202. if v == nil {
  3203. return
  3204. }
  3205. return *v, true
  3206. }
  3207. // OldType returns the old "type" field's value of the Label entity.
  3208. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  3209. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3210. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  3211. if !m.op.Is(OpUpdateOne) {
  3212. return v, errors.New("OldType is only allowed on UpdateOne operations")
  3213. }
  3214. if m.id == nil || m.oldValue == nil {
  3215. return v, errors.New("OldType requires an ID field in the mutation")
  3216. }
  3217. oldValue, err := m.oldValue(ctx)
  3218. if err != nil {
  3219. return v, fmt.Errorf("querying old value for OldType: %w", err)
  3220. }
  3221. return oldValue.Type, nil
  3222. }
  3223. // AddType adds i to the "type" field.
  3224. func (m *LabelMutation) AddType(i int) {
  3225. if m.add_type != nil {
  3226. *m.add_type += i
  3227. } else {
  3228. m.add_type = &i
  3229. }
  3230. }
  3231. // AddedType returns the value that was added to the "type" field in this mutation.
  3232. func (m *LabelMutation) AddedType() (r int, exists bool) {
  3233. v := m.add_type
  3234. if v == nil {
  3235. return
  3236. }
  3237. return *v, true
  3238. }
  3239. // ResetType resets all changes to the "type" field.
  3240. func (m *LabelMutation) ResetType() {
  3241. m._type = nil
  3242. m.add_type = nil
  3243. }
  3244. // SetName sets the "name" field.
  3245. func (m *LabelMutation) SetName(s string) {
  3246. m.name = &s
  3247. }
  3248. // Name returns the value of the "name" field in the mutation.
  3249. func (m *LabelMutation) Name() (r string, exists bool) {
  3250. v := m.name
  3251. if v == nil {
  3252. return
  3253. }
  3254. return *v, true
  3255. }
  3256. // OldName returns the old "name" field's value of the Label entity.
  3257. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  3258. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3259. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  3260. if !m.op.Is(OpUpdateOne) {
  3261. return v, errors.New("OldName is only allowed on UpdateOne operations")
  3262. }
  3263. if m.id == nil || m.oldValue == nil {
  3264. return v, errors.New("OldName requires an ID field in the mutation")
  3265. }
  3266. oldValue, err := m.oldValue(ctx)
  3267. if err != nil {
  3268. return v, fmt.Errorf("querying old value for OldName: %w", err)
  3269. }
  3270. return oldValue.Name, nil
  3271. }
  3272. // ResetName resets all changes to the "name" field.
  3273. func (m *LabelMutation) ResetName() {
  3274. m.name = nil
  3275. }
  3276. // SetFrom sets the "from" field.
  3277. func (m *LabelMutation) SetFrom(i int) {
  3278. m.from = &i
  3279. m.addfrom = nil
  3280. }
  3281. // From returns the value of the "from" field in the mutation.
  3282. func (m *LabelMutation) From() (r int, exists bool) {
  3283. v := m.from
  3284. if v == nil {
  3285. return
  3286. }
  3287. return *v, true
  3288. }
  3289. // OldFrom returns the old "from" field's value of the Label entity.
  3290. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  3291. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3292. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  3293. if !m.op.Is(OpUpdateOne) {
  3294. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  3295. }
  3296. if m.id == nil || m.oldValue == nil {
  3297. return v, errors.New("OldFrom requires an ID field in the mutation")
  3298. }
  3299. oldValue, err := m.oldValue(ctx)
  3300. if err != nil {
  3301. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  3302. }
  3303. return oldValue.From, nil
  3304. }
  3305. // AddFrom adds i to the "from" field.
  3306. func (m *LabelMutation) AddFrom(i int) {
  3307. if m.addfrom != nil {
  3308. *m.addfrom += i
  3309. } else {
  3310. m.addfrom = &i
  3311. }
  3312. }
  3313. // AddedFrom returns the value that was added to the "from" field in this mutation.
  3314. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  3315. v := m.addfrom
  3316. if v == nil {
  3317. return
  3318. }
  3319. return *v, true
  3320. }
  3321. // ResetFrom resets all changes to the "from" field.
  3322. func (m *LabelMutation) ResetFrom() {
  3323. m.from = nil
  3324. m.addfrom = nil
  3325. }
  3326. // SetMode sets the "mode" field.
  3327. func (m *LabelMutation) SetMode(i int) {
  3328. m.mode = &i
  3329. m.addmode = nil
  3330. }
  3331. // Mode returns the value of the "mode" field in the mutation.
  3332. func (m *LabelMutation) Mode() (r int, exists bool) {
  3333. v := m.mode
  3334. if v == nil {
  3335. return
  3336. }
  3337. return *v, true
  3338. }
  3339. // OldMode returns the old "mode" field's value of the Label entity.
  3340. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  3341. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3342. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  3343. if !m.op.Is(OpUpdateOne) {
  3344. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  3345. }
  3346. if m.id == nil || m.oldValue == nil {
  3347. return v, errors.New("OldMode requires an ID field in the mutation")
  3348. }
  3349. oldValue, err := m.oldValue(ctx)
  3350. if err != nil {
  3351. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  3352. }
  3353. return oldValue.Mode, nil
  3354. }
  3355. // AddMode adds i to the "mode" field.
  3356. func (m *LabelMutation) AddMode(i int) {
  3357. if m.addmode != nil {
  3358. *m.addmode += i
  3359. } else {
  3360. m.addmode = &i
  3361. }
  3362. }
  3363. // AddedMode returns the value that was added to the "mode" field in this mutation.
  3364. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  3365. v := m.addmode
  3366. if v == nil {
  3367. return
  3368. }
  3369. return *v, true
  3370. }
  3371. // ResetMode resets all changes to the "mode" field.
  3372. func (m *LabelMutation) ResetMode() {
  3373. m.mode = nil
  3374. m.addmode = nil
  3375. }
  3376. // SetConditions sets the "conditions" field.
  3377. func (m *LabelMutation) SetConditions(s string) {
  3378. m.conditions = &s
  3379. }
  3380. // Conditions returns the value of the "conditions" field in the mutation.
  3381. func (m *LabelMutation) Conditions() (r string, exists bool) {
  3382. v := m.conditions
  3383. if v == nil {
  3384. return
  3385. }
  3386. return *v, true
  3387. }
  3388. // OldConditions returns the old "conditions" field's value of the Label entity.
  3389. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  3390. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3391. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  3392. if !m.op.Is(OpUpdateOne) {
  3393. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  3394. }
  3395. if m.id == nil || m.oldValue == nil {
  3396. return v, errors.New("OldConditions requires an ID field in the mutation")
  3397. }
  3398. oldValue, err := m.oldValue(ctx)
  3399. if err != nil {
  3400. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  3401. }
  3402. return oldValue.Conditions, nil
  3403. }
  3404. // ClearConditions clears the value of the "conditions" field.
  3405. func (m *LabelMutation) ClearConditions() {
  3406. m.conditions = nil
  3407. m.clearedFields[label.FieldConditions] = struct{}{}
  3408. }
  3409. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  3410. func (m *LabelMutation) ConditionsCleared() bool {
  3411. _, ok := m.clearedFields[label.FieldConditions]
  3412. return ok
  3413. }
  3414. // ResetConditions resets all changes to the "conditions" field.
  3415. func (m *LabelMutation) ResetConditions() {
  3416. m.conditions = nil
  3417. delete(m.clearedFields, label.FieldConditions)
  3418. }
  3419. // SetOrganizationID sets the "organization_id" field.
  3420. func (m *LabelMutation) SetOrganizationID(u uint64) {
  3421. m.organization_id = &u
  3422. m.addorganization_id = nil
  3423. }
  3424. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3425. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  3426. v := m.organization_id
  3427. if v == nil {
  3428. return
  3429. }
  3430. return *v, true
  3431. }
  3432. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  3433. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  3434. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3435. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3436. if !m.op.Is(OpUpdateOne) {
  3437. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3438. }
  3439. if m.id == nil || m.oldValue == nil {
  3440. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3441. }
  3442. oldValue, err := m.oldValue(ctx)
  3443. if err != nil {
  3444. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3445. }
  3446. return oldValue.OrganizationID, nil
  3447. }
  3448. // AddOrganizationID adds u to the "organization_id" field.
  3449. func (m *LabelMutation) AddOrganizationID(u int64) {
  3450. if m.addorganization_id != nil {
  3451. *m.addorganization_id += u
  3452. } else {
  3453. m.addorganization_id = &u
  3454. }
  3455. }
  3456. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3457. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  3458. v := m.addorganization_id
  3459. if v == nil {
  3460. return
  3461. }
  3462. return *v, true
  3463. }
  3464. // ClearOrganizationID clears the value of the "organization_id" field.
  3465. func (m *LabelMutation) ClearOrganizationID() {
  3466. m.organization_id = nil
  3467. m.addorganization_id = nil
  3468. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  3469. }
  3470. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3471. func (m *LabelMutation) OrganizationIDCleared() bool {
  3472. _, ok := m.clearedFields[label.FieldOrganizationID]
  3473. return ok
  3474. }
  3475. // ResetOrganizationID resets all changes to the "organization_id" field.
  3476. func (m *LabelMutation) ResetOrganizationID() {
  3477. m.organization_id = nil
  3478. m.addorganization_id = nil
  3479. delete(m.clearedFields, label.FieldOrganizationID)
  3480. }
  3481. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  3482. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  3483. if m.label_relationships == nil {
  3484. m.label_relationships = make(map[uint64]struct{})
  3485. }
  3486. for i := range ids {
  3487. m.label_relationships[ids[i]] = struct{}{}
  3488. }
  3489. }
  3490. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  3491. func (m *LabelMutation) ClearLabelRelationships() {
  3492. m.clearedlabel_relationships = true
  3493. }
  3494. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  3495. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  3496. return m.clearedlabel_relationships
  3497. }
  3498. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  3499. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  3500. if m.removedlabel_relationships == nil {
  3501. m.removedlabel_relationships = make(map[uint64]struct{})
  3502. }
  3503. for i := range ids {
  3504. delete(m.label_relationships, ids[i])
  3505. m.removedlabel_relationships[ids[i]] = struct{}{}
  3506. }
  3507. }
  3508. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  3509. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  3510. for id := range m.removedlabel_relationships {
  3511. ids = append(ids, id)
  3512. }
  3513. return
  3514. }
  3515. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  3516. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  3517. for id := range m.label_relationships {
  3518. ids = append(ids, id)
  3519. }
  3520. return
  3521. }
  3522. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  3523. func (m *LabelMutation) ResetLabelRelationships() {
  3524. m.label_relationships = nil
  3525. m.clearedlabel_relationships = false
  3526. m.removedlabel_relationships = nil
  3527. }
  3528. // Where appends a list predicates to the LabelMutation builder.
  3529. func (m *LabelMutation) Where(ps ...predicate.Label) {
  3530. m.predicates = append(m.predicates, ps...)
  3531. }
  3532. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  3533. // users can use type-assertion to append predicates that do not depend on any generated package.
  3534. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  3535. p := make([]predicate.Label, len(ps))
  3536. for i := range ps {
  3537. p[i] = ps[i]
  3538. }
  3539. m.Where(p...)
  3540. }
  3541. // Op returns the operation name.
  3542. func (m *LabelMutation) Op() Op {
  3543. return m.op
  3544. }
  3545. // SetOp allows setting the mutation operation.
  3546. func (m *LabelMutation) SetOp(op Op) {
  3547. m.op = op
  3548. }
  3549. // Type returns the node type of this mutation (Label).
  3550. func (m *LabelMutation) Type() string {
  3551. return m.typ
  3552. }
  3553. // Fields returns all fields that were changed during this mutation. Note that in
  3554. // order to get all numeric fields that were incremented/decremented, call
  3555. // AddedFields().
  3556. func (m *LabelMutation) Fields() []string {
  3557. fields := make([]string, 0, 9)
  3558. if m.created_at != nil {
  3559. fields = append(fields, label.FieldCreatedAt)
  3560. }
  3561. if m.updated_at != nil {
  3562. fields = append(fields, label.FieldUpdatedAt)
  3563. }
  3564. if m.status != nil {
  3565. fields = append(fields, label.FieldStatus)
  3566. }
  3567. if m._type != nil {
  3568. fields = append(fields, label.FieldType)
  3569. }
  3570. if m.name != nil {
  3571. fields = append(fields, label.FieldName)
  3572. }
  3573. if m.from != nil {
  3574. fields = append(fields, label.FieldFrom)
  3575. }
  3576. if m.mode != nil {
  3577. fields = append(fields, label.FieldMode)
  3578. }
  3579. if m.conditions != nil {
  3580. fields = append(fields, label.FieldConditions)
  3581. }
  3582. if m.organization_id != nil {
  3583. fields = append(fields, label.FieldOrganizationID)
  3584. }
  3585. return fields
  3586. }
  3587. // Field returns the value of a field with the given name. The second boolean
  3588. // return value indicates that this field was not set, or was not defined in the
  3589. // schema.
  3590. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  3591. switch name {
  3592. case label.FieldCreatedAt:
  3593. return m.CreatedAt()
  3594. case label.FieldUpdatedAt:
  3595. return m.UpdatedAt()
  3596. case label.FieldStatus:
  3597. return m.Status()
  3598. case label.FieldType:
  3599. return m.GetType()
  3600. case label.FieldName:
  3601. return m.Name()
  3602. case label.FieldFrom:
  3603. return m.From()
  3604. case label.FieldMode:
  3605. return m.Mode()
  3606. case label.FieldConditions:
  3607. return m.Conditions()
  3608. case label.FieldOrganizationID:
  3609. return m.OrganizationID()
  3610. }
  3611. return nil, false
  3612. }
  3613. // OldField returns the old value of the field from the database. An error is
  3614. // returned if the mutation operation is not UpdateOne, or the query to the
  3615. // database failed.
  3616. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3617. switch name {
  3618. case label.FieldCreatedAt:
  3619. return m.OldCreatedAt(ctx)
  3620. case label.FieldUpdatedAt:
  3621. return m.OldUpdatedAt(ctx)
  3622. case label.FieldStatus:
  3623. return m.OldStatus(ctx)
  3624. case label.FieldType:
  3625. return m.OldType(ctx)
  3626. case label.FieldName:
  3627. return m.OldName(ctx)
  3628. case label.FieldFrom:
  3629. return m.OldFrom(ctx)
  3630. case label.FieldMode:
  3631. return m.OldMode(ctx)
  3632. case label.FieldConditions:
  3633. return m.OldConditions(ctx)
  3634. case label.FieldOrganizationID:
  3635. return m.OldOrganizationID(ctx)
  3636. }
  3637. return nil, fmt.Errorf("unknown Label field %s", name)
  3638. }
  3639. // SetField sets the value of a field with the given name. It returns an error if
  3640. // the field is not defined in the schema, or if the type mismatched the field
  3641. // type.
  3642. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  3643. switch name {
  3644. case label.FieldCreatedAt:
  3645. v, ok := value.(time.Time)
  3646. if !ok {
  3647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3648. }
  3649. m.SetCreatedAt(v)
  3650. return nil
  3651. case label.FieldUpdatedAt:
  3652. v, ok := value.(time.Time)
  3653. if !ok {
  3654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3655. }
  3656. m.SetUpdatedAt(v)
  3657. return nil
  3658. case label.FieldStatus:
  3659. v, ok := value.(uint8)
  3660. if !ok {
  3661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3662. }
  3663. m.SetStatus(v)
  3664. return nil
  3665. case label.FieldType:
  3666. v, ok := value.(int)
  3667. if !ok {
  3668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3669. }
  3670. m.SetType(v)
  3671. return nil
  3672. case label.FieldName:
  3673. v, ok := value.(string)
  3674. if !ok {
  3675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3676. }
  3677. m.SetName(v)
  3678. return nil
  3679. case label.FieldFrom:
  3680. v, ok := value.(int)
  3681. if !ok {
  3682. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3683. }
  3684. m.SetFrom(v)
  3685. return nil
  3686. case label.FieldMode:
  3687. v, ok := value.(int)
  3688. if !ok {
  3689. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3690. }
  3691. m.SetMode(v)
  3692. return nil
  3693. case label.FieldConditions:
  3694. v, ok := value.(string)
  3695. if !ok {
  3696. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3697. }
  3698. m.SetConditions(v)
  3699. return nil
  3700. case label.FieldOrganizationID:
  3701. v, ok := value.(uint64)
  3702. if !ok {
  3703. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3704. }
  3705. m.SetOrganizationID(v)
  3706. return nil
  3707. }
  3708. return fmt.Errorf("unknown Label field %s", name)
  3709. }
  3710. // AddedFields returns all numeric fields that were incremented/decremented during
  3711. // this mutation.
  3712. func (m *LabelMutation) AddedFields() []string {
  3713. var fields []string
  3714. if m.addstatus != nil {
  3715. fields = append(fields, label.FieldStatus)
  3716. }
  3717. if m.add_type != nil {
  3718. fields = append(fields, label.FieldType)
  3719. }
  3720. if m.addfrom != nil {
  3721. fields = append(fields, label.FieldFrom)
  3722. }
  3723. if m.addmode != nil {
  3724. fields = append(fields, label.FieldMode)
  3725. }
  3726. if m.addorganization_id != nil {
  3727. fields = append(fields, label.FieldOrganizationID)
  3728. }
  3729. return fields
  3730. }
  3731. // AddedField returns the numeric value that was incremented/decremented on a field
  3732. // with the given name. The second boolean return value indicates that this field
  3733. // was not set, or was not defined in the schema.
  3734. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  3735. switch name {
  3736. case label.FieldStatus:
  3737. return m.AddedStatus()
  3738. case label.FieldType:
  3739. return m.AddedType()
  3740. case label.FieldFrom:
  3741. return m.AddedFrom()
  3742. case label.FieldMode:
  3743. return m.AddedMode()
  3744. case label.FieldOrganizationID:
  3745. return m.AddedOrganizationID()
  3746. }
  3747. return nil, false
  3748. }
  3749. // AddField adds the value to the field with the given name. It returns an error if
  3750. // the field is not defined in the schema, or if the type mismatched the field
  3751. // type.
  3752. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  3753. switch name {
  3754. case label.FieldStatus:
  3755. v, ok := value.(int8)
  3756. if !ok {
  3757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3758. }
  3759. m.AddStatus(v)
  3760. return nil
  3761. case label.FieldType:
  3762. v, ok := value.(int)
  3763. if !ok {
  3764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3765. }
  3766. m.AddType(v)
  3767. return nil
  3768. case label.FieldFrom:
  3769. v, ok := value.(int)
  3770. if !ok {
  3771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3772. }
  3773. m.AddFrom(v)
  3774. return nil
  3775. case label.FieldMode:
  3776. v, ok := value.(int)
  3777. if !ok {
  3778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3779. }
  3780. m.AddMode(v)
  3781. return nil
  3782. case label.FieldOrganizationID:
  3783. v, ok := value.(int64)
  3784. if !ok {
  3785. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3786. }
  3787. m.AddOrganizationID(v)
  3788. return nil
  3789. }
  3790. return fmt.Errorf("unknown Label numeric field %s", name)
  3791. }
  3792. // ClearedFields returns all nullable fields that were cleared during this
  3793. // mutation.
  3794. func (m *LabelMutation) ClearedFields() []string {
  3795. var fields []string
  3796. if m.FieldCleared(label.FieldStatus) {
  3797. fields = append(fields, label.FieldStatus)
  3798. }
  3799. if m.FieldCleared(label.FieldConditions) {
  3800. fields = append(fields, label.FieldConditions)
  3801. }
  3802. if m.FieldCleared(label.FieldOrganizationID) {
  3803. fields = append(fields, label.FieldOrganizationID)
  3804. }
  3805. return fields
  3806. }
  3807. // FieldCleared returns a boolean indicating if a field with the given name was
  3808. // cleared in this mutation.
  3809. func (m *LabelMutation) FieldCleared(name string) bool {
  3810. _, ok := m.clearedFields[name]
  3811. return ok
  3812. }
  3813. // ClearField clears the value of the field with the given name. It returns an
  3814. // error if the field is not defined in the schema.
  3815. func (m *LabelMutation) ClearField(name string) error {
  3816. switch name {
  3817. case label.FieldStatus:
  3818. m.ClearStatus()
  3819. return nil
  3820. case label.FieldConditions:
  3821. m.ClearConditions()
  3822. return nil
  3823. case label.FieldOrganizationID:
  3824. m.ClearOrganizationID()
  3825. return nil
  3826. }
  3827. return fmt.Errorf("unknown Label nullable field %s", name)
  3828. }
  3829. // ResetField resets all changes in the mutation for the field with the given name.
  3830. // It returns an error if the field is not defined in the schema.
  3831. func (m *LabelMutation) ResetField(name string) error {
  3832. switch name {
  3833. case label.FieldCreatedAt:
  3834. m.ResetCreatedAt()
  3835. return nil
  3836. case label.FieldUpdatedAt:
  3837. m.ResetUpdatedAt()
  3838. return nil
  3839. case label.FieldStatus:
  3840. m.ResetStatus()
  3841. return nil
  3842. case label.FieldType:
  3843. m.ResetType()
  3844. return nil
  3845. case label.FieldName:
  3846. m.ResetName()
  3847. return nil
  3848. case label.FieldFrom:
  3849. m.ResetFrom()
  3850. return nil
  3851. case label.FieldMode:
  3852. m.ResetMode()
  3853. return nil
  3854. case label.FieldConditions:
  3855. m.ResetConditions()
  3856. return nil
  3857. case label.FieldOrganizationID:
  3858. m.ResetOrganizationID()
  3859. return nil
  3860. }
  3861. return fmt.Errorf("unknown Label field %s", name)
  3862. }
  3863. // AddedEdges returns all edge names that were set/added in this mutation.
  3864. func (m *LabelMutation) AddedEdges() []string {
  3865. edges := make([]string, 0, 1)
  3866. if m.label_relationships != nil {
  3867. edges = append(edges, label.EdgeLabelRelationships)
  3868. }
  3869. return edges
  3870. }
  3871. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3872. // name in this mutation.
  3873. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  3874. switch name {
  3875. case label.EdgeLabelRelationships:
  3876. ids := make([]ent.Value, 0, len(m.label_relationships))
  3877. for id := range m.label_relationships {
  3878. ids = append(ids, id)
  3879. }
  3880. return ids
  3881. }
  3882. return nil
  3883. }
  3884. // RemovedEdges returns all edge names that were removed in this mutation.
  3885. func (m *LabelMutation) RemovedEdges() []string {
  3886. edges := make([]string, 0, 1)
  3887. if m.removedlabel_relationships != nil {
  3888. edges = append(edges, label.EdgeLabelRelationships)
  3889. }
  3890. return edges
  3891. }
  3892. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3893. // the given name in this mutation.
  3894. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  3895. switch name {
  3896. case label.EdgeLabelRelationships:
  3897. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  3898. for id := range m.removedlabel_relationships {
  3899. ids = append(ids, id)
  3900. }
  3901. return ids
  3902. }
  3903. return nil
  3904. }
  3905. // ClearedEdges returns all edge names that were cleared in this mutation.
  3906. func (m *LabelMutation) ClearedEdges() []string {
  3907. edges := make([]string, 0, 1)
  3908. if m.clearedlabel_relationships {
  3909. edges = append(edges, label.EdgeLabelRelationships)
  3910. }
  3911. return edges
  3912. }
  3913. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3914. // was cleared in this mutation.
  3915. func (m *LabelMutation) EdgeCleared(name string) bool {
  3916. switch name {
  3917. case label.EdgeLabelRelationships:
  3918. return m.clearedlabel_relationships
  3919. }
  3920. return false
  3921. }
  3922. // ClearEdge clears the value of the edge with the given name. It returns an error
  3923. // if that edge is not defined in the schema.
  3924. func (m *LabelMutation) ClearEdge(name string) error {
  3925. switch name {
  3926. }
  3927. return fmt.Errorf("unknown Label unique edge %s", name)
  3928. }
  3929. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3930. // It returns an error if the edge is not defined in the schema.
  3931. func (m *LabelMutation) ResetEdge(name string) error {
  3932. switch name {
  3933. case label.EdgeLabelRelationships:
  3934. m.ResetLabelRelationships()
  3935. return nil
  3936. }
  3937. return fmt.Errorf("unknown Label edge %s", name)
  3938. }
  3939. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  3940. type LabelRelationshipMutation struct {
  3941. config
  3942. op Op
  3943. typ string
  3944. id *uint64
  3945. created_at *time.Time
  3946. updated_at *time.Time
  3947. status *uint8
  3948. addstatus *int8
  3949. deleted_at *time.Time
  3950. organization_id *uint64
  3951. addorganization_id *int64
  3952. clearedFields map[string]struct{}
  3953. contacts *uint64
  3954. clearedcontacts bool
  3955. labels *uint64
  3956. clearedlabels bool
  3957. done bool
  3958. oldValue func(context.Context) (*LabelRelationship, error)
  3959. predicates []predicate.LabelRelationship
  3960. }
  3961. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  3962. // labelrelationshipOption allows management of the mutation configuration using functional options.
  3963. type labelrelationshipOption func(*LabelRelationshipMutation)
  3964. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  3965. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  3966. m := &LabelRelationshipMutation{
  3967. config: c,
  3968. op: op,
  3969. typ: TypeLabelRelationship,
  3970. clearedFields: make(map[string]struct{}),
  3971. }
  3972. for _, opt := range opts {
  3973. opt(m)
  3974. }
  3975. return m
  3976. }
  3977. // withLabelRelationshipID sets the ID field of the mutation.
  3978. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  3979. return func(m *LabelRelationshipMutation) {
  3980. var (
  3981. err error
  3982. once sync.Once
  3983. value *LabelRelationship
  3984. )
  3985. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  3986. once.Do(func() {
  3987. if m.done {
  3988. err = errors.New("querying old values post mutation is not allowed")
  3989. } else {
  3990. value, err = m.Client().LabelRelationship.Get(ctx, id)
  3991. }
  3992. })
  3993. return value, err
  3994. }
  3995. m.id = &id
  3996. }
  3997. }
  3998. // withLabelRelationship sets the old LabelRelationship of the mutation.
  3999. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  4000. return func(m *LabelRelationshipMutation) {
  4001. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  4002. return node, nil
  4003. }
  4004. m.id = &node.ID
  4005. }
  4006. }
  4007. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4008. // executed in a transaction (ent.Tx), a transactional client is returned.
  4009. func (m LabelRelationshipMutation) Client() *Client {
  4010. client := &Client{config: m.config}
  4011. client.init()
  4012. return client
  4013. }
  4014. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4015. // it returns an error otherwise.
  4016. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  4017. if _, ok := m.driver.(*txDriver); !ok {
  4018. return nil, errors.New("ent: mutation is not running in a transaction")
  4019. }
  4020. tx := &Tx{config: m.config}
  4021. tx.init()
  4022. return tx, nil
  4023. }
  4024. // SetID sets the value of the id field. Note that this
  4025. // operation is only accepted on creation of LabelRelationship entities.
  4026. func (m *LabelRelationshipMutation) SetID(id uint64) {
  4027. m.id = &id
  4028. }
  4029. // ID returns the ID value in the mutation. Note that the ID is only available
  4030. // if it was provided to the builder or after it was returned from the database.
  4031. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  4032. if m.id == nil {
  4033. return
  4034. }
  4035. return *m.id, true
  4036. }
  4037. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4038. // That means, if the mutation is applied within a transaction with an isolation level such
  4039. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4040. // or updated by the mutation.
  4041. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  4042. switch {
  4043. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4044. id, exists := m.ID()
  4045. if exists {
  4046. return []uint64{id}, nil
  4047. }
  4048. fallthrough
  4049. case m.op.Is(OpUpdate | OpDelete):
  4050. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  4051. default:
  4052. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4053. }
  4054. }
  4055. // SetCreatedAt sets the "created_at" field.
  4056. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  4057. m.created_at = &t
  4058. }
  4059. // CreatedAt returns the value of the "created_at" field in the mutation.
  4060. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  4061. v := m.created_at
  4062. if v == nil {
  4063. return
  4064. }
  4065. return *v, true
  4066. }
  4067. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  4068. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  4069. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4070. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4071. if !m.op.Is(OpUpdateOne) {
  4072. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4073. }
  4074. if m.id == nil || m.oldValue == nil {
  4075. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4076. }
  4077. oldValue, err := m.oldValue(ctx)
  4078. if err != nil {
  4079. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4080. }
  4081. return oldValue.CreatedAt, nil
  4082. }
  4083. // ResetCreatedAt resets all changes to the "created_at" field.
  4084. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  4085. m.created_at = nil
  4086. }
  4087. // SetUpdatedAt sets the "updated_at" field.
  4088. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  4089. m.updated_at = &t
  4090. }
  4091. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4092. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  4093. v := m.updated_at
  4094. if v == nil {
  4095. return
  4096. }
  4097. return *v, true
  4098. }
  4099. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  4100. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  4101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4102. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4103. if !m.op.Is(OpUpdateOne) {
  4104. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4105. }
  4106. if m.id == nil || m.oldValue == nil {
  4107. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4108. }
  4109. oldValue, err := m.oldValue(ctx)
  4110. if err != nil {
  4111. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4112. }
  4113. return oldValue.UpdatedAt, nil
  4114. }
  4115. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4116. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  4117. m.updated_at = nil
  4118. }
  4119. // SetStatus sets the "status" field.
  4120. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  4121. m.status = &u
  4122. m.addstatus = nil
  4123. }
  4124. // Status returns the value of the "status" field in the mutation.
  4125. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  4126. v := m.status
  4127. if v == nil {
  4128. return
  4129. }
  4130. return *v, true
  4131. }
  4132. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  4133. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  4134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4135. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  4136. if !m.op.Is(OpUpdateOne) {
  4137. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  4138. }
  4139. if m.id == nil || m.oldValue == nil {
  4140. return v, errors.New("OldStatus requires an ID field in the mutation")
  4141. }
  4142. oldValue, err := m.oldValue(ctx)
  4143. if err != nil {
  4144. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  4145. }
  4146. return oldValue.Status, nil
  4147. }
  4148. // AddStatus adds u to the "status" field.
  4149. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  4150. if m.addstatus != nil {
  4151. *m.addstatus += u
  4152. } else {
  4153. m.addstatus = &u
  4154. }
  4155. }
  4156. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4157. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  4158. v := m.addstatus
  4159. if v == nil {
  4160. return
  4161. }
  4162. return *v, true
  4163. }
  4164. // ClearStatus clears the value of the "status" field.
  4165. func (m *LabelRelationshipMutation) ClearStatus() {
  4166. m.status = nil
  4167. m.addstatus = nil
  4168. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  4169. }
  4170. // StatusCleared returns if the "status" field was cleared in this mutation.
  4171. func (m *LabelRelationshipMutation) StatusCleared() bool {
  4172. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  4173. return ok
  4174. }
  4175. // ResetStatus resets all changes to the "status" field.
  4176. func (m *LabelRelationshipMutation) ResetStatus() {
  4177. m.status = nil
  4178. m.addstatus = nil
  4179. delete(m.clearedFields, labelrelationship.FieldStatus)
  4180. }
  4181. // SetDeletedAt sets the "deleted_at" field.
  4182. func (m *LabelRelationshipMutation) SetDeletedAt(t time.Time) {
  4183. m.deleted_at = &t
  4184. }
  4185. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4186. func (m *LabelRelationshipMutation) DeletedAt() (r time.Time, exists bool) {
  4187. v := m.deleted_at
  4188. if v == nil {
  4189. return
  4190. }
  4191. return *v, true
  4192. }
  4193. // OldDeletedAt returns the old "deleted_at" field's value of the LabelRelationship entity.
  4194. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  4195. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4196. func (m *LabelRelationshipMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4197. if !m.op.Is(OpUpdateOne) {
  4198. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4199. }
  4200. if m.id == nil || m.oldValue == nil {
  4201. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4202. }
  4203. oldValue, err := m.oldValue(ctx)
  4204. if err != nil {
  4205. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4206. }
  4207. return oldValue.DeletedAt, nil
  4208. }
  4209. // ClearDeletedAt clears the value of the "deleted_at" field.
  4210. func (m *LabelRelationshipMutation) ClearDeletedAt() {
  4211. m.deleted_at = nil
  4212. m.clearedFields[labelrelationship.FieldDeletedAt] = struct{}{}
  4213. }
  4214. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4215. func (m *LabelRelationshipMutation) DeletedAtCleared() bool {
  4216. _, ok := m.clearedFields[labelrelationship.FieldDeletedAt]
  4217. return ok
  4218. }
  4219. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4220. func (m *LabelRelationshipMutation) ResetDeletedAt() {
  4221. m.deleted_at = nil
  4222. delete(m.clearedFields, labelrelationship.FieldDeletedAt)
  4223. }
  4224. // SetLabelID sets the "label_id" field.
  4225. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  4226. m.labels = &u
  4227. }
  4228. // LabelID returns the value of the "label_id" field in the mutation.
  4229. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  4230. v := m.labels
  4231. if v == nil {
  4232. return
  4233. }
  4234. return *v, true
  4235. }
  4236. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  4237. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  4238. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4239. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  4240. if !m.op.Is(OpUpdateOne) {
  4241. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  4242. }
  4243. if m.id == nil || m.oldValue == nil {
  4244. return v, errors.New("OldLabelID requires an ID field in the mutation")
  4245. }
  4246. oldValue, err := m.oldValue(ctx)
  4247. if err != nil {
  4248. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  4249. }
  4250. return oldValue.LabelID, nil
  4251. }
  4252. // ResetLabelID resets all changes to the "label_id" field.
  4253. func (m *LabelRelationshipMutation) ResetLabelID() {
  4254. m.labels = nil
  4255. }
  4256. // SetContactID sets the "contact_id" field.
  4257. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  4258. m.contacts = &u
  4259. }
  4260. // ContactID returns the value of the "contact_id" field in the mutation.
  4261. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  4262. v := m.contacts
  4263. if v == nil {
  4264. return
  4265. }
  4266. return *v, true
  4267. }
  4268. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  4269. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  4270. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4271. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  4272. if !m.op.Is(OpUpdateOne) {
  4273. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  4274. }
  4275. if m.id == nil || m.oldValue == nil {
  4276. return v, errors.New("OldContactID requires an ID field in the mutation")
  4277. }
  4278. oldValue, err := m.oldValue(ctx)
  4279. if err != nil {
  4280. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  4281. }
  4282. return oldValue.ContactID, nil
  4283. }
  4284. // ResetContactID resets all changes to the "contact_id" field.
  4285. func (m *LabelRelationshipMutation) ResetContactID() {
  4286. m.contacts = nil
  4287. }
  4288. // SetOrganizationID sets the "organization_id" field.
  4289. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  4290. m.organization_id = &u
  4291. m.addorganization_id = nil
  4292. }
  4293. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4294. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  4295. v := m.organization_id
  4296. if v == nil {
  4297. return
  4298. }
  4299. return *v, true
  4300. }
  4301. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  4302. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  4303. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4304. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4305. if !m.op.Is(OpUpdateOne) {
  4306. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4307. }
  4308. if m.id == nil || m.oldValue == nil {
  4309. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4310. }
  4311. oldValue, err := m.oldValue(ctx)
  4312. if err != nil {
  4313. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4314. }
  4315. return oldValue.OrganizationID, nil
  4316. }
  4317. // AddOrganizationID adds u to the "organization_id" field.
  4318. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  4319. if m.addorganization_id != nil {
  4320. *m.addorganization_id += u
  4321. } else {
  4322. m.addorganization_id = &u
  4323. }
  4324. }
  4325. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4326. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  4327. v := m.addorganization_id
  4328. if v == nil {
  4329. return
  4330. }
  4331. return *v, true
  4332. }
  4333. // ClearOrganizationID clears the value of the "organization_id" field.
  4334. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  4335. m.organization_id = nil
  4336. m.addorganization_id = nil
  4337. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  4338. }
  4339. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  4340. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  4341. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  4342. return ok
  4343. }
  4344. // ResetOrganizationID resets all changes to the "organization_id" field.
  4345. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  4346. m.organization_id = nil
  4347. m.addorganization_id = nil
  4348. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  4349. }
  4350. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  4351. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  4352. m.contacts = &id
  4353. }
  4354. // ClearContacts clears the "contacts" edge to the Contact entity.
  4355. func (m *LabelRelationshipMutation) ClearContacts() {
  4356. m.clearedcontacts = true
  4357. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  4358. }
  4359. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  4360. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  4361. return m.clearedcontacts
  4362. }
  4363. // ContactsID returns the "contacts" edge ID in the mutation.
  4364. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  4365. if m.contacts != nil {
  4366. return *m.contacts, true
  4367. }
  4368. return
  4369. }
  4370. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  4371. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  4372. // ContactsID instead. It exists only for internal usage by the builders.
  4373. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  4374. if id := m.contacts; id != nil {
  4375. ids = append(ids, *id)
  4376. }
  4377. return
  4378. }
  4379. // ResetContacts resets all changes to the "contacts" edge.
  4380. func (m *LabelRelationshipMutation) ResetContacts() {
  4381. m.contacts = nil
  4382. m.clearedcontacts = false
  4383. }
  4384. // SetLabelsID sets the "labels" edge to the Label entity by id.
  4385. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  4386. m.labels = &id
  4387. }
  4388. // ClearLabels clears the "labels" edge to the Label entity.
  4389. func (m *LabelRelationshipMutation) ClearLabels() {
  4390. m.clearedlabels = true
  4391. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  4392. }
  4393. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  4394. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  4395. return m.clearedlabels
  4396. }
  4397. // LabelsID returns the "labels" edge ID in the mutation.
  4398. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  4399. if m.labels != nil {
  4400. return *m.labels, true
  4401. }
  4402. return
  4403. }
  4404. // LabelsIDs returns the "labels" edge IDs in the mutation.
  4405. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  4406. // LabelsID instead. It exists only for internal usage by the builders.
  4407. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  4408. if id := m.labels; id != nil {
  4409. ids = append(ids, *id)
  4410. }
  4411. return
  4412. }
  4413. // ResetLabels resets all changes to the "labels" edge.
  4414. func (m *LabelRelationshipMutation) ResetLabels() {
  4415. m.labels = nil
  4416. m.clearedlabels = false
  4417. }
  4418. // Where appends a list predicates to the LabelRelationshipMutation builder.
  4419. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  4420. m.predicates = append(m.predicates, ps...)
  4421. }
  4422. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  4423. // users can use type-assertion to append predicates that do not depend on any generated package.
  4424. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  4425. p := make([]predicate.LabelRelationship, 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 *LabelRelationshipMutation) Op() Op {
  4433. return m.op
  4434. }
  4435. // SetOp allows setting the mutation operation.
  4436. func (m *LabelRelationshipMutation) SetOp(op Op) {
  4437. m.op = op
  4438. }
  4439. // Type returns the node type of this mutation (LabelRelationship).
  4440. func (m *LabelRelationshipMutation) 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 *LabelRelationshipMutation) Fields() []string {
  4447. fields := make([]string, 0, 7)
  4448. if m.created_at != nil {
  4449. fields = append(fields, labelrelationship.FieldCreatedAt)
  4450. }
  4451. if m.updated_at != nil {
  4452. fields = append(fields, labelrelationship.FieldUpdatedAt)
  4453. }
  4454. if m.status != nil {
  4455. fields = append(fields, labelrelationship.FieldStatus)
  4456. }
  4457. if m.deleted_at != nil {
  4458. fields = append(fields, labelrelationship.FieldDeletedAt)
  4459. }
  4460. if m.labels != nil {
  4461. fields = append(fields, labelrelationship.FieldLabelID)
  4462. }
  4463. if m.contacts != nil {
  4464. fields = append(fields, labelrelationship.FieldContactID)
  4465. }
  4466. if m.organization_id != nil {
  4467. fields = append(fields, labelrelationship.FieldOrganizationID)
  4468. }
  4469. return fields
  4470. }
  4471. // Field returns the value of a field with the given name. The second boolean
  4472. // return value indicates that this field was not set, or was not defined in the
  4473. // schema.
  4474. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  4475. switch name {
  4476. case labelrelationship.FieldCreatedAt:
  4477. return m.CreatedAt()
  4478. case labelrelationship.FieldUpdatedAt:
  4479. return m.UpdatedAt()
  4480. case labelrelationship.FieldStatus:
  4481. return m.Status()
  4482. case labelrelationship.FieldDeletedAt:
  4483. return m.DeletedAt()
  4484. case labelrelationship.FieldLabelID:
  4485. return m.LabelID()
  4486. case labelrelationship.FieldContactID:
  4487. return m.ContactID()
  4488. case labelrelationship.FieldOrganizationID:
  4489. return m.OrganizationID()
  4490. }
  4491. return nil, false
  4492. }
  4493. // OldField returns the old value of the field from the database. An error is
  4494. // returned if the mutation operation is not UpdateOne, or the query to the
  4495. // database failed.
  4496. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4497. switch name {
  4498. case labelrelationship.FieldCreatedAt:
  4499. return m.OldCreatedAt(ctx)
  4500. case labelrelationship.FieldUpdatedAt:
  4501. return m.OldUpdatedAt(ctx)
  4502. case labelrelationship.FieldStatus:
  4503. return m.OldStatus(ctx)
  4504. case labelrelationship.FieldDeletedAt:
  4505. return m.OldDeletedAt(ctx)
  4506. case labelrelationship.FieldLabelID:
  4507. return m.OldLabelID(ctx)
  4508. case labelrelationship.FieldContactID:
  4509. return m.OldContactID(ctx)
  4510. case labelrelationship.FieldOrganizationID:
  4511. return m.OldOrganizationID(ctx)
  4512. }
  4513. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  4514. }
  4515. // SetField sets the value of a field with the given name. It returns an error if
  4516. // the field is not defined in the schema, or if the type mismatched the field
  4517. // type.
  4518. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  4519. switch name {
  4520. case labelrelationship.FieldCreatedAt:
  4521. v, ok := value.(time.Time)
  4522. if !ok {
  4523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4524. }
  4525. m.SetCreatedAt(v)
  4526. return nil
  4527. case labelrelationship.FieldUpdatedAt:
  4528. v, ok := value.(time.Time)
  4529. if !ok {
  4530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4531. }
  4532. m.SetUpdatedAt(v)
  4533. return nil
  4534. case labelrelationship.FieldStatus:
  4535. v, ok := value.(uint8)
  4536. if !ok {
  4537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4538. }
  4539. m.SetStatus(v)
  4540. return nil
  4541. case labelrelationship.FieldDeletedAt:
  4542. v, ok := value.(time.Time)
  4543. if !ok {
  4544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4545. }
  4546. m.SetDeletedAt(v)
  4547. return nil
  4548. case labelrelationship.FieldLabelID:
  4549. v, ok := value.(uint64)
  4550. if !ok {
  4551. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4552. }
  4553. m.SetLabelID(v)
  4554. return nil
  4555. case labelrelationship.FieldContactID:
  4556. v, ok := value.(uint64)
  4557. if !ok {
  4558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4559. }
  4560. m.SetContactID(v)
  4561. return nil
  4562. case labelrelationship.FieldOrganizationID:
  4563. v, ok := value.(uint64)
  4564. if !ok {
  4565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4566. }
  4567. m.SetOrganizationID(v)
  4568. return nil
  4569. }
  4570. return fmt.Errorf("unknown LabelRelationship field %s", name)
  4571. }
  4572. // AddedFields returns all numeric fields that were incremented/decremented during
  4573. // this mutation.
  4574. func (m *LabelRelationshipMutation) AddedFields() []string {
  4575. var fields []string
  4576. if m.addstatus != nil {
  4577. fields = append(fields, labelrelationship.FieldStatus)
  4578. }
  4579. if m.addorganization_id != nil {
  4580. fields = append(fields, labelrelationship.FieldOrganizationID)
  4581. }
  4582. return fields
  4583. }
  4584. // AddedField returns the numeric value that was incremented/decremented on a field
  4585. // with the given name. The second boolean return value indicates that this field
  4586. // was not set, or was not defined in the schema.
  4587. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  4588. switch name {
  4589. case labelrelationship.FieldStatus:
  4590. return m.AddedStatus()
  4591. case labelrelationship.FieldOrganizationID:
  4592. return m.AddedOrganizationID()
  4593. }
  4594. return nil, false
  4595. }
  4596. // AddField adds the value to the field with the given name. It returns an error if
  4597. // the field is not defined in the schema, or if the type mismatched the field
  4598. // type.
  4599. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  4600. switch name {
  4601. case labelrelationship.FieldStatus:
  4602. v, ok := value.(int8)
  4603. if !ok {
  4604. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4605. }
  4606. m.AddStatus(v)
  4607. return nil
  4608. case labelrelationship.FieldOrganizationID:
  4609. v, ok := value.(int64)
  4610. if !ok {
  4611. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4612. }
  4613. m.AddOrganizationID(v)
  4614. return nil
  4615. }
  4616. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  4617. }
  4618. // ClearedFields returns all nullable fields that were cleared during this
  4619. // mutation.
  4620. func (m *LabelRelationshipMutation) ClearedFields() []string {
  4621. var fields []string
  4622. if m.FieldCleared(labelrelationship.FieldStatus) {
  4623. fields = append(fields, labelrelationship.FieldStatus)
  4624. }
  4625. if m.FieldCleared(labelrelationship.FieldDeletedAt) {
  4626. fields = append(fields, labelrelationship.FieldDeletedAt)
  4627. }
  4628. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  4629. fields = append(fields, labelrelationship.FieldOrganizationID)
  4630. }
  4631. return fields
  4632. }
  4633. // FieldCleared returns a boolean indicating if a field with the given name was
  4634. // cleared in this mutation.
  4635. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  4636. _, ok := m.clearedFields[name]
  4637. return ok
  4638. }
  4639. // ClearField clears the value of the field with the given name. It returns an
  4640. // error if the field is not defined in the schema.
  4641. func (m *LabelRelationshipMutation) ClearField(name string) error {
  4642. switch name {
  4643. case labelrelationship.FieldStatus:
  4644. m.ClearStatus()
  4645. return nil
  4646. case labelrelationship.FieldDeletedAt:
  4647. m.ClearDeletedAt()
  4648. return nil
  4649. case labelrelationship.FieldOrganizationID:
  4650. m.ClearOrganizationID()
  4651. return nil
  4652. }
  4653. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  4654. }
  4655. // ResetField resets all changes in the mutation for the field with the given name.
  4656. // It returns an error if the field is not defined in the schema.
  4657. func (m *LabelRelationshipMutation) ResetField(name string) error {
  4658. switch name {
  4659. case labelrelationship.FieldCreatedAt:
  4660. m.ResetCreatedAt()
  4661. return nil
  4662. case labelrelationship.FieldUpdatedAt:
  4663. m.ResetUpdatedAt()
  4664. return nil
  4665. case labelrelationship.FieldStatus:
  4666. m.ResetStatus()
  4667. return nil
  4668. case labelrelationship.FieldDeletedAt:
  4669. m.ResetDeletedAt()
  4670. return nil
  4671. case labelrelationship.FieldLabelID:
  4672. m.ResetLabelID()
  4673. return nil
  4674. case labelrelationship.FieldContactID:
  4675. m.ResetContactID()
  4676. return nil
  4677. case labelrelationship.FieldOrganizationID:
  4678. m.ResetOrganizationID()
  4679. return nil
  4680. }
  4681. return fmt.Errorf("unknown LabelRelationship field %s", name)
  4682. }
  4683. // AddedEdges returns all edge names that were set/added in this mutation.
  4684. func (m *LabelRelationshipMutation) AddedEdges() []string {
  4685. edges := make([]string, 0, 2)
  4686. if m.contacts != nil {
  4687. edges = append(edges, labelrelationship.EdgeContacts)
  4688. }
  4689. if m.labels != nil {
  4690. edges = append(edges, labelrelationship.EdgeLabels)
  4691. }
  4692. return edges
  4693. }
  4694. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4695. // name in this mutation.
  4696. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  4697. switch name {
  4698. case labelrelationship.EdgeContacts:
  4699. if id := m.contacts; id != nil {
  4700. return []ent.Value{*id}
  4701. }
  4702. case labelrelationship.EdgeLabels:
  4703. if id := m.labels; id != nil {
  4704. return []ent.Value{*id}
  4705. }
  4706. }
  4707. return nil
  4708. }
  4709. // RemovedEdges returns all edge names that were removed in this mutation.
  4710. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  4711. edges := make([]string, 0, 2)
  4712. return edges
  4713. }
  4714. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4715. // the given name in this mutation.
  4716. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  4717. return nil
  4718. }
  4719. // ClearedEdges returns all edge names that were cleared in this mutation.
  4720. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  4721. edges := make([]string, 0, 2)
  4722. if m.clearedcontacts {
  4723. edges = append(edges, labelrelationship.EdgeContacts)
  4724. }
  4725. if m.clearedlabels {
  4726. edges = append(edges, labelrelationship.EdgeLabels)
  4727. }
  4728. return edges
  4729. }
  4730. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4731. // was cleared in this mutation.
  4732. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  4733. switch name {
  4734. case labelrelationship.EdgeContacts:
  4735. return m.clearedcontacts
  4736. case labelrelationship.EdgeLabels:
  4737. return m.clearedlabels
  4738. }
  4739. return false
  4740. }
  4741. // ClearEdge clears the value of the edge with the given name. It returns an error
  4742. // if that edge is not defined in the schema.
  4743. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  4744. switch name {
  4745. case labelrelationship.EdgeContacts:
  4746. m.ClearContacts()
  4747. return nil
  4748. case labelrelationship.EdgeLabels:
  4749. m.ClearLabels()
  4750. return nil
  4751. }
  4752. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  4753. }
  4754. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4755. // It returns an error if the edge is not defined in the schema.
  4756. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  4757. switch name {
  4758. case labelrelationship.EdgeContacts:
  4759. m.ResetContacts()
  4760. return nil
  4761. case labelrelationship.EdgeLabels:
  4762. m.ResetLabels()
  4763. return nil
  4764. }
  4765. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  4766. }
  4767. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  4768. type MessageMutation struct {
  4769. config
  4770. op Op
  4771. typ string
  4772. id *int
  4773. wx_wxid *string
  4774. wxid *string
  4775. content *string
  4776. clearedFields map[string]struct{}
  4777. done bool
  4778. oldValue func(context.Context) (*Message, error)
  4779. predicates []predicate.Message
  4780. }
  4781. var _ ent.Mutation = (*MessageMutation)(nil)
  4782. // messageOption allows management of the mutation configuration using functional options.
  4783. type messageOption func(*MessageMutation)
  4784. // newMessageMutation creates new mutation for the Message entity.
  4785. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  4786. m := &MessageMutation{
  4787. config: c,
  4788. op: op,
  4789. typ: TypeMessage,
  4790. clearedFields: make(map[string]struct{}),
  4791. }
  4792. for _, opt := range opts {
  4793. opt(m)
  4794. }
  4795. return m
  4796. }
  4797. // withMessageID sets the ID field of the mutation.
  4798. func withMessageID(id int) messageOption {
  4799. return func(m *MessageMutation) {
  4800. var (
  4801. err error
  4802. once sync.Once
  4803. value *Message
  4804. )
  4805. m.oldValue = func(ctx context.Context) (*Message, error) {
  4806. once.Do(func() {
  4807. if m.done {
  4808. err = errors.New("querying old values post mutation is not allowed")
  4809. } else {
  4810. value, err = m.Client().Message.Get(ctx, id)
  4811. }
  4812. })
  4813. return value, err
  4814. }
  4815. m.id = &id
  4816. }
  4817. }
  4818. // withMessage sets the old Message of the mutation.
  4819. func withMessage(node *Message) messageOption {
  4820. return func(m *MessageMutation) {
  4821. m.oldValue = func(context.Context) (*Message, error) {
  4822. return node, nil
  4823. }
  4824. m.id = &node.ID
  4825. }
  4826. }
  4827. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4828. // executed in a transaction (ent.Tx), a transactional client is returned.
  4829. func (m MessageMutation) Client() *Client {
  4830. client := &Client{config: m.config}
  4831. client.init()
  4832. return client
  4833. }
  4834. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4835. // it returns an error otherwise.
  4836. func (m MessageMutation) Tx() (*Tx, error) {
  4837. if _, ok := m.driver.(*txDriver); !ok {
  4838. return nil, errors.New("ent: mutation is not running in a transaction")
  4839. }
  4840. tx := &Tx{config: m.config}
  4841. tx.init()
  4842. return tx, nil
  4843. }
  4844. // ID returns the ID value in the mutation. Note that the ID is only available
  4845. // if it was provided to the builder or after it was returned from the database.
  4846. func (m *MessageMutation) ID() (id int, exists bool) {
  4847. if m.id == nil {
  4848. return
  4849. }
  4850. return *m.id, true
  4851. }
  4852. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4853. // That means, if the mutation is applied within a transaction with an isolation level such
  4854. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4855. // or updated by the mutation.
  4856. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  4857. switch {
  4858. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4859. id, exists := m.ID()
  4860. if exists {
  4861. return []int{id}, nil
  4862. }
  4863. fallthrough
  4864. case m.op.Is(OpUpdate | OpDelete):
  4865. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  4866. default:
  4867. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4868. }
  4869. }
  4870. // SetWxWxid sets the "wx_wxid" field.
  4871. func (m *MessageMutation) SetWxWxid(s string) {
  4872. m.wx_wxid = &s
  4873. }
  4874. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  4875. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  4876. v := m.wx_wxid
  4877. if v == nil {
  4878. return
  4879. }
  4880. return *v, true
  4881. }
  4882. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  4883. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  4884. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4885. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  4886. if !m.op.Is(OpUpdateOne) {
  4887. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  4888. }
  4889. if m.id == nil || m.oldValue == nil {
  4890. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  4891. }
  4892. oldValue, err := m.oldValue(ctx)
  4893. if err != nil {
  4894. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  4895. }
  4896. return oldValue.WxWxid, nil
  4897. }
  4898. // ClearWxWxid clears the value of the "wx_wxid" field.
  4899. func (m *MessageMutation) ClearWxWxid() {
  4900. m.wx_wxid = nil
  4901. m.clearedFields[message.FieldWxWxid] = struct{}{}
  4902. }
  4903. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  4904. func (m *MessageMutation) WxWxidCleared() bool {
  4905. _, ok := m.clearedFields[message.FieldWxWxid]
  4906. return ok
  4907. }
  4908. // ResetWxWxid resets all changes to the "wx_wxid" field.
  4909. func (m *MessageMutation) ResetWxWxid() {
  4910. m.wx_wxid = nil
  4911. delete(m.clearedFields, message.FieldWxWxid)
  4912. }
  4913. // SetWxid sets the "wxid" field.
  4914. func (m *MessageMutation) SetWxid(s string) {
  4915. m.wxid = &s
  4916. }
  4917. // Wxid returns the value of the "wxid" field in the mutation.
  4918. func (m *MessageMutation) Wxid() (r string, exists bool) {
  4919. v := m.wxid
  4920. if v == nil {
  4921. return
  4922. }
  4923. return *v, true
  4924. }
  4925. // OldWxid returns the old "wxid" field's value of the Message entity.
  4926. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  4927. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4928. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  4929. if !m.op.Is(OpUpdateOne) {
  4930. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  4931. }
  4932. if m.id == nil || m.oldValue == nil {
  4933. return v, errors.New("OldWxid requires an ID field in the mutation")
  4934. }
  4935. oldValue, err := m.oldValue(ctx)
  4936. if err != nil {
  4937. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  4938. }
  4939. return oldValue.Wxid, nil
  4940. }
  4941. // ResetWxid resets all changes to the "wxid" field.
  4942. func (m *MessageMutation) ResetWxid() {
  4943. m.wxid = nil
  4944. }
  4945. // SetContent sets the "content" field.
  4946. func (m *MessageMutation) SetContent(s string) {
  4947. m.content = &s
  4948. }
  4949. // Content returns the value of the "content" field in the mutation.
  4950. func (m *MessageMutation) Content() (r string, exists bool) {
  4951. v := m.content
  4952. if v == nil {
  4953. return
  4954. }
  4955. return *v, true
  4956. }
  4957. // OldContent returns the old "content" field's value of the Message entity.
  4958. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  4959. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4960. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  4961. if !m.op.Is(OpUpdateOne) {
  4962. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  4963. }
  4964. if m.id == nil || m.oldValue == nil {
  4965. return v, errors.New("OldContent requires an ID field in the mutation")
  4966. }
  4967. oldValue, err := m.oldValue(ctx)
  4968. if err != nil {
  4969. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  4970. }
  4971. return oldValue.Content, nil
  4972. }
  4973. // ResetContent resets all changes to the "content" field.
  4974. func (m *MessageMutation) ResetContent() {
  4975. m.content = nil
  4976. }
  4977. // Where appends a list predicates to the MessageMutation builder.
  4978. func (m *MessageMutation) Where(ps ...predicate.Message) {
  4979. m.predicates = append(m.predicates, ps...)
  4980. }
  4981. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  4982. // users can use type-assertion to append predicates that do not depend on any generated package.
  4983. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  4984. p := make([]predicate.Message, len(ps))
  4985. for i := range ps {
  4986. p[i] = ps[i]
  4987. }
  4988. m.Where(p...)
  4989. }
  4990. // Op returns the operation name.
  4991. func (m *MessageMutation) Op() Op {
  4992. return m.op
  4993. }
  4994. // SetOp allows setting the mutation operation.
  4995. func (m *MessageMutation) SetOp(op Op) {
  4996. m.op = op
  4997. }
  4998. // Type returns the node type of this mutation (Message).
  4999. func (m *MessageMutation) Type() string {
  5000. return m.typ
  5001. }
  5002. // Fields returns all fields that were changed during this mutation. Note that in
  5003. // order to get all numeric fields that were incremented/decremented, call
  5004. // AddedFields().
  5005. func (m *MessageMutation) Fields() []string {
  5006. fields := make([]string, 0, 3)
  5007. if m.wx_wxid != nil {
  5008. fields = append(fields, message.FieldWxWxid)
  5009. }
  5010. if m.wxid != nil {
  5011. fields = append(fields, message.FieldWxid)
  5012. }
  5013. if m.content != nil {
  5014. fields = append(fields, message.FieldContent)
  5015. }
  5016. return fields
  5017. }
  5018. // Field returns the value of a field with the given name. The second boolean
  5019. // return value indicates that this field was not set, or was not defined in the
  5020. // schema.
  5021. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  5022. switch name {
  5023. case message.FieldWxWxid:
  5024. return m.WxWxid()
  5025. case message.FieldWxid:
  5026. return m.Wxid()
  5027. case message.FieldContent:
  5028. return m.Content()
  5029. }
  5030. return nil, false
  5031. }
  5032. // OldField returns the old value of the field from the database. An error is
  5033. // returned if the mutation operation is not UpdateOne, or the query to the
  5034. // database failed.
  5035. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5036. switch name {
  5037. case message.FieldWxWxid:
  5038. return m.OldWxWxid(ctx)
  5039. case message.FieldWxid:
  5040. return m.OldWxid(ctx)
  5041. case message.FieldContent:
  5042. return m.OldContent(ctx)
  5043. }
  5044. return nil, fmt.Errorf("unknown Message field %s", name)
  5045. }
  5046. // SetField sets the value of a field with the given name. It returns an error if
  5047. // the field is not defined in the schema, or if the type mismatched the field
  5048. // type.
  5049. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  5050. switch name {
  5051. case message.FieldWxWxid:
  5052. v, ok := value.(string)
  5053. if !ok {
  5054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5055. }
  5056. m.SetWxWxid(v)
  5057. return nil
  5058. case message.FieldWxid:
  5059. v, ok := value.(string)
  5060. if !ok {
  5061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5062. }
  5063. m.SetWxid(v)
  5064. return nil
  5065. case message.FieldContent:
  5066. v, ok := value.(string)
  5067. if !ok {
  5068. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5069. }
  5070. m.SetContent(v)
  5071. return nil
  5072. }
  5073. return fmt.Errorf("unknown Message field %s", name)
  5074. }
  5075. // AddedFields returns all numeric fields that were incremented/decremented during
  5076. // this mutation.
  5077. func (m *MessageMutation) AddedFields() []string {
  5078. return nil
  5079. }
  5080. // AddedField returns the numeric value that was incremented/decremented on a field
  5081. // with the given name. The second boolean return value indicates that this field
  5082. // was not set, or was not defined in the schema.
  5083. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  5084. return nil, false
  5085. }
  5086. // AddField adds the value to the field with the given name. It returns an error if
  5087. // the field is not defined in the schema, or if the type mismatched the field
  5088. // type.
  5089. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  5090. switch name {
  5091. }
  5092. return fmt.Errorf("unknown Message numeric field %s", name)
  5093. }
  5094. // ClearedFields returns all nullable fields that were cleared during this
  5095. // mutation.
  5096. func (m *MessageMutation) ClearedFields() []string {
  5097. var fields []string
  5098. if m.FieldCleared(message.FieldWxWxid) {
  5099. fields = append(fields, message.FieldWxWxid)
  5100. }
  5101. return fields
  5102. }
  5103. // FieldCleared returns a boolean indicating if a field with the given name was
  5104. // cleared in this mutation.
  5105. func (m *MessageMutation) FieldCleared(name string) bool {
  5106. _, ok := m.clearedFields[name]
  5107. return ok
  5108. }
  5109. // ClearField clears the value of the field with the given name. It returns an
  5110. // error if the field is not defined in the schema.
  5111. func (m *MessageMutation) ClearField(name string) error {
  5112. switch name {
  5113. case message.FieldWxWxid:
  5114. m.ClearWxWxid()
  5115. return nil
  5116. }
  5117. return fmt.Errorf("unknown Message nullable field %s", name)
  5118. }
  5119. // ResetField resets all changes in the mutation for the field with the given name.
  5120. // It returns an error if the field is not defined in the schema.
  5121. func (m *MessageMutation) ResetField(name string) error {
  5122. switch name {
  5123. case message.FieldWxWxid:
  5124. m.ResetWxWxid()
  5125. return nil
  5126. case message.FieldWxid:
  5127. m.ResetWxid()
  5128. return nil
  5129. case message.FieldContent:
  5130. m.ResetContent()
  5131. return nil
  5132. }
  5133. return fmt.Errorf("unknown Message field %s", name)
  5134. }
  5135. // AddedEdges returns all edge names that were set/added in this mutation.
  5136. func (m *MessageMutation) AddedEdges() []string {
  5137. edges := make([]string, 0, 0)
  5138. return edges
  5139. }
  5140. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5141. // name in this mutation.
  5142. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  5143. return nil
  5144. }
  5145. // RemovedEdges returns all edge names that were removed in this mutation.
  5146. func (m *MessageMutation) RemovedEdges() []string {
  5147. edges := make([]string, 0, 0)
  5148. return edges
  5149. }
  5150. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5151. // the given name in this mutation.
  5152. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  5153. return nil
  5154. }
  5155. // ClearedEdges returns all edge names that were cleared in this mutation.
  5156. func (m *MessageMutation) ClearedEdges() []string {
  5157. edges := make([]string, 0, 0)
  5158. return edges
  5159. }
  5160. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5161. // was cleared in this mutation.
  5162. func (m *MessageMutation) EdgeCleared(name string) bool {
  5163. return false
  5164. }
  5165. // ClearEdge clears the value of the edge with the given name. It returns an error
  5166. // if that edge is not defined in the schema.
  5167. func (m *MessageMutation) ClearEdge(name string) error {
  5168. return fmt.Errorf("unknown Message unique edge %s", name)
  5169. }
  5170. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5171. // It returns an error if the edge is not defined in the schema.
  5172. func (m *MessageMutation) ResetEdge(name string) error {
  5173. return fmt.Errorf("unknown Message edge %s", name)
  5174. }
  5175. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  5176. type MessageRecordsMutation struct {
  5177. config
  5178. op Op
  5179. typ string
  5180. id *uint64
  5181. created_at *time.Time
  5182. updated_at *time.Time
  5183. status *uint8
  5184. addstatus *int8
  5185. deleted_at *time.Time
  5186. bot_wxid *string
  5187. contact_type *int
  5188. addcontact_type *int
  5189. contact_wxid *string
  5190. content_type *int
  5191. addcontent_type *int
  5192. content *string
  5193. meta *custom_types.Meta
  5194. error_detail *string
  5195. send_time *time.Time
  5196. source_type *int
  5197. addsource_type *int
  5198. organization_id *uint64
  5199. addorganization_id *int64
  5200. clearedFields map[string]struct{}
  5201. sop_stage *uint64
  5202. clearedsop_stage bool
  5203. sop_node *uint64
  5204. clearedsop_node bool
  5205. message_contact *uint64
  5206. clearedmessage_contact bool
  5207. done bool
  5208. oldValue func(context.Context) (*MessageRecords, error)
  5209. predicates []predicate.MessageRecords
  5210. }
  5211. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  5212. // messagerecordsOption allows management of the mutation configuration using functional options.
  5213. type messagerecordsOption func(*MessageRecordsMutation)
  5214. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  5215. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  5216. m := &MessageRecordsMutation{
  5217. config: c,
  5218. op: op,
  5219. typ: TypeMessageRecords,
  5220. clearedFields: make(map[string]struct{}),
  5221. }
  5222. for _, opt := range opts {
  5223. opt(m)
  5224. }
  5225. return m
  5226. }
  5227. // withMessageRecordsID sets the ID field of the mutation.
  5228. func withMessageRecordsID(id uint64) messagerecordsOption {
  5229. return func(m *MessageRecordsMutation) {
  5230. var (
  5231. err error
  5232. once sync.Once
  5233. value *MessageRecords
  5234. )
  5235. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  5236. once.Do(func() {
  5237. if m.done {
  5238. err = errors.New("querying old values post mutation is not allowed")
  5239. } else {
  5240. value, err = m.Client().MessageRecords.Get(ctx, id)
  5241. }
  5242. })
  5243. return value, err
  5244. }
  5245. m.id = &id
  5246. }
  5247. }
  5248. // withMessageRecords sets the old MessageRecords of the mutation.
  5249. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  5250. return func(m *MessageRecordsMutation) {
  5251. m.oldValue = func(context.Context) (*MessageRecords, error) {
  5252. return node, nil
  5253. }
  5254. m.id = &node.ID
  5255. }
  5256. }
  5257. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5258. // executed in a transaction (ent.Tx), a transactional client is returned.
  5259. func (m MessageRecordsMutation) Client() *Client {
  5260. client := &Client{config: m.config}
  5261. client.init()
  5262. return client
  5263. }
  5264. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5265. // it returns an error otherwise.
  5266. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  5267. if _, ok := m.driver.(*txDriver); !ok {
  5268. return nil, errors.New("ent: mutation is not running in a transaction")
  5269. }
  5270. tx := &Tx{config: m.config}
  5271. tx.init()
  5272. return tx, nil
  5273. }
  5274. // SetID sets the value of the id field. Note that this
  5275. // operation is only accepted on creation of MessageRecords entities.
  5276. func (m *MessageRecordsMutation) SetID(id uint64) {
  5277. m.id = &id
  5278. }
  5279. // ID returns the ID value in the mutation. Note that the ID is only available
  5280. // if it was provided to the builder or after it was returned from the database.
  5281. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  5282. if m.id == nil {
  5283. return
  5284. }
  5285. return *m.id, true
  5286. }
  5287. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5288. // That means, if the mutation is applied within a transaction with an isolation level such
  5289. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5290. // or updated by the mutation.
  5291. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  5292. switch {
  5293. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5294. id, exists := m.ID()
  5295. if exists {
  5296. return []uint64{id}, nil
  5297. }
  5298. fallthrough
  5299. case m.op.Is(OpUpdate | OpDelete):
  5300. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  5301. default:
  5302. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5303. }
  5304. }
  5305. // SetCreatedAt sets the "created_at" field.
  5306. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  5307. m.created_at = &t
  5308. }
  5309. // CreatedAt returns the value of the "created_at" field in the mutation.
  5310. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  5311. v := m.created_at
  5312. if v == nil {
  5313. return
  5314. }
  5315. return *v, true
  5316. }
  5317. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  5318. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5319. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5320. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5321. if !m.op.Is(OpUpdateOne) {
  5322. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5323. }
  5324. if m.id == nil || m.oldValue == nil {
  5325. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5326. }
  5327. oldValue, err := m.oldValue(ctx)
  5328. if err != nil {
  5329. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5330. }
  5331. return oldValue.CreatedAt, nil
  5332. }
  5333. // ResetCreatedAt resets all changes to the "created_at" field.
  5334. func (m *MessageRecordsMutation) ResetCreatedAt() {
  5335. m.created_at = nil
  5336. }
  5337. // SetUpdatedAt sets the "updated_at" field.
  5338. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  5339. m.updated_at = &t
  5340. }
  5341. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5342. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  5343. v := m.updated_at
  5344. if v == nil {
  5345. return
  5346. }
  5347. return *v, true
  5348. }
  5349. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  5350. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5352. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5353. if !m.op.Is(OpUpdateOne) {
  5354. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5355. }
  5356. if m.id == nil || m.oldValue == nil {
  5357. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5358. }
  5359. oldValue, err := m.oldValue(ctx)
  5360. if err != nil {
  5361. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5362. }
  5363. return oldValue.UpdatedAt, nil
  5364. }
  5365. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5366. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  5367. m.updated_at = nil
  5368. }
  5369. // SetStatus sets the "status" field.
  5370. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  5371. m.status = &u
  5372. m.addstatus = nil
  5373. }
  5374. // Status returns the value of the "status" field in the mutation.
  5375. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  5376. v := m.status
  5377. if v == nil {
  5378. return
  5379. }
  5380. return *v, true
  5381. }
  5382. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  5383. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5384. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5385. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  5386. if !m.op.Is(OpUpdateOne) {
  5387. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5388. }
  5389. if m.id == nil || m.oldValue == nil {
  5390. return v, errors.New("OldStatus requires an ID field in the mutation")
  5391. }
  5392. oldValue, err := m.oldValue(ctx)
  5393. if err != nil {
  5394. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5395. }
  5396. return oldValue.Status, nil
  5397. }
  5398. // AddStatus adds u to the "status" field.
  5399. func (m *MessageRecordsMutation) AddStatus(u int8) {
  5400. if m.addstatus != nil {
  5401. *m.addstatus += u
  5402. } else {
  5403. m.addstatus = &u
  5404. }
  5405. }
  5406. // AddedStatus returns the value that was added to the "status" field in this mutation.
  5407. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  5408. v := m.addstatus
  5409. if v == nil {
  5410. return
  5411. }
  5412. return *v, true
  5413. }
  5414. // ClearStatus clears the value of the "status" field.
  5415. func (m *MessageRecordsMutation) ClearStatus() {
  5416. m.status = nil
  5417. m.addstatus = nil
  5418. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  5419. }
  5420. // StatusCleared returns if the "status" field was cleared in this mutation.
  5421. func (m *MessageRecordsMutation) StatusCleared() bool {
  5422. _, ok := m.clearedFields[messagerecords.FieldStatus]
  5423. return ok
  5424. }
  5425. // ResetStatus resets all changes to the "status" field.
  5426. func (m *MessageRecordsMutation) ResetStatus() {
  5427. m.status = nil
  5428. m.addstatus = nil
  5429. delete(m.clearedFields, messagerecords.FieldStatus)
  5430. }
  5431. // SetDeletedAt sets the "deleted_at" field.
  5432. func (m *MessageRecordsMutation) SetDeletedAt(t time.Time) {
  5433. m.deleted_at = &t
  5434. }
  5435. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5436. func (m *MessageRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  5437. v := m.deleted_at
  5438. if v == nil {
  5439. return
  5440. }
  5441. return *v, true
  5442. }
  5443. // OldDeletedAt returns the old "deleted_at" field's value of the MessageRecords entity.
  5444. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5446. func (m *MessageRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5447. if !m.op.Is(OpUpdateOne) {
  5448. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5449. }
  5450. if m.id == nil || m.oldValue == nil {
  5451. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5452. }
  5453. oldValue, err := m.oldValue(ctx)
  5454. if err != nil {
  5455. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5456. }
  5457. return oldValue.DeletedAt, nil
  5458. }
  5459. // ClearDeletedAt clears the value of the "deleted_at" field.
  5460. func (m *MessageRecordsMutation) ClearDeletedAt() {
  5461. m.deleted_at = nil
  5462. m.clearedFields[messagerecords.FieldDeletedAt] = struct{}{}
  5463. }
  5464. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5465. func (m *MessageRecordsMutation) DeletedAtCleared() bool {
  5466. _, ok := m.clearedFields[messagerecords.FieldDeletedAt]
  5467. return ok
  5468. }
  5469. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5470. func (m *MessageRecordsMutation) ResetDeletedAt() {
  5471. m.deleted_at = nil
  5472. delete(m.clearedFields, messagerecords.FieldDeletedAt)
  5473. }
  5474. // SetBotWxid sets the "bot_wxid" field.
  5475. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  5476. m.bot_wxid = &s
  5477. }
  5478. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  5479. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  5480. v := m.bot_wxid
  5481. if v == nil {
  5482. return
  5483. }
  5484. return *v, true
  5485. }
  5486. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  5487. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5489. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  5490. if !m.op.Is(OpUpdateOne) {
  5491. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  5492. }
  5493. if m.id == nil || m.oldValue == nil {
  5494. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  5495. }
  5496. oldValue, err := m.oldValue(ctx)
  5497. if err != nil {
  5498. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  5499. }
  5500. return oldValue.BotWxid, nil
  5501. }
  5502. // ResetBotWxid resets all changes to the "bot_wxid" field.
  5503. func (m *MessageRecordsMutation) ResetBotWxid() {
  5504. m.bot_wxid = nil
  5505. }
  5506. // SetContactID sets the "contact_id" field.
  5507. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  5508. m.message_contact = &u
  5509. }
  5510. // ContactID returns the value of the "contact_id" field in the mutation.
  5511. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  5512. v := m.message_contact
  5513. if v == nil {
  5514. return
  5515. }
  5516. return *v, true
  5517. }
  5518. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  5519. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5521. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  5522. if !m.op.Is(OpUpdateOne) {
  5523. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  5524. }
  5525. if m.id == nil || m.oldValue == nil {
  5526. return v, errors.New("OldContactID requires an ID field in the mutation")
  5527. }
  5528. oldValue, err := m.oldValue(ctx)
  5529. if err != nil {
  5530. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  5531. }
  5532. return oldValue.ContactID, nil
  5533. }
  5534. // ClearContactID clears the value of the "contact_id" field.
  5535. func (m *MessageRecordsMutation) ClearContactID() {
  5536. m.message_contact = nil
  5537. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  5538. }
  5539. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  5540. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  5541. _, ok := m.clearedFields[messagerecords.FieldContactID]
  5542. return ok
  5543. }
  5544. // ResetContactID resets all changes to the "contact_id" field.
  5545. func (m *MessageRecordsMutation) ResetContactID() {
  5546. m.message_contact = nil
  5547. delete(m.clearedFields, messagerecords.FieldContactID)
  5548. }
  5549. // SetContactType sets the "contact_type" field.
  5550. func (m *MessageRecordsMutation) SetContactType(i int) {
  5551. m.contact_type = &i
  5552. m.addcontact_type = nil
  5553. }
  5554. // ContactType returns the value of the "contact_type" field in the mutation.
  5555. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  5556. v := m.contact_type
  5557. if v == nil {
  5558. return
  5559. }
  5560. return *v, true
  5561. }
  5562. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  5563. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5565. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  5566. if !m.op.Is(OpUpdateOne) {
  5567. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  5568. }
  5569. if m.id == nil || m.oldValue == nil {
  5570. return v, errors.New("OldContactType requires an ID field in the mutation")
  5571. }
  5572. oldValue, err := m.oldValue(ctx)
  5573. if err != nil {
  5574. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  5575. }
  5576. return oldValue.ContactType, nil
  5577. }
  5578. // AddContactType adds i to the "contact_type" field.
  5579. func (m *MessageRecordsMutation) AddContactType(i int) {
  5580. if m.addcontact_type != nil {
  5581. *m.addcontact_type += i
  5582. } else {
  5583. m.addcontact_type = &i
  5584. }
  5585. }
  5586. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  5587. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  5588. v := m.addcontact_type
  5589. if v == nil {
  5590. return
  5591. }
  5592. return *v, true
  5593. }
  5594. // ResetContactType resets all changes to the "contact_type" field.
  5595. func (m *MessageRecordsMutation) ResetContactType() {
  5596. m.contact_type = nil
  5597. m.addcontact_type = nil
  5598. }
  5599. // SetContactWxid sets the "contact_wxid" field.
  5600. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  5601. m.contact_wxid = &s
  5602. }
  5603. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  5604. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  5605. v := m.contact_wxid
  5606. if v == nil {
  5607. return
  5608. }
  5609. return *v, true
  5610. }
  5611. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  5612. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5613. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5614. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  5615. if !m.op.Is(OpUpdateOne) {
  5616. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  5617. }
  5618. if m.id == nil || m.oldValue == nil {
  5619. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  5620. }
  5621. oldValue, err := m.oldValue(ctx)
  5622. if err != nil {
  5623. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  5624. }
  5625. return oldValue.ContactWxid, nil
  5626. }
  5627. // ResetContactWxid resets all changes to the "contact_wxid" field.
  5628. func (m *MessageRecordsMutation) ResetContactWxid() {
  5629. m.contact_wxid = nil
  5630. }
  5631. // SetContentType sets the "content_type" field.
  5632. func (m *MessageRecordsMutation) SetContentType(i int) {
  5633. m.content_type = &i
  5634. m.addcontent_type = nil
  5635. }
  5636. // ContentType returns the value of the "content_type" field in the mutation.
  5637. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  5638. v := m.content_type
  5639. if v == nil {
  5640. return
  5641. }
  5642. return *v, true
  5643. }
  5644. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  5645. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5646. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5647. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  5648. if !m.op.Is(OpUpdateOne) {
  5649. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  5650. }
  5651. if m.id == nil || m.oldValue == nil {
  5652. return v, errors.New("OldContentType requires an ID field in the mutation")
  5653. }
  5654. oldValue, err := m.oldValue(ctx)
  5655. if err != nil {
  5656. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  5657. }
  5658. return oldValue.ContentType, nil
  5659. }
  5660. // AddContentType adds i to the "content_type" field.
  5661. func (m *MessageRecordsMutation) AddContentType(i int) {
  5662. if m.addcontent_type != nil {
  5663. *m.addcontent_type += i
  5664. } else {
  5665. m.addcontent_type = &i
  5666. }
  5667. }
  5668. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  5669. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  5670. v := m.addcontent_type
  5671. if v == nil {
  5672. return
  5673. }
  5674. return *v, true
  5675. }
  5676. // ResetContentType resets all changes to the "content_type" field.
  5677. func (m *MessageRecordsMutation) ResetContentType() {
  5678. m.content_type = nil
  5679. m.addcontent_type = nil
  5680. }
  5681. // SetContent sets the "content" field.
  5682. func (m *MessageRecordsMutation) SetContent(s string) {
  5683. m.content = &s
  5684. }
  5685. // Content returns the value of the "content" field in the mutation.
  5686. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  5687. v := m.content
  5688. if v == nil {
  5689. return
  5690. }
  5691. return *v, true
  5692. }
  5693. // OldContent returns the old "content" field's value of the MessageRecords entity.
  5694. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5695. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5696. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  5697. if !m.op.Is(OpUpdateOne) {
  5698. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  5699. }
  5700. if m.id == nil || m.oldValue == nil {
  5701. return v, errors.New("OldContent requires an ID field in the mutation")
  5702. }
  5703. oldValue, err := m.oldValue(ctx)
  5704. if err != nil {
  5705. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  5706. }
  5707. return oldValue.Content, nil
  5708. }
  5709. // ResetContent resets all changes to the "content" field.
  5710. func (m *MessageRecordsMutation) ResetContent() {
  5711. m.content = nil
  5712. }
  5713. // SetMeta sets the "meta" field.
  5714. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  5715. m.meta = &ct
  5716. }
  5717. // Meta returns the value of the "meta" field in the mutation.
  5718. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  5719. v := m.meta
  5720. if v == nil {
  5721. return
  5722. }
  5723. return *v, true
  5724. }
  5725. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  5726. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5727. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5728. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  5729. if !m.op.Is(OpUpdateOne) {
  5730. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  5731. }
  5732. if m.id == nil || m.oldValue == nil {
  5733. return v, errors.New("OldMeta requires an ID field in the mutation")
  5734. }
  5735. oldValue, err := m.oldValue(ctx)
  5736. if err != nil {
  5737. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  5738. }
  5739. return oldValue.Meta, nil
  5740. }
  5741. // ClearMeta clears the value of the "meta" field.
  5742. func (m *MessageRecordsMutation) ClearMeta() {
  5743. m.meta = nil
  5744. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  5745. }
  5746. // MetaCleared returns if the "meta" field was cleared in this mutation.
  5747. func (m *MessageRecordsMutation) MetaCleared() bool {
  5748. _, ok := m.clearedFields[messagerecords.FieldMeta]
  5749. return ok
  5750. }
  5751. // ResetMeta resets all changes to the "meta" field.
  5752. func (m *MessageRecordsMutation) ResetMeta() {
  5753. m.meta = nil
  5754. delete(m.clearedFields, messagerecords.FieldMeta)
  5755. }
  5756. // SetErrorDetail sets the "error_detail" field.
  5757. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  5758. m.error_detail = &s
  5759. }
  5760. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  5761. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  5762. v := m.error_detail
  5763. if v == nil {
  5764. return
  5765. }
  5766. return *v, true
  5767. }
  5768. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  5769. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5770. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5771. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  5772. if !m.op.Is(OpUpdateOne) {
  5773. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  5774. }
  5775. if m.id == nil || m.oldValue == nil {
  5776. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  5777. }
  5778. oldValue, err := m.oldValue(ctx)
  5779. if err != nil {
  5780. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  5781. }
  5782. return oldValue.ErrorDetail, nil
  5783. }
  5784. // ResetErrorDetail resets all changes to the "error_detail" field.
  5785. func (m *MessageRecordsMutation) ResetErrorDetail() {
  5786. m.error_detail = nil
  5787. }
  5788. // SetSendTime sets the "send_time" field.
  5789. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  5790. m.send_time = &t
  5791. }
  5792. // SendTime returns the value of the "send_time" field in the mutation.
  5793. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  5794. v := m.send_time
  5795. if v == nil {
  5796. return
  5797. }
  5798. return *v, true
  5799. }
  5800. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  5801. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5802. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5803. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  5804. if !m.op.Is(OpUpdateOne) {
  5805. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  5806. }
  5807. if m.id == nil || m.oldValue == nil {
  5808. return v, errors.New("OldSendTime requires an ID field in the mutation")
  5809. }
  5810. oldValue, err := m.oldValue(ctx)
  5811. if err != nil {
  5812. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  5813. }
  5814. return oldValue.SendTime, nil
  5815. }
  5816. // ClearSendTime clears the value of the "send_time" field.
  5817. func (m *MessageRecordsMutation) ClearSendTime() {
  5818. m.send_time = nil
  5819. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  5820. }
  5821. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  5822. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  5823. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  5824. return ok
  5825. }
  5826. // ResetSendTime resets all changes to the "send_time" field.
  5827. func (m *MessageRecordsMutation) ResetSendTime() {
  5828. m.send_time = nil
  5829. delete(m.clearedFields, messagerecords.FieldSendTime)
  5830. }
  5831. // SetSourceType sets the "source_type" field.
  5832. func (m *MessageRecordsMutation) SetSourceType(i int) {
  5833. m.source_type = &i
  5834. m.addsource_type = nil
  5835. }
  5836. // SourceType returns the value of the "source_type" field in the mutation.
  5837. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  5838. v := m.source_type
  5839. if v == nil {
  5840. return
  5841. }
  5842. return *v, true
  5843. }
  5844. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  5845. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5846. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5847. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  5848. if !m.op.Is(OpUpdateOne) {
  5849. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  5850. }
  5851. if m.id == nil || m.oldValue == nil {
  5852. return v, errors.New("OldSourceType requires an ID field in the mutation")
  5853. }
  5854. oldValue, err := m.oldValue(ctx)
  5855. if err != nil {
  5856. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  5857. }
  5858. return oldValue.SourceType, nil
  5859. }
  5860. // AddSourceType adds i to the "source_type" field.
  5861. func (m *MessageRecordsMutation) AddSourceType(i int) {
  5862. if m.addsource_type != nil {
  5863. *m.addsource_type += i
  5864. } else {
  5865. m.addsource_type = &i
  5866. }
  5867. }
  5868. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  5869. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  5870. v := m.addsource_type
  5871. if v == nil {
  5872. return
  5873. }
  5874. return *v, true
  5875. }
  5876. // ResetSourceType resets all changes to the "source_type" field.
  5877. func (m *MessageRecordsMutation) ResetSourceType() {
  5878. m.source_type = nil
  5879. m.addsource_type = nil
  5880. }
  5881. // SetSourceID sets the "source_id" field.
  5882. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  5883. m.sop_stage = &u
  5884. }
  5885. // SourceID returns the value of the "source_id" field in the mutation.
  5886. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  5887. v := m.sop_stage
  5888. if v == nil {
  5889. return
  5890. }
  5891. return *v, true
  5892. }
  5893. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  5894. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5895. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5896. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  5897. if !m.op.Is(OpUpdateOne) {
  5898. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  5899. }
  5900. if m.id == nil || m.oldValue == nil {
  5901. return v, errors.New("OldSourceID requires an ID field in the mutation")
  5902. }
  5903. oldValue, err := m.oldValue(ctx)
  5904. if err != nil {
  5905. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  5906. }
  5907. return oldValue.SourceID, nil
  5908. }
  5909. // ClearSourceID clears the value of the "source_id" field.
  5910. func (m *MessageRecordsMutation) ClearSourceID() {
  5911. m.sop_stage = nil
  5912. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  5913. }
  5914. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  5915. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  5916. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  5917. return ok
  5918. }
  5919. // ResetSourceID resets all changes to the "source_id" field.
  5920. func (m *MessageRecordsMutation) ResetSourceID() {
  5921. m.sop_stage = nil
  5922. delete(m.clearedFields, messagerecords.FieldSourceID)
  5923. }
  5924. // SetSubSourceID sets the "sub_source_id" field.
  5925. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  5926. m.sop_node = &u
  5927. }
  5928. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  5929. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  5930. v := m.sop_node
  5931. if v == nil {
  5932. return
  5933. }
  5934. return *v, true
  5935. }
  5936. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  5937. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5938. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5939. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  5940. if !m.op.Is(OpUpdateOne) {
  5941. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  5942. }
  5943. if m.id == nil || m.oldValue == nil {
  5944. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  5945. }
  5946. oldValue, err := m.oldValue(ctx)
  5947. if err != nil {
  5948. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  5949. }
  5950. return oldValue.SubSourceID, nil
  5951. }
  5952. // ClearSubSourceID clears the value of the "sub_source_id" field.
  5953. func (m *MessageRecordsMutation) ClearSubSourceID() {
  5954. m.sop_node = nil
  5955. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  5956. }
  5957. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  5958. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  5959. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  5960. return ok
  5961. }
  5962. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  5963. func (m *MessageRecordsMutation) ResetSubSourceID() {
  5964. m.sop_node = nil
  5965. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  5966. }
  5967. // SetOrganizationID sets the "organization_id" field.
  5968. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  5969. m.organization_id = &u
  5970. m.addorganization_id = nil
  5971. }
  5972. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5973. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  5974. v := m.organization_id
  5975. if v == nil {
  5976. return
  5977. }
  5978. return *v, true
  5979. }
  5980. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  5981. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5982. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5983. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5984. if !m.op.Is(OpUpdateOne) {
  5985. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5986. }
  5987. if m.id == nil || m.oldValue == nil {
  5988. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5989. }
  5990. oldValue, err := m.oldValue(ctx)
  5991. if err != nil {
  5992. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  5993. }
  5994. return oldValue.OrganizationID, nil
  5995. }
  5996. // AddOrganizationID adds u to the "organization_id" field.
  5997. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  5998. if m.addorganization_id != nil {
  5999. *m.addorganization_id += u
  6000. } else {
  6001. m.addorganization_id = &u
  6002. }
  6003. }
  6004. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6005. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  6006. v := m.addorganization_id
  6007. if v == nil {
  6008. return
  6009. }
  6010. return *v, true
  6011. }
  6012. // ClearOrganizationID clears the value of the "organization_id" field.
  6013. func (m *MessageRecordsMutation) ClearOrganizationID() {
  6014. m.organization_id = nil
  6015. m.addorganization_id = nil
  6016. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  6017. }
  6018. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  6019. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  6020. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  6021. return ok
  6022. }
  6023. // ResetOrganizationID resets all changes to the "organization_id" field.
  6024. func (m *MessageRecordsMutation) ResetOrganizationID() {
  6025. m.organization_id = nil
  6026. m.addorganization_id = nil
  6027. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  6028. }
  6029. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  6030. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  6031. m.sop_stage = &id
  6032. }
  6033. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  6034. func (m *MessageRecordsMutation) ClearSopStage() {
  6035. m.clearedsop_stage = true
  6036. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  6037. }
  6038. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  6039. func (m *MessageRecordsMutation) SopStageCleared() bool {
  6040. return m.SourceIDCleared() || m.clearedsop_stage
  6041. }
  6042. // SopStageID returns the "sop_stage" edge ID in the mutation.
  6043. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  6044. if m.sop_stage != nil {
  6045. return *m.sop_stage, true
  6046. }
  6047. return
  6048. }
  6049. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  6050. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  6051. // SopStageID instead. It exists only for internal usage by the builders.
  6052. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  6053. if id := m.sop_stage; id != nil {
  6054. ids = append(ids, *id)
  6055. }
  6056. return
  6057. }
  6058. // ResetSopStage resets all changes to the "sop_stage" edge.
  6059. func (m *MessageRecordsMutation) ResetSopStage() {
  6060. m.sop_stage = nil
  6061. m.clearedsop_stage = false
  6062. }
  6063. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  6064. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  6065. m.sop_node = &id
  6066. }
  6067. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  6068. func (m *MessageRecordsMutation) ClearSopNode() {
  6069. m.clearedsop_node = true
  6070. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  6071. }
  6072. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  6073. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  6074. return m.SubSourceIDCleared() || m.clearedsop_node
  6075. }
  6076. // SopNodeID returns the "sop_node" edge ID in the mutation.
  6077. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  6078. if m.sop_node != nil {
  6079. return *m.sop_node, true
  6080. }
  6081. return
  6082. }
  6083. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  6084. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  6085. // SopNodeID instead. It exists only for internal usage by the builders.
  6086. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  6087. if id := m.sop_node; id != nil {
  6088. ids = append(ids, *id)
  6089. }
  6090. return
  6091. }
  6092. // ResetSopNode resets all changes to the "sop_node" edge.
  6093. func (m *MessageRecordsMutation) ResetSopNode() {
  6094. m.sop_node = nil
  6095. m.clearedsop_node = false
  6096. }
  6097. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  6098. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  6099. m.message_contact = &id
  6100. }
  6101. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  6102. func (m *MessageRecordsMutation) ClearMessageContact() {
  6103. m.clearedmessage_contact = true
  6104. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  6105. }
  6106. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  6107. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  6108. return m.ContactIDCleared() || m.clearedmessage_contact
  6109. }
  6110. // MessageContactID returns the "message_contact" edge ID in the mutation.
  6111. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  6112. if m.message_contact != nil {
  6113. return *m.message_contact, true
  6114. }
  6115. return
  6116. }
  6117. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  6118. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  6119. // MessageContactID instead. It exists only for internal usage by the builders.
  6120. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  6121. if id := m.message_contact; id != nil {
  6122. ids = append(ids, *id)
  6123. }
  6124. return
  6125. }
  6126. // ResetMessageContact resets all changes to the "message_contact" edge.
  6127. func (m *MessageRecordsMutation) ResetMessageContact() {
  6128. m.message_contact = nil
  6129. m.clearedmessage_contact = false
  6130. }
  6131. // Where appends a list predicates to the MessageRecordsMutation builder.
  6132. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  6133. m.predicates = append(m.predicates, ps...)
  6134. }
  6135. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  6136. // users can use type-assertion to append predicates that do not depend on any generated package.
  6137. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  6138. p := make([]predicate.MessageRecords, len(ps))
  6139. for i := range ps {
  6140. p[i] = ps[i]
  6141. }
  6142. m.Where(p...)
  6143. }
  6144. // Op returns the operation name.
  6145. func (m *MessageRecordsMutation) Op() Op {
  6146. return m.op
  6147. }
  6148. // SetOp allows setting the mutation operation.
  6149. func (m *MessageRecordsMutation) SetOp(op Op) {
  6150. m.op = op
  6151. }
  6152. // Type returns the node type of this mutation (MessageRecords).
  6153. func (m *MessageRecordsMutation) Type() string {
  6154. return m.typ
  6155. }
  6156. // Fields returns all fields that were changed during this mutation. Note that in
  6157. // order to get all numeric fields that were incremented/decremented, call
  6158. // AddedFields().
  6159. func (m *MessageRecordsMutation) Fields() []string {
  6160. fields := make([]string, 0, 17)
  6161. if m.created_at != nil {
  6162. fields = append(fields, messagerecords.FieldCreatedAt)
  6163. }
  6164. if m.updated_at != nil {
  6165. fields = append(fields, messagerecords.FieldUpdatedAt)
  6166. }
  6167. if m.status != nil {
  6168. fields = append(fields, messagerecords.FieldStatus)
  6169. }
  6170. if m.deleted_at != nil {
  6171. fields = append(fields, messagerecords.FieldDeletedAt)
  6172. }
  6173. if m.bot_wxid != nil {
  6174. fields = append(fields, messagerecords.FieldBotWxid)
  6175. }
  6176. if m.message_contact != nil {
  6177. fields = append(fields, messagerecords.FieldContactID)
  6178. }
  6179. if m.contact_type != nil {
  6180. fields = append(fields, messagerecords.FieldContactType)
  6181. }
  6182. if m.contact_wxid != nil {
  6183. fields = append(fields, messagerecords.FieldContactWxid)
  6184. }
  6185. if m.content_type != nil {
  6186. fields = append(fields, messagerecords.FieldContentType)
  6187. }
  6188. if m.content != nil {
  6189. fields = append(fields, messagerecords.FieldContent)
  6190. }
  6191. if m.meta != nil {
  6192. fields = append(fields, messagerecords.FieldMeta)
  6193. }
  6194. if m.error_detail != nil {
  6195. fields = append(fields, messagerecords.FieldErrorDetail)
  6196. }
  6197. if m.send_time != nil {
  6198. fields = append(fields, messagerecords.FieldSendTime)
  6199. }
  6200. if m.source_type != nil {
  6201. fields = append(fields, messagerecords.FieldSourceType)
  6202. }
  6203. if m.sop_stage != nil {
  6204. fields = append(fields, messagerecords.FieldSourceID)
  6205. }
  6206. if m.sop_node != nil {
  6207. fields = append(fields, messagerecords.FieldSubSourceID)
  6208. }
  6209. if m.organization_id != nil {
  6210. fields = append(fields, messagerecords.FieldOrganizationID)
  6211. }
  6212. return fields
  6213. }
  6214. // Field returns the value of a field with the given name. The second boolean
  6215. // return value indicates that this field was not set, or was not defined in the
  6216. // schema.
  6217. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  6218. switch name {
  6219. case messagerecords.FieldCreatedAt:
  6220. return m.CreatedAt()
  6221. case messagerecords.FieldUpdatedAt:
  6222. return m.UpdatedAt()
  6223. case messagerecords.FieldStatus:
  6224. return m.Status()
  6225. case messagerecords.FieldDeletedAt:
  6226. return m.DeletedAt()
  6227. case messagerecords.FieldBotWxid:
  6228. return m.BotWxid()
  6229. case messagerecords.FieldContactID:
  6230. return m.ContactID()
  6231. case messagerecords.FieldContactType:
  6232. return m.ContactType()
  6233. case messagerecords.FieldContactWxid:
  6234. return m.ContactWxid()
  6235. case messagerecords.FieldContentType:
  6236. return m.ContentType()
  6237. case messagerecords.FieldContent:
  6238. return m.Content()
  6239. case messagerecords.FieldMeta:
  6240. return m.Meta()
  6241. case messagerecords.FieldErrorDetail:
  6242. return m.ErrorDetail()
  6243. case messagerecords.FieldSendTime:
  6244. return m.SendTime()
  6245. case messagerecords.FieldSourceType:
  6246. return m.SourceType()
  6247. case messagerecords.FieldSourceID:
  6248. return m.SourceID()
  6249. case messagerecords.FieldSubSourceID:
  6250. return m.SubSourceID()
  6251. case messagerecords.FieldOrganizationID:
  6252. return m.OrganizationID()
  6253. }
  6254. return nil, false
  6255. }
  6256. // OldField returns the old value of the field from the database. An error is
  6257. // returned if the mutation operation is not UpdateOne, or the query to the
  6258. // database failed.
  6259. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6260. switch name {
  6261. case messagerecords.FieldCreatedAt:
  6262. return m.OldCreatedAt(ctx)
  6263. case messagerecords.FieldUpdatedAt:
  6264. return m.OldUpdatedAt(ctx)
  6265. case messagerecords.FieldStatus:
  6266. return m.OldStatus(ctx)
  6267. case messagerecords.FieldDeletedAt:
  6268. return m.OldDeletedAt(ctx)
  6269. case messagerecords.FieldBotWxid:
  6270. return m.OldBotWxid(ctx)
  6271. case messagerecords.FieldContactID:
  6272. return m.OldContactID(ctx)
  6273. case messagerecords.FieldContactType:
  6274. return m.OldContactType(ctx)
  6275. case messagerecords.FieldContactWxid:
  6276. return m.OldContactWxid(ctx)
  6277. case messagerecords.FieldContentType:
  6278. return m.OldContentType(ctx)
  6279. case messagerecords.FieldContent:
  6280. return m.OldContent(ctx)
  6281. case messagerecords.FieldMeta:
  6282. return m.OldMeta(ctx)
  6283. case messagerecords.FieldErrorDetail:
  6284. return m.OldErrorDetail(ctx)
  6285. case messagerecords.FieldSendTime:
  6286. return m.OldSendTime(ctx)
  6287. case messagerecords.FieldSourceType:
  6288. return m.OldSourceType(ctx)
  6289. case messagerecords.FieldSourceID:
  6290. return m.OldSourceID(ctx)
  6291. case messagerecords.FieldSubSourceID:
  6292. return m.OldSubSourceID(ctx)
  6293. case messagerecords.FieldOrganizationID:
  6294. return m.OldOrganizationID(ctx)
  6295. }
  6296. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  6297. }
  6298. // SetField sets the value of a field with the given name. It returns an error if
  6299. // the field is not defined in the schema, or if the type mismatched the field
  6300. // type.
  6301. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  6302. switch name {
  6303. case messagerecords.FieldCreatedAt:
  6304. v, ok := value.(time.Time)
  6305. if !ok {
  6306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6307. }
  6308. m.SetCreatedAt(v)
  6309. return nil
  6310. case messagerecords.FieldUpdatedAt:
  6311. v, ok := value.(time.Time)
  6312. if !ok {
  6313. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6314. }
  6315. m.SetUpdatedAt(v)
  6316. return nil
  6317. case messagerecords.FieldStatus:
  6318. v, ok := value.(uint8)
  6319. if !ok {
  6320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6321. }
  6322. m.SetStatus(v)
  6323. return nil
  6324. case messagerecords.FieldDeletedAt:
  6325. v, ok := value.(time.Time)
  6326. if !ok {
  6327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6328. }
  6329. m.SetDeletedAt(v)
  6330. return nil
  6331. case messagerecords.FieldBotWxid:
  6332. v, ok := value.(string)
  6333. if !ok {
  6334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6335. }
  6336. m.SetBotWxid(v)
  6337. return nil
  6338. case messagerecords.FieldContactID:
  6339. v, ok := value.(uint64)
  6340. if !ok {
  6341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6342. }
  6343. m.SetContactID(v)
  6344. return nil
  6345. case messagerecords.FieldContactType:
  6346. v, ok := value.(int)
  6347. if !ok {
  6348. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6349. }
  6350. m.SetContactType(v)
  6351. return nil
  6352. case messagerecords.FieldContactWxid:
  6353. v, ok := value.(string)
  6354. if !ok {
  6355. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6356. }
  6357. m.SetContactWxid(v)
  6358. return nil
  6359. case messagerecords.FieldContentType:
  6360. v, ok := value.(int)
  6361. if !ok {
  6362. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6363. }
  6364. m.SetContentType(v)
  6365. return nil
  6366. case messagerecords.FieldContent:
  6367. v, ok := value.(string)
  6368. if !ok {
  6369. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6370. }
  6371. m.SetContent(v)
  6372. return nil
  6373. case messagerecords.FieldMeta:
  6374. v, ok := value.(custom_types.Meta)
  6375. if !ok {
  6376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6377. }
  6378. m.SetMeta(v)
  6379. return nil
  6380. case messagerecords.FieldErrorDetail:
  6381. v, ok := value.(string)
  6382. if !ok {
  6383. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6384. }
  6385. m.SetErrorDetail(v)
  6386. return nil
  6387. case messagerecords.FieldSendTime:
  6388. v, ok := value.(time.Time)
  6389. if !ok {
  6390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6391. }
  6392. m.SetSendTime(v)
  6393. return nil
  6394. case messagerecords.FieldSourceType:
  6395. v, ok := value.(int)
  6396. if !ok {
  6397. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6398. }
  6399. m.SetSourceType(v)
  6400. return nil
  6401. case messagerecords.FieldSourceID:
  6402. v, ok := value.(uint64)
  6403. if !ok {
  6404. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6405. }
  6406. m.SetSourceID(v)
  6407. return nil
  6408. case messagerecords.FieldSubSourceID:
  6409. v, ok := value.(uint64)
  6410. if !ok {
  6411. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6412. }
  6413. m.SetSubSourceID(v)
  6414. return nil
  6415. case messagerecords.FieldOrganizationID:
  6416. v, ok := value.(uint64)
  6417. if !ok {
  6418. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6419. }
  6420. m.SetOrganizationID(v)
  6421. return nil
  6422. }
  6423. return fmt.Errorf("unknown MessageRecords field %s", name)
  6424. }
  6425. // AddedFields returns all numeric fields that were incremented/decremented during
  6426. // this mutation.
  6427. func (m *MessageRecordsMutation) AddedFields() []string {
  6428. var fields []string
  6429. if m.addstatus != nil {
  6430. fields = append(fields, messagerecords.FieldStatus)
  6431. }
  6432. if m.addcontact_type != nil {
  6433. fields = append(fields, messagerecords.FieldContactType)
  6434. }
  6435. if m.addcontent_type != nil {
  6436. fields = append(fields, messagerecords.FieldContentType)
  6437. }
  6438. if m.addsource_type != nil {
  6439. fields = append(fields, messagerecords.FieldSourceType)
  6440. }
  6441. if m.addorganization_id != nil {
  6442. fields = append(fields, messagerecords.FieldOrganizationID)
  6443. }
  6444. return fields
  6445. }
  6446. // AddedField returns the numeric value that was incremented/decremented on a field
  6447. // with the given name. The second boolean return value indicates that this field
  6448. // was not set, or was not defined in the schema.
  6449. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  6450. switch name {
  6451. case messagerecords.FieldStatus:
  6452. return m.AddedStatus()
  6453. case messagerecords.FieldContactType:
  6454. return m.AddedContactType()
  6455. case messagerecords.FieldContentType:
  6456. return m.AddedContentType()
  6457. case messagerecords.FieldSourceType:
  6458. return m.AddedSourceType()
  6459. case messagerecords.FieldOrganizationID:
  6460. return m.AddedOrganizationID()
  6461. }
  6462. return nil, false
  6463. }
  6464. // AddField adds the value to the field with the given name. It returns an error if
  6465. // the field is not defined in the schema, or if the type mismatched the field
  6466. // type.
  6467. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  6468. switch name {
  6469. case messagerecords.FieldStatus:
  6470. v, ok := value.(int8)
  6471. if !ok {
  6472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6473. }
  6474. m.AddStatus(v)
  6475. return nil
  6476. case messagerecords.FieldContactType:
  6477. v, ok := value.(int)
  6478. if !ok {
  6479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6480. }
  6481. m.AddContactType(v)
  6482. return nil
  6483. case messagerecords.FieldContentType:
  6484. v, ok := value.(int)
  6485. if !ok {
  6486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6487. }
  6488. m.AddContentType(v)
  6489. return nil
  6490. case messagerecords.FieldSourceType:
  6491. v, ok := value.(int)
  6492. if !ok {
  6493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6494. }
  6495. m.AddSourceType(v)
  6496. return nil
  6497. case messagerecords.FieldOrganizationID:
  6498. v, ok := value.(int64)
  6499. if !ok {
  6500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6501. }
  6502. m.AddOrganizationID(v)
  6503. return nil
  6504. }
  6505. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  6506. }
  6507. // ClearedFields returns all nullable fields that were cleared during this
  6508. // mutation.
  6509. func (m *MessageRecordsMutation) ClearedFields() []string {
  6510. var fields []string
  6511. if m.FieldCleared(messagerecords.FieldStatus) {
  6512. fields = append(fields, messagerecords.FieldStatus)
  6513. }
  6514. if m.FieldCleared(messagerecords.FieldDeletedAt) {
  6515. fields = append(fields, messagerecords.FieldDeletedAt)
  6516. }
  6517. if m.FieldCleared(messagerecords.FieldContactID) {
  6518. fields = append(fields, messagerecords.FieldContactID)
  6519. }
  6520. if m.FieldCleared(messagerecords.FieldMeta) {
  6521. fields = append(fields, messagerecords.FieldMeta)
  6522. }
  6523. if m.FieldCleared(messagerecords.FieldSendTime) {
  6524. fields = append(fields, messagerecords.FieldSendTime)
  6525. }
  6526. if m.FieldCleared(messagerecords.FieldSourceID) {
  6527. fields = append(fields, messagerecords.FieldSourceID)
  6528. }
  6529. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  6530. fields = append(fields, messagerecords.FieldSubSourceID)
  6531. }
  6532. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  6533. fields = append(fields, messagerecords.FieldOrganizationID)
  6534. }
  6535. return fields
  6536. }
  6537. // FieldCleared returns a boolean indicating if a field with the given name was
  6538. // cleared in this mutation.
  6539. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  6540. _, ok := m.clearedFields[name]
  6541. return ok
  6542. }
  6543. // ClearField clears the value of the field with the given name. It returns an
  6544. // error if the field is not defined in the schema.
  6545. func (m *MessageRecordsMutation) ClearField(name string) error {
  6546. switch name {
  6547. case messagerecords.FieldStatus:
  6548. m.ClearStatus()
  6549. return nil
  6550. case messagerecords.FieldDeletedAt:
  6551. m.ClearDeletedAt()
  6552. return nil
  6553. case messagerecords.FieldContactID:
  6554. m.ClearContactID()
  6555. return nil
  6556. case messagerecords.FieldMeta:
  6557. m.ClearMeta()
  6558. return nil
  6559. case messagerecords.FieldSendTime:
  6560. m.ClearSendTime()
  6561. return nil
  6562. case messagerecords.FieldSourceID:
  6563. m.ClearSourceID()
  6564. return nil
  6565. case messagerecords.FieldSubSourceID:
  6566. m.ClearSubSourceID()
  6567. return nil
  6568. case messagerecords.FieldOrganizationID:
  6569. m.ClearOrganizationID()
  6570. return nil
  6571. }
  6572. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  6573. }
  6574. // ResetField resets all changes in the mutation for the field with the given name.
  6575. // It returns an error if the field is not defined in the schema.
  6576. func (m *MessageRecordsMutation) ResetField(name string) error {
  6577. switch name {
  6578. case messagerecords.FieldCreatedAt:
  6579. m.ResetCreatedAt()
  6580. return nil
  6581. case messagerecords.FieldUpdatedAt:
  6582. m.ResetUpdatedAt()
  6583. return nil
  6584. case messagerecords.FieldStatus:
  6585. m.ResetStatus()
  6586. return nil
  6587. case messagerecords.FieldDeletedAt:
  6588. m.ResetDeletedAt()
  6589. return nil
  6590. case messagerecords.FieldBotWxid:
  6591. m.ResetBotWxid()
  6592. return nil
  6593. case messagerecords.FieldContactID:
  6594. m.ResetContactID()
  6595. return nil
  6596. case messagerecords.FieldContactType:
  6597. m.ResetContactType()
  6598. return nil
  6599. case messagerecords.FieldContactWxid:
  6600. m.ResetContactWxid()
  6601. return nil
  6602. case messagerecords.FieldContentType:
  6603. m.ResetContentType()
  6604. return nil
  6605. case messagerecords.FieldContent:
  6606. m.ResetContent()
  6607. return nil
  6608. case messagerecords.FieldMeta:
  6609. m.ResetMeta()
  6610. return nil
  6611. case messagerecords.FieldErrorDetail:
  6612. m.ResetErrorDetail()
  6613. return nil
  6614. case messagerecords.FieldSendTime:
  6615. m.ResetSendTime()
  6616. return nil
  6617. case messagerecords.FieldSourceType:
  6618. m.ResetSourceType()
  6619. return nil
  6620. case messagerecords.FieldSourceID:
  6621. m.ResetSourceID()
  6622. return nil
  6623. case messagerecords.FieldSubSourceID:
  6624. m.ResetSubSourceID()
  6625. return nil
  6626. case messagerecords.FieldOrganizationID:
  6627. m.ResetOrganizationID()
  6628. return nil
  6629. }
  6630. return fmt.Errorf("unknown MessageRecords field %s", name)
  6631. }
  6632. // AddedEdges returns all edge names that were set/added in this mutation.
  6633. func (m *MessageRecordsMutation) AddedEdges() []string {
  6634. edges := make([]string, 0, 3)
  6635. if m.sop_stage != nil {
  6636. edges = append(edges, messagerecords.EdgeSopStage)
  6637. }
  6638. if m.sop_node != nil {
  6639. edges = append(edges, messagerecords.EdgeSopNode)
  6640. }
  6641. if m.message_contact != nil {
  6642. edges = append(edges, messagerecords.EdgeMessageContact)
  6643. }
  6644. return edges
  6645. }
  6646. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6647. // name in this mutation.
  6648. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  6649. switch name {
  6650. case messagerecords.EdgeSopStage:
  6651. if id := m.sop_stage; id != nil {
  6652. return []ent.Value{*id}
  6653. }
  6654. case messagerecords.EdgeSopNode:
  6655. if id := m.sop_node; id != nil {
  6656. return []ent.Value{*id}
  6657. }
  6658. case messagerecords.EdgeMessageContact:
  6659. if id := m.message_contact; id != nil {
  6660. return []ent.Value{*id}
  6661. }
  6662. }
  6663. return nil
  6664. }
  6665. // RemovedEdges returns all edge names that were removed in this mutation.
  6666. func (m *MessageRecordsMutation) RemovedEdges() []string {
  6667. edges := make([]string, 0, 3)
  6668. return edges
  6669. }
  6670. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6671. // the given name in this mutation.
  6672. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  6673. return nil
  6674. }
  6675. // ClearedEdges returns all edge names that were cleared in this mutation.
  6676. func (m *MessageRecordsMutation) ClearedEdges() []string {
  6677. edges := make([]string, 0, 3)
  6678. if m.clearedsop_stage {
  6679. edges = append(edges, messagerecords.EdgeSopStage)
  6680. }
  6681. if m.clearedsop_node {
  6682. edges = append(edges, messagerecords.EdgeSopNode)
  6683. }
  6684. if m.clearedmessage_contact {
  6685. edges = append(edges, messagerecords.EdgeMessageContact)
  6686. }
  6687. return edges
  6688. }
  6689. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6690. // was cleared in this mutation.
  6691. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  6692. switch name {
  6693. case messagerecords.EdgeSopStage:
  6694. return m.clearedsop_stage
  6695. case messagerecords.EdgeSopNode:
  6696. return m.clearedsop_node
  6697. case messagerecords.EdgeMessageContact:
  6698. return m.clearedmessage_contact
  6699. }
  6700. return false
  6701. }
  6702. // ClearEdge clears the value of the edge with the given name. It returns an error
  6703. // if that edge is not defined in the schema.
  6704. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  6705. switch name {
  6706. case messagerecords.EdgeSopStage:
  6707. m.ClearSopStage()
  6708. return nil
  6709. case messagerecords.EdgeSopNode:
  6710. m.ClearSopNode()
  6711. return nil
  6712. case messagerecords.EdgeMessageContact:
  6713. m.ClearMessageContact()
  6714. return nil
  6715. }
  6716. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  6717. }
  6718. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6719. // It returns an error if the edge is not defined in the schema.
  6720. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  6721. switch name {
  6722. case messagerecords.EdgeSopStage:
  6723. m.ResetSopStage()
  6724. return nil
  6725. case messagerecords.EdgeSopNode:
  6726. m.ResetSopNode()
  6727. return nil
  6728. case messagerecords.EdgeMessageContact:
  6729. m.ResetMessageContact()
  6730. return nil
  6731. }
  6732. return fmt.Errorf("unknown MessageRecords edge %s", name)
  6733. }
  6734. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  6735. type MsgMutation struct {
  6736. config
  6737. op Op
  6738. typ string
  6739. id *uint64
  6740. created_at *time.Time
  6741. updated_at *time.Time
  6742. deleted_at *time.Time
  6743. status *uint8
  6744. addstatus *int8
  6745. fromwxid *string
  6746. toid *string
  6747. msgtype *int32
  6748. addmsgtype *int32
  6749. msg *string
  6750. batch_no *string
  6751. clearedFields map[string]struct{}
  6752. done bool
  6753. oldValue func(context.Context) (*Msg, error)
  6754. predicates []predicate.Msg
  6755. }
  6756. var _ ent.Mutation = (*MsgMutation)(nil)
  6757. // msgOption allows management of the mutation configuration using functional options.
  6758. type msgOption func(*MsgMutation)
  6759. // newMsgMutation creates new mutation for the Msg entity.
  6760. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  6761. m := &MsgMutation{
  6762. config: c,
  6763. op: op,
  6764. typ: TypeMsg,
  6765. clearedFields: make(map[string]struct{}),
  6766. }
  6767. for _, opt := range opts {
  6768. opt(m)
  6769. }
  6770. return m
  6771. }
  6772. // withMsgID sets the ID field of the mutation.
  6773. func withMsgID(id uint64) msgOption {
  6774. return func(m *MsgMutation) {
  6775. var (
  6776. err error
  6777. once sync.Once
  6778. value *Msg
  6779. )
  6780. m.oldValue = func(ctx context.Context) (*Msg, error) {
  6781. once.Do(func() {
  6782. if m.done {
  6783. err = errors.New("querying old values post mutation is not allowed")
  6784. } else {
  6785. value, err = m.Client().Msg.Get(ctx, id)
  6786. }
  6787. })
  6788. return value, err
  6789. }
  6790. m.id = &id
  6791. }
  6792. }
  6793. // withMsg sets the old Msg of the mutation.
  6794. func withMsg(node *Msg) msgOption {
  6795. return func(m *MsgMutation) {
  6796. m.oldValue = func(context.Context) (*Msg, error) {
  6797. return node, nil
  6798. }
  6799. m.id = &node.ID
  6800. }
  6801. }
  6802. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6803. // executed in a transaction (ent.Tx), a transactional client is returned.
  6804. func (m MsgMutation) Client() *Client {
  6805. client := &Client{config: m.config}
  6806. client.init()
  6807. return client
  6808. }
  6809. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6810. // it returns an error otherwise.
  6811. func (m MsgMutation) Tx() (*Tx, error) {
  6812. if _, ok := m.driver.(*txDriver); !ok {
  6813. return nil, errors.New("ent: mutation is not running in a transaction")
  6814. }
  6815. tx := &Tx{config: m.config}
  6816. tx.init()
  6817. return tx, nil
  6818. }
  6819. // SetID sets the value of the id field. Note that this
  6820. // operation is only accepted on creation of Msg entities.
  6821. func (m *MsgMutation) SetID(id uint64) {
  6822. m.id = &id
  6823. }
  6824. // ID returns the ID value in the mutation. Note that the ID is only available
  6825. // if it was provided to the builder or after it was returned from the database.
  6826. func (m *MsgMutation) ID() (id uint64, exists bool) {
  6827. if m.id == nil {
  6828. return
  6829. }
  6830. return *m.id, true
  6831. }
  6832. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6833. // That means, if the mutation is applied within a transaction with an isolation level such
  6834. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6835. // or updated by the mutation.
  6836. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  6837. switch {
  6838. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6839. id, exists := m.ID()
  6840. if exists {
  6841. return []uint64{id}, nil
  6842. }
  6843. fallthrough
  6844. case m.op.Is(OpUpdate | OpDelete):
  6845. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  6846. default:
  6847. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6848. }
  6849. }
  6850. // SetCreatedAt sets the "created_at" field.
  6851. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  6852. m.created_at = &t
  6853. }
  6854. // CreatedAt returns the value of the "created_at" field in the mutation.
  6855. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  6856. v := m.created_at
  6857. if v == nil {
  6858. return
  6859. }
  6860. return *v, true
  6861. }
  6862. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  6863. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  6864. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6865. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6866. if !m.op.Is(OpUpdateOne) {
  6867. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6868. }
  6869. if m.id == nil || m.oldValue == nil {
  6870. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6871. }
  6872. oldValue, err := m.oldValue(ctx)
  6873. if err != nil {
  6874. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6875. }
  6876. return oldValue.CreatedAt, nil
  6877. }
  6878. // ResetCreatedAt resets all changes to the "created_at" field.
  6879. func (m *MsgMutation) ResetCreatedAt() {
  6880. m.created_at = nil
  6881. }
  6882. // SetUpdatedAt sets the "updated_at" field.
  6883. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  6884. m.updated_at = &t
  6885. }
  6886. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6887. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  6888. v := m.updated_at
  6889. if v == nil {
  6890. return
  6891. }
  6892. return *v, true
  6893. }
  6894. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  6895. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  6896. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6897. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6898. if !m.op.Is(OpUpdateOne) {
  6899. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6900. }
  6901. if m.id == nil || m.oldValue == nil {
  6902. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6903. }
  6904. oldValue, err := m.oldValue(ctx)
  6905. if err != nil {
  6906. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6907. }
  6908. return oldValue.UpdatedAt, nil
  6909. }
  6910. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6911. func (m *MsgMutation) ResetUpdatedAt() {
  6912. m.updated_at = nil
  6913. }
  6914. // SetDeletedAt sets the "deleted_at" field.
  6915. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  6916. m.deleted_at = &t
  6917. }
  6918. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6919. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  6920. v := m.deleted_at
  6921. if v == nil {
  6922. return
  6923. }
  6924. return *v, true
  6925. }
  6926. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  6927. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  6928. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6929. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6930. if !m.op.Is(OpUpdateOne) {
  6931. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6932. }
  6933. if m.id == nil || m.oldValue == nil {
  6934. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6935. }
  6936. oldValue, err := m.oldValue(ctx)
  6937. if err != nil {
  6938. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6939. }
  6940. return oldValue.DeletedAt, nil
  6941. }
  6942. // ClearDeletedAt clears the value of the "deleted_at" field.
  6943. func (m *MsgMutation) ClearDeletedAt() {
  6944. m.deleted_at = nil
  6945. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  6946. }
  6947. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6948. func (m *MsgMutation) DeletedAtCleared() bool {
  6949. _, ok := m.clearedFields[msg.FieldDeletedAt]
  6950. return ok
  6951. }
  6952. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6953. func (m *MsgMutation) ResetDeletedAt() {
  6954. m.deleted_at = nil
  6955. delete(m.clearedFields, msg.FieldDeletedAt)
  6956. }
  6957. // SetStatus sets the "status" field.
  6958. func (m *MsgMutation) SetStatus(u uint8) {
  6959. m.status = &u
  6960. m.addstatus = nil
  6961. }
  6962. // Status returns the value of the "status" field in the mutation.
  6963. func (m *MsgMutation) Status() (r uint8, exists bool) {
  6964. v := m.status
  6965. if v == nil {
  6966. return
  6967. }
  6968. return *v, true
  6969. }
  6970. // OldStatus returns the old "status" field's value of the Msg entity.
  6971. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  6972. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6973. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  6974. if !m.op.Is(OpUpdateOne) {
  6975. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  6976. }
  6977. if m.id == nil || m.oldValue == nil {
  6978. return v, errors.New("OldStatus requires an ID field in the mutation")
  6979. }
  6980. oldValue, err := m.oldValue(ctx)
  6981. if err != nil {
  6982. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  6983. }
  6984. return oldValue.Status, nil
  6985. }
  6986. // AddStatus adds u to the "status" field.
  6987. func (m *MsgMutation) AddStatus(u int8) {
  6988. if m.addstatus != nil {
  6989. *m.addstatus += u
  6990. } else {
  6991. m.addstatus = &u
  6992. }
  6993. }
  6994. // AddedStatus returns the value that was added to the "status" field in this mutation.
  6995. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  6996. v := m.addstatus
  6997. if v == nil {
  6998. return
  6999. }
  7000. return *v, true
  7001. }
  7002. // ClearStatus clears the value of the "status" field.
  7003. func (m *MsgMutation) ClearStatus() {
  7004. m.status = nil
  7005. m.addstatus = nil
  7006. m.clearedFields[msg.FieldStatus] = struct{}{}
  7007. }
  7008. // StatusCleared returns if the "status" field was cleared in this mutation.
  7009. func (m *MsgMutation) StatusCleared() bool {
  7010. _, ok := m.clearedFields[msg.FieldStatus]
  7011. return ok
  7012. }
  7013. // ResetStatus resets all changes to the "status" field.
  7014. func (m *MsgMutation) ResetStatus() {
  7015. m.status = nil
  7016. m.addstatus = nil
  7017. delete(m.clearedFields, msg.FieldStatus)
  7018. }
  7019. // SetFromwxid sets the "fromwxid" field.
  7020. func (m *MsgMutation) SetFromwxid(s string) {
  7021. m.fromwxid = &s
  7022. }
  7023. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  7024. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  7025. v := m.fromwxid
  7026. if v == nil {
  7027. return
  7028. }
  7029. return *v, true
  7030. }
  7031. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  7032. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  7033. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7034. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  7035. if !m.op.Is(OpUpdateOne) {
  7036. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  7037. }
  7038. if m.id == nil || m.oldValue == nil {
  7039. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  7040. }
  7041. oldValue, err := m.oldValue(ctx)
  7042. if err != nil {
  7043. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  7044. }
  7045. return oldValue.Fromwxid, nil
  7046. }
  7047. // ClearFromwxid clears the value of the "fromwxid" field.
  7048. func (m *MsgMutation) ClearFromwxid() {
  7049. m.fromwxid = nil
  7050. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  7051. }
  7052. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  7053. func (m *MsgMutation) FromwxidCleared() bool {
  7054. _, ok := m.clearedFields[msg.FieldFromwxid]
  7055. return ok
  7056. }
  7057. // ResetFromwxid resets all changes to the "fromwxid" field.
  7058. func (m *MsgMutation) ResetFromwxid() {
  7059. m.fromwxid = nil
  7060. delete(m.clearedFields, msg.FieldFromwxid)
  7061. }
  7062. // SetToid sets the "toid" field.
  7063. func (m *MsgMutation) SetToid(s string) {
  7064. m.toid = &s
  7065. }
  7066. // Toid returns the value of the "toid" field in the mutation.
  7067. func (m *MsgMutation) Toid() (r string, exists bool) {
  7068. v := m.toid
  7069. if v == nil {
  7070. return
  7071. }
  7072. return *v, true
  7073. }
  7074. // OldToid returns the old "toid" field's value of the Msg entity.
  7075. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  7076. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7077. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  7078. if !m.op.Is(OpUpdateOne) {
  7079. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  7080. }
  7081. if m.id == nil || m.oldValue == nil {
  7082. return v, errors.New("OldToid requires an ID field in the mutation")
  7083. }
  7084. oldValue, err := m.oldValue(ctx)
  7085. if err != nil {
  7086. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  7087. }
  7088. return oldValue.Toid, nil
  7089. }
  7090. // ClearToid clears the value of the "toid" field.
  7091. func (m *MsgMutation) ClearToid() {
  7092. m.toid = nil
  7093. m.clearedFields[msg.FieldToid] = struct{}{}
  7094. }
  7095. // ToidCleared returns if the "toid" field was cleared in this mutation.
  7096. func (m *MsgMutation) ToidCleared() bool {
  7097. _, ok := m.clearedFields[msg.FieldToid]
  7098. return ok
  7099. }
  7100. // ResetToid resets all changes to the "toid" field.
  7101. func (m *MsgMutation) ResetToid() {
  7102. m.toid = nil
  7103. delete(m.clearedFields, msg.FieldToid)
  7104. }
  7105. // SetMsgtype sets the "msgtype" field.
  7106. func (m *MsgMutation) SetMsgtype(i int32) {
  7107. m.msgtype = &i
  7108. m.addmsgtype = nil
  7109. }
  7110. // Msgtype returns the value of the "msgtype" field in the mutation.
  7111. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  7112. v := m.msgtype
  7113. if v == nil {
  7114. return
  7115. }
  7116. return *v, true
  7117. }
  7118. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  7119. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  7120. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7121. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  7122. if !m.op.Is(OpUpdateOne) {
  7123. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  7124. }
  7125. if m.id == nil || m.oldValue == nil {
  7126. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  7127. }
  7128. oldValue, err := m.oldValue(ctx)
  7129. if err != nil {
  7130. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  7131. }
  7132. return oldValue.Msgtype, nil
  7133. }
  7134. // AddMsgtype adds i to the "msgtype" field.
  7135. func (m *MsgMutation) AddMsgtype(i int32) {
  7136. if m.addmsgtype != nil {
  7137. *m.addmsgtype += i
  7138. } else {
  7139. m.addmsgtype = &i
  7140. }
  7141. }
  7142. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  7143. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  7144. v := m.addmsgtype
  7145. if v == nil {
  7146. return
  7147. }
  7148. return *v, true
  7149. }
  7150. // ClearMsgtype clears the value of the "msgtype" field.
  7151. func (m *MsgMutation) ClearMsgtype() {
  7152. m.msgtype = nil
  7153. m.addmsgtype = nil
  7154. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  7155. }
  7156. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  7157. func (m *MsgMutation) MsgtypeCleared() bool {
  7158. _, ok := m.clearedFields[msg.FieldMsgtype]
  7159. return ok
  7160. }
  7161. // ResetMsgtype resets all changes to the "msgtype" field.
  7162. func (m *MsgMutation) ResetMsgtype() {
  7163. m.msgtype = nil
  7164. m.addmsgtype = nil
  7165. delete(m.clearedFields, msg.FieldMsgtype)
  7166. }
  7167. // SetMsg sets the "msg" field.
  7168. func (m *MsgMutation) SetMsg(s string) {
  7169. m.msg = &s
  7170. }
  7171. // Msg returns the value of the "msg" field in the mutation.
  7172. func (m *MsgMutation) Msg() (r string, exists bool) {
  7173. v := m.msg
  7174. if v == nil {
  7175. return
  7176. }
  7177. return *v, true
  7178. }
  7179. // OldMsg returns the old "msg" field's value of the Msg entity.
  7180. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  7181. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7182. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  7183. if !m.op.Is(OpUpdateOne) {
  7184. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  7185. }
  7186. if m.id == nil || m.oldValue == nil {
  7187. return v, errors.New("OldMsg requires an ID field in the mutation")
  7188. }
  7189. oldValue, err := m.oldValue(ctx)
  7190. if err != nil {
  7191. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  7192. }
  7193. return oldValue.Msg, nil
  7194. }
  7195. // ClearMsg clears the value of the "msg" field.
  7196. func (m *MsgMutation) ClearMsg() {
  7197. m.msg = nil
  7198. m.clearedFields[msg.FieldMsg] = struct{}{}
  7199. }
  7200. // MsgCleared returns if the "msg" field was cleared in this mutation.
  7201. func (m *MsgMutation) MsgCleared() bool {
  7202. _, ok := m.clearedFields[msg.FieldMsg]
  7203. return ok
  7204. }
  7205. // ResetMsg resets all changes to the "msg" field.
  7206. func (m *MsgMutation) ResetMsg() {
  7207. m.msg = nil
  7208. delete(m.clearedFields, msg.FieldMsg)
  7209. }
  7210. // SetBatchNo sets the "batch_no" field.
  7211. func (m *MsgMutation) SetBatchNo(s string) {
  7212. m.batch_no = &s
  7213. }
  7214. // BatchNo returns the value of the "batch_no" field in the mutation.
  7215. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  7216. v := m.batch_no
  7217. if v == nil {
  7218. return
  7219. }
  7220. return *v, true
  7221. }
  7222. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  7223. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  7224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7225. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  7226. if !m.op.Is(OpUpdateOne) {
  7227. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  7228. }
  7229. if m.id == nil || m.oldValue == nil {
  7230. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  7231. }
  7232. oldValue, err := m.oldValue(ctx)
  7233. if err != nil {
  7234. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  7235. }
  7236. return oldValue.BatchNo, nil
  7237. }
  7238. // ClearBatchNo clears the value of the "batch_no" field.
  7239. func (m *MsgMutation) ClearBatchNo() {
  7240. m.batch_no = nil
  7241. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  7242. }
  7243. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  7244. func (m *MsgMutation) BatchNoCleared() bool {
  7245. _, ok := m.clearedFields[msg.FieldBatchNo]
  7246. return ok
  7247. }
  7248. // ResetBatchNo resets all changes to the "batch_no" field.
  7249. func (m *MsgMutation) ResetBatchNo() {
  7250. m.batch_no = nil
  7251. delete(m.clearedFields, msg.FieldBatchNo)
  7252. }
  7253. // Where appends a list predicates to the MsgMutation builder.
  7254. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  7255. m.predicates = append(m.predicates, ps...)
  7256. }
  7257. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  7258. // users can use type-assertion to append predicates that do not depend on any generated package.
  7259. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  7260. p := make([]predicate.Msg, len(ps))
  7261. for i := range ps {
  7262. p[i] = ps[i]
  7263. }
  7264. m.Where(p...)
  7265. }
  7266. // Op returns the operation name.
  7267. func (m *MsgMutation) Op() Op {
  7268. return m.op
  7269. }
  7270. // SetOp allows setting the mutation operation.
  7271. func (m *MsgMutation) SetOp(op Op) {
  7272. m.op = op
  7273. }
  7274. // Type returns the node type of this mutation (Msg).
  7275. func (m *MsgMutation) Type() string {
  7276. return m.typ
  7277. }
  7278. // Fields returns all fields that were changed during this mutation. Note that in
  7279. // order to get all numeric fields that were incremented/decremented, call
  7280. // AddedFields().
  7281. func (m *MsgMutation) Fields() []string {
  7282. fields := make([]string, 0, 9)
  7283. if m.created_at != nil {
  7284. fields = append(fields, msg.FieldCreatedAt)
  7285. }
  7286. if m.updated_at != nil {
  7287. fields = append(fields, msg.FieldUpdatedAt)
  7288. }
  7289. if m.deleted_at != nil {
  7290. fields = append(fields, msg.FieldDeletedAt)
  7291. }
  7292. if m.status != nil {
  7293. fields = append(fields, msg.FieldStatus)
  7294. }
  7295. if m.fromwxid != nil {
  7296. fields = append(fields, msg.FieldFromwxid)
  7297. }
  7298. if m.toid != nil {
  7299. fields = append(fields, msg.FieldToid)
  7300. }
  7301. if m.msgtype != nil {
  7302. fields = append(fields, msg.FieldMsgtype)
  7303. }
  7304. if m.msg != nil {
  7305. fields = append(fields, msg.FieldMsg)
  7306. }
  7307. if m.batch_no != nil {
  7308. fields = append(fields, msg.FieldBatchNo)
  7309. }
  7310. return fields
  7311. }
  7312. // Field returns the value of a field with the given name. The second boolean
  7313. // return value indicates that this field was not set, or was not defined in the
  7314. // schema.
  7315. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  7316. switch name {
  7317. case msg.FieldCreatedAt:
  7318. return m.CreatedAt()
  7319. case msg.FieldUpdatedAt:
  7320. return m.UpdatedAt()
  7321. case msg.FieldDeletedAt:
  7322. return m.DeletedAt()
  7323. case msg.FieldStatus:
  7324. return m.Status()
  7325. case msg.FieldFromwxid:
  7326. return m.Fromwxid()
  7327. case msg.FieldToid:
  7328. return m.Toid()
  7329. case msg.FieldMsgtype:
  7330. return m.Msgtype()
  7331. case msg.FieldMsg:
  7332. return m.Msg()
  7333. case msg.FieldBatchNo:
  7334. return m.BatchNo()
  7335. }
  7336. return nil, false
  7337. }
  7338. // OldField returns the old value of the field from the database. An error is
  7339. // returned if the mutation operation is not UpdateOne, or the query to the
  7340. // database failed.
  7341. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7342. switch name {
  7343. case msg.FieldCreatedAt:
  7344. return m.OldCreatedAt(ctx)
  7345. case msg.FieldUpdatedAt:
  7346. return m.OldUpdatedAt(ctx)
  7347. case msg.FieldDeletedAt:
  7348. return m.OldDeletedAt(ctx)
  7349. case msg.FieldStatus:
  7350. return m.OldStatus(ctx)
  7351. case msg.FieldFromwxid:
  7352. return m.OldFromwxid(ctx)
  7353. case msg.FieldToid:
  7354. return m.OldToid(ctx)
  7355. case msg.FieldMsgtype:
  7356. return m.OldMsgtype(ctx)
  7357. case msg.FieldMsg:
  7358. return m.OldMsg(ctx)
  7359. case msg.FieldBatchNo:
  7360. return m.OldBatchNo(ctx)
  7361. }
  7362. return nil, fmt.Errorf("unknown Msg field %s", name)
  7363. }
  7364. // SetField sets the value of a field with the given name. It returns an error if
  7365. // the field is not defined in the schema, or if the type mismatched the field
  7366. // type.
  7367. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  7368. switch name {
  7369. case msg.FieldCreatedAt:
  7370. v, ok := value.(time.Time)
  7371. if !ok {
  7372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7373. }
  7374. m.SetCreatedAt(v)
  7375. return nil
  7376. case msg.FieldUpdatedAt:
  7377. v, ok := value.(time.Time)
  7378. if !ok {
  7379. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7380. }
  7381. m.SetUpdatedAt(v)
  7382. return nil
  7383. case msg.FieldDeletedAt:
  7384. v, ok := value.(time.Time)
  7385. if !ok {
  7386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7387. }
  7388. m.SetDeletedAt(v)
  7389. return nil
  7390. case msg.FieldStatus:
  7391. v, ok := value.(uint8)
  7392. if !ok {
  7393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7394. }
  7395. m.SetStatus(v)
  7396. return nil
  7397. case msg.FieldFromwxid:
  7398. v, ok := value.(string)
  7399. if !ok {
  7400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7401. }
  7402. m.SetFromwxid(v)
  7403. return nil
  7404. case msg.FieldToid:
  7405. v, ok := value.(string)
  7406. if !ok {
  7407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7408. }
  7409. m.SetToid(v)
  7410. return nil
  7411. case msg.FieldMsgtype:
  7412. v, ok := value.(int32)
  7413. if !ok {
  7414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7415. }
  7416. m.SetMsgtype(v)
  7417. return nil
  7418. case msg.FieldMsg:
  7419. v, ok := value.(string)
  7420. if !ok {
  7421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7422. }
  7423. m.SetMsg(v)
  7424. return nil
  7425. case msg.FieldBatchNo:
  7426. v, ok := value.(string)
  7427. if !ok {
  7428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7429. }
  7430. m.SetBatchNo(v)
  7431. return nil
  7432. }
  7433. return fmt.Errorf("unknown Msg field %s", name)
  7434. }
  7435. // AddedFields returns all numeric fields that were incremented/decremented during
  7436. // this mutation.
  7437. func (m *MsgMutation) AddedFields() []string {
  7438. var fields []string
  7439. if m.addstatus != nil {
  7440. fields = append(fields, msg.FieldStatus)
  7441. }
  7442. if m.addmsgtype != nil {
  7443. fields = append(fields, msg.FieldMsgtype)
  7444. }
  7445. return fields
  7446. }
  7447. // AddedField returns the numeric value that was incremented/decremented on a field
  7448. // with the given name. The second boolean return value indicates that this field
  7449. // was not set, or was not defined in the schema.
  7450. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  7451. switch name {
  7452. case msg.FieldStatus:
  7453. return m.AddedStatus()
  7454. case msg.FieldMsgtype:
  7455. return m.AddedMsgtype()
  7456. }
  7457. return nil, false
  7458. }
  7459. // AddField adds the value to the field with the given name. It returns an error if
  7460. // the field is not defined in the schema, or if the type mismatched the field
  7461. // type.
  7462. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  7463. switch name {
  7464. case msg.FieldStatus:
  7465. v, ok := value.(int8)
  7466. if !ok {
  7467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7468. }
  7469. m.AddStatus(v)
  7470. return nil
  7471. case msg.FieldMsgtype:
  7472. v, ok := value.(int32)
  7473. if !ok {
  7474. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7475. }
  7476. m.AddMsgtype(v)
  7477. return nil
  7478. }
  7479. return fmt.Errorf("unknown Msg numeric field %s", name)
  7480. }
  7481. // ClearedFields returns all nullable fields that were cleared during this
  7482. // mutation.
  7483. func (m *MsgMutation) ClearedFields() []string {
  7484. var fields []string
  7485. if m.FieldCleared(msg.FieldDeletedAt) {
  7486. fields = append(fields, msg.FieldDeletedAt)
  7487. }
  7488. if m.FieldCleared(msg.FieldStatus) {
  7489. fields = append(fields, msg.FieldStatus)
  7490. }
  7491. if m.FieldCleared(msg.FieldFromwxid) {
  7492. fields = append(fields, msg.FieldFromwxid)
  7493. }
  7494. if m.FieldCleared(msg.FieldToid) {
  7495. fields = append(fields, msg.FieldToid)
  7496. }
  7497. if m.FieldCleared(msg.FieldMsgtype) {
  7498. fields = append(fields, msg.FieldMsgtype)
  7499. }
  7500. if m.FieldCleared(msg.FieldMsg) {
  7501. fields = append(fields, msg.FieldMsg)
  7502. }
  7503. if m.FieldCleared(msg.FieldBatchNo) {
  7504. fields = append(fields, msg.FieldBatchNo)
  7505. }
  7506. return fields
  7507. }
  7508. // FieldCleared returns a boolean indicating if a field with the given name was
  7509. // cleared in this mutation.
  7510. func (m *MsgMutation) FieldCleared(name string) bool {
  7511. _, ok := m.clearedFields[name]
  7512. return ok
  7513. }
  7514. // ClearField clears the value of the field with the given name. It returns an
  7515. // error if the field is not defined in the schema.
  7516. func (m *MsgMutation) ClearField(name string) error {
  7517. switch name {
  7518. case msg.FieldDeletedAt:
  7519. m.ClearDeletedAt()
  7520. return nil
  7521. case msg.FieldStatus:
  7522. m.ClearStatus()
  7523. return nil
  7524. case msg.FieldFromwxid:
  7525. m.ClearFromwxid()
  7526. return nil
  7527. case msg.FieldToid:
  7528. m.ClearToid()
  7529. return nil
  7530. case msg.FieldMsgtype:
  7531. m.ClearMsgtype()
  7532. return nil
  7533. case msg.FieldMsg:
  7534. m.ClearMsg()
  7535. return nil
  7536. case msg.FieldBatchNo:
  7537. m.ClearBatchNo()
  7538. return nil
  7539. }
  7540. return fmt.Errorf("unknown Msg nullable field %s", name)
  7541. }
  7542. // ResetField resets all changes in the mutation for the field with the given name.
  7543. // It returns an error if the field is not defined in the schema.
  7544. func (m *MsgMutation) ResetField(name string) error {
  7545. switch name {
  7546. case msg.FieldCreatedAt:
  7547. m.ResetCreatedAt()
  7548. return nil
  7549. case msg.FieldUpdatedAt:
  7550. m.ResetUpdatedAt()
  7551. return nil
  7552. case msg.FieldDeletedAt:
  7553. m.ResetDeletedAt()
  7554. return nil
  7555. case msg.FieldStatus:
  7556. m.ResetStatus()
  7557. return nil
  7558. case msg.FieldFromwxid:
  7559. m.ResetFromwxid()
  7560. return nil
  7561. case msg.FieldToid:
  7562. m.ResetToid()
  7563. return nil
  7564. case msg.FieldMsgtype:
  7565. m.ResetMsgtype()
  7566. return nil
  7567. case msg.FieldMsg:
  7568. m.ResetMsg()
  7569. return nil
  7570. case msg.FieldBatchNo:
  7571. m.ResetBatchNo()
  7572. return nil
  7573. }
  7574. return fmt.Errorf("unknown Msg field %s", name)
  7575. }
  7576. // AddedEdges returns all edge names that were set/added in this mutation.
  7577. func (m *MsgMutation) AddedEdges() []string {
  7578. edges := make([]string, 0, 0)
  7579. return edges
  7580. }
  7581. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7582. // name in this mutation.
  7583. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  7584. return nil
  7585. }
  7586. // RemovedEdges returns all edge names that were removed in this mutation.
  7587. func (m *MsgMutation) RemovedEdges() []string {
  7588. edges := make([]string, 0, 0)
  7589. return edges
  7590. }
  7591. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7592. // the given name in this mutation.
  7593. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  7594. return nil
  7595. }
  7596. // ClearedEdges returns all edge names that were cleared in this mutation.
  7597. func (m *MsgMutation) ClearedEdges() []string {
  7598. edges := make([]string, 0, 0)
  7599. return edges
  7600. }
  7601. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7602. // was cleared in this mutation.
  7603. func (m *MsgMutation) EdgeCleared(name string) bool {
  7604. return false
  7605. }
  7606. // ClearEdge clears the value of the edge with the given name. It returns an error
  7607. // if that edge is not defined in the schema.
  7608. func (m *MsgMutation) ClearEdge(name string) error {
  7609. return fmt.Errorf("unknown Msg unique edge %s", name)
  7610. }
  7611. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7612. // It returns an error if the edge is not defined in the schema.
  7613. func (m *MsgMutation) ResetEdge(name string) error {
  7614. return fmt.Errorf("unknown Msg edge %s", name)
  7615. }
  7616. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  7617. type ServerMutation struct {
  7618. config
  7619. op Op
  7620. typ string
  7621. id *uint64
  7622. created_at *time.Time
  7623. updated_at *time.Time
  7624. status *uint8
  7625. addstatus *int8
  7626. deleted_at *time.Time
  7627. name *string
  7628. public_ip *string
  7629. private_ip *string
  7630. admin_port *string
  7631. clearedFields map[string]struct{}
  7632. wxs map[uint64]struct{}
  7633. removedwxs map[uint64]struct{}
  7634. clearedwxs bool
  7635. done bool
  7636. oldValue func(context.Context) (*Server, error)
  7637. predicates []predicate.Server
  7638. }
  7639. var _ ent.Mutation = (*ServerMutation)(nil)
  7640. // serverOption allows management of the mutation configuration using functional options.
  7641. type serverOption func(*ServerMutation)
  7642. // newServerMutation creates new mutation for the Server entity.
  7643. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  7644. m := &ServerMutation{
  7645. config: c,
  7646. op: op,
  7647. typ: TypeServer,
  7648. clearedFields: make(map[string]struct{}),
  7649. }
  7650. for _, opt := range opts {
  7651. opt(m)
  7652. }
  7653. return m
  7654. }
  7655. // withServerID sets the ID field of the mutation.
  7656. func withServerID(id uint64) serverOption {
  7657. return func(m *ServerMutation) {
  7658. var (
  7659. err error
  7660. once sync.Once
  7661. value *Server
  7662. )
  7663. m.oldValue = func(ctx context.Context) (*Server, error) {
  7664. once.Do(func() {
  7665. if m.done {
  7666. err = errors.New("querying old values post mutation is not allowed")
  7667. } else {
  7668. value, err = m.Client().Server.Get(ctx, id)
  7669. }
  7670. })
  7671. return value, err
  7672. }
  7673. m.id = &id
  7674. }
  7675. }
  7676. // withServer sets the old Server of the mutation.
  7677. func withServer(node *Server) serverOption {
  7678. return func(m *ServerMutation) {
  7679. m.oldValue = func(context.Context) (*Server, error) {
  7680. return node, nil
  7681. }
  7682. m.id = &node.ID
  7683. }
  7684. }
  7685. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7686. // executed in a transaction (ent.Tx), a transactional client is returned.
  7687. func (m ServerMutation) Client() *Client {
  7688. client := &Client{config: m.config}
  7689. client.init()
  7690. return client
  7691. }
  7692. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7693. // it returns an error otherwise.
  7694. func (m ServerMutation) Tx() (*Tx, error) {
  7695. if _, ok := m.driver.(*txDriver); !ok {
  7696. return nil, errors.New("ent: mutation is not running in a transaction")
  7697. }
  7698. tx := &Tx{config: m.config}
  7699. tx.init()
  7700. return tx, nil
  7701. }
  7702. // SetID sets the value of the id field. Note that this
  7703. // operation is only accepted on creation of Server entities.
  7704. func (m *ServerMutation) SetID(id uint64) {
  7705. m.id = &id
  7706. }
  7707. // ID returns the ID value in the mutation. Note that the ID is only available
  7708. // if it was provided to the builder or after it was returned from the database.
  7709. func (m *ServerMutation) ID() (id uint64, exists bool) {
  7710. if m.id == nil {
  7711. return
  7712. }
  7713. return *m.id, true
  7714. }
  7715. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7716. // That means, if the mutation is applied within a transaction with an isolation level such
  7717. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7718. // or updated by the mutation.
  7719. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  7720. switch {
  7721. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7722. id, exists := m.ID()
  7723. if exists {
  7724. return []uint64{id}, nil
  7725. }
  7726. fallthrough
  7727. case m.op.Is(OpUpdate | OpDelete):
  7728. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  7729. default:
  7730. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7731. }
  7732. }
  7733. // SetCreatedAt sets the "created_at" field.
  7734. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  7735. m.created_at = &t
  7736. }
  7737. // CreatedAt returns the value of the "created_at" field in the mutation.
  7738. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  7739. v := m.created_at
  7740. if v == nil {
  7741. return
  7742. }
  7743. return *v, true
  7744. }
  7745. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  7746. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  7747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7748. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7749. if !m.op.Is(OpUpdateOne) {
  7750. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7751. }
  7752. if m.id == nil || m.oldValue == nil {
  7753. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7754. }
  7755. oldValue, err := m.oldValue(ctx)
  7756. if err != nil {
  7757. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7758. }
  7759. return oldValue.CreatedAt, nil
  7760. }
  7761. // ResetCreatedAt resets all changes to the "created_at" field.
  7762. func (m *ServerMutation) ResetCreatedAt() {
  7763. m.created_at = nil
  7764. }
  7765. // SetUpdatedAt sets the "updated_at" field.
  7766. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  7767. m.updated_at = &t
  7768. }
  7769. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7770. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  7771. v := m.updated_at
  7772. if v == nil {
  7773. return
  7774. }
  7775. return *v, true
  7776. }
  7777. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  7778. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  7779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7780. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7781. if !m.op.Is(OpUpdateOne) {
  7782. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7783. }
  7784. if m.id == nil || m.oldValue == nil {
  7785. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7786. }
  7787. oldValue, err := m.oldValue(ctx)
  7788. if err != nil {
  7789. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7790. }
  7791. return oldValue.UpdatedAt, nil
  7792. }
  7793. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7794. func (m *ServerMutation) ResetUpdatedAt() {
  7795. m.updated_at = nil
  7796. }
  7797. // SetStatus sets the "status" field.
  7798. func (m *ServerMutation) SetStatus(u uint8) {
  7799. m.status = &u
  7800. m.addstatus = nil
  7801. }
  7802. // Status returns the value of the "status" field in the mutation.
  7803. func (m *ServerMutation) Status() (r uint8, exists bool) {
  7804. v := m.status
  7805. if v == nil {
  7806. return
  7807. }
  7808. return *v, true
  7809. }
  7810. // OldStatus returns the old "status" field's value of the Server entity.
  7811. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  7812. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7813. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7814. if !m.op.Is(OpUpdateOne) {
  7815. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7816. }
  7817. if m.id == nil || m.oldValue == nil {
  7818. return v, errors.New("OldStatus requires an ID field in the mutation")
  7819. }
  7820. oldValue, err := m.oldValue(ctx)
  7821. if err != nil {
  7822. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7823. }
  7824. return oldValue.Status, nil
  7825. }
  7826. // AddStatus adds u to the "status" field.
  7827. func (m *ServerMutation) AddStatus(u int8) {
  7828. if m.addstatus != nil {
  7829. *m.addstatus += u
  7830. } else {
  7831. m.addstatus = &u
  7832. }
  7833. }
  7834. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7835. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  7836. v := m.addstatus
  7837. if v == nil {
  7838. return
  7839. }
  7840. return *v, true
  7841. }
  7842. // ClearStatus clears the value of the "status" field.
  7843. func (m *ServerMutation) ClearStatus() {
  7844. m.status = nil
  7845. m.addstatus = nil
  7846. m.clearedFields[server.FieldStatus] = struct{}{}
  7847. }
  7848. // StatusCleared returns if the "status" field was cleared in this mutation.
  7849. func (m *ServerMutation) StatusCleared() bool {
  7850. _, ok := m.clearedFields[server.FieldStatus]
  7851. return ok
  7852. }
  7853. // ResetStatus resets all changes to the "status" field.
  7854. func (m *ServerMutation) ResetStatus() {
  7855. m.status = nil
  7856. m.addstatus = nil
  7857. delete(m.clearedFields, server.FieldStatus)
  7858. }
  7859. // SetDeletedAt sets the "deleted_at" field.
  7860. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  7861. m.deleted_at = &t
  7862. }
  7863. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7864. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  7865. v := m.deleted_at
  7866. if v == nil {
  7867. return
  7868. }
  7869. return *v, true
  7870. }
  7871. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  7872. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  7873. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7874. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7875. if !m.op.Is(OpUpdateOne) {
  7876. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7877. }
  7878. if m.id == nil || m.oldValue == nil {
  7879. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7880. }
  7881. oldValue, err := m.oldValue(ctx)
  7882. if err != nil {
  7883. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7884. }
  7885. return oldValue.DeletedAt, nil
  7886. }
  7887. // ClearDeletedAt clears the value of the "deleted_at" field.
  7888. func (m *ServerMutation) ClearDeletedAt() {
  7889. m.deleted_at = nil
  7890. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  7891. }
  7892. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7893. func (m *ServerMutation) DeletedAtCleared() bool {
  7894. _, ok := m.clearedFields[server.FieldDeletedAt]
  7895. return ok
  7896. }
  7897. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7898. func (m *ServerMutation) ResetDeletedAt() {
  7899. m.deleted_at = nil
  7900. delete(m.clearedFields, server.FieldDeletedAt)
  7901. }
  7902. // SetName sets the "name" field.
  7903. func (m *ServerMutation) SetName(s string) {
  7904. m.name = &s
  7905. }
  7906. // Name returns the value of the "name" field in the mutation.
  7907. func (m *ServerMutation) Name() (r string, exists bool) {
  7908. v := m.name
  7909. if v == nil {
  7910. return
  7911. }
  7912. return *v, true
  7913. }
  7914. // OldName returns the old "name" field's value of the Server entity.
  7915. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  7916. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7917. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  7918. if !m.op.Is(OpUpdateOne) {
  7919. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7920. }
  7921. if m.id == nil || m.oldValue == nil {
  7922. return v, errors.New("OldName requires an ID field in the mutation")
  7923. }
  7924. oldValue, err := m.oldValue(ctx)
  7925. if err != nil {
  7926. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7927. }
  7928. return oldValue.Name, nil
  7929. }
  7930. // ResetName resets all changes to the "name" field.
  7931. func (m *ServerMutation) ResetName() {
  7932. m.name = nil
  7933. }
  7934. // SetPublicIP sets the "public_ip" field.
  7935. func (m *ServerMutation) SetPublicIP(s string) {
  7936. m.public_ip = &s
  7937. }
  7938. // PublicIP returns the value of the "public_ip" field in the mutation.
  7939. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  7940. v := m.public_ip
  7941. if v == nil {
  7942. return
  7943. }
  7944. return *v, true
  7945. }
  7946. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  7947. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  7948. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7949. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  7950. if !m.op.Is(OpUpdateOne) {
  7951. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  7952. }
  7953. if m.id == nil || m.oldValue == nil {
  7954. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  7955. }
  7956. oldValue, err := m.oldValue(ctx)
  7957. if err != nil {
  7958. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  7959. }
  7960. return oldValue.PublicIP, nil
  7961. }
  7962. // ResetPublicIP resets all changes to the "public_ip" field.
  7963. func (m *ServerMutation) ResetPublicIP() {
  7964. m.public_ip = nil
  7965. }
  7966. // SetPrivateIP sets the "private_ip" field.
  7967. func (m *ServerMutation) SetPrivateIP(s string) {
  7968. m.private_ip = &s
  7969. }
  7970. // PrivateIP returns the value of the "private_ip" field in the mutation.
  7971. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  7972. v := m.private_ip
  7973. if v == nil {
  7974. return
  7975. }
  7976. return *v, true
  7977. }
  7978. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  7979. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  7980. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7981. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  7982. if !m.op.Is(OpUpdateOne) {
  7983. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  7984. }
  7985. if m.id == nil || m.oldValue == nil {
  7986. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  7987. }
  7988. oldValue, err := m.oldValue(ctx)
  7989. if err != nil {
  7990. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  7991. }
  7992. return oldValue.PrivateIP, nil
  7993. }
  7994. // ResetPrivateIP resets all changes to the "private_ip" field.
  7995. func (m *ServerMutation) ResetPrivateIP() {
  7996. m.private_ip = nil
  7997. }
  7998. // SetAdminPort sets the "admin_port" field.
  7999. func (m *ServerMutation) SetAdminPort(s string) {
  8000. m.admin_port = &s
  8001. }
  8002. // AdminPort returns the value of the "admin_port" field in the mutation.
  8003. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  8004. v := m.admin_port
  8005. if v == nil {
  8006. return
  8007. }
  8008. return *v, true
  8009. }
  8010. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  8011. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  8012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8013. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  8014. if !m.op.Is(OpUpdateOne) {
  8015. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  8016. }
  8017. if m.id == nil || m.oldValue == nil {
  8018. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  8019. }
  8020. oldValue, err := m.oldValue(ctx)
  8021. if err != nil {
  8022. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  8023. }
  8024. return oldValue.AdminPort, nil
  8025. }
  8026. // ResetAdminPort resets all changes to the "admin_port" field.
  8027. func (m *ServerMutation) ResetAdminPort() {
  8028. m.admin_port = nil
  8029. }
  8030. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  8031. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  8032. if m.wxs == nil {
  8033. m.wxs = make(map[uint64]struct{})
  8034. }
  8035. for i := range ids {
  8036. m.wxs[ids[i]] = struct{}{}
  8037. }
  8038. }
  8039. // ClearWxs clears the "wxs" edge to the Wx entity.
  8040. func (m *ServerMutation) ClearWxs() {
  8041. m.clearedwxs = true
  8042. }
  8043. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  8044. func (m *ServerMutation) WxsCleared() bool {
  8045. return m.clearedwxs
  8046. }
  8047. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  8048. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  8049. if m.removedwxs == nil {
  8050. m.removedwxs = make(map[uint64]struct{})
  8051. }
  8052. for i := range ids {
  8053. delete(m.wxs, ids[i])
  8054. m.removedwxs[ids[i]] = struct{}{}
  8055. }
  8056. }
  8057. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  8058. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  8059. for id := range m.removedwxs {
  8060. ids = append(ids, id)
  8061. }
  8062. return
  8063. }
  8064. // WxsIDs returns the "wxs" edge IDs in the mutation.
  8065. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  8066. for id := range m.wxs {
  8067. ids = append(ids, id)
  8068. }
  8069. return
  8070. }
  8071. // ResetWxs resets all changes to the "wxs" edge.
  8072. func (m *ServerMutation) ResetWxs() {
  8073. m.wxs = nil
  8074. m.clearedwxs = false
  8075. m.removedwxs = nil
  8076. }
  8077. // Where appends a list predicates to the ServerMutation builder.
  8078. func (m *ServerMutation) Where(ps ...predicate.Server) {
  8079. m.predicates = append(m.predicates, ps...)
  8080. }
  8081. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  8082. // users can use type-assertion to append predicates that do not depend on any generated package.
  8083. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  8084. p := make([]predicate.Server, len(ps))
  8085. for i := range ps {
  8086. p[i] = ps[i]
  8087. }
  8088. m.Where(p...)
  8089. }
  8090. // Op returns the operation name.
  8091. func (m *ServerMutation) Op() Op {
  8092. return m.op
  8093. }
  8094. // SetOp allows setting the mutation operation.
  8095. func (m *ServerMutation) SetOp(op Op) {
  8096. m.op = op
  8097. }
  8098. // Type returns the node type of this mutation (Server).
  8099. func (m *ServerMutation) Type() string {
  8100. return m.typ
  8101. }
  8102. // Fields returns all fields that were changed during this mutation. Note that in
  8103. // order to get all numeric fields that were incremented/decremented, call
  8104. // AddedFields().
  8105. func (m *ServerMutation) Fields() []string {
  8106. fields := make([]string, 0, 8)
  8107. if m.created_at != nil {
  8108. fields = append(fields, server.FieldCreatedAt)
  8109. }
  8110. if m.updated_at != nil {
  8111. fields = append(fields, server.FieldUpdatedAt)
  8112. }
  8113. if m.status != nil {
  8114. fields = append(fields, server.FieldStatus)
  8115. }
  8116. if m.deleted_at != nil {
  8117. fields = append(fields, server.FieldDeletedAt)
  8118. }
  8119. if m.name != nil {
  8120. fields = append(fields, server.FieldName)
  8121. }
  8122. if m.public_ip != nil {
  8123. fields = append(fields, server.FieldPublicIP)
  8124. }
  8125. if m.private_ip != nil {
  8126. fields = append(fields, server.FieldPrivateIP)
  8127. }
  8128. if m.admin_port != nil {
  8129. fields = append(fields, server.FieldAdminPort)
  8130. }
  8131. return fields
  8132. }
  8133. // Field returns the value of a field with the given name. The second boolean
  8134. // return value indicates that this field was not set, or was not defined in the
  8135. // schema.
  8136. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  8137. switch name {
  8138. case server.FieldCreatedAt:
  8139. return m.CreatedAt()
  8140. case server.FieldUpdatedAt:
  8141. return m.UpdatedAt()
  8142. case server.FieldStatus:
  8143. return m.Status()
  8144. case server.FieldDeletedAt:
  8145. return m.DeletedAt()
  8146. case server.FieldName:
  8147. return m.Name()
  8148. case server.FieldPublicIP:
  8149. return m.PublicIP()
  8150. case server.FieldPrivateIP:
  8151. return m.PrivateIP()
  8152. case server.FieldAdminPort:
  8153. return m.AdminPort()
  8154. }
  8155. return nil, false
  8156. }
  8157. // OldField returns the old value of the field from the database. An error is
  8158. // returned if the mutation operation is not UpdateOne, or the query to the
  8159. // database failed.
  8160. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8161. switch name {
  8162. case server.FieldCreatedAt:
  8163. return m.OldCreatedAt(ctx)
  8164. case server.FieldUpdatedAt:
  8165. return m.OldUpdatedAt(ctx)
  8166. case server.FieldStatus:
  8167. return m.OldStatus(ctx)
  8168. case server.FieldDeletedAt:
  8169. return m.OldDeletedAt(ctx)
  8170. case server.FieldName:
  8171. return m.OldName(ctx)
  8172. case server.FieldPublicIP:
  8173. return m.OldPublicIP(ctx)
  8174. case server.FieldPrivateIP:
  8175. return m.OldPrivateIP(ctx)
  8176. case server.FieldAdminPort:
  8177. return m.OldAdminPort(ctx)
  8178. }
  8179. return nil, fmt.Errorf("unknown Server field %s", name)
  8180. }
  8181. // SetField sets the value of a field with the given name. It returns an error if
  8182. // the field is not defined in the schema, or if the type mismatched the field
  8183. // type.
  8184. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  8185. switch name {
  8186. case server.FieldCreatedAt:
  8187. v, ok := value.(time.Time)
  8188. if !ok {
  8189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8190. }
  8191. m.SetCreatedAt(v)
  8192. return nil
  8193. case server.FieldUpdatedAt:
  8194. v, ok := value.(time.Time)
  8195. if !ok {
  8196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8197. }
  8198. m.SetUpdatedAt(v)
  8199. return nil
  8200. case server.FieldStatus:
  8201. v, ok := value.(uint8)
  8202. if !ok {
  8203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8204. }
  8205. m.SetStatus(v)
  8206. return nil
  8207. case server.FieldDeletedAt:
  8208. v, ok := value.(time.Time)
  8209. if !ok {
  8210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8211. }
  8212. m.SetDeletedAt(v)
  8213. return nil
  8214. case server.FieldName:
  8215. v, ok := value.(string)
  8216. if !ok {
  8217. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8218. }
  8219. m.SetName(v)
  8220. return nil
  8221. case server.FieldPublicIP:
  8222. v, ok := value.(string)
  8223. if !ok {
  8224. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8225. }
  8226. m.SetPublicIP(v)
  8227. return nil
  8228. case server.FieldPrivateIP:
  8229. v, ok := value.(string)
  8230. if !ok {
  8231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8232. }
  8233. m.SetPrivateIP(v)
  8234. return nil
  8235. case server.FieldAdminPort:
  8236. v, ok := value.(string)
  8237. if !ok {
  8238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8239. }
  8240. m.SetAdminPort(v)
  8241. return nil
  8242. }
  8243. return fmt.Errorf("unknown Server field %s", name)
  8244. }
  8245. // AddedFields returns all numeric fields that were incremented/decremented during
  8246. // this mutation.
  8247. func (m *ServerMutation) AddedFields() []string {
  8248. var fields []string
  8249. if m.addstatus != nil {
  8250. fields = append(fields, server.FieldStatus)
  8251. }
  8252. return fields
  8253. }
  8254. // AddedField returns the numeric value that was incremented/decremented on a field
  8255. // with the given name. The second boolean return value indicates that this field
  8256. // was not set, or was not defined in the schema.
  8257. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  8258. switch name {
  8259. case server.FieldStatus:
  8260. return m.AddedStatus()
  8261. }
  8262. return nil, false
  8263. }
  8264. // AddField adds the value to the field with the given name. It returns an error if
  8265. // the field is not defined in the schema, or if the type mismatched the field
  8266. // type.
  8267. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  8268. switch name {
  8269. case server.FieldStatus:
  8270. v, ok := value.(int8)
  8271. if !ok {
  8272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8273. }
  8274. m.AddStatus(v)
  8275. return nil
  8276. }
  8277. return fmt.Errorf("unknown Server numeric field %s", name)
  8278. }
  8279. // ClearedFields returns all nullable fields that were cleared during this
  8280. // mutation.
  8281. func (m *ServerMutation) ClearedFields() []string {
  8282. var fields []string
  8283. if m.FieldCleared(server.FieldStatus) {
  8284. fields = append(fields, server.FieldStatus)
  8285. }
  8286. if m.FieldCleared(server.FieldDeletedAt) {
  8287. fields = append(fields, server.FieldDeletedAt)
  8288. }
  8289. return fields
  8290. }
  8291. // FieldCleared returns a boolean indicating if a field with the given name was
  8292. // cleared in this mutation.
  8293. func (m *ServerMutation) FieldCleared(name string) bool {
  8294. _, ok := m.clearedFields[name]
  8295. return ok
  8296. }
  8297. // ClearField clears the value of the field with the given name. It returns an
  8298. // error if the field is not defined in the schema.
  8299. func (m *ServerMutation) ClearField(name string) error {
  8300. switch name {
  8301. case server.FieldStatus:
  8302. m.ClearStatus()
  8303. return nil
  8304. case server.FieldDeletedAt:
  8305. m.ClearDeletedAt()
  8306. return nil
  8307. }
  8308. return fmt.Errorf("unknown Server nullable field %s", name)
  8309. }
  8310. // ResetField resets all changes in the mutation for the field with the given name.
  8311. // It returns an error if the field is not defined in the schema.
  8312. func (m *ServerMutation) ResetField(name string) error {
  8313. switch name {
  8314. case server.FieldCreatedAt:
  8315. m.ResetCreatedAt()
  8316. return nil
  8317. case server.FieldUpdatedAt:
  8318. m.ResetUpdatedAt()
  8319. return nil
  8320. case server.FieldStatus:
  8321. m.ResetStatus()
  8322. return nil
  8323. case server.FieldDeletedAt:
  8324. m.ResetDeletedAt()
  8325. return nil
  8326. case server.FieldName:
  8327. m.ResetName()
  8328. return nil
  8329. case server.FieldPublicIP:
  8330. m.ResetPublicIP()
  8331. return nil
  8332. case server.FieldPrivateIP:
  8333. m.ResetPrivateIP()
  8334. return nil
  8335. case server.FieldAdminPort:
  8336. m.ResetAdminPort()
  8337. return nil
  8338. }
  8339. return fmt.Errorf("unknown Server field %s", name)
  8340. }
  8341. // AddedEdges returns all edge names that were set/added in this mutation.
  8342. func (m *ServerMutation) AddedEdges() []string {
  8343. edges := make([]string, 0, 1)
  8344. if m.wxs != nil {
  8345. edges = append(edges, server.EdgeWxs)
  8346. }
  8347. return edges
  8348. }
  8349. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8350. // name in this mutation.
  8351. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  8352. switch name {
  8353. case server.EdgeWxs:
  8354. ids := make([]ent.Value, 0, len(m.wxs))
  8355. for id := range m.wxs {
  8356. ids = append(ids, id)
  8357. }
  8358. return ids
  8359. }
  8360. return nil
  8361. }
  8362. // RemovedEdges returns all edge names that were removed in this mutation.
  8363. func (m *ServerMutation) RemovedEdges() []string {
  8364. edges := make([]string, 0, 1)
  8365. if m.removedwxs != nil {
  8366. edges = append(edges, server.EdgeWxs)
  8367. }
  8368. return edges
  8369. }
  8370. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8371. // the given name in this mutation.
  8372. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  8373. switch name {
  8374. case server.EdgeWxs:
  8375. ids := make([]ent.Value, 0, len(m.removedwxs))
  8376. for id := range m.removedwxs {
  8377. ids = append(ids, id)
  8378. }
  8379. return ids
  8380. }
  8381. return nil
  8382. }
  8383. // ClearedEdges returns all edge names that were cleared in this mutation.
  8384. func (m *ServerMutation) ClearedEdges() []string {
  8385. edges := make([]string, 0, 1)
  8386. if m.clearedwxs {
  8387. edges = append(edges, server.EdgeWxs)
  8388. }
  8389. return edges
  8390. }
  8391. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8392. // was cleared in this mutation.
  8393. func (m *ServerMutation) EdgeCleared(name string) bool {
  8394. switch name {
  8395. case server.EdgeWxs:
  8396. return m.clearedwxs
  8397. }
  8398. return false
  8399. }
  8400. // ClearEdge clears the value of the edge with the given name. It returns an error
  8401. // if that edge is not defined in the schema.
  8402. func (m *ServerMutation) ClearEdge(name string) error {
  8403. switch name {
  8404. }
  8405. return fmt.Errorf("unknown Server unique edge %s", name)
  8406. }
  8407. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8408. // It returns an error if the edge is not defined in the schema.
  8409. func (m *ServerMutation) ResetEdge(name string) error {
  8410. switch name {
  8411. case server.EdgeWxs:
  8412. m.ResetWxs()
  8413. return nil
  8414. }
  8415. return fmt.Errorf("unknown Server edge %s", name)
  8416. }
  8417. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  8418. type SopNodeMutation struct {
  8419. config
  8420. op Op
  8421. typ string
  8422. id *uint64
  8423. created_at *time.Time
  8424. updated_at *time.Time
  8425. status *uint8
  8426. addstatus *int8
  8427. deleted_at *time.Time
  8428. parent_id *uint64
  8429. addparent_id *int64
  8430. name *string
  8431. condition_type *int
  8432. addcondition_type *int
  8433. condition_list *[]string
  8434. appendcondition_list []string
  8435. no_reply_condition *uint64
  8436. addno_reply_condition *int64
  8437. action_message *[]custom_types.Action
  8438. appendaction_message []custom_types.Action
  8439. action_label *[]uint64
  8440. appendaction_label []uint64
  8441. clearedFields map[string]struct{}
  8442. sop_stage *uint64
  8443. clearedsop_stage bool
  8444. node_messages map[uint64]struct{}
  8445. removednode_messages map[uint64]struct{}
  8446. clearednode_messages bool
  8447. done bool
  8448. oldValue func(context.Context) (*SopNode, error)
  8449. predicates []predicate.SopNode
  8450. }
  8451. var _ ent.Mutation = (*SopNodeMutation)(nil)
  8452. // sopnodeOption allows management of the mutation configuration using functional options.
  8453. type sopnodeOption func(*SopNodeMutation)
  8454. // newSopNodeMutation creates new mutation for the SopNode entity.
  8455. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  8456. m := &SopNodeMutation{
  8457. config: c,
  8458. op: op,
  8459. typ: TypeSopNode,
  8460. clearedFields: make(map[string]struct{}),
  8461. }
  8462. for _, opt := range opts {
  8463. opt(m)
  8464. }
  8465. return m
  8466. }
  8467. // withSopNodeID sets the ID field of the mutation.
  8468. func withSopNodeID(id uint64) sopnodeOption {
  8469. return func(m *SopNodeMutation) {
  8470. var (
  8471. err error
  8472. once sync.Once
  8473. value *SopNode
  8474. )
  8475. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  8476. once.Do(func() {
  8477. if m.done {
  8478. err = errors.New("querying old values post mutation is not allowed")
  8479. } else {
  8480. value, err = m.Client().SopNode.Get(ctx, id)
  8481. }
  8482. })
  8483. return value, err
  8484. }
  8485. m.id = &id
  8486. }
  8487. }
  8488. // withSopNode sets the old SopNode of the mutation.
  8489. func withSopNode(node *SopNode) sopnodeOption {
  8490. return func(m *SopNodeMutation) {
  8491. m.oldValue = func(context.Context) (*SopNode, error) {
  8492. return node, nil
  8493. }
  8494. m.id = &node.ID
  8495. }
  8496. }
  8497. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8498. // executed in a transaction (ent.Tx), a transactional client is returned.
  8499. func (m SopNodeMutation) Client() *Client {
  8500. client := &Client{config: m.config}
  8501. client.init()
  8502. return client
  8503. }
  8504. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8505. // it returns an error otherwise.
  8506. func (m SopNodeMutation) Tx() (*Tx, error) {
  8507. if _, ok := m.driver.(*txDriver); !ok {
  8508. return nil, errors.New("ent: mutation is not running in a transaction")
  8509. }
  8510. tx := &Tx{config: m.config}
  8511. tx.init()
  8512. return tx, nil
  8513. }
  8514. // SetID sets the value of the id field. Note that this
  8515. // operation is only accepted on creation of SopNode entities.
  8516. func (m *SopNodeMutation) SetID(id uint64) {
  8517. m.id = &id
  8518. }
  8519. // ID returns the ID value in the mutation. Note that the ID is only available
  8520. // if it was provided to the builder or after it was returned from the database.
  8521. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  8522. if m.id == nil {
  8523. return
  8524. }
  8525. return *m.id, true
  8526. }
  8527. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8528. // That means, if the mutation is applied within a transaction with an isolation level such
  8529. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8530. // or updated by the mutation.
  8531. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  8532. switch {
  8533. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8534. id, exists := m.ID()
  8535. if exists {
  8536. return []uint64{id}, nil
  8537. }
  8538. fallthrough
  8539. case m.op.Is(OpUpdate | OpDelete):
  8540. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  8541. default:
  8542. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8543. }
  8544. }
  8545. // SetCreatedAt sets the "created_at" field.
  8546. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  8547. m.created_at = &t
  8548. }
  8549. // CreatedAt returns the value of the "created_at" field in the mutation.
  8550. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  8551. v := m.created_at
  8552. if v == nil {
  8553. return
  8554. }
  8555. return *v, true
  8556. }
  8557. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  8558. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  8559. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8560. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8561. if !m.op.Is(OpUpdateOne) {
  8562. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8563. }
  8564. if m.id == nil || m.oldValue == nil {
  8565. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8566. }
  8567. oldValue, err := m.oldValue(ctx)
  8568. if err != nil {
  8569. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8570. }
  8571. return oldValue.CreatedAt, nil
  8572. }
  8573. // ResetCreatedAt resets all changes to the "created_at" field.
  8574. func (m *SopNodeMutation) ResetCreatedAt() {
  8575. m.created_at = nil
  8576. }
  8577. // SetUpdatedAt sets the "updated_at" field.
  8578. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  8579. m.updated_at = &t
  8580. }
  8581. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8582. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  8583. v := m.updated_at
  8584. if v == nil {
  8585. return
  8586. }
  8587. return *v, true
  8588. }
  8589. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  8590. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  8591. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8592. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8593. if !m.op.Is(OpUpdateOne) {
  8594. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8595. }
  8596. if m.id == nil || m.oldValue == nil {
  8597. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8598. }
  8599. oldValue, err := m.oldValue(ctx)
  8600. if err != nil {
  8601. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8602. }
  8603. return oldValue.UpdatedAt, nil
  8604. }
  8605. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8606. func (m *SopNodeMutation) ResetUpdatedAt() {
  8607. m.updated_at = nil
  8608. }
  8609. // SetStatus sets the "status" field.
  8610. func (m *SopNodeMutation) SetStatus(u uint8) {
  8611. m.status = &u
  8612. m.addstatus = nil
  8613. }
  8614. // Status returns the value of the "status" field in the mutation.
  8615. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  8616. v := m.status
  8617. if v == nil {
  8618. return
  8619. }
  8620. return *v, true
  8621. }
  8622. // OldStatus returns the old "status" field's value of the SopNode entity.
  8623. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  8624. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8625. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  8626. if !m.op.Is(OpUpdateOne) {
  8627. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  8628. }
  8629. if m.id == nil || m.oldValue == nil {
  8630. return v, errors.New("OldStatus requires an ID field in the mutation")
  8631. }
  8632. oldValue, err := m.oldValue(ctx)
  8633. if err != nil {
  8634. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  8635. }
  8636. return oldValue.Status, nil
  8637. }
  8638. // AddStatus adds u to the "status" field.
  8639. func (m *SopNodeMutation) AddStatus(u int8) {
  8640. if m.addstatus != nil {
  8641. *m.addstatus += u
  8642. } else {
  8643. m.addstatus = &u
  8644. }
  8645. }
  8646. // AddedStatus returns the value that was added to the "status" field in this mutation.
  8647. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  8648. v := m.addstatus
  8649. if v == nil {
  8650. return
  8651. }
  8652. return *v, true
  8653. }
  8654. // ClearStatus clears the value of the "status" field.
  8655. func (m *SopNodeMutation) ClearStatus() {
  8656. m.status = nil
  8657. m.addstatus = nil
  8658. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  8659. }
  8660. // StatusCleared returns if the "status" field was cleared in this mutation.
  8661. func (m *SopNodeMutation) StatusCleared() bool {
  8662. _, ok := m.clearedFields[sopnode.FieldStatus]
  8663. return ok
  8664. }
  8665. // ResetStatus resets all changes to the "status" field.
  8666. func (m *SopNodeMutation) ResetStatus() {
  8667. m.status = nil
  8668. m.addstatus = nil
  8669. delete(m.clearedFields, sopnode.FieldStatus)
  8670. }
  8671. // SetDeletedAt sets the "deleted_at" field.
  8672. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  8673. m.deleted_at = &t
  8674. }
  8675. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8676. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  8677. v := m.deleted_at
  8678. if v == nil {
  8679. return
  8680. }
  8681. return *v, true
  8682. }
  8683. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  8684. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  8685. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8686. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8687. if !m.op.Is(OpUpdateOne) {
  8688. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8689. }
  8690. if m.id == nil || m.oldValue == nil {
  8691. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8692. }
  8693. oldValue, err := m.oldValue(ctx)
  8694. if err != nil {
  8695. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8696. }
  8697. return oldValue.DeletedAt, nil
  8698. }
  8699. // ClearDeletedAt clears the value of the "deleted_at" field.
  8700. func (m *SopNodeMutation) ClearDeletedAt() {
  8701. m.deleted_at = nil
  8702. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  8703. }
  8704. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8705. func (m *SopNodeMutation) DeletedAtCleared() bool {
  8706. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  8707. return ok
  8708. }
  8709. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8710. func (m *SopNodeMutation) ResetDeletedAt() {
  8711. m.deleted_at = nil
  8712. delete(m.clearedFields, sopnode.FieldDeletedAt)
  8713. }
  8714. // SetStageID sets the "stage_id" field.
  8715. func (m *SopNodeMutation) SetStageID(u uint64) {
  8716. m.sop_stage = &u
  8717. }
  8718. // StageID returns the value of the "stage_id" field in the mutation.
  8719. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  8720. v := m.sop_stage
  8721. if v == nil {
  8722. return
  8723. }
  8724. return *v, true
  8725. }
  8726. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  8727. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  8728. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8729. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  8730. if !m.op.Is(OpUpdateOne) {
  8731. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  8732. }
  8733. if m.id == nil || m.oldValue == nil {
  8734. return v, errors.New("OldStageID requires an ID field in the mutation")
  8735. }
  8736. oldValue, err := m.oldValue(ctx)
  8737. if err != nil {
  8738. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  8739. }
  8740. return oldValue.StageID, nil
  8741. }
  8742. // ResetStageID resets all changes to the "stage_id" field.
  8743. func (m *SopNodeMutation) ResetStageID() {
  8744. m.sop_stage = nil
  8745. }
  8746. // SetParentID sets the "parent_id" field.
  8747. func (m *SopNodeMutation) SetParentID(u uint64) {
  8748. m.parent_id = &u
  8749. m.addparent_id = nil
  8750. }
  8751. // ParentID returns the value of the "parent_id" field in the mutation.
  8752. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  8753. v := m.parent_id
  8754. if v == nil {
  8755. return
  8756. }
  8757. return *v, true
  8758. }
  8759. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  8760. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  8761. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8762. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  8763. if !m.op.Is(OpUpdateOne) {
  8764. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  8765. }
  8766. if m.id == nil || m.oldValue == nil {
  8767. return v, errors.New("OldParentID requires an ID field in the mutation")
  8768. }
  8769. oldValue, err := m.oldValue(ctx)
  8770. if err != nil {
  8771. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  8772. }
  8773. return oldValue.ParentID, nil
  8774. }
  8775. // AddParentID adds u to the "parent_id" field.
  8776. func (m *SopNodeMutation) AddParentID(u int64) {
  8777. if m.addparent_id != nil {
  8778. *m.addparent_id += u
  8779. } else {
  8780. m.addparent_id = &u
  8781. }
  8782. }
  8783. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  8784. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  8785. v := m.addparent_id
  8786. if v == nil {
  8787. return
  8788. }
  8789. return *v, true
  8790. }
  8791. // ResetParentID resets all changes to the "parent_id" field.
  8792. func (m *SopNodeMutation) ResetParentID() {
  8793. m.parent_id = nil
  8794. m.addparent_id = nil
  8795. }
  8796. // SetName sets the "name" field.
  8797. func (m *SopNodeMutation) SetName(s string) {
  8798. m.name = &s
  8799. }
  8800. // Name returns the value of the "name" field in the mutation.
  8801. func (m *SopNodeMutation) Name() (r string, exists bool) {
  8802. v := m.name
  8803. if v == nil {
  8804. return
  8805. }
  8806. return *v, true
  8807. }
  8808. // OldName returns the old "name" field's value of the SopNode entity.
  8809. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  8810. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8811. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  8812. if !m.op.Is(OpUpdateOne) {
  8813. return v, errors.New("OldName is only allowed on UpdateOne operations")
  8814. }
  8815. if m.id == nil || m.oldValue == nil {
  8816. return v, errors.New("OldName requires an ID field in the mutation")
  8817. }
  8818. oldValue, err := m.oldValue(ctx)
  8819. if err != nil {
  8820. return v, fmt.Errorf("querying old value for OldName: %w", err)
  8821. }
  8822. return oldValue.Name, nil
  8823. }
  8824. // ResetName resets all changes to the "name" field.
  8825. func (m *SopNodeMutation) ResetName() {
  8826. m.name = nil
  8827. }
  8828. // SetConditionType sets the "condition_type" field.
  8829. func (m *SopNodeMutation) SetConditionType(i int) {
  8830. m.condition_type = &i
  8831. m.addcondition_type = nil
  8832. }
  8833. // ConditionType returns the value of the "condition_type" field in the mutation.
  8834. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  8835. v := m.condition_type
  8836. if v == nil {
  8837. return
  8838. }
  8839. return *v, true
  8840. }
  8841. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  8842. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  8843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8844. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  8845. if !m.op.Is(OpUpdateOne) {
  8846. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  8847. }
  8848. if m.id == nil || m.oldValue == nil {
  8849. return v, errors.New("OldConditionType requires an ID field in the mutation")
  8850. }
  8851. oldValue, err := m.oldValue(ctx)
  8852. if err != nil {
  8853. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  8854. }
  8855. return oldValue.ConditionType, nil
  8856. }
  8857. // AddConditionType adds i to the "condition_type" field.
  8858. func (m *SopNodeMutation) AddConditionType(i int) {
  8859. if m.addcondition_type != nil {
  8860. *m.addcondition_type += i
  8861. } else {
  8862. m.addcondition_type = &i
  8863. }
  8864. }
  8865. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  8866. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  8867. v := m.addcondition_type
  8868. if v == nil {
  8869. return
  8870. }
  8871. return *v, true
  8872. }
  8873. // ResetConditionType resets all changes to the "condition_type" field.
  8874. func (m *SopNodeMutation) ResetConditionType() {
  8875. m.condition_type = nil
  8876. m.addcondition_type = nil
  8877. }
  8878. // SetConditionList sets the "condition_list" field.
  8879. func (m *SopNodeMutation) SetConditionList(s []string) {
  8880. m.condition_list = &s
  8881. m.appendcondition_list = nil
  8882. }
  8883. // ConditionList returns the value of the "condition_list" field in the mutation.
  8884. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  8885. v := m.condition_list
  8886. if v == nil {
  8887. return
  8888. }
  8889. return *v, true
  8890. }
  8891. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  8892. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  8893. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8894. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  8895. if !m.op.Is(OpUpdateOne) {
  8896. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  8897. }
  8898. if m.id == nil || m.oldValue == nil {
  8899. return v, errors.New("OldConditionList requires an ID field in the mutation")
  8900. }
  8901. oldValue, err := m.oldValue(ctx)
  8902. if err != nil {
  8903. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  8904. }
  8905. return oldValue.ConditionList, nil
  8906. }
  8907. // AppendConditionList adds s to the "condition_list" field.
  8908. func (m *SopNodeMutation) AppendConditionList(s []string) {
  8909. m.appendcondition_list = append(m.appendcondition_list, s...)
  8910. }
  8911. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  8912. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  8913. if len(m.appendcondition_list) == 0 {
  8914. return nil, false
  8915. }
  8916. return m.appendcondition_list, true
  8917. }
  8918. // ClearConditionList clears the value of the "condition_list" field.
  8919. func (m *SopNodeMutation) ClearConditionList() {
  8920. m.condition_list = nil
  8921. m.appendcondition_list = nil
  8922. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  8923. }
  8924. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  8925. func (m *SopNodeMutation) ConditionListCleared() bool {
  8926. _, ok := m.clearedFields[sopnode.FieldConditionList]
  8927. return ok
  8928. }
  8929. // ResetConditionList resets all changes to the "condition_list" field.
  8930. func (m *SopNodeMutation) ResetConditionList() {
  8931. m.condition_list = nil
  8932. m.appendcondition_list = nil
  8933. delete(m.clearedFields, sopnode.FieldConditionList)
  8934. }
  8935. // SetNoReplyCondition sets the "no_reply_condition" field.
  8936. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  8937. m.no_reply_condition = &u
  8938. m.addno_reply_condition = nil
  8939. }
  8940. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  8941. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  8942. v := m.no_reply_condition
  8943. if v == nil {
  8944. return
  8945. }
  8946. return *v, true
  8947. }
  8948. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  8949. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  8950. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8951. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  8952. if !m.op.Is(OpUpdateOne) {
  8953. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  8954. }
  8955. if m.id == nil || m.oldValue == nil {
  8956. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  8957. }
  8958. oldValue, err := m.oldValue(ctx)
  8959. if err != nil {
  8960. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  8961. }
  8962. return oldValue.NoReplyCondition, nil
  8963. }
  8964. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  8965. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  8966. if m.addno_reply_condition != nil {
  8967. *m.addno_reply_condition += u
  8968. } else {
  8969. m.addno_reply_condition = &u
  8970. }
  8971. }
  8972. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  8973. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  8974. v := m.addno_reply_condition
  8975. if v == nil {
  8976. return
  8977. }
  8978. return *v, true
  8979. }
  8980. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  8981. func (m *SopNodeMutation) ResetNoReplyCondition() {
  8982. m.no_reply_condition = nil
  8983. m.addno_reply_condition = nil
  8984. }
  8985. // SetActionMessage sets the "action_message" field.
  8986. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  8987. m.action_message = &ct
  8988. m.appendaction_message = nil
  8989. }
  8990. // ActionMessage returns the value of the "action_message" field in the mutation.
  8991. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  8992. v := m.action_message
  8993. if v == nil {
  8994. return
  8995. }
  8996. return *v, true
  8997. }
  8998. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  8999. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9001. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  9002. if !m.op.Is(OpUpdateOne) {
  9003. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  9004. }
  9005. if m.id == nil || m.oldValue == nil {
  9006. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  9007. }
  9008. oldValue, err := m.oldValue(ctx)
  9009. if err != nil {
  9010. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  9011. }
  9012. return oldValue.ActionMessage, nil
  9013. }
  9014. // AppendActionMessage adds ct to the "action_message" field.
  9015. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  9016. m.appendaction_message = append(m.appendaction_message, ct...)
  9017. }
  9018. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  9019. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  9020. if len(m.appendaction_message) == 0 {
  9021. return nil, false
  9022. }
  9023. return m.appendaction_message, true
  9024. }
  9025. // ClearActionMessage clears the value of the "action_message" field.
  9026. func (m *SopNodeMutation) ClearActionMessage() {
  9027. m.action_message = nil
  9028. m.appendaction_message = nil
  9029. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  9030. }
  9031. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  9032. func (m *SopNodeMutation) ActionMessageCleared() bool {
  9033. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  9034. return ok
  9035. }
  9036. // ResetActionMessage resets all changes to the "action_message" field.
  9037. func (m *SopNodeMutation) ResetActionMessage() {
  9038. m.action_message = nil
  9039. m.appendaction_message = nil
  9040. delete(m.clearedFields, sopnode.FieldActionMessage)
  9041. }
  9042. // SetActionLabel sets the "action_label" field.
  9043. func (m *SopNodeMutation) SetActionLabel(u []uint64) {
  9044. m.action_label = &u
  9045. m.appendaction_label = nil
  9046. }
  9047. // ActionLabel returns the value of the "action_label" field in the mutation.
  9048. func (m *SopNodeMutation) ActionLabel() (r []uint64, exists bool) {
  9049. v := m.action_label
  9050. if v == nil {
  9051. return
  9052. }
  9053. return *v, true
  9054. }
  9055. // OldActionLabel returns the old "action_label" field's value of the SopNode entity.
  9056. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9058. func (m *SopNodeMutation) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  9059. if !m.op.Is(OpUpdateOne) {
  9060. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  9061. }
  9062. if m.id == nil || m.oldValue == nil {
  9063. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  9064. }
  9065. oldValue, err := m.oldValue(ctx)
  9066. if err != nil {
  9067. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  9068. }
  9069. return oldValue.ActionLabel, nil
  9070. }
  9071. // AppendActionLabel adds u to the "action_label" field.
  9072. func (m *SopNodeMutation) AppendActionLabel(u []uint64) {
  9073. m.appendaction_label = append(m.appendaction_label, u...)
  9074. }
  9075. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  9076. func (m *SopNodeMutation) AppendedActionLabel() ([]uint64, bool) {
  9077. if len(m.appendaction_label) == 0 {
  9078. return nil, false
  9079. }
  9080. return m.appendaction_label, true
  9081. }
  9082. // ClearActionLabel clears the value of the "action_label" field.
  9083. func (m *SopNodeMutation) ClearActionLabel() {
  9084. m.action_label = nil
  9085. m.appendaction_label = nil
  9086. m.clearedFields[sopnode.FieldActionLabel] = struct{}{}
  9087. }
  9088. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  9089. func (m *SopNodeMutation) ActionLabelCleared() bool {
  9090. _, ok := m.clearedFields[sopnode.FieldActionLabel]
  9091. return ok
  9092. }
  9093. // ResetActionLabel resets all changes to the "action_label" field.
  9094. func (m *SopNodeMutation) ResetActionLabel() {
  9095. m.action_label = nil
  9096. m.appendaction_label = nil
  9097. delete(m.clearedFields, sopnode.FieldActionLabel)
  9098. }
  9099. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  9100. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  9101. m.sop_stage = &id
  9102. }
  9103. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  9104. func (m *SopNodeMutation) ClearSopStage() {
  9105. m.clearedsop_stage = true
  9106. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  9107. }
  9108. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  9109. func (m *SopNodeMutation) SopStageCleared() bool {
  9110. return m.clearedsop_stage
  9111. }
  9112. // SopStageID returns the "sop_stage" edge ID in the mutation.
  9113. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  9114. if m.sop_stage != nil {
  9115. return *m.sop_stage, true
  9116. }
  9117. return
  9118. }
  9119. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  9120. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  9121. // SopStageID instead. It exists only for internal usage by the builders.
  9122. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  9123. if id := m.sop_stage; id != nil {
  9124. ids = append(ids, *id)
  9125. }
  9126. return
  9127. }
  9128. // ResetSopStage resets all changes to the "sop_stage" edge.
  9129. func (m *SopNodeMutation) ResetSopStage() {
  9130. m.sop_stage = nil
  9131. m.clearedsop_stage = false
  9132. }
  9133. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  9134. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  9135. if m.node_messages == nil {
  9136. m.node_messages = make(map[uint64]struct{})
  9137. }
  9138. for i := range ids {
  9139. m.node_messages[ids[i]] = struct{}{}
  9140. }
  9141. }
  9142. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  9143. func (m *SopNodeMutation) ClearNodeMessages() {
  9144. m.clearednode_messages = true
  9145. }
  9146. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  9147. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  9148. return m.clearednode_messages
  9149. }
  9150. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  9151. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  9152. if m.removednode_messages == nil {
  9153. m.removednode_messages = make(map[uint64]struct{})
  9154. }
  9155. for i := range ids {
  9156. delete(m.node_messages, ids[i])
  9157. m.removednode_messages[ids[i]] = struct{}{}
  9158. }
  9159. }
  9160. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  9161. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  9162. for id := range m.removednode_messages {
  9163. ids = append(ids, id)
  9164. }
  9165. return
  9166. }
  9167. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  9168. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  9169. for id := range m.node_messages {
  9170. ids = append(ids, id)
  9171. }
  9172. return
  9173. }
  9174. // ResetNodeMessages resets all changes to the "node_messages" edge.
  9175. func (m *SopNodeMutation) ResetNodeMessages() {
  9176. m.node_messages = nil
  9177. m.clearednode_messages = false
  9178. m.removednode_messages = nil
  9179. }
  9180. // Where appends a list predicates to the SopNodeMutation builder.
  9181. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  9182. m.predicates = append(m.predicates, ps...)
  9183. }
  9184. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  9185. // users can use type-assertion to append predicates that do not depend on any generated package.
  9186. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  9187. p := make([]predicate.SopNode, len(ps))
  9188. for i := range ps {
  9189. p[i] = ps[i]
  9190. }
  9191. m.Where(p...)
  9192. }
  9193. // Op returns the operation name.
  9194. func (m *SopNodeMutation) Op() Op {
  9195. return m.op
  9196. }
  9197. // SetOp allows setting the mutation operation.
  9198. func (m *SopNodeMutation) SetOp(op Op) {
  9199. m.op = op
  9200. }
  9201. // Type returns the node type of this mutation (SopNode).
  9202. func (m *SopNodeMutation) Type() string {
  9203. return m.typ
  9204. }
  9205. // Fields returns all fields that were changed during this mutation. Note that in
  9206. // order to get all numeric fields that were incremented/decremented, call
  9207. // AddedFields().
  9208. func (m *SopNodeMutation) Fields() []string {
  9209. fields := make([]string, 0, 12)
  9210. if m.created_at != nil {
  9211. fields = append(fields, sopnode.FieldCreatedAt)
  9212. }
  9213. if m.updated_at != nil {
  9214. fields = append(fields, sopnode.FieldUpdatedAt)
  9215. }
  9216. if m.status != nil {
  9217. fields = append(fields, sopnode.FieldStatus)
  9218. }
  9219. if m.deleted_at != nil {
  9220. fields = append(fields, sopnode.FieldDeletedAt)
  9221. }
  9222. if m.sop_stage != nil {
  9223. fields = append(fields, sopnode.FieldStageID)
  9224. }
  9225. if m.parent_id != nil {
  9226. fields = append(fields, sopnode.FieldParentID)
  9227. }
  9228. if m.name != nil {
  9229. fields = append(fields, sopnode.FieldName)
  9230. }
  9231. if m.condition_type != nil {
  9232. fields = append(fields, sopnode.FieldConditionType)
  9233. }
  9234. if m.condition_list != nil {
  9235. fields = append(fields, sopnode.FieldConditionList)
  9236. }
  9237. if m.no_reply_condition != nil {
  9238. fields = append(fields, sopnode.FieldNoReplyCondition)
  9239. }
  9240. if m.action_message != nil {
  9241. fields = append(fields, sopnode.FieldActionMessage)
  9242. }
  9243. if m.action_label != nil {
  9244. fields = append(fields, sopnode.FieldActionLabel)
  9245. }
  9246. return fields
  9247. }
  9248. // Field returns the value of a field with the given name. The second boolean
  9249. // return value indicates that this field was not set, or was not defined in the
  9250. // schema.
  9251. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  9252. switch name {
  9253. case sopnode.FieldCreatedAt:
  9254. return m.CreatedAt()
  9255. case sopnode.FieldUpdatedAt:
  9256. return m.UpdatedAt()
  9257. case sopnode.FieldStatus:
  9258. return m.Status()
  9259. case sopnode.FieldDeletedAt:
  9260. return m.DeletedAt()
  9261. case sopnode.FieldStageID:
  9262. return m.StageID()
  9263. case sopnode.FieldParentID:
  9264. return m.ParentID()
  9265. case sopnode.FieldName:
  9266. return m.Name()
  9267. case sopnode.FieldConditionType:
  9268. return m.ConditionType()
  9269. case sopnode.FieldConditionList:
  9270. return m.ConditionList()
  9271. case sopnode.FieldNoReplyCondition:
  9272. return m.NoReplyCondition()
  9273. case sopnode.FieldActionMessage:
  9274. return m.ActionMessage()
  9275. case sopnode.FieldActionLabel:
  9276. return m.ActionLabel()
  9277. }
  9278. return nil, false
  9279. }
  9280. // OldField returns the old value of the field from the database. An error is
  9281. // returned if the mutation operation is not UpdateOne, or the query to the
  9282. // database failed.
  9283. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9284. switch name {
  9285. case sopnode.FieldCreatedAt:
  9286. return m.OldCreatedAt(ctx)
  9287. case sopnode.FieldUpdatedAt:
  9288. return m.OldUpdatedAt(ctx)
  9289. case sopnode.FieldStatus:
  9290. return m.OldStatus(ctx)
  9291. case sopnode.FieldDeletedAt:
  9292. return m.OldDeletedAt(ctx)
  9293. case sopnode.FieldStageID:
  9294. return m.OldStageID(ctx)
  9295. case sopnode.FieldParentID:
  9296. return m.OldParentID(ctx)
  9297. case sopnode.FieldName:
  9298. return m.OldName(ctx)
  9299. case sopnode.FieldConditionType:
  9300. return m.OldConditionType(ctx)
  9301. case sopnode.FieldConditionList:
  9302. return m.OldConditionList(ctx)
  9303. case sopnode.FieldNoReplyCondition:
  9304. return m.OldNoReplyCondition(ctx)
  9305. case sopnode.FieldActionMessage:
  9306. return m.OldActionMessage(ctx)
  9307. case sopnode.FieldActionLabel:
  9308. return m.OldActionLabel(ctx)
  9309. }
  9310. return nil, fmt.Errorf("unknown SopNode field %s", name)
  9311. }
  9312. // SetField sets the value of a field with the given name. It returns an error if
  9313. // the field is not defined in the schema, or if the type mismatched the field
  9314. // type.
  9315. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  9316. switch name {
  9317. case sopnode.FieldCreatedAt:
  9318. v, ok := value.(time.Time)
  9319. if !ok {
  9320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9321. }
  9322. m.SetCreatedAt(v)
  9323. return nil
  9324. case sopnode.FieldUpdatedAt:
  9325. v, ok := value.(time.Time)
  9326. if !ok {
  9327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9328. }
  9329. m.SetUpdatedAt(v)
  9330. return nil
  9331. case sopnode.FieldStatus:
  9332. v, ok := value.(uint8)
  9333. if !ok {
  9334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9335. }
  9336. m.SetStatus(v)
  9337. return nil
  9338. case sopnode.FieldDeletedAt:
  9339. v, ok := value.(time.Time)
  9340. if !ok {
  9341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9342. }
  9343. m.SetDeletedAt(v)
  9344. return nil
  9345. case sopnode.FieldStageID:
  9346. v, ok := value.(uint64)
  9347. if !ok {
  9348. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9349. }
  9350. m.SetStageID(v)
  9351. return nil
  9352. case sopnode.FieldParentID:
  9353. v, ok := value.(uint64)
  9354. if !ok {
  9355. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9356. }
  9357. m.SetParentID(v)
  9358. return nil
  9359. case sopnode.FieldName:
  9360. v, ok := value.(string)
  9361. if !ok {
  9362. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9363. }
  9364. m.SetName(v)
  9365. return nil
  9366. case sopnode.FieldConditionType:
  9367. v, ok := value.(int)
  9368. if !ok {
  9369. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9370. }
  9371. m.SetConditionType(v)
  9372. return nil
  9373. case sopnode.FieldConditionList:
  9374. v, ok := value.([]string)
  9375. if !ok {
  9376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9377. }
  9378. m.SetConditionList(v)
  9379. return nil
  9380. case sopnode.FieldNoReplyCondition:
  9381. v, ok := value.(uint64)
  9382. if !ok {
  9383. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9384. }
  9385. m.SetNoReplyCondition(v)
  9386. return nil
  9387. case sopnode.FieldActionMessage:
  9388. v, ok := value.([]custom_types.Action)
  9389. if !ok {
  9390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9391. }
  9392. m.SetActionMessage(v)
  9393. return nil
  9394. case sopnode.FieldActionLabel:
  9395. v, ok := value.([]uint64)
  9396. if !ok {
  9397. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9398. }
  9399. m.SetActionLabel(v)
  9400. return nil
  9401. }
  9402. return fmt.Errorf("unknown SopNode field %s", name)
  9403. }
  9404. // AddedFields returns all numeric fields that were incremented/decremented during
  9405. // this mutation.
  9406. func (m *SopNodeMutation) AddedFields() []string {
  9407. var fields []string
  9408. if m.addstatus != nil {
  9409. fields = append(fields, sopnode.FieldStatus)
  9410. }
  9411. if m.addparent_id != nil {
  9412. fields = append(fields, sopnode.FieldParentID)
  9413. }
  9414. if m.addcondition_type != nil {
  9415. fields = append(fields, sopnode.FieldConditionType)
  9416. }
  9417. if m.addno_reply_condition != nil {
  9418. fields = append(fields, sopnode.FieldNoReplyCondition)
  9419. }
  9420. return fields
  9421. }
  9422. // AddedField returns the numeric value that was incremented/decremented on a field
  9423. // with the given name. The second boolean return value indicates that this field
  9424. // was not set, or was not defined in the schema.
  9425. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  9426. switch name {
  9427. case sopnode.FieldStatus:
  9428. return m.AddedStatus()
  9429. case sopnode.FieldParentID:
  9430. return m.AddedParentID()
  9431. case sopnode.FieldConditionType:
  9432. return m.AddedConditionType()
  9433. case sopnode.FieldNoReplyCondition:
  9434. return m.AddedNoReplyCondition()
  9435. }
  9436. return nil, false
  9437. }
  9438. // AddField adds the value to the field with the given name. It returns an error if
  9439. // the field is not defined in the schema, or if the type mismatched the field
  9440. // type.
  9441. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  9442. switch name {
  9443. case sopnode.FieldStatus:
  9444. v, ok := value.(int8)
  9445. if !ok {
  9446. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9447. }
  9448. m.AddStatus(v)
  9449. return nil
  9450. case sopnode.FieldParentID:
  9451. v, ok := value.(int64)
  9452. if !ok {
  9453. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9454. }
  9455. m.AddParentID(v)
  9456. return nil
  9457. case sopnode.FieldConditionType:
  9458. v, ok := value.(int)
  9459. if !ok {
  9460. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9461. }
  9462. m.AddConditionType(v)
  9463. return nil
  9464. case sopnode.FieldNoReplyCondition:
  9465. v, ok := value.(int64)
  9466. if !ok {
  9467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9468. }
  9469. m.AddNoReplyCondition(v)
  9470. return nil
  9471. }
  9472. return fmt.Errorf("unknown SopNode numeric field %s", name)
  9473. }
  9474. // ClearedFields returns all nullable fields that were cleared during this
  9475. // mutation.
  9476. func (m *SopNodeMutation) ClearedFields() []string {
  9477. var fields []string
  9478. if m.FieldCleared(sopnode.FieldStatus) {
  9479. fields = append(fields, sopnode.FieldStatus)
  9480. }
  9481. if m.FieldCleared(sopnode.FieldDeletedAt) {
  9482. fields = append(fields, sopnode.FieldDeletedAt)
  9483. }
  9484. if m.FieldCleared(sopnode.FieldConditionList) {
  9485. fields = append(fields, sopnode.FieldConditionList)
  9486. }
  9487. if m.FieldCleared(sopnode.FieldActionMessage) {
  9488. fields = append(fields, sopnode.FieldActionMessage)
  9489. }
  9490. if m.FieldCleared(sopnode.FieldActionLabel) {
  9491. fields = append(fields, sopnode.FieldActionLabel)
  9492. }
  9493. return fields
  9494. }
  9495. // FieldCleared returns a boolean indicating if a field with the given name was
  9496. // cleared in this mutation.
  9497. func (m *SopNodeMutation) FieldCleared(name string) bool {
  9498. _, ok := m.clearedFields[name]
  9499. return ok
  9500. }
  9501. // ClearField clears the value of the field with the given name. It returns an
  9502. // error if the field is not defined in the schema.
  9503. func (m *SopNodeMutation) ClearField(name string) error {
  9504. switch name {
  9505. case sopnode.FieldStatus:
  9506. m.ClearStatus()
  9507. return nil
  9508. case sopnode.FieldDeletedAt:
  9509. m.ClearDeletedAt()
  9510. return nil
  9511. case sopnode.FieldConditionList:
  9512. m.ClearConditionList()
  9513. return nil
  9514. case sopnode.FieldActionMessage:
  9515. m.ClearActionMessage()
  9516. return nil
  9517. case sopnode.FieldActionLabel:
  9518. m.ClearActionLabel()
  9519. return nil
  9520. }
  9521. return fmt.Errorf("unknown SopNode nullable field %s", name)
  9522. }
  9523. // ResetField resets all changes in the mutation for the field with the given name.
  9524. // It returns an error if the field is not defined in the schema.
  9525. func (m *SopNodeMutation) ResetField(name string) error {
  9526. switch name {
  9527. case sopnode.FieldCreatedAt:
  9528. m.ResetCreatedAt()
  9529. return nil
  9530. case sopnode.FieldUpdatedAt:
  9531. m.ResetUpdatedAt()
  9532. return nil
  9533. case sopnode.FieldStatus:
  9534. m.ResetStatus()
  9535. return nil
  9536. case sopnode.FieldDeletedAt:
  9537. m.ResetDeletedAt()
  9538. return nil
  9539. case sopnode.FieldStageID:
  9540. m.ResetStageID()
  9541. return nil
  9542. case sopnode.FieldParentID:
  9543. m.ResetParentID()
  9544. return nil
  9545. case sopnode.FieldName:
  9546. m.ResetName()
  9547. return nil
  9548. case sopnode.FieldConditionType:
  9549. m.ResetConditionType()
  9550. return nil
  9551. case sopnode.FieldConditionList:
  9552. m.ResetConditionList()
  9553. return nil
  9554. case sopnode.FieldNoReplyCondition:
  9555. m.ResetNoReplyCondition()
  9556. return nil
  9557. case sopnode.FieldActionMessage:
  9558. m.ResetActionMessage()
  9559. return nil
  9560. case sopnode.FieldActionLabel:
  9561. m.ResetActionLabel()
  9562. return nil
  9563. }
  9564. return fmt.Errorf("unknown SopNode field %s", name)
  9565. }
  9566. // AddedEdges returns all edge names that were set/added in this mutation.
  9567. func (m *SopNodeMutation) AddedEdges() []string {
  9568. edges := make([]string, 0, 2)
  9569. if m.sop_stage != nil {
  9570. edges = append(edges, sopnode.EdgeSopStage)
  9571. }
  9572. if m.node_messages != nil {
  9573. edges = append(edges, sopnode.EdgeNodeMessages)
  9574. }
  9575. return edges
  9576. }
  9577. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9578. // name in this mutation.
  9579. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  9580. switch name {
  9581. case sopnode.EdgeSopStage:
  9582. if id := m.sop_stage; id != nil {
  9583. return []ent.Value{*id}
  9584. }
  9585. case sopnode.EdgeNodeMessages:
  9586. ids := make([]ent.Value, 0, len(m.node_messages))
  9587. for id := range m.node_messages {
  9588. ids = append(ids, id)
  9589. }
  9590. return ids
  9591. }
  9592. return nil
  9593. }
  9594. // RemovedEdges returns all edge names that were removed in this mutation.
  9595. func (m *SopNodeMutation) RemovedEdges() []string {
  9596. edges := make([]string, 0, 2)
  9597. if m.removednode_messages != nil {
  9598. edges = append(edges, sopnode.EdgeNodeMessages)
  9599. }
  9600. return edges
  9601. }
  9602. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9603. // the given name in this mutation.
  9604. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  9605. switch name {
  9606. case sopnode.EdgeNodeMessages:
  9607. ids := make([]ent.Value, 0, len(m.removednode_messages))
  9608. for id := range m.removednode_messages {
  9609. ids = append(ids, id)
  9610. }
  9611. return ids
  9612. }
  9613. return nil
  9614. }
  9615. // ClearedEdges returns all edge names that were cleared in this mutation.
  9616. func (m *SopNodeMutation) ClearedEdges() []string {
  9617. edges := make([]string, 0, 2)
  9618. if m.clearedsop_stage {
  9619. edges = append(edges, sopnode.EdgeSopStage)
  9620. }
  9621. if m.clearednode_messages {
  9622. edges = append(edges, sopnode.EdgeNodeMessages)
  9623. }
  9624. return edges
  9625. }
  9626. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9627. // was cleared in this mutation.
  9628. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  9629. switch name {
  9630. case sopnode.EdgeSopStage:
  9631. return m.clearedsop_stage
  9632. case sopnode.EdgeNodeMessages:
  9633. return m.clearednode_messages
  9634. }
  9635. return false
  9636. }
  9637. // ClearEdge clears the value of the edge with the given name. It returns an error
  9638. // if that edge is not defined in the schema.
  9639. func (m *SopNodeMutation) ClearEdge(name string) error {
  9640. switch name {
  9641. case sopnode.EdgeSopStage:
  9642. m.ClearSopStage()
  9643. return nil
  9644. }
  9645. return fmt.Errorf("unknown SopNode unique edge %s", name)
  9646. }
  9647. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9648. // It returns an error if the edge is not defined in the schema.
  9649. func (m *SopNodeMutation) ResetEdge(name string) error {
  9650. switch name {
  9651. case sopnode.EdgeSopStage:
  9652. m.ResetSopStage()
  9653. return nil
  9654. case sopnode.EdgeNodeMessages:
  9655. m.ResetNodeMessages()
  9656. return nil
  9657. }
  9658. return fmt.Errorf("unknown SopNode edge %s", name)
  9659. }
  9660. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  9661. type SopStageMutation struct {
  9662. config
  9663. op Op
  9664. typ string
  9665. id *uint64
  9666. created_at *time.Time
  9667. updated_at *time.Time
  9668. status *uint8
  9669. addstatus *int8
  9670. deleted_at *time.Time
  9671. name *string
  9672. condition_type *int
  9673. addcondition_type *int
  9674. condition_operator *int
  9675. addcondition_operator *int
  9676. condition_list *[]custom_types.Condition
  9677. appendcondition_list []custom_types.Condition
  9678. action_message *[]custom_types.Action
  9679. appendaction_message []custom_types.Action
  9680. action_label *[]uint64
  9681. appendaction_label []uint64
  9682. index_sort *int
  9683. addindex_sort *int
  9684. clearedFields map[string]struct{}
  9685. sop_task *uint64
  9686. clearedsop_task bool
  9687. stage_nodes map[uint64]struct{}
  9688. removedstage_nodes map[uint64]struct{}
  9689. clearedstage_nodes bool
  9690. stage_messages map[uint64]struct{}
  9691. removedstage_messages map[uint64]struct{}
  9692. clearedstage_messages bool
  9693. done bool
  9694. oldValue func(context.Context) (*SopStage, error)
  9695. predicates []predicate.SopStage
  9696. }
  9697. var _ ent.Mutation = (*SopStageMutation)(nil)
  9698. // sopstageOption allows management of the mutation configuration using functional options.
  9699. type sopstageOption func(*SopStageMutation)
  9700. // newSopStageMutation creates new mutation for the SopStage entity.
  9701. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  9702. m := &SopStageMutation{
  9703. config: c,
  9704. op: op,
  9705. typ: TypeSopStage,
  9706. clearedFields: make(map[string]struct{}),
  9707. }
  9708. for _, opt := range opts {
  9709. opt(m)
  9710. }
  9711. return m
  9712. }
  9713. // withSopStageID sets the ID field of the mutation.
  9714. func withSopStageID(id uint64) sopstageOption {
  9715. return func(m *SopStageMutation) {
  9716. var (
  9717. err error
  9718. once sync.Once
  9719. value *SopStage
  9720. )
  9721. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  9722. once.Do(func() {
  9723. if m.done {
  9724. err = errors.New("querying old values post mutation is not allowed")
  9725. } else {
  9726. value, err = m.Client().SopStage.Get(ctx, id)
  9727. }
  9728. })
  9729. return value, err
  9730. }
  9731. m.id = &id
  9732. }
  9733. }
  9734. // withSopStage sets the old SopStage of the mutation.
  9735. func withSopStage(node *SopStage) sopstageOption {
  9736. return func(m *SopStageMutation) {
  9737. m.oldValue = func(context.Context) (*SopStage, error) {
  9738. return node, nil
  9739. }
  9740. m.id = &node.ID
  9741. }
  9742. }
  9743. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9744. // executed in a transaction (ent.Tx), a transactional client is returned.
  9745. func (m SopStageMutation) Client() *Client {
  9746. client := &Client{config: m.config}
  9747. client.init()
  9748. return client
  9749. }
  9750. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9751. // it returns an error otherwise.
  9752. func (m SopStageMutation) Tx() (*Tx, error) {
  9753. if _, ok := m.driver.(*txDriver); !ok {
  9754. return nil, errors.New("ent: mutation is not running in a transaction")
  9755. }
  9756. tx := &Tx{config: m.config}
  9757. tx.init()
  9758. return tx, nil
  9759. }
  9760. // SetID sets the value of the id field. Note that this
  9761. // operation is only accepted on creation of SopStage entities.
  9762. func (m *SopStageMutation) SetID(id uint64) {
  9763. m.id = &id
  9764. }
  9765. // ID returns the ID value in the mutation. Note that the ID is only available
  9766. // if it was provided to the builder or after it was returned from the database.
  9767. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  9768. if m.id == nil {
  9769. return
  9770. }
  9771. return *m.id, true
  9772. }
  9773. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9774. // That means, if the mutation is applied within a transaction with an isolation level such
  9775. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9776. // or updated by the mutation.
  9777. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  9778. switch {
  9779. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9780. id, exists := m.ID()
  9781. if exists {
  9782. return []uint64{id}, nil
  9783. }
  9784. fallthrough
  9785. case m.op.Is(OpUpdate | OpDelete):
  9786. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  9787. default:
  9788. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9789. }
  9790. }
  9791. // SetCreatedAt sets the "created_at" field.
  9792. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  9793. m.created_at = &t
  9794. }
  9795. // CreatedAt returns the value of the "created_at" field in the mutation.
  9796. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  9797. v := m.created_at
  9798. if v == nil {
  9799. return
  9800. }
  9801. return *v, true
  9802. }
  9803. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  9804. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  9805. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9806. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9807. if !m.op.Is(OpUpdateOne) {
  9808. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9809. }
  9810. if m.id == nil || m.oldValue == nil {
  9811. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9812. }
  9813. oldValue, err := m.oldValue(ctx)
  9814. if err != nil {
  9815. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9816. }
  9817. return oldValue.CreatedAt, nil
  9818. }
  9819. // ResetCreatedAt resets all changes to the "created_at" field.
  9820. func (m *SopStageMutation) ResetCreatedAt() {
  9821. m.created_at = nil
  9822. }
  9823. // SetUpdatedAt sets the "updated_at" field.
  9824. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  9825. m.updated_at = &t
  9826. }
  9827. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9828. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  9829. v := m.updated_at
  9830. if v == nil {
  9831. return
  9832. }
  9833. return *v, true
  9834. }
  9835. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  9836. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  9837. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9838. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9839. if !m.op.Is(OpUpdateOne) {
  9840. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9841. }
  9842. if m.id == nil || m.oldValue == nil {
  9843. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9844. }
  9845. oldValue, err := m.oldValue(ctx)
  9846. if err != nil {
  9847. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9848. }
  9849. return oldValue.UpdatedAt, nil
  9850. }
  9851. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9852. func (m *SopStageMutation) ResetUpdatedAt() {
  9853. m.updated_at = nil
  9854. }
  9855. // SetStatus sets the "status" field.
  9856. func (m *SopStageMutation) SetStatus(u uint8) {
  9857. m.status = &u
  9858. m.addstatus = nil
  9859. }
  9860. // Status returns the value of the "status" field in the mutation.
  9861. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  9862. v := m.status
  9863. if v == nil {
  9864. return
  9865. }
  9866. return *v, true
  9867. }
  9868. // OldStatus returns the old "status" field's value of the SopStage entity.
  9869. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  9870. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9871. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  9872. if !m.op.Is(OpUpdateOne) {
  9873. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9874. }
  9875. if m.id == nil || m.oldValue == nil {
  9876. return v, errors.New("OldStatus requires an ID field in the mutation")
  9877. }
  9878. oldValue, err := m.oldValue(ctx)
  9879. if err != nil {
  9880. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9881. }
  9882. return oldValue.Status, nil
  9883. }
  9884. // AddStatus adds u to the "status" field.
  9885. func (m *SopStageMutation) AddStatus(u int8) {
  9886. if m.addstatus != nil {
  9887. *m.addstatus += u
  9888. } else {
  9889. m.addstatus = &u
  9890. }
  9891. }
  9892. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9893. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  9894. v := m.addstatus
  9895. if v == nil {
  9896. return
  9897. }
  9898. return *v, true
  9899. }
  9900. // ClearStatus clears the value of the "status" field.
  9901. func (m *SopStageMutation) ClearStatus() {
  9902. m.status = nil
  9903. m.addstatus = nil
  9904. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  9905. }
  9906. // StatusCleared returns if the "status" field was cleared in this mutation.
  9907. func (m *SopStageMutation) StatusCleared() bool {
  9908. _, ok := m.clearedFields[sopstage.FieldStatus]
  9909. return ok
  9910. }
  9911. // ResetStatus resets all changes to the "status" field.
  9912. func (m *SopStageMutation) ResetStatus() {
  9913. m.status = nil
  9914. m.addstatus = nil
  9915. delete(m.clearedFields, sopstage.FieldStatus)
  9916. }
  9917. // SetDeletedAt sets the "deleted_at" field.
  9918. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  9919. m.deleted_at = &t
  9920. }
  9921. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9922. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  9923. v := m.deleted_at
  9924. if v == nil {
  9925. return
  9926. }
  9927. return *v, true
  9928. }
  9929. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  9930. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  9931. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9932. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9933. if !m.op.Is(OpUpdateOne) {
  9934. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9935. }
  9936. if m.id == nil || m.oldValue == nil {
  9937. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9938. }
  9939. oldValue, err := m.oldValue(ctx)
  9940. if err != nil {
  9941. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9942. }
  9943. return oldValue.DeletedAt, nil
  9944. }
  9945. // ClearDeletedAt clears the value of the "deleted_at" field.
  9946. func (m *SopStageMutation) ClearDeletedAt() {
  9947. m.deleted_at = nil
  9948. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  9949. }
  9950. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9951. func (m *SopStageMutation) DeletedAtCleared() bool {
  9952. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  9953. return ok
  9954. }
  9955. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9956. func (m *SopStageMutation) ResetDeletedAt() {
  9957. m.deleted_at = nil
  9958. delete(m.clearedFields, sopstage.FieldDeletedAt)
  9959. }
  9960. // SetTaskID sets the "task_id" field.
  9961. func (m *SopStageMutation) SetTaskID(u uint64) {
  9962. m.sop_task = &u
  9963. }
  9964. // TaskID returns the value of the "task_id" field in the mutation.
  9965. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  9966. v := m.sop_task
  9967. if v == nil {
  9968. return
  9969. }
  9970. return *v, true
  9971. }
  9972. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  9973. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  9974. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9975. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  9976. if !m.op.Is(OpUpdateOne) {
  9977. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  9978. }
  9979. if m.id == nil || m.oldValue == nil {
  9980. return v, errors.New("OldTaskID requires an ID field in the mutation")
  9981. }
  9982. oldValue, err := m.oldValue(ctx)
  9983. if err != nil {
  9984. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  9985. }
  9986. return oldValue.TaskID, nil
  9987. }
  9988. // ResetTaskID resets all changes to the "task_id" field.
  9989. func (m *SopStageMutation) ResetTaskID() {
  9990. m.sop_task = nil
  9991. }
  9992. // SetName sets the "name" field.
  9993. func (m *SopStageMutation) SetName(s string) {
  9994. m.name = &s
  9995. }
  9996. // Name returns the value of the "name" field in the mutation.
  9997. func (m *SopStageMutation) Name() (r string, exists bool) {
  9998. v := m.name
  9999. if v == nil {
  10000. return
  10001. }
  10002. return *v, true
  10003. }
  10004. // OldName returns the old "name" field's value of the SopStage entity.
  10005. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  10006. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10007. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  10008. if !m.op.Is(OpUpdateOne) {
  10009. return v, errors.New("OldName is only allowed on UpdateOne operations")
  10010. }
  10011. if m.id == nil || m.oldValue == nil {
  10012. return v, errors.New("OldName requires an ID field in the mutation")
  10013. }
  10014. oldValue, err := m.oldValue(ctx)
  10015. if err != nil {
  10016. return v, fmt.Errorf("querying old value for OldName: %w", err)
  10017. }
  10018. return oldValue.Name, nil
  10019. }
  10020. // ResetName resets all changes to the "name" field.
  10021. func (m *SopStageMutation) ResetName() {
  10022. m.name = nil
  10023. }
  10024. // SetConditionType sets the "condition_type" field.
  10025. func (m *SopStageMutation) SetConditionType(i int) {
  10026. m.condition_type = &i
  10027. m.addcondition_type = nil
  10028. }
  10029. // ConditionType returns the value of the "condition_type" field in the mutation.
  10030. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  10031. v := m.condition_type
  10032. if v == nil {
  10033. return
  10034. }
  10035. return *v, true
  10036. }
  10037. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  10038. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  10039. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10040. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  10041. if !m.op.Is(OpUpdateOne) {
  10042. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  10043. }
  10044. if m.id == nil || m.oldValue == nil {
  10045. return v, errors.New("OldConditionType requires an ID field in the mutation")
  10046. }
  10047. oldValue, err := m.oldValue(ctx)
  10048. if err != nil {
  10049. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  10050. }
  10051. return oldValue.ConditionType, nil
  10052. }
  10053. // AddConditionType adds i to the "condition_type" field.
  10054. func (m *SopStageMutation) AddConditionType(i int) {
  10055. if m.addcondition_type != nil {
  10056. *m.addcondition_type += i
  10057. } else {
  10058. m.addcondition_type = &i
  10059. }
  10060. }
  10061. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  10062. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  10063. v := m.addcondition_type
  10064. if v == nil {
  10065. return
  10066. }
  10067. return *v, true
  10068. }
  10069. // ResetConditionType resets all changes to the "condition_type" field.
  10070. func (m *SopStageMutation) ResetConditionType() {
  10071. m.condition_type = nil
  10072. m.addcondition_type = nil
  10073. }
  10074. // SetConditionOperator sets the "condition_operator" field.
  10075. func (m *SopStageMutation) SetConditionOperator(i int) {
  10076. m.condition_operator = &i
  10077. m.addcondition_operator = nil
  10078. }
  10079. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  10080. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  10081. v := m.condition_operator
  10082. if v == nil {
  10083. return
  10084. }
  10085. return *v, true
  10086. }
  10087. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  10088. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  10089. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10090. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  10091. if !m.op.Is(OpUpdateOne) {
  10092. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  10093. }
  10094. if m.id == nil || m.oldValue == nil {
  10095. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  10096. }
  10097. oldValue, err := m.oldValue(ctx)
  10098. if err != nil {
  10099. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  10100. }
  10101. return oldValue.ConditionOperator, nil
  10102. }
  10103. // AddConditionOperator adds i to the "condition_operator" field.
  10104. func (m *SopStageMutation) AddConditionOperator(i int) {
  10105. if m.addcondition_operator != nil {
  10106. *m.addcondition_operator += i
  10107. } else {
  10108. m.addcondition_operator = &i
  10109. }
  10110. }
  10111. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  10112. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  10113. v := m.addcondition_operator
  10114. if v == nil {
  10115. return
  10116. }
  10117. return *v, true
  10118. }
  10119. // ResetConditionOperator resets all changes to the "condition_operator" field.
  10120. func (m *SopStageMutation) ResetConditionOperator() {
  10121. m.condition_operator = nil
  10122. m.addcondition_operator = nil
  10123. }
  10124. // SetConditionList sets the "condition_list" field.
  10125. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  10126. m.condition_list = &ct
  10127. m.appendcondition_list = nil
  10128. }
  10129. // ConditionList returns the value of the "condition_list" field in the mutation.
  10130. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  10131. v := m.condition_list
  10132. if v == nil {
  10133. return
  10134. }
  10135. return *v, true
  10136. }
  10137. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  10138. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  10139. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10140. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  10141. if !m.op.Is(OpUpdateOne) {
  10142. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  10143. }
  10144. if m.id == nil || m.oldValue == nil {
  10145. return v, errors.New("OldConditionList requires an ID field in the mutation")
  10146. }
  10147. oldValue, err := m.oldValue(ctx)
  10148. if err != nil {
  10149. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  10150. }
  10151. return oldValue.ConditionList, nil
  10152. }
  10153. // AppendConditionList adds ct to the "condition_list" field.
  10154. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  10155. m.appendcondition_list = append(m.appendcondition_list, ct...)
  10156. }
  10157. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  10158. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  10159. if len(m.appendcondition_list) == 0 {
  10160. return nil, false
  10161. }
  10162. return m.appendcondition_list, true
  10163. }
  10164. // ResetConditionList resets all changes to the "condition_list" field.
  10165. func (m *SopStageMutation) ResetConditionList() {
  10166. m.condition_list = nil
  10167. m.appendcondition_list = nil
  10168. }
  10169. // SetActionMessage sets the "action_message" field.
  10170. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  10171. m.action_message = &ct
  10172. m.appendaction_message = nil
  10173. }
  10174. // ActionMessage returns the value of the "action_message" field in the mutation.
  10175. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  10176. v := m.action_message
  10177. if v == nil {
  10178. return
  10179. }
  10180. return *v, true
  10181. }
  10182. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  10183. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  10184. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10185. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  10186. if !m.op.Is(OpUpdateOne) {
  10187. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  10188. }
  10189. if m.id == nil || m.oldValue == nil {
  10190. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  10191. }
  10192. oldValue, err := m.oldValue(ctx)
  10193. if err != nil {
  10194. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  10195. }
  10196. return oldValue.ActionMessage, nil
  10197. }
  10198. // AppendActionMessage adds ct to the "action_message" field.
  10199. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  10200. m.appendaction_message = append(m.appendaction_message, ct...)
  10201. }
  10202. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  10203. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  10204. if len(m.appendaction_message) == 0 {
  10205. return nil, false
  10206. }
  10207. return m.appendaction_message, true
  10208. }
  10209. // ClearActionMessage clears the value of the "action_message" field.
  10210. func (m *SopStageMutation) ClearActionMessage() {
  10211. m.action_message = nil
  10212. m.appendaction_message = nil
  10213. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  10214. }
  10215. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  10216. func (m *SopStageMutation) ActionMessageCleared() bool {
  10217. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  10218. return ok
  10219. }
  10220. // ResetActionMessage resets all changes to the "action_message" field.
  10221. func (m *SopStageMutation) ResetActionMessage() {
  10222. m.action_message = nil
  10223. m.appendaction_message = nil
  10224. delete(m.clearedFields, sopstage.FieldActionMessage)
  10225. }
  10226. // SetActionLabel sets the "action_label" field.
  10227. func (m *SopStageMutation) SetActionLabel(u []uint64) {
  10228. m.action_label = &u
  10229. m.appendaction_label = nil
  10230. }
  10231. // ActionLabel returns the value of the "action_label" field in the mutation.
  10232. func (m *SopStageMutation) ActionLabel() (r []uint64, exists bool) {
  10233. v := m.action_label
  10234. if v == nil {
  10235. return
  10236. }
  10237. return *v, true
  10238. }
  10239. // OldActionLabel returns the old "action_label" field's value of the SopStage entity.
  10240. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  10241. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10242. func (m *SopStageMutation) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  10243. if !m.op.Is(OpUpdateOne) {
  10244. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  10245. }
  10246. if m.id == nil || m.oldValue == nil {
  10247. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  10248. }
  10249. oldValue, err := m.oldValue(ctx)
  10250. if err != nil {
  10251. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  10252. }
  10253. return oldValue.ActionLabel, nil
  10254. }
  10255. // AppendActionLabel adds u to the "action_label" field.
  10256. func (m *SopStageMutation) AppendActionLabel(u []uint64) {
  10257. m.appendaction_label = append(m.appendaction_label, u...)
  10258. }
  10259. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  10260. func (m *SopStageMutation) AppendedActionLabel() ([]uint64, bool) {
  10261. if len(m.appendaction_label) == 0 {
  10262. return nil, false
  10263. }
  10264. return m.appendaction_label, true
  10265. }
  10266. // ClearActionLabel clears the value of the "action_label" field.
  10267. func (m *SopStageMutation) ClearActionLabel() {
  10268. m.action_label = nil
  10269. m.appendaction_label = nil
  10270. m.clearedFields[sopstage.FieldActionLabel] = struct{}{}
  10271. }
  10272. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  10273. func (m *SopStageMutation) ActionLabelCleared() bool {
  10274. _, ok := m.clearedFields[sopstage.FieldActionLabel]
  10275. return ok
  10276. }
  10277. // ResetActionLabel resets all changes to the "action_label" field.
  10278. func (m *SopStageMutation) ResetActionLabel() {
  10279. m.action_label = nil
  10280. m.appendaction_label = nil
  10281. delete(m.clearedFields, sopstage.FieldActionLabel)
  10282. }
  10283. // SetIndexSort sets the "index_sort" field.
  10284. func (m *SopStageMutation) SetIndexSort(i int) {
  10285. m.index_sort = &i
  10286. m.addindex_sort = nil
  10287. }
  10288. // IndexSort returns the value of the "index_sort" field in the mutation.
  10289. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  10290. v := m.index_sort
  10291. if v == nil {
  10292. return
  10293. }
  10294. return *v, true
  10295. }
  10296. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  10297. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  10298. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10299. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  10300. if !m.op.Is(OpUpdateOne) {
  10301. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  10302. }
  10303. if m.id == nil || m.oldValue == nil {
  10304. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  10305. }
  10306. oldValue, err := m.oldValue(ctx)
  10307. if err != nil {
  10308. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  10309. }
  10310. return oldValue.IndexSort, nil
  10311. }
  10312. // AddIndexSort adds i to the "index_sort" field.
  10313. func (m *SopStageMutation) AddIndexSort(i int) {
  10314. if m.addindex_sort != nil {
  10315. *m.addindex_sort += i
  10316. } else {
  10317. m.addindex_sort = &i
  10318. }
  10319. }
  10320. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  10321. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  10322. v := m.addindex_sort
  10323. if v == nil {
  10324. return
  10325. }
  10326. return *v, true
  10327. }
  10328. // ClearIndexSort clears the value of the "index_sort" field.
  10329. func (m *SopStageMutation) ClearIndexSort() {
  10330. m.index_sort = nil
  10331. m.addindex_sort = nil
  10332. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  10333. }
  10334. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  10335. func (m *SopStageMutation) IndexSortCleared() bool {
  10336. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  10337. return ok
  10338. }
  10339. // ResetIndexSort resets all changes to the "index_sort" field.
  10340. func (m *SopStageMutation) ResetIndexSort() {
  10341. m.index_sort = nil
  10342. m.addindex_sort = nil
  10343. delete(m.clearedFields, sopstage.FieldIndexSort)
  10344. }
  10345. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  10346. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  10347. m.sop_task = &id
  10348. }
  10349. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  10350. func (m *SopStageMutation) ClearSopTask() {
  10351. m.clearedsop_task = true
  10352. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  10353. }
  10354. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  10355. func (m *SopStageMutation) SopTaskCleared() bool {
  10356. return m.clearedsop_task
  10357. }
  10358. // SopTaskID returns the "sop_task" edge ID in the mutation.
  10359. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  10360. if m.sop_task != nil {
  10361. return *m.sop_task, true
  10362. }
  10363. return
  10364. }
  10365. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  10366. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  10367. // SopTaskID instead. It exists only for internal usage by the builders.
  10368. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  10369. if id := m.sop_task; id != nil {
  10370. ids = append(ids, *id)
  10371. }
  10372. return
  10373. }
  10374. // ResetSopTask resets all changes to the "sop_task" edge.
  10375. func (m *SopStageMutation) ResetSopTask() {
  10376. m.sop_task = nil
  10377. m.clearedsop_task = false
  10378. }
  10379. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  10380. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  10381. if m.stage_nodes == nil {
  10382. m.stage_nodes = make(map[uint64]struct{})
  10383. }
  10384. for i := range ids {
  10385. m.stage_nodes[ids[i]] = struct{}{}
  10386. }
  10387. }
  10388. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  10389. func (m *SopStageMutation) ClearStageNodes() {
  10390. m.clearedstage_nodes = true
  10391. }
  10392. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  10393. func (m *SopStageMutation) StageNodesCleared() bool {
  10394. return m.clearedstage_nodes
  10395. }
  10396. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  10397. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  10398. if m.removedstage_nodes == nil {
  10399. m.removedstage_nodes = make(map[uint64]struct{})
  10400. }
  10401. for i := range ids {
  10402. delete(m.stage_nodes, ids[i])
  10403. m.removedstage_nodes[ids[i]] = struct{}{}
  10404. }
  10405. }
  10406. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  10407. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  10408. for id := range m.removedstage_nodes {
  10409. ids = append(ids, id)
  10410. }
  10411. return
  10412. }
  10413. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  10414. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  10415. for id := range m.stage_nodes {
  10416. ids = append(ids, id)
  10417. }
  10418. return
  10419. }
  10420. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  10421. func (m *SopStageMutation) ResetStageNodes() {
  10422. m.stage_nodes = nil
  10423. m.clearedstage_nodes = false
  10424. m.removedstage_nodes = nil
  10425. }
  10426. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  10427. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  10428. if m.stage_messages == nil {
  10429. m.stage_messages = make(map[uint64]struct{})
  10430. }
  10431. for i := range ids {
  10432. m.stage_messages[ids[i]] = struct{}{}
  10433. }
  10434. }
  10435. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  10436. func (m *SopStageMutation) ClearStageMessages() {
  10437. m.clearedstage_messages = true
  10438. }
  10439. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  10440. func (m *SopStageMutation) StageMessagesCleared() bool {
  10441. return m.clearedstage_messages
  10442. }
  10443. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  10444. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  10445. if m.removedstage_messages == nil {
  10446. m.removedstage_messages = make(map[uint64]struct{})
  10447. }
  10448. for i := range ids {
  10449. delete(m.stage_messages, ids[i])
  10450. m.removedstage_messages[ids[i]] = struct{}{}
  10451. }
  10452. }
  10453. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  10454. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  10455. for id := range m.removedstage_messages {
  10456. ids = append(ids, id)
  10457. }
  10458. return
  10459. }
  10460. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  10461. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  10462. for id := range m.stage_messages {
  10463. ids = append(ids, id)
  10464. }
  10465. return
  10466. }
  10467. // ResetStageMessages resets all changes to the "stage_messages" edge.
  10468. func (m *SopStageMutation) ResetStageMessages() {
  10469. m.stage_messages = nil
  10470. m.clearedstage_messages = false
  10471. m.removedstage_messages = nil
  10472. }
  10473. // Where appends a list predicates to the SopStageMutation builder.
  10474. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  10475. m.predicates = append(m.predicates, ps...)
  10476. }
  10477. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  10478. // users can use type-assertion to append predicates that do not depend on any generated package.
  10479. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  10480. p := make([]predicate.SopStage, len(ps))
  10481. for i := range ps {
  10482. p[i] = ps[i]
  10483. }
  10484. m.Where(p...)
  10485. }
  10486. // Op returns the operation name.
  10487. func (m *SopStageMutation) Op() Op {
  10488. return m.op
  10489. }
  10490. // SetOp allows setting the mutation operation.
  10491. func (m *SopStageMutation) SetOp(op Op) {
  10492. m.op = op
  10493. }
  10494. // Type returns the node type of this mutation (SopStage).
  10495. func (m *SopStageMutation) Type() string {
  10496. return m.typ
  10497. }
  10498. // Fields returns all fields that were changed during this mutation. Note that in
  10499. // order to get all numeric fields that were incremented/decremented, call
  10500. // AddedFields().
  10501. func (m *SopStageMutation) Fields() []string {
  10502. fields := make([]string, 0, 12)
  10503. if m.created_at != nil {
  10504. fields = append(fields, sopstage.FieldCreatedAt)
  10505. }
  10506. if m.updated_at != nil {
  10507. fields = append(fields, sopstage.FieldUpdatedAt)
  10508. }
  10509. if m.status != nil {
  10510. fields = append(fields, sopstage.FieldStatus)
  10511. }
  10512. if m.deleted_at != nil {
  10513. fields = append(fields, sopstage.FieldDeletedAt)
  10514. }
  10515. if m.sop_task != nil {
  10516. fields = append(fields, sopstage.FieldTaskID)
  10517. }
  10518. if m.name != nil {
  10519. fields = append(fields, sopstage.FieldName)
  10520. }
  10521. if m.condition_type != nil {
  10522. fields = append(fields, sopstage.FieldConditionType)
  10523. }
  10524. if m.condition_operator != nil {
  10525. fields = append(fields, sopstage.FieldConditionOperator)
  10526. }
  10527. if m.condition_list != nil {
  10528. fields = append(fields, sopstage.FieldConditionList)
  10529. }
  10530. if m.action_message != nil {
  10531. fields = append(fields, sopstage.FieldActionMessage)
  10532. }
  10533. if m.action_label != nil {
  10534. fields = append(fields, sopstage.FieldActionLabel)
  10535. }
  10536. if m.index_sort != nil {
  10537. fields = append(fields, sopstage.FieldIndexSort)
  10538. }
  10539. return fields
  10540. }
  10541. // Field returns the value of a field with the given name. The second boolean
  10542. // return value indicates that this field was not set, or was not defined in the
  10543. // schema.
  10544. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  10545. switch name {
  10546. case sopstage.FieldCreatedAt:
  10547. return m.CreatedAt()
  10548. case sopstage.FieldUpdatedAt:
  10549. return m.UpdatedAt()
  10550. case sopstage.FieldStatus:
  10551. return m.Status()
  10552. case sopstage.FieldDeletedAt:
  10553. return m.DeletedAt()
  10554. case sopstage.FieldTaskID:
  10555. return m.TaskID()
  10556. case sopstage.FieldName:
  10557. return m.Name()
  10558. case sopstage.FieldConditionType:
  10559. return m.ConditionType()
  10560. case sopstage.FieldConditionOperator:
  10561. return m.ConditionOperator()
  10562. case sopstage.FieldConditionList:
  10563. return m.ConditionList()
  10564. case sopstage.FieldActionMessage:
  10565. return m.ActionMessage()
  10566. case sopstage.FieldActionLabel:
  10567. return m.ActionLabel()
  10568. case sopstage.FieldIndexSort:
  10569. return m.IndexSort()
  10570. }
  10571. return nil, false
  10572. }
  10573. // OldField returns the old value of the field from the database. An error is
  10574. // returned if the mutation operation is not UpdateOne, or the query to the
  10575. // database failed.
  10576. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10577. switch name {
  10578. case sopstage.FieldCreatedAt:
  10579. return m.OldCreatedAt(ctx)
  10580. case sopstage.FieldUpdatedAt:
  10581. return m.OldUpdatedAt(ctx)
  10582. case sopstage.FieldStatus:
  10583. return m.OldStatus(ctx)
  10584. case sopstage.FieldDeletedAt:
  10585. return m.OldDeletedAt(ctx)
  10586. case sopstage.FieldTaskID:
  10587. return m.OldTaskID(ctx)
  10588. case sopstage.FieldName:
  10589. return m.OldName(ctx)
  10590. case sopstage.FieldConditionType:
  10591. return m.OldConditionType(ctx)
  10592. case sopstage.FieldConditionOperator:
  10593. return m.OldConditionOperator(ctx)
  10594. case sopstage.FieldConditionList:
  10595. return m.OldConditionList(ctx)
  10596. case sopstage.FieldActionMessage:
  10597. return m.OldActionMessage(ctx)
  10598. case sopstage.FieldActionLabel:
  10599. return m.OldActionLabel(ctx)
  10600. case sopstage.FieldIndexSort:
  10601. return m.OldIndexSort(ctx)
  10602. }
  10603. return nil, fmt.Errorf("unknown SopStage field %s", name)
  10604. }
  10605. // SetField sets the value of a field with the given name. It returns an error if
  10606. // the field is not defined in the schema, or if the type mismatched the field
  10607. // type.
  10608. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  10609. switch name {
  10610. case sopstage.FieldCreatedAt:
  10611. v, ok := value.(time.Time)
  10612. if !ok {
  10613. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10614. }
  10615. m.SetCreatedAt(v)
  10616. return nil
  10617. case sopstage.FieldUpdatedAt:
  10618. v, ok := value.(time.Time)
  10619. if !ok {
  10620. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10621. }
  10622. m.SetUpdatedAt(v)
  10623. return nil
  10624. case sopstage.FieldStatus:
  10625. v, ok := value.(uint8)
  10626. if !ok {
  10627. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10628. }
  10629. m.SetStatus(v)
  10630. return nil
  10631. case sopstage.FieldDeletedAt:
  10632. v, ok := value.(time.Time)
  10633. if !ok {
  10634. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10635. }
  10636. m.SetDeletedAt(v)
  10637. return nil
  10638. case sopstage.FieldTaskID:
  10639. v, ok := value.(uint64)
  10640. if !ok {
  10641. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10642. }
  10643. m.SetTaskID(v)
  10644. return nil
  10645. case sopstage.FieldName:
  10646. v, ok := value.(string)
  10647. if !ok {
  10648. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10649. }
  10650. m.SetName(v)
  10651. return nil
  10652. case sopstage.FieldConditionType:
  10653. v, ok := value.(int)
  10654. if !ok {
  10655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10656. }
  10657. m.SetConditionType(v)
  10658. return nil
  10659. case sopstage.FieldConditionOperator:
  10660. v, ok := value.(int)
  10661. if !ok {
  10662. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10663. }
  10664. m.SetConditionOperator(v)
  10665. return nil
  10666. case sopstage.FieldConditionList:
  10667. v, ok := value.([]custom_types.Condition)
  10668. if !ok {
  10669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10670. }
  10671. m.SetConditionList(v)
  10672. return nil
  10673. case sopstage.FieldActionMessage:
  10674. v, ok := value.([]custom_types.Action)
  10675. if !ok {
  10676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10677. }
  10678. m.SetActionMessage(v)
  10679. return nil
  10680. case sopstage.FieldActionLabel:
  10681. v, ok := value.([]uint64)
  10682. if !ok {
  10683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10684. }
  10685. m.SetActionLabel(v)
  10686. return nil
  10687. case sopstage.FieldIndexSort:
  10688. v, ok := value.(int)
  10689. if !ok {
  10690. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10691. }
  10692. m.SetIndexSort(v)
  10693. return nil
  10694. }
  10695. return fmt.Errorf("unknown SopStage field %s", name)
  10696. }
  10697. // AddedFields returns all numeric fields that were incremented/decremented during
  10698. // this mutation.
  10699. func (m *SopStageMutation) AddedFields() []string {
  10700. var fields []string
  10701. if m.addstatus != nil {
  10702. fields = append(fields, sopstage.FieldStatus)
  10703. }
  10704. if m.addcondition_type != nil {
  10705. fields = append(fields, sopstage.FieldConditionType)
  10706. }
  10707. if m.addcondition_operator != nil {
  10708. fields = append(fields, sopstage.FieldConditionOperator)
  10709. }
  10710. if m.addindex_sort != nil {
  10711. fields = append(fields, sopstage.FieldIndexSort)
  10712. }
  10713. return fields
  10714. }
  10715. // AddedField returns the numeric value that was incremented/decremented on a field
  10716. // with the given name. The second boolean return value indicates that this field
  10717. // was not set, or was not defined in the schema.
  10718. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  10719. switch name {
  10720. case sopstage.FieldStatus:
  10721. return m.AddedStatus()
  10722. case sopstage.FieldConditionType:
  10723. return m.AddedConditionType()
  10724. case sopstage.FieldConditionOperator:
  10725. return m.AddedConditionOperator()
  10726. case sopstage.FieldIndexSort:
  10727. return m.AddedIndexSort()
  10728. }
  10729. return nil, false
  10730. }
  10731. // AddField adds the value to the field with the given name. It returns an error if
  10732. // the field is not defined in the schema, or if the type mismatched the field
  10733. // type.
  10734. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  10735. switch name {
  10736. case sopstage.FieldStatus:
  10737. v, ok := value.(int8)
  10738. if !ok {
  10739. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10740. }
  10741. m.AddStatus(v)
  10742. return nil
  10743. case sopstage.FieldConditionType:
  10744. v, ok := value.(int)
  10745. if !ok {
  10746. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10747. }
  10748. m.AddConditionType(v)
  10749. return nil
  10750. case sopstage.FieldConditionOperator:
  10751. v, ok := value.(int)
  10752. if !ok {
  10753. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10754. }
  10755. m.AddConditionOperator(v)
  10756. return nil
  10757. case sopstage.FieldIndexSort:
  10758. v, ok := value.(int)
  10759. if !ok {
  10760. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10761. }
  10762. m.AddIndexSort(v)
  10763. return nil
  10764. }
  10765. return fmt.Errorf("unknown SopStage numeric field %s", name)
  10766. }
  10767. // ClearedFields returns all nullable fields that were cleared during this
  10768. // mutation.
  10769. func (m *SopStageMutation) ClearedFields() []string {
  10770. var fields []string
  10771. if m.FieldCleared(sopstage.FieldStatus) {
  10772. fields = append(fields, sopstage.FieldStatus)
  10773. }
  10774. if m.FieldCleared(sopstage.FieldDeletedAt) {
  10775. fields = append(fields, sopstage.FieldDeletedAt)
  10776. }
  10777. if m.FieldCleared(sopstage.FieldActionMessage) {
  10778. fields = append(fields, sopstage.FieldActionMessage)
  10779. }
  10780. if m.FieldCleared(sopstage.FieldActionLabel) {
  10781. fields = append(fields, sopstage.FieldActionLabel)
  10782. }
  10783. if m.FieldCleared(sopstage.FieldIndexSort) {
  10784. fields = append(fields, sopstage.FieldIndexSort)
  10785. }
  10786. return fields
  10787. }
  10788. // FieldCleared returns a boolean indicating if a field with the given name was
  10789. // cleared in this mutation.
  10790. func (m *SopStageMutation) FieldCleared(name string) bool {
  10791. _, ok := m.clearedFields[name]
  10792. return ok
  10793. }
  10794. // ClearField clears the value of the field with the given name. It returns an
  10795. // error if the field is not defined in the schema.
  10796. func (m *SopStageMutation) ClearField(name string) error {
  10797. switch name {
  10798. case sopstage.FieldStatus:
  10799. m.ClearStatus()
  10800. return nil
  10801. case sopstage.FieldDeletedAt:
  10802. m.ClearDeletedAt()
  10803. return nil
  10804. case sopstage.FieldActionMessage:
  10805. m.ClearActionMessage()
  10806. return nil
  10807. case sopstage.FieldActionLabel:
  10808. m.ClearActionLabel()
  10809. return nil
  10810. case sopstage.FieldIndexSort:
  10811. m.ClearIndexSort()
  10812. return nil
  10813. }
  10814. return fmt.Errorf("unknown SopStage nullable field %s", name)
  10815. }
  10816. // ResetField resets all changes in the mutation for the field with the given name.
  10817. // It returns an error if the field is not defined in the schema.
  10818. func (m *SopStageMutation) ResetField(name string) error {
  10819. switch name {
  10820. case sopstage.FieldCreatedAt:
  10821. m.ResetCreatedAt()
  10822. return nil
  10823. case sopstage.FieldUpdatedAt:
  10824. m.ResetUpdatedAt()
  10825. return nil
  10826. case sopstage.FieldStatus:
  10827. m.ResetStatus()
  10828. return nil
  10829. case sopstage.FieldDeletedAt:
  10830. m.ResetDeletedAt()
  10831. return nil
  10832. case sopstage.FieldTaskID:
  10833. m.ResetTaskID()
  10834. return nil
  10835. case sopstage.FieldName:
  10836. m.ResetName()
  10837. return nil
  10838. case sopstage.FieldConditionType:
  10839. m.ResetConditionType()
  10840. return nil
  10841. case sopstage.FieldConditionOperator:
  10842. m.ResetConditionOperator()
  10843. return nil
  10844. case sopstage.FieldConditionList:
  10845. m.ResetConditionList()
  10846. return nil
  10847. case sopstage.FieldActionMessage:
  10848. m.ResetActionMessage()
  10849. return nil
  10850. case sopstage.FieldActionLabel:
  10851. m.ResetActionLabel()
  10852. return nil
  10853. case sopstage.FieldIndexSort:
  10854. m.ResetIndexSort()
  10855. return nil
  10856. }
  10857. return fmt.Errorf("unknown SopStage field %s", name)
  10858. }
  10859. // AddedEdges returns all edge names that were set/added in this mutation.
  10860. func (m *SopStageMutation) AddedEdges() []string {
  10861. edges := make([]string, 0, 3)
  10862. if m.sop_task != nil {
  10863. edges = append(edges, sopstage.EdgeSopTask)
  10864. }
  10865. if m.stage_nodes != nil {
  10866. edges = append(edges, sopstage.EdgeStageNodes)
  10867. }
  10868. if m.stage_messages != nil {
  10869. edges = append(edges, sopstage.EdgeStageMessages)
  10870. }
  10871. return edges
  10872. }
  10873. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10874. // name in this mutation.
  10875. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  10876. switch name {
  10877. case sopstage.EdgeSopTask:
  10878. if id := m.sop_task; id != nil {
  10879. return []ent.Value{*id}
  10880. }
  10881. case sopstage.EdgeStageNodes:
  10882. ids := make([]ent.Value, 0, len(m.stage_nodes))
  10883. for id := range m.stage_nodes {
  10884. ids = append(ids, id)
  10885. }
  10886. return ids
  10887. case sopstage.EdgeStageMessages:
  10888. ids := make([]ent.Value, 0, len(m.stage_messages))
  10889. for id := range m.stage_messages {
  10890. ids = append(ids, id)
  10891. }
  10892. return ids
  10893. }
  10894. return nil
  10895. }
  10896. // RemovedEdges returns all edge names that were removed in this mutation.
  10897. func (m *SopStageMutation) RemovedEdges() []string {
  10898. edges := make([]string, 0, 3)
  10899. if m.removedstage_nodes != nil {
  10900. edges = append(edges, sopstage.EdgeStageNodes)
  10901. }
  10902. if m.removedstage_messages != nil {
  10903. edges = append(edges, sopstage.EdgeStageMessages)
  10904. }
  10905. return edges
  10906. }
  10907. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10908. // the given name in this mutation.
  10909. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  10910. switch name {
  10911. case sopstage.EdgeStageNodes:
  10912. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  10913. for id := range m.removedstage_nodes {
  10914. ids = append(ids, id)
  10915. }
  10916. return ids
  10917. case sopstage.EdgeStageMessages:
  10918. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  10919. for id := range m.removedstage_messages {
  10920. ids = append(ids, id)
  10921. }
  10922. return ids
  10923. }
  10924. return nil
  10925. }
  10926. // ClearedEdges returns all edge names that were cleared in this mutation.
  10927. func (m *SopStageMutation) ClearedEdges() []string {
  10928. edges := make([]string, 0, 3)
  10929. if m.clearedsop_task {
  10930. edges = append(edges, sopstage.EdgeSopTask)
  10931. }
  10932. if m.clearedstage_nodes {
  10933. edges = append(edges, sopstage.EdgeStageNodes)
  10934. }
  10935. if m.clearedstage_messages {
  10936. edges = append(edges, sopstage.EdgeStageMessages)
  10937. }
  10938. return edges
  10939. }
  10940. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10941. // was cleared in this mutation.
  10942. func (m *SopStageMutation) EdgeCleared(name string) bool {
  10943. switch name {
  10944. case sopstage.EdgeSopTask:
  10945. return m.clearedsop_task
  10946. case sopstage.EdgeStageNodes:
  10947. return m.clearedstage_nodes
  10948. case sopstage.EdgeStageMessages:
  10949. return m.clearedstage_messages
  10950. }
  10951. return false
  10952. }
  10953. // ClearEdge clears the value of the edge with the given name. It returns an error
  10954. // if that edge is not defined in the schema.
  10955. func (m *SopStageMutation) ClearEdge(name string) error {
  10956. switch name {
  10957. case sopstage.EdgeSopTask:
  10958. m.ClearSopTask()
  10959. return nil
  10960. }
  10961. return fmt.Errorf("unknown SopStage unique edge %s", name)
  10962. }
  10963. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10964. // It returns an error if the edge is not defined in the schema.
  10965. func (m *SopStageMutation) ResetEdge(name string) error {
  10966. switch name {
  10967. case sopstage.EdgeSopTask:
  10968. m.ResetSopTask()
  10969. return nil
  10970. case sopstage.EdgeStageNodes:
  10971. m.ResetStageNodes()
  10972. return nil
  10973. case sopstage.EdgeStageMessages:
  10974. m.ResetStageMessages()
  10975. return nil
  10976. }
  10977. return fmt.Errorf("unknown SopStage edge %s", name)
  10978. }
  10979. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  10980. type SopTaskMutation struct {
  10981. config
  10982. op Op
  10983. typ string
  10984. id *uint64
  10985. created_at *time.Time
  10986. updated_at *time.Time
  10987. status *uint8
  10988. addstatus *int8
  10989. deleted_at *time.Time
  10990. name *string
  10991. bot_wxid_list *[]string
  10992. appendbot_wxid_list []string
  10993. _type *int
  10994. add_type *int
  10995. plan_start_time *time.Time
  10996. plan_end_time *time.Time
  10997. creator_id *string
  10998. organization_id *uint64
  10999. addorganization_id *int64
  11000. clearedFields map[string]struct{}
  11001. task_stages map[uint64]struct{}
  11002. removedtask_stages map[uint64]struct{}
  11003. clearedtask_stages bool
  11004. done bool
  11005. oldValue func(context.Context) (*SopTask, error)
  11006. predicates []predicate.SopTask
  11007. }
  11008. var _ ent.Mutation = (*SopTaskMutation)(nil)
  11009. // soptaskOption allows management of the mutation configuration using functional options.
  11010. type soptaskOption func(*SopTaskMutation)
  11011. // newSopTaskMutation creates new mutation for the SopTask entity.
  11012. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  11013. m := &SopTaskMutation{
  11014. config: c,
  11015. op: op,
  11016. typ: TypeSopTask,
  11017. clearedFields: make(map[string]struct{}),
  11018. }
  11019. for _, opt := range opts {
  11020. opt(m)
  11021. }
  11022. return m
  11023. }
  11024. // withSopTaskID sets the ID field of the mutation.
  11025. func withSopTaskID(id uint64) soptaskOption {
  11026. return func(m *SopTaskMutation) {
  11027. var (
  11028. err error
  11029. once sync.Once
  11030. value *SopTask
  11031. )
  11032. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  11033. once.Do(func() {
  11034. if m.done {
  11035. err = errors.New("querying old values post mutation is not allowed")
  11036. } else {
  11037. value, err = m.Client().SopTask.Get(ctx, id)
  11038. }
  11039. })
  11040. return value, err
  11041. }
  11042. m.id = &id
  11043. }
  11044. }
  11045. // withSopTask sets the old SopTask of the mutation.
  11046. func withSopTask(node *SopTask) soptaskOption {
  11047. return func(m *SopTaskMutation) {
  11048. m.oldValue = func(context.Context) (*SopTask, error) {
  11049. return node, nil
  11050. }
  11051. m.id = &node.ID
  11052. }
  11053. }
  11054. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11055. // executed in a transaction (ent.Tx), a transactional client is returned.
  11056. func (m SopTaskMutation) Client() *Client {
  11057. client := &Client{config: m.config}
  11058. client.init()
  11059. return client
  11060. }
  11061. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11062. // it returns an error otherwise.
  11063. func (m SopTaskMutation) Tx() (*Tx, error) {
  11064. if _, ok := m.driver.(*txDriver); !ok {
  11065. return nil, errors.New("ent: mutation is not running in a transaction")
  11066. }
  11067. tx := &Tx{config: m.config}
  11068. tx.init()
  11069. return tx, nil
  11070. }
  11071. // SetID sets the value of the id field. Note that this
  11072. // operation is only accepted on creation of SopTask entities.
  11073. func (m *SopTaskMutation) SetID(id uint64) {
  11074. m.id = &id
  11075. }
  11076. // ID returns the ID value in the mutation. Note that the ID is only available
  11077. // if it was provided to the builder or after it was returned from the database.
  11078. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  11079. if m.id == nil {
  11080. return
  11081. }
  11082. return *m.id, true
  11083. }
  11084. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11085. // That means, if the mutation is applied within a transaction with an isolation level such
  11086. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11087. // or updated by the mutation.
  11088. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  11089. switch {
  11090. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11091. id, exists := m.ID()
  11092. if exists {
  11093. return []uint64{id}, nil
  11094. }
  11095. fallthrough
  11096. case m.op.Is(OpUpdate | OpDelete):
  11097. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  11098. default:
  11099. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11100. }
  11101. }
  11102. // SetCreatedAt sets the "created_at" field.
  11103. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  11104. m.created_at = &t
  11105. }
  11106. // CreatedAt returns the value of the "created_at" field in the mutation.
  11107. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  11108. v := m.created_at
  11109. if v == nil {
  11110. return
  11111. }
  11112. return *v, true
  11113. }
  11114. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  11115. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  11116. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11117. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11118. if !m.op.Is(OpUpdateOne) {
  11119. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11120. }
  11121. if m.id == nil || m.oldValue == nil {
  11122. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11123. }
  11124. oldValue, err := m.oldValue(ctx)
  11125. if err != nil {
  11126. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11127. }
  11128. return oldValue.CreatedAt, nil
  11129. }
  11130. // ResetCreatedAt resets all changes to the "created_at" field.
  11131. func (m *SopTaskMutation) ResetCreatedAt() {
  11132. m.created_at = nil
  11133. }
  11134. // SetUpdatedAt sets the "updated_at" field.
  11135. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  11136. m.updated_at = &t
  11137. }
  11138. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11139. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  11140. v := m.updated_at
  11141. if v == nil {
  11142. return
  11143. }
  11144. return *v, true
  11145. }
  11146. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  11147. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  11148. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11149. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11150. if !m.op.Is(OpUpdateOne) {
  11151. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11152. }
  11153. if m.id == nil || m.oldValue == nil {
  11154. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11155. }
  11156. oldValue, err := m.oldValue(ctx)
  11157. if err != nil {
  11158. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11159. }
  11160. return oldValue.UpdatedAt, nil
  11161. }
  11162. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11163. func (m *SopTaskMutation) ResetUpdatedAt() {
  11164. m.updated_at = nil
  11165. }
  11166. // SetStatus sets the "status" field.
  11167. func (m *SopTaskMutation) SetStatus(u uint8) {
  11168. m.status = &u
  11169. m.addstatus = nil
  11170. }
  11171. // Status returns the value of the "status" field in the mutation.
  11172. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  11173. v := m.status
  11174. if v == nil {
  11175. return
  11176. }
  11177. return *v, true
  11178. }
  11179. // OldStatus returns the old "status" field's value of the SopTask entity.
  11180. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  11181. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11182. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11183. if !m.op.Is(OpUpdateOne) {
  11184. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11185. }
  11186. if m.id == nil || m.oldValue == nil {
  11187. return v, errors.New("OldStatus requires an ID field in the mutation")
  11188. }
  11189. oldValue, err := m.oldValue(ctx)
  11190. if err != nil {
  11191. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11192. }
  11193. return oldValue.Status, nil
  11194. }
  11195. // AddStatus adds u to the "status" field.
  11196. func (m *SopTaskMutation) AddStatus(u int8) {
  11197. if m.addstatus != nil {
  11198. *m.addstatus += u
  11199. } else {
  11200. m.addstatus = &u
  11201. }
  11202. }
  11203. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11204. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  11205. v := m.addstatus
  11206. if v == nil {
  11207. return
  11208. }
  11209. return *v, true
  11210. }
  11211. // ClearStatus clears the value of the "status" field.
  11212. func (m *SopTaskMutation) ClearStatus() {
  11213. m.status = nil
  11214. m.addstatus = nil
  11215. m.clearedFields[soptask.FieldStatus] = struct{}{}
  11216. }
  11217. // StatusCleared returns if the "status" field was cleared in this mutation.
  11218. func (m *SopTaskMutation) StatusCleared() bool {
  11219. _, ok := m.clearedFields[soptask.FieldStatus]
  11220. return ok
  11221. }
  11222. // ResetStatus resets all changes to the "status" field.
  11223. func (m *SopTaskMutation) ResetStatus() {
  11224. m.status = nil
  11225. m.addstatus = nil
  11226. delete(m.clearedFields, soptask.FieldStatus)
  11227. }
  11228. // SetDeletedAt sets the "deleted_at" field.
  11229. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  11230. m.deleted_at = &t
  11231. }
  11232. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11233. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  11234. v := m.deleted_at
  11235. if v == nil {
  11236. return
  11237. }
  11238. return *v, true
  11239. }
  11240. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  11241. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  11242. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11243. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11244. if !m.op.Is(OpUpdateOne) {
  11245. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11246. }
  11247. if m.id == nil || m.oldValue == nil {
  11248. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11249. }
  11250. oldValue, err := m.oldValue(ctx)
  11251. if err != nil {
  11252. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11253. }
  11254. return oldValue.DeletedAt, nil
  11255. }
  11256. // ClearDeletedAt clears the value of the "deleted_at" field.
  11257. func (m *SopTaskMutation) ClearDeletedAt() {
  11258. m.deleted_at = nil
  11259. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  11260. }
  11261. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11262. func (m *SopTaskMutation) DeletedAtCleared() bool {
  11263. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  11264. return ok
  11265. }
  11266. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11267. func (m *SopTaskMutation) ResetDeletedAt() {
  11268. m.deleted_at = nil
  11269. delete(m.clearedFields, soptask.FieldDeletedAt)
  11270. }
  11271. // SetName sets the "name" field.
  11272. func (m *SopTaskMutation) SetName(s string) {
  11273. m.name = &s
  11274. }
  11275. // Name returns the value of the "name" field in the mutation.
  11276. func (m *SopTaskMutation) Name() (r string, exists bool) {
  11277. v := m.name
  11278. if v == nil {
  11279. return
  11280. }
  11281. return *v, true
  11282. }
  11283. // OldName returns the old "name" field's value of the SopTask entity.
  11284. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  11285. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11286. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  11287. if !m.op.Is(OpUpdateOne) {
  11288. return v, errors.New("OldName is only allowed on UpdateOne operations")
  11289. }
  11290. if m.id == nil || m.oldValue == nil {
  11291. return v, errors.New("OldName requires an ID field in the mutation")
  11292. }
  11293. oldValue, err := m.oldValue(ctx)
  11294. if err != nil {
  11295. return v, fmt.Errorf("querying old value for OldName: %w", err)
  11296. }
  11297. return oldValue.Name, nil
  11298. }
  11299. // ResetName resets all changes to the "name" field.
  11300. func (m *SopTaskMutation) ResetName() {
  11301. m.name = nil
  11302. }
  11303. // SetBotWxidList sets the "bot_wxid_list" field.
  11304. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  11305. m.bot_wxid_list = &s
  11306. m.appendbot_wxid_list = nil
  11307. }
  11308. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  11309. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  11310. v := m.bot_wxid_list
  11311. if v == nil {
  11312. return
  11313. }
  11314. return *v, true
  11315. }
  11316. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  11317. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  11318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11319. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  11320. if !m.op.Is(OpUpdateOne) {
  11321. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  11322. }
  11323. if m.id == nil || m.oldValue == nil {
  11324. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  11325. }
  11326. oldValue, err := m.oldValue(ctx)
  11327. if err != nil {
  11328. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  11329. }
  11330. return oldValue.BotWxidList, nil
  11331. }
  11332. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  11333. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  11334. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  11335. }
  11336. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  11337. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  11338. if len(m.appendbot_wxid_list) == 0 {
  11339. return nil, false
  11340. }
  11341. return m.appendbot_wxid_list, true
  11342. }
  11343. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  11344. func (m *SopTaskMutation) ClearBotWxidList() {
  11345. m.bot_wxid_list = nil
  11346. m.appendbot_wxid_list = nil
  11347. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  11348. }
  11349. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  11350. func (m *SopTaskMutation) BotWxidListCleared() bool {
  11351. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  11352. return ok
  11353. }
  11354. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  11355. func (m *SopTaskMutation) ResetBotWxidList() {
  11356. m.bot_wxid_list = nil
  11357. m.appendbot_wxid_list = nil
  11358. delete(m.clearedFields, soptask.FieldBotWxidList)
  11359. }
  11360. // SetType sets the "type" field.
  11361. func (m *SopTaskMutation) SetType(i int) {
  11362. m._type = &i
  11363. m.add_type = nil
  11364. }
  11365. // GetType returns the value of the "type" field in the mutation.
  11366. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  11367. v := m._type
  11368. if v == nil {
  11369. return
  11370. }
  11371. return *v, true
  11372. }
  11373. // OldType returns the old "type" field's value of the SopTask entity.
  11374. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  11375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11376. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  11377. if !m.op.Is(OpUpdateOne) {
  11378. return v, errors.New("OldType is only allowed on UpdateOne operations")
  11379. }
  11380. if m.id == nil || m.oldValue == nil {
  11381. return v, errors.New("OldType requires an ID field in the mutation")
  11382. }
  11383. oldValue, err := m.oldValue(ctx)
  11384. if err != nil {
  11385. return v, fmt.Errorf("querying old value for OldType: %w", err)
  11386. }
  11387. return oldValue.Type, nil
  11388. }
  11389. // AddType adds i to the "type" field.
  11390. func (m *SopTaskMutation) AddType(i int) {
  11391. if m.add_type != nil {
  11392. *m.add_type += i
  11393. } else {
  11394. m.add_type = &i
  11395. }
  11396. }
  11397. // AddedType returns the value that was added to the "type" field in this mutation.
  11398. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  11399. v := m.add_type
  11400. if v == nil {
  11401. return
  11402. }
  11403. return *v, true
  11404. }
  11405. // ResetType resets all changes to the "type" field.
  11406. func (m *SopTaskMutation) ResetType() {
  11407. m._type = nil
  11408. m.add_type = nil
  11409. }
  11410. // SetPlanStartTime sets the "plan_start_time" field.
  11411. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  11412. m.plan_start_time = &t
  11413. }
  11414. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  11415. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  11416. v := m.plan_start_time
  11417. if v == nil {
  11418. return
  11419. }
  11420. return *v, true
  11421. }
  11422. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  11423. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  11424. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11425. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  11426. if !m.op.Is(OpUpdateOne) {
  11427. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  11428. }
  11429. if m.id == nil || m.oldValue == nil {
  11430. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  11431. }
  11432. oldValue, err := m.oldValue(ctx)
  11433. if err != nil {
  11434. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  11435. }
  11436. return oldValue.PlanStartTime, nil
  11437. }
  11438. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  11439. func (m *SopTaskMutation) ClearPlanStartTime() {
  11440. m.plan_start_time = nil
  11441. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  11442. }
  11443. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  11444. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  11445. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  11446. return ok
  11447. }
  11448. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  11449. func (m *SopTaskMutation) ResetPlanStartTime() {
  11450. m.plan_start_time = nil
  11451. delete(m.clearedFields, soptask.FieldPlanStartTime)
  11452. }
  11453. // SetPlanEndTime sets the "plan_end_time" field.
  11454. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  11455. m.plan_end_time = &t
  11456. }
  11457. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  11458. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  11459. v := m.plan_end_time
  11460. if v == nil {
  11461. return
  11462. }
  11463. return *v, true
  11464. }
  11465. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  11466. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  11467. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11468. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  11469. if !m.op.Is(OpUpdateOne) {
  11470. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  11471. }
  11472. if m.id == nil || m.oldValue == nil {
  11473. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  11474. }
  11475. oldValue, err := m.oldValue(ctx)
  11476. if err != nil {
  11477. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  11478. }
  11479. return oldValue.PlanEndTime, nil
  11480. }
  11481. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  11482. func (m *SopTaskMutation) ClearPlanEndTime() {
  11483. m.plan_end_time = nil
  11484. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  11485. }
  11486. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  11487. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  11488. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  11489. return ok
  11490. }
  11491. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  11492. func (m *SopTaskMutation) ResetPlanEndTime() {
  11493. m.plan_end_time = nil
  11494. delete(m.clearedFields, soptask.FieldPlanEndTime)
  11495. }
  11496. // SetCreatorID sets the "creator_id" field.
  11497. func (m *SopTaskMutation) SetCreatorID(s string) {
  11498. m.creator_id = &s
  11499. }
  11500. // CreatorID returns the value of the "creator_id" field in the mutation.
  11501. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  11502. v := m.creator_id
  11503. if v == nil {
  11504. return
  11505. }
  11506. return *v, true
  11507. }
  11508. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  11509. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  11510. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11511. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  11512. if !m.op.Is(OpUpdateOne) {
  11513. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  11514. }
  11515. if m.id == nil || m.oldValue == nil {
  11516. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  11517. }
  11518. oldValue, err := m.oldValue(ctx)
  11519. if err != nil {
  11520. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  11521. }
  11522. return oldValue.CreatorID, nil
  11523. }
  11524. // ClearCreatorID clears the value of the "creator_id" field.
  11525. func (m *SopTaskMutation) ClearCreatorID() {
  11526. m.creator_id = nil
  11527. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  11528. }
  11529. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  11530. func (m *SopTaskMutation) CreatorIDCleared() bool {
  11531. _, ok := m.clearedFields[soptask.FieldCreatorID]
  11532. return ok
  11533. }
  11534. // ResetCreatorID resets all changes to the "creator_id" field.
  11535. func (m *SopTaskMutation) ResetCreatorID() {
  11536. m.creator_id = nil
  11537. delete(m.clearedFields, soptask.FieldCreatorID)
  11538. }
  11539. // SetOrganizationID sets the "organization_id" field.
  11540. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  11541. m.organization_id = &u
  11542. m.addorganization_id = nil
  11543. }
  11544. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11545. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  11546. v := m.organization_id
  11547. if v == nil {
  11548. return
  11549. }
  11550. return *v, true
  11551. }
  11552. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  11553. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  11554. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11555. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11556. if !m.op.Is(OpUpdateOne) {
  11557. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11558. }
  11559. if m.id == nil || m.oldValue == nil {
  11560. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11561. }
  11562. oldValue, err := m.oldValue(ctx)
  11563. if err != nil {
  11564. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11565. }
  11566. return oldValue.OrganizationID, nil
  11567. }
  11568. // AddOrganizationID adds u to the "organization_id" field.
  11569. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  11570. if m.addorganization_id != nil {
  11571. *m.addorganization_id += u
  11572. } else {
  11573. m.addorganization_id = &u
  11574. }
  11575. }
  11576. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11577. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  11578. v := m.addorganization_id
  11579. if v == nil {
  11580. return
  11581. }
  11582. return *v, true
  11583. }
  11584. // ClearOrganizationID clears the value of the "organization_id" field.
  11585. func (m *SopTaskMutation) ClearOrganizationID() {
  11586. m.organization_id = nil
  11587. m.addorganization_id = nil
  11588. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  11589. }
  11590. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11591. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  11592. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  11593. return ok
  11594. }
  11595. // ResetOrganizationID resets all changes to the "organization_id" field.
  11596. func (m *SopTaskMutation) ResetOrganizationID() {
  11597. m.organization_id = nil
  11598. m.addorganization_id = nil
  11599. delete(m.clearedFields, soptask.FieldOrganizationID)
  11600. }
  11601. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  11602. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  11603. if m.task_stages == nil {
  11604. m.task_stages = make(map[uint64]struct{})
  11605. }
  11606. for i := range ids {
  11607. m.task_stages[ids[i]] = struct{}{}
  11608. }
  11609. }
  11610. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  11611. func (m *SopTaskMutation) ClearTaskStages() {
  11612. m.clearedtask_stages = true
  11613. }
  11614. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  11615. func (m *SopTaskMutation) TaskStagesCleared() bool {
  11616. return m.clearedtask_stages
  11617. }
  11618. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  11619. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  11620. if m.removedtask_stages == nil {
  11621. m.removedtask_stages = make(map[uint64]struct{})
  11622. }
  11623. for i := range ids {
  11624. delete(m.task_stages, ids[i])
  11625. m.removedtask_stages[ids[i]] = struct{}{}
  11626. }
  11627. }
  11628. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  11629. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  11630. for id := range m.removedtask_stages {
  11631. ids = append(ids, id)
  11632. }
  11633. return
  11634. }
  11635. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  11636. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  11637. for id := range m.task_stages {
  11638. ids = append(ids, id)
  11639. }
  11640. return
  11641. }
  11642. // ResetTaskStages resets all changes to the "task_stages" edge.
  11643. func (m *SopTaskMutation) ResetTaskStages() {
  11644. m.task_stages = nil
  11645. m.clearedtask_stages = false
  11646. m.removedtask_stages = nil
  11647. }
  11648. // Where appends a list predicates to the SopTaskMutation builder.
  11649. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  11650. m.predicates = append(m.predicates, ps...)
  11651. }
  11652. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  11653. // users can use type-assertion to append predicates that do not depend on any generated package.
  11654. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  11655. p := make([]predicate.SopTask, len(ps))
  11656. for i := range ps {
  11657. p[i] = ps[i]
  11658. }
  11659. m.Where(p...)
  11660. }
  11661. // Op returns the operation name.
  11662. func (m *SopTaskMutation) Op() Op {
  11663. return m.op
  11664. }
  11665. // SetOp allows setting the mutation operation.
  11666. func (m *SopTaskMutation) SetOp(op Op) {
  11667. m.op = op
  11668. }
  11669. // Type returns the node type of this mutation (SopTask).
  11670. func (m *SopTaskMutation) Type() string {
  11671. return m.typ
  11672. }
  11673. // Fields returns all fields that were changed during this mutation. Note that in
  11674. // order to get all numeric fields that were incremented/decremented, call
  11675. // AddedFields().
  11676. func (m *SopTaskMutation) Fields() []string {
  11677. fields := make([]string, 0, 11)
  11678. if m.created_at != nil {
  11679. fields = append(fields, soptask.FieldCreatedAt)
  11680. }
  11681. if m.updated_at != nil {
  11682. fields = append(fields, soptask.FieldUpdatedAt)
  11683. }
  11684. if m.status != nil {
  11685. fields = append(fields, soptask.FieldStatus)
  11686. }
  11687. if m.deleted_at != nil {
  11688. fields = append(fields, soptask.FieldDeletedAt)
  11689. }
  11690. if m.name != nil {
  11691. fields = append(fields, soptask.FieldName)
  11692. }
  11693. if m.bot_wxid_list != nil {
  11694. fields = append(fields, soptask.FieldBotWxidList)
  11695. }
  11696. if m._type != nil {
  11697. fields = append(fields, soptask.FieldType)
  11698. }
  11699. if m.plan_start_time != nil {
  11700. fields = append(fields, soptask.FieldPlanStartTime)
  11701. }
  11702. if m.plan_end_time != nil {
  11703. fields = append(fields, soptask.FieldPlanEndTime)
  11704. }
  11705. if m.creator_id != nil {
  11706. fields = append(fields, soptask.FieldCreatorID)
  11707. }
  11708. if m.organization_id != nil {
  11709. fields = append(fields, soptask.FieldOrganizationID)
  11710. }
  11711. return fields
  11712. }
  11713. // Field returns the value of a field with the given name. The second boolean
  11714. // return value indicates that this field was not set, or was not defined in the
  11715. // schema.
  11716. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  11717. switch name {
  11718. case soptask.FieldCreatedAt:
  11719. return m.CreatedAt()
  11720. case soptask.FieldUpdatedAt:
  11721. return m.UpdatedAt()
  11722. case soptask.FieldStatus:
  11723. return m.Status()
  11724. case soptask.FieldDeletedAt:
  11725. return m.DeletedAt()
  11726. case soptask.FieldName:
  11727. return m.Name()
  11728. case soptask.FieldBotWxidList:
  11729. return m.BotWxidList()
  11730. case soptask.FieldType:
  11731. return m.GetType()
  11732. case soptask.FieldPlanStartTime:
  11733. return m.PlanStartTime()
  11734. case soptask.FieldPlanEndTime:
  11735. return m.PlanEndTime()
  11736. case soptask.FieldCreatorID:
  11737. return m.CreatorID()
  11738. case soptask.FieldOrganizationID:
  11739. return m.OrganizationID()
  11740. }
  11741. return nil, false
  11742. }
  11743. // OldField returns the old value of the field from the database. An error is
  11744. // returned if the mutation operation is not UpdateOne, or the query to the
  11745. // database failed.
  11746. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11747. switch name {
  11748. case soptask.FieldCreatedAt:
  11749. return m.OldCreatedAt(ctx)
  11750. case soptask.FieldUpdatedAt:
  11751. return m.OldUpdatedAt(ctx)
  11752. case soptask.FieldStatus:
  11753. return m.OldStatus(ctx)
  11754. case soptask.FieldDeletedAt:
  11755. return m.OldDeletedAt(ctx)
  11756. case soptask.FieldName:
  11757. return m.OldName(ctx)
  11758. case soptask.FieldBotWxidList:
  11759. return m.OldBotWxidList(ctx)
  11760. case soptask.FieldType:
  11761. return m.OldType(ctx)
  11762. case soptask.FieldPlanStartTime:
  11763. return m.OldPlanStartTime(ctx)
  11764. case soptask.FieldPlanEndTime:
  11765. return m.OldPlanEndTime(ctx)
  11766. case soptask.FieldCreatorID:
  11767. return m.OldCreatorID(ctx)
  11768. case soptask.FieldOrganizationID:
  11769. return m.OldOrganizationID(ctx)
  11770. }
  11771. return nil, fmt.Errorf("unknown SopTask field %s", name)
  11772. }
  11773. // SetField sets the value of a field with the given name. It returns an error if
  11774. // the field is not defined in the schema, or if the type mismatched the field
  11775. // type.
  11776. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  11777. switch name {
  11778. case soptask.FieldCreatedAt:
  11779. v, ok := value.(time.Time)
  11780. if !ok {
  11781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11782. }
  11783. m.SetCreatedAt(v)
  11784. return nil
  11785. case soptask.FieldUpdatedAt:
  11786. v, ok := value.(time.Time)
  11787. if !ok {
  11788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11789. }
  11790. m.SetUpdatedAt(v)
  11791. return nil
  11792. case soptask.FieldStatus:
  11793. v, ok := value.(uint8)
  11794. if !ok {
  11795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11796. }
  11797. m.SetStatus(v)
  11798. return nil
  11799. case soptask.FieldDeletedAt:
  11800. v, ok := value.(time.Time)
  11801. if !ok {
  11802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11803. }
  11804. m.SetDeletedAt(v)
  11805. return nil
  11806. case soptask.FieldName:
  11807. v, ok := value.(string)
  11808. if !ok {
  11809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11810. }
  11811. m.SetName(v)
  11812. return nil
  11813. case soptask.FieldBotWxidList:
  11814. v, ok := value.([]string)
  11815. if !ok {
  11816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11817. }
  11818. m.SetBotWxidList(v)
  11819. return nil
  11820. case soptask.FieldType:
  11821. v, ok := value.(int)
  11822. if !ok {
  11823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11824. }
  11825. m.SetType(v)
  11826. return nil
  11827. case soptask.FieldPlanStartTime:
  11828. v, ok := value.(time.Time)
  11829. if !ok {
  11830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11831. }
  11832. m.SetPlanStartTime(v)
  11833. return nil
  11834. case soptask.FieldPlanEndTime:
  11835. v, ok := value.(time.Time)
  11836. if !ok {
  11837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11838. }
  11839. m.SetPlanEndTime(v)
  11840. return nil
  11841. case soptask.FieldCreatorID:
  11842. v, ok := value.(string)
  11843. if !ok {
  11844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11845. }
  11846. m.SetCreatorID(v)
  11847. return nil
  11848. case soptask.FieldOrganizationID:
  11849. v, ok := value.(uint64)
  11850. if !ok {
  11851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11852. }
  11853. m.SetOrganizationID(v)
  11854. return nil
  11855. }
  11856. return fmt.Errorf("unknown SopTask field %s", name)
  11857. }
  11858. // AddedFields returns all numeric fields that were incremented/decremented during
  11859. // this mutation.
  11860. func (m *SopTaskMutation) AddedFields() []string {
  11861. var fields []string
  11862. if m.addstatus != nil {
  11863. fields = append(fields, soptask.FieldStatus)
  11864. }
  11865. if m.add_type != nil {
  11866. fields = append(fields, soptask.FieldType)
  11867. }
  11868. if m.addorganization_id != nil {
  11869. fields = append(fields, soptask.FieldOrganizationID)
  11870. }
  11871. return fields
  11872. }
  11873. // AddedField returns the numeric value that was incremented/decremented on a field
  11874. // with the given name. The second boolean return value indicates that this field
  11875. // was not set, or was not defined in the schema.
  11876. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  11877. switch name {
  11878. case soptask.FieldStatus:
  11879. return m.AddedStatus()
  11880. case soptask.FieldType:
  11881. return m.AddedType()
  11882. case soptask.FieldOrganizationID:
  11883. return m.AddedOrganizationID()
  11884. }
  11885. return nil, false
  11886. }
  11887. // AddField adds the value to the field with the given name. It returns an error if
  11888. // the field is not defined in the schema, or if the type mismatched the field
  11889. // type.
  11890. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  11891. switch name {
  11892. case soptask.FieldStatus:
  11893. v, ok := value.(int8)
  11894. if !ok {
  11895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11896. }
  11897. m.AddStatus(v)
  11898. return nil
  11899. case soptask.FieldType:
  11900. v, ok := value.(int)
  11901. if !ok {
  11902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11903. }
  11904. m.AddType(v)
  11905. return nil
  11906. case soptask.FieldOrganizationID:
  11907. v, ok := value.(int64)
  11908. if !ok {
  11909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11910. }
  11911. m.AddOrganizationID(v)
  11912. return nil
  11913. }
  11914. return fmt.Errorf("unknown SopTask numeric field %s", name)
  11915. }
  11916. // ClearedFields returns all nullable fields that were cleared during this
  11917. // mutation.
  11918. func (m *SopTaskMutation) ClearedFields() []string {
  11919. var fields []string
  11920. if m.FieldCleared(soptask.FieldStatus) {
  11921. fields = append(fields, soptask.FieldStatus)
  11922. }
  11923. if m.FieldCleared(soptask.FieldDeletedAt) {
  11924. fields = append(fields, soptask.FieldDeletedAt)
  11925. }
  11926. if m.FieldCleared(soptask.FieldBotWxidList) {
  11927. fields = append(fields, soptask.FieldBotWxidList)
  11928. }
  11929. if m.FieldCleared(soptask.FieldPlanStartTime) {
  11930. fields = append(fields, soptask.FieldPlanStartTime)
  11931. }
  11932. if m.FieldCleared(soptask.FieldPlanEndTime) {
  11933. fields = append(fields, soptask.FieldPlanEndTime)
  11934. }
  11935. if m.FieldCleared(soptask.FieldCreatorID) {
  11936. fields = append(fields, soptask.FieldCreatorID)
  11937. }
  11938. if m.FieldCleared(soptask.FieldOrganizationID) {
  11939. fields = append(fields, soptask.FieldOrganizationID)
  11940. }
  11941. return fields
  11942. }
  11943. // FieldCleared returns a boolean indicating if a field with the given name was
  11944. // cleared in this mutation.
  11945. func (m *SopTaskMutation) FieldCleared(name string) bool {
  11946. _, ok := m.clearedFields[name]
  11947. return ok
  11948. }
  11949. // ClearField clears the value of the field with the given name. It returns an
  11950. // error if the field is not defined in the schema.
  11951. func (m *SopTaskMutation) ClearField(name string) error {
  11952. switch name {
  11953. case soptask.FieldStatus:
  11954. m.ClearStatus()
  11955. return nil
  11956. case soptask.FieldDeletedAt:
  11957. m.ClearDeletedAt()
  11958. return nil
  11959. case soptask.FieldBotWxidList:
  11960. m.ClearBotWxidList()
  11961. return nil
  11962. case soptask.FieldPlanStartTime:
  11963. m.ClearPlanStartTime()
  11964. return nil
  11965. case soptask.FieldPlanEndTime:
  11966. m.ClearPlanEndTime()
  11967. return nil
  11968. case soptask.FieldCreatorID:
  11969. m.ClearCreatorID()
  11970. return nil
  11971. case soptask.FieldOrganizationID:
  11972. m.ClearOrganizationID()
  11973. return nil
  11974. }
  11975. return fmt.Errorf("unknown SopTask nullable field %s", name)
  11976. }
  11977. // ResetField resets all changes in the mutation for the field with the given name.
  11978. // It returns an error if the field is not defined in the schema.
  11979. func (m *SopTaskMutation) ResetField(name string) error {
  11980. switch name {
  11981. case soptask.FieldCreatedAt:
  11982. m.ResetCreatedAt()
  11983. return nil
  11984. case soptask.FieldUpdatedAt:
  11985. m.ResetUpdatedAt()
  11986. return nil
  11987. case soptask.FieldStatus:
  11988. m.ResetStatus()
  11989. return nil
  11990. case soptask.FieldDeletedAt:
  11991. m.ResetDeletedAt()
  11992. return nil
  11993. case soptask.FieldName:
  11994. m.ResetName()
  11995. return nil
  11996. case soptask.FieldBotWxidList:
  11997. m.ResetBotWxidList()
  11998. return nil
  11999. case soptask.FieldType:
  12000. m.ResetType()
  12001. return nil
  12002. case soptask.FieldPlanStartTime:
  12003. m.ResetPlanStartTime()
  12004. return nil
  12005. case soptask.FieldPlanEndTime:
  12006. m.ResetPlanEndTime()
  12007. return nil
  12008. case soptask.FieldCreatorID:
  12009. m.ResetCreatorID()
  12010. return nil
  12011. case soptask.FieldOrganizationID:
  12012. m.ResetOrganizationID()
  12013. return nil
  12014. }
  12015. return fmt.Errorf("unknown SopTask field %s", name)
  12016. }
  12017. // AddedEdges returns all edge names that were set/added in this mutation.
  12018. func (m *SopTaskMutation) AddedEdges() []string {
  12019. edges := make([]string, 0, 1)
  12020. if m.task_stages != nil {
  12021. edges = append(edges, soptask.EdgeTaskStages)
  12022. }
  12023. return edges
  12024. }
  12025. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12026. // name in this mutation.
  12027. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  12028. switch name {
  12029. case soptask.EdgeTaskStages:
  12030. ids := make([]ent.Value, 0, len(m.task_stages))
  12031. for id := range m.task_stages {
  12032. ids = append(ids, id)
  12033. }
  12034. return ids
  12035. }
  12036. return nil
  12037. }
  12038. // RemovedEdges returns all edge names that were removed in this mutation.
  12039. func (m *SopTaskMutation) RemovedEdges() []string {
  12040. edges := make([]string, 0, 1)
  12041. if m.removedtask_stages != nil {
  12042. edges = append(edges, soptask.EdgeTaskStages)
  12043. }
  12044. return edges
  12045. }
  12046. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12047. // the given name in this mutation.
  12048. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  12049. switch name {
  12050. case soptask.EdgeTaskStages:
  12051. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  12052. for id := range m.removedtask_stages {
  12053. ids = append(ids, id)
  12054. }
  12055. return ids
  12056. }
  12057. return nil
  12058. }
  12059. // ClearedEdges returns all edge names that were cleared in this mutation.
  12060. func (m *SopTaskMutation) ClearedEdges() []string {
  12061. edges := make([]string, 0, 1)
  12062. if m.clearedtask_stages {
  12063. edges = append(edges, soptask.EdgeTaskStages)
  12064. }
  12065. return edges
  12066. }
  12067. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12068. // was cleared in this mutation.
  12069. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  12070. switch name {
  12071. case soptask.EdgeTaskStages:
  12072. return m.clearedtask_stages
  12073. }
  12074. return false
  12075. }
  12076. // ClearEdge clears the value of the edge with the given name. It returns an error
  12077. // if that edge is not defined in the schema.
  12078. func (m *SopTaskMutation) ClearEdge(name string) error {
  12079. switch name {
  12080. }
  12081. return fmt.Errorf("unknown SopTask unique edge %s", name)
  12082. }
  12083. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12084. // It returns an error if the edge is not defined in the schema.
  12085. func (m *SopTaskMutation) ResetEdge(name string) error {
  12086. switch name {
  12087. case soptask.EdgeTaskStages:
  12088. m.ResetTaskStages()
  12089. return nil
  12090. }
  12091. return fmt.Errorf("unknown SopTask edge %s", name)
  12092. }
  12093. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  12094. type WxMutation struct {
  12095. config
  12096. op Op
  12097. typ string
  12098. id *uint64
  12099. created_at *time.Time
  12100. updated_at *time.Time
  12101. status *uint8
  12102. addstatus *int8
  12103. deleted_at *time.Time
  12104. port *string
  12105. process_id *string
  12106. callback *string
  12107. wxid *string
  12108. account *string
  12109. nickname *string
  12110. tel *string
  12111. head_big *string
  12112. organization_id *uint64
  12113. addorganization_id *int64
  12114. clearedFields map[string]struct{}
  12115. server *uint64
  12116. clearedserver bool
  12117. done bool
  12118. oldValue func(context.Context) (*Wx, error)
  12119. predicates []predicate.Wx
  12120. }
  12121. var _ ent.Mutation = (*WxMutation)(nil)
  12122. // wxOption allows management of the mutation configuration using functional options.
  12123. type wxOption func(*WxMutation)
  12124. // newWxMutation creates new mutation for the Wx entity.
  12125. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  12126. m := &WxMutation{
  12127. config: c,
  12128. op: op,
  12129. typ: TypeWx,
  12130. clearedFields: make(map[string]struct{}),
  12131. }
  12132. for _, opt := range opts {
  12133. opt(m)
  12134. }
  12135. return m
  12136. }
  12137. // withWxID sets the ID field of the mutation.
  12138. func withWxID(id uint64) wxOption {
  12139. return func(m *WxMutation) {
  12140. var (
  12141. err error
  12142. once sync.Once
  12143. value *Wx
  12144. )
  12145. m.oldValue = func(ctx context.Context) (*Wx, error) {
  12146. once.Do(func() {
  12147. if m.done {
  12148. err = errors.New("querying old values post mutation is not allowed")
  12149. } else {
  12150. value, err = m.Client().Wx.Get(ctx, id)
  12151. }
  12152. })
  12153. return value, err
  12154. }
  12155. m.id = &id
  12156. }
  12157. }
  12158. // withWx sets the old Wx of the mutation.
  12159. func withWx(node *Wx) wxOption {
  12160. return func(m *WxMutation) {
  12161. m.oldValue = func(context.Context) (*Wx, error) {
  12162. return node, nil
  12163. }
  12164. m.id = &node.ID
  12165. }
  12166. }
  12167. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12168. // executed in a transaction (ent.Tx), a transactional client is returned.
  12169. func (m WxMutation) Client() *Client {
  12170. client := &Client{config: m.config}
  12171. client.init()
  12172. return client
  12173. }
  12174. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12175. // it returns an error otherwise.
  12176. func (m WxMutation) Tx() (*Tx, error) {
  12177. if _, ok := m.driver.(*txDriver); !ok {
  12178. return nil, errors.New("ent: mutation is not running in a transaction")
  12179. }
  12180. tx := &Tx{config: m.config}
  12181. tx.init()
  12182. return tx, nil
  12183. }
  12184. // SetID sets the value of the id field. Note that this
  12185. // operation is only accepted on creation of Wx entities.
  12186. func (m *WxMutation) SetID(id uint64) {
  12187. m.id = &id
  12188. }
  12189. // ID returns the ID value in the mutation. Note that the ID is only available
  12190. // if it was provided to the builder or after it was returned from the database.
  12191. func (m *WxMutation) ID() (id uint64, exists bool) {
  12192. if m.id == nil {
  12193. return
  12194. }
  12195. return *m.id, true
  12196. }
  12197. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12198. // That means, if the mutation is applied within a transaction with an isolation level such
  12199. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12200. // or updated by the mutation.
  12201. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  12202. switch {
  12203. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12204. id, exists := m.ID()
  12205. if exists {
  12206. return []uint64{id}, nil
  12207. }
  12208. fallthrough
  12209. case m.op.Is(OpUpdate | OpDelete):
  12210. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  12211. default:
  12212. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12213. }
  12214. }
  12215. // SetCreatedAt sets the "created_at" field.
  12216. func (m *WxMutation) SetCreatedAt(t time.Time) {
  12217. m.created_at = &t
  12218. }
  12219. // CreatedAt returns the value of the "created_at" field in the mutation.
  12220. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  12221. v := m.created_at
  12222. if v == nil {
  12223. return
  12224. }
  12225. return *v, true
  12226. }
  12227. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  12228. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  12229. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12230. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12231. if !m.op.Is(OpUpdateOne) {
  12232. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12233. }
  12234. if m.id == nil || m.oldValue == nil {
  12235. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12236. }
  12237. oldValue, err := m.oldValue(ctx)
  12238. if err != nil {
  12239. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12240. }
  12241. return oldValue.CreatedAt, nil
  12242. }
  12243. // ResetCreatedAt resets all changes to the "created_at" field.
  12244. func (m *WxMutation) ResetCreatedAt() {
  12245. m.created_at = nil
  12246. }
  12247. // SetUpdatedAt sets the "updated_at" field.
  12248. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  12249. m.updated_at = &t
  12250. }
  12251. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12252. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  12253. v := m.updated_at
  12254. if v == nil {
  12255. return
  12256. }
  12257. return *v, true
  12258. }
  12259. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  12260. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  12261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12262. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12263. if !m.op.Is(OpUpdateOne) {
  12264. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12265. }
  12266. if m.id == nil || m.oldValue == nil {
  12267. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12268. }
  12269. oldValue, err := m.oldValue(ctx)
  12270. if err != nil {
  12271. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12272. }
  12273. return oldValue.UpdatedAt, nil
  12274. }
  12275. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12276. func (m *WxMutation) ResetUpdatedAt() {
  12277. m.updated_at = nil
  12278. }
  12279. // SetStatus sets the "status" field.
  12280. func (m *WxMutation) SetStatus(u uint8) {
  12281. m.status = &u
  12282. m.addstatus = nil
  12283. }
  12284. // Status returns the value of the "status" field in the mutation.
  12285. func (m *WxMutation) Status() (r uint8, exists bool) {
  12286. v := m.status
  12287. if v == nil {
  12288. return
  12289. }
  12290. return *v, true
  12291. }
  12292. // OldStatus returns the old "status" field's value of the Wx entity.
  12293. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  12294. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12295. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12296. if !m.op.Is(OpUpdateOne) {
  12297. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12298. }
  12299. if m.id == nil || m.oldValue == nil {
  12300. return v, errors.New("OldStatus requires an ID field in the mutation")
  12301. }
  12302. oldValue, err := m.oldValue(ctx)
  12303. if err != nil {
  12304. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12305. }
  12306. return oldValue.Status, nil
  12307. }
  12308. // AddStatus adds u to the "status" field.
  12309. func (m *WxMutation) AddStatus(u int8) {
  12310. if m.addstatus != nil {
  12311. *m.addstatus += u
  12312. } else {
  12313. m.addstatus = &u
  12314. }
  12315. }
  12316. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12317. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  12318. v := m.addstatus
  12319. if v == nil {
  12320. return
  12321. }
  12322. return *v, true
  12323. }
  12324. // ClearStatus clears the value of the "status" field.
  12325. func (m *WxMutation) ClearStatus() {
  12326. m.status = nil
  12327. m.addstatus = nil
  12328. m.clearedFields[wx.FieldStatus] = struct{}{}
  12329. }
  12330. // StatusCleared returns if the "status" field was cleared in this mutation.
  12331. func (m *WxMutation) StatusCleared() bool {
  12332. _, ok := m.clearedFields[wx.FieldStatus]
  12333. return ok
  12334. }
  12335. // ResetStatus resets all changes to the "status" field.
  12336. func (m *WxMutation) ResetStatus() {
  12337. m.status = nil
  12338. m.addstatus = nil
  12339. delete(m.clearedFields, wx.FieldStatus)
  12340. }
  12341. // SetDeletedAt sets the "deleted_at" field.
  12342. func (m *WxMutation) SetDeletedAt(t time.Time) {
  12343. m.deleted_at = &t
  12344. }
  12345. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12346. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  12347. v := m.deleted_at
  12348. if v == nil {
  12349. return
  12350. }
  12351. return *v, true
  12352. }
  12353. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  12354. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  12355. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12356. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12357. if !m.op.Is(OpUpdateOne) {
  12358. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12359. }
  12360. if m.id == nil || m.oldValue == nil {
  12361. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12362. }
  12363. oldValue, err := m.oldValue(ctx)
  12364. if err != nil {
  12365. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12366. }
  12367. return oldValue.DeletedAt, nil
  12368. }
  12369. // ClearDeletedAt clears the value of the "deleted_at" field.
  12370. func (m *WxMutation) ClearDeletedAt() {
  12371. m.deleted_at = nil
  12372. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  12373. }
  12374. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12375. func (m *WxMutation) DeletedAtCleared() bool {
  12376. _, ok := m.clearedFields[wx.FieldDeletedAt]
  12377. return ok
  12378. }
  12379. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12380. func (m *WxMutation) ResetDeletedAt() {
  12381. m.deleted_at = nil
  12382. delete(m.clearedFields, wx.FieldDeletedAt)
  12383. }
  12384. // SetServerID sets the "server_id" field.
  12385. func (m *WxMutation) SetServerID(u uint64) {
  12386. m.server = &u
  12387. }
  12388. // ServerID returns the value of the "server_id" field in the mutation.
  12389. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  12390. v := m.server
  12391. if v == nil {
  12392. return
  12393. }
  12394. return *v, true
  12395. }
  12396. // OldServerID returns the old "server_id" field's value of the Wx entity.
  12397. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  12398. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12399. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  12400. if !m.op.Is(OpUpdateOne) {
  12401. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  12402. }
  12403. if m.id == nil || m.oldValue == nil {
  12404. return v, errors.New("OldServerID requires an ID field in the mutation")
  12405. }
  12406. oldValue, err := m.oldValue(ctx)
  12407. if err != nil {
  12408. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  12409. }
  12410. return oldValue.ServerID, nil
  12411. }
  12412. // ClearServerID clears the value of the "server_id" field.
  12413. func (m *WxMutation) ClearServerID() {
  12414. m.server = nil
  12415. m.clearedFields[wx.FieldServerID] = struct{}{}
  12416. }
  12417. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  12418. func (m *WxMutation) ServerIDCleared() bool {
  12419. _, ok := m.clearedFields[wx.FieldServerID]
  12420. return ok
  12421. }
  12422. // ResetServerID resets all changes to the "server_id" field.
  12423. func (m *WxMutation) ResetServerID() {
  12424. m.server = nil
  12425. delete(m.clearedFields, wx.FieldServerID)
  12426. }
  12427. // SetPort sets the "port" field.
  12428. func (m *WxMutation) SetPort(s string) {
  12429. m.port = &s
  12430. }
  12431. // Port returns the value of the "port" field in the mutation.
  12432. func (m *WxMutation) Port() (r string, exists bool) {
  12433. v := m.port
  12434. if v == nil {
  12435. return
  12436. }
  12437. return *v, true
  12438. }
  12439. // OldPort returns the old "port" field's value of the Wx entity.
  12440. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  12441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12442. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  12443. if !m.op.Is(OpUpdateOne) {
  12444. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  12445. }
  12446. if m.id == nil || m.oldValue == nil {
  12447. return v, errors.New("OldPort requires an ID field in the mutation")
  12448. }
  12449. oldValue, err := m.oldValue(ctx)
  12450. if err != nil {
  12451. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  12452. }
  12453. return oldValue.Port, nil
  12454. }
  12455. // ResetPort resets all changes to the "port" field.
  12456. func (m *WxMutation) ResetPort() {
  12457. m.port = nil
  12458. }
  12459. // SetProcessID sets the "process_id" field.
  12460. func (m *WxMutation) SetProcessID(s string) {
  12461. m.process_id = &s
  12462. }
  12463. // ProcessID returns the value of the "process_id" field in the mutation.
  12464. func (m *WxMutation) ProcessID() (r string, exists bool) {
  12465. v := m.process_id
  12466. if v == nil {
  12467. return
  12468. }
  12469. return *v, true
  12470. }
  12471. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  12472. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  12473. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12474. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  12475. if !m.op.Is(OpUpdateOne) {
  12476. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  12477. }
  12478. if m.id == nil || m.oldValue == nil {
  12479. return v, errors.New("OldProcessID requires an ID field in the mutation")
  12480. }
  12481. oldValue, err := m.oldValue(ctx)
  12482. if err != nil {
  12483. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  12484. }
  12485. return oldValue.ProcessID, nil
  12486. }
  12487. // ResetProcessID resets all changes to the "process_id" field.
  12488. func (m *WxMutation) ResetProcessID() {
  12489. m.process_id = nil
  12490. }
  12491. // SetCallback sets the "callback" field.
  12492. func (m *WxMutation) SetCallback(s string) {
  12493. m.callback = &s
  12494. }
  12495. // Callback returns the value of the "callback" field in the mutation.
  12496. func (m *WxMutation) Callback() (r string, exists bool) {
  12497. v := m.callback
  12498. if v == nil {
  12499. return
  12500. }
  12501. return *v, true
  12502. }
  12503. // OldCallback returns the old "callback" field's value of the Wx entity.
  12504. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  12505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12506. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  12507. if !m.op.Is(OpUpdateOne) {
  12508. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  12509. }
  12510. if m.id == nil || m.oldValue == nil {
  12511. return v, errors.New("OldCallback requires an ID field in the mutation")
  12512. }
  12513. oldValue, err := m.oldValue(ctx)
  12514. if err != nil {
  12515. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  12516. }
  12517. return oldValue.Callback, nil
  12518. }
  12519. // ResetCallback resets all changes to the "callback" field.
  12520. func (m *WxMutation) ResetCallback() {
  12521. m.callback = nil
  12522. }
  12523. // SetWxid sets the "wxid" field.
  12524. func (m *WxMutation) SetWxid(s string) {
  12525. m.wxid = &s
  12526. }
  12527. // Wxid returns the value of the "wxid" field in the mutation.
  12528. func (m *WxMutation) Wxid() (r string, exists bool) {
  12529. v := m.wxid
  12530. if v == nil {
  12531. return
  12532. }
  12533. return *v, true
  12534. }
  12535. // OldWxid returns the old "wxid" field's value of the Wx entity.
  12536. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  12537. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12538. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  12539. if !m.op.Is(OpUpdateOne) {
  12540. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  12541. }
  12542. if m.id == nil || m.oldValue == nil {
  12543. return v, errors.New("OldWxid requires an ID field in the mutation")
  12544. }
  12545. oldValue, err := m.oldValue(ctx)
  12546. if err != nil {
  12547. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  12548. }
  12549. return oldValue.Wxid, nil
  12550. }
  12551. // ResetWxid resets all changes to the "wxid" field.
  12552. func (m *WxMutation) ResetWxid() {
  12553. m.wxid = nil
  12554. }
  12555. // SetAccount sets the "account" field.
  12556. func (m *WxMutation) SetAccount(s string) {
  12557. m.account = &s
  12558. }
  12559. // Account returns the value of the "account" field in the mutation.
  12560. func (m *WxMutation) Account() (r string, exists bool) {
  12561. v := m.account
  12562. if v == nil {
  12563. return
  12564. }
  12565. return *v, true
  12566. }
  12567. // OldAccount returns the old "account" field's value of the Wx entity.
  12568. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  12569. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12570. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  12571. if !m.op.Is(OpUpdateOne) {
  12572. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  12573. }
  12574. if m.id == nil || m.oldValue == nil {
  12575. return v, errors.New("OldAccount requires an ID field in the mutation")
  12576. }
  12577. oldValue, err := m.oldValue(ctx)
  12578. if err != nil {
  12579. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  12580. }
  12581. return oldValue.Account, nil
  12582. }
  12583. // ResetAccount resets all changes to the "account" field.
  12584. func (m *WxMutation) ResetAccount() {
  12585. m.account = nil
  12586. }
  12587. // SetNickname sets the "nickname" field.
  12588. func (m *WxMutation) SetNickname(s string) {
  12589. m.nickname = &s
  12590. }
  12591. // Nickname returns the value of the "nickname" field in the mutation.
  12592. func (m *WxMutation) Nickname() (r string, exists bool) {
  12593. v := m.nickname
  12594. if v == nil {
  12595. return
  12596. }
  12597. return *v, true
  12598. }
  12599. // OldNickname returns the old "nickname" field's value of the Wx entity.
  12600. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  12601. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12602. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  12603. if !m.op.Is(OpUpdateOne) {
  12604. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  12605. }
  12606. if m.id == nil || m.oldValue == nil {
  12607. return v, errors.New("OldNickname requires an ID field in the mutation")
  12608. }
  12609. oldValue, err := m.oldValue(ctx)
  12610. if err != nil {
  12611. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  12612. }
  12613. return oldValue.Nickname, nil
  12614. }
  12615. // ResetNickname resets all changes to the "nickname" field.
  12616. func (m *WxMutation) ResetNickname() {
  12617. m.nickname = nil
  12618. }
  12619. // SetTel sets the "tel" field.
  12620. func (m *WxMutation) SetTel(s string) {
  12621. m.tel = &s
  12622. }
  12623. // Tel returns the value of the "tel" field in the mutation.
  12624. func (m *WxMutation) Tel() (r string, exists bool) {
  12625. v := m.tel
  12626. if v == nil {
  12627. return
  12628. }
  12629. return *v, true
  12630. }
  12631. // OldTel returns the old "tel" field's value of the Wx entity.
  12632. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  12633. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12634. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  12635. if !m.op.Is(OpUpdateOne) {
  12636. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  12637. }
  12638. if m.id == nil || m.oldValue == nil {
  12639. return v, errors.New("OldTel requires an ID field in the mutation")
  12640. }
  12641. oldValue, err := m.oldValue(ctx)
  12642. if err != nil {
  12643. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  12644. }
  12645. return oldValue.Tel, nil
  12646. }
  12647. // ResetTel resets all changes to the "tel" field.
  12648. func (m *WxMutation) ResetTel() {
  12649. m.tel = nil
  12650. }
  12651. // SetHeadBig sets the "head_big" field.
  12652. func (m *WxMutation) SetHeadBig(s string) {
  12653. m.head_big = &s
  12654. }
  12655. // HeadBig returns the value of the "head_big" field in the mutation.
  12656. func (m *WxMutation) HeadBig() (r string, exists bool) {
  12657. v := m.head_big
  12658. if v == nil {
  12659. return
  12660. }
  12661. return *v, true
  12662. }
  12663. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  12664. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  12665. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12666. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  12667. if !m.op.Is(OpUpdateOne) {
  12668. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  12669. }
  12670. if m.id == nil || m.oldValue == nil {
  12671. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  12672. }
  12673. oldValue, err := m.oldValue(ctx)
  12674. if err != nil {
  12675. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  12676. }
  12677. return oldValue.HeadBig, nil
  12678. }
  12679. // ResetHeadBig resets all changes to the "head_big" field.
  12680. func (m *WxMutation) ResetHeadBig() {
  12681. m.head_big = nil
  12682. }
  12683. // SetOrganizationID sets the "organization_id" field.
  12684. func (m *WxMutation) SetOrganizationID(u uint64) {
  12685. m.organization_id = &u
  12686. m.addorganization_id = nil
  12687. }
  12688. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12689. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  12690. v := m.organization_id
  12691. if v == nil {
  12692. return
  12693. }
  12694. return *v, true
  12695. }
  12696. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  12697. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  12698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12699. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12700. if !m.op.Is(OpUpdateOne) {
  12701. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12702. }
  12703. if m.id == nil || m.oldValue == nil {
  12704. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12705. }
  12706. oldValue, err := m.oldValue(ctx)
  12707. if err != nil {
  12708. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12709. }
  12710. return oldValue.OrganizationID, nil
  12711. }
  12712. // AddOrganizationID adds u to the "organization_id" field.
  12713. func (m *WxMutation) AddOrganizationID(u int64) {
  12714. if m.addorganization_id != nil {
  12715. *m.addorganization_id += u
  12716. } else {
  12717. m.addorganization_id = &u
  12718. }
  12719. }
  12720. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12721. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  12722. v := m.addorganization_id
  12723. if v == nil {
  12724. return
  12725. }
  12726. return *v, true
  12727. }
  12728. // ClearOrganizationID clears the value of the "organization_id" field.
  12729. func (m *WxMutation) ClearOrganizationID() {
  12730. m.organization_id = nil
  12731. m.addorganization_id = nil
  12732. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  12733. }
  12734. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  12735. func (m *WxMutation) OrganizationIDCleared() bool {
  12736. _, ok := m.clearedFields[wx.FieldOrganizationID]
  12737. return ok
  12738. }
  12739. // ResetOrganizationID resets all changes to the "organization_id" field.
  12740. func (m *WxMutation) ResetOrganizationID() {
  12741. m.organization_id = nil
  12742. m.addorganization_id = nil
  12743. delete(m.clearedFields, wx.FieldOrganizationID)
  12744. }
  12745. // ClearServer clears the "server" edge to the Server entity.
  12746. func (m *WxMutation) ClearServer() {
  12747. m.clearedserver = true
  12748. m.clearedFields[wx.FieldServerID] = struct{}{}
  12749. }
  12750. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  12751. func (m *WxMutation) ServerCleared() bool {
  12752. return m.ServerIDCleared() || m.clearedserver
  12753. }
  12754. // ServerIDs returns the "server" edge IDs in the mutation.
  12755. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  12756. // ServerID instead. It exists only for internal usage by the builders.
  12757. func (m *WxMutation) ServerIDs() (ids []uint64) {
  12758. if id := m.server; id != nil {
  12759. ids = append(ids, *id)
  12760. }
  12761. return
  12762. }
  12763. // ResetServer resets all changes to the "server" edge.
  12764. func (m *WxMutation) ResetServer() {
  12765. m.server = nil
  12766. m.clearedserver = false
  12767. }
  12768. // Where appends a list predicates to the WxMutation builder.
  12769. func (m *WxMutation) Where(ps ...predicate.Wx) {
  12770. m.predicates = append(m.predicates, ps...)
  12771. }
  12772. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  12773. // users can use type-assertion to append predicates that do not depend on any generated package.
  12774. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  12775. p := make([]predicate.Wx, len(ps))
  12776. for i := range ps {
  12777. p[i] = ps[i]
  12778. }
  12779. m.Where(p...)
  12780. }
  12781. // Op returns the operation name.
  12782. func (m *WxMutation) Op() Op {
  12783. return m.op
  12784. }
  12785. // SetOp allows setting the mutation operation.
  12786. func (m *WxMutation) SetOp(op Op) {
  12787. m.op = op
  12788. }
  12789. // Type returns the node type of this mutation (Wx).
  12790. func (m *WxMutation) Type() string {
  12791. return m.typ
  12792. }
  12793. // Fields returns all fields that were changed during this mutation. Note that in
  12794. // order to get all numeric fields that were incremented/decremented, call
  12795. // AddedFields().
  12796. func (m *WxMutation) Fields() []string {
  12797. fields := make([]string, 0, 14)
  12798. if m.created_at != nil {
  12799. fields = append(fields, wx.FieldCreatedAt)
  12800. }
  12801. if m.updated_at != nil {
  12802. fields = append(fields, wx.FieldUpdatedAt)
  12803. }
  12804. if m.status != nil {
  12805. fields = append(fields, wx.FieldStatus)
  12806. }
  12807. if m.deleted_at != nil {
  12808. fields = append(fields, wx.FieldDeletedAt)
  12809. }
  12810. if m.server != nil {
  12811. fields = append(fields, wx.FieldServerID)
  12812. }
  12813. if m.port != nil {
  12814. fields = append(fields, wx.FieldPort)
  12815. }
  12816. if m.process_id != nil {
  12817. fields = append(fields, wx.FieldProcessID)
  12818. }
  12819. if m.callback != nil {
  12820. fields = append(fields, wx.FieldCallback)
  12821. }
  12822. if m.wxid != nil {
  12823. fields = append(fields, wx.FieldWxid)
  12824. }
  12825. if m.account != nil {
  12826. fields = append(fields, wx.FieldAccount)
  12827. }
  12828. if m.nickname != nil {
  12829. fields = append(fields, wx.FieldNickname)
  12830. }
  12831. if m.tel != nil {
  12832. fields = append(fields, wx.FieldTel)
  12833. }
  12834. if m.head_big != nil {
  12835. fields = append(fields, wx.FieldHeadBig)
  12836. }
  12837. if m.organization_id != nil {
  12838. fields = append(fields, wx.FieldOrganizationID)
  12839. }
  12840. return fields
  12841. }
  12842. // Field returns the value of a field with the given name. The second boolean
  12843. // return value indicates that this field was not set, or was not defined in the
  12844. // schema.
  12845. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  12846. switch name {
  12847. case wx.FieldCreatedAt:
  12848. return m.CreatedAt()
  12849. case wx.FieldUpdatedAt:
  12850. return m.UpdatedAt()
  12851. case wx.FieldStatus:
  12852. return m.Status()
  12853. case wx.FieldDeletedAt:
  12854. return m.DeletedAt()
  12855. case wx.FieldServerID:
  12856. return m.ServerID()
  12857. case wx.FieldPort:
  12858. return m.Port()
  12859. case wx.FieldProcessID:
  12860. return m.ProcessID()
  12861. case wx.FieldCallback:
  12862. return m.Callback()
  12863. case wx.FieldWxid:
  12864. return m.Wxid()
  12865. case wx.FieldAccount:
  12866. return m.Account()
  12867. case wx.FieldNickname:
  12868. return m.Nickname()
  12869. case wx.FieldTel:
  12870. return m.Tel()
  12871. case wx.FieldHeadBig:
  12872. return m.HeadBig()
  12873. case wx.FieldOrganizationID:
  12874. return m.OrganizationID()
  12875. }
  12876. return nil, false
  12877. }
  12878. // OldField returns the old value of the field from the database. An error is
  12879. // returned if the mutation operation is not UpdateOne, or the query to the
  12880. // database failed.
  12881. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12882. switch name {
  12883. case wx.FieldCreatedAt:
  12884. return m.OldCreatedAt(ctx)
  12885. case wx.FieldUpdatedAt:
  12886. return m.OldUpdatedAt(ctx)
  12887. case wx.FieldStatus:
  12888. return m.OldStatus(ctx)
  12889. case wx.FieldDeletedAt:
  12890. return m.OldDeletedAt(ctx)
  12891. case wx.FieldServerID:
  12892. return m.OldServerID(ctx)
  12893. case wx.FieldPort:
  12894. return m.OldPort(ctx)
  12895. case wx.FieldProcessID:
  12896. return m.OldProcessID(ctx)
  12897. case wx.FieldCallback:
  12898. return m.OldCallback(ctx)
  12899. case wx.FieldWxid:
  12900. return m.OldWxid(ctx)
  12901. case wx.FieldAccount:
  12902. return m.OldAccount(ctx)
  12903. case wx.FieldNickname:
  12904. return m.OldNickname(ctx)
  12905. case wx.FieldTel:
  12906. return m.OldTel(ctx)
  12907. case wx.FieldHeadBig:
  12908. return m.OldHeadBig(ctx)
  12909. case wx.FieldOrganizationID:
  12910. return m.OldOrganizationID(ctx)
  12911. }
  12912. return nil, fmt.Errorf("unknown Wx field %s", name)
  12913. }
  12914. // SetField sets the value of a field with the given name. It returns an error if
  12915. // the field is not defined in the schema, or if the type mismatched the field
  12916. // type.
  12917. func (m *WxMutation) SetField(name string, value ent.Value) error {
  12918. switch name {
  12919. case wx.FieldCreatedAt:
  12920. v, ok := value.(time.Time)
  12921. if !ok {
  12922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12923. }
  12924. m.SetCreatedAt(v)
  12925. return nil
  12926. case wx.FieldUpdatedAt:
  12927. v, ok := value.(time.Time)
  12928. if !ok {
  12929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12930. }
  12931. m.SetUpdatedAt(v)
  12932. return nil
  12933. case wx.FieldStatus:
  12934. v, ok := value.(uint8)
  12935. if !ok {
  12936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12937. }
  12938. m.SetStatus(v)
  12939. return nil
  12940. case wx.FieldDeletedAt:
  12941. v, ok := value.(time.Time)
  12942. if !ok {
  12943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12944. }
  12945. m.SetDeletedAt(v)
  12946. return nil
  12947. case wx.FieldServerID:
  12948. v, ok := value.(uint64)
  12949. if !ok {
  12950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12951. }
  12952. m.SetServerID(v)
  12953. return nil
  12954. case wx.FieldPort:
  12955. v, ok := value.(string)
  12956. if !ok {
  12957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12958. }
  12959. m.SetPort(v)
  12960. return nil
  12961. case wx.FieldProcessID:
  12962. v, ok := value.(string)
  12963. if !ok {
  12964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12965. }
  12966. m.SetProcessID(v)
  12967. return nil
  12968. case wx.FieldCallback:
  12969. v, ok := value.(string)
  12970. if !ok {
  12971. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12972. }
  12973. m.SetCallback(v)
  12974. return nil
  12975. case wx.FieldWxid:
  12976. v, ok := value.(string)
  12977. if !ok {
  12978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12979. }
  12980. m.SetWxid(v)
  12981. return nil
  12982. case wx.FieldAccount:
  12983. v, ok := value.(string)
  12984. if !ok {
  12985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12986. }
  12987. m.SetAccount(v)
  12988. return nil
  12989. case wx.FieldNickname:
  12990. v, ok := value.(string)
  12991. if !ok {
  12992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12993. }
  12994. m.SetNickname(v)
  12995. return nil
  12996. case wx.FieldTel:
  12997. v, ok := value.(string)
  12998. if !ok {
  12999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13000. }
  13001. m.SetTel(v)
  13002. return nil
  13003. case wx.FieldHeadBig:
  13004. v, ok := value.(string)
  13005. if !ok {
  13006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13007. }
  13008. m.SetHeadBig(v)
  13009. return nil
  13010. case wx.FieldOrganizationID:
  13011. v, ok := value.(uint64)
  13012. if !ok {
  13013. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13014. }
  13015. m.SetOrganizationID(v)
  13016. return nil
  13017. }
  13018. return fmt.Errorf("unknown Wx field %s", name)
  13019. }
  13020. // AddedFields returns all numeric fields that were incremented/decremented during
  13021. // this mutation.
  13022. func (m *WxMutation) AddedFields() []string {
  13023. var fields []string
  13024. if m.addstatus != nil {
  13025. fields = append(fields, wx.FieldStatus)
  13026. }
  13027. if m.addorganization_id != nil {
  13028. fields = append(fields, wx.FieldOrganizationID)
  13029. }
  13030. return fields
  13031. }
  13032. // AddedField returns the numeric value that was incremented/decremented on a field
  13033. // with the given name. The second boolean return value indicates that this field
  13034. // was not set, or was not defined in the schema.
  13035. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  13036. switch name {
  13037. case wx.FieldStatus:
  13038. return m.AddedStatus()
  13039. case wx.FieldOrganizationID:
  13040. return m.AddedOrganizationID()
  13041. }
  13042. return nil, false
  13043. }
  13044. // AddField adds the value to the field with the given name. It returns an error if
  13045. // the field is not defined in the schema, or if the type mismatched the field
  13046. // type.
  13047. func (m *WxMutation) AddField(name string, value ent.Value) error {
  13048. switch name {
  13049. case wx.FieldStatus:
  13050. v, ok := value.(int8)
  13051. if !ok {
  13052. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13053. }
  13054. m.AddStatus(v)
  13055. return nil
  13056. case wx.FieldOrganizationID:
  13057. v, ok := value.(int64)
  13058. if !ok {
  13059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13060. }
  13061. m.AddOrganizationID(v)
  13062. return nil
  13063. }
  13064. return fmt.Errorf("unknown Wx numeric field %s", name)
  13065. }
  13066. // ClearedFields returns all nullable fields that were cleared during this
  13067. // mutation.
  13068. func (m *WxMutation) ClearedFields() []string {
  13069. var fields []string
  13070. if m.FieldCleared(wx.FieldStatus) {
  13071. fields = append(fields, wx.FieldStatus)
  13072. }
  13073. if m.FieldCleared(wx.FieldDeletedAt) {
  13074. fields = append(fields, wx.FieldDeletedAt)
  13075. }
  13076. if m.FieldCleared(wx.FieldServerID) {
  13077. fields = append(fields, wx.FieldServerID)
  13078. }
  13079. if m.FieldCleared(wx.FieldOrganizationID) {
  13080. fields = append(fields, wx.FieldOrganizationID)
  13081. }
  13082. return fields
  13083. }
  13084. // FieldCleared returns a boolean indicating if a field with the given name was
  13085. // cleared in this mutation.
  13086. func (m *WxMutation) FieldCleared(name string) bool {
  13087. _, ok := m.clearedFields[name]
  13088. return ok
  13089. }
  13090. // ClearField clears the value of the field with the given name. It returns an
  13091. // error if the field is not defined in the schema.
  13092. func (m *WxMutation) ClearField(name string) error {
  13093. switch name {
  13094. case wx.FieldStatus:
  13095. m.ClearStatus()
  13096. return nil
  13097. case wx.FieldDeletedAt:
  13098. m.ClearDeletedAt()
  13099. return nil
  13100. case wx.FieldServerID:
  13101. m.ClearServerID()
  13102. return nil
  13103. case wx.FieldOrganizationID:
  13104. m.ClearOrganizationID()
  13105. return nil
  13106. }
  13107. return fmt.Errorf("unknown Wx nullable field %s", name)
  13108. }
  13109. // ResetField resets all changes in the mutation for the field with the given name.
  13110. // It returns an error if the field is not defined in the schema.
  13111. func (m *WxMutation) ResetField(name string) error {
  13112. switch name {
  13113. case wx.FieldCreatedAt:
  13114. m.ResetCreatedAt()
  13115. return nil
  13116. case wx.FieldUpdatedAt:
  13117. m.ResetUpdatedAt()
  13118. return nil
  13119. case wx.FieldStatus:
  13120. m.ResetStatus()
  13121. return nil
  13122. case wx.FieldDeletedAt:
  13123. m.ResetDeletedAt()
  13124. return nil
  13125. case wx.FieldServerID:
  13126. m.ResetServerID()
  13127. return nil
  13128. case wx.FieldPort:
  13129. m.ResetPort()
  13130. return nil
  13131. case wx.FieldProcessID:
  13132. m.ResetProcessID()
  13133. return nil
  13134. case wx.FieldCallback:
  13135. m.ResetCallback()
  13136. return nil
  13137. case wx.FieldWxid:
  13138. m.ResetWxid()
  13139. return nil
  13140. case wx.FieldAccount:
  13141. m.ResetAccount()
  13142. return nil
  13143. case wx.FieldNickname:
  13144. m.ResetNickname()
  13145. return nil
  13146. case wx.FieldTel:
  13147. m.ResetTel()
  13148. return nil
  13149. case wx.FieldHeadBig:
  13150. m.ResetHeadBig()
  13151. return nil
  13152. case wx.FieldOrganizationID:
  13153. m.ResetOrganizationID()
  13154. return nil
  13155. }
  13156. return fmt.Errorf("unknown Wx field %s", name)
  13157. }
  13158. // AddedEdges returns all edge names that were set/added in this mutation.
  13159. func (m *WxMutation) AddedEdges() []string {
  13160. edges := make([]string, 0, 1)
  13161. if m.server != nil {
  13162. edges = append(edges, wx.EdgeServer)
  13163. }
  13164. return edges
  13165. }
  13166. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13167. // name in this mutation.
  13168. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  13169. switch name {
  13170. case wx.EdgeServer:
  13171. if id := m.server; id != nil {
  13172. return []ent.Value{*id}
  13173. }
  13174. }
  13175. return nil
  13176. }
  13177. // RemovedEdges returns all edge names that were removed in this mutation.
  13178. func (m *WxMutation) RemovedEdges() []string {
  13179. edges := make([]string, 0, 1)
  13180. return edges
  13181. }
  13182. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13183. // the given name in this mutation.
  13184. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  13185. return nil
  13186. }
  13187. // ClearedEdges returns all edge names that were cleared in this mutation.
  13188. func (m *WxMutation) ClearedEdges() []string {
  13189. edges := make([]string, 0, 1)
  13190. if m.clearedserver {
  13191. edges = append(edges, wx.EdgeServer)
  13192. }
  13193. return edges
  13194. }
  13195. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13196. // was cleared in this mutation.
  13197. func (m *WxMutation) EdgeCleared(name string) bool {
  13198. switch name {
  13199. case wx.EdgeServer:
  13200. return m.clearedserver
  13201. }
  13202. return false
  13203. }
  13204. // ClearEdge clears the value of the edge with the given name. It returns an error
  13205. // if that edge is not defined in the schema.
  13206. func (m *WxMutation) ClearEdge(name string) error {
  13207. switch name {
  13208. case wx.EdgeServer:
  13209. m.ClearServer()
  13210. return nil
  13211. }
  13212. return fmt.Errorf("unknown Wx unique edge %s", name)
  13213. }
  13214. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13215. // It returns an error if the edge is not defined in the schema.
  13216. func (m *WxMutation) ResetEdge(name string) error {
  13217. switch name {
  13218. case wx.EdgeServer:
  13219. m.ResetServer()
  13220. return nil
  13221. }
  13222. return fmt.Errorf("unknown Wx edge %s", name)
  13223. }