mutation.go 202 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "sync"
  8. "time"
  9. "entgo.io/ent"
  10. "entgo.io/ent/dialect/sql"
  11. "github.com/suyuan32/simple-admin-job/ent/custom_types"
  12. "github.com/suyuan32/simple-admin-job/ent/messagerecords"
  13. "github.com/suyuan32/simple-admin-job/ent/predicate"
  14. "github.com/suyuan32/simple-admin-job/ent/sopnode"
  15. "github.com/suyuan32/simple-admin-job/ent/sopstage"
  16. "github.com/suyuan32/simple-admin-job/ent/soptask"
  17. "github.com/suyuan32/simple-admin-job/ent/task"
  18. "github.com/suyuan32/simple-admin-job/ent/tasklog"
  19. )
  20. const (
  21. // Operation types.
  22. OpCreate = ent.OpCreate
  23. OpDelete = ent.OpDelete
  24. OpDeleteOne = ent.OpDeleteOne
  25. OpUpdate = ent.OpUpdate
  26. OpUpdateOne = ent.OpUpdateOne
  27. // Node types.
  28. TypeMessageRecords = "MessageRecords"
  29. TypeSopNode = "SopNode"
  30. TypeSopStage = "SopStage"
  31. TypeSopTask = "SopTask"
  32. TypeTask = "Task"
  33. TypeTaskLog = "TaskLog"
  34. )
  35. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  36. type MessageRecordsMutation struct {
  37. config
  38. op Op
  39. typ string
  40. id *uint64
  41. created_at *time.Time
  42. updated_at *time.Time
  43. status *uint8
  44. addstatus *int8
  45. bot_wxid *string
  46. contact_id *uint64
  47. addcontact_id *int64
  48. contact_type *int
  49. addcontact_type *int
  50. contact_wxid *string
  51. content_type *int
  52. addcontent_type *int
  53. content *string
  54. meta *custom_types.Meta
  55. error_detail *string
  56. send_time *time.Time
  57. source_type *int
  58. addsource_type *int
  59. source_id *uint64
  60. addsource_id *int64
  61. sub_source_id *uint64
  62. addsub_source_id *int64
  63. clearedFields map[string]struct{}
  64. done bool
  65. oldValue func(context.Context) (*MessageRecords, error)
  66. predicates []predicate.MessageRecords
  67. }
  68. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  69. // messagerecordsOption allows management of the mutation configuration using functional options.
  70. type messagerecordsOption func(*MessageRecordsMutation)
  71. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  72. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  73. m := &MessageRecordsMutation{
  74. config: c,
  75. op: op,
  76. typ: TypeMessageRecords,
  77. clearedFields: make(map[string]struct{}),
  78. }
  79. for _, opt := range opts {
  80. opt(m)
  81. }
  82. return m
  83. }
  84. // withMessageRecordsID sets the ID field of the mutation.
  85. func withMessageRecordsID(id uint64) messagerecordsOption {
  86. return func(m *MessageRecordsMutation) {
  87. var (
  88. err error
  89. once sync.Once
  90. value *MessageRecords
  91. )
  92. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  93. once.Do(func() {
  94. if m.done {
  95. err = errors.New("querying old values post mutation is not allowed")
  96. } else {
  97. value, err = m.Client().MessageRecords.Get(ctx, id)
  98. }
  99. })
  100. return value, err
  101. }
  102. m.id = &id
  103. }
  104. }
  105. // withMessageRecords sets the old MessageRecords of the mutation.
  106. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  107. return func(m *MessageRecordsMutation) {
  108. m.oldValue = func(context.Context) (*MessageRecords, error) {
  109. return node, nil
  110. }
  111. m.id = &node.ID
  112. }
  113. }
  114. // Client returns a new `ent.Client` from the mutation. If the mutation was
  115. // executed in a transaction (ent.Tx), a transactional client is returned.
  116. func (m MessageRecordsMutation) Client() *Client {
  117. client := &Client{config: m.config}
  118. client.init()
  119. return client
  120. }
  121. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  122. // it returns an error otherwise.
  123. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  124. if _, ok := m.driver.(*txDriver); !ok {
  125. return nil, errors.New("ent: mutation is not running in a transaction")
  126. }
  127. tx := &Tx{config: m.config}
  128. tx.init()
  129. return tx, nil
  130. }
  131. // SetID sets the value of the id field. Note that this
  132. // operation is only accepted on creation of MessageRecords entities.
  133. func (m *MessageRecordsMutation) SetID(id uint64) {
  134. m.id = &id
  135. }
  136. // ID returns the ID value in the mutation. Note that the ID is only available
  137. // if it was provided to the builder or after it was returned from the database.
  138. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  139. if m.id == nil {
  140. return
  141. }
  142. return *m.id, true
  143. }
  144. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  145. // That means, if the mutation is applied within a transaction with an isolation level such
  146. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  147. // or updated by the mutation.
  148. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  149. switch {
  150. case m.op.Is(OpUpdateOne | OpDeleteOne):
  151. id, exists := m.ID()
  152. if exists {
  153. return []uint64{id}, nil
  154. }
  155. fallthrough
  156. case m.op.Is(OpUpdate | OpDelete):
  157. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  158. default:
  159. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  160. }
  161. }
  162. // SetCreatedAt sets the "created_at" field.
  163. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  164. m.created_at = &t
  165. }
  166. // CreatedAt returns the value of the "created_at" field in the mutation.
  167. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  168. v := m.created_at
  169. if v == nil {
  170. return
  171. }
  172. return *v, true
  173. }
  174. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  175. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  176. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  177. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  178. if !m.op.Is(OpUpdateOne) {
  179. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  180. }
  181. if m.id == nil || m.oldValue == nil {
  182. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  183. }
  184. oldValue, err := m.oldValue(ctx)
  185. if err != nil {
  186. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  187. }
  188. return oldValue.CreatedAt, nil
  189. }
  190. // ResetCreatedAt resets all changes to the "created_at" field.
  191. func (m *MessageRecordsMutation) ResetCreatedAt() {
  192. m.created_at = nil
  193. }
  194. // SetUpdatedAt sets the "updated_at" field.
  195. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  196. m.updated_at = &t
  197. }
  198. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  199. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  200. v := m.updated_at
  201. if v == nil {
  202. return
  203. }
  204. return *v, true
  205. }
  206. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  207. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  208. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  209. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  210. if !m.op.Is(OpUpdateOne) {
  211. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  212. }
  213. if m.id == nil || m.oldValue == nil {
  214. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  215. }
  216. oldValue, err := m.oldValue(ctx)
  217. if err != nil {
  218. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  219. }
  220. return oldValue.UpdatedAt, nil
  221. }
  222. // ResetUpdatedAt resets all changes to the "updated_at" field.
  223. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  224. m.updated_at = nil
  225. }
  226. // SetStatus sets the "status" field.
  227. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  228. m.status = &u
  229. m.addstatus = nil
  230. }
  231. // Status returns the value of the "status" field in the mutation.
  232. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  233. v := m.status
  234. if v == nil {
  235. return
  236. }
  237. return *v, true
  238. }
  239. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  240. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  241. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  242. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  243. if !m.op.Is(OpUpdateOne) {
  244. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  245. }
  246. if m.id == nil || m.oldValue == nil {
  247. return v, errors.New("OldStatus requires an ID field in the mutation")
  248. }
  249. oldValue, err := m.oldValue(ctx)
  250. if err != nil {
  251. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  252. }
  253. return oldValue.Status, nil
  254. }
  255. // AddStatus adds u to the "status" field.
  256. func (m *MessageRecordsMutation) AddStatus(u int8) {
  257. if m.addstatus != nil {
  258. *m.addstatus += u
  259. } else {
  260. m.addstatus = &u
  261. }
  262. }
  263. // AddedStatus returns the value that was added to the "status" field in this mutation.
  264. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  265. v := m.addstatus
  266. if v == nil {
  267. return
  268. }
  269. return *v, true
  270. }
  271. // ClearStatus clears the value of the "status" field.
  272. func (m *MessageRecordsMutation) ClearStatus() {
  273. m.status = nil
  274. m.addstatus = nil
  275. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  276. }
  277. // StatusCleared returns if the "status" field was cleared in this mutation.
  278. func (m *MessageRecordsMutation) StatusCleared() bool {
  279. _, ok := m.clearedFields[messagerecords.FieldStatus]
  280. return ok
  281. }
  282. // ResetStatus resets all changes to the "status" field.
  283. func (m *MessageRecordsMutation) ResetStatus() {
  284. m.status = nil
  285. m.addstatus = nil
  286. delete(m.clearedFields, messagerecords.FieldStatus)
  287. }
  288. // SetBotWxid sets the "bot_wxid" field.
  289. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  290. m.bot_wxid = &s
  291. }
  292. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  293. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  294. v := m.bot_wxid
  295. if v == nil {
  296. return
  297. }
  298. return *v, true
  299. }
  300. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  301. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  302. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  303. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  304. if !m.op.Is(OpUpdateOne) {
  305. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  306. }
  307. if m.id == nil || m.oldValue == nil {
  308. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  309. }
  310. oldValue, err := m.oldValue(ctx)
  311. if err != nil {
  312. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  313. }
  314. return oldValue.BotWxid, nil
  315. }
  316. // ResetBotWxid resets all changes to the "bot_wxid" field.
  317. func (m *MessageRecordsMutation) ResetBotWxid() {
  318. m.bot_wxid = nil
  319. }
  320. // SetContactID sets the "contact_id" field.
  321. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  322. m.contact_id = &u
  323. m.addcontact_id = nil
  324. }
  325. // ContactID returns the value of the "contact_id" field in the mutation.
  326. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  327. v := m.contact_id
  328. if v == nil {
  329. return
  330. }
  331. return *v, true
  332. }
  333. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  334. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  336. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  337. if !m.op.Is(OpUpdateOne) {
  338. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  339. }
  340. if m.id == nil || m.oldValue == nil {
  341. return v, errors.New("OldContactID requires an ID field in the mutation")
  342. }
  343. oldValue, err := m.oldValue(ctx)
  344. if err != nil {
  345. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  346. }
  347. return oldValue.ContactID, nil
  348. }
  349. // AddContactID adds u to the "contact_id" field.
  350. func (m *MessageRecordsMutation) AddContactID(u int64) {
  351. if m.addcontact_id != nil {
  352. *m.addcontact_id += u
  353. } else {
  354. m.addcontact_id = &u
  355. }
  356. }
  357. // AddedContactID returns the value that was added to the "contact_id" field in this mutation.
  358. func (m *MessageRecordsMutation) AddedContactID() (r int64, exists bool) {
  359. v := m.addcontact_id
  360. if v == nil {
  361. return
  362. }
  363. return *v, true
  364. }
  365. // ClearContactID clears the value of the "contact_id" field.
  366. func (m *MessageRecordsMutation) ClearContactID() {
  367. m.contact_id = nil
  368. m.addcontact_id = nil
  369. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  370. }
  371. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  372. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  373. _, ok := m.clearedFields[messagerecords.FieldContactID]
  374. return ok
  375. }
  376. // ResetContactID resets all changes to the "contact_id" field.
  377. func (m *MessageRecordsMutation) ResetContactID() {
  378. m.contact_id = nil
  379. m.addcontact_id = nil
  380. delete(m.clearedFields, messagerecords.FieldContactID)
  381. }
  382. // SetContactType sets the "contact_type" field.
  383. func (m *MessageRecordsMutation) SetContactType(i int) {
  384. m.contact_type = &i
  385. m.addcontact_type = nil
  386. }
  387. // ContactType returns the value of the "contact_type" field in the mutation.
  388. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  389. v := m.contact_type
  390. if v == nil {
  391. return
  392. }
  393. return *v, true
  394. }
  395. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  396. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  397. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  398. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  399. if !m.op.Is(OpUpdateOne) {
  400. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  401. }
  402. if m.id == nil || m.oldValue == nil {
  403. return v, errors.New("OldContactType requires an ID field in the mutation")
  404. }
  405. oldValue, err := m.oldValue(ctx)
  406. if err != nil {
  407. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  408. }
  409. return oldValue.ContactType, nil
  410. }
  411. // AddContactType adds i to the "contact_type" field.
  412. func (m *MessageRecordsMutation) AddContactType(i int) {
  413. if m.addcontact_type != nil {
  414. *m.addcontact_type += i
  415. } else {
  416. m.addcontact_type = &i
  417. }
  418. }
  419. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  420. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  421. v := m.addcontact_type
  422. if v == nil {
  423. return
  424. }
  425. return *v, true
  426. }
  427. // ResetContactType resets all changes to the "contact_type" field.
  428. func (m *MessageRecordsMutation) ResetContactType() {
  429. m.contact_type = nil
  430. m.addcontact_type = nil
  431. }
  432. // SetContactWxid sets the "contact_wxid" field.
  433. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  434. m.contact_wxid = &s
  435. }
  436. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  437. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  438. v := m.contact_wxid
  439. if v == nil {
  440. return
  441. }
  442. return *v, true
  443. }
  444. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  445. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  447. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  448. if !m.op.Is(OpUpdateOne) {
  449. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  450. }
  451. if m.id == nil || m.oldValue == nil {
  452. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  453. }
  454. oldValue, err := m.oldValue(ctx)
  455. if err != nil {
  456. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  457. }
  458. return oldValue.ContactWxid, nil
  459. }
  460. // ResetContactWxid resets all changes to the "contact_wxid" field.
  461. func (m *MessageRecordsMutation) ResetContactWxid() {
  462. m.contact_wxid = nil
  463. }
  464. // SetContentType sets the "content_type" field.
  465. func (m *MessageRecordsMutation) SetContentType(i int) {
  466. m.content_type = &i
  467. m.addcontent_type = nil
  468. }
  469. // ContentType returns the value of the "content_type" field in the mutation.
  470. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  471. v := m.content_type
  472. if v == nil {
  473. return
  474. }
  475. return *v, true
  476. }
  477. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  478. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  479. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  480. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  481. if !m.op.Is(OpUpdateOne) {
  482. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  483. }
  484. if m.id == nil || m.oldValue == nil {
  485. return v, errors.New("OldContentType requires an ID field in the mutation")
  486. }
  487. oldValue, err := m.oldValue(ctx)
  488. if err != nil {
  489. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  490. }
  491. return oldValue.ContentType, nil
  492. }
  493. // AddContentType adds i to the "content_type" field.
  494. func (m *MessageRecordsMutation) AddContentType(i int) {
  495. if m.addcontent_type != nil {
  496. *m.addcontent_type += i
  497. } else {
  498. m.addcontent_type = &i
  499. }
  500. }
  501. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  502. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  503. v := m.addcontent_type
  504. if v == nil {
  505. return
  506. }
  507. return *v, true
  508. }
  509. // ResetContentType resets all changes to the "content_type" field.
  510. func (m *MessageRecordsMutation) ResetContentType() {
  511. m.content_type = nil
  512. m.addcontent_type = nil
  513. }
  514. // SetContent sets the "content" field.
  515. func (m *MessageRecordsMutation) SetContent(s string) {
  516. m.content = &s
  517. }
  518. // Content returns the value of the "content" field in the mutation.
  519. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  520. v := m.content
  521. if v == nil {
  522. return
  523. }
  524. return *v, true
  525. }
  526. // OldContent returns the old "content" field's value of the MessageRecords entity.
  527. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  528. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  529. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  530. if !m.op.Is(OpUpdateOne) {
  531. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  532. }
  533. if m.id == nil || m.oldValue == nil {
  534. return v, errors.New("OldContent requires an ID field in the mutation")
  535. }
  536. oldValue, err := m.oldValue(ctx)
  537. if err != nil {
  538. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  539. }
  540. return oldValue.Content, nil
  541. }
  542. // ResetContent resets all changes to the "content" field.
  543. func (m *MessageRecordsMutation) ResetContent() {
  544. m.content = nil
  545. }
  546. // SetMeta sets the "meta" field.
  547. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  548. m.meta = &ct
  549. }
  550. // Meta returns the value of the "meta" field in the mutation.
  551. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  552. v := m.meta
  553. if v == nil {
  554. return
  555. }
  556. return *v, true
  557. }
  558. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  559. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  560. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  561. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  562. if !m.op.Is(OpUpdateOne) {
  563. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  564. }
  565. if m.id == nil || m.oldValue == nil {
  566. return v, errors.New("OldMeta requires an ID field in the mutation")
  567. }
  568. oldValue, err := m.oldValue(ctx)
  569. if err != nil {
  570. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  571. }
  572. return oldValue.Meta, nil
  573. }
  574. // ClearMeta clears the value of the "meta" field.
  575. func (m *MessageRecordsMutation) ClearMeta() {
  576. m.meta = nil
  577. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  578. }
  579. // MetaCleared returns if the "meta" field was cleared in this mutation.
  580. func (m *MessageRecordsMutation) MetaCleared() bool {
  581. _, ok := m.clearedFields[messagerecords.FieldMeta]
  582. return ok
  583. }
  584. // ResetMeta resets all changes to the "meta" field.
  585. func (m *MessageRecordsMutation) ResetMeta() {
  586. m.meta = nil
  587. delete(m.clearedFields, messagerecords.FieldMeta)
  588. }
  589. // SetErrorDetail sets the "error_detail" field.
  590. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  591. m.error_detail = &s
  592. }
  593. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  594. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  595. v := m.error_detail
  596. if v == nil {
  597. return
  598. }
  599. return *v, true
  600. }
  601. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  602. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  604. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  605. if !m.op.Is(OpUpdateOne) {
  606. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  607. }
  608. if m.id == nil || m.oldValue == nil {
  609. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  610. }
  611. oldValue, err := m.oldValue(ctx)
  612. if err != nil {
  613. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  614. }
  615. return oldValue.ErrorDetail, nil
  616. }
  617. // ResetErrorDetail resets all changes to the "error_detail" field.
  618. func (m *MessageRecordsMutation) ResetErrorDetail() {
  619. m.error_detail = nil
  620. }
  621. // SetSendTime sets the "send_time" field.
  622. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  623. m.send_time = &t
  624. }
  625. // SendTime returns the value of the "send_time" field in the mutation.
  626. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  627. v := m.send_time
  628. if v == nil {
  629. return
  630. }
  631. return *v, true
  632. }
  633. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  634. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  636. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  637. if !m.op.Is(OpUpdateOne) {
  638. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  639. }
  640. if m.id == nil || m.oldValue == nil {
  641. return v, errors.New("OldSendTime requires an ID field in the mutation")
  642. }
  643. oldValue, err := m.oldValue(ctx)
  644. if err != nil {
  645. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  646. }
  647. return oldValue.SendTime, nil
  648. }
  649. // ClearSendTime clears the value of the "send_time" field.
  650. func (m *MessageRecordsMutation) ClearSendTime() {
  651. m.send_time = nil
  652. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  653. }
  654. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  655. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  656. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  657. return ok
  658. }
  659. // ResetSendTime resets all changes to the "send_time" field.
  660. func (m *MessageRecordsMutation) ResetSendTime() {
  661. m.send_time = nil
  662. delete(m.clearedFields, messagerecords.FieldSendTime)
  663. }
  664. // SetSourceType sets the "source_type" field.
  665. func (m *MessageRecordsMutation) SetSourceType(i int) {
  666. m.source_type = &i
  667. m.addsource_type = nil
  668. }
  669. // SourceType returns the value of the "source_type" field in the mutation.
  670. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  671. v := m.source_type
  672. if v == nil {
  673. return
  674. }
  675. return *v, true
  676. }
  677. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  678. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  680. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  681. if !m.op.Is(OpUpdateOne) {
  682. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  683. }
  684. if m.id == nil || m.oldValue == nil {
  685. return v, errors.New("OldSourceType requires an ID field in the mutation")
  686. }
  687. oldValue, err := m.oldValue(ctx)
  688. if err != nil {
  689. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  690. }
  691. return oldValue.SourceType, nil
  692. }
  693. // AddSourceType adds i to the "source_type" field.
  694. func (m *MessageRecordsMutation) AddSourceType(i int) {
  695. if m.addsource_type != nil {
  696. *m.addsource_type += i
  697. } else {
  698. m.addsource_type = &i
  699. }
  700. }
  701. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  702. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  703. v := m.addsource_type
  704. if v == nil {
  705. return
  706. }
  707. return *v, true
  708. }
  709. // ResetSourceType resets all changes to the "source_type" field.
  710. func (m *MessageRecordsMutation) ResetSourceType() {
  711. m.source_type = nil
  712. m.addsource_type = nil
  713. }
  714. // SetSourceID sets the "source_id" field.
  715. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  716. m.source_id = &u
  717. m.addsource_id = nil
  718. }
  719. // SourceID returns the value of the "source_id" field in the mutation.
  720. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  721. v := m.source_id
  722. if v == nil {
  723. return
  724. }
  725. return *v, true
  726. }
  727. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  728. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  729. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  730. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  731. if !m.op.Is(OpUpdateOne) {
  732. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  733. }
  734. if m.id == nil || m.oldValue == nil {
  735. return v, errors.New("OldSourceID requires an ID field in the mutation")
  736. }
  737. oldValue, err := m.oldValue(ctx)
  738. if err != nil {
  739. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  740. }
  741. return oldValue.SourceID, nil
  742. }
  743. // AddSourceID adds u to the "source_id" field.
  744. func (m *MessageRecordsMutation) AddSourceID(u int64) {
  745. if m.addsource_id != nil {
  746. *m.addsource_id += u
  747. } else {
  748. m.addsource_id = &u
  749. }
  750. }
  751. // AddedSourceID returns the value that was added to the "source_id" field in this mutation.
  752. func (m *MessageRecordsMutation) AddedSourceID() (r int64, exists bool) {
  753. v := m.addsource_id
  754. if v == nil {
  755. return
  756. }
  757. return *v, true
  758. }
  759. // ClearSourceID clears the value of the "source_id" field.
  760. func (m *MessageRecordsMutation) ClearSourceID() {
  761. m.source_id = nil
  762. m.addsource_id = nil
  763. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  764. }
  765. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  766. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  767. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  768. return ok
  769. }
  770. // ResetSourceID resets all changes to the "source_id" field.
  771. func (m *MessageRecordsMutation) ResetSourceID() {
  772. m.source_id = nil
  773. m.addsource_id = nil
  774. delete(m.clearedFields, messagerecords.FieldSourceID)
  775. }
  776. // SetSubSourceID sets the "sub_source_id" field.
  777. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  778. m.sub_source_id = &u
  779. m.addsub_source_id = nil
  780. }
  781. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  782. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  783. v := m.sub_source_id
  784. if v == nil {
  785. return
  786. }
  787. return *v, true
  788. }
  789. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  790. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  791. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  792. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  793. if !m.op.Is(OpUpdateOne) {
  794. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  795. }
  796. if m.id == nil || m.oldValue == nil {
  797. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  798. }
  799. oldValue, err := m.oldValue(ctx)
  800. if err != nil {
  801. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  802. }
  803. return oldValue.SubSourceID, nil
  804. }
  805. // AddSubSourceID adds u to the "sub_source_id" field.
  806. func (m *MessageRecordsMutation) AddSubSourceID(u int64) {
  807. if m.addsub_source_id != nil {
  808. *m.addsub_source_id += u
  809. } else {
  810. m.addsub_source_id = &u
  811. }
  812. }
  813. // AddedSubSourceID returns the value that was added to the "sub_source_id" field in this mutation.
  814. func (m *MessageRecordsMutation) AddedSubSourceID() (r int64, exists bool) {
  815. v := m.addsub_source_id
  816. if v == nil {
  817. return
  818. }
  819. return *v, true
  820. }
  821. // ClearSubSourceID clears the value of the "sub_source_id" field.
  822. func (m *MessageRecordsMutation) ClearSubSourceID() {
  823. m.sub_source_id = nil
  824. m.addsub_source_id = nil
  825. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  826. }
  827. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  828. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  829. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  830. return ok
  831. }
  832. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  833. func (m *MessageRecordsMutation) ResetSubSourceID() {
  834. m.sub_source_id = nil
  835. m.addsub_source_id = nil
  836. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  837. }
  838. // Where appends a list predicates to the MessageRecordsMutation builder.
  839. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  840. m.predicates = append(m.predicates, ps...)
  841. }
  842. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  843. // users can use type-assertion to append predicates that do not depend on any generated package.
  844. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  845. p := make([]predicate.MessageRecords, len(ps))
  846. for i := range ps {
  847. p[i] = ps[i]
  848. }
  849. m.Where(p...)
  850. }
  851. // Op returns the operation name.
  852. func (m *MessageRecordsMutation) Op() Op {
  853. return m.op
  854. }
  855. // SetOp allows setting the mutation operation.
  856. func (m *MessageRecordsMutation) SetOp(op Op) {
  857. m.op = op
  858. }
  859. // Type returns the node type of this mutation (MessageRecords).
  860. func (m *MessageRecordsMutation) Type() string {
  861. return m.typ
  862. }
  863. // Fields returns all fields that were changed during this mutation. Note that in
  864. // order to get all numeric fields that were incremented/decremented, call
  865. // AddedFields().
  866. func (m *MessageRecordsMutation) Fields() []string {
  867. fields := make([]string, 0, 15)
  868. if m.created_at != nil {
  869. fields = append(fields, messagerecords.FieldCreatedAt)
  870. }
  871. if m.updated_at != nil {
  872. fields = append(fields, messagerecords.FieldUpdatedAt)
  873. }
  874. if m.status != nil {
  875. fields = append(fields, messagerecords.FieldStatus)
  876. }
  877. if m.bot_wxid != nil {
  878. fields = append(fields, messagerecords.FieldBotWxid)
  879. }
  880. if m.contact_id != nil {
  881. fields = append(fields, messagerecords.FieldContactID)
  882. }
  883. if m.contact_type != nil {
  884. fields = append(fields, messagerecords.FieldContactType)
  885. }
  886. if m.contact_wxid != nil {
  887. fields = append(fields, messagerecords.FieldContactWxid)
  888. }
  889. if m.content_type != nil {
  890. fields = append(fields, messagerecords.FieldContentType)
  891. }
  892. if m.content != nil {
  893. fields = append(fields, messagerecords.FieldContent)
  894. }
  895. if m.meta != nil {
  896. fields = append(fields, messagerecords.FieldMeta)
  897. }
  898. if m.error_detail != nil {
  899. fields = append(fields, messagerecords.FieldErrorDetail)
  900. }
  901. if m.send_time != nil {
  902. fields = append(fields, messagerecords.FieldSendTime)
  903. }
  904. if m.source_type != nil {
  905. fields = append(fields, messagerecords.FieldSourceType)
  906. }
  907. if m.source_id != nil {
  908. fields = append(fields, messagerecords.FieldSourceID)
  909. }
  910. if m.sub_source_id != nil {
  911. fields = append(fields, messagerecords.FieldSubSourceID)
  912. }
  913. return fields
  914. }
  915. // Field returns the value of a field with the given name. The second boolean
  916. // return value indicates that this field was not set, or was not defined in the
  917. // schema.
  918. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  919. switch name {
  920. case messagerecords.FieldCreatedAt:
  921. return m.CreatedAt()
  922. case messagerecords.FieldUpdatedAt:
  923. return m.UpdatedAt()
  924. case messagerecords.FieldStatus:
  925. return m.Status()
  926. case messagerecords.FieldBotWxid:
  927. return m.BotWxid()
  928. case messagerecords.FieldContactID:
  929. return m.ContactID()
  930. case messagerecords.FieldContactType:
  931. return m.ContactType()
  932. case messagerecords.FieldContactWxid:
  933. return m.ContactWxid()
  934. case messagerecords.FieldContentType:
  935. return m.ContentType()
  936. case messagerecords.FieldContent:
  937. return m.Content()
  938. case messagerecords.FieldMeta:
  939. return m.Meta()
  940. case messagerecords.FieldErrorDetail:
  941. return m.ErrorDetail()
  942. case messagerecords.FieldSendTime:
  943. return m.SendTime()
  944. case messagerecords.FieldSourceType:
  945. return m.SourceType()
  946. case messagerecords.FieldSourceID:
  947. return m.SourceID()
  948. case messagerecords.FieldSubSourceID:
  949. return m.SubSourceID()
  950. }
  951. return nil, false
  952. }
  953. // OldField returns the old value of the field from the database. An error is
  954. // returned if the mutation operation is not UpdateOne, or the query to the
  955. // database failed.
  956. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  957. switch name {
  958. case messagerecords.FieldCreatedAt:
  959. return m.OldCreatedAt(ctx)
  960. case messagerecords.FieldUpdatedAt:
  961. return m.OldUpdatedAt(ctx)
  962. case messagerecords.FieldStatus:
  963. return m.OldStatus(ctx)
  964. case messagerecords.FieldBotWxid:
  965. return m.OldBotWxid(ctx)
  966. case messagerecords.FieldContactID:
  967. return m.OldContactID(ctx)
  968. case messagerecords.FieldContactType:
  969. return m.OldContactType(ctx)
  970. case messagerecords.FieldContactWxid:
  971. return m.OldContactWxid(ctx)
  972. case messagerecords.FieldContentType:
  973. return m.OldContentType(ctx)
  974. case messagerecords.FieldContent:
  975. return m.OldContent(ctx)
  976. case messagerecords.FieldMeta:
  977. return m.OldMeta(ctx)
  978. case messagerecords.FieldErrorDetail:
  979. return m.OldErrorDetail(ctx)
  980. case messagerecords.FieldSendTime:
  981. return m.OldSendTime(ctx)
  982. case messagerecords.FieldSourceType:
  983. return m.OldSourceType(ctx)
  984. case messagerecords.FieldSourceID:
  985. return m.OldSourceID(ctx)
  986. case messagerecords.FieldSubSourceID:
  987. return m.OldSubSourceID(ctx)
  988. }
  989. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  990. }
  991. // SetField sets the value of a field with the given name. It returns an error if
  992. // the field is not defined in the schema, or if the type mismatched the field
  993. // type.
  994. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  995. switch name {
  996. case messagerecords.FieldCreatedAt:
  997. v, ok := value.(time.Time)
  998. if !ok {
  999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1000. }
  1001. m.SetCreatedAt(v)
  1002. return nil
  1003. case messagerecords.FieldUpdatedAt:
  1004. v, ok := value.(time.Time)
  1005. if !ok {
  1006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1007. }
  1008. m.SetUpdatedAt(v)
  1009. return nil
  1010. case messagerecords.FieldStatus:
  1011. v, ok := value.(uint8)
  1012. if !ok {
  1013. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1014. }
  1015. m.SetStatus(v)
  1016. return nil
  1017. case messagerecords.FieldBotWxid:
  1018. v, ok := value.(string)
  1019. if !ok {
  1020. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1021. }
  1022. m.SetBotWxid(v)
  1023. return nil
  1024. case messagerecords.FieldContactID:
  1025. v, ok := value.(uint64)
  1026. if !ok {
  1027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1028. }
  1029. m.SetContactID(v)
  1030. return nil
  1031. case messagerecords.FieldContactType:
  1032. v, ok := value.(int)
  1033. if !ok {
  1034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1035. }
  1036. m.SetContactType(v)
  1037. return nil
  1038. case messagerecords.FieldContactWxid:
  1039. v, ok := value.(string)
  1040. if !ok {
  1041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1042. }
  1043. m.SetContactWxid(v)
  1044. return nil
  1045. case messagerecords.FieldContentType:
  1046. v, ok := value.(int)
  1047. if !ok {
  1048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1049. }
  1050. m.SetContentType(v)
  1051. return nil
  1052. case messagerecords.FieldContent:
  1053. v, ok := value.(string)
  1054. if !ok {
  1055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1056. }
  1057. m.SetContent(v)
  1058. return nil
  1059. case messagerecords.FieldMeta:
  1060. v, ok := value.(custom_types.Meta)
  1061. if !ok {
  1062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1063. }
  1064. m.SetMeta(v)
  1065. return nil
  1066. case messagerecords.FieldErrorDetail:
  1067. v, ok := value.(string)
  1068. if !ok {
  1069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1070. }
  1071. m.SetErrorDetail(v)
  1072. return nil
  1073. case messagerecords.FieldSendTime:
  1074. v, ok := value.(time.Time)
  1075. if !ok {
  1076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1077. }
  1078. m.SetSendTime(v)
  1079. return nil
  1080. case messagerecords.FieldSourceType:
  1081. v, ok := value.(int)
  1082. if !ok {
  1083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1084. }
  1085. m.SetSourceType(v)
  1086. return nil
  1087. case messagerecords.FieldSourceID:
  1088. v, ok := value.(uint64)
  1089. if !ok {
  1090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1091. }
  1092. m.SetSourceID(v)
  1093. return nil
  1094. case messagerecords.FieldSubSourceID:
  1095. v, ok := value.(uint64)
  1096. if !ok {
  1097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1098. }
  1099. m.SetSubSourceID(v)
  1100. return nil
  1101. }
  1102. return fmt.Errorf("unknown MessageRecords field %s", name)
  1103. }
  1104. // AddedFields returns all numeric fields that were incremented/decremented during
  1105. // this mutation.
  1106. func (m *MessageRecordsMutation) AddedFields() []string {
  1107. var fields []string
  1108. if m.addstatus != nil {
  1109. fields = append(fields, messagerecords.FieldStatus)
  1110. }
  1111. if m.addcontact_id != nil {
  1112. fields = append(fields, messagerecords.FieldContactID)
  1113. }
  1114. if m.addcontact_type != nil {
  1115. fields = append(fields, messagerecords.FieldContactType)
  1116. }
  1117. if m.addcontent_type != nil {
  1118. fields = append(fields, messagerecords.FieldContentType)
  1119. }
  1120. if m.addsource_type != nil {
  1121. fields = append(fields, messagerecords.FieldSourceType)
  1122. }
  1123. if m.addsource_id != nil {
  1124. fields = append(fields, messagerecords.FieldSourceID)
  1125. }
  1126. if m.addsub_source_id != nil {
  1127. fields = append(fields, messagerecords.FieldSubSourceID)
  1128. }
  1129. return fields
  1130. }
  1131. // AddedField returns the numeric value that was incremented/decremented on a field
  1132. // with the given name. The second boolean return value indicates that this field
  1133. // was not set, or was not defined in the schema.
  1134. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  1135. switch name {
  1136. case messagerecords.FieldStatus:
  1137. return m.AddedStatus()
  1138. case messagerecords.FieldContactID:
  1139. return m.AddedContactID()
  1140. case messagerecords.FieldContactType:
  1141. return m.AddedContactType()
  1142. case messagerecords.FieldContentType:
  1143. return m.AddedContentType()
  1144. case messagerecords.FieldSourceType:
  1145. return m.AddedSourceType()
  1146. case messagerecords.FieldSourceID:
  1147. return m.AddedSourceID()
  1148. case messagerecords.FieldSubSourceID:
  1149. return m.AddedSubSourceID()
  1150. }
  1151. return nil, false
  1152. }
  1153. // AddField adds the value to the field with the given name. It returns an error if
  1154. // the field is not defined in the schema, or if the type mismatched the field
  1155. // type.
  1156. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  1157. switch name {
  1158. case messagerecords.FieldStatus:
  1159. v, ok := value.(int8)
  1160. if !ok {
  1161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1162. }
  1163. m.AddStatus(v)
  1164. return nil
  1165. case messagerecords.FieldContactID:
  1166. v, ok := value.(int64)
  1167. if !ok {
  1168. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1169. }
  1170. m.AddContactID(v)
  1171. return nil
  1172. case messagerecords.FieldContactType:
  1173. v, ok := value.(int)
  1174. if !ok {
  1175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1176. }
  1177. m.AddContactType(v)
  1178. return nil
  1179. case messagerecords.FieldContentType:
  1180. v, ok := value.(int)
  1181. if !ok {
  1182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1183. }
  1184. m.AddContentType(v)
  1185. return nil
  1186. case messagerecords.FieldSourceType:
  1187. v, ok := value.(int)
  1188. if !ok {
  1189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1190. }
  1191. m.AddSourceType(v)
  1192. return nil
  1193. case messagerecords.FieldSourceID:
  1194. v, ok := value.(int64)
  1195. if !ok {
  1196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1197. }
  1198. m.AddSourceID(v)
  1199. return nil
  1200. case messagerecords.FieldSubSourceID:
  1201. v, ok := value.(int64)
  1202. if !ok {
  1203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1204. }
  1205. m.AddSubSourceID(v)
  1206. return nil
  1207. }
  1208. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  1209. }
  1210. // ClearedFields returns all nullable fields that were cleared during this
  1211. // mutation.
  1212. func (m *MessageRecordsMutation) ClearedFields() []string {
  1213. var fields []string
  1214. if m.FieldCleared(messagerecords.FieldStatus) {
  1215. fields = append(fields, messagerecords.FieldStatus)
  1216. }
  1217. if m.FieldCleared(messagerecords.FieldContactID) {
  1218. fields = append(fields, messagerecords.FieldContactID)
  1219. }
  1220. if m.FieldCleared(messagerecords.FieldMeta) {
  1221. fields = append(fields, messagerecords.FieldMeta)
  1222. }
  1223. if m.FieldCleared(messagerecords.FieldSendTime) {
  1224. fields = append(fields, messagerecords.FieldSendTime)
  1225. }
  1226. if m.FieldCleared(messagerecords.FieldSourceID) {
  1227. fields = append(fields, messagerecords.FieldSourceID)
  1228. }
  1229. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  1230. fields = append(fields, messagerecords.FieldSubSourceID)
  1231. }
  1232. return fields
  1233. }
  1234. // FieldCleared returns a boolean indicating if a field with the given name was
  1235. // cleared in this mutation.
  1236. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  1237. _, ok := m.clearedFields[name]
  1238. return ok
  1239. }
  1240. // ClearField clears the value of the field with the given name. It returns an
  1241. // error if the field is not defined in the schema.
  1242. func (m *MessageRecordsMutation) ClearField(name string) error {
  1243. switch name {
  1244. case messagerecords.FieldStatus:
  1245. m.ClearStatus()
  1246. return nil
  1247. case messagerecords.FieldContactID:
  1248. m.ClearContactID()
  1249. return nil
  1250. case messagerecords.FieldMeta:
  1251. m.ClearMeta()
  1252. return nil
  1253. case messagerecords.FieldSendTime:
  1254. m.ClearSendTime()
  1255. return nil
  1256. case messagerecords.FieldSourceID:
  1257. m.ClearSourceID()
  1258. return nil
  1259. case messagerecords.FieldSubSourceID:
  1260. m.ClearSubSourceID()
  1261. return nil
  1262. }
  1263. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  1264. }
  1265. // ResetField resets all changes in the mutation for the field with the given name.
  1266. // It returns an error if the field is not defined in the schema.
  1267. func (m *MessageRecordsMutation) ResetField(name string) error {
  1268. switch name {
  1269. case messagerecords.FieldCreatedAt:
  1270. m.ResetCreatedAt()
  1271. return nil
  1272. case messagerecords.FieldUpdatedAt:
  1273. m.ResetUpdatedAt()
  1274. return nil
  1275. case messagerecords.FieldStatus:
  1276. m.ResetStatus()
  1277. return nil
  1278. case messagerecords.FieldBotWxid:
  1279. m.ResetBotWxid()
  1280. return nil
  1281. case messagerecords.FieldContactID:
  1282. m.ResetContactID()
  1283. return nil
  1284. case messagerecords.FieldContactType:
  1285. m.ResetContactType()
  1286. return nil
  1287. case messagerecords.FieldContactWxid:
  1288. m.ResetContactWxid()
  1289. return nil
  1290. case messagerecords.FieldContentType:
  1291. m.ResetContentType()
  1292. return nil
  1293. case messagerecords.FieldContent:
  1294. m.ResetContent()
  1295. return nil
  1296. case messagerecords.FieldMeta:
  1297. m.ResetMeta()
  1298. return nil
  1299. case messagerecords.FieldErrorDetail:
  1300. m.ResetErrorDetail()
  1301. return nil
  1302. case messagerecords.FieldSendTime:
  1303. m.ResetSendTime()
  1304. return nil
  1305. case messagerecords.FieldSourceType:
  1306. m.ResetSourceType()
  1307. return nil
  1308. case messagerecords.FieldSourceID:
  1309. m.ResetSourceID()
  1310. return nil
  1311. case messagerecords.FieldSubSourceID:
  1312. m.ResetSubSourceID()
  1313. return nil
  1314. }
  1315. return fmt.Errorf("unknown MessageRecords field %s", name)
  1316. }
  1317. // AddedEdges returns all edge names that were set/added in this mutation.
  1318. func (m *MessageRecordsMutation) AddedEdges() []string {
  1319. edges := make([]string, 0, 0)
  1320. return edges
  1321. }
  1322. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1323. // name in this mutation.
  1324. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  1325. return nil
  1326. }
  1327. // RemovedEdges returns all edge names that were removed in this mutation.
  1328. func (m *MessageRecordsMutation) RemovedEdges() []string {
  1329. edges := make([]string, 0, 0)
  1330. return edges
  1331. }
  1332. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1333. // the given name in this mutation.
  1334. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  1335. return nil
  1336. }
  1337. // ClearedEdges returns all edge names that were cleared in this mutation.
  1338. func (m *MessageRecordsMutation) ClearedEdges() []string {
  1339. edges := make([]string, 0, 0)
  1340. return edges
  1341. }
  1342. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1343. // was cleared in this mutation.
  1344. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  1345. return false
  1346. }
  1347. // ClearEdge clears the value of the edge with the given name. It returns an error
  1348. // if that edge is not defined in the schema.
  1349. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  1350. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  1351. }
  1352. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1353. // It returns an error if the edge is not defined in the schema.
  1354. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  1355. return fmt.Errorf("unknown MessageRecords edge %s", name)
  1356. }
  1357. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  1358. type SopNodeMutation struct {
  1359. config
  1360. op Op
  1361. typ string
  1362. id *uint64
  1363. created_at *time.Time
  1364. updated_at *time.Time
  1365. status *uint8
  1366. addstatus *int8
  1367. parent_id *uint64
  1368. addparent_id *int64
  1369. name *string
  1370. condition_type *int
  1371. addcondition_type *int
  1372. condition_list *[]string
  1373. appendcondition_list []string
  1374. no_reply_condition *uint64
  1375. addno_reply_condition *int64
  1376. action_message *[]custom_types.Action
  1377. appendaction_message []custom_types.Action
  1378. action_label *[]uint64
  1379. appendaction_label []uint64
  1380. deleted_at *time.Time
  1381. clearedFields map[string]struct{}
  1382. sop_stage *uint64
  1383. clearedsop_stage bool
  1384. node_messages map[uint64]struct{}
  1385. removednode_messages map[uint64]struct{}
  1386. clearednode_messages bool
  1387. done bool
  1388. oldValue func(context.Context) (*SopNode, error)
  1389. predicates []predicate.SopNode
  1390. }
  1391. var _ ent.Mutation = (*SopNodeMutation)(nil)
  1392. // sopnodeOption allows management of the mutation configuration using functional options.
  1393. type sopnodeOption func(*SopNodeMutation)
  1394. // newSopNodeMutation creates new mutation for the SopNode entity.
  1395. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  1396. m := &SopNodeMutation{
  1397. config: c,
  1398. op: op,
  1399. typ: TypeSopNode,
  1400. clearedFields: make(map[string]struct{}),
  1401. }
  1402. for _, opt := range opts {
  1403. opt(m)
  1404. }
  1405. return m
  1406. }
  1407. // withSopNodeID sets the ID field of the mutation.
  1408. func withSopNodeID(id uint64) sopnodeOption {
  1409. return func(m *SopNodeMutation) {
  1410. var (
  1411. err error
  1412. once sync.Once
  1413. value *SopNode
  1414. )
  1415. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  1416. once.Do(func() {
  1417. if m.done {
  1418. err = errors.New("querying old values post mutation is not allowed")
  1419. } else {
  1420. value, err = m.Client().SopNode.Get(ctx, id)
  1421. }
  1422. })
  1423. return value, err
  1424. }
  1425. m.id = &id
  1426. }
  1427. }
  1428. // withSopNode sets the old SopNode of the mutation.
  1429. func withSopNode(node *SopNode) sopnodeOption {
  1430. return func(m *SopNodeMutation) {
  1431. m.oldValue = func(context.Context) (*SopNode, error) {
  1432. return node, nil
  1433. }
  1434. m.id = &node.ID
  1435. }
  1436. }
  1437. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1438. // executed in a transaction (ent.Tx), a transactional client is returned.
  1439. func (m SopNodeMutation) Client() *Client {
  1440. client := &Client{config: m.config}
  1441. client.init()
  1442. return client
  1443. }
  1444. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1445. // it returns an error otherwise.
  1446. func (m SopNodeMutation) Tx() (*Tx, error) {
  1447. if _, ok := m.driver.(*txDriver); !ok {
  1448. return nil, errors.New("ent: mutation is not running in a transaction")
  1449. }
  1450. tx := &Tx{config: m.config}
  1451. tx.init()
  1452. return tx, nil
  1453. }
  1454. // SetID sets the value of the id field. Note that this
  1455. // operation is only accepted on creation of SopNode entities.
  1456. func (m *SopNodeMutation) SetID(id uint64) {
  1457. m.id = &id
  1458. }
  1459. // ID returns the ID value in the mutation. Note that the ID is only available
  1460. // if it was provided to the builder or after it was returned from the database.
  1461. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  1462. if m.id == nil {
  1463. return
  1464. }
  1465. return *m.id, true
  1466. }
  1467. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1468. // That means, if the mutation is applied within a transaction with an isolation level such
  1469. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1470. // or updated by the mutation.
  1471. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  1472. switch {
  1473. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1474. id, exists := m.ID()
  1475. if exists {
  1476. return []uint64{id}, nil
  1477. }
  1478. fallthrough
  1479. case m.op.Is(OpUpdate | OpDelete):
  1480. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  1481. default:
  1482. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1483. }
  1484. }
  1485. // SetCreatedAt sets the "created_at" field.
  1486. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  1487. m.created_at = &t
  1488. }
  1489. // CreatedAt returns the value of the "created_at" field in the mutation.
  1490. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  1491. v := m.created_at
  1492. if v == nil {
  1493. return
  1494. }
  1495. return *v, true
  1496. }
  1497. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  1498. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  1499. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1500. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  1501. if !m.op.Is(OpUpdateOne) {
  1502. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  1503. }
  1504. if m.id == nil || m.oldValue == nil {
  1505. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  1506. }
  1507. oldValue, err := m.oldValue(ctx)
  1508. if err != nil {
  1509. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  1510. }
  1511. return oldValue.CreatedAt, nil
  1512. }
  1513. // ResetCreatedAt resets all changes to the "created_at" field.
  1514. func (m *SopNodeMutation) ResetCreatedAt() {
  1515. m.created_at = nil
  1516. }
  1517. // SetUpdatedAt sets the "updated_at" field.
  1518. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  1519. m.updated_at = &t
  1520. }
  1521. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  1522. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  1523. v := m.updated_at
  1524. if v == nil {
  1525. return
  1526. }
  1527. return *v, true
  1528. }
  1529. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  1530. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  1531. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1532. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  1533. if !m.op.Is(OpUpdateOne) {
  1534. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  1535. }
  1536. if m.id == nil || m.oldValue == nil {
  1537. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  1538. }
  1539. oldValue, err := m.oldValue(ctx)
  1540. if err != nil {
  1541. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  1542. }
  1543. return oldValue.UpdatedAt, nil
  1544. }
  1545. // ResetUpdatedAt resets all changes to the "updated_at" field.
  1546. func (m *SopNodeMutation) ResetUpdatedAt() {
  1547. m.updated_at = nil
  1548. }
  1549. // SetStatus sets the "status" field.
  1550. func (m *SopNodeMutation) SetStatus(u uint8) {
  1551. m.status = &u
  1552. m.addstatus = nil
  1553. }
  1554. // Status returns the value of the "status" field in the mutation.
  1555. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  1556. v := m.status
  1557. if v == nil {
  1558. return
  1559. }
  1560. return *v, true
  1561. }
  1562. // OldStatus returns the old "status" field's value of the SopNode entity.
  1563. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  1564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1565. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  1566. if !m.op.Is(OpUpdateOne) {
  1567. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  1568. }
  1569. if m.id == nil || m.oldValue == nil {
  1570. return v, errors.New("OldStatus requires an ID field in the mutation")
  1571. }
  1572. oldValue, err := m.oldValue(ctx)
  1573. if err != nil {
  1574. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  1575. }
  1576. return oldValue.Status, nil
  1577. }
  1578. // AddStatus adds u to the "status" field.
  1579. func (m *SopNodeMutation) AddStatus(u int8) {
  1580. if m.addstatus != nil {
  1581. *m.addstatus += u
  1582. } else {
  1583. m.addstatus = &u
  1584. }
  1585. }
  1586. // AddedStatus returns the value that was added to the "status" field in this mutation.
  1587. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  1588. v := m.addstatus
  1589. if v == nil {
  1590. return
  1591. }
  1592. return *v, true
  1593. }
  1594. // ClearStatus clears the value of the "status" field.
  1595. func (m *SopNodeMutation) ClearStatus() {
  1596. m.status = nil
  1597. m.addstatus = nil
  1598. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  1599. }
  1600. // StatusCleared returns if the "status" field was cleared in this mutation.
  1601. func (m *SopNodeMutation) StatusCleared() bool {
  1602. _, ok := m.clearedFields[sopnode.FieldStatus]
  1603. return ok
  1604. }
  1605. // ResetStatus resets all changes to the "status" field.
  1606. func (m *SopNodeMutation) ResetStatus() {
  1607. m.status = nil
  1608. m.addstatus = nil
  1609. delete(m.clearedFields, sopnode.FieldStatus)
  1610. }
  1611. // SetStageID sets the "stage_id" field.
  1612. func (m *SopNodeMutation) SetStageID(u uint64) {
  1613. m.sop_stage = &u
  1614. }
  1615. // StageID returns the value of the "stage_id" field in the mutation.
  1616. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  1617. v := m.sop_stage
  1618. if v == nil {
  1619. return
  1620. }
  1621. return *v, true
  1622. }
  1623. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  1624. // If the SopNode 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 *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  1627. if !m.op.Is(OpUpdateOne) {
  1628. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  1629. }
  1630. if m.id == nil || m.oldValue == nil {
  1631. return v, errors.New("OldStageID 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 OldStageID: %w", err)
  1636. }
  1637. return oldValue.StageID, nil
  1638. }
  1639. // ResetStageID resets all changes to the "stage_id" field.
  1640. func (m *SopNodeMutation) ResetStageID() {
  1641. m.sop_stage = nil
  1642. }
  1643. // SetParentID sets the "parent_id" field.
  1644. func (m *SopNodeMutation) SetParentID(u uint64) {
  1645. m.parent_id = &u
  1646. m.addparent_id = nil
  1647. }
  1648. // ParentID returns the value of the "parent_id" field in the mutation.
  1649. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  1650. v := m.parent_id
  1651. if v == nil {
  1652. return
  1653. }
  1654. return *v, true
  1655. }
  1656. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  1657. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  1658. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1659. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  1660. if !m.op.Is(OpUpdateOne) {
  1661. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  1662. }
  1663. if m.id == nil || m.oldValue == nil {
  1664. return v, errors.New("OldParentID requires an ID field in the mutation")
  1665. }
  1666. oldValue, err := m.oldValue(ctx)
  1667. if err != nil {
  1668. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  1669. }
  1670. return oldValue.ParentID, nil
  1671. }
  1672. // AddParentID adds u to the "parent_id" field.
  1673. func (m *SopNodeMutation) AddParentID(u int64) {
  1674. if m.addparent_id != nil {
  1675. *m.addparent_id += u
  1676. } else {
  1677. m.addparent_id = &u
  1678. }
  1679. }
  1680. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  1681. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  1682. v := m.addparent_id
  1683. if v == nil {
  1684. return
  1685. }
  1686. return *v, true
  1687. }
  1688. // ResetParentID resets all changes to the "parent_id" field.
  1689. func (m *SopNodeMutation) ResetParentID() {
  1690. m.parent_id = nil
  1691. m.addparent_id = nil
  1692. }
  1693. // SetName sets the "name" field.
  1694. func (m *SopNodeMutation) SetName(s string) {
  1695. m.name = &s
  1696. }
  1697. // Name returns the value of the "name" field in the mutation.
  1698. func (m *SopNodeMutation) Name() (r string, exists bool) {
  1699. v := m.name
  1700. if v == nil {
  1701. return
  1702. }
  1703. return *v, true
  1704. }
  1705. // OldName returns the old "name" field's value of the SopNode entity.
  1706. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  1707. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1708. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  1709. if !m.op.Is(OpUpdateOne) {
  1710. return v, errors.New("OldName is only allowed on UpdateOne operations")
  1711. }
  1712. if m.id == nil || m.oldValue == nil {
  1713. return v, errors.New("OldName requires an ID field in the mutation")
  1714. }
  1715. oldValue, err := m.oldValue(ctx)
  1716. if err != nil {
  1717. return v, fmt.Errorf("querying old value for OldName: %w", err)
  1718. }
  1719. return oldValue.Name, nil
  1720. }
  1721. // ResetName resets all changes to the "name" field.
  1722. func (m *SopNodeMutation) ResetName() {
  1723. m.name = nil
  1724. }
  1725. // SetConditionType sets the "condition_type" field.
  1726. func (m *SopNodeMutation) SetConditionType(i int) {
  1727. m.condition_type = &i
  1728. m.addcondition_type = nil
  1729. }
  1730. // ConditionType returns the value of the "condition_type" field in the mutation.
  1731. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  1732. v := m.condition_type
  1733. if v == nil {
  1734. return
  1735. }
  1736. return *v, true
  1737. }
  1738. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  1739. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  1740. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1741. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  1742. if !m.op.Is(OpUpdateOne) {
  1743. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  1744. }
  1745. if m.id == nil || m.oldValue == nil {
  1746. return v, errors.New("OldConditionType requires an ID field in the mutation")
  1747. }
  1748. oldValue, err := m.oldValue(ctx)
  1749. if err != nil {
  1750. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  1751. }
  1752. return oldValue.ConditionType, nil
  1753. }
  1754. // AddConditionType adds i to the "condition_type" field.
  1755. func (m *SopNodeMutation) AddConditionType(i int) {
  1756. if m.addcondition_type != nil {
  1757. *m.addcondition_type += i
  1758. } else {
  1759. m.addcondition_type = &i
  1760. }
  1761. }
  1762. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  1763. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  1764. v := m.addcondition_type
  1765. if v == nil {
  1766. return
  1767. }
  1768. return *v, true
  1769. }
  1770. // ResetConditionType resets all changes to the "condition_type" field.
  1771. func (m *SopNodeMutation) ResetConditionType() {
  1772. m.condition_type = nil
  1773. m.addcondition_type = nil
  1774. }
  1775. // SetConditionList sets the "condition_list" field.
  1776. func (m *SopNodeMutation) SetConditionList(s []string) {
  1777. m.condition_list = &s
  1778. m.appendcondition_list = nil
  1779. }
  1780. // ConditionList returns the value of the "condition_list" field in the mutation.
  1781. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  1782. v := m.condition_list
  1783. if v == nil {
  1784. return
  1785. }
  1786. return *v, true
  1787. }
  1788. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  1789. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  1790. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1791. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  1792. if !m.op.Is(OpUpdateOne) {
  1793. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  1794. }
  1795. if m.id == nil || m.oldValue == nil {
  1796. return v, errors.New("OldConditionList requires an ID field in the mutation")
  1797. }
  1798. oldValue, err := m.oldValue(ctx)
  1799. if err != nil {
  1800. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  1801. }
  1802. return oldValue.ConditionList, nil
  1803. }
  1804. // AppendConditionList adds s to the "condition_list" field.
  1805. func (m *SopNodeMutation) AppendConditionList(s []string) {
  1806. m.appendcondition_list = append(m.appendcondition_list, s...)
  1807. }
  1808. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  1809. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  1810. if len(m.appendcondition_list) == 0 {
  1811. return nil, false
  1812. }
  1813. return m.appendcondition_list, true
  1814. }
  1815. // ClearConditionList clears the value of the "condition_list" field.
  1816. func (m *SopNodeMutation) ClearConditionList() {
  1817. m.condition_list = nil
  1818. m.appendcondition_list = nil
  1819. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  1820. }
  1821. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  1822. func (m *SopNodeMutation) ConditionListCleared() bool {
  1823. _, ok := m.clearedFields[sopnode.FieldConditionList]
  1824. return ok
  1825. }
  1826. // ResetConditionList resets all changes to the "condition_list" field.
  1827. func (m *SopNodeMutation) ResetConditionList() {
  1828. m.condition_list = nil
  1829. m.appendcondition_list = nil
  1830. delete(m.clearedFields, sopnode.FieldConditionList)
  1831. }
  1832. // SetNoReplyCondition sets the "no_reply_condition" field.
  1833. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  1834. m.no_reply_condition = &u
  1835. m.addno_reply_condition = nil
  1836. }
  1837. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  1838. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  1839. v := m.no_reply_condition
  1840. if v == nil {
  1841. return
  1842. }
  1843. return *v, true
  1844. }
  1845. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  1846. // If the SopNode 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 *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  1849. if !m.op.Is(OpUpdateOne) {
  1850. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  1851. }
  1852. if m.id == nil || m.oldValue == nil {
  1853. return v, errors.New("OldNoReplyCondition 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 OldNoReplyCondition: %w", err)
  1858. }
  1859. return oldValue.NoReplyCondition, nil
  1860. }
  1861. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  1862. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  1863. if m.addno_reply_condition != nil {
  1864. *m.addno_reply_condition += u
  1865. } else {
  1866. m.addno_reply_condition = &u
  1867. }
  1868. }
  1869. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  1870. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  1871. v := m.addno_reply_condition
  1872. if v == nil {
  1873. return
  1874. }
  1875. return *v, true
  1876. }
  1877. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  1878. func (m *SopNodeMutation) ResetNoReplyCondition() {
  1879. m.no_reply_condition = nil
  1880. m.addno_reply_condition = nil
  1881. }
  1882. // SetActionMessage sets the "action_message" field.
  1883. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  1884. m.action_message = &ct
  1885. m.appendaction_message = nil
  1886. }
  1887. // ActionMessage returns the value of the "action_message" field in the mutation.
  1888. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  1889. v := m.action_message
  1890. if v == nil {
  1891. return
  1892. }
  1893. return *v, true
  1894. }
  1895. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  1896. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  1897. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1898. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  1899. if !m.op.Is(OpUpdateOne) {
  1900. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  1901. }
  1902. if m.id == nil || m.oldValue == nil {
  1903. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  1904. }
  1905. oldValue, err := m.oldValue(ctx)
  1906. if err != nil {
  1907. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  1908. }
  1909. return oldValue.ActionMessage, nil
  1910. }
  1911. // AppendActionMessage adds ct to the "action_message" field.
  1912. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  1913. m.appendaction_message = append(m.appendaction_message, ct...)
  1914. }
  1915. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  1916. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  1917. if len(m.appendaction_message) == 0 {
  1918. return nil, false
  1919. }
  1920. return m.appendaction_message, true
  1921. }
  1922. // ClearActionMessage clears the value of the "action_message" field.
  1923. func (m *SopNodeMutation) ClearActionMessage() {
  1924. m.action_message = nil
  1925. m.appendaction_message = nil
  1926. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  1927. }
  1928. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  1929. func (m *SopNodeMutation) ActionMessageCleared() bool {
  1930. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  1931. return ok
  1932. }
  1933. // ResetActionMessage resets all changes to the "action_message" field.
  1934. func (m *SopNodeMutation) ResetActionMessage() {
  1935. m.action_message = nil
  1936. m.appendaction_message = nil
  1937. delete(m.clearedFields, sopnode.FieldActionMessage)
  1938. }
  1939. // SetActionLabel sets the "action_label" field.
  1940. func (m *SopNodeMutation) SetActionLabel(u []uint64) {
  1941. m.action_label = &u
  1942. m.appendaction_label = nil
  1943. }
  1944. // ActionLabel returns the value of the "action_label" field in the mutation.
  1945. func (m *SopNodeMutation) ActionLabel() (r []uint64, exists bool) {
  1946. v := m.action_label
  1947. if v == nil {
  1948. return
  1949. }
  1950. return *v, true
  1951. }
  1952. // OldActionLabel returns the old "action_label" field's value of the SopNode entity.
  1953. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  1954. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1955. func (m *SopNodeMutation) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  1956. if !m.op.Is(OpUpdateOne) {
  1957. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  1958. }
  1959. if m.id == nil || m.oldValue == nil {
  1960. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  1961. }
  1962. oldValue, err := m.oldValue(ctx)
  1963. if err != nil {
  1964. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  1965. }
  1966. return oldValue.ActionLabel, nil
  1967. }
  1968. // AppendActionLabel adds u to the "action_label" field.
  1969. func (m *SopNodeMutation) AppendActionLabel(u []uint64) {
  1970. m.appendaction_label = append(m.appendaction_label, u...)
  1971. }
  1972. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  1973. func (m *SopNodeMutation) AppendedActionLabel() ([]uint64, bool) {
  1974. if len(m.appendaction_label) == 0 {
  1975. return nil, false
  1976. }
  1977. return m.appendaction_label, true
  1978. }
  1979. // ClearActionLabel clears the value of the "action_label" field.
  1980. func (m *SopNodeMutation) ClearActionLabel() {
  1981. m.action_label = nil
  1982. m.appendaction_label = nil
  1983. m.clearedFields[sopnode.FieldActionLabel] = struct{}{}
  1984. }
  1985. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  1986. func (m *SopNodeMutation) ActionLabelCleared() bool {
  1987. _, ok := m.clearedFields[sopnode.FieldActionLabel]
  1988. return ok
  1989. }
  1990. // ResetActionLabel resets all changes to the "action_label" field.
  1991. func (m *SopNodeMutation) ResetActionLabel() {
  1992. m.action_label = nil
  1993. m.appendaction_label = nil
  1994. delete(m.clearedFields, sopnode.FieldActionLabel)
  1995. }
  1996. // SetDeletedAt sets the "deleted_at" field.
  1997. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  1998. m.deleted_at = &t
  1999. }
  2000. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2001. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  2002. v := m.deleted_at
  2003. if v == nil {
  2004. return
  2005. }
  2006. return *v, true
  2007. }
  2008. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  2009. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  2010. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2011. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2012. if !m.op.Is(OpUpdateOne) {
  2013. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2014. }
  2015. if m.id == nil || m.oldValue == nil {
  2016. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2017. }
  2018. oldValue, err := m.oldValue(ctx)
  2019. if err != nil {
  2020. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2021. }
  2022. return oldValue.DeletedAt, nil
  2023. }
  2024. // ClearDeletedAt clears the value of the "deleted_at" field.
  2025. func (m *SopNodeMutation) ClearDeletedAt() {
  2026. m.deleted_at = nil
  2027. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  2028. }
  2029. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2030. func (m *SopNodeMutation) DeletedAtCleared() bool {
  2031. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  2032. return ok
  2033. }
  2034. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2035. func (m *SopNodeMutation) ResetDeletedAt() {
  2036. m.deleted_at = nil
  2037. delete(m.clearedFields, sopnode.FieldDeletedAt)
  2038. }
  2039. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  2040. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  2041. m.sop_stage = &id
  2042. }
  2043. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  2044. func (m *SopNodeMutation) ClearSopStage() {
  2045. m.clearedsop_stage = true
  2046. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  2047. }
  2048. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  2049. func (m *SopNodeMutation) SopStageCleared() bool {
  2050. return m.clearedsop_stage
  2051. }
  2052. // SopStageID returns the "sop_stage" edge ID in the mutation.
  2053. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  2054. if m.sop_stage != nil {
  2055. return *m.sop_stage, true
  2056. }
  2057. return
  2058. }
  2059. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  2060. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  2061. // SopStageID instead. It exists only for internal usage by the builders.
  2062. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  2063. if id := m.sop_stage; id != nil {
  2064. ids = append(ids, *id)
  2065. }
  2066. return
  2067. }
  2068. // ResetSopStage resets all changes to the "sop_stage" edge.
  2069. func (m *SopNodeMutation) ResetSopStage() {
  2070. m.sop_stage = nil
  2071. m.clearedsop_stage = false
  2072. }
  2073. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  2074. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  2075. if m.node_messages == nil {
  2076. m.node_messages = make(map[uint64]struct{})
  2077. }
  2078. for i := range ids {
  2079. m.node_messages[ids[i]] = struct{}{}
  2080. }
  2081. }
  2082. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  2083. func (m *SopNodeMutation) ClearNodeMessages() {
  2084. m.clearednode_messages = true
  2085. }
  2086. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  2087. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  2088. return m.clearednode_messages
  2089. }
  2090. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  2091. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  2092. if m.removednode_messages == nil {
  2093. m.removednode_messages = make(map[uint64]struct{})
  2094. }
  2095. for i := range ids {
  2096. delete(m.node_messages, ids[i])
  2097. m.removednode_messages[ids[i]] = struct{}{}
  2098. }
  2099. }
  2100. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  2101. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  2102. for id := range m.removednode_messages {
  2103. ids = append(ids, id)
  2104. }
  2105. return
  2106. }
  2107. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  2108. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  2109. for id := range m.node_messages {
  2110. ids = append(ids, id)
  2111. }
  2112. return
  2113. }
  2114. // ResetNodeMessages resets all changes to the "node_messages" edge.
  2115. func (m *SopNodeMutation) ResetNodeMessages() {
  2116. m.node_messages = nil
  2117. m.clearednode_messages = false
  2118. m.removednode_messages = nil
  2119. }
  2120. // Where appends a list predicates to the SopNodeMutation builder.
  2121. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  2122. m.predicates = append(m.predicates, ps...)
  2123. }
  2124. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  2125. // users can use type-assertion to append predicates that do not depend on any generated package.
  2126. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  2127. p := make([]predicate.SopNode, len(ps))
  2128. for i := range ps {
  2129. p[i] = ps[i]
  2130. }
  2131. m.Where(p...)
  2132. }
  2133. // Op returns the operation name.
  2134. func (m *SopNodeMutation) Op() Op {
  2135. return m.op
  2136. }
  2137. // SetOp allows setting the mutation operation.
  2138. func (m *SopNodeMutation) SetOp(op Op) {
  2139. m.op = op
  2140. }
  2141. // Type returns the node type of this mutation (SopNode).
  2142. func (m *SopNodeMutation) Type() string {
  2143. return m.typ
  2144. }
  2145. // Fields returns all fields that were changed during this mutation. Note that in
  2146. // order to get all numeric fields that were incremented/decremented, call
  2147. // AddedFields().
  2148. func (m *SopNodeMutation) Fields() []string {
  2149. fields := make([]string, 0, 12)
  2150. if m.created_at != nil {
  2151. fields = append(fields, sopnode.FieldCreatedAt)
  2152. }
  2153. if m.updated_at != nil {
  2154. fields = append(fields, sopnode.FieldUpdatedAt)
  2155. }
  2156. if m.status != nil {
  2157. fields = append(fields, sopnode.FieldStatus)
  2158. }
  2159. if m.sop_stage != nil {
  2160. fields = append(fields, sopnode.FieldStageID)
  2161. }
  2162. if m.parent_id != nil {
  2163. fields = append(fields, sopnode.FieldParentID)
  2164. }
  2165. if m.name != nil {
  2166. fields = append(fields, sopnode.FieldName)
  2167. }
  2168. if m.condition_type != nil {
  2169. fields = append(fields, sopnode.FieldConditionType)
  2170. }
  2171. if m.condition_list != nil {
  2172. fields = append(fields, sopnode.FieldConditionList)
  2173. }
  2174. if m.no_reply_condition != nil {
  2175. fields = append(fields, sopnode.FieldNoReplyCondition)
  2176. }
  2177. if m.action_message != nil {
  2178. fields = append(fields, sopnode.FieldActionMessage)
  2179. }
  2180. if m.action_label != nil {
  2181. fields = append(fields, sopnode.FieldActionLabel)
  2182. }
  2183. if m.deleted_at != nil {
  2184. fields = append(fields, sopnode.FieldDeletedAt)
  2185. }
  2186. return fields
  2187. }
  2188. // Field returns the value of a field with the given name. The second boolean
  2189. // return value indicates that this field was not set, or was not defined in the
  2190. // schema.
  2191. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  2192. switch name {
  2193. case sopnode.FieldCreatedAt:
  2194. return m.CreatedAt()
  2195. case sopnode.FieldUpdatedAt:
  2196. return m.UpdatedAt()
  2197. case sopnode.FieldStatus:
  2198. return m.Status()
  2199. case sopnode.FieldStageID:
  2200. return m.StageID()
  2201. case sopnode.FieldParentID:
  2202. return m.ParentID()
  2203. case sopnode.FieldName:
  2204. return m.Name()
  2205. case sopnode.FieldConditionType:
  2206. return m.ConditionType()
  2207. case sopnode.FieldConditionList:
  2208. return m.ConditionList()
  2209. case sopnode.FieldNoReplyCondition:
  2210. return m.NoReplyCondition()
  2211. case sopnode.FieldActionMessage:
  2212. return m.ActionMessage()
  2213. case sopnode.FieldActionLabel:
  2214. return m.ActionLabel()
  2215. case sopnode.FieldDeletedAt:
  2216. return m.DeletedAt()
  2217. }
  2218. return nil, false
  2219. }
  2220. // OldField returns the old value of the field from the database. An error is
  2221. // returned if the mutation operation is not UpdateOne, or the query to the
  2222. // database failed.
  2223. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2224. switch name {
  2225. case sopnode.FieldCreatedAt:
  2226. return m.OldCreatedAt(ctx)
  2227. case sopnode.FieldUpdatedAt:
  2228. return m.OldUpdatedAt(ctx)
  2229. case sopnode.FieldStatus:
  2230. return m.OldStatus(ctx)
  2231. case sopnode.FieldStageID:
  2232. return m.OldStageID(ctx)
  2233. case sopnode.FieldParentID:
  2234. return m.OldParentID(ctx)
  2235. case sopnode.FieldName:
  2236. return m.OldName(ctx)
  2237. case sopnode.FieldConditionType:
  2238. return m.OldConditionType(ctx)
  2239. case sopnode.FieldConditionList:
  2240. return m.OldConditionList(ctx)
  2241. case sopnode.FieldNoReplyCondition:
  2242. return m.OldNoReplyCondition(ctx)
  2243. case sopnode.FieldActionMessage:
  2244. return m.OldActionMessage(ctx)
  2245. case sopnode.FieldActionLabel:
  2246. return m.OldActionLabel(ctx)
  2247. case sopnode.FieldDeletedAt:
  2248. return m.OldDeletedAt(ctx)
  2249. }
  2250. return nil, fmt.Errorf("unknown SopNode field %s", name)
  2251. }
  2252. // SetField sets the value of a field with the given name. It returns an error if
  2253. // the field is not defined in the schema, or if the type mismatched the field
  2254. // type.
  2255. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  2256. switch name {
  2257. case sopnode.FieldCreatedAt:
  2258. v, ok := value.(time.Time)
  2259. if !ok {
  2260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2261. }
  2262. m.SetCreatedAt(v)
  2263. return nil
  2264. case sopnode.FieldUpdatedAt:
  2265. v, ok := value.(time.Time)
  2266. if !ok {
  2267. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2268. }
  2269. m.SetUpdatedAt(v)
  2270. return nil
  2271. case sopnode.FieldStatus:
  2272. v, ok := value.(uint8)
  2273. if !ok {
  2274. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2275. }
  2276. m.SetStatus(v)
  2277. return nil
  2278. case sopnode.FieldStageID:
  2279. v, ok := value.(uint64)
  2280. if !ok {
  2281. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2282. }
  2283. m.SetStageID(v)
  2284. return nil
  2285. case sopnode.FieldParentID:
  2286. v, ok := value.(uint64)
  2287. if !ok {
  2288. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2289. }
  2290. m.SetParentID(v)
  2291. return nil
  2292. case sopnode.FieldName:
  2293. v, ok := value.(string)
  2294. if !ok {
  2295. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2296. }
  2297. m.SetName(v)
  2298. return nil
  2299. case sopnode.FieldConditionType:
  2300. v, ok := value.(int)
  2301. if !ok {
  2302. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2303. }
  2304. m.SetConditionType(v)
  2305. return nil
  2306. case sopnode.FieldConditionList:
  2307. v, ok := value.([]string)
  2308. if !ok {
  2309. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2310. }
  2311. m.SetConditionList(v)
  2312. return nil
  2313. case sopnode.FieldNoReplyCondition:
  2314. v, ok := value.(uint64)
  2315. if !ok {
  2316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2317. }
  2318. m.SetNoReplyCondition(v)
  2319. return nil
  2320. case sopnode.FieldActionMessage:
  2321. v, ok := value.([]custom_types.Action)
  2322. if !ok {
  2323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2324. }
  2325. m.SetActionMessage(v)
  2326. return nil
  2327. case sopnode.FieldActionLabel:
  2328. v, ok := value.([]uint64)
  2329. if !ok {
  2330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2331. }
  2332. m.SetActionLabel(v)
  2333. return nil
  2334. case sopnode.FieldDeletedAt:
  2335. v, ok := value.(time.Time)
  2336. if !ok {
  2337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2338. }
  2339. m.SetDeletedAt(v)
  2340. return nil
  2341. }
  2342. return fmt.Errorf("unknown SopNode field %s", name)
  2343. }
  2344. // AddedFields returns all numeric fields that were incremented/decremented during
  2345. // this mutation.
  2346. func (m *SopNodeMutation) AddedFields() []string {
  2347. var fields []string
  2348. if m.addstatus != nil {
  2349. fields = append(fields, sopnode.FieldStatus)
  2350. }
  2351. if m.addparent_id != nil {
  2352. fields = append(fields, sopnode.FieldParentID)
  2353. }
  2354. if m.addcondition_type != nil {
  2355. fields = append(fields, sopnode.FieldConditionType)
  2356. }
  2357. if m.addno_reply_condition != nil {
  2358. fields = append(fields, sopnode.FieldNoReplyCondition)
  2359. }
  2360. return fields
  2361. }
  2362. // AddedField returns the numeric value that was incremented/decremented on a field
  2363. // with the given name. The second boolean return value indicates that this field
  2364. // was not set, or was not defined in the schema.
  2365. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  2366. switch name {
  2367. case sopnode.FieldStatus:
  2368. return m.AddedStatus()
  2369. case sopnode.FieldParentID:
  2370. return m.AddedParentID()
  2371. case sopnode.FieldConditionType:
  2372. return m.AddedConditionType()
  2373. case sopnode.FieldNoReplyCondition:
  2374. return m.AddedNoReplyCondition()
  2375. }
  2376. return nil, false
  2377. }
  2378. // AddField adds the value to the field with the given name. It returns an error if
  2379. // the field is not defined in the schema, or if the type mismatched the field
  2380. // type.
  2381. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  2382. switch name {
  2383. case sopnode.FieldStatus:
  2384. v, ok := value.(int8)
  2385. if !ok {
  2386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2387. }
  2388. m.AddStatus(v)
  2389. return nil
  2390. case sopnode.FieldParentID:
  2391. v, ok := value.(int64)
  2392. if !ok {
  2393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2394. }
  2395. m.AddParentID(v)
  2396. return nil
  2397. case sopnode.FieldConditionType:
  2398. v, ok := value.(int)
  2399. if !ok {
  2400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2401. }
  2402. m.AddConditionType(v)
  2403. return nil
  2404. case sopnode.FieldNoReplyCondition:
  2405. v, ok := value.(int64)
  2406. if !ok {
  2407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2408. }
  2409. m.AddNoReplyCondition(v)
  2410. return nil
  2411. }
  2412. return fmt.Errorf("unknown SopNode numeric field %s", name)
  2413. }
  2414. // ClearedFields returns all nullable fields that were cleared during this
  2415. // mutation.
  2416. func (m *SopNodeMutation) ClearedFields() []string {
  2417. var fields []string
  2418. if m.FieldCleared(sopnode.FieldStatus) {
  2419. fields = append(fields, sopnode.FieldStatus)
  2420. }
  2421. if m.FieldCleared(sopnode.FieldConditionList) {
  2422. fields = append(fields, sopnode.FieldConditionList)
  2423. }
  2424. if m.FieldCleared(sopnode.FieldActionMessage) {
  2425. fields = append(fields, sopnode.FieldActionMessage)
  2426. }
  2427. if m.FieldCleared(sopnode.FieldActionLabel) {
  2428. fields = append(fields, sopnode.FieldActionLabel)
  2429. }
  2430. if m.FieldCleared(sopnode.FieldDeletedAt) {
  2431. fields = append(fields, sopnode.FieldDeletedAt)
  2432. }
  2433. return fields
  2434. }
  2435. // FieldCleared returns a boolean indicating if a field with the given name was
  2436. // cleared in this mutation.
  2437. func (m *SopNodeMutation) FieldCleared(name string) bool {
  2438. _, ok := m.clearedFields[name]
  2439. return ok
  2440. }
  2441. // ClearField clears the value of the field with the given name. It returns an
  2442. // error if the field is not defined in the schema.
  2443. func (m *SopNodeMutation) ClearField(name string) error {
  2444. switch name {
  2445. case sopnode.FieldStatus:
  2446. m.ClearStatus()
  2447. return nil
  2448. case sopnode.FieldConditionList:
  2449. m.ClearConditionList()
  2450. return nil
  2451. case sopnode.FieldActionMessage:
  2452. m.ClearActionMessage()
  2453. return nil
  2454. case sopnode.FieldActionLabel:
  2455. m.ClearActionLabel()
  2456. return nil
  2457. case sopnode.FieldDeletedAt:
  2458. m.ClearDeletedAt()
  2459. return nil
  2460. }
  2461. return fmt.Errorf("unknown SopNode nullable field %s", name)
  2462. }
  2463. // ResetField resets all changes in the mutation for the field with the given name.
  2464. // It returns an error if the field is not defined in the schema.
  2465. func (m *SopNodeMutation) ResetField(name string) error {
  2466. switch name {
  2467. case sopnode.FieldCreatedAt:
  2468. m.ResetCreatedAt()
  2469. return nil
  2470. case sopnode.FieldUpdatedAt:
  2471. m.ResetUpdatedAt()
  2472. return nil
  2473. case sopnode.FieldStatus:
  2474. m.ResetStatus()
  2475. return nil
  2476. case sopnode.FieldStageID:
  2477. m.ResetStageID()
  2478. return nil
  2479. case sopnode.FieldParentID:
  2480. m.ResetParentID()
  2481. return nil
  2482. case sopnode.FieldName:
  2483. m.ResetName()
  2484. return nil
  2485. case sopnode.FieldConditionType:
  2486. m.ResetConditionType()
  2487. return nil
  2488. case sopnode.FieldConditionList:
  2489. m.ResetConditionList()
  2490. return nil
  2491. case sopnode.FieldNoReplyCondition:
  2492. m.ResetNoReplyCondition()
  2493. return nil
  2494. case sopnode.FieldActionMessage:
  2495. m.ResetActionMessage()
  2496. return nil
  2497. case sopnode.FieldActionLabel:
  2498. m.ResetActionLabel()
  2499. return nil
  2500. case sopnode.FieldDeletedAt:
  2501. m.ResetDeletedAt()
  2502. return nil
  2503. }
  2504. return fmt.Errorf("unknown SopNode field %s", name)
  2505. }
  2506. // AddedEdges returns all edge names that were set/added in this mutation.
  2507. func (m *SopNodeMutation) AddedEdges() []string {
  2508. edges := make([]string, 0, 2)
  2509. if m.sop_stage != nil {
  2510. edges = append(edges, sopnode.EdgeSopStage)
  2511. }
  2512. if m.node_messages != nil {
  2513. edges = append(edges, sopnode.EdgeNodeMessages)
  2514. }
  2515. return edges
  2516. }
  2517. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2518. // name in this mutation.
  2519. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  2520. switch name {
  2521. case sopnode.EdgeSopStage:
  2522. if id := m.sop_stage; id != nil {
  2523. return []ent.Value{*id}
  2524. }
  2525. case sopnode.EdgeNodeMessages:
  2526. ids := make([]ent.Value, 0, len(m.node_messages))
  2527. for id := range m.node_messages {
  2528. ids = append(ids, id)
  2529. }
  2530. return ids
  2531. }
  2532. return nil
  2533. }
  2534. // RemovedEdges returns all edge names that were removed in this mutation.
  2535. func (m *SopNodeMutation) RemovedEdges() []string {
  2536. edges := make([]string, 0, 2)
  2537. if m.removednode_messages != nil {
  2538. edges = append(edges, sopnode.EdgeNodeMessages)
  2539. }
  2540. return edges
  2541. }
  2542. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2543. // the given name in this mutation.
  2544. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  2545. switch name {
  2546. case sopnode.EdgeNodeMessages:
  2547. ids := make([]ent.Value, 0, len(m.removednode_messages))
  2548. for id := range m.removednode_messages {
  2549. ids = append(ids, id)
  2550. }
  2551. return ids
  2552. }
  2553. return nil
  2554. }
  2555. // ClearedEdges returns all edge names that were cleared in this mutation.
  2556. func (m *SopNodeMutation) ClearedEdges() []string {
  2557. edges := make([]string, 0, 2)
  2558. if m.clearedsop_stage {
  2559. edges = append(edges, sopnode.EdgeSopStage)
  2560. }
  2561. if m.clearednode_messages {
  2562. edges = append(edges, sopnode.EdgeNodeMessages)
  2563. }
  2564. return edges
  2565. }
  2566. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2567. // was cleared in this mutation.
  2568. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  2569. switch name {
  2570. case sopnode.EdgeSopStage:
  2571. return m.clearedsop_stage
  2572. case sopnode.EdgeNodeMessages:
  2573. return m.clearednode_messages
  2574. }
  2575. return false
  2576. }
  2577. // ClearEdge clears the value of the edge with the given name. It returns an error
  2578. // if that edge is not defined in the schema.
  2579. func (m *SopNodeMutation) ClearEdge(name string) error {
  2580. switch name {
  2581. case sopnode.EdgeSopStage:
  2582. m.ClearSopStage()
  2583. return nil
  2584. }
  2585. return fmt.Errorf("unknown SopNode unique edge %s", name)
  2586. }
  2587. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2588. // It returns an error if the edge is not defined in the schema.
  2589. func (m *SopNodeMutation) ResetEdge(name string) error {
  2590. switch name {
  2591. case sopnode.EdgeSopStage:
  2592. m.ResetSopStage()
  2593. return nil
  2594. case sopnode.EdgeNodeMessages:
  2595. m.ResetNodeMessages()
  2596. return nil
  2597. }
  2598. return fmt.Errorf("unknown SopNode edge %s", name)
  2599. }
  2600. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  2601. type SopStageMutation struct {
  2602. config
  2603. op Op
  2604. typ string
  2605. id *uint64
  2606. created_at *time.Time
  2607. updated_at *time.Time
  2608. status *uint8
  2609. addstatus *int8
  2610. name *string
  2611. condition_type *int
  2612. addcondition_type *int
  2613. condition_operator *int
  2614. addcondition_operator *int
  2615. condition_list *[]custom_types.Condition
  2616. appendcondition_list []custom_types.Condition
  2617. action_message *[]custom_types.Action
  2618. appendaction_message []custom_types.Action
  2619. action_label *[]uint64
  2620. appendaction_label []uint64
  2621. index_sort *int
  2622. addindex_sort *int
  2623. deleted_at *time.Time
  2624. clearedFields map[string]struct{}
  2625. sop_task *uint64
  2626. clearedsop_task bool
  2627. stage_nodes map[uint64]struct{}
  2628. removedstage_nodes map[uint64]struct{}
  2629. clearedstage_nodes bool
  2630. stage_messages map[uint64]struct{}
  2631. removedstage_messages map[uint64]struct{}
  2632. clearedstage_messages bool
  2633. done bool
  2634. oldValue func(context.Context) (*SopStage, error)
  2635. predicates []predicate.SopStage
  2636. }
  2637. var _ ent.Mutation = (*SopStageMutation)(nil)
  2638. // sopstageOption allows management of the mutation configuration using functional options.
  2639. type sopstageOption func(*SopStageMutation)
  2640. // newSopStageMutation creates new mutation for the SopStage entity.
  2641. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  2642. m := &SopStageMutation{
  2643. config: c,
  2644. op: op,
  2645. typ: TypeSopStage,
  2646. clearedFields: make(map[string]struct{}),
  2647. }
  2648. for _, opt := range opts {
  2649. opt(m)
  2650. }
  2651. return m
  2652. }
  2653. // withSopStageID sets the ID field of the mutation.
  2654. func withSopStageID(id uint64) sopstageOption {
  2655. return func(m *SopStageMutation) {
  2656. var (
  2657. err error
  2658. once sync.Once
  2659. value *SopStage
  2660. )
  2661. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  2662. once.Do(func() {
  2663. if m.done {
  2664. err = errors.New("querying old values post mutation is not allowed")
  2665. } else {
  2666. value, err = m.Client().SopStage.Get(ctx, id)
  2667. }
  2668. })
  2669. return value, err
  2670. }
  2671. m.id = &id
  2672. }
  2673. }
  2674. // withSopStage sets the old SopStage of the mutation.
  2675. func withSopStage(node *SopStage) sopstageOption {
  2676. return func(m *SopStageMutation) {
  2677. m.oldValue = func(context.Context) (*SopStage, error) {
  2678. return node, nil
  2679. }
  2680. m.id = &node.ID
  2681. }
  2682. }
  2683. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2684. // executed in a transaction (ent.Tx), a transactional client is returned.
  2685. func (m SopStageMutation) Client() *Client {
  2686. client := &Client{config: m.config}
  2687. client.init()
  2688. return client
  2689. }
  2690. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2691. // it returns an error otherwise.
  2692. func (m SopStageMutation) Tx() (*Tx, error) {
  2693. if _, ok := m.driver.(*txDriver); !ok {
  2694. return nil, errors.New("ent: mutation is not running in a transaction")
  2695. }
  2696. tx := &Tx{config: m.config}
  2697. tx.init()
  2698. return tx, nil
  2699. }
  2700. // SetID sets the value of the id field. Note that this
  2701. // operation is only accepted on creation of SopStage entities.
  2702. func (m *SopStageMutation) SetID(id uint64) {
  2703. m.id = &id
  2704. }
  2705. // ID returns the ID value in the mutation. Note that the ID is only available
  2706. // if it was provided to the builder or after it was returned from the database.
  2707. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  2708. if m.id == nil {
  2709. return
  2710. }
  2711. return *m.id, true
  2712. }
  2713. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2714. // That means, if the mutation is applied within a transaction with an isolation level such
  2715. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2716. // or updated by the mutation.
  2717. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  2718. switch {
  2719. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2720. id, exists := m.ID()
  2721. if exists {
  2722. return []uint64{id}, nil
  2723. }
  2724. fallthrough
  2725. case m.op.Is(OpUpdate | OpDelete):
  2726. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  2727. default:
  2728. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2729. }
  2730. }
  2731. // SetCreatedAt sets the "created_at" field.
  2732. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  2733. m.created_at = &t
  2734. }
  2735. // CreatedAt returns the value of the "created_at" field in the mutation.
  2736. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  2737. v := m.created_at
  2738. if v == nil {
  2739. return
  2740. }
  2741. return *v, true
  2742. }
  2743. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  2744. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  2745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2746. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2747. if !m.op.Is(OpUpdateOne) {
  2748. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2749. }
  2750. if m.id == nil || m.oldValue == nil {
  2751. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2752. }
  2753. oldValue, err := m.oldValue(ctx)
  2754. if err != nil {
  2755. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2756. }
  2757. return oldValue.CreatedAt, nil
  2758. }
  2759. // ResetCreatedAt resets all changes to the "created_at" field.
  2760. func (m *SopStageMutation) ResetCreatedAt() {
  2761. m.created_at = nil
  2762. }
  2763. // SetUpdatedAt sets the "updated_at" field.
  2764. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  2765. m.updated_at = &t
  2766. }
  2767. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2768. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  2769. v := m.updated_at
  2770. if v == nil {
  2771. return
  2772. }
  2773. return *v, true
  2774. }
  2775. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  2776. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  2777. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2778. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2779. if !m.op.Is(OpUpdateOne) {
  2780. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2781. }
  2782. if m.id == nil || m.oldValue == nil {
  2783. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2784. }
  2785. oldValue, err := m.oldValue(ctx)
  2786. if err != nil {
  2787. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2788. }
  2789. return oldValue.UpdatedAt, nil
  2790. }
  2791. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2792. func (m *SopStageMutation) ResetUpdatedAt() {
  2793. m.updated_at = nil
  2794. }
  2795. // SetStatus sets the "status" field.
  2796. func (m *SopStageMutation) SetStatus(u uint8) {
  2797. m.status = &u
  2798. m.addstatus = nil
  2799. }
  2800. // Status returns the value of the "status" field in the mutation.
  2801. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  2802. v := m.status
  2803. if v == nil {
  2804. return
  2805. }
  2806. return *v, true
  2807. }
  2808. // OldStatus returns the old "status" field's value of the SopStage entity.
  2809. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  2810. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2811. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  2812. if !m.op.Is(OpUpdateOne) {
  2813. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  2814. }
  2815. if m.id == nil || m.oldValue == nil {
  2816. return v, errors.New("OldStatus requires an ID field in the mutation")
  2817. }
  2818. oldValue, err := m.oldValue(ctx)
  2819. if err != nil {
  2820. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  2821. }
  2822. return oldValue.Status, nil
  2823. }
  2824. // AddStatus adds u to the "status" field.
  2825. func (m *SopStageMutation) AddStatus(u int8) {
  2826. if m.addstatus != nil {
  2827. *m.addstatus += u
  2828. } else {
  2829. m.addstatus = &u
  2830. }
  2831. }
  2832. // AddedStatus returns the value that was added to the "status" field in this mutation.
  2833. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  2834. v := m.addstatus
  2835. if v == nil {
  2836. return
  2837. }
  2838. return *v, true
  2839. }
  2840. // ClearStatus clears the value of the "status" field.
  2841. func (m *SopStageMutation) ClearStatus() {
  2842. m.status = nil
  2843. m.addstatus = nil
  2844. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  2845. }
  2846. // StatusCleared returns if the "status" field was cleared in this mutation.
  2847. func (m *SopStageMutation) StatusCleared() bool {
  2848. _, ok := m.clearedFields[sopstage.FieldStatus]
  2849. return ok
  2850. }
  2851. // ResetStatus resets all changes to the "status" field.
  2852. func (m *SopStageMutation) ResetStatus() {
  2853. m.status = nil
  2854. m.addstatus = nil
  2855. delete(m.clearedFields, sopstage.FieldStatus)
  2856. }
  2857. // SetTaskID sets the "task_id" field.
  2858. func (m *SopStageMutation) SetTaskID(u uint64) {
  2859. m.sop_task = &u
  2860. }
  2861. // TaskID returns the value of the "task_id" field in the mutation.
  2862. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  2863. v := m.sop_task
  2864. if v == nil {
  2865. return
  2866. }
  2867. return *v, true
  2868. }
  2869. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  2870. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  2871. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2872. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  2873. if !m.op.Is(OpUpdateOne) {
  2874. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  2875. }
  2876. if m.id == nil || m.oldValue == nil {
  2877. return v, errors.New("OldTaskID requires an ID field in the mutation")
  2878. }
  2879. oldValue, err := m.oldValue(ctx)
  2880. if err != nil {
  2881. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  2882. }
  2883. return oldValue.TaskID, nil
  2884. }
  2885. // ResetTaskID resets all changes to the "task_id" field.
  2886. func (m *SopStageMutation) ResetTaskID() {
  2887. m.sop_task = nil
  2888. }
  2889. // SetName sets the "name" field.
  2890. func (m *SopStageMutation) SetName(s string) {
  2891. m.name = &s
  2892. }
  2893. // Name returns the value of the "name" field in the mutation.
  2894. func (m *SopStageMutation) Name() (r string, exists bool) {
  2895. v := m.name
  2896. if v == nil {
  2897. return
  2898. }
  2899. return *v, true
  2900. }
  2901. // OldName returns the old "name" field's value of the SopStage entity.
  2902. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  2903. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2904. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  2905. if !m.op.Is(OpUpdateOne) {
  2906. return v, errors.New("OldName is only allowed on UpdateOne operations")
  2907. }
  2908. if m.id == nil || m.oldValue == nil {
  2909. return v, errors.New("OldName requires an ID field in the mutation")
  2910. }
  2911. oldValue, err := m.oldValue(ctx)
  2912. if err != nil {
  2913. return v, fmt.Errorf("querying old value for OldName: %w", err)
  2914. }
  2915. return oldValue.Name, nil
  2916. }
  2917. // ResetName resets all changes to the "name" field.
  2918. func (m *SopStageMutation) ResetName() {
  2919. m.name = nil
  2920. }
  2921. // SetConditionType sets the "condition_type" field.
  2922. func (m *SopStageMutation) SetConditionType(i int) {
  2923. m.condition_type = &i
  2924. m.addcondition_type = nil
  2925. }
  2926. // ConditionType returns the value of the "condition_type" field in the mutation.
  2927. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  2928. v := m.condition_type
  2929. if v == nil {
  2930. return
  2931. }
  2932. return *v, true
  2933. }
  2934. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  2935. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  2936. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2937. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  2938. if !m.op.Is(OpUpdateOne) {
  2939. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  2940. }
  2941. if m.id == nil || m.oldValue == nil {
  2942. return v, errors.New("OldConditionType requires an ID field in the mutation")
  2943. }
  2944. oldValue, err := m.oldValue(ctx)
  2945. if err != nil {
  2946. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  2947. }
  2948. return oldValue.ConditionType, nil
  2949. }
  2950. // AddConditionType adds i to the "condition_type" field.
  2951. func (m *SopStageMutation) AddConditionType(i int) {
  2952. if m.addcondition_type != nil {
  2953. *m.addcondition_type += i
  2954. } else {
  2955. m.addcondition_type = &i
  2956. }
  2957. }
  2958. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  2959. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  2960. v := m.addcondition_type
  2961. if v == nil {
  2962. return
  2963. }
  2964. return *v, true
  2965. }
  2966. // ResetConditionType resets all changes to the "condition_type" field.
  2967. func (m *SopStageMutation) ResetConditionType() {
  2968. m.condition_type = nil
  2969. m.addcondition_type = nil
  2970. }
  2971. // SetConditionOperator sets the "condition_operator" field.
  2972. func (m *SopStageMutation) SetConditionOperator(i int) {
  2973. m.condition_operator = &i
  2974. m.addcondition_operator = nil
  2975. }
  2976. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  2977. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  2978. v := m.condition_operator
  2979. if v == nil {
  2980. return
  2981. }
  2982. return *v, true
  2983. }
  2984. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  2985. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  2986. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2987. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  2988. if !m.op.Is(OpUpdateOne) {
  2989. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  2990. }
  2991. if m.id == nil || m.oldValue == nil {
  2992. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  2993. }
  2994. oldValue, err := m.oldValue(ctx)
  2995. if err != nil {
  2996. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  2997. }
  2998. return oldValue.ConditionOperator, nil
  2999. }
  3000. // AddConditionOperator adds i to the "condition_operator" field.
  3001. func (m *SopStageMutation) AddConditionOperator(i int) {
  3002. if m.addcondition_operator != nil {
  3003. *m.addcondition_operator += i
  3004. } else {
  3005. m.addcondition_operator = &i
  3006. }
  3007. }
  3008. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  3009. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  3010. v := m.addcondition_operator
  3011. if v == nil {
  3012. return
  3013. }
  3014. return *v, true
  3015. }
  3016. // ResetConditionOperator resets all changes to the "condition_operator" field.
  3017. func (m *SopStageMutation) ResetConditionOperator() {
  3018. m.condition_operator = nil
  3019. m.addcondition_operator = nil
  3020. }
  3021. // SetConditionList sets the "condition_list" field.
  3022. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  3023. m.condition_list = &ct
  3024. m.appendcondition_list = nil
  3025. }
  3026. // ConditionList returns the value of the "condition_list" field in the mutation.
  3027. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  3028. v := m.condition_list
  3029. if v == nil {
  3030. return
  3031. }
  3032. return *v, true
  3033. }
  3034. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  3035. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  3036. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3037. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  3038. if !m.op.Is(OpUpdateOne) {
  3039. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  3040. }
  3041. if m.id == nil || m.oldValue == nil {
  3042. return v, errors.New("OldConditionList requires an ID field in the mutation")
  3043. }
  3044. oldValue, err := m.oldValue(ctx)
  3045. if err != nil {
  3046. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  3047. }
  3048. return oldValue.ConditionList, nil
  3049. }
  3050. // AppendConditionList adds ct to the "condition_list" field.
  3051. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  3052. m.appendcondition_list = append(m.appendcondition_list, ct...)
  3053. }
  3054. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  3055. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  3056. if len(m.appendcondition_list) == 0 {
  3057. return nil, false
  3058. }
  3059. return m.appendcondition_list, true
  3060. }
  3061. // ResetConditionList resets all changes to the "condition_list" field.
  3062. func (m *SopStageMutation) ResetConditionList() {
  3063. m.condition_list = nil
  3064. m.appendcondition_list = nil
  3065. }
  3066. // SetActionMessage sets the "action_message" field.
  3067. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  3068. m.action_message = &ct
  3069. m.appendaction_message = nil
  3070. }
  3071. // ActionMessage returns the value of the "action_message" field in the mutation.
  3072. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  3073. v := m.action_message
  3074. if v == nil {
  3075. return
  3076. }
  3077. return *v, true
  3078. }
  3079. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  3080. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  3081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3082. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  3083. if !m.op.Is(OpUpdateOne) {
  3084. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  3085. }
  3086. if m.id == nil || m.oldValue == nil {
  3087. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  3088. }
  3089. oldValue, err := m.oldValue(ctx)
  3090. if err != nil {
  3091. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  3092. }
  3093. return oldValue.ActionMessage, nil
  3094. }
  3095. // AppendActionMessage adds ct to the "action_message" field.
  3096. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  3097. m.appendaction_message = append(m.appendaction_message, ct...)
  3098. }
  3099. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  3100. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  3101. if len(m.appendaction_message) == 0 {
  3102. return nil, false
  3103. }
  3104. return m.appendaction_message, true
  3105. }
  3106. // ClearActionMessage clears the value of the "action_message" field.
  3107. func (m *SopStageMutation) ClearActionMessage() {
  3108. m.action_message = nil
  3109. m.appendaction_message = nil
  3110. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  3111. }
  3112. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  3113. func (m *SopStageMutation) ActionMessageCleared() bool {
  3114. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  3115. return ok
  3116. }
  3117. // ResetActionMessage resets all changes to the "action_message" field.
  3118. func (m *SopStageMutation) ResetActionMessage() {
  3119. m.action_message = nil
  3120. m.appendaction_message = nil
  3121. delete(m.clearedFields, sopstage.FieldActionMessage)
  3122. }
  3123. // SetActionLabel sets the "action_label" field.
  3124. func (m *SopStageMutation) SetActionLabel(u []uint64) {
  3125. m.action_label = &u
  3126. m.appendaction_label = nil
  3127. }
  3128. // ActionLabel returns the value of the "action_label" field in the mutation.
  3129. func (m *SopStageMutation) ActionLabel() (r []uint64, exists bool) {
  3130. v := m.action_label
  3131. if v == nil {
  3132. return
  3133. }
  3134. return *v, true
  3135. }
  3136. // OldActionLabel returns the old "action_label" field's value of the SopStage entity.
  3137. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  3138. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3139. func (m *SopStageMutation) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  3140. if !m.op.Is(OpUpdateOne) {
  3141. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  3142. }
  3143. if m.id == nil || m.oldValue == nil {
  3144. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  3145. }
  3146. oldValue, err := m.oldValue(ctx)
  3147. if err != nil {
  3148. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  3149. }
  3150. return oldValue.ActionLabel, nil
  3151. }
  3152. // AppendActionLabel adds u to the "action_label" field.
  3153. func (m *SopStageMutation) AppendActionLabel(u []uint64) {
  3154. m.appendaction_label = append(m.appendaction_label, u...)
  3155. }
  3156. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  3157. func (m *SopStageMutation) AppendedActionLabel() ([]uint64, bool) {
  3158. if len(m.appendaction_label) == 0 {
  3159. return nil, false
  3160. }
  3161. return m.appendaction_label, true
  3162. }
  3163. // ClearActionLabel clears the value of the "action_label" field.
  3164. func (m *SopStageMutation) ClearActionLabel() {
  3165. m.action_label = nil
  3166. m.appendaction_label = nil
  3167. m.clearedFields[sopstage.FieldActionLabel] = struct{}{}
  3168. }
  3169. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  3170. func (m *SopStageMutation) ActionLabelCleared() bool {
  3171. _, ok := m.clearedFields[sopstage.FieldActionLabel]
  3172. return ok
  3173. }
  3174. // ResetActionLabel resets all changes to the "action_label" field.
  3175. func (m *SopStageMutation) ResetActionLabel() {
  3176. m.action_label = nil
  3177. m.appendaction_label = nil
  3178. delete(m.clearedFields, sopstage.FieldActionLabel)
  3179. }
  3180. // SetIndexSort sets the "index_sort" field.
  3181. func (m *SopStageMutation) SetIndexSort(i int) {
  3182. m.index_sort = &i
  3183. m.addindex_sort = nil
  3184. }
  3185. // IndexSort returns the value of the "index_sort" field in the mutation.
  3186. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  3187. v := m.index_sort
  3188. if v == nil {
  3189. return
  3190. }
  3191. return *v, true
  3192. }
  3193. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  3194. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  3195. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3196. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  3197. if !m.op.Is(OpUpdateOne) {
  3198. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  3199. }
  3200. if m.id == nil || m.oldValue == nil {
  3201. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  3202. }
  3203. oldValue, err := m.oldValue(ctx)
  3204. if err != nil {
  3205. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  3206. }
  3207. return oldValue.IndexSort, nil
  3208. }
  3209. // AddIndexSort adds i to the "index_sort" field.
  3210. func (m *SopStageMutation) AddIndexSort(i int) {
  3211. if m.addindex_sort != nil {
  3212. *m.addindex_sort += i
  3213. } else {
  3214. m.addindex_sort = &i
  3215. }
  3216. }
  3217. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  3218. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  3219. v := m.addindex_sort
  3220. if v == nil {
  3221. return
  3222. }
  3223. return *v, true
  3224. }
  3225. // ClearIndexSort clears the value of the "index_sort" field.
  3226. func (m *SopStageMutation) ClearIndexSort() {
  3227. m.index_sort = nil
  3228. m.addindex_sort = nil
  3229. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  3230. }
  3231. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  3232. func (m *SopStageMutation) IndexSortCleared() bool {
  3233. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  3234. return ok
  3235. }
  3236. // ResetIndexSort resets all changes to the "index_sort" field.
  3237. func (m *SopStageMutation) ResetIndexSort() {
  3238. m.index_sort = nil
  3239. m.addindex_sort = nil
  3240. delete(m.clearedFields, sopstage.FieldIndexSort)
  3241. }
  3242. // SetDeletedAt sets the "deleted_at" field.
  3243. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  3244. m.deleted_at = &t
  3245. }
  3246. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3247. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  3248. v := m.deleted_at
  3249. if v == nil {
  3250. return
  3251. }
  3252. return *v, true
  3253. }
  3254. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  3255. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  3256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3257. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3258. if !m.op.Is(OpUpdateOne) {
  3259. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3260. }
  3261. if m.id == nil || m.oldValue == nil {
  3262. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3263. }
  3264. oldValue, err := m.oldValue(ctx)
  3265. if err != nil {
  3266. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3267. }
  3268. return oldValue.DeletedAt, nil
  3269. }
  3270. // ClearDeletedAt clears the value of the "deleted_at" field.
  3271. func (m *SopStageMutation) ClearDeletedAt() {
  3272. m.deleted_at = nil
  3273. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  3274. }
  3275. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3276. func (m *SopStageMutation) DeletedAtCleared() bool {
  3277. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  3278. return ok
  3279. }
  3280. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3281. func (m *SopStageMutation) ResetDeletedAt() {
  3282. m.deleted_at = nil
  3283. delete(m.clearedFields, sopstage.FieldDeletedAt)
  3284. }
  3285. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  3286. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  3287. m.sop_task = &id
  3288. }
  3289. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  3290. func (m *SopStageMutation) ClearSopTask() {
  3291. m.clearedsop_task = true
  3292. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  3293. }
  3294. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  3295. func (m *SopStageMutation) SopTaskCleared() bool {
  3296. return m.clearedsop_task
  3297. }
  3298. // SopTaskID returns the "sop_task" edge ID in the mutation.
  3299. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  3300. if m.sop_task != nil {
  3301. return *m.sop_task, true
  3302. }
  3303. return
  3304. }
  3305. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  3306. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  3307. // SopTaskID instead. It exists only for internal usage by the builders.
  3308. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  3309. if id := m.sop_task; id != nil {
  3310. ids = append(ids, *id)
  3311. }
  3312. return
  3313. }
  3314. // ResetSopTask resets all changes to the "sop_task" edge.
  3315. func (m *SopStageMutation) ResetSopTask() {
  3316. m.sop_task = nil
  3317. m.clearedsop_task = false
  3318. }
  3319. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  3320. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  3321. if m.stage_nodes == nil {
  3322. m.stage_nodes = make(map[uint64]struct{})
  3323. }
  3324. for i := range ids {
  3325. m.stage_nodes[ids[i]] = struct{}{}
  3326. }
  3327. }
  3328. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  3329. func (m *SopStageMutation) ClearStageNodes() {
  3330. m.clearedstage_nodes = true
  3331. }
  3332. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  3333. func (m *SopStageMutation) StageNodesCleared() bool {
  3334. return m.clearedstage_nodes
  3335. }
  3336. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  3337. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  3338. if m.removedstage_nodes == nil {
  3339. m.removedstage_nodes = make(map[uint64]struct{})
  3340. }
  3341. for i := range ids {
  3342. delete(m.stage_nodes, ids[i])
  3343. m.removedstage_nodes[ids[i]] = struct{}{}
  3344. }
  3345. }
  3346. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  3347. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  3348. for id := range m.removedstage_nodes {
  3349. ids = append(ids, id)
  3350. }
  3351. return
  3352. }
  3353. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  3354. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  3355. for id := range m.stage_nodes {
  3356. ids = append(ids, id)
  3357. }
  3358. return
  3359. }
  3360. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  3361. func (m *SopStageMutation) ResetStageNodes() {
  3362. m.stage_nodes = nil
  3363. m.clearedstage_nodes = false
  3364. m.removedstage_nodes = nil
  3365. }
  3366. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  3367. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  3368. if m.stage_messages == nil {
  3369. m.stage_messages = make(map[uint64]struct{})
  3370. }
  3371. for i := range ids {
  3372. m.stage_messages[ids[i]] = struct{}{}
  3373. }
  3374. }
  3375. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  3376. func (m *SopStageMutation) ClearStageMessages() {
  3377. m.clearedstage_messages = true
  3378. }
  3379. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  3380. func (m *SopStageMutation) StageMessagesCleared() bool {
  3381. return m.clearedstage_messages
  3382. }
  3383. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  3384. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  3385. if m.removedstage_messages == nil {
  3386. m.removedstage_messages = make(map[uint64]struct{})
  3387. }
  3388. for i := range ids {
  3389. delete(m.stage_messages, ids[i])
  3390. m.removedstage_messages[ids[i]] = struct{}{}
  3391. }
  3392. }
  3393. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  3394. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  3395. for id := range m.removedstage_messages {
  3396. ids = append(ids, id)
  3397. }
  3398. return
  3399. }
  3400. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  3401. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  3402. for id := range m.stage_messages {
  3403. ids = append(ids, id)
  3404. }
  3405. return
  3406. }
  3407. // ResetStageMessages resets all changes to the "stage_messages" edge.
  3408. func (m *SopStageMutation) ResetStageMessages() {
  3409. m.stage_messages = nil
  3410. m.clearedstage_messages = false
  3411. m.removedstage_messages = nil
  3412. }
  3413. // Where appends a list predicates to the SopStageMutation builder.
  3414. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  3415. m.predicates = append(m.predicates, ps...)
  3416. }
  3417. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  3418. // users can use type-assertion to append predicates that do not depend on any generated package.
  3419. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  3420. p := make([]predicate.SopStage, len(ps))
  3421. for i := range ps {
  3422. p[i] = ps[i]
  3423. }
  3424. m.Where(p...)
  3425. }
  3426. // Op returns the operation name.
  3427. func (m *SopStageMutation) Op() Op {
  3428. return m.op
  3429. }
  3430. // SetOp allows setting the mutation operation.
  3431. func (m *SopStageMutation) SetOp(op Op) {
  3432. m.op = op
  3433. }
  3434. // Type returns the node type of this mutation (SopStage).
  3435. func (m *SopStageMutation) Type() string {
  3436. return m.typ
  3437. }
  3438. // Fields returns all fields that were changed during this mutation. Note that in
  3439. // order to get all numeric fields that were incremented/decremented, call
  3440. // AddedFields().
  3441. func (m *SopStageMutation) Fields() []string {
  3442. fields := make([]string, 0, 12)
  3443. if m.created_at != nil {
  3444. fields = append(fields, sopstage.FieldCreatedAt)
  3445. }
  3446. if m.updated_at != nil {
  3447. fields = append(fields, sopstage.FieldUpdatedAt)
  3448. }
  3449. if m.status != nil {
  3450. fields = append(fields, sopstage.FieldStatus)
  3451. }
  3452. if m.sop_task != nil {
  3453. fields = append(fields, sopstage.FieldTaskID)
  3454. }
  3455. if m.name != nil {
  3456. fields = append(fields, sopstage.FieldName)
  3457. }
  3458. if m.condition_type != nil {
  3459. fields = append(fields, sopstage.FieldConditionType)
  3460. }
  3461. if m.condition_operator != nil {
  3462. fields = append(fields, sopstage.FieldConditionOperator)
  3463. }
  3464. if m.condition_list != nil {
  3465. fields = append(fields, sopstage.FieldConditionList)
  3466. }
  3467. if m.action_message != nil {
  3468. fields = append(fields, sopstage.FieldActionMessage)
  3469. }
  3470. if m.action_label != nil {
  3471. fields = append(fields, sopstage.FieldActionLabel)
  3472. }
  3473. if m.index_sort != nil {
  3474. fields = append(fields, sopstage.FieldIndexSort)
  3475. }
  3476. if m.deleted_at != nil {
  3477. fields = append(fields, sopstage.FieldDeletedAt)
  3478. }
  3479. return fields
  3480. }
  3481. // Field returns the value of a field with the given name. The second boolean
  3482. // return value indicates that this field was not set, or was not defined in the
  3483. // schema.
  3484. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  3485. switch name {
  3486. case sopstage.FieldCreatedAt:
  3487. return m.CreatedAt()
  3488. case sopstage.FieldUpdatedAt:
  3489. return m.UpdatedAt()
  3490. case sopstage.FieldStatus:
  3491. return m.Status()
  3492. case sopstage.FieldTaskID:
  3493. return m.TaskID()
  3494. case sopstage.FieldName:
  3495. return m.Name()
  3496. case sopstage.FieldConditionType:
  3497. return m.ConditionType()
  3498. case sopstage.FieldConditionOperator:
  3499. return m.ConditionOperator()
  3500. case sopstage.FieldConditionList:
  3501. return m.ConditionList()
  3502. case sopstage.FieldActionMessage:
  3503. return m.ActionMessage()
  3504. case sopstage.FieldActionLabel:
  3505. return m.ActionLabel()
  3506. case sopstage.FieldIndexSort:
  3507. return m.IndexSort()
  3508. case sopstage.FieldDeletedAt:
  3509. return m.DeletedAt()
  3510. }
  3511. return nil, false
  3512. }
  3513. // OldField returns the old value of the field from the database. An error is
  3514. // returned if the mutation operation is not UpdateOne, or the query to the
  3515. // database failed.
  3516. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3517. switch name {
  3518. case sopstage.FieldCreatedAt:
  3519. return m.OldCreatedAt(ctx)
  3520. case sopstage.FieldUpdatedAt:
  3521. return m.OldUpdatedAt(ctx)
  3522. case sopstage.FieldStatus:
  3523. return m.OldStatus(ctx)
  3524. case sopstage.FieldTaskID:
  3525. return m.OldTaskID(ctx)
  3526. case sopstage.FieldName:
  3527. return m.OldName(ctx)
  3528. case sopstage.FieldConditionType:
  3529. return m.OldConditionType(ctx)
  3530. case sopstage.FieldConditionOperator:
  3531. return m.OldConditionOperator(ctx)
  3532. case sopstage.FieldConditionList:
  3533. return m.OldConditionList(ctx)
  3534. case sopstage.FieldActionMessage:
  3535. return m.OldActionMessage(ctx)
  3536. case sopstage.FieldActionLabel:
  3537. return m.OldActionLabel(ctx)
  3538. case sopstage.FieldIndexSort:
  3539. return m.OldIndexSort(ctx)
  3540. case sopstage.FieldDeletedAt:
  3541. return m.OldDeletedAt(ctx)
  3542. }
  3543. return nil, fmt.Errorf("unknown SopStage field %s", name)
  3544. }
  3545. // SetField sets the value of a field with the given name. It returns an error if
  3546. // the field is not defined in the schema, or if the type mismatched the field
  3547. // type.
  3548. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  3549. switch name {
  3550. case sopstage.FieldCreatedAt:
  3551. v, ok := value.(time.Time)
  3552. if !ok {
  3553. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3554. }
  3555. m.SetCreatedAt(v)
  3556. return nil
  3557. case sopstage.FieldUpdatedAt:
  3558. v, ok := value.(time.Time)
  3559. if !ok {
  3560. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3561. }
  3562. m.SetUpdatedAt(v)
  3563. return nil
  3564. case sopstage.FieldStatus:
  3565. v, ok := value.(uint8)
  3566. if !ok {
  3567. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3568. }
  3569. m.SetStatus(v)
  3570. return nil
  3571. case sopstage.FieldTaskID:
  3572. v, ok := value.(uint64)
  3573. if !ok {
  3574. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3575. }
  3576. m.SetTaskID(v)
  3577. return nil
  3578. case sopstage.FieldName:
  3579. v, ok := value.(string)
  3580. if !ok {
  3581. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3582. }
  3583. m.SetName(v)
  3584. return nil
  3585. case sopstage.FieldConditionType:
  3586. v, ok := value.(int)
  3587. if !ok {
  3588. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3589. }
  3590. m.SetConditionType(v)
  3591. return nil
  3592. case sopstage.FieldConditionOperator:
  3593. v, ok := value.(int)
  3594. if !ok {
  3595. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3596. }
  3597. m.SetConditionOperator(v)
  3598. return nil
  3599. case sopstage.FieldConditionList:
  3600. v, ok := value.([]custom_types.Condition)
  3601. if !ok {
  3602. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3603. }
  3604. m.SetConditionList(v)
  3605. return nil
  3606. case sopstage.FieldActionMessage:
  3607. v, ok := value.([]custom_types.Action)
  3608. if !ok {
  3609. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3610. }
  3611. m.SetActionMessage(v)
  3612. return nil
  3613. case sopstage.FieldActionLabel:
  3614. v, ok := value.([]uint64)
  3615. if !ok {
  3616. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3617. }
  3618. m.SetActionLabel(v)
  3619. return nil
  3620. case sopstage.FieldIndexSort:
  3621. v, ok := value.(int)
  3622. if !ok {
  3623. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3624. }
  3625. m.SetIndexSort(v)
  3626. return nil
  3627. case sopstage.FieldDeletedAt:
  3628. v, ok := value.(time.Time)
  3629. if !ok {
  3630. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3631. }
  3632. m.SetDeletedAt(v)
  3633. return nil
  3634. }
  3635. return fmt.Errorf("unknown SopStage field %s", name)
  3636. }
  3637. // AddedFields returns all numeric fields that were incremented/decremented during
  3638. // this mutation.
  3639. func (m *SopStageMutation) AddedFields() []string {
  3640. var fields []string
  3641. if m.addstatus != nil {
  3642. fields = append(fields, sopstage.FieldStatus)
  3643. }
  3644. if m.addcondition_type != nil {
  3645. fields = append(fields, sopstage.FieldConditionType)
  3646. }
  3647. if m.addcondition_operator != nil {
  3648. fields = append(fields, sopstage.FieldConditionOperator)
  3649. }
  3650. if m.addindex_sort != nil {
  3651. fields = append(fields, sopstage.FieldIndexSort)
  3652. }
  3653. return fields
  3654. }
  3655. // AddedField returns the numeric value that was incremented/decremented on a field
  3656. // with the given name. The second boolean return value indicates that this field
  3657. // was not set, or was not defined in the schema.
  3658. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  3659. switch name {
  3660. case sopstage.FieldStatus:
  3661. return m.AddedStatus()
  3662. case sopstage.FieldConditionType:
  3663. return m.AddedConditionType()
  3664. case sopstage.FieldConditionOperator:
  3665. return m.AddedConditionOperator()
  3666. case sopstage.FieldIndexSort:
  3667. return m.AddedIndexSort()
  3668. }
  3669. return nil, false
  3670. }
  3671. // AddField adds the value to the field with the given name. It returns an error if
  3672. // the field is not defined in the schema, or if the type mismatched the field
  3673. // type.
  3674. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  3675. switch name {
  3676. case sopstage.FieldStatus:
  3677. v, ok := value.(int8)
  3678. if !ok {
  3679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3680. }
  3681. m.AddStatus(v)
  3682. return nil
  3683. case sopstage.FieldConditionType:
  3684. v, ok := value.(int)
  3685. if !ok {
  3686. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3687. }
  3688. m.AddConditionType(v)
  3689. return nil
  3690. case sopstage.FieldConditionOperator:
  3691. v, ok := value.(int)
  3692. if !ok {
  3693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3694. }
  3695. m.AddConditionOperator(v)
  3696. return nil
  3697. case sopstage.FieldIndexSort:
  3698. v, ok := value.(int)
  3699. if !ok {
  3700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3701. }
  3702. m.AddIndexSort(v)
  3703. return nil
  3704. }
  3705. return fmt.Errorf("unknown SopStage numeric field %s", name)
  3706. }
  3707. // ClearedFields returns all nullable fields that were cleared during this
  3708. // mutation.
  3709. func (m *SopStageMutation) ClearedFields() []string {
  3710. var fields []string
  3711. if m.FieldCleared(sopstage.FieldStatus) {
  3712. fields = append(fields, sopstage.FieldStatus)
  3713. }
  3714. if m.FieldCleared(sopstage.FieldActionMessage) {
  3715. fields = append(fields, sopstage.FieldActionMessage)
  3716. }
  3717. if m.FieldCleared(sopstage.FieldActionLabel) {
  3718. fields = append(fields, sopstage.FieldActionLabel)
  3719. }
  3720. if m.FieldCleared(sopstage.FieldIndexSort) {
  3721. fields = append(fields, sopstage.FieldIndexSort)
  3722. }
  3723. if m.FieldCleared(sopstage.FieldDeletedAt) {
  3724. fields = append(fields, sopstage.FieldDeletedAt)
  3725. }
  3726. return fields
  3727. }
  3728. // FieldCleared returns a boolean indicating if a field with the given name was
  3729. // cleared in this mutation.
  3730. func (m *SopStageMutation) FieldCleared(name string) bool {
  3731. _, ok := m.clearedFields[name]
  3732. return ok
  3733. }
  3734. // ClearField clears the value of the field with the given name. It returns an
  3735. // error if the field is not defined in the schema.
  3736. func (m *SopStageMutation) ClearField(name string) error {
  3737. switch name {
  3738. case sopstage.FieldStatus:
  3739. m.ClearStatus()
  3740. return nil
  3741. case sopstage.FieldActionMessage:
  3742. m.ClearActionMessage()
  3743. return nil
  3744. case sopstage.FieldActionLabel:
  3745. m.ClearActionLabel()
  3746. return nil
  3747. case sopstage.FieldIndexSort:
  3748. m.ClearIndexSort()
  3749. return nil
  3750. case sopstage.FieldDeletedAt:
  3751. m.ClearDeletedAt()
  3752. return nil
  3753. }
  3754. return fmt.Errorf("unknown SopStage nullable field %s", name)
  3755. }
  3756. // ResetField resets all changes in the mutation for the field with the given name.
  3757. // It returns an error if the field is not defined in the schema.
  3758. func (m *SopStageMutation) ResetField(name string) error {
  3759. switch name {
  3760. case sopstage.FieldCreatedAt:
  3761. m.ResetCreatedAt()
  3762. return nil
  3763. case sopstage.FieldUpdatedAt:
  3764. m.ResetUpdatedAt()
  3765. return nil
  3766. case sopstage.FieldStatus:
  3767. m.ResetStatus()
  3768. return nil
  3769. case sopstage.FieldTaskID:
  3770. m.ResetTaskID()
  3771. return nil
  3772. case sopstage.FieldName:
  3773. m.ResetName()
  3774. return nil
  3775. case sopstage.FieldConditionType:
  3776. m.ResetConditionType()
  3777. return nil
  3778. case sopstage.FieldConditionOperator:
  3779. m.ResetConditionOperator()
  3780. return nil
  3781. case sopstage.FieldConditionList:
  3782. m.ResetConditionList()
  3783. return nil
  3784. case sopstage.FieldActionMessage:
  3785. m.ResetActionMessage()
  3786. return nil
  3787. case sopstage.FieldActionLabel:
  3788. m.ResetActionLabel()
  3789. return nil
  3790. case sopstage.FieldIndexSort:
  3791. m.ResetIndexSort()
  3792. return nil
  3793. case sopstage.FieldDeletedAt:
  3794. m.ResetDeletedAt()
  3795. return nil
  3796. }
  3797. return fmt.Errorf("unknown SopStage field %s", name)
  3798. }
  3799. // AddedEdges returns all edge names that were set/added in this mutation.
  3800. func (m *SopStageMutation) AddedEdges() []string {
  3801. edges := make([]string, 0, 3)
  3802. if m.sop_task != nil {
  3803. edges = append(edges, sopstage.EdgeSopTask)
  3804. }
  3805. if m.stage_nodes != nil {
  3806. edges = append(edges, sopstage.EdgeStageNodes)
  3807. }
  3808. if m.stage_messages != nil {
  3809. edges = append(edges, sopstage.EdgeStageMessages)
  3810. }
  3811. return edges
  3812. }
  3813. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3814. // name in this mutation.
  3815. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  3816. switch name {
  3817. case sopstage.EdgeSopTask:
  3818. if id := m.sop_task; id != nil {
  3819. return []ent.Value{*id}
  3820. }
  3821. case sopstage.EdgeStageNodes:
  3822. ids := make([]ent.Value, 0, len(m.stage_nodes))
  3823. for id := range m.stage_nodes {
  3824. ids = append(ids, id)
  3825. }
  3826. return ids
  3827. case sopstage.EdgeStageMessages:
  3828. ids := make([]ent.Value, 0, len(m.stage_messages))
  3829. for id := range m.stage_messages {
  3830. ids = append(ids, id)
  3831. }
  3832. return ids
  3833. }
  3834. return nil
  3835. }
  3836. // RemovedEdges returns all edge names that were removed in this mutation.
  3837. func (m *SopStageMutation) RemovedEdges() []string {
  3838. edges := make([]string, 0, 3)
  3839. if m.removedstage_nodes != nil {
  3840. edges = append(edges, sopstage.EdgeStageNodes)
  3841. }
  3842. if m.removedstage_messages != nil {
  3843. edges = append(edges, sopstage.EdgeStageMessages)
  3844. }
  3845. return edges
  3846. }
  3847. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3848. // the given name in this mutation.
  3849. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  3850. switch name {
  3851. case sopstage.EdgeStageNodes:
  3852. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  3853. for id := range m.removedstage_nodes {
  3854. ids = append(ids, id)
  3855. }
  3856. return ids
  3857. case sopstage.EdgeStageMessages:
  3858. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  3859. for id := range m.removedstage_messages {
  3860. ids = append(ids, id)
  3861. }
  3862. return ids
  3863. }
  3864. return nil
  3865. }
  3866. // ClearedEdges returns all edge names that were cleared in this mutation.
  3867. func (m *SopStageMutation) ClearedEdges() []string {
  3868. edges := make([]string, 0, 3)
  3869. if m.clearedsop_task {
  3870. edges = append(edges, sopstage.EdgeSopTask)
  3871. }
  3872. if m.clearedstage_nodes {
  3873. edges = append(edges, sopstage.EdgeStageNodes)
  3874. }
  3875. if m.clearedstage_messages {
  3876. edges = append(edges, sopstage.EdgeStageMessages)
  3877. }
  3878. return edges
  3879. }
  3880. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3881. // was cleared in this mutation.
  3882. func (m *SopStageMutation) EdgeCleared(name string) bool {
  3883. switch name {
  3884. case sopstage.EdgeSopTask:
  3885. return m.clearedsop_task
  3886. case sopstage.EdgeStageNodes:
  3887. return m.clearedstage_nodes
  3888. case sopstage.EdgeStageMessages:
  3889. return m.clearedstage_messages
  3890. }
  3891. return false
  3892. }
  3893. // ClearEdge clears the value of the edge with the given name. It returns an error
  3894. // if that edge is not defined in the schema.
  3895. func (m *SopStageMutation) ClearEdge(name string) error {
  3896. switch name {
  3897. case sopstage.EdgeSopTask:
  3898. m.ClearSopTask()
  3899. return nil
  3900. }
  3901. return fmt.Errorf("unknown SopStage unique edge %s", name)
  3902. }
  3903. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3904. // It returns an error if the edge is not defined in the schema.
  3905. func (m *SopStageMutation) ResetEdge(name string) error {
  3906. switch name {
  3907. case sopstage.EdgeSopTask:
  3908. m.ResetSopTask()
  3909. return nil
  3910. case sopstage.EdgeStageNodes:
  3911. m.ResetStageNodes()
  3912. return nil
  3913. case sopstage.EdgeStageMessages:
  3914. m.ResetStageMessages()
  3915. return nil
  3916. }
  3917. return fmt.Errorf("unknown SopStage edge %s", name)
  3918. }
  3919. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  3920. type SopTaskMutation struct {
  3921. config
  3922. op Op
  3923. typ string
  3924. id *uint64
  3925. created_at *time.Time
  3926. updated_at *time.Time
  3927. status *uint8
  3928. addstatus *int8
  3929. name *string
  3930. bot_wxid_list *[]string
  3931. appendbot_wxid_list []string
  3932. _type *int
  3933. add_type *int
  3934. plan_start_time *time.Time
  3935. plan_end_time *time.Time
  3936. creator_id *string
  3937. deleted_at *time.Time
  3938. clearedFields map[string]struct{}
  3939. task_stages map[uint64]struct{}
  3940. removedtask_stages map[uint64]struct{}
  3941. clearedtask_stages bool
  3942. done bool
  3943. oldValue func(context.Context) (*SopTask, error)
  3944. predicates []predicate.SopTask
  3945. }
  3946. var _ ent.Mutation = (*SopTaskMutation)(nil)
  3947. // soptaskOption allows management of the mutation configuration using functional options.
  3948. type soptaskOption func(*SopTaskMutation)
  3949. // newSopTaskMutation creates new mutation for the SopTask entity.
  3950. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  3951. m := &SopTaskMutation{
  3952. config: c,
  3953. op: op,
  3954. typ: TypeSopTask,
  3955. clearedFields: make(map[string]struct{}),
  3956. }
  3957. for _, opt := range opts {
  3958. opt(m)
  3959. }
  3960. return m
  3961. }
  3962. // withSopTaskID sets the ID field of the mutation.
  3963. func withSopTaskID(id uint64) soptaskOption {
  3964. return func(m *SopTaskMutation) {
  3965. var (
  3966. err error
  3967. once sync.Once
  3968. value *SopTask
  3969. )
  3970. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  3971. once.Do(func() {
  3972. if m.done {
  3973. err = errors.New("querying old values post mutation is not allowed")
  3974. } else {
  3975. value, err = m.Client().SopTask.Get(ctx, id)
  3976. }
  3977. })
  3978. return value, err
  3979. }
  3980. m.id = &id
  3981. }
  3982. }
  3983. // withSopTask sets the old SopTask of the mutation.
  3984. func withSopTask(node *SopTask) soptaskOption {
  3985. return func(m *SopTaskMutation) {
  3986. m.oldValue = func(context.Context) (*SopTask, error) {
  3987. return node, nil
  3988. }
  3989. m.id = &node.ID
  3990. }
  3991. }
  3992. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3993. // executed in a transaction (ent.Tx), a transactional client is returned.
  3994. func (m SopTaskMutation) Client() *Client {
  3995. client := &Client{config: m.config}
  3996. client.init()
  3997. return client
  3998. }
  3999. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4000. // it returns an error otherwise.
  4001. func (m SopTaskMutation) Tx() (*Tx, error) {
  4002. if _, ok := m.driver.(*txDriver); !ok {
  4003. return nil, errors.New("ent: mutation is not running in a transaction")
  4004. }
  4005. tx := &Tx{config: m.config}
  4006. tx.init()
  4007. return tx, nil
  4008. }
  4009. // SetID sets the value of the id field. Note that this
  4010. // operation is only accepted on creation of SopTask entities.
  4011. func (m *SopTaskMutation) SetID(id uint64) {
  4012. m.id = &id
  4013. }
  4014. // ID returns the ID value in the mutation. Note that the ID is only available
  4015. // if it was provided to the builder or after it was returned from the database.
  4016. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  4017. if m.id == nil {
  4018. return
  4019. }
  4020. return *m.id, true
  4021. }
  4022. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4023. // That means, if the mutation is applied within a transaction with an isolation level such
  4024. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4025. // or updated by the mutation.
  4026. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  4027. switch {
  4028. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4029. id, exists := m.ID()
  4030. if exists {
  4031. return []uint64{id}, nil
  4032. }
  4033. fallthrough
  4034. case m.op.Is(OpUpdate | OpDelete):
  4035. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  4036. default:
  4037. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4038. }
  4039. }
  4040. // SetCreatedAt sets the "created_at" field.
  4041. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  4042. m.created_at = &t
  4043. }
  4044. // CreatedAt returns the value of the "created_at" field in the mutation.
  4045. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  4046. v := m.created_at
  4047. if v == nil {
  4048. return
  4049. }
  4050. return *v, true
  4051. }
  4052. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  4053. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  4054. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4055. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4056. if !m.op.Is(OpUpdateOne) {
  4057. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4058. }
  4059. if m.id == nil || m.oldValue == nil {
  4060. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4061. }
  4062. oldValue, err := m.oldValue(ctx)
  4063. if err != nil {
  4064. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4065. }
  4066. return oldValue.CreatedAt, nil
  4067. }
  4068. // ResetCreatedAt resets all changes to the "created_at" field.
  4069. func (m *SopTaskMutation) ResetCreatedAt() {
  4070. m.created_at = nil
  4071. }
  4072. // SetUpdatedAt sets the "updated_at" field.
  4073. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  4074. m.updated_at = &t
  4075. }
  4076. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4077. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  4078. v := m.updated_at
  4079. if v == nil {
  4080. return
  4081. }
  4082. return *v, true
  4083. }
  4084. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  4085. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  4086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4087. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4088. if !m.op.Is(OpUpdateOne) {
  4089. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4090. }
  4091. if m.id == nil || m.oldValue == nil {
  4092. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4093. }
  4094. oldValue, err := m.oldValue(ctx)
  4095. if err != nil {
  4096. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4097. }
  4098. return oldValue.UpdatedAt, nil
  4099. }
  4100. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4101. func (m *SopTaskMutation) ResetUpdatedAt() {
  4102. m.updated_at = nil
  4103. }
  4104. // SetStatus sets the "status" field.
  4105. func (m *SopTaskMutation) SetStatus(u uint8) {
  4106. m.status = &u
  4107. m.addstatus = nil
  4108. }
  4109. // Status returns the value of the "status" field in the mutation.
  4110. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  4111. v := m.status
  4112. if v == nil {
  4113. return
  4114. }
  4115. return *v, true
  4116. }
  4117. // OldStatus returns the old "status" field's value of the SopTask entity.
  4118. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  4119. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4120. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  4121. if !m.op.Is(OpUpdateOne) {
  4122. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  4123. }
  4124. if m.id == nil || m.oldValue == nil {
  4125. return v, errors.New("OldStatus requires an ID field in the mutation")
  4126. }
  4127. oldValue, err := m.oldValue(ctx)
  4128. if err != nil {
  4129. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  4130. }
  4131. return oldValue.Status, nil
  4132. }
  4133. // AddStatus adds u to the "status" field.
  4134. func (m *SopTaskMutation) AddStatus(u int8) {
  4135. if m.addstatus != nil {
  4136. *m.addstatus += u
  4137. } else {
  4138. m.addstatus = &u
  4139. }
  4140. }
  4141. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4142. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  4143. v := m.addstatus
  4144. if v == nil {
  4145. return
  4146. }
  4147. return *v, true
  4148. }
  4149. // ClearStatus clears the value of the "status" field.
  4150. func (m *SopTaskMutation) ClearStatus() {
  4151. m.status = nil
  4152. m.addstatus = nil
  4153. m.clearedFields[soptask.FieldStatus] = struct{}{}
  4154. }
  4155. // StatusCleared returns if the "status" field was cleared in this mutation.
  4156. func (m *SopTaskMutation) StatusCleared() bool {
  4157. _, ok := m.clearedFields[soptask.FieldStatus]
  4158. return ok
  4159. }
  4160. // ResetStatus resets all changes to the "status" field.
  4161. func (m *SopTaskMutation) ResetStatus() {
  4162. m.status = nil
  4163. m.addstatus = nil
  4164. delete(m.clearedFields, soptask.FieldStatus)
  4165. }
  4166. // SetName sets the "name" field.
  4167. func (m *SopTaskMutation) SetName(s string) {
  4168. m.name = &s
  4169. }
  4170. // Name returns the value of the "name" field in the mutation.
  4171. func (m *SopTaskMutation) Name() (r string, exists bool) {
  4172. v := m.name
  4173. if v == nil {
  4174. return
  4175. }
  4176. return *v, true
  4177. }
  4178. // OldName returns the old "name" field's value of the SopTask entity.
  4179. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  4180. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4181. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  4182. if !m.op.Is(OpUpdateOne) {
  4183. return v, errors.New("OldName is only allowed on UpdateOne operations")
  4184. }
  4185. if m.id == nil || m.oldValue == nil {
  4186. return v, errors.New("OldName requires an ID field in the mutation")
  4187. }
  4188. oldValue, err := m.oldValue(ctx)
  4189. if err != nil {
  4190. return v, fmt.Errorf("querying old value for OldName: %w", err)
  4191. }
  4192. return oldValue.Name, nil
  4193. }
  4194. // ResetName resets all changes to the "name" field.
  4195. func (m *SopTaskMutation) ResetName() {
  4196. m.name = nil
  4197. }
  4198. // SetBotWxidList sets the "bot_wxid_list" field.
  4199. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  4200. m.bot_wxid_list = &s
  4201. m.appendbot_wxid_list = nil
  4202. }
  4203. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  4204. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  4205. v := m.bot_wxid_list
  4206. if v == nil {
  4207. return
  4208. }
  4209. return *v, true
  4210. }
  4211. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  4212. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  4213. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4214. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  4215. if !m.op.Is(OpUpdateOne) {
  4216. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  4217. }
  4218. if m.id == nil || m.oldValue == nil {
  4219. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  4220. }
  4221. oldValue, err := m.oldValue(ctx)
  4222. if err != nil {
  4223. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  4224. }
  4225. return oldValue.BotWxidList, nil
  4226. }
  4227. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  4228. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  4229. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  4230. }
  4231. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  4232. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  4233. if len(m.appendbot_wxid_list) == 0 {
  4234. return nil, false
  4235. }
  4236. return m.appendbot_wxid_list, true
  4237. }
  4238. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  4239. func (m *SopTaskMutation) ClearBotWxidList() {
  4240. m.bot_wxid_list = nil
  4241. m.appendbot_wxid_list = nil
  4242. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  4243. }
  4244. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  4245. func (m *SopTaskMutation) BotWxidListCleared() bool {
  4246. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  4247. return ok
  4248. }
  4249. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  4250. func (m *SopTaskMutation) ResetBotWxidList() {
  4251. m.bot_wxid_list = nil
  4252. m.appendbot_wxid_list = nil
  4253. delete(m.clearedFields, soptask.FieldBotWxidList)
  4254. }
  4255. // SetType sets the "type" field.
  4256. func (m *SopTaskMutation) SetType(i int) {
  4257. m._type = &i
  4258. m.add_type = nil
  4259. }
  4260. // GetType returns the value of the "type" field in the mutation.
  4261. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  4262. v := m._type
  4263. if v == nil {
  4264. return
  4265. }
  4266. return *v, true
  4267. }
  4268. // OldType returns the old "type" field's value of the SopTask entity.
  4269. // If the SopTask 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 *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  4272. if !m.op.Is(OpUpdateOne) {
  4273. return v, errors.New("OldType is only allowed on UpdateOne operations")
  4274. }
  4275. if m.id == nil || m.oldValue == nil {
  4276. return v, errors.New("OldType 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 OldType: %w", err)
  4281. }
  4282. return oldValue.Type, nil
  4283. }
  4284. // AddType adds i to the "type" field.
  4285. func (m *SopTaskMutation) AddType(i int) {
  4286. if m.add_type != nil {
  4287. *m.add_type += i
  4288. } else {
  4289. m.add_type = &i
  4290. }
  4291. }
  4292. // AddedType returns the value that was added to the "type" field in this mutation.
  4293. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  4294. v := m.add_type
  4295. if v == nil {
  4296. return
  4297. }
  4298. return *v, true
  4299. }
  4300. // ResetType resets all changes to the "type" field.
  4301. func (m *SopTaskMutation) ResetType() {
  4302. m._type = nil
  4303. m.add_type = nil
  4304. }
  4305. // SetPlanStartTime sets the "plan_start_time" field.
  4306. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  4307. m.plan_start_time = &t
  4308. }
  4309. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  4310. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  4311. v := m.plan_start_time
  4312. if v == nil {
  4313. return
  4314. }
  4315. return *v, true
  4316. }
  4317. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  4318. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  4319. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4320. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  4321. if !m.op.Is(OpUpdateOne) {
  4322. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  4323. }
  4324. if m.id == nil || m.oldValue == nil {
  4325. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  4326. }
  4327. oldValue, err := m.oldValue(ctx)
  4328. if err != nil {
  4329. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  4330. }
  4331. return oldValue.PlanStartTime, nil
  4332. }
  4333. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  4334. func (m *SopTaskMutation) ClearPlanStartTime() {
  4335. m.plan_start_time = nil
  4336. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  4337. }
  4338. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  4339. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  4340. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  4341. return ok
  4342. }
  4343. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  4344. func (m *SopTaskMutation) ResetPlanStartTime() {
  4345. m.plan_start_time = nil
  4346. delete(m.clearedFields, soptask.FieldPlanStartTime)
  4347. }
  4348. // SetPlanEndTime sets the "plan_end_time" field.
  4349. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  4350. m.plan_end_time = &t
  4351. }
  4352. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  4353. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  4354. v := m.plan_end_time
  4355. if v == nil {
  4356. return
  4357. }
  4358. return *v, true
  4359. }
  4360. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  4361. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  4362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4363. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  4364. if !m.op.Is(OpUpdateOne) {
  4365. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  4366. }
  4367. if m.id == nil || m.oldValue == nil {
  4368. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  4369. }
  4370. oldValue, err := m.oldValue(ctx)
  4371. if err != nil {
  4372. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  4373. }
  4374. return oldValue.PlanEndTime, nil
  4375. }
  4376. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  4377. func (m *SopTaskMutation) ClearPlanEndTime() {
  4378. m.plan_end_time = nil
  4379. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  4380. }
  4381. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  4382. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  4383. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  4384. return ok
  4385. }
  4386. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  4387. func (m *SopTaskMutation) ResetPlanEndTime() {
  4388. m.plan_end_time = nil
  4389. delete(m.clearedFields, soptask.FieldPlanEndTime)
  4390. }
  4391. // SetCreatorID sets the "creator_id" field.
  4392. func (m *SopTaskMutation) SetCreatorID(s string) {
  4393. m.creator_id = &s
  4394. }
  4395. // CreatorID returns the value of the "creator_id" field in the mutation.
  4396. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  4397. v := m.creator_id
  4398. if v == nil {
  4399. return
  4400. }
  4401. return *v, true
  4402. }
  4403. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  4404. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  4405. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4406. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  4407. if !m.op.Is(OpUpdateOne) {
  4408. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  4409. }
  4410. if m.id == nil || m.oldValue == nil {
  4411. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  4412. }
  4413. oldValue, err := m.oldValue(ctx)
  4414. if err != nil {
  4415. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  4416. }
  4417. return oldValue.CreatorID, nil
  4418. }
  4419. // ClearCreatorID clears the value of the "creator_id" field.
  4420. func (m *SopTaskMutation) ClearCreatorID() {
  4421. m.creator_id = nil
  4422. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  4423. }
  4424. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  4425. func (m *SopTaskMutation) CreatorIDCleared() bool {
  4426. _, ok := m.clearedFields[soptask.FieldCreatorID]
  4427. return ok
  4428. }
  4429. // ResetCreatorID resets all changes to the "creator_id" field.
  4430. func (m *SopTaskMutation) ResetCreatorID() {
  4431. m.creator_id = nil
  4432. delete(m.clearedFields, soptask.FieldCreatorID)
  4433. }
  4434. // SetDeletedAt sets the "deleted_at" field.
  4435. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  4436. m.deleted_at = &t
  4437. }
  4438. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4439. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  4440. v := m.deleted_at
  4441. if v == nil {
  4442. return
  4443. }
  4444. return *v, true
  4445. }
  4446. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  4447. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  4448. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4449. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4450. if !m.op.Is(OpUpdateOne) {
  4451. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4452. }
  4453. if m.id == nil || m.oldValue == nil {
  4454. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4455. }
  4456. oldValue, err := m.oldValue(ctx)
  4457. if err != nil {
  4458. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4459. }
  4460. return oldValue.DeletedAt, nil
  4461. }
  4462. // ClearDeletedAt clears the value of the "deleted_at" field.
  4463. func (m *SopTaskMutation) ClearDeletedAt() {
  4464. m.deleted_at = nil
  4465. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  4466. }
  4467. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4468. func (m *SopTaskMutation) DeletedAtCleared() bool {
  4469. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  4470. return ok
  4471. }
  4472. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4473. func (m *SopTaskMutation) ResetDeletedAt() {
  4474. m.deleted_at = nil
  4475. delete(m.clearedFields, soptask.FieldDeletedAt)
  4476. }
  4477. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  4478. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  4479. if m.task_stages == nil {
  4480. m.task_stages = make(map[uint64]struct{})
  4481. }
  4482. for i := range ids {
  4483. m.task_stages[ids[i]] = struct{}{}
  4484. }
  4485. }
  4486. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  4487. func (m *SopTaskMutation) ClearTaskStages() {
  4488. m.clearedtask_stages = true
  4489. }
  4490. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  4491. func (m *SopTaskMutation) TaskStagesCleared() bool {
  4492. return m.clearedtask_stages
  4493. }
  4494. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  4495. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  4496. if m.removedtask_stages == nil {
  4497. m.removedtask_stages = make(map[uint64]struct{})
  4498. }
  4499. for i := range ids {
  4500. delete(m.task_stages, ids[i])
  4501. m.removedtask_stages[ids[i]] = struct{}{}
  4502. }
  4503. }
  4504. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  4505. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  4506. for id := range m.removedtask_stages {
  4507. ids = append(ids, id)
  4508. }
  4509. return
  4510. }
  4511. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  4512. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  4513. for id := range m.task_stages {
  4514. ids = append(ids, id)
  4515. }
  4516. return
  4517. }
  4518. // ResetTaskStages resets all changes to the "task_stages" edge.
  4519. func (m *SopTaskMutation) ResetTaskStages() {
  4520. m.task_stages = nil
  4521. m.clearedtask_stages = false
  4522. m.removedtask_stages = nil
  4523. }
  4524. // Where appends a list predicates to the SopTaskMutation builder.
  4525. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  4526. m.predicates = append(m.predicates, ps...)
  4527. }
  4528. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  4529. // users can use type-assertion to append predicates that do not depend on any generated package.
  4530. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  4531. p := make([]predicate.SopTask, len(ps))
  4532. for i := range ps {
  4533. p[i] = ps[i]
  4534. }
  4535. m.Where(p...)
  4536. }
  4537. // Op returns the operation name.
  4538. func (m *SopTaskMutation) Op() Op {
  4539. return m.op
  4540. }
  4541. // SetOp allows setting the mutation operation.
  4542. func (m *SopTaskMutation) SetOp(op Op) {
  4543. m.op = op
  4544. }
  4545. // Type returns the node type of this mutation (SopTask).
  4546. func (m *SopTaskMutation) Type() string {
  4547. return m.typ
  4548. }
  4549. // Fields returns all fields that were changed during this mutation. Note that in
  4550. // order to get all numeric fields that were incremented/decremented, call
  4551. // AddedFields().
  4552. func (m *SopTaskMutation) Fields() []string {
  4553. fields := make([]string, 0, 10)
  4554. if m.created_at != nil {
  4555. fields = append(fields, soptask.FieldCreatedAt)
  4556. }
  4557. if m.updated_at != nil {
  4558. fields = append(fields, soptask.FieldUpdatedAt)
  4559. }
  4560. if m.status != nil {
  4561. fields = append(fields, soptask.FieldStatus)
  4562. }
  4563. if m.name != nil {
  4564. fields = append(fields, soptask.FieldName)
  4565. }
  4566. if m.bot_wxid_list != nil {
  4567. fields = append(fields, soptask.FieldBotWxidList)
  4568. }
  4569. if m._type != nil {
  4570. fields = append(fields, soptask.FieldType)
  4571. }
  4572. if m.plan_start_time != nil {
  4573. fields = append(fields, soptask.FieldPlanStartTime)
  4574. }
  4575. if m.plan_end_time != nil {
  4576. fields = append(fields, soptask.FieldPlanEndTime)
  4577. }
  4578. if m.creator_id != nil {
  4579. fields = append(fields, soptask.FieldCreatorID)
  4580. }
  4581. if m.deleted_at != nil {
  4582. fields = append(fields, soptask.FieldDeletedAt)
  4583. }
  4584. return fields
  4585. }
  4586. // Field returns the value of a field with the given name. The second boolean
  4587. // return value indicates that this field was not set, or was not defined in the
  4588. // schema.
  4589. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  4590. switch name {
  4591. case soptask.FieldCreatedAt:
  4592. return m.CreatedAt()
  4593. case soptask.FieldUpdatedAt:
  4594. return m.UpdatedAt()
  4595. case soptask.FieldStatus:
  4596. return m.Status()
  4597. case soptask.FieldName:
  4598. return m.Name()
  4599. case soptask.FieldBotWxidList:
  4600. return m.BotWxidList()
  4601. case soptask.FieldType:
  4602. return m.GetType()
  4603. case soptask.FieldPlanStartTime:
  4604. return m.PlanStartTime()
  4605. case soptask.FieldPlanEndTime:
  4606. return m.PlanEndTime()
  4607. case soptask.FieldCreatorID:
  4608. return m.CreatorID()
  4609. case soptask.FieldDeletedAt:
  4610. return m.DeletedAt()
  4611. }
  4612. return nil, false
  4613. }
  4614. // OldField returns the old value of the field from the database. An error is
  4615. // returned if the mutation operation is not UpdateOne, or the query to the
  4616. // database failed.
  4617. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4618. switch name {
  4619. case soptask.FieldCreatedAt:
  4620. return m.OldCreatedAt(ctx)
  4621. case soptask.FieldUpdatedAt:
  4622. return m.OldUpdatedAt(ctx)
  4623. case soptask.FieldStatus:
  4624. return m.OldStatus(ctx)
  4625. case soptask.FieldName:
  4626. return m.OldName(ctx)
  4627. case soptask.FieldBotWxidList:
  4628. return m.OldBotWxidList(ctx)
  4629. case soptask.FieldType:
  4630. return m.OldType(ctx)
  4631. case soptask.FieldPlanStartTime:
  4632. return m.OldPlanStartTime(ctx)
  4633. case soptask.FieldPlanEndTime:
  4634. return m.OldPlanEndTime(ctx)
  4635. case soptask.FieldCreatorID:
  4636. return m.OldCreatorID(ctx)
  4637. case soptask.FieldDeletedAt:
  4638. return m.OldDeletedAt(ctx)
  4639. }
  4640. return nil, fmt.Errorf("unknown SopTask field %s", name)
  4641. }
  4642. // SetField sets the value of a field with the given name. It returns an error if
  4643. // the field is not defined in the schema, or if the type mismatched the field
  4644. // type.
  4645. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  4646. switch name {
  4647. case soptask.FieldCreatedAt:
  4648. v, ok := value.(time.Time)
  4649. if !ok {
  4650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4651. }
  4652. m.SetCreatedAt(v)
  4653. return nil
  4654. case soptask.FieldUpdatedAt:
  4655. v, ok := value.(time.Time)
  4656. if !ok {
  4657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4658. }
  4659. m.SetUpdatedAt(v)
  4660. return nil
  4661. case soptask.FieldStatus:
  4662. v, ok := value.(uint8)
  4663. if !ok {
  4664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4665. }
  4666. m.SetStatus(v)
  4667. return nil
  4668. case soptask.FieldName:
  4669. v, ok := value.(string)
  4670. if !ok {
  4671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4672. }
  4673. m.SetName(v)
  4674. return nil
  4675. case soptask.FieldBotWxidList:
  4676. v, ok := value.([]string)
  4677. if !ok {
  4678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4679. }
  4680. m.SetBotWxidList(v)
  4681. return nil
  4682. case soptask.FieldType:
  4683. v, ok := value.(int)
  4684. if !ok {
  4685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4686. }
  4687. m.SetType(v)
  4688. return nil
  4689. case soptask.FieldPlanStartTime:
  4690. v, ok := value.(time.Time)
  4691. if !ok {
  4692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4693. }
  4694. m.SetPlanStartTime(v)
  4695. return nil
  4696. case soptask.FieldPlanEndTime:
  4697. v, ok := value.(time.Time)
  4698. if !ok {
  4699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4700. }
  4701. m.SetPlanEndTime(v)
  4702. return nil
  4703. case soptask.FieldCreatorID:
  4704. v, ok := value.(string)
  4705. if !ok {
  4706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4707. }
  4708. m.SetCreatorID(v)
  4709. return nil
  4710. case soptask.FieldDeletedAt:
  4711. v, ok := value.(time.Time)
  4712. if !ok {
  4713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4714. }
  4715. m.SetDeletedAt(v)
  4716. return nil
  4717. }
  4718. return fmt.Errorf("unknown SopTask field %s", name)
  4719. }
  4720. // AddedFields returns all numeric fields that were incremented/decremented during
  4721. // this mutation.
  4722. func (m *SopTaskMutation) AddedFields() []string {
  4723. var fields []string
  4724. if m.addstatus != nil {
  4725. fields = append(fields, soptask.FieldStatus)
  4726. }
  4727. if m.add_type != nil {
  4728. fields = append(fields, soptask.FieldType)
  4729. }
  4730. return fields
  4731. }
  4732. // AddedField returns the numeric value that was incremented/decremented on a field
  4733. // with the given name. The second boolean return value indicates that this field
  4734. // was not set, or was not defined in the schema.
  4735. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  4736. switch name {
  4737. case soptask.FieldStatus:
  4738. return m.AddedStatus()
  4739. case soptask.FieldType:
  4740. return m.AddedType()
  4741. }
  4742. return nil, false
  4743. }
  4744. // AddField adds the value to the field with the given name. It returns an error if
  4745. // the field is not defined in the schema, or if the type mismatched the field
  4746. // type.
  4747. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  4748. switch name {
  4749. case soptask.FieldStatus:
  4750. v, ok := value.(int8)
  4751. if !ok {
  4752. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4753. }
  4754. m.AddStatus(v)
  4755. return nil
  4756. case soptask.FieldType:
  4757. v, ok := value.(int)
  4758. if !ok {
  4759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4760. }
  4761. m.AddType(v)
  4762. return nil
  4763. }
  4764. return fmt.Errorf("unknown SopTask numeric field %s", name)
  4765. }
  4766. // ClearedFields returns all nullable fields that were cleared during this
  4767. // mutation.
  4768. func (m *SopTaskMutation) ClearedFields() []string {
  4769. var fields []string
  4770. if m.FieldCleared(soptask.FieldStatus) {
  4771. fields = append(fields, soptask.FieldStatus)
  4772. }
  4773. if m.FieldCleared(soptask.FieldBotWxidList) {
  4774. fields = append(fields, soptask.FieldBotWxidList)
  4775. }
  4776. if m.FieldCleared(soptask.FieldPlanStartTime) {
  4777. fields = append(fields, soptask.FieldPlanStartTime)
  4778. }
  4779. if m.FieldCleared(soptask.FieldPlanEndTime) {
  4780. fields = append(fields, soptask.FieldPlanEndTime)
  4781. }
  4782. if m.FieldCleared(soptask.FieldCreatorID) {
  4783. fields = append(fields, soptask.FieldCreatorID)
  4784. }
  4785. if m.FieldCleared(soptask.FieldDeletedAt) {
  4786. fields = append(fields, soptask.FieldDeletedAt)
  4787. }
  4788. return fields
  4789. }
  4790. // FieldCleared returns a boolean indicating if a field with the given name was
  4791. // cleared in this mutation.
  4792. func (m *SopTaskMutation) FieldCleared(name string) bool {
  4793. _, ok := m.clearedFields[name]
  4794. return ok
  4795. }
  4796. // ClearField clears the value of the field with the given name. It returns an
  4797. // error if the field is not defined in the schema.
  4798. func (m *SopTaskMutation) ClearField(name string) error {
  4799. switch name {
  4800. case soptask.FieldStatus:
  4801. m.ClearStatus()
  4802. return nil
  4803. case soptask.FieldBotWxidList:
  4804. m.ClearBotWxidList()
  4805. return nil
  4806. case soptask.FieldPlanStartTime:
  4807. m.ClearPlanStartTime()
  4808. return nil
  4809. case soptask.FieldPlanEndTime:
  4810. m.ClearPlanEndTime()
  4811. return nil
  4812. case soptask.FieldCreatorID:
  4813. m.ClearCreatorID()
  4814. return nil
  4815. case soptask.FieldDeletedAt:
  4816. m.ClearDeletedAt()
  4817. return nil
  4818. }
  4819. return fmt.Errorf("unknown SopTask nullable field %s", name)
  4820. }
  4821. // ResetField resets all changes in the mutation for the field with the given name.
  4822. // It returns an error if the field is not defined in the schema.
  4823. func (m *SopTaskMutation) ResetField(name string) error {
  4824. switch name {
  4825. case soptask.FieldCreatedAt:
  4826. m.ResetCreatedAt()
  4827. return nil
  4828. case soptask.FieldUpdatedAt:
  4829. m.ResetUpdatedAt()
  4830. return nil
  4831. case soptask.FieldStatus:
  4832. m.ResetStatus()
  4833. return nil
  4834. case soptask.FieldName:
  4835. m.ResetName()
  4836. return nil
  4837. case soptask.FieldBotWxidList:
  4838. m.ResetBotWxidList()
  4839. return nil
  4840. case soptask.FieldType:
  4841. m.ResetType()
  4842. return nil
  4843. case soptask.FieldPlanStartTime:
  4844. m.ResetPlanStartTime()
  4845. return nil
  4846. case soptask.FieldPlanEndTime:
  4847. m.ResetPlanEndTime()
  4848. return nil
  4849. case soptask.FieldCreatorID:
  4850. m.ResetCreatorID()
  4851. return nil
  4852. case soptask.FieldDeletedAt:
  4853. m.ResetDeletedAt()
  4854. return nil
  4855. }
  4856. return fmt.Errorf("unknown SopTask field %s", name)
  4857. }
  4858. // AddedEdges returns all edge names that were set/added in this mutation.
  4859. func (m *SopTaskMutation) AddedEdges() []string {
  4860. edges := make([]string, 0, 1)
  4861. if m.task_stages != nil {
  4862. edges = append(edges, soptask.EdgeTaskStages)
  4863. }
  4864. return edges
  4865. }
  4866. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4867. // name in this mutation.
  4868. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  4869. switch name {
  4870. case soptask.EdgeTaskStages:
  4871. ids := make([]ent.Value, 0, len(m.task_stages))
  4872. for id := range m.task_stages {
  4873. ids = append(ids, id)
  4874. }
  4875. return ids
  4876. }
  4877. return nil
  4878. }
  4879. // RemovedEdges returns all edge names that were removed in this mutation.
  4880. func (m *SopTaskMutation) RemovedEdges() []string {
  4881. edges := make([]string, 0, 1)
  4882. if m.removedtask_stages != nil {
  4883. edges = append(edges, soptask.EdgeTaskStages)
  4884. }
  4885. return edges
  4886. }
  4887. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4888. // the given name in this mutation.
  4889. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  4890. switch name {
  4891. case soptask.EdgeTaskStages:
  4892. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  4893. for id := range m.removedtask_stages {
  4894. ids = append(ids, id)
  4895. }
  4896. return ids
  4897. }
  4898. return nil
  4899. }
  4900. // ClearedEdges returns all edge names that were cleared in this mutation.
  4901. func (m *SopTaskMutation) ClearedEdges() []string {
  4902. edges := make([]string, 0, 1)
  4903. if m.clearedtask_stages {
  4904. edges = append(edges, soptask.EdgeTaskStages)
  4905. }
  4906. return edges
  4907. }
  4908. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4909. // was cleared in this mutation.
  4910. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  4911. switch name {
  4912. case soptask.EdgeTaskStages:
  4913. return m.clearedtask_stages
  4914. }
  4915. return false
  4916. }
  4917. // ClearEdge clears the value of the edge with the given name. It returns an error
  4918. // if that edge is not defined in the schema.
  4919. func (m *SopTaskMutation) ClearEdge(name string) error {
  4920. switch name {
  4921. }
  4922. return fmt.Errorf("unknown SopTask unique edge %s", name)
  4923. }
  4924. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4925. // It returns an error if the edge is not defined in the schema.
  4926. func (m *SopTaskMutation) ResetEdge(name string) error {
  4927. switch name {
  4928. case soptask.EdgeTaskStages:
  4929. m.ResetTaskStages()
  4930. return nil
  4931. }
  4932. return fmt.Errorf("unknown SopTask edge %s", name)
  4933. }
  4934. // TaskMutation represents an operation that mutates the Task nodes in the graph.
  4935. type TaskMutation struct {
  4936. config
  4937. op Op
  4938. typ string
  4939. id *uint64
  4940. created_at *time.Time
  4941. updated_at *time.Time
  4942. status *uint8
  4943. addstatus *int8
  4944. name *string
  4945. task_group *string
  4946. cron_expression *string
  4947. pattern *string
  4948. payload *string
  4949. clearedFields map[string]struct{}
  4950. task_logs map[uint64]struct{}
  4951. removedtask_logs map[uint64]struct{}
  4952. clearedtask_logs bool
  4953. done bool
  4954. oldValue func(context.Context) (*Task, error)
  4955. predicates []predicate.Task
  4956. }
  4957. var _ ent.Mutation = (*TaskMutation)(nil)
  4958. // taskOption allows management of the mutation configuration using functional options.
  4959. type taskOption func(*TaskMutation)
  4960. // newTaskMutation creates new mutation for the Task entity.
  4961. func newTaskMutation(c config, op Op, opts ...taskOption) *TaskMutation {
  4962. m := &TaskMutation{
  4963. config: c,
  4964. op: op,
  4965. typ: TypeTask,
  4966. clearedFields: make(map[string]struct{}),
  4967. }
  4968. for _, opt := range opts {
  4969. opt(m)
  4970. }
  4971. return m
  4972. }
  4973. // withTaskID sets the ID field of the mutation.
  4974. func withTaskID(id uint64) taskOption {
  4975. return func(m *TaskMutation) {
  4976. var (
  4977. err error
  4978. once sync.Once
  4979. value *Task
  4980. )
  4981. m.oldValue = func(ctx context.Context) (*Task, error) {
  4982. once.Do(func() {
  4983. if m.done {
  4984. err = errors.New("querying old values post mutation is not allowed")
  4985. } else {
  4986. value, err = m.Client().Task.Get(ctx, id)
  4987. }
  4988. })
  4989. return value, err
  4990. }
  4991. m.id = &id
  4992. }
  4993. }
  4994. // withTask sets the old Task of the mutation.
  4995. func withTask(node *Task) taskOption {
  4996. return func(m *TaskMutation) {
  4997. m.oldValue = func(context.Context) (*Task, error) {
  4998. return node, nil
  4999. }
  5000. m.id = &node.ID
  5001. }
  5002. }
  5003. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5004. // executed in a transaction (ent.Tx), a transactional client is returned.
  5005. func (m TaskMutation) Client() *Client {
  5006. client := &Client{config: m.config}
  5007. client.init()
  5008. return client
  5009. }
  5010. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5011. // it returns an error otherwise.
  5012. func (m TaskMutation) Tx() (*Tx, error) {
  5013. if _, ok := m.driver.(*txDriver); !ok {
  5014. return nil, errors.New("ent: mutation is not running in a transaction")
  5015. }
  5016. tx := &Tx{config: m.config}
  5017. tx.init()
  5018. return tx, nil
  5019. }
  5020. // SetID sets the value of the id field. Note that this
  5021. // operation is only accepted on creation of Task entities.
  5022. func (m *TaskMutation) SetID(id uint64) {
  5023. m.id = &id
  5024. }
  5025. // ID returns the ID value in the mutation. Note that the ID is only available
  5026. // if it was provided to the builder or after it was returned from the database.
  5027. func (m *TaskMutation) ID() (id uint64, exists bool) {
  5028. if m.id == nil {
  5029. return
  5030. }
  5031. return *m.id, true
  5032. }
  5033. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5034. // That means, if the mutation is applied within a transaction with an isolation level such
  5035. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5036. // or updated by the mutation.
  5037. func (m *TaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  5038. switch {
  5039. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5040. id, exists := m.ID()
  5041. if exists {
  5042. return []uint64{id}, nil
  5043. }
  5044. fallthrough
  5045. case m.op.Is(OpUpdate | OpDelete):
  5046. return m.Client().Task.Query().Where(m.predicates...).IDs(ctx)
  5047. default:
  5048. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5049. }
  5050. }
  5051. // SetCreatedAt sets the "created_at" field.
  5052. func (m *TaskMutation) SetCreatedAt(t time.Time) {
  5053. m.created_at = &t
  5054. }
  5055. // CreatedAt returns the value of the "created_at" field in the mutation.
  5056. func (m *TaskMutation) CreatedAt() (r time.Time, exists bool) {
  5057. v := m.created_at
  5058. if v == nil {
  5059. return
  5060. }
  5061. return *v, true
  5062. }
  5063. // OldCreatedAt returns the old "created_at" field's value of the Task entity.
  5064. // If the Task object wasn't provided to the builder, the object is fetched from the database.
  5065. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5066. func (m *TaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5067. if !m.op.Is(OpUpdateOne) {
  5068. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5069. }
  5070. if m.id == nil || m.oldValue == nil {
  5071. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5072. }
  5073. oldValue, err := m.oldValue(ctx)
  5074. if err != nil {
  5075. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5076. }
  5077. return oldValue.CreatedAt, nil
  5078. }
  5079. // ResetCreatedAt resets all changes to the "created_at" field.
  5080. func (m *TaskMutation) ResetCreatedAt() {
  5081. m.created_at = nil
  5082. }
  5083. // SetUpdatedAt sets the "updated_at" field.
  5084. func (m *TaskMutation) SetUpdatedAt(t time.Time) {
  5085. m.updated_at = &t
  5086. }
  5087. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5088. func (m *TaskMutation) UpdatedAt() (r time.Time, exists bool) {
  5089. v := m.updated_at
  5090. if v == nil {
  5091. return
  5092. }
  5093. return *v, true
  5094. }
  5095. // OldUpdatedAt returns the old "updated_at" field's value of the Task entity.
  5096. // If the Task object wasn't provided to the builder, the object is fetched from the database.
  5097. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5098. func (m *TaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5099. if !m.op.Is(OpUpdateOne) {
  5100. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5101. }
  5102. if m.id == nil || m.oldValue == nil {
  5103. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5104. }
  5105. oldValue, err := m.oldValue(ctx)
  5106. if err != nil {
  5107. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5108. }
  5109. return oldValue.UpdatedAt, nil
  5110. }
  5111. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5112. func (m *TaskMutation) ResetUpdatedAt() {
  5113. m.updated_at = nil
  5114. }
  5115. // SetStatus sets the "status" field.
  5116. func (m *TaskMutation) SetStatus(u uint8) {
  5117. m.status = &u
  5118. m.addstatus = nil
  5119. }
  5120. // Status returns the value of the "status" field in the mutation.
  5121. func (m *TaskMutation) Status() (r uint8, exists bool) {
  5122. v := m.status
  5123. if v == nil {
  5124. return
  5125. }
  5126. return *v, true
  5127. }
  5128. // OldStatus returns the old "status" field's value of the Task entity.
  5129. // If the Task object wasn't provided to the builder, the object is fetched from the database.
  5130. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5131. func (m *TaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  5132. if !m.op.Is(OpUpdateOne) {
  5133. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5134. }
  5135. if m.id == nil || m.oldValue == nil {
  5136. return v, errors.New("OldStatus requires an ID field in the mutation")
  5137. }
  5138. oldValue, err := m.oldValue(ctx)
  5139. if err != nil {
  5140. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5141. }
  5142. return oldValue.Status, nil
  5143. }
  5144. // AddStatus adds u to the "status" field.
  5145. func (m *TaskMutation) AddStatus(u int8) {
  5146. if m.addstatus != nil {
  5147. *m.addstatus += u
  5148. } else {
  5149. m.addstatus = &u
  5150. }
  5151. }
  5152. // AddedStatus returns the value that was added to the "status" field in this mutation.
  5153. func (m *TaskMutation) AddedStatus() (r int8, exists bool) {
  5154. v := m.addstatus
  5155. if v == nil {
  5156. return
  5157. }
  5158. return *v, true
  5159. }
  5160. // ClearStatus clears the value of the "status" field.
  5161. func (m *TaskMutation) ClearStatus() {
  5162. m.status = nil
  5163. m.addstatus = nil
  5164. m.clearedFields[task.FieldStatus] = struct{}{}
  5165. }
  5166. // StatusCleared returns if the "status" field was cleared in this mutation.
  5167. func (m *TaskMutation) StatusCleared() bool {
  5168. _, ok := m.clearedFields[task.FieldStatus]
  5169. return ok
  5170. }
  5171. // ResetStatus resets all changes to the "status" field.
  5172. func (m *TaskMutation) ResetStatus() {
  5173. m.status = nil
  5174. m.addstatus = nil
  5175. delete(m.clearedFields, task.FieldStatus)
  5176. }
  5177. // SetName sets the "name" field.
  5178. func (m *TaskMutation) SetName(s string) {
  5179. m.name = &s
  5180. }
  5181. // Name returns the value of the "name" field in the mutation.
  5182. func (m *TaskMutation) Name() (r string, exists bool) {
  5183. v := m.name
  5184. if v == nil {
  5185. return
  5186. }
  5187. return *v, true
  5188. }
  5189. // OldName returns the old "name" field's value of the Task entity.
  5190. // If the Task object wasn't provided to the builder, the object is fetched from the database.
  5191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5192. func (m *TaskMutation) OldName(ctx context.Context) (v string, err error) {
  5193. if !m.op.Is(OpUpdateOne) {
  5194. return v, errors.New("OldName is only allowed on UpdateOne operations")
  5195. }
  5196. if m.id == nil || m.oldValue == nil {
  5197. return v, errors.New("OldName requires an ID field in the mutation")
  5198. }
  5199. oldValue, err := m.oldValue(ctx)
  5200. if err != nil {
  5201. return v, fmt.Errorf("querying old value for OldName: %w", err)
  5202. }
  5203. return oldValue.Name, nil
  5204. }
  5205. // ResetName resets all changes to the "name" field.
  5206. func (m *TaskMutation) ResetName() {
  5207. m.name = nil
  5208. }
  5209. // SetTaskGroup sets the "task_group" field.
  5210. func (m *TaskMutation) SetTaskGroup(s string) {
  5211. m.task_group = &s
  5212. }
  5213. // TaskGroup returns the value of the "task_group" field in the mutation.
  5214. func (m *TaskMutation) TaskGroup() (r string, exists bool) {
  5215. v := m.task_group
  5216. if v == nil {
  5217. return
  5218. }
  5219. return *v, true
  5220. }
  5221. // OldTaskGroup returns the old "task_group" field's value of the Task entity.
  5222. // If the Task object wasn't provided to the builder, the object is fetched from the database.
  5223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5224. func (m *TaskMutation) OldTaskGroup(ctx context.Context) (v string, err error) {
  5225. if !m.op.Is(OpUpdateOne) {
  5226. return v, errors.New("OldTaskGroup is only allowed on UpdateOne operations")
  5227. }
  5228. if m.id == nil || m.oldValue == nil {
  5229. return v, errors.New("OldTaskGroup requires an ID field in the mutation")
  5230. }
  5231. oldValue, err := m.oldValue(ctx)
  5232. if err != nil {
  5233. return v, fmt.Errorf("querying old value for OldTaskGroup: %w", err)
  5234. }
  5235. return oldValue.TaskGroup, nil
  5236. }
  5237. // ResetTaskGroup resets all changes to the "task_group" field.
  5238. func (m *TaskMutation) ResetTaskGroup() {
  5239. m.task_group = nil
  5240. }
  5241. // SetCronExpression sets the "cron_expression" field.
  5242. func (m *TaskMutation) SetCronExpression(s string) {
  5243. m.cron_expression = &s
  5244. }
  5245. // CronExpression returns the value of the "cron_expression" field in the mutation.
  5246. func (m *TaskMutation) CronExpression() (r string, exists bool) {
  5247. v := m.cron_expression
  5248. if v == nil {
  5249. return
  5250. }
  5251. return *v, true
  5252. }
  5253. // OldCronExpression returns the old "cron_expression" field's value of the Task entity.
  5254. // If the Task object wasn't provided to the builder, the object is fetched from the database.
  5255. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5256. func (m *TaskMutation) OldCronExpression(ctx context.Context) (v string, err error) {
  5257. if !m.op.Is(OpUpdateOne) {
  5258. return v, errors.New("OldCronExpression is only allowed on UpdateOne operations")
  5259. }
  5260. if m.id == nil || m.oldValue == nil {
  5261. return v, errors.New("OldCronExpression requires an ID field in the mutation")
  5262. }
  5263. oldValue, err := m.oldValue(ctx)
  5264. if err != nil {
  5265. return v, fmt.Errorf("querying old value for OldCronExpression: %w", err)
  5266. }
  5267. return oldValue.CronExpression, nil
  5268. }
  5269. // ResetCronExpression resets all changes to the "cron_expression" field.
  5270. func (m *TaskMutation) ResetCronExpression() {
  5271. m.cron_expression = nil
  5272. }
  5273. // SetPattern sets the "pattern" field.
  5274. func (m *TaskMutation) SetPattern(s string) {
  5275. m.pattern = &s
  5276. }
  5277. // Pattern returns the value of the "pattern" field in the mutation.
  5278. func (m *TaskMutation) Pattern() (r string, exists bool) {
  5279. v := m.pattern
  5280. if v == nil {
  5281. return
  5282. }
  5283. return *v, true
  5284. }
  5285. // OldPattern returns the old "pattern" field's value of the Task entity.
  5286. // If the Task object wasn't provided to the builder, the object is fetched from the database.
  5287. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5288. func (m *TaskMutation) OldPattern(ctx context.Context) (v string, err error) {
  5289. if !m.op.Is(OpUpdateOne) {
  5290. return v, errors.New("OldPattern is only allowed on UpdateOne operations")
  5291. }
  5292. if m.id == nil || m.oldValue == nil {
  5293. return v, errors.New("OldPattern requires an ID field in the mutation")
  5294. }
  5295. oldValue, err := m.oldValue(ctx)
  5296. if err != nil {
  5297. return v, fmt.Errorf("querying old value for OldPattern: %w", err)
  5298. }
  5299. return oldValue.Pattern, nil
  5300. }
  5301. // ResetPattern resets all changes to the "pattern" field.
  5302. func (m *TaskMutation) ResetPattern() {
  5303. m.pattern = nil
  5304. }
  5305. // SetPayload sets the "payload" field.
  5306. func (m *TaskMutation) SetPayload(s string) {
  5307. m.payload = &s
  5308. }
  5309. // Payload returns the value of the "payload" field in the mutation.
  5310. func (m *TaskMutation) Payload() (r string, exists bool) {
  5311. v := m.payload
  5312. if v == nil {
  5313. return
  5314. }
  5315. return *v, true
  5316. }
  5317. // OldPayload returns the old "payload" field's value of the Task entity.
  5318. // If the Task 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 *TaskMutation) OldPayload(ctx context.Context) (v string, err error) {
  5321. if !m.op.Is(OpUpdateOne) {
  5322. return v, errors.New("OldPayload is only allowed on UpdateOne operations")
  5323. }
  5324. if m.id == nil || m.oldValue == nil {
  5325. return v, errors.New("OldPayload 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 OldPayload: %w", err)
  5330. }
  5331. return oldValue.Payload, nil
  5332. }
  5333. // ResetPayload resets all changes to the "payload" field.
  5334. func (m *TaskMutation) ResetPayload() {
  5335. m.payload = nil
  5336. }
  5337. // AddTaskLogIDs adds the "task_logs" edge to the TaskLog entity by ids.
  5338. func (m *TaskMutation) AddTaskLogIDs(ids ...uint64) {
  5339. if m.task_logs == nil {
  5340. m.task_logs = make(map[uint64]struct{})
  5341. }
  5342. for i := range ids {
  5343. m.task_logs[ids[i]] = struct{}{}
  5344. }
  5345. }
  5346. // ClearTaskLogs clears the "task_logs" edge to the TaskLog entity.
  5347. func (m *TaskMutation) ClearTaskLogs() {
  5348. m.clearedtask_logs = true
  5349. }
  5350. // TaskLogsCleared reports if the "task_logs" edge to the TaskLog entity was cleared.
  5351. func (m *TaskMutation) TaskLogsCleared() bool {
  5352. return m.clearedtask_logs
  5353. }
  5354. // RemoveTaskLogIDs removes the "task_logs" edge to the TaskLog entity by IDs.
  5355. func (m *TaskMutation) RemoveTaskLogIDs(ids ...uint64) {
  5356. if m.removedtask_logs == nil {
  5357. m.removedtask_logs = make(map[uint64]struct{})
  5358. }
  5359. for i := range ids {
  5360. delete(m.task_logs, ids[i])
  5361. m.removedtask_logs[ids[i]] = struct{}{}
  5362. }
  5363. }
  5364. // RemovedTaskLogs returns the removed IDs of the "task_logs" edge to the TaskLog entity.
  5365. func (m *TaskMutation) RemovedTaskLogsIDs() (ids []uint64) {
  5366. for id := range m.removedtask_logs {
  5367. ids = append(ids, id)
  5368. }
  5369. return
  5370. }
  5371. // TaskLogsIDs returns the "task_logs" edge IDs in the mutation.
  5372. func (m *TaskMutation) TaskLogsIDs() (ids []uint64) {
  5373. for id := range m.task_logs {
  5374. ids = append(ids, id)
  5375. }
  5376. return
  5377. }
  5378. // ResetTaskLogs resets all changes to the "task_logs" edge.
  5379. func (m *TaskMutation) ResetTaskLogs() {
  5380. m.task_logs = nil
  5381. m.clearedtask_logs = false
  5382. m.removedtask_logs = nil
  5383. }
  5384. // Where appends a list predicates to the TaskMutation builder.
  5385. func (m *TaskMutation) Where(ps ...predicate.Task) {
  5386. m.predicates = append(m.predicates, ps...)
  5387. }
  5388. // WhereP appends storage-level predicates to the TaskMutation builder. Using this method,
  5389. // users can use type-assertion to append predicates that do not depend on any generated package.
  5390. func (m *TaskMutation) WhereP(ps ...func(*sql.Selector)) {
  5391. p := make([]predicate.Task, len(ps))
  5392. for i := range ps {
  5393. p[i] = ps[i]
  5394. }
  5395. m.Where(p...)
  5396. }
  5397. // Op returns the operation name.
  5398. func (m *TaskMutation) Op() Op {
  5399. return m.op
  5400. }
  5401. // SetOp allows setting the mutation operation.
  5402. func (m *TaskMutation) SetOp(op Op) {
  5403. m.op = op
  5404. }
  5405. // Type returns the node type of this mutation (Task).
  5406. func (m *TaskMutation) Type() string {
  5407. return m.typ
  5408. }
  5409. // Fields returns all fields that were changed during this mutation. Note that in
  5410. // order to get all numeric fields that were incremented/decremented, call
  5411. // AddedFields().
  5412. func (m *TaskMutation) Fields() []string {
  5413. fields := make([]string, 0, 8)
  5414. if m.created_at != nil {
  5415. fields = append(fields, task.FieldCreatedAt)
  5416. }
  5417. if m.updated_at != nil {
  5418. fields = append(fields, task.FieldUpdatedAt)
  5419. }
  5420. if m.status != nil {
  5421. fields = append(fields, task.FieldStatus)
  5422. }
  5423. if m.name != nil {
  5424. fields = append(fields, task.FieldName)
  5425. }
  5426. if m.task_group != nil {
  5427. fields = append(fields, task.FieldTaskGroup)
  5428. }
  5429. if m.cron_expression != nil {
  5430. fields = append(fields, task.FieldCronExpression)
  5431. }
  5432. if m.pattern != nil {
  5433. fields = append(fields, task.FieldPattern)
  5434. }
  5435. if m.payload != nil {
  5436. fields = append(fields, task.FieldPayload)
  5437. }
  5438. return fields
  5439. }
  5440. // Field returns the value of a field with the given name. The second boolean
  5441. // return value indicates that this field was not set, or was not defined in the
  5442. // schema.
  5443. func (m *TaskMutation) Field(name string) (ent.Value, bool) {
  5444. switch name {
  5445. case task.FieldCreatedAt:
  5446. return m.CreatedAt()
  5447. case task.FieldUpdatedAt:
  5448. return m.UpdatedAt()
  5449. case task.FieldStatus:
  5450. return m.Status()
  5451. case task.FieldName:
  5452. return m.Name()
  5453. case task.FieldTaskGroup:
  5454. return m.TaskGroup()
  5455. case task.FieldCronExpression:
  5456. return m.CronExpression()
  5457. case task.FieldPattern:
  5458. return m.Pattern()
  5459. case task.FieldPayload:
  5460. return m.Payload()
  5461. }
  5462. return nil, false
  5463. }
  5464. // OldField returns the old value of the field from the database. An error is
  5465. // returned if the mutation operation is not UpdateOne, or the query to the
  5466. // database failed.
  5467. func (m *TaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5468. switch name {
  5469. case task.FieldCreatedAt:
  5470. return m.OldCreatedAt(ctx)
  5471. case task.FieldUpdatedAt:
  5472. return m.OldUpdatedAt(ctx)
  5473. case task.FieldStatus:
  5474. return m.OldStatus(ctx)
  5475. case task.FieldName:
  5476. return m.OldName(ctx)
  5477. case task.FieldTaskGroup:
  5478. return m.OldTaskGroup(ctx)
  5479. case task.FieldCronExpression:
  5480. return m.OldCronExpression(ctx)
  5481. case task.FieldPattern:
  5482. return m.OldPattern(ctx)
  5483. case task.FieldPayload:
  5484. return m.OldPayload(ctx)
  5485. }
  5486. return nil, fmt.Errorf("unknown Task field %s", name)
  5487. }
  5488. // SetField sets the value of a field with the given name. It returns an error if
  5489. // the field is not defined in the schema, or if the type mismatched the field
  5490. // type.
  5491. func (m *TaskMutation) SetField(name string, value ent.Value) error {
  5492. switch name {
  5493. case task.FieldCreatedAt:
  5494. v, ok := value.(time.Time)
  5495. if !ok {
  5496. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5497. }
  5498. m.SetCreatedAt(v)
  5499. return nil
  5500. case task.FieldUpdatedAt:
  5501. v, ok := value.(time.Time)
  5502. if !ok {
  5503. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5504. }
  5505. m.SetUpdatedAt(v)
  5506. return nil
  5507. case task.FieldStatus:
  5508. v, ok := value.(uint8)
  5509. if !ok {
  5510. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5511. }
  5512. m.SetStatus(v)
  5513. return nil
  5514. case task.FieldName:
  5515. v, ok := value.(string)
  5516. if !ok {
  5517. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5518. }
  5519. m.SetName(v)
  5520. return nil
  5521. case task.FieldTaskGroup:
  5522. v, ok := value.(string)
  5523. if !ok {
  5524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5525. }
  5526. m.SetTaskGroup(v)
  5527. return nil
  5528. case task.FieldCronExpression:
  5529. v, ok := value.(string)
  5530. if !ok {
  5531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5532. }
  5533. m.SetCronExpression(v)
  5534. return nil
  5535. case task.FieldPattern:
  5536. v, ok := value.(string)
  5537. if !ok {
  5538. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5539. }
  5540. m.SetPattern(v)
  5541. return nil
  5542. case task.FieldPayload:
  5543. v, ok := value.(string)
  5544. if !ok {
  5545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5546. }
  5547. m.SetPayload(v)
  5548. return nil
  5549. }
  5550. return fmt.Errorf("unknown Task field %s", name)
  5551. }
  5552. // AddedFields returns all numeric fields that were incremented/decremented during
  5553. // this mutation.
  5554. func (m *TaskMutation) AddedFields() []string {
  5555. var fields []string
  5556. if m.addstatus != nil {
  5557. fields = append(fields, task.FieldStatus)
  5558. }
  5559. return fields
  5560. }
  5561. // AddedField returns the numeric value that was incremented/decremented on a field
  5562. // with the given name. The second boolean return value indicates that this field
  5563. // was not set, or was not defined in the schema.
  5564. func (m *TaskMutation) AddedField(name string) (ent.Value, bool) {
  5565. switch name {
  5566. case task.FieldStatus:
  5567. return m.AddedStatus()
  5568. }
  5569. return nil, false
  5570. }
  5571. // AddField adds the value to the field with the given name. It returns an error if
  5572. // the field is not defined in the schema, or if the type mismatched the field
  5573. // type.
  5574. func (m *TaskMutation) AddField(name string, value ent.Value) error {
  5575. switch name {
  5576. case task.FieldStatus:
  5577. v, ok := value.(int8)
  5578. if !ok {
  5579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5580. }
  5581. m.AddStatus(v)
  5582. return nil
  5583. }
  5584. return fmt.Errorf("unknown Task numeric field %s", name)
  5585. }
  5586. // ClearedFields returns all nullable fields that were cleared during this
  5587. // mutation.
  5588. func (m *TaskMutation) ClearedFields() []string {
  5589. var fields []string
  5590. if m.FieldCleared(task.FieldStatus) {
  5591. fields = append(fields, task.FieldStatus)
  5592. }
  5593. return fields
  5594. }
  5595. // FieldCleared returns a boolean indicating if a field with the given name was
  5596. // cleared in this mutation.
  5597. func (m *TaskMutation) FieldCleared(name string) bool {
  5598. _, ok := m.clearedFields[name]
  5599. return ok
  5600. }
  5601. // ClearField clears the value of the field with the given name. It returns an
  5602. // error if the field is not defined in the schema.
  5603. func (m *TaskMutation) ClearField(name string) error {
  5604. switch name {
  5605. case task.FieldStatus:
  5606. m.ClearStatus()
  5607. return nil
  5608. }
  5609. return fmt.Errorf("unknown Task nullable field %s", name)
  5610. }
  5611. // ResetField resets all changes in the mutation for the field with the given name.
  5612. // It returns an error if the field is not defined in the schema.
  5613. func (m *TaskMutation) ResetField(name string) error {
  5614. switch name {
  5615. case task.FieldCreatedAt:
  5616. m.ResetCreatedAt()
  5617. return nil
  5618. case task.FieldUpdatedAt:
  5619. m.ResetUpdatedAt()
  5620. return nil
  5621. case task.FieldStatus:
  5622. m.ResetStatus()
  5623. return nil
  5624. case task.FieldName:
  5625. m.ResetName()
  5626. return nil
  5627. case task.FieldTaskGroup:
  5628. m.ResetTaskGroup()
  5629. return nil
  5630. case task.FieldCronExpression:
  5631. m.ResetCronExpression()
  5632. return nil
  5633. case task.FieldPattern:
  5634. m.ResetPattern()
  5635. return nil
  5636. case task.FieldPayload:
  5637. m.ResetPayload()
  5638. return nil
  5639. }
  5640. return fmt.Errorf("unknown Task field %s", name)
  5641. }
  5642. // AddedEdges returns all edge names that were set/added in this mutation.
  5643. func (m *TaskMutation) AddedEdges() []string {
  5644. edges := make([]string, 0, 1)
  5645. if m.task_logs != nil {
  5646. edges = append(edges, task.EdgeTaskLogs)
  5647. }
  5648. return edges
  5649. }
  5650. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5651. // name in this mutation.
  5652. func (m *TaskMutation) AddedIDs(name string) []ent.Value {
  5653. switch name {
  5654. case task.EdgeTaskLogs:
  5655. ids := make([]ent.Value, 0, len(m.task_logs))
  5656. for id := range m.task_logs {
  5657. ids = append(ids, id)
  5658. }
  5659. return ids
  5660. }
  5661. return nil
  5662. }
  5663. // RemovedEdges returns all edge names that were removed in this mutation.
  5664. func (m *TaskMutation) RemovedEdges() []string {
  5665. edges := make([]string, 0, 1)
  5666. if m.removedtask_logs != nil {
  5667. edges = append(edges, task.EdgeTaskLogs)
  5668. }
  5669. return edges
  5670. }
  5671. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5672. // the given name in this mutation.
  5673. func (m *TaskMutation) RemovedIDs(name string) []ent.Value {
  5674. switch name {
  5675. case task.EdgeTaskLogs:
  5676. ids := make([]ent.Value, 0, len(m.removedtask_logs))
  5677. for id := range m.removedtask_logs {
  5678. ids = append(ids, id)
  5679. }
  5680. return ids
  5681. }
  5682. return nil
  5683. }
  5684. // ClearedEdges returns all edge names that were cleared in this mutation.
  5685. func (m *TaskMutation) ClearedEdges() []string {
  5686. edges := make([]string, 0, 1)
  5687. if m.clearedtask_logs {
  5688. edges = append(edges, task.EdgeTaskLogs)
  5689. }
  5690. return edges
  5691. }
  5692. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5693. // was cleared in this mutation.
  5694. func (m *TaskMutation) EdgeCleared(name string) bool {
  5695. switch name {
  5696. case task.EdgeTaskLogs:
  5697. return m.clearedtask_logs
  5698. }
  5699. return false
  5700. }
  5701. // ClearEdge clears the value of the edge with the given name. It returns an error
  5702. // if that edge is not defined in the schema.
  5703. func (m *TaskMutation) ClearEdge(name string) error {
  5704. switch name {
  5705. }
  5706. return fmt.Errorf("unknown Task unique edge %s", name)
  5707. }
  5708. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5709. // It returns an error if the edge is not defined in the schema.
  5710. func (m *TaskMutation) ResetEdge(name string) error {
  5711. switch name {
  5712. case task.EdgeTaskLogs:
  5713. m.ResetTaskLogs()
  5714. return nil
  5715. }
  5716. return fmt.Errorf("unknown Task edge %s", name)
  5717. }
  5718. // TaskLogMutation represents an operation that mutates the TaskLog nodes in the graph.
  5719. type TaskLogMutation struct {
  5720. config
  5721. op Op
  5722. typ string
  5723. id *uint64
  5724. started_at *time.Time
  5725. finished_at *time.Time
  5726. result *uint8
  5727. addresult *int8
  5728. clearedFields map[string]struct{}
  5729. tasks *uint64
  5730. clearedtasks bool
  5731. done bool
  5732. oldValue func(context.Context) (*TaskLog, error)
  5733. predicates []predicate.TaskLog
  5734. }
  5735. var _ ent.Mutation = (*TaskLogMutation)(nil)
  5736. // tasklogOption allows management of the mutation configuration using functional options.
  5737. type tasklogOption func(*TaskLogMutation)
  5738. // newTaskLogMutation creates new mutation for the TaskLog entity.
  5739. func newTaskLogMutation(c config, op Op, opts ...tasklogOption) *TaskLogMutation {
  5740. m := &TaskLogMutation{
  5741. config: c,
  5742. op: op,
  5743. typ: TypeTaskLog,
  5744. clearedFields: make(map[string]struct{}),
  5745. }
  5746. for _, opt := range opts {
  5747. opt(m)
  5748. }
  5749. return m
  5750. }
  5751. // withTaskLogID sets the ID field of the mutation.
  5752. func withTaskLogID(id uint64) tasklogOption {
  5753. return func(m *TaskLogMutation) {
  5754. var (
  5755. err error
  5756. once sync.Once
  5757. value *TaskLog
  5758. )
  5759. m.oldValue = func(ctx context.Context) (*TaskLog, error) {
  5760. once.Do(func() {
  5761. if m.done {
  5762. err = errors.New("querying old values post mutation is not allowed")
  5763. } else {
  5764. value, err = m.Client().TaskLog.Get(ctx, id)
  5765. }
  5766. })
  5767. return value, err
  5768. }
  5769. m.id = &id
  5770. }
  5771. }
  5772. // withTaskLog sets the old TaskLog of the mutation.
  5773. func withTaskLog(node *TaskLog) tasklogOption {
  5774. return func(m *TaskLogMutation) {
  5775. m.oldValue = func(context.Context) (*TaskLog, error) {
  5776. return node, nil
  5777. }
  5778. m.id = &node.ID
  5779. }
  5780. }
  5781. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5782. // executed in a transaction (ent.Tx), a transactional client is returned.
  5783. func (m TaskLogMutation) Client() *Client {
  5784. client := &Client{config: m.config}
  5785. client.init()
  5786. return client
  5787. }
  5788. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5789. // it returns an error otherwise.
  5790. func (m TaskLogMutation) Tx() (*Tx, error) {
  5791. if _, ok := m.driver.(*txDriver); !ok {
  5792. return nil, errors.New("ent: mutation is not running in a transaction")
  5793. }
  5794. tx := &Tx{config: m.config}
  5795. tx.init()
  5796. return tx, nil
  5797. }
  5798. // SetID sets the value of the id field. Note that this
  5799. // operation is only accepted on creation of TaskLog entities.
  5800. func (m *TaskLogMutation) SetID(id uint64) {
  5801. m.id = &id
  5802. }
  5803. // ID returns the ID value in the mutation. Note that the ID is only available
  5804. // if it was provided to the builder or after it was returned from the database.
  5805. func (m *TaskLogMutation) ID() (id uint64, exists bool) {
  5806. if m.id == nil {
  5807. return
  5808. }
  5809. return *m.id, true
  5810. }
  5811. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5812. // That means, if the mutation is applied within a transaction with an isolation level such
  5813. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5814. // or updated by the mutation.
  5815. func (m *TaskLogMutation) IDs(ctx context.Context) ([]uint64, error) {
  5816. switch {
  5817. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5818. id, exists := m.ID()
  5819. if exists {
  5820. return []uint64{id}, nil
  5821. }
  5822. fallthrough
  5823. case m.op.Is(OpUpdate | OpDelete):
  5824. return m.Client().TaskLog.Query().Where(m.predicates...).IDs(ctx)
  5825. default:
  5826. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5827. }
  5828. }
  5829. // SetStartedAt sets the "started_at" field.
  5830. func (m *TaskLogMutation) SetStartedAt(t time.Time) {
  5831. m.started_at = &t
  5832. }
  5833. // StartedAt returns the value of the "started_at" field in the mutation.
  5834. func (m *TaskLogMutation) StartedAt() (r time.Time, exists bool) {
  5835. v := m.started_at
  5836. if v == nil {
  5837. return
  5838. }
  5839. return *v, true
  5840. }
  5841. // OldStartedAt returns the old "started_at" field's value of the TaskLog entity.
  5842. // If the TaskLog object wasn't provided to the builder, the object is fetched from the database.
  5843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5844. func (m *TaskLogMutation) OldStartedAt(ctx context.Context) (v time.Time, err error) {
  5845. if !m.op.Is(OpUpdateOne) {
  5846. return v, errors.New("OldStartedAt is only allowed on UpdateOne operations")
  5847. }
  5848. if m.id == nil || m.oldValue == nil {
  5849. return v, errors.New("OldStartedAt requires an ID field in the mutation")
  5850. }
  5851. oldValue, err := m.oldValue(ctx)
  5852. if err != nil {
  5853. return v, fmt.Errorf("querying old value for OldStartedAt: %w", err)
  5854. }
  5855. return oldValue.StartedAt, nil
  5856. }
  5857. // ResetStartedAt resets all changes to the "started_at" field.
  5858. func (m *TaskLogMutation) ResetStartedAt() {
  5859. m.started_at = nil
  5860. }
  5861. // SetFinishedAt sets the "finished_at" field.
  5862. func (m *TaskLogMutation) SetFinishedAt(t time.Time) {
  5863. m.finished_at = &t
  5864. }
  5865. // FinishedAt returns the value of the "finished_at" field in the mutation.
  5866. func (m *TaskLogMutation) FinishedAt() (r time.Time, exists bool) {
  5867. v := m.finished_at
  5868. if v == nil {
  5869. return
  5870. }
  5871. return *v, true
  5872. }
  5873. // OldFinishedAt returns the old "finished_at" field's value of the TaskLog entity.
  5874. // If the TaskLog object wasn't provided to the builder, the object is fetched from the database.
  5875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5876. func (m *TaskLogMutation) OldFinishedAt(ctx context.Context) (v time.Time, err error) {
  5877. if !m.op.Is(OpUpdateOne) {
  5878. return v, errors.New("OldFinishedAt is only allowed on UpdateOne operations")
  5879. }
  5880. if m.id == nil || m.oldValue == nil {
  5881. return v, errors.New("OldFinishedAt requires an ID field in the mutation")
  5882. }
  5883. oldValue, err := m.oldValue(ctx)
  5884. if err != nil {
  5885. return v, fmt.Errorf("querying old value for OldFinishedAt: %w", err)
  5886. }
  5887. return oldValue.FinishedAt, nil
  5888. }
  5889. // ResetFinishedAt resets all changes to the "finished_at" field.
  5890. func (m *TaskLogMutation) ResetFinishedAt() {
  5891. m.finished_at = nil
  5892. }
  5893. // SetResult sets the "result" field.
  5894. func (m *TaskLogMutation) SetResult(u uint8) {
  5895. m.result = &u
  5896. m.addresult = nil
  5897. }
  5898. // Result returns the value of the "result" field in the mutation.
  5899. func (m *TaskLogMutation) Result() (r uint8, exists bool) {
  5900. v := m.result
  5901. if v == nil {
  5902. return
  5903. }
  5904. return *v, true
  5905. }
  5906. // OldResult returns the old "result" field's value of the TaskLog entity.
  5907. // If the TaskLog object wasn't provided to the builder, the object is fetched from the database.
  5908. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5909. func (m *TaskLogMutation) OldResult(ctx context.Context) (v uint8, err error) {
  5910. if !m.op.Is(OpUpdateOne) {
  5911. return v, errors.New("OldResult is only allowed on UpdateOne operations")
  5912. }
  5913. if m.id == nil || m.oldValue == nil {
  5914. return v, errors.New("OldResult requires an ID field in the mutation")
  5915. }
  5916. oldValue, err := m.oldValue(ctx)
  5917. if err != nil {
  5918. return v, fmt.Errorf("querying old value for OldResult: %w", err)
  5919. }
  5920. return oldValue.Result, nil
  5921. }
  5922. // AddResult adds u to the "result" field.
  5923. func (m *TaskLogMutation) AddResult(u int8) {
  5924. if m.addresult != nil {
  5925. *m.addresult += u
  5926. } else {
  5927. m.addresult = &u
  5928. }
  5929. }
  5930. // AddedResult returns the value that was added to the "result" field in this mutation.
  5931. func (m *TaskLogMutation) AddedResult() (r int8, exists bool) {
  5932. v := m.addresult
  5933. if v == nil {
  5934. return
  5935. }
  5936. return *v, true
  5937. }
  5938. // ResetResult resets all changes to the "result" field.
  5939. func (m *TaskLogMutation) ResetResult() {
  5940. m.result = nil
  5941. m.addresult = nil
  5942. }
  5943. // SetTasksID sets the "tasks" edge to the Task entity by id.
  5944. func (m *TaskLogMutation) SetTasksID(id uint64) {
  5945. m.tasks = &id
  5946. }
  5947. // ClearTasks clears the "tasks" edge to the Task entity.
  5948. func (m *TaskLogMutation) ClearTasks() {
  5949. m.clearedtasks = true
  5950. }
  5951. // TasksCleared reports if the "tasks" edge to the Task entity was cleared.
  5952. func (m *TaskLogMutation) TasksCleared() bool {
  5953. return m.clearedtasks
  5954. }
  5955. // TasksID returns the "tasks" edge ID in the mutation.
  5956. func (m *TaskLogMutation) TasksID() (id uint64, exists bool) {
  5957. if m.tasks != nil {
  5958. return *m.tasks, true
  5959. }
  5960. return
  5961. }
  5962. // TasksIDs returns the "tasks" edge IDs in the mutation.
  5963. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  5964. // TasksID instead. It exists only for internal usage by the builders.
  5965. func (m *TaskLogMutation) TasksIDs() (ids []uint64) {
  5966. if id := m.tasks; id != nil {
  5967. ids = append(ids, *id)
  5968. }
  5969. return
  5970. }
  5971. // ResetTasks resets all changes to the "tasks" edge.
  5972. func (m *TaskLogMutation) ResetTasks() {
  5973. m.tasks = nil
  5974. m.clearedtasks = false
  5975. }
  5976. // Where appends a list predicates to the TaskLogMutation builder.
  5977. func (m *TaskLogMutation) Where(ps ...predicate.TaskLog) {
  5978. m.predicates = append(m.predicates, ps...)
  5979. }
  5980. // WhereP appends storage-level predicates to the TaskLogMutation builder. Using this method,
  5981. // users can use type-assertion to append predicates that do not depend on any generated package.
  5982. func (m *TaskLogMutation) WhereP(ps ...func(*sql.Selector)) {
  5983. p := make([]predicate.TaskLog, len(ps))
  5984. for i := range ps {
  5985. p[i] = ps[i]
  5986. }
  5987. m.Where(p...)
  5988. }
  5989. // Op returns the operation name.
  5990. func (m *TaskLogMutation) Op() Op {
  5991. return m.op
  5992. }
  5993. // SetOp allows setting the mutation operation.
  5994. func (m *TaskLogMutation) SetOp(op Op) {
  5995. m.op = op
  5996. }
  5997. // Type returns the node type of this mutation (TaskLog).
  5998. func (m *TaskLogMutation) Type() string {
  5999. return m.typ
  6000. }
  6001. // Fields returns all fields that were changed during this mutation. Note that in
  6002. // order to get all numeric fields that were incremented/decremented, call
  6003. // AddedFields().
  6004. func (m *TaskLogMutation) Fields() []string {
  6005. fields := make([]string, 0, 3)
  6006. if m.started_at != nil {
  6007. fields = append(fields, tasklog.FieldStartedAt)
  6008. }
  6009. if m.finished_at != nil {
  6010. fields = append(fields, tasklog.FieldFinishedAt)
  6011. }
  6012. if m.result != nil {
  6013. fields = append(fields, tasklog.FieldResult)
  6014. }
  6015. return fields
  6016. }
  6017. // Field returns the value of a field with the given name. The second boolean
  6018. // return value indicates that this field was not set, or was not defined in the
  6019. // schema.
  6020. func (m *TaskLogMutation) Field(name string) (ent.Value, bool) {
  6021. switch name {
  6022. case tasklog.FieldStartedAt:
  6023. return m.StartedAt()
  6024. case tasklog.FieldFinishedAt:
  6025. return m.FinishedAt()
  6026. case tasklog.FieldResult:
  6027. return m.Result()
  6028. }
  6029. return nil, false
  6030. }
  6031. // OldField returns the old value of the field from the database. An error is
  6032. // returned if the mutation operation is not UpdateOne, or the query to the
  6033. // database failed.
  6034. func (m *TaskLogMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6035. switch name {
  6036. case tasklog.FieldStartedAt:
  6037. return m.OldStartedAt(ctx)
  6038. case tasklog.FieldFinishedAt:
  6039. return m.OldFinishedAt(ctx)
  6040. case tasklog.FieldResult:
  6041. return m.OldResult(ctx)
  6042. }
  6043. return nil, fmt.Errorf("unknown TaskLog field %s", name)
  6044. }
  6045. // SetField sets the value of a field with the given name. It returns an error if
  6046. // the field is not defined in the schema, or if the type mismatched the field
  6047. // type.
  6048. func (m *TaskLogMutation) SetField(name string, value ent.Value) error {
  6049. switch name {
  6050. case tasklog.FieldStartedAt:
  6051. v, ok := value.(time.Time)
  6052. if !ok {
  6053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6054. }
  6055. m.SetStartedAt(v)
  6056. return nil
  6057. case tasklog.FieldFinishedAt:
  6058. v, ok := value.(time.Time)
  6059. if !ok {
  6060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6061. }
  6062. m.SetFinishedAt(v)
  6063. return nil
  6064. case tasklog.FieldResult:
  6065. v, ok := value.(uint8)
  6066. if !ok {
  6067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6068. }
  6069. m.SetResult(v)
  6070. return nil
  6071. }
  6072. return fmt.Errorf("unknown TaskLog field %s", name)
  6073. }
  6074. // AddedFields returns all numeric fields that were incremented/decremented during
  6075. // this mutation.
  6076. func (m *TaskLogMutation) AddedFields() []string {
  6077. var fields []string
  6078. if m.addresult != nil {
  6079. fields = append(fields, tasklog.FieldResult)
  6080. }
  6081. return fields
  6082. }
  6083. // AddedField returns the numeric value that was incremented/decremented on a field
  6084. // with the given name. The second boolean return value indicates that this field
  6085. // was not set, or was not defined in the schema.
  6086. func (m *TaskLogMutation) AddedField(name string) (ent.Value, bool) {
  6087. switch name {
  6088. case tasklog.FieldResult:
  6089. return m.AddedResult()
  6090. }
  6091. return nil, false
  6092. }
  6093. // AddField adds the value to the field with the given name. It returns an error if
  6094. // the field is not defined in the schema, or if the type mismatched the field
  6095. // type.
  6096. func (m *TaskLogMutation) AddField(name string, value ent.Value) error {
  6097. switch name {
  6098. case tasklog.FieldResult:
  6099. v, ok := value.(int8)
  6100. if !ok {
  6101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6102. }
  6103. m.AddResult(v)
  6104. return nil
  6105. }
  6106. return fmt.Errorf("unknown TaskLog numeric field %s", name)
  6107. }
  6108. // ClearedFields returns all nullable fields that were cleared during this
  6109. // mutation.
  6110. func (m *TaskLogMutation) ClearedFields() []string {
  6111. return nil
  6112. }
  6113. // FieldCleared returns a boolean indicating if a field with the given name was
  6114. // cleared in this mutation.
  6115. func (m *TaskLogMutation) FieldCleared(name string) bool {
  6116. _, ok := m.clearedFields[name]
  6117. return ok
  6118. }
  6119. // ClearField clears the value of the field with the given name. It returns an
  6120. // error if the field is not defined in the schema.
  6121. func (m *TaskLogMutation) ClearField(name string) error {
  6122. return fmt.Errorf("unknown TaskLog nullable field %s", name)
  6123. }
  6124. // ResetField resets all changes in the mutation for the field with the given name.
  6125. // It returns an error if the field is not defined in the schema.
  6126. func (m *TaskLogMutation) ResetField(name string) error {
  6127. switch name {
  6128. case tasklog.FieldStartedAt:
  6129. m.ResetStartedAt()
  6130. return nil
  6131. case tasklog.FieldFinishedAt:
  6132. m.ResetFinishedAt()
  6133. return nil
  6134. case tasklog.FieldResult:
  6135. m.ResetResult()
  6136. return nil
  6137. }
  6138. return fmt.Errorf("unknown TaskLog field %s", name)
  6139. }
  6140. // AddedEdges returns all edge names that were set/added in this mutation.
  6141. func (m *TaskLogMutation) AddedEdges() []string {
  6142. edges := make([]string, 0, 1)
  6143. if m.tasks != nil {
  6144. edges = append(edges, tasklog.EdgeTasks)
  6145. }
  6146. return edges
  6147. }
  6148. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6149. // name in this mutation.
  6150. func (m *TaskLogMutation) AddedIDs(name string) []ent.Value {
  6151. switch name {
  6152. case tasklog.EdgeTasks:
  6153. if id := m.tasks; id != nil {
  6154. return []ent.Value{*id}
  6155. }
  6156. }
  6157. return nil
  6158. }
  6159. // RemovedEdges returns all edge names that were removed in this mutation.
  6160. func (m *TaskLogMutation) RemovedEdges() []string {
  6161. edges := make([]string, 0, 1)
  6162. return edges
  6163. }
  6164. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6165. // the given name in this mutation.
  6166. func (m *TaskLogMutation) RemovedIDs(name string) []ent.Value {
  6167. return nil
  6168. }
  6169. // ClearedEdges returns all edge names that were cleared in this mutation.
  6170. func (m *TaskLogMutation) ClearedEdges() []string {
  6171. edges := make([]string, 0, 1)
  6172. if m.clearedtasks {
  6173. edges = append(edges, tasklog.EdgeTasks)
  6174. }
  6175. return edges
  6176. }
  6177. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6178. // was cleared in this mutation.
  6179. func (m *TaskLogMutation) EdgeCleared(name string) bool {
  6180. switch name {
  6181. case tasklog.EdgeTasks:
  6182. return m.clearedtasks
  6183. }
  6184. return false
  6185. }
  6186. // ClearEdge clears the value of the edge with the given name. It returns an error
  6187. // if that edge is not defined in the schema.
  6188. func (m *TaskLogMutation) ClearEdge(name string) error {
  6189. switch name {
  6190. case tasklog.EdgeTasks:
  6191. m.ClearTasks()
  6192. return nil
  6193. }
  6194. return fmt.Errorf("unknown TaskLog unique edge %s", name)
  6195. }
  6196. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6197. // It returns an error if the edge is not defined in the schema.
  6198. func (m *TaskLogMutation) ResetEdge(name string) error {
  6199. switch name {
  6200. case tasklog.EdgeTasks:
  6201. m.ResetTasks()
  6202. return nil
  6203. }
  6204. return fmt.Errorf("unknown TaskLog edge %s", name)
  6205. }