mutation.go 336 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "sync"
  8. "time"
  9. "wechat-api/ent/contact"
  10. "wechat-api/ent/custom_types"
  11. "wechat-api/ent/label"
  12. "wechat-api/ent/labelrelationship"
  13. "wechat-api/ent/message"
  14. "wechat-api/ent/messagerecords"
  15. "wechat-api/ent/predicate"
  16. "wechat-api/ent/server"
  17. "wechat-api/ent/sopnode"
  18. "wechat-api/ent/sopstage"
  19. "wechat-api/ent/soptask"
  20. "wechat-api/ent/wx"
  21. "entgo.io/ent"
  22. "entgo.io/ent/dialect/sql"
  23. )
  24. const (
  25. // Operation types.
  26. OpCreate = ent.OpCreate
  27. OpDelete = ent.OpDelete
  28. OpDeleteOne = ent.OpDeleteOne
  29. OpUpdate = ent.OpUpdate
  30. OpUpdateOne = ent.OpUpdateOne
  31. // Node types.
  32. TypeContact = "Contact"
  33. TypeLabel = "Label"
  34. TypeLabelRelationship = "LabelRelationship"
  35. TypeMessage = "Message"
  36. TypeMessageRecords = "MessageRecords"
  37. TypeServer = "Server"
  38. TypeSopNode = "SopNode"
  39. TypeSopStage = "SopStage"
  40. TypeSopTask = "SopTask"
  41. TypeWx = "Wx"
  42. )
  43. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  44. type ContactMutation struct {
  45. config
  46. op Op
  47. typ string
  48. id *uint64
  49. created_at *time.Time
  50. updated_at *time.Time
  51. status *uint8
  52. addstatus *int8
  53. deleted_at *time.Time
  54. wx_wxid *string
  55. _type *int
  56. add_type *int
  57. wxid *string
  58. account *string
  59. nickname *string
  60. markname *string
  61. headimg *string
  62. sex *int
  63. addsex *int
  64. starrole *string
  65. dontseeit *int
  66. adddontseeit *int
  67. dontseeme *int
  68. adddontseeme *int
  69. lag *string
  70. gid *string
  71. gname *string
  72. v3 *string
  73. clearedFields map[string]struct{}
  74. contact_relationships map[uint64]struct{}
  75. removedcontact_relationships map[uint64]struct{}
  76. clearedcontact_relationships bool
  77. contact_messages map[uint64]struct{}
  78. removedcontact_messages map[uint64]struct{}
  79. clearedcontact_messages bool
  80. done bool
  81. oldValue func(context.Context) (*Contact, error)
  82. predicates []predicate.Contact
  83. }
  84. var _ ent.Mutation = (*ContactMutation)(nil)
  85. // contactOption allows management of the mutation configuration using functional options.
  86. type contactOption func(*ContactMutation)
  87. // newContactMutation creates new mutation for the Contact entity.
  88. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  89. m := &ContactMutation{
  90. config: c,
  91. op: op,
  92. typ: TypeContact,
  93. clearedFields: make(map[string]struct{}),
  94. }
  95. for _, opt := range opts {
  96. opt(m)
  97. }
  98. return m
  99. }
  100. // withContactID sets the ID field of the mutation.
  101. func withContactID(id uint64) contactOption {
  102. return func(m *ContactMutation) {
  103. var (
  104. err error
  105. once sync.Once
  106. value *Contact
  107. )
  108. m.oldValue = func(ctx context.Context) (*Contact, error) {
  109. once.Do(func() {
  110. if m.done {
  111. err = errors.New("querying old values post mutation is not allowed")
  112. } else {
  113. value, err = m.Client().Contact.Get(ctx, id)
  114. }
  115. })
  116. return value, err
  117. }
  118. m.id = &id
  119. }
  120. }
  121. // withContact sets the old Contact of the mutation.
  122. func withContact(node *Contact) contactOption {
  123. return func(m *ContactMutation) {
  124. m.oldValue = func(context.Context) (*Contact, error) {
  125. return node, nil
  126. }
  127. m.id = &node.ID
  128. }
  129. }
  130. // Client returns a new `ent.Client` from the mutation. If the mutation was
  131. // executed in a transaction (ent.Tx), a transactional client is returned.
  132. func (m ContactMutation) Client() *Client {
  133. client := &Client{config: m.config}
  134. client.init()
  135. return client
  136. }
  137. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  138. // it returns an error otherwise.
  139. func (m ContactMutation) Tx() (*Tx, error) {
  140. if _, ok := m.driver.(*txDriver); !ok {
  141. return nil, errors.New("ent: mutation is not running in a transaction")
  142. }
  143. tx := &Tx{config: m.config}
  144. tx.init()
  145. return tx, nil
  146. }
  147. // SetID sets the value of the id field. Note that this
  148. // operation is only accepted on creation of Contact entities.
  149. func (m *ContactMutation) SetID(id uint64) {
  150. m.id = &id
  151. }
  152. // ID returns the ID value in the mutation. Note that the ID is only available
  153. // if it was provided to the builder or after it was returned from the database.
  154. func (m *ContactMutation) ID() (id uint64, exists bool) {
  155. if m.id == nil {
  156. return
  157. }
  158. return *m.id, true
  159. }
  160. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  161. // That means, if the mutation is applied within a transaction with an isolation level such
  162. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  163. // or updated by the mutation.
  164. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  165. switch {
  166. case m.op.Is(OpUpdateOne | OpDeleteOne):
  167. id, exists := m.ID()
  168. if exists {
  169. return []uint64{id}, nil
  170. }
  171. fallthrough
  172. case m.op.Is(OpUpdate | OpDelete):
  173. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  174. default:
  175. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  176. }
  177. }
  178. // SetCreatedAt sets the "created_at" field.
  179. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  180. m.created_at = &t
  181. }
  182. // CreatedAt returns the value of the "created_at" field in the mutation.
  183. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  184. v := m.created_at
  185. if v == nil {
  186. return
  187. }
  188. return *v, true
  189. }
  190. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  191. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  192. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  193. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  194. if !m.op.Is(OpUpdateOne) {
  195. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  196. }
  197. if m.id == nil || m.oldValue == nil {
  198. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  199. }
  200. oldValue, err := m.oldValue(ctx)
  201. if err != nil {
  202. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  203. }
  204. return oldValue.CreatedAt, nil
  205. }
  206. // ResetCreatedAt resets all changes to the "created_at" field.
  207. func (m *ContactMutation) ResetCreatedAt() {
  208. m.created_at = nil
  209. }
  210. // SetUpdatedAt sets the "updated_at" field.
  211. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  212. m.updated_at = &t
  213. }
  214. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  215. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  216. v := m.updated_at
  217. if v == nil {
  218. return
  219. }
  220. return *v, true
  221. }
  222. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  223. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  225. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  226. if !m.op.Is(OpUpdateOne) {
  227. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  228. }
  229. if m.id == nil || m.oldValue == nil {
  230. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  231. }
  232. oldValue, err := m.oldValue(ctx)
  233. if err != nil {
  234. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  235. }
  236. return oldValue.UpdatedAt, nil
  237. }
  238. // ResetUpdatedAt resets all changes to the "updated_at" field.
  239. func (m *ContactMutation) ResetUpdatedAt() {
  240. m.updated_at = nil
  241. }
  242. // SetStatus sets the "status" field.
  243. func (m *ContactMutation) SetStatus(u uint8) {
  244. m.status = &u
  245. m.addstatus = nil
  246. }
  247. // Status returns the value of the "status" field in the mutation.
  248. func (m *ContactMutation) Status() (r uint8, exists bool) {
  249. v := m.status
  250. if v == nil {
  251. return
  252. }
  253. return *v, true
  254. }
  255. // OldStatus returns the old "status" field's value of the Contact entity.
  256. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  257. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  258. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  259. if !m.op.Is(OpUpdateOne) {
  260. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  261. }
  262. if m.id == nil || m.oldValue == nil {
  263. return v, errors.New("OldStatus requires an ID field in the mutation")
  264. }
  265. oldValue, err := m.oldValue(ctx)
  266. if err != nil {
  267. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  268. }
  269. return oldValue.Status, nil
  270. }
  271. // AddStatus adds u to the "status" field.
  272. func (m *ContactMutation) AddStatus(u int8) {
  273. if m.addstatus != nil {
  274. *m.addstatus += u
  275. } else {
  276. m.addstatus = &u
  277. }
  278. }
  279. // AddedStatus returns the value that was added to the "status" field in this mutation.
  280. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  281. v := m.addstatus
  282. if v == nil {
  283. return
  284. }
  285. return *v, true
  286. }
  287. // ClearStatus clears the value of the "status" field.
  288. func (m *ContactMutation) ClearStatus() {
  289. m.status = nil
  290. m.addstatus = nil
  291. m.clearedFields[contact.FieldStatus] = struct{}{}
  292. }
  293. // StatusCleared returns if the "status" field was cleared in this mutation.
  294. func (m *ContactMutation) StatusCleared() bool {
  295. _, ok := m.clearedFields[contact.FieldStatus]
  296. return ok
  297. }
  298. // ResetStatus resets all changes to the "status" field.
  299. func (m *ContactMutation) ResetStatus() {
  300. m.status = nil
  301. m.addstatus = nil
  302. delete(m.clearedFields, contact.FieldStatus)
  303. }
  304. // SetDeletedAt sets the "deleted_at" field.
  305. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  306. m.deleted_at = &t
  307. }
  308. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  309. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  310. v := m.deleted_at
  311. if v == nil {
  312. return
  313. }
  314. return *v, true
  315. }
  316. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  317. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  319. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  320. if !m.op.Is(OpUpdateOne) {
  321. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  322. }
  323. if m.id == nil || m.oldValue == nil {
  324. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  325. }
  326. oldValue, err := m.oldValue(ctx)
  327. if err != nil {
  328. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  329. }
  330. return oldValue.DeletedAt, nil
  331. }
  332. // ClearDeletedAt clears the value of the "deleted_at" field.
  333. func (m *ContactMutation) ClearDeletedAt() {
  334. m.deleted_at = nil
  335. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  336. }
  337. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  338. func (m *ContactMutation) DeletedAtCleared() bool {
  339. _, ok := m.clearedFields[contact.FieldDeletedAt]
  340. return ok
  341. }
  342. // ResetDeletedAt resets all changes to the "deleted_at" field.
  343. func (m *ContactMutation) ResetDeletedAt() {
  344. m.deleted_at = nil
  345. delete(m.clearedFields, contact.FieldDeletedAt)
  346. }
  347. // SetWxWxid sets the "wx_wxid" field.
  348. func (m *ContactMutation) SetWxWxid(s string) {
  349. m.wx_wxid = &s
  350. }
  351. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  352. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  353. v := m.wx_wxid
  354. if v == nil {
  355. return
  356. }
  357. return *v, true
  358. }
  359. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  360. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  362. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  363. if !m.op.Is(OpUpdateOne) {
  364. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  365. }
  366. if m.id == nil || m.oldValue == nil {
  367. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  368. }
  369. oldValue, err := m.oldValue(ctx)
  370. if err != nil {
  371. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  372. }
  373. return oldValue.WxWxid, nil
  374. }
  375. // ClearWxWxid clears the value of the "wx_wxid" field.
  376. func (m *ContactMutation) ClearWxWxid() {
  377. m.wx_wxid = nil
  378. m.clearedFields[contact.FieldWxWxid] = struct{}{}
  379. }
  380. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  381. func (m *ContactMutation) WxWxidCleared() bool {
  382. _, ok := m.clearedFields[contact.FieldWxWxid]
  383. return ok
  384. }
  385. // ResetWxWxid resets all changes to the "wx_wxid" field.
  386. func (m *ContactMutation) ResetWxWxid() {
  387. m.wx_wxid = nil
  388. delete(m.clearedFields, contact.FieldWxWxid)
  389. }
  390. // SetType sets the "type" field.
  391. func (m *ContactMutation) SetType(i int) {
  392. m._type = &i
  393. m.add_type = nil
  394. }
  395. // GetType returns the value of the "type" field in the mutation.
  396. func (m *ContactMutation) GetType() (r int, exists bool) {
  397. v := m._type
  398. if v == nil {
  399. return
  400. }
  401. return *v, true
  402. }
  403. // OldType returns the old "type" field's value of the Contact entity.
  404. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  405. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  406. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  407. if !m.op.Is(OpUpdateOne) {
  408. return v, errors.New("OldType is only allowed on UpdateOne operations")
  409. }
  410. if m.id == nil || m.oldValue == nil {
  411. return v, errors.New("OldType requires an ID field in the mutation")
  412. }
  413. oldValue, err := m.oldValue(ctx)
  414. if err != nil {
  415. return v, fmt.Errorf("querying old value for OldType: %w", err)
  416. }
  417. return oldValue.Type, nil
  418. }
  419. // AddType adds i to the "type" field.
  420. func (m *ContactMutation) AddType(i int) {
  421. if m.add_type != nil {
  422. *m.add_type += i
  423. } else {
  424. m.add_type = &i
  425. }
  426. }
  427. // AddedType returns the value that was added to the "type" field in this mutation.
  428. func (m *ContactMutation) AddedType() (r int, exists bool) {
  429. v := m.add_type
  430. if v == nil {
  431. return
  432. }
  433. return *v, true
  434. }
  435. // ClearType clears the value of the "type" field.
  436. func (m *ContactMutation) ClearType() {
  437. m._type = nil
  438. m.add_type = nil
  439. m.clearedFields[contact.FieldType] = struct{}{}
  440. }
  441. // TypeCleared returns if the "type" field was cleared in this mutation.
  442. func (m *ContactMutation) TypeCleared() bool {
  443. _, ok := m.clearedFields[contact.FieldType]
  444. return ok
  445. }
  446. // ResetType resets all changes to the "type" field.
  447. func (m *ContactMutation) ResetType() {
  448. m._type = nil
  449. m.add_type = nil
  450. delete(m.clearedFields, contact.FieldType)
  451. }
  452. // SetWxid sets the "wxid" field.
  453. func (m *ContactMutation) SetWxid(s string) {
  454. m.wxid = &s
  455. }
  456. // Wxid returns the value of the "wxid" field in the mutation.
  457. func (m *ContactMutation) Wxid() (r string, exists bool) {
  458. v := m.wxid
  459. if v == nil {
  460. return
  461. }
  462. return *v, true
  463. }
  464. // OldWxid returns the old "wxid" field's value of the Contact entity.
  465. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  466. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  467. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  468. if !m.op.Is(OpUpdateOne) {
  469. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  470. }
  471. if m.id == nil || m.oldValue == nil {
  472. return v, errors.New("OldWxid requires an ID field in the mutation")
  473. }
  474. oldValue, err := m.oldValue(ctx)
  475. if err != nil {
  476. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  477. }
  478. return oldValue.Wxid, nil
  479. }
  480. // ResetWxid resets all changes to the "wxid" field.
  481. func (m *ContactMutation) ResetWxid() {
  482. m.wxid = nil
  483. }
  484. // SetAccount sets the "account" field.
  485. func (m *ContactMutation) SetAccount(s string) {
  486. m.account = &s
  487. }
  488. // Account returns the value of the "account" field in the mutation.
  489. func (m *ContactMutation) Account() (r string, exists bool) {
  490. v := m.account
  491. if v == nil {
  492. return
  493. }
  494. return *v, true
  495. }
  496. // OldAccount returns the old "account" field's value of the Contact entity.
  497. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  498. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  499. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  500. if !m.op.Is(OpUpdateOne) {
  501. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  502. }
  503. if m.id == nil || m.oldValue == nil {
  504. return v, errors.New("OldAccount requires an ID field in the mutation")
  505. }
  506. oldValue, err := m.oldValue(ctx)
  507. if err != nil {
  508. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  509. }
  510. return oldValue.Account, nil
  511. }
  512. // ResetAccount resets all changes to the "account" field.
  513. func (m *ContactMutation) ResetAccount() {
  514. m.account = nil
  515. }
  516. // SetNickname sets the "nickname" field.
  517. func (m *ContactMutation) SetNickname(s string) {
  518. m.nickname = &s
  519. }
  520. // Nickname returns the value of the "nickname" field in the mutation.
  521. func (m *ContactMutation) Nickname() (r string, exists bool) {
  522. v := m.nickname
  523. if v == nil {
  524. return
  525. }
  526. return *v, true
  527. }
  528. // OldNickname returns the old "nickname" field's value of the Contact entity.
  529. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  530. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  531. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  532. if !m.op.Is(OpUpdateOne) {
  533. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  534. }
  535. if m.id == nil || m.oldValue == nil {
  536. return v, errors.New("OldNickname requires an ID field in the mutation")
  537. }
  538. oldValue, err := m.oldValue(ctx)
  539. if err != nil {
  540. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  541. }
  542. return oldValue.Nickname, nil
  543. }
  544. // ResetNickname resets all changes to the "nickname" field.
  545. func (m *ContactMutation) ResetNickname() {
  546. m.nickname = nil
  547. }
  548. // SetMarkname sets the "markname" field.
  549. func (m *ContactMutation) SetMarkname(s string) {
  550. m.markname = &s
  551. }
  552. // Markname returns the value of the "markname" field in the mutation.
  553. func (m *ContactMutation) Markname() (r string, exists bool) {
  554. v := m.markname
  555. if v == nil {
  556. return
  557. }
  558. return *v, true
  559. }
  560. // OldMarkname returns the old "markname" field's value of the Contact entity.
  561. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  562. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  563. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  564. if !m.op.Is(OpUpdateOne) {
  565. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  566. }
  567. if m.id == nil || m.oldValue == nil {
  568. return v, errors.New("OldMarkname requires an ID field in the mutation")
  569. }
  570. oldValue, err := m.oldValue(ctx)
  571. if err != nil {
  572. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  573. }
  574. return oldValue.Markname, nil
  575. }
  576. // ResetMarkname resets all changes to the "markname" field.
  577. func (m *ContactMutation) ResetMarkname() {
  578. m.markname = nil
  579. }
  580. // SetHeadimg sets the "headimg" field.
  581. func (m *ContactMutation) SetHeadimg(s string) {
  582. m.headimg = &s
  583. }
  584. // Headimg returns the value of the "headimg" field in the mutation.
  585. func (m *ContactMutation) Headimg() (r string, exists bool) {
  586. v := m.headimg
  587. if v == nil {
  588. return
  589. }
  590. return *v, true
  591. }
  592. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  593. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  594. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  595. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  596. if !m.op.Is(OpUpdateOne) {
  597. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  598. }
  599. if m.id == nil || m.oldValue == nil {
  600. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  601. }
  602. oldValue, err := m.oldValue(ctx)
  603. if err != nil {
  604. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  605. }
  606. return oldValue.Headimg, nil
  607. }
  608. // ResetHeadimg resets all changes to the "headimg" field.
  609. func (m *ContactMutation) ResetHeadimg() {
  610. m.headimg = nil
  611. }
  612. // SetSex sets the "sex" field.
  613. func (m *ContactMutation) SetSex(i int) {
  614. m.sex = &i
  615. m.addsex = nil
  616. }
  617. // Sex returns the value of the "sex" field in the mutation.
  618. func (m *ContactMutation) Sex() (r int, exists bool) {
  619. v := m.sex
  620. if v == nil {
  621. return
  622. }
  623. return *v, true
  624. }
  625. // OldSex returns the old "sex" field's value of the Contact entity.
  626. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  627. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  628. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  629. if !m.op.Is(OpUpdateOne) {
  630. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  631. }
  632. if m.id == nil || m.oldValue == nil {
  633. return v, errors.New("OldSex requires an ID field in the mutation")
  634. }
  635. oldValue, err := m.oldValue(ctx)
  636. if err != nil {
  637. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  638. }
  639. return oldValue.Sex, nil
  640. }
  641. // AddSex adds i to the "sex" field.
  642. func (m *ContactMutation) AddSex(i int) {
  643. if m.addsex != nil {
  644. *m.addsex += i
  645. } else {
  646. m.addsex = &i
  647. }
  648. }
  649. // AddedSex returns the value that was added to the "sex" field in this mutation.
  650. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  651. v := m.addsex
  652. if v == nil {
  653. return
  654. }
  655. return *v, true
  656. }
  657. // ResetSex resets all changes to the "sex" field.
  658. func (m *ContactMutation) ResetSex() {
  659. m.sex = nil
  660. m.addsex = nil
  661. }
  662. // SetStarrole sets the "starrole" field.
  663. func (m *ContactMutation) SetStarrole(s string) {
  664. m.starrole = &s
  665. }
  666. // Starrole returns the value of the "starrole" field in the mutation.
  667. func (m *ContactMutation) Starrole() (r string, exists bool) {
  668. v := m.starrole
  669. if v == nil {
  670. return
  671. }
  672. return *v, true
  673. }
  674. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  675. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  677. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  678. if !m.op.Is(OpUpdateOne) {
  679. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  680. }
  681. if m.id == nil || m.oldValue == nil {
  682. return v, errors.New("OldStarrole requires an ID field in the mutation")
  683. }
  684. oldValue, err := m.oldValue(ctx)
  685. if err != nil {
  686. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  687. }
  688. return oldValue.Starrole, nil
  689. }
  690. // ResetStarrole resets all changes to the "starrole" field.
  691. func (m *ContactMutation) ResetStarrole() {
  692. m.starrole = nil
  693. }
  694. // SetDontseeit sets the "dontseeit" field.
  695. func (m *ContactMutation) SetDontseeit(i int) {
  696. m.dontseeit = &i
  697. m.adddontseeit = nil
  698. }
  699. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  700. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  701. v := m.dontseeit
  702. if v == nil {
  703. return
  704. }
  705. return *v, true
  706. }
  707. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  708. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  709. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  710. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  711. if !m.op.Is(OpUpdateOne) {
  712. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  713. }
  714. if m.id == nil || m.oldValue == nil {
  715. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  716. }
  717. oldValue, err := m.oldValue(ctx)
  718. if err != nil {
  719. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  720. }
  721. return oldValue.Dontseeit, nil
  722. }
  723. // AddDontseeit adds i to the "dontseeit" field.
  724. func (m *ContactMutation) AddDontseeit(i int) {
  725. if m.adddontseeit != nil {
  726. *m.adddontseeit += i
  727. } else {
  728. m.adddontseeit = &i
  729. }
  730. }
  731. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  732. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  733. v := m.adddontseeit
  734. if v == nil {
  735. return
  736. }
  737. return *v, true
  738. }
  739. // ResetDontseeit resets all changes to the "dontseeit" field.
  740. func (m *ContactMutation) ResetDontseeit() {
  741. m.dontseeit = nil
  742. m.adddontseeit = nil
  743. }
  744. // SetDontseeme sets the "dontseeme" field.
  745. func (m *ContactMutation) SetDontseeme(i int) {
  746. m.dontseeme = &i
  747. m.adddontseeme = nil
  748. }
  749. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  750. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  751. v := m.dontseeme
  752. if v == nil {
  753. return
  754. }
  755. return *v, true
  756. }
  757. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  758. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  759. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  760. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  761. if !m.op.Is(OpUpdateOne) {
  762. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  763. }
  764. if m.id == nil || m.oldValue == nil {
  765. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  766. }
  767. oldValue, err := m.oldValue(ctx)
  768. if err != nil {
  769. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  770. }
  771. return oldValue.Dontseeme, nil
  772. }
  773. // AddDontseeme adds i to the "dontseeme" field.
  774. func (m *ContactMutation) AddDontseeme(i int) {
  775. if m.adddontseeme != nil {
  776. *m.adddontseeme += i
  777. } else {
  778. m.adddontseeme = &i
  779. }
  780. }
  781. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  782. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  783. v := m.adddontseeme
  784. if v == nil {
  785. return
  786. }
  787. return *v, true
  788. }
  789. // ResetDontseeme resets all changes to the "dontseeme" field.
  790. func (m *ContactMutation) ResetDontseeme() {
  791. m.dontseeme = nil
  792. m.adddontseeme = nil
  793. }
  794. // SetLag sets the "lag" field.
  795. func (m *ContactMutation) SetLag(s string) {
  796. m.lag = &s
  797. }
  798. // Lag returns the value of the "lag" field in the mutation.
  799. func (m *ContactMutation) Lag() (r string, exists bool) {
  800. v := m.lag
  801. if v == nil {
  802. return
  803. }
  804. return *v, true
  805. }
  806. // OldLag returns the old "lag" field's value of the Contact entity.
  807. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  808. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  809. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  810. if !m.op.Is(OpUpdateOne) {
  811. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  812. }
  813. if m.id == nil || m.oldValue == nil {
  814. return v, errors.New("OldLag requires an ID field in the mutation")
  815. }
  816. oldValue, err := m.oldValue(ctx)
  817. if err != nil {
  818. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  819. }
  820. return oldValue.Lag, nil
  821. }
  822. // ResetLag resets all changes to the "lag" field.
  823. func (m *ContactMutation) ResetLag() {
  824. m.lag = nil
  825. }
  826. // SetGid sets the "gid" field.
  827. func (m *ContactMutation) SetGid(s string) {
  828. m.gid = &s
  829. }
  830. // Gid returns the value of the "gid" field in the mutation.
  831. func (m *ContactMutation) Gid() (r string, exists bool) {
  832. v := m.gid
  833. if v == nil {
  834. return
  835. }
  836. return *v, true
  837. }
  838. // OldGid returns the old "gid" field's value of the Contact entity.
  839. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  840. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  841. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  842. if !m.op.Is(OpUpdateOne) {
  843. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  844. }
  845. if m.id == nil || m.oldValue == nil {
  846. return v, errors.New("OldGid requires an ID field in the mutation")
  847. }
  848. oldValue, err := m.oldValue(ctx)
  849. if err != nil {
  850. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  851. }
  852. return oldValue.Gid, nil
  853. }
  854. // ResetGid resets all changes to the "gid" field.
  855. func (m *ContactMutation) ResetGid() {
  856. m.gid = nil
  857. }
  858. // SetGname sets the "gname" field.
  859. func (m *ContactMutation) SetGname(s string) {
  860. m.gname = &s
  861. }
  862. // Gname returns the value of the "gname" field in the mutation.
  863. func (m *ContactMutation) Gname() (r string, exists bool) {
  864. v := m.gname
  865. if v == nil {
  866. return
  867. }
  868. return *v, true
  869. }
  870. // OldGname returns the old "gname" field's value of the Contact entity.
  871. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  872. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  873. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  874. if !m.op.Is(OpUpdateOne) {
  875. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  876. }
  877. if m.id == nil || m.oldValue == nil {
  878. return v, errors.New("OldGname requires an ID field in the mutation")
  879. }
  880. oldValue, err := m.oldValue(ctx)
  881. if err != nil {
  882. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  883. }
  884. return oldValue.Gname, nil
  885. }
  886. // ResetGname resets all changes to the "gname" field.
  887. func (m *ContactMutation) ResetGname() {
  888. m.gname = nil
  889. }
  890. // SetV3 sets the "v3" field.
  891. func (m *ContactMutation) SetV3(s string) {
  892. m.v3 = &s
  893. }
  894. // V3 returns the value of the "v3" field in the mutation.
  895. func (m *ContactMutation) V3() (r string, exists bool) {
  896. v := m.v3
  897. if v == nil {
  898. return
  899. }
  900. return *v, true
  901. }
  902. // OldV3 returns the old "v3" field's value of the Contact entity.
  903. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  904. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  905. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  906. if !m.op.Is(OpUpdateOne) {
  907. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  908. }
  909. if m.id == nil || m.oldValue == nil {
  910. return v, errors.New("OldV3 requires an ID field in the mutation")
  911. }
  912. oldValue, err := m.oldValue(ctx)
  913. if err != nil {
  914. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  915. }
  916. return oldValue.V3, nil
  917. }
  918. // ResetV3 resets all changes to the "v3" field.
  919. func (m *ContactMutation) ResetV3() {
  920. m.v3 = nil
  921. }
  922. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  923. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  924. if m.contact_relationships == nil {
  925. m.contact_relationships = make(map[uint64]struct{})
  926. }
  927. for i := range ids {
  928. m.contact_relationships[ids[i]] = struct{}{}
  929. }
  930. }
  931. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  932. func (m *ContactMutation) ClearContactRelationships() {
  933. m.clearedcontact_relationships = true
  934. }
  935. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  936. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  937. return m.clearedcontact_relationships
  938. }
  939. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  940. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  941. if m.removedcontact_relationships == nil {
  942. m.removedcontact_relationships = make(map[uint64]struct{})
  943. }
  944. for i := range ids {
  945. delete(m.contact_relationships, ids[i])
  946. m.removedcontact_relationships[ids[i]] = struct{}{}
  947. }
  948. }
  949. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  950. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  951. for id := range m.removedcontact_relationships {
  952. ids = append(ids, id)
  953. }
  954. return
  955. }
  956. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  957. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  958. for id := range m.contact_relationships {
  959. ids = append(ids, id)
  960. }
  961. return
  962. }
  963. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  964. func (m *ContactMutation) ResetContactRelationships() {
  965. m.contact_relationships = nil
  966. m.clearedcontact_relationships = false
  967. m.removedcontact_relationships = nil
  968. }
  969. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  970. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  971. if m.contact_messages == nil {
  972. m.contact_messages = make(map[uint64]struct{})
  973. }
  974. for i := range ids {
  975. m.contact_messages[ids[i]] = struct{}{}
  976. }
  977. }
  978. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  979. func (m *ContactMutation) ClearContactMessages() {
  980. m.clearedcontact_messages = true
  981. }
  982. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  983. func (m *ContactMutation) ContactMessagesCleared() bool {
  984. return m.clearedcontact_messages
  985. }
  986. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  987. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  988. if m.removedcontact_messages == nil {
  989. m.removedcontact_messages = make(map[uint64]struct{})
  990. }
  991. for i := range ids {
  992. delete(m.contact_messages, ids[i])
  993. m.removedcontact_messages[ids[i]] = struct{}{}
  994. }
  995. }
  996. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  997. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  998. for id := range m.removedcontact_messages {
  999. ids = append(ids, id)
  1000. }
  1001. return
  1002. }
  1003. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  1004. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  1005. for id := range m.contact_messages {
  1006. ids = append(ids, id)
  1007. }
  1008. return
  1009. }
  1010. // ResetContactMessages resets all changes to the "contact_messages" edge.
  1011. func (m *ContactMutation) ResetContactMessages() {
  1012. m.contact_messages = nil
  1013. m.clearedcontact_messages = false
  1014. m.removedcontact_messages = nil
  1015. }
  1016. // Where appends a list predicates to the ContactMutation builder.
  1017. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  1018. m.predicates = append(m.predicates, ps...)
  1019. }
  1020. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  1021. // users can use type-assertion to append predicates that do not depend on any generated package.
  1022. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  1023. p := make([]predicate.Contact, len(ps))
  1024. for i := range ps {
  1025. p[i] = ps[i]
  1026. }
  1027. m.Where(p...)
  1028. }
  1029. // Op returns the operation name.
  1030. func (m *ContactMutation) Op() Op {
  1031. return m.op
  1032. }
  1033. // SetOp allows setting the mutation operation.
  1034. func (m *ContactMutation) SetOp(op Op) {
  1035. m.op = op
  1036. }
  1037. // Type returns the node type of this mutation (Contact).
  1038. func (m *ContactMutation) Type() string {
  1039. return m.typ
  1040. }
  1041. // Fields returns all fields that were changed during this mutation. Note that in
  1042. // order to get all numeric fields that were incremented/decremented, call
  1043. // AddedFields().
  1044. func (m *ContactMutation) Fields() []string {
  1045. fields := make([]string, 0, 19)
  1046. if m.created_at != nil {
  1047. fields = append(fields, contact.FieldCreatedAt)
  1048. }
  1049. if m.updated_at != nil {
  1050. fields = append(fields, contact.FieldUpdatedAt)
  1051. }
  1052. if m.status != nil {
  1053. fields = append(fields, contact.FieldStatus)
  1054. }
  1055. if m.deleted_at != nil {
  1056. fields = append(fields, contact.FieldDeletedAt)
  1057. }
  1058. if m.wx_wxid != nil {
  1059. fields = append(fields, contact.FieldWxWxid)
  1060. }
  1061. if m._type != nil {
  1062. fields = append(fields, contact.FieldType)
  1063. }
  1064. if m.wxid != nil {
  1065. fields = append(fields, contact.FieldWxid)
  1066. }
  1067. if m.account != nil {
  1068. fields = append(fields, contact.FieldAccount)
  1069. }
  1070. if m.nickname != nil {
  1071. fields = append(fields, contact.FieldNickname)
  1072. }
  1073. if m.markname != nil {
  1074. fields = append(fields, contact.FieldMarkname)
  1075. }
  1076. if m.headimg != nil {
  1077. fields = append(fields, contact.FieldHeadimg)
  1078. }
  1079. if m.sex != nil {
  1080. fields = append(fields, contact.FieldSex)
  1081. }
  1082. if m.starrole != nil {
  1083. fields = append(fields, contact.FieldStarrole)
  1084. }
  1085. if m.dontseeit != nil {
  1086. fields = append(fields, contact.FieldDontseeit)
  1087. }
  1088. if m.dontseeme != nil {
  1089. fields = append(fields, contact.FieldDontseeme)
  1090. }
  1091. if m.lag != nil {
  1092. fields = append(fields, contact.FieldLag)
  1093. }
  1094. if m.gid != nil {
  1095. fields = append(fields, contact.FieldGid)
  1096. }
  1097. if m.gname != nil {
  1098. fields = append(fields, contact.FieldGname)
  1099. }
  1100. if m.v3 != nil {
  1101. fields = append(fields, contact.FieldV3)
  1102. }
  1103. return fields
  1104. }
  1105. // Field returns the value of a field with the given name. The second boolean
  1106. // return value indicates that this field was not set, or was not defined in the
  1107. // schema.
  1108. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  1109. switch name {
  1110. case contact.FieldCreatedAt:
  1111. return m.CreatedAt()
  1112. case contact.FieldUpdatedAt:
  1113. return m.UpdatedAt()
  1114. case contact.FieldStatus:
  1115. return m.Status()
  1116. case contact.FieldDeletedAt:
  1117. return m.DeletedAt()
  1118. case contact.FieldWxWxid:
  1119. return m.WxWxid()
  1120. case contact.FieldType:
  1121. return m.GetType()
  1122. case contact.FieldWxid:
  1123. return m.Wxid()
  1124. case contact.FieldAccount:
  1125. return m.Account()
  1126. case contact.FieldNickname:
  1127. return m.Nickname()
  1128. case contact.FieldMarkname:
  1129. return m.Markname()
  1130. case contact.FieldHeadimg:
  1131. return m.Headimg()
  1132. case contact.FieldSex:
  1133. return m.Sex()
  1134. case contact.FieldStarrole:
  1135. return m.Starrole()
  1136. case contact.FieldDontseeit:
  1137. return m.Dontseeit()
  1138. case contact.FieldDontseeme:
  1139. return m.Dontseeme()
  1140. case contact.FieldLag:
  1141. return m.Lag()
  1142. case contact.FieldGid:
  1143. return m.Gid()
  1144. case contact.FieldGname:
  1145. return m.Gname()
  1146. case contact.FieldV3:
  1147. return m.V3()
  1148. }
  1149. return nil, false
  1150. }
  1151. // OldField returns the old value of the field from the database. An error is
  1152. // returned if the mutation operation is not UpdateOne, or the query to the
  1153. // database failed.
  1154. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1155. switch name {
  1156. case contact.FieldCreatedAt:
  1157. return m.OldCreatedAt(ctx)
  1158. case contact.FieldUpdatedAt:
  1159. return m.OldUpdatedAt(ctx)
  1160. case contact.FieldStatus:
  1161. return m.OldStatus(ctx)
  1162. case contact.FieldDeletedAt:
  1163. return m.OldDeletedAt(ctx)
  1164. case contact.FieldWxWxid:
  1165. return m.OldWxWxid(ctx)
  1166. case contact.FieldType:
  1167. return m.OldType(ctx)
  1168. case contact.FieldWxid:
  1169. return m.OldWxid(ctx)
  1170. case contact.FieldAccount:
  1171. return m.OldAccount(ctx)
  1172. case contact.FieldNickname:
  1173. return m.OldNickname(ctx)
  1174. case contact.FieldMarkname:
  1175. return m.OldMarkname(ctx)
  1176. case contact.FieldHeadimg:
  1177. return m.OldHeadimg(ctx)
  1178. case contact.FieldSex:
  1179. return m.OldSex(ctx)
  1180. case contact.FieldStarrole:
  1181. return m.OldStarrole(ctx)
  1182. case contact.FieldDontseeit:
  1183. return m.OldDontseeit(ctx)
  1184. case contact.FieldDontseeme:
  1185. return m.OldDontseeme(ctx)
  1186. case contact.FieldLag:
  1187. return m.OldLag(ctx)
  1188. case contact.FieldGid:
  1189. return m.OldGid(ctx)
  1190. case contact.FieldGname:
  1191. return m.OldGname(ctx)
  1192. case contact.FieldV3:
  1193. return m.OldV3(ctx)
  1194. }
  1195. return nil, fmt.Errorf("unknown Contact field %s", name)
  1196. }
  1197. // SetField sets the value of a field with the given name. It returns an error if
  1198. // the field is not defined in the schema, or if the type mismatched the field
  1199. // type.
  1200. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  1201. switch name {
  1202. case contact.FieldCreatedAt:
  1203. v, ok := value.(time.Time)
  1204. if !ok {
  1205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1206. }
  1207. m.SetCreatedAt(v)
  1208. return nil
  1209. case contact.FieldUpdatedAt:
  1210. v, ok := value.(time.Time)
  1211. if !ok {
  1212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1213. }
  1214. m.SetUpdatedAt(v)
  1215. return nil
  1216. case contact.FieldStatus:
  1217. v, ok := value.(uint8)
  1218. if !ok {
  1219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1220. }
  1221. m.SetStatus(v)
  1222. return nil
  1223. case contact.FieldDeletedAt:
  1224. v, ok := value.(time.Time)
  1225. if !ok {
  1226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1227. }
  1228. m.SetDeletedAt(v)
  1229. return nil
  1230. case contact.FieldWxWxid:
  1231. v, ok := value.(string)
  1232. if !ok {
  1233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1234. }
  1235. m.SetWxWxid(v)
  1236. return nil
  1237. case contact.FieldType:
  1238. v, ok := value.(int)
  1239. if !ok {
  1240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1241. }
  1242. m.SetType(v)
  1243. return nil
  1244. case contact.FieldWxid:
  1245. v, ok := value.(string)
  1246. if !ok {
  1247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1248. }
  1249. m.SetWxid(v)
  1250. return nil
  1251. case contact.FieldAccount:
  1252. v, ok := value.(string)
  1253. if !ok {
  1254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1255. }
  1256. m.SetAccount(v)
  1257. return nil
  1258. case contact.FieldNickname:
  1259. v, ok := value.(string)
  1260. if !ok {
  1261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1262. }
  1263. m.SetNickname(v)
  1264. return nil
  1265. case contact.FieldMarkname:
  1266. v, ok := value.(string)
  1267. if !ok {
  1268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1269. }
  1270. m.SetMarkname(v)
  1271. return nil
  1272. case contact.FieldHeadimg:
  1273. v, ok := value.(string)
  1274. if !ok {
  1275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1276. }
  1277. m.SetHeadimg(v)
  1278. return nil
  1279. case contact.FieldSex:
  1280. v, ok := value.(int)
  1281. if !ok {
  1282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1283. }
  1284. m.SetSex(v)
  1285. return nil
  1286. case contact.FieldStarrole:
  1287. v, ok := value.(string)
  1288. if !ok {
  1289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1290. }
  1291. m.SetStarrole(v)
  1292. return nil
  1293. case contact.FieldDontseeit:
  1294. v, ok := value.(int)
  1295. if !ok {
  1296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1297. }
  1298. m.SetDontseeit(v)
  1299. return nil
  1300. case contact.FieldDontseeme:
  1301. v, ok := value.(int)
  1302. if !ok {
  1303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1304. }
  1305. m.SetDontseeme(v)
  1306. return nil
  1307. case contact.FieldLag:
  1308. v, ok := value.(string)
  1309. if !ok {
  1310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1311. }
  1312. m.SetLag(v)
  1313. return nil
  1314. case contact.FieldGid:
  1315. v, ok := value.(string)
  1316. if !ok {
  1317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1318. }
  1319. m.SetGid(v)
  1320. return nil
  1321. case contact.FieldGname:
  1322. v, ok := value.(string)
  1323. if !ok {
  1324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1325. }
  1326. m.SetGname(v)
  1327. return nil
  1328. case contact.FieldV3:
  1329. v, ok := value.(string)
  1330. if !ok {
  1331. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1332. }
  1333. m.SetV3(v)
  1334. return nil
  1335. }
  1336. return fmt.Errorf("unknown Contact field %s", name)
  1337. }
  1338. // AddedFields returns all numeric fields that were incremented/decremented during
  1339. // this mutation.
  1340. func (m *ContactMutation) AddedFields() []string {
  1341. var fields []string
  1342. if m.addstatus != nil {
  1343. fields = append(fields, contact.FieldStatus)
  1344. }
  1345. if m.add_type != nil {
  1346. fields = append(fields, contact.FieldType)
  1347. }
  1348. if m.addsex != nil {
  1349. fields = append(fields, contact.FieldSex)
  1350. }
  1351. if m.adddontseeit != nil {
  1352. fields = append(fields, contact.FieldDontseeit)
  1353. }
  1354. if m.adddontseeme != nil {
  1355. fields = append(fields, contact.FieldDontseeme)
  1356. }
  1357. return fields
  1358. }
  1359. // AddedField returns the numeric value that was incremented/decremented on a field
  1360. // with the given name. The second boolean return value indicates that this field
  1361. // was not set, or was not defined in the schema.
  1362. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  1363. switch name {
  1364. case contact.FieldStatus:
  1365. return m.AddedStatus()
  1366. case contact.FieldType:
  1367. return m.AddedType()
  1368. case contact.FieldSex:
  1369. return m.AddedSex()
  1370. case contact.FieldDontseeit:
  1371. return m.AddedDontseeit()
  1372. case contact.FieldDontseeme:
  1373. return m.AddedDontseeme()
  1374. }
  1375. return nil, false
  1376. }
  1377. // AddField adds the value to the field with the given name. It returns an error if
  1378. // the field is not defined in the schema, or if the type mismatched the field
  1379. // type.
  1380. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  1381. switch name {
  1382. case contact.FieldStatus:
  1383. v, ok := value.(int8)
  1384. if !ok {
  1385. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1386. }
  1387. m.AddStatus(v)
  1388. return nil
  1389. case contact.FieldType:
  1390. v, ok := value.(int)
  1391. if !ok {
  1392. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1393. }
  1394. m.AddType(v)
  1395. return nil
  1396. case contact.FieldSex:
  1397. v, ok := value.(int)
  1398. if !ok {
  1399. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1400. }
  1401. m.AddSex(v)
  1402. return nil
  1403. case contact.FieldDontseeit:
  1404. v, ok := value.(int)
  1405. if !ok {
  1406. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1407. }
  1408. m.AddDontseeit(v)
  1409. return nil
  1410. case contact.FieldDontseeme:
  1411. v, ok := value.(int)
  1412. if !ok {
  1413. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1414. }
  1415. m.AddDontseeme(v)
  1416. return nil
  1417. }
  1418. return fmt.Errorf("unknown Contact numeric field %s", name)
  1419. }
  1420. // ClearedFields returns all nullable fields that were cleared during this
  1421. // mutation.
  1422. func (m *ContactMutation) ClearedFields() []string {
  1423. var fields []string
  1424. if m.FieldCleared(contact.FieldStatus) {
  1425. fields = append(fields, contact.FieldStatus)
  1426. }
  1427. if m.FieldCleared(contact.FieldDeletedAt) {
  1428. fields = append(fields, contact.FieldDeletedAt)
  1429. }
  1430. if m.FieldCleared(contact.FieldWxWxid) {
  1431. fields = append(fields, contact.FieldWxWxid)
  1432. }
  1433. if m.FieldCleared(contact.FieldType) {
  1434. fields = append(fields, contact.FieldType)
  1435. }
  1436. return fields
  1437. }
  1438. // FieldCleared returns a boolean indicating if a field with the given name was
  1439. // cleared in this mutation.
  1440. func (m *ContactMutation) FieldCleared(name string) bool {
  1441. _, ok := m.clearedFields[name]
  1442. return ok
  1443. }
  1444. // ClearField clears the value of the field with the given name. It returns an
  1445. // error if the field is not defined in the schema.
  1446. func (m *ContactMutation) ClearField(name string) error {
  1447. switch name {
  1448. case contact.FieldStatus:
  1449. m.ClearStatus()
  1450. return nil
  1451. case contact.FieldDeletedAt:
  1452. m.ClearDeletedAt()
  1453. return nil
  1454. case contact.FieldWxWxid:
  1455. m.ClearWxWxid()
  1456. return nil
  1457. case contact.FieldType:
  1458. m.ClearType()
  1459. return nil
  1460. }
  1461. return fmt.Errorf("unknown Contact nullable field %s", name)
  1462. }
  1463. // ResetField resets all changes in the mutation for the field with the given name.
  1464. // It returns an error if the field is not defined in the schema.
  1465. func (m *ContactMutation) ResetField(name string) error {
  1466. switch name {
  1467. case contact.FieldCreatedAt:
  1468. m.ResetCreatedAt()
  1469. return nil
  1470. case contact.FieldUpdatedAt:
  1471. m.ResetUpdatedAt()
  1472. return nil
  1473. case contact.FieldStatus:
  1474. m.ResetStatus()
  1475. return nil
  1476. case contact.FieldDeletedAt:
  1477. m.ResetDeletedAt()
  1478. return nil
  1479. case contact.FieldWxWxid:
  1480. m.ResetWxWxid()
  1481. return nil
  1482. case contact.FieldType:
  1483. m.ResetType()
  1484. return nil
  1485. case contact.FieldWxid:
  1486. m.ResetWxid()
  1487. return nil
  1488. case contact.FieldAccount:
  1489. m.ResetAccount()
  1490. return nil
  1491. case contact.FieldNickname:
  1492. m.ResetNickname()
  1493. return nil
  1494. case contact.FieldMarkname:
  1495. m.ResetMarkname()
  1496. return nil
  1497. case contact.FieldHeadimg:
  1498. m.ResetHeadimg()
  1499. return nil
  1500. case contact.FieldSex:
  1501. m.ResetSex()
  1502. return nil
  1503. case contact.FieldStarrole:
  1504. m.ResetStarrole()
  1505. return nil
  1506. case contact.FieldDontseeit:
  1507. m.ResetDontseeit()
  1508. return nil
  1509. case contact.FieldDontseeme:
  1510. m.ResetDontseeme()
  1511. return nil
  1512. case contact.FieldLag:
  1513. m.ResetLag()
  1514. return nil
  1515. case contact.FieldGid:
  1516. m.ResetGid()
  1517. return nil
  1518. case contact.FieldGname:
  1519. m.ResetGname()
  1520. return nil
  1521. case contact.FieldV3:
  1522. m.ResetV3()
  1523. return nil
  1524. }
  1525. return fmt.Errorf("unknown Contact field %s", name)
  1526. }
  1527. // AddedEdges returns all edge names that were set/added in this mutation.
  1528. func (m *ContactMutation) AddedEdges() []string {
  1529. edges := make([]string, 0, 2)
  1530. if m.contact_relationships != nil {
  1531. edges = append(edges, contact.EdgeContactRelationships)
  1532. }
  1533. if m.contact_messages != nil {
  1534. edges = append(edges, contact.EdgeContactMessages)
  1535. }
  1536. return edges
  1537. }
  1538. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1539. // name in this mutation.
  1540. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  1541. switch name {
  1542. case contact.EdgeContactRelationships:
  1543. ids := make([]ent.Value, 0, len(m.contact_relationships))
  1544. for id := range m.contact_relationships {
  1545. ids = append(ids, id)
  1546. }
  1547. return ids
  1548. case contact.EdgeContactMessages:
  1549. ids := make([]ent.Value, 0, len(m.contact_messages))
  1550. for id := range m.contact_messages {
  1551. ids = append(ids, id)
  1552. }
  1553. return ids
  1554. }
  1555. return nil
  1556. }
  1557. // RemovedEdges returns all edge names that were removed in this mutation.
  1558. func (m *ContactMutation) RemovedEdges() []string {
  1559. edges := make([]string, 0, 2)
  1560. if m.removedcontact_relationships != nil {
  1561. edges = append(edges, contact.EdgeContactRelationships)
  1562. }
  1563. if m.removedcontact_messages != nil {
  1564. edges = append(edges, contact.EdgeContactMessages)
  1565. }
  1566. return edges
  1567. }
  1568. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1569. // the given name in this mutation.
  1570. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  1571. switch name {
  1572. case contact.EdgeContactRelationships:
  1573. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  1574. for id := range m.removedcontact_relationships {
  1575. ids = append(ids, id)
  1576. }
  1577. return ids
  1578. case contact.EdgeContactMessages:
  1579. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  1580. for id := range m.removedcontact_messages {
  1581. ids = append(ids, id)
  1582. }
  1583. return ids
  1584. }
  1585. return nil
  1586. }
  1587. // ClearedEdges returns all edge names that were cleared in this mutation.
  1588. func (m *ContactMutation) ClearedEdges() []string {
  1589. edges := make([]string, 0, 2)
  1590. if m.clearedcontact_relationships {
  1591. edges = append(edges, contact.EdgeContactRelationships)
  1592. }
  1593. if m.clearedcontact_messages {
  1594. edges = append(edges, contact.EdgeContactMessages)
  1595. }
  1596. return edges
  1597. }
  1598. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1599. // was cleared in this mutation.
  1600. func (m *ContactMutation) EdgeCleared(name string) bool {
  1601. switch name {
  1602. case contact.EdgeContactRelationships:
  1603. return m.clearedcontact_relationships
  1604. case contact.EdgeContactMessages:
  1605. return m.clearedcontact_messages
  1606. }
  1607. return false
  1608. }
  1609. // ClearEdge clears the value of the edge with the given name. It returns an error
  1610. // if that edge is not defined in the schema.
  1611. func (m *ContactMutation) ClearEdge(name string) error {
  1612. switch name {
  1613. }
  1614. return fmt.Errorf("unknown Contact unique edge %s", name)
  1615. }
  1616. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1617. // It returns an error if the edge is not defined in the schema.
  1618. func (m *ContactMutation) ResetEdge(name string) error {
  1619. switch name {
  1620. case contact.EdgeContactRelationships:
  1621. m.ResetContactRelationships()
  1622. return nil
  1623. case contact.EdgeContactMessages:
  1624. m.ResetContactMessages()
  1625. return nil
  1626. }
  1627. return fmt.Errorf("unknown Contact edge %s", name)
  1628. }
  1629. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  1630. type LabelMutation struct {
  1631. config
  1632. op Op
  1633. typ string
  1634. id *uint64
  1635. created_at *time.Time
  1636. updated_at *time.Time
  1637. status *uint8
  1638. addstatus *int8
  1639. deleted_at *time.Time
  1640. _type *int
  1641. add_type *int
  1642. name *string
  1643. from *int
  1644. addfrom *int
  1645. mode *int
  1646. addmode *int
  1647. conditions *string
  1648. clearedFields map[string]struct{}
  1649. label_relationships map[uint64]struct{}
  1650. removedlabel_relationships map[uint64]struct{}
  1651. clearedlabel_relationships bool
  1652. done bool
  1653. oldValue func(context.Context) (*Label, error)
  1654. predicates []predicate.Label
  1655. }
  1656. var _ ent.Mutation = (*LabelMutation)(nil)
  1657. // labelOption allows management of the mutation configuration using functional options.
  1658. type labelOption func(*LabelMutation)
  1659. // newLabelMutation creates new mutation for the Label entity.
  1660. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  1661. m := &LabelMutation{
  1662. config: c,
  1663. op: op,
  1664. typ: TypeLabel,
  1665. clearedFields: make(map[string]struct{}),
  1666. }
  1667. for _, opt := range opts {
  1668. opt(m)
  1669. }
  1670. return m
  1671. }
  1672. // withLabelID sets the ID field of the mutation.
  1673. func withLabelID(id uint64) labelOption {
  1674. return func(m *LabelMutation) {
  1675. var (
  1676. err error
  1677. once sync.Once
  1678. value *Label
  1679. )
  1680. m.oldValue = func(ctx context.Context) (*Label, error) {
  1681. once.Do(func() {
  1682. if m.done {
  1683. err = errors.New("querying old values post mutation is not allowed")
  1684. } else {
  1685. value, err = m.Client().Label.Get(ctx, id)
  1686. }
  1687. })
  1688. return value, err
  1689. }
  1690. m.id = &id
  1691. }
  1692. }
  1693. // withLabel sets the old Label of the mutation.
  1694. func withLabel(node *Label) labelOption {
  1695. return func(m *LabelMutation) {
  1696. m.oldValue = func(context.Context) (*Label, error) {
  1697. return node, nil
  1698. }
  1699. m.id = &node.ID
  1700. }
  1701. }
  1702. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1703. // executed in a transaction (ent.Tx), a transactional client is returned.
  1704. func (m LabelMutation) Client() *Client {
  1705. client := &Client{config: m.config}
  1706. client.init()
  1707. return client
  1708. }
  1709. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1710. // it returns an error otherwise.
  1711. func (m LabelMutation) Tx() (*Tx, error) {
  1712. if _, ok := m.driver.(*txDriver); !ok {
  1713. return nil, errors.New("ent: mutation is not running in a transaction")
  1714. }
  1715. tx := &Tx{config: m.config}
  1716. tx.init()
  1717. return tx, nil
  1718. }
  1719. // SetID sets the value of the id field. Note that this
  1720. // operation is only accepted on creation of Label entities.
  1721. func (m *LabelMutation) SetID(id uint64) {
  1722. m.id = &id
  1723. }
  1724. // ID returns the ID value in the mutation. Note that the ID is only available
  1725. // if it was provided to the builder or after it was returned from the database.
  1726. func (m *LabelMutation) ID() (id uint64, exists bool) {
  1727. if m.id == nil {
  1728. return
  1729. }
  1730. return *m.id, true
  1731. }
  1732. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1733. // That means, if the mutation is applied within a transaction with an isolation level such
  1734. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1735. // or updated by the mutation.
  1736. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  1737. switch {
  1738. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1739. id, exists := m.ID()
  1740. if exists {
  1741. return []uint64{id}, nil
  1742. }
  1743. fallthrough
  1744. case m.op.Is(OpUpdate | OpDelete):
  1745. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  1746. default:
  1747. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1748. }
  1749. }
  1750. // SetCreatedAt sets the "created_at" field.
  1751. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  1752. m.created_at = &t
  1753. }
  1754. // CreatedAt returns the value of the "created_at" field in the mutation.
  1755. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  1756. v := m.created_at
  1757. if v == nil {
  1758. return
  1759. }
  1760. return *v, true
  1761. }
  1762. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  1763. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  1764. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1765. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  1766. if !m.op.Is(OpUpdateOne) {
  1767. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  1768. }
  1769. if m.id == nil || m.oldValue == nil {
  1770. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  1771. }
  1772. oldValue, err := m.oldValue(ctx)
  1773. if err != nil {
  1774. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  1775. }
  1776. return oldValue.CreatedAt, nil
  1777. }
  1778. // ResetCreatedAt resets all changes to the "created_at" field.
  1779. func (m *LabelMutation) ResetCreatedAt() {
  1780. m.created_at = nil
  1781. }
  1782. // SetUpdatedAt sets the "updated_at" field.
  1783. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  1784. m.updated_at = &t
  1785. }
  1786. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  1787. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  1788. v := m.updated_at
  1789. if v == nil {
  1790. return
  1791. }
  1792. return *v, true
  1793. }
  1794. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  1795. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  1796. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1797. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  1798. if !m.op.Is(OpUpdateOne) {
  1799. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  1800. }
  1801. if m.id == nil || m.oldValue == nil {
  1802. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  1803. }
  1804. oldValue, err := m.oldValue(ctx)
  1805. if err != nil {
  1806. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  1807. }
  1808. return oldValue.UpdatedAt, nil
  1809. }
  1810. // ResetUpdatedAt resets all changes to the "updated_at" field.
  1811. func (m *LabelMutation) ResetUpdatedAt() {
  1812. m.updated_at = nil
  1813. }
  1814. // SetStatus sets the "status" field.
  1815. func (m *LabelMutation) SetStatus(u uint8) {
  1816. m.status = &u
  1817. m.addstatus = nil
  1818. }
  1819. // Status returns the value of the "status" field in the mutation.
  1820. func (m *LabelMutation) Status() (r uint8, exists bool) {
  1821. v := m.status
  1822. if v == nil {
  1823. return
  1824. }
  1825. return *v, true
  1826. }
  1827. // OldStatus returns the old "status" field's value of the Label entity.
  1828. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  1829. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1830. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  1831. if !m.op.Is(OpUpdateOne) {
  1832. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  1833. }
  1834. if m.id == nil || m.oldValue == nil {
  1835. return v, errors.New("OldStatus requires an ID field in the mutation")
  1836. }
  1837. oldValue, err := m.oldValue(ctx)
  1838. if err != nil {
  1839. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  1840. }
  1841. return oldValue.Status, nil
  1842. }
  1843. // AddStatus adds u to the "status" field.
  1844. func (m *LabelMutation) AddStatus(u int8) {
  1845. if m.addstatus != nil {
  1846. *m.addstatus += u
  1847. } else {
  1848. m.addstatus = &u
  1849. }
  1850. }
  1851. // AddedStatus returns the value that was added to the "status" field in this mutation.
  1852. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  1853. v := m.addstatus
  1854. if v == nil {
  1855. return
  1856. }
  1857. return *v, true
  1858. }
  1859. // ClearStatus clears the value of the "status" field.
  1860. func (m *LabelMutation) ClearStatus() {
  1861. m.status = nil
  1862. m.addstatus = nil
  1863. m.clearedFields[label.FieldStatus] = struct{}{}
  1864. }
  1865. // StatusCleared returns if the "status" field was cleared in this mutation.
  1866. func (m *LabelMutation) StatusCleared() bool {
  1867. _, ok := m.clearedFields[label.FieldStatus]
  1868. return ok
  1869. }
  1870. // ResetStatus resets all changes to the "status" field.
  1871. func (m *LabelMutation) ResetStatus() {
  1872. m.status = nil
  1873. m.addstatus = nil
  1874. delete(m.clearedFields, label.FieldStatus)
  1875. }
  1876. // SetDeletedAt sets the "deleted_at" field.
  1877. func (m *LabelMutation) SetDeletedAt(t time.Time) {
  1878. m.deleted_at = &t
  1879. }
  1880. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  1881. func (m *LabelMutation) DeletedAt() (r time.Time, exists bool) {
  1882. v := m.deleted_at
  1883. if v == nil {
  1884. return
  1885. }
  1886. return *v, true
  1887. }
  1888. // OldDeletedAt returns the old "deleted_at" field's value of the Label entity.
  1889. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  1890. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1891. func (m *LabelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  1892. if !m.op.Is(OpUpdateOne) {
  1893. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  1894. }
  1895. if m.id == nil || m.oldValue == nil {
  1896. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  1897. }
  1898. oldValue, err := m.oldValue(ctx)
  1899. if err != nil {
  1900. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  1901. }
  1902. return oldValue.DeletedAt, nil
  1903. }
  1904. // ClearDeletedAt clears the value of the "deleted_at" field.
  1905. func (m *LabelMutation) ClearDeletedAt() {
  1906. m.deleted_at = nil
  1907. m.clearedFields[label.FieldDeletedAt] = struct{}{}
  1908. }
  1909. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  1910. func (m *LabelMutation) DeletedAtCleared() bool {
  1911. _, ok := m.clearedFields[label.FieldDeletedAt]
  1912. return ok
  1913. }
  1914. // ResetDeletedAt resets all changes to the "deleted_at" field.
  1915. func (m *LabelMutation) ResetDeletedAt() {
  1916. m.deleted_at = nil
  1917. delete(m.clearedFields, label.FieldDeletedAt)
  1918. }
  1919. // SetType sets the "type" field.
  1920. func (m *LabelMutation) SetType(i int) {
  1921. m._type = &i
  1922. m.add_type = nil
  1923. }
  1924. // GetType returns the value of the "type" field in the mutation.
  1925. func (m *LabelMutation) GetType() (r int, exists bool) {
  1926. v := m._type
  1927. if v == nil {
  1928. return
  1929. }
  1930. return *v, true
  1931. }
  1932. // OldType returns the old "type" field's value of the Label entity.
  1933. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  1934. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1935. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  1936. if !m.op.Is(OpUpdateOne) {
  1937. return v, errors.New("OldType is only allowed on UpdateOne operations")
  1938. }
  1939. if m.id == nil || m.oldValue == nil {
  1940. return v, errors.New("OldType requires an ID field in the mutation")
  1941. }
  1942. oldValue, err := m.oldValue(ctx)
  1943. if err != nil {
  1944. return v, fmt.Errorf("querying old value for OldType: %w", err)
  1945. }
  1946. return oldValue.Type, nil
  1947. }
  1948. // AddType adds i to the "type" field.
  1949. func (m *LabelMutation) AddType(i int) {
  1950. if m.add_type != nil {
  1951. *m.add_type += i
  1952. } else {
  1953. m.add_type = &i
  1954. }
  1955. }
  1956. // AddedType returns the value that was added to the "type" field in this mutation.
  1957. func (m *LabelMutation) AddedType() (r int, exists bool) {
  1958. v := m.add_type
  1959. if v == nil {
  1960. return
  1961. }
  1962. return *v, true
  1963. }
  1964. // ResetType resets all changes to the "type" field.
  1965. func (m *LabelMutation) ResetType() {
  1966. m._type = nil
  1967. m.add_type = nil
  1968. }
  1969. // SetName sets the "name" field.
  1970. func (m *LabelMutation) SetName(s string) {
  1971. m.name = &s
  1972. }
  1973. // Name returns the value of the "name" field in the mutation.
  1974. func (m *LabelMutation) Name() (r string, exists bool) {
  1975. v := m.name
  1976. if v == nil {
  1977. return
  1978. }
  1979. return *v, true
  1980. }
  1981. // OldName returns the old "name" field's value of the Label entity.
  1982. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  1983. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1984. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  1985. if !m.op.Is(OpUpdateOne) {
  1986. return v, errors.New("OldName is only allowed on UpdateOne operations")
  1987. }
  1988. if m.id == nil || m.oldValue == nil {
  1989. return v, errors.New("OldName requires an ID field in the mutation")
  1990. }
  1991. oldValue, err := m.oldValue(ctx)
  1992. if err != nil {
  1993. return v, fmt.Errorf("querying old value for OldName: %w", err)
  1994. }
  1995. return oldValue.Name, nil
  1996. }
  1997. // ResetName resets all changes to the "name" field.
  1998. func (m *LabelMutation) ResetName() {
  1999. m.name = nil
  2000. }
  2001. // SetFrom sets the "from" field.
  2002. func (m *LabelMutation) SetFrom(i int) {
  2003. m.from = &i
  2004. m.addfrom = nil
  2005. }
  2006. // From returns the value of the "from" field in the mutation.
  2007. func (m *LabelMutation) From() (r int, exists bool) {
  2008. v := m.from
  2009. if v == nil {
  2010. return
  2011. }
  2012. return *v, true
  2013. }
  2014. // OldFrom returns the old "from" field's value of the Label entity.
  2015. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  2016. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2017. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  2018. if !m.op.Is(OpUpdateOne) {
  2019. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  2020. }
  2021. if m.id == nil || m.oldValue == nil {
  2022. return v, errors.New("OldFrom requires an ID field in the mutation")
  2023. }
  2024. oldValue, err := m.oldValue(ctx)
  2025. if err != nil {
  2026. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  2027. }
  2028. return oldValue.From, nil
  2029. }
  2030. // AddFrom adds i to the "from" field.
  2031. func (m *LabelMutation) AddFrom(i int) {
  2032. if m.addfrom != nil {
  2033. *m.addfrom += i
  2034. } else {
  2035. m.addfrom = &i
  2036. }
  2037. }
  2038. // AddedFrom returns the value that was added to the "from" field in this mutation.
  2039. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  2040. v := m.addfrom
  2041. if v == nil {
  2042. return
  2043. }
  2044. return *v, true
  2045. }
  2046. // ResetFrom resets all changes to the "from" field.
  2047. func (m *LabelMutation) ResetFrom() {
  2048. m.from = nil
  2049. m.addfrom = nil
  2050. }
  2051. // SetMode sets the "mode" field.
  2052. func (m *LabelMutation) SetMode(i int) {
  2053. m.mode = &i
  2054. m.addmode = nil
  2055. }
  2056. // Mode returns the value of the "mode" field in the mutation.
  2057. func (m *LabelMutation) Mode() (r int, exists bool) {
  2058. v := m.mode
  2059. if v == nil {
  2060. return
  2061. }
  2062. return *v, true
  2063. }
  2064. // OldMode returns the old "mode" field's value of the Label entity.
  2065. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  2066. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2067. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  2068. if !m.op.Is(OpUpdateOne) {
  2069. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  2070. }
  2071. if m.id == nil || m.oldValue == nil {
  2072. return v, errors.New("OldMode requires an ID field in the mutation")
  2073. }
  2074. oldValue, err := m.oldValue(ctx)
  2075. if err != nil {
  2076. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  2077. }
  2078. return oldValue.Mode, nil
  2079. }
  2080. // AddMode adds i to the "mode" field.
  2081. func (m *LabelMutation) AddMode(i int) {
  2082. if m.addmode != nil {
  2083. *m.addmode += i
  2084. } else {
  2085. m.addmode = &i
  2086. }
  2087. }
  2088. // AddedMode returns the value that was added to the "mode" field in this mutation.
  2089. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  2090. v := m.addmode
  2091. if v == nil {
  2092. return
  2093. }
  2094. return *v, true
  2095. }
  2096. // ResetMode resets all changes to the "mode" field.
  2097. func (m *LabelMutation) ResetMode() {
  2098. m.mode = nil
  2099. m.addmode = nil
  2100. }
  2101. // SetConditions sets the "conditions" field.
  2102. func (m *LabelMutation) SetConditions(s string) {
  2103. m.conditions = &s
  2104. }
  2105. // Conditions returns the value of the "conditions" field in the mutation.
  2106. func (m *LabelMutation) Conditions() (r string, exists bool) {
  2107. v := m.conditions
  2108. if v == nil {
  2109. return
  2110. }
  2111. return *v, true
  2112. }
  2113. // OldConditions returns the old "conditions" field's value of the Label entity.
  2114. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  2115. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2116. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  2117. if !m.op.Is(OpUpdateOne) {
  2118. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  2119. }
  2120. if m.id == nil || m.oldValue == nil {
  2121. return v, errors.New("OldConditions requires an ID field in the mutation")
  2122. }
  2123. oldValue, err := m.oldValue(ctx)
  2124. if err != nil {
  2125. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  2126. }
  2127. return oldValue.Conditions, nil
  2128. }
  2129. // ClearConditions clears the value of the "conditions" field.
  2130. func (m *LabelMutation) ClearConditions() {
  2131. m.conditions = nil
  2132. m.clearedFields[label.FieldConditions] = struct{}{}
  2133. }
  2134. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  2135. func (m *LabelMutation) ConditionsCleared() bool {
  2136. _, ok := m.clearedFields[label.FieldConditions]
  2137. return ok
  2138. }
  2139. // ResetConditions resets all changes to the "conditions" field.
  2140. func (m *LabelMutation) ResetConditions() {
  2141. m.conditions = nil
  2142. delete(m.clearedFields, label.FieldConditions)
  2143. }
  2144. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  2145. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  2146. if m.label_relationships == nil {
  2147. m.label_relationships = make(map[uint64]struct{})
  2148. }
  2149. for i := range ids {
  2150. m.label_relationships[ids[i]] = struct{}{}
  2151. }
  2152. }
  2153. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  2154. func (m *LabelMutation) ClearLabelRelationships() {
  2155. m.clearedlabel_relationships = true
  2156. }
  2157. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  2158. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  2159. return m.clearedlabel_relationships
  2160. }
  2161. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  2162. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  2163. if m.removedlabel_relationships == nil {
  2164. m.removedlabel_relationships = make(map[uint64]struct{})
  2165. }
  2166. for i := range ids {
  2167. delete(m.label_relationships, ids[i])
  2168. m.removedlabel_relationships[ids[i]] = struct{}{}
  2169. }
  2170. }
  2171. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  2172. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  2173. for id := range m.removedlabel_relationships {
  2174. ids = append(ids, id)
  2175. }
  2176. return
  2177. }
  2178. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  2179. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  2180. for id := range m.label_relationships {
  2181. ids = append(ids, id)
  2182. }
  2183. return
  2184. }
  2185. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  2186. func (m *LabelMutation) ResetLabelRelationships() {
  2187. m.label_relationships = nil
  2188. m.clearedlabel_relationships = false
  2189. m.removedlabel_relationships = nil
  2190. }
  2191. // Where appends a list predicates to the LabelMutation builder.
  2192. func (m *LabelMutation) Where(ps ...predicate.Label) {
  2193. m.predicates = append(m.predicates, ps...)
  2194. }
  2195. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  2196. // users can use type-assertion to append predicates that do not depend on any generated package.
  2197. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  2198. p := make([]predicate.Label, len(ps))
  2199. for i := range ps {
  2200. p[i] = ps[i]
  2201. }
  2202. m.Where(p...)
  2203. }
  2204. // Op returns the operation name.
  2205. func (m *LabelMutation) Op() Op {
  2206. return m.op
  2207. }
  2208. // SetOp allows setting the mutation operation.
  2209. func (m *LabelMutation) SetOp(op Op) {
  2210. m.op = op
  2211. }
  2212. // Type returns the node type of this mutation (Label).
  2213. func (m *LabelMutation) Type() string {
  2214. return m.typ
  2215. }
  2216. // Fields returns all fields that were changed during this mutation. Note that in
  2217. // order to get all numeric fields that were incremented/decremented, call
  2218. // AddedFields().
  2219. func (m *LabelMutation) Fields() []string {
  2220. fields := make([]string, 0, 9)
  2221. if m.created_at != nil {
  2222. fields = append(fields, label.FieldCreatedAt)
  2223. }
  2224. if m.updated_at != nil {
  2225. fields = append(fields, label.FieldUpdatedAt)
  2226. }
  2227. if m.status != nil {
  2228. fields = append(fields, label.FieldStatus)
  2229. }
  2230. if m.deleted_at != nil {
  2231. fields = append(fields, label.FieldDeletedAt)
  2232. }
  2233. if m._type != nil {
  2234. fields = append(fields, label.FieldType)
  2235. }
  2236. if m.name != nil {
  2237. fields = append(fields, label.FieldName)
  2238. }
  2239. if m.from != nil {
  2240. fields = append(fields, label.FieldFrom)
  2241. }
  2242. if m.mode != nil {
  2243. fields = append(fields, label.FieldMode)
  2244. }
  2245. if m.conditions != nil {
  2246. fields = append(fields, label.FieldConditions)
  2247. }
  2248. return fields
  2249. }
  2250. // Field returns the value of a field with the given name. The second boolean
  2251. // return value indicates that this field was not set, or was not defined in the
  2252. // schema.
  2253. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  2254. switch name {
  2255. case label.FieldCreatedAt:
  2256. return m.CreatedAt()
  2257. case label.FieldUpdatedAt:
  2258. return m.UpdatedAt()
  2259. case label.FieldStatus:
  2260. return m.Status()
  2261. case label.FieldDeletedAt:
  2262. return m.DeletedAt()
  2263. case label.FieldType:
  2264. return m.GetType()
  2265. case label.FieldName:
  2266. return m.Name()
  2267. case label.FieldFrom:
  2268. return m.From()
  2269. case label.FieldMode:
  2270. return m.Mode()
  2271. case label.FieldConditions:
  2272. return m.Conditions()
  2273. }
  2274. return nil, false
  2275. }
  2276. // OldField returns the old value of the field from the database. An error is
  2277. // returned if the mutation operation is not UpdateOne, or the query to the
  2278. // database failed.
  2279. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2280. switch name {
  2281. case label.FieldCreatedAt:
  2282. return m.OldCreatedAt(ctx)
  2283. case label.FieldUpdatedAt:
  2284. return m.OldUpdatedAt(ctx)
  2285. case label.FieldStatus:
  2286. return m.OldStatus(ctx)
  2287. case label.FieldDeletedAt:
  2288. return m.OldDeletedAt(ctx)
  2289. case label.FieldType:
  2290. return m.OldType(ctx)
  2291. case label.FieldName:
  2292. return m.OldName(ctx)
  2293. case label.FieldFrom:
  2294. return m.OldFrom(ctx)
  2295. case label.FieldMode:
  2296. return m.OldMode(ctx)
  2297. case label.FieldConditions:
  2298. return m.OldConditions(ctx)
  2299. }
  2300. return nil, fmt.Errorf("unknown Label field %s", name)
  2301. }
  2302. // SetField sets the value of a field with the given name. It returns an error if
  2303. // the field is not defined in the schema, or if the type mismatched the field
  2304. // type.
  2305. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  2306. switch name {
  2307. case label.FieldCreatedAt:
  2308. v, ok := value.(time.Time)
  2309. if !ok {
  2310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2311. }
  2312. m.SetCreatedAt(v)
  2313. return nil
  2314. case label.FieldUpdatedAt:
  2315. v, ok := value.(time.Time)
  2316. if !ok {
  2317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2318. }
  2319. m.SetUpdatedAt(v)
  2320. return nil
  2321. case label.FieldStatus:
  2322. v, ok := value.(uint8)
  2323. if !ok {
  2324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2325. }
  2326. m.SetStatus(v)
  2327. return nil
  2328. case label.FieldDeletedAt:
  2329. v, ok := value.(time.Time)
  2330. if !ok {
  2331. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2332. }
  2333. m.SetDeletedAt(v)
  2334. return nil
  2335. case label.FieldType:
  2336. v, ok := value.(int)
  2337. if !ok {
  2338. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2339. }
  2340. m.SetType(v)
  2341. return nil
  2342. case label.FieldName:
  2343. v, ok := value.(string)
  2344. if !ok {
  2345. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2346. }
  2347. m.SetName(v)
  2348. return nil
  2349. case label.FieldFrom:
  2350. v, ok := value.(int)
  2351. if !ok {
  2352. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2353. }
  2354. m.SetFrom(v)
  2355. return nil
  2356. case label.FieldMode:
  2357. v, ok := value.(int)
  2358. if !ok {
  2359. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2360. }
  2361. m.SetMode(v)
  2362. return nil
  2363. case label.FieldConditions:
  2364. v, ok := value.(string)
  2365. if !ok {
  2366. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2367. }
  2368. m.SetConditions(v)
  2369. return nil
  2370. }
  2371. return fmt.Errorf("unknown Label field %s", name)
  2372. }
  2373. // AddedFields returns all numeric fields that were incremented/decremented during
  2374. // this mutation.
  2375. func (m *LabelMutation) AddedFields() []string {
  2376. var fields []string
  2377. if m.addstatus != nil {
  2378. fields = append(fields, label.FieldStatus)
  2379. }
  2380. if m.add_type != nil {
  2381. fields = append(fields, label.FieldType)
  2382. }
  2383. if m.addfrom != nil {
  2384. fields = append(fields, label.FieldFrom)
  2385. }
  2386. if m.addmode != nil {
  2387. fields = append(fields, label.FieldMode)
  2388. }
  2389. return fields
  2390. }
  2391. // AddedField returns the numeric value that was incremented/decremented on a field
  2392. // with the given name. The second boolean return value indicates that this field
  2393. // was not set, or was not defined in the schema.
  2394. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  2395. switch name {
  2396. case label.FieldStatus:
  2397. return m.AddedStatus()
  2398. case label.FieldType:
  2399. return m.AddedType()
  2400. case label.FieldFrom:
  2401. return m.AddedFrom()
  2402. case label.FieldMode:
  2403. return m.AddedMode()
  2404. }
  2405. return nil, false
  2406. }
  2407. // AddField adds the value to the field with the given name. It returns an error if
  2408. // the field is not defined in the schema, or if the type mismatched the field
  2409. // type.
  2410. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  2411. switch name {
  2412. case label.FieldStatus:
  2413. v, ok := value.(int8)
  2414. if !ok {
  2415. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2416. }
  2417. m.AddStatus(v)
  2418. return nil
  2419. case label.FieldType:
  2420. v, ok := value.(int)
  2421. if !ok {
  2422. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2423. }
  2424. m.AddType(v)
  2425. return nil
  2426. case label.FieldFrom:
  2427. v, ok := value.(int)
  2428. if !ok {
  2429. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2430. }
  2431. m.AddFrom(v)
  2432. return nil
  2433. case label.FieldMode:
  2434. v, ok := value.(int)
  2435. if !ok {
  2436. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2437. }
  2438. m.AddMode(v)
  2439. return nil
  2440. }
  2441. return fmt.Errorf("unknown Label numeric field %s", name)
  2442. }
  2443. // ClearedFields returns all nullable fields that were cleared during this
  2444. // mutation.
  2445. func (m *LabelMutation) ClearedFields() []string {
  2446. var fields []string
  2447. if m.FieldCleared(label.FieldStatus) {
  2448. fields = append(fields, label.FieldStatus)
  2449. }
  2450. if m.FieldCleared(label.FieldDeletedAt) {
  2451. fields = append(fields, label.FieldDeletedAt)
  2452. }
  2453. if m.FieldCleared(label.FieldConditions) {
  2454. fields = append(fields, label.FieldConditions)
  2455. }
  2456. return fields
  2457. }
  2458. // FieldCleared returns a boolean indicating if a field with the given name was
  2459. // cleared in this mutation.
  2460. func (m *LabelMutation) FieldCleared(name string) bool {
  2461. _, ok := m.clearedFields[name]
  2462. return ok
  2463. }
  2464. // ClearField clears the value of the field with the given name. It returns an
  2465. // error if the field is not defined in the schema.
  2466. func (m *LabelMutation) ClearField(name string) error {
  2467. switch name {
  2468. case label.FieldStatus:
  2469. m.ClearStatus()
  2470. return nil
  2471. case label.FieldDeletedAt:
  2472. m.ClearDeletedAt()
  2473. return nil
  2474. case label.FieldConditions:
  2475. m.ClearConditions()
  2476. return nil
  2477. }
  2478. return fmt.Errorf("unknown Label nullable field %s", name)
  2479. }
  2480. // ResetField resets all changes in the mutation for the field with the given name.
  2481. // It returns an error if the field is not defined in the schema.
  2482. func (m *LabelMutation) ResetField(name string) error {
  2483. switch name {
  2484. case label.FieldCreatedAt:
  2485. m.ResetCreatedAt()
  2486. return nil
  2487. case label.FieldUpdatedAt:
  2488. m.ResetUpdatedAt()
  2489. return nil
  2490. case label.FieldStatus:
  2491. m.ResetStatus()
  2492. return nil
  2493. case label.FieldDeletedAt:
  2494. m.ResetDeletedAt()
  2495. return nil
  2496. case label.FieldType:
  2497. m.ResetType()
  2498. return nil
  2499. case label.FieldName:
  2500. m.ResetName()
  2501. return nil
  2502. case label.FieldFrom:
  2503. m.ResetFrom()
  2504. return nil
  2505. case label.FieldMode:
  2506. m.ResetMode()
  2507. return nil
  2508. case label.FieldConditions:
  2509. m.ResetConditions()
  2510. return nil
  2511. }
  2512. return fmt.Errorf("unknown Label field %s", name)
  2513. }
  2514. // AddedEdges returns all edge names that were set/added in this mutation.
  2515. func (m *LabelMutation) AddedEdges() []string {
  2516. edges := make([]string, 0, 1)
  2517. if m.label_relationships != nil {
  2518. edges = append(edges, label.EdgeLabelRelationships)
  2519. }
  2520. return edges
  2521. }
  2522. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2523. // name in this mutation.
  2524. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  2525. switch name {
  2526. case label.EdgeLabelRelationships:
  2527. ids := make([]ent.Value, 0, len(m.label_relationships))
  2528. for id := range m.label_relationships {
  2529. ids = append(ids, id)
  2530. }
  2531. return ids
  2532. }
  2533. return nil
  2534. }
  2535. // RemovedEdges returns all edge names that were removed in this mutation.
  2536. func (m *LabelMutation) RemovedEdges() []string {
  2537. edges := make([]string, 0, 1)
  2538. if m.removedlabel_relationships != nil {
  2539. edges = append(edges, label.EdgeLabelRelationships)
  2540. }
  2541. return edges
  2542. }
  2543. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2544. // the given name in this mutation.
  2545. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  2546. switch name {
  2547. case label.EdgeLabelRelationships:
  2548. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  2549. for id := range m.removedlabel_relationships {
  2550. ids = append(ids, id)
  2551. }
  2552. return ids
  2553. }
  2554. return nil
  2555. }
  2556. // ClearedEdges returns all edge names that were cleared in this mutation.
  2557. func (m *LabelMutation) ClearedEdges() []string {
  2558. edges := make([]string, 0, 1)
  2559. if m.clearedlabel_relationships {
  2560. edges = append(edges, label.EdgeLabelRelationships)
  2561. }
  2562. return edges
  2563. }
  2564. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2565. // was cleared in this mutation.
  2566. func (m *LabelMutation) EdgeCleared(name string) bool {
  2567. switch name {
  2568. case label.EdgeLabelRelationships:
  2569. return m.clearedlabel_relationships
  2570. }
  2571. return false
  2572. }
  2573. // ClearEdge clears the value of the edge with the given name. It returns an error
  2574. // if that edge is not defined in the schema.
  2575. func (m *LabelMutation) ClearEdge(name string) error {
  2576. switch name {
  2577. }
  2578. return fmt.Errorf("unknown Label unique edge %s", name)
  2579. }
  2580. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2581. // It returns an error if the edge is not defined in the schema.
  2582. func (m *LabelMutation) ResetEdge(name string) error {
  2583. switch name {
  2584. case label.EdgeLabelRelationships:
  2585. m.ResetLabelRelationships()
  2586. return nil
  2587. }
  2588. return fmt.Errorf("unknown Label edge %s", name)
  2589. }
  2590. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  2591. type LabelRelationshipMutation struct {
  2592. config
  2593. op Op
  2594. typ string
  2595. id *uint64
  2596. created_at *time.Time
  2597. updated_at *time.Time
  2598. status *uint8
  2599. addstatus *int8
  2600. deleted_at *time.Time
  2601. clearedFields map[string]struct{}
  2602. contacts *uint64
  2603. clearedcontacts bool
  2604. labels *uint64
  2605. clearedlabels bool
  2606. done bool
  2607. oldValue func(context.Context) (*LabelRelationship, error)
  2608. predicates []predicate.LabelRelationship
  2609. }
  2610. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  2611. // labelrelationshipOption allows management of the mutation configuration using functional options.
  2612. type labelrelationshipOption func(*LabelRelationshipMutation)
  2613. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  2614. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  2615. m := &LabelRelationshipMutation{
  2616. config: c,
  2617. op: op,
  2618. typ: TypeLabelRelationship,
  2619. clearedFields: make(map[string]struct{}),
  2620. }
  2621. for _, opt := range opts {
  2622. opt(m)
  2623. }
  2624. return m
  2625. }
  2626. // withLabelRelationshipID sets the ID field of the mutation.
  2627. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  2628. return func(m *LabelRelationshipMutation) {
  2629. var (
  2630. err error
  2631. once sync.Once
  2632. value *LabelRelationship
  2633. )
  2634. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  2635. once.Do(func() {
  2636. if m.done {
  2637. err = errors.New("querying old values post mutation is not allowed")
  2638. } else {
  2639. value, err = m.Client().LabelRelationship.Get(ctx, id)
  2640. }
  2641. })
  2642. return value, err
  2643. }
  2644. m.id = &id
  2645. }
  2646. }
  2647. // withLabelRelationship sets the old LabelRelationship of the mutation.
  2648. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  2649. return func(m *LabelRelationshipMutation) {
  2650. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  2651. return node, nil
  2652. }
  2653. m.id = &node.ID
  2654. }
  2655. }
  2656. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2657. // executed in a transaction (ent.Tx), a transactional client is returned.
  2658. func (m LabelRelationshipMutation) Client() *Client {
  2659. client := &Client{config: m.config}
  2660. client.init()
  2661. return client
  2662. }
  2663. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2664. // it returns an error otherwise.
  2665. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  2666. if _, ok := m.driver.(*txDriver); !ok {
  2667. return nil, errors.New("ent: mutation is not running in a transaction")
  2668. }
  2669. tx := &Tx{config: m.config}
  2670. tx.init()
  2671. return tx, nil
  2672. }
  2673. // SetID sets the value of the id field. Note that this
  2674. // operation is only accepted on creation of LabelRelationship entities.
  2675. func (m *LabelRelationshipMutation) SetID(id uint64) {
  2676. m.id = &id
  2677. }
  2678. // ID returns the ID value in the mutation. Note that the ID is only available
  2679. // if it was provided to the builder or after it was returned from the database.
  2680. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  2681. if m.id == nil {
  2682. return
  2683. }
  2684. return *m.id, true
  2685. }
  2686. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2687. // That means, if the mutation is applied within a transaction with an isolation level such
  2688. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2689. // or updated by the mutation.
  2690. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  2691. switch {
  2692. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2693. id, exists := m.ID()
  2694. if exists {
  2695. return []uint64{id}, nil
  2696. }
  2697. fallthrough
  2698. case m.op.Is(OpUpdate | OpDelete):
  2699. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  2700. default:
  2701. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2702. }
  2703. }
  2704. // SetCreatedAt sets the "created_at" field.
  2705. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  2706. m.created_at = &t
  2707. }
  2708. // CreatedAt returns the value of the "created_at" field in the mutation.
  2709. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  2710. v := m.created_at
  2711. if v == nil {
  2712. return
  2713. }
  2714. return *v, true
  2715. }
  2716. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  2717. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  2718. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2719. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2720. if !m.op.Is(OpUpdateOne) {
  2721. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2722. }
  2723. if m.id == nil || m.oldValue == nil {
  2724. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2725. }
  2726. oldValue, err := m.oldValue(ctx)
  2727. if err != nil {
  2728. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2729. }
  2730. return oldValue.CreatedAt, nil
  2731. }
  2732. // ResetCreatedAt resets all changes to the "created_at" field.
  2733. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  2734. m.created_at = nil
  2735. }
  2736. // SetUpdatedAt sets the "updated_at" field.
  2737. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  2738. m.updated_at = &t
  2739. }
  2740. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2741. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  2742. v := m.updated_at
  2743. if v == nil {
  2744. return
  2745. }
  2746. return *v, true
  2747. }
  2748. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  2749. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  2750. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2751. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2752. if !m.op.Is(OpUpdateOne) {
  2753. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2754. }
  2755. if m.id == nil || m.oldValue == nil {
  2756. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2757. }
  2758. oldValue, err := m.oldValue(ctx)
  2759. if err != nil {
  2760. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2761. }
  2762. return oldValue.UpdatedAt, nil
  2763. }
  2764. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2765. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  2766. m.updated_at = nil
  2767. }
  2768. // SetStatus sets the "status" field.
  2769. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  2770. m.status = &u
  2771. m.addstatus = nil
  2772. }
  2773. // Status returns the value of the "status" field in the mutation.
  2774. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  2775. v := m.status
  2776. if v == nil {
  2777. return
  2778. }
  2779. return *v, true
  2780. }
  2781. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  2782. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  2783. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2784. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  2785. if !m.op.Is(OpUpdateOne) {
  2786. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  2787. }
  2788. if m.id == nil || m.oldValue == nil {
  2789. return v, errors.New("OldStatus requires an ID field in the mutation")
  2790. }
  2791. oldValue, err := m.oldValue(ctx)
  2792. if err != nil {
  2793. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  2794. }
  2795. return oldValue.Status, nil
  2796. }
  2797. // AddStatus adds u to the "status" field.
  2798. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  2799. if m.addstatus != nil {
  2800. *m.addstatus += u
  2801. } else {
  2802. m.addstatus = &u
  2803. }
  2804. }
  2805. // AddedStatus returns the value that was added to the "status" field in this mutation.
  2806. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  2807. v := m.addstatus
  2808. if v == nil {
  2809. return
  2810. }
  2811. return *v, true
  2812. }
  2813. // ClearStatus clears the value of the "status" field.
  2814. func (m *LabelRelationshipMutation) ClearStatus() {
  2815. m.status = nil
  2816. m.addstatus = nil
  2817. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  2818. }
  2819. // StatusCleared returns if the "status" field was cleared in this mutation.
  2820. func (m *LabelRelationshipMutation) StatusCleared() bool {
  2821. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  2822. return ok
  2823. }
  2824. // ResetStatus resets all changes to the "status" field.
  2825. func (m *LabelRelationshipMutation) ResetStatus() {
  2826. m.status = nil
  2827. m.addstatus = nil
  2828. delete(m.clearedFields, labelrelationship.FieldStatus)
  2829. }
  2830. // SetDeletedAt sets the "deleted_at" field.
  2831. func (m *LabelRelationshipMutation) SetDeletedAt(t time.Time) {
  2832. m.deleted_at = &t
  2833. }
  2834. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2835. func (m *LabelRelationshipMutation) DeletedAt() (r time.Time, exists bool) {
  2836. v := m.deleted_at
  2837. if v == nil {
  2838. return
  2839. }
  2840. return *v, true
  2841. }
  2842. // OldDeletedAt returns the old "deleted_at" field's value of the LabelRelationship entity.
  2843. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  2844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2845. func (m *LabelRelationshipMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2846. if !m.op.Is(OpUpdateOne) {
  2847. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2848. }
  2849. if m.id == nil || m.oldValue == nil {
  2850. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2851. }
  2852. oldValue, err := m.oldValue(ctx)
  2853. if err != nil {
  2854. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2855. }
  2856. return oldValue.DeletedAt, nil
  2857. }
  2858. // ClearDeletedAt clears the value of the "deleted_at" field.
  2859. func (m *LabelRelationshipMutation) ClearDeletedAt() {
  2860. m.deleted_at = nil
  2861. m.clearedFields[labelrelationship.FieldDeletedAt] = struct{}{}
  2862. }
  2863. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2864. func (m *LabelRelationshipMutation) DeletedAtCleared() bool {
  2865. _, ok := m.clearedFields[labelrelationship.FieldDeletedAt]
  2866. return ok
  2867. }
  2868. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2869. func (m *LabelRelationshipMutation) ResetDeletedAt() {
  2870. m.deleted_at = nil
  2871. delete(m.clearedFields, labelrelationship.FieldDeletedAt)
  2872. }
  2873. // SetLabelID sets the "label_id" field.
  2874. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  2875. m.labels = &u
  2876. }
  2877. // LabelID returns the value of the "label_id" field in the mutation.
  2878. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  2879. v := m.labels
  2880. if v == nil {
  2881. return
  2882. }
  2883. return *v, true
  2884. }
  2885. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  2886. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  2887. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2888. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  2889. if !m.op.Is(OpUpdateOne) {
  2890. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  2891. }
  2892. if m.id == nil || m.oldValue == nil {
  2893. return v, errors.New("OldLabelID requires an ID field in the mutation")
  2894. }
  2895. oldValue, err := m.oldValue(ctx)
  2896. if err != nil {
  2897. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  2898. }
  2899. return oldValue.LabelID, nil
  2900. }
  2901. // ResetLabelID resets all changes to the "label_id" field.
  2902. func (m *LabelRelationshipMutation) ResetLabelID() {
  2903. m.labels = nil
  2904. }
  2905. // SetContactID sets the "contact_id" field.
  2906. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  2907. m.contacts = &u
  2908. }
  2909. // ContactID returns the value of the "contact_id" field in the mutation.
  2910. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  2911. v := m.contacts
  2912. if v == nil {
  2913. return
  2914. }
  2915. return *v, true
  2916. }
  2917. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  2918. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  2919. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2920. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  2921. if !m.op.Is(OpUpdateOne) {
  2922. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  2923. }
  2924. if m.id == nil || m.oldValue == nil {
  2925. return v, errors.New("OldContactID requires an ID field in the mutation")
  2926. }
  2927. oldValue, err := m.oldValue(ctx)
  2928. if err != nil {
  2929. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  2930. }
  2931. return oldValue.ContactID, nil
  2932. }
  2933. // ResetContactID resets all changes to the "contact_id" field.
  2934. func (m *LabelRelationshipMutation) ResetContactID() {
  2935. m.contacts = nil
  2936. }
  2937. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  2938. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  2939. m.contacts = &id
  2940. }
  2941. // ClearContacts clears the "contacts" edge to the Contact entity.
  2942. func (m *LabelRelationshipMutation) ClearContacts() {
  2943. m.clearedcontacts = true
  2944. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  2945. }
  2946. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  2947. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  2948. return m.clearedcontacts
  2949. }
  2950. // ContactsID returns the "contacts" edge ID in the mutation.
  2951. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  2952. if m.contacts != nil {
  2953. return *m.contacts, true
  2954. }
  2955. return
  2956. }
  2957. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  2958. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  2959. // ContactsID instead. It exists only for internal usage by the builders.
  2960. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  2961. if id := m.contacts; id != nil {
  2962. ids = append(ids, *id)
  2963. }
  2964. return
  2965. }
  2966. // ResetContacts resets all changes to the "contacts" edge.
  2967. func (m *LabelRelationshipMutation) ResetContacts() {
  2968. m.contacts = nil
  2969. m.clearedcontacts = false
  2970. }
  2971. // SetLabelsID sets the "labels" edge to the Label entity by id.
  2972. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  2973. m.labels = &id
  2974. }
  2975. // ClearLabels clears the "labels" edge to the Label entity.
  2976. func (m *LabelRelationshipMutation) ClearLabels() {
  2977. m.clearedlabels = true
  2978. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  2979. }
  2980. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  2981. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  2982. return m.clearedlabels
  2983. }
  2984. // LabelsID returns the "labels" edge ID in the mutation.
  2985. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  2986. if m.labels != nil {
  2987. return *m.labels, true
  2988. }
  2989. return
  2990. }
  2991. // LabelsIDs returns the "labels" edge IDs in the mutation.
  2992. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  2993. // LabelsID instead. It exists only for internal usage by the builders.
  2994. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  2995. if id := m.labels; id != nil {
  2996. ids = append(ids, *id)
  2997. }
  2998. return
  2999. }
  3000. // ResetLabels resets all changes to the "labels" edge.
  3001. func (m *LabelRelationshipMutation) ResetLabels() {
  3002. m.labels = nil
  3003. m.clearedlabels = false
  3004. }
  3005. // Where appends a list predicates to the LabelRelationshipMutation builder.
  3006. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  3007. m.predicates = append(m.predicates, ps...)
  3008. }
  3009. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  3010. // users can use type-assertion to append predicates that do not depend on any generated package.
  3011. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  3012. p := make([]predicate.LabelRelationship, len(ps))
  3013. for i := range ps {
  3014. p[i] = ps[i]
  3015. }
  3016. m.Where(p...)
  3017. }
  3018. // Op returns the operation name.
  3019. func (m *LabelRelationshipMutation) Op() Op {
  3020. return m.op
  3021. }
  3022. // SetOp allows setting the mutation operation.
  3023. func (m *LabelRelationshipMutation) SetOp(op Op) {
  3024. m.op = op
  3025. }
  3026. // Type returns the node type of this mutation (LabelRelationship).
  3027. func (m *LabelRelationshipMutation) Type() string {
  3028. return m.typ
  3029. }
  3030. // Fields returns all fields that were changed during this mutation. Note that in
  3031. // order to get all numeric fields that were incremented/decremented, call
  3032. // AddedFields().
  3033. func (m *LabelRelationshipMutation) Fields() []string {
  3034. fields := make([]string, 0, 6)
  3035. if m.created_at != nil {
  3036. fields = append(fields, labelrelationship.FieldCreatedAt)
  3037. }
  3038. if m.updated_at != nil {
  3039. fields = append(fields, labelrelationship.FieldUpdatedAt)
  3040. }
  3041. if m.status != nil {
  3042. fields = append(fields, labelrelationship.FieldStatus)
  3043. }
  3044. if m.deleted_at != nil {
  3045. fields = append(fields, labelrelationship.FieldDeletedAt)
  3046. }
  3047. if m.labels != nil {
  3048. fields = append(fields, labelrelationship.FieldLabelID)
  3049. }
  3050. if m.contacts != nil {
  3051. fields = append(fields, labelrelationship.FieldContactID)
  3052. }
  3053. return fields
  3054. }
  3055. // Field returns the value of a field with the given name. The second boolean
  3056. // return value indicates that this field was not set, or was not defined in the
  3057. // schema.
  3058. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  3059. switch name {
  3060. case labelrelationship.FieldCreatedAt:
  3061. return m.CreatedAt()
  3062. case labelrelationship.FieldUpdatedAt:
  3063. return m.UpdatedAt()
  3064. case labelrelationship.FieldStatus:
  3065. return m.Status()
  3066. case labelrelationship.FieldDeletedAt:
  3067. return m.DeletedAt()
  3068. case labelrelationship.FieldLabelID:
  3069. return m.LabelID()
  3070. case labelrelationship.FieldContactID:
  3071. return m.ContactID()
  3072. }
  3073. return nil, false
  3074. }
  3075. // OldField returns the old value of the field from the database. An error is
  3076. // returned if the mutation operation is not UpdateOne, or the query to the
  3077. // database failed.
  3078. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3079. switch name {
  3080. case labelrelationship.FieldCreatedAt:
  3081. return m.OldCreatedAt(ctx)
  3082. case labelrelationship.FieldUpdatedAt:
  3083. return m.OldUpdatedAt(ctx)
  3084. case labelrelationship.FieldStatus:
  3085. return m.OldStatus(ctx)
  3086. case labelrelationship.FieldDeletedAt:
  3087. return m.OldDeletedAt(ctx)
  3088. case labelrelationship.FieldLabelID:
  3089. return m.OldLabelID(ctx)
  3090. case labelrelationship.FieldContactID:
  3091. return m.OldContactID(ctx)
  3092. }
  3093. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  3094. }
  3095. // SetField sets the value of a field with the given name. It returns an error if
  3096. // the field is not defined in the schema, or if the type mismatched the field
  3097. // type.
  3098. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  3099. switch name {
  3100. case labelrelationship.FieldCreatedAt:
  3101. v, ok := value.(time.Time)
  3102. if !ok {
  3103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3104. }
  3105. m.SetCreatedAt(v)
  3106. return nil
  3107. case labelrelationship.FieldUpdatedAt:
  3108. v, ok := value.(time.Time)
  3109. if !ok {
  3110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3111. }
  3112. m.SetUpdatedAt(v)
  3113. return nil
  3114. case labelrelationship.FieldStatus:
  3115. v, ok := value.(uint8)
  3116. if !ok {
  3117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3118. }
  3119. m.SetStatus(v)
  3120. return nil
  3121. case labelrelationship.FieldDeletedAt:
  3122. v, ok := value.(time.Time)
  3123. if !ok {
  3124. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3125. }
  3126. m.SetDeletedAt(v)
  3127. return nil
  3128. case labelrelationship.FieldLabelID:
  3129. v, ok := value.(uint64)
  3130. if !ok {
  3131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3132. }
  3133. m.SetLabelID(v)
  3134. return nil
  3135. case labelrelationship.FieldContactID:
  3136. v, ok := value.(uint64)
  3137. if !ok {
  3138. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3139. }
  3140. m.SetContactID(v)
  3141. return nil
  3142. }
  3143. return fmt.Errorf("unknown LabelRelationship field %s", name)
  3144. }
  3145. // AddedFields returns all numeric fields that were incremented/decremented during
  3146. // this mutation.
  3147. func (m *LabelRelationshipMutation) AddedFields() []string {
  3148. var fields []string
  3149. if m.addstatus != nil {
  3150. fields = append(fields, labelrelationship.FieldStatus)
  3151. }
  3152. return fields
  3153. }
  3154. // AddedField returns the numeric value that was incremented/decremented on a field
  3155. // with the given name. The second boolean return value indicates that this field
  3156. // was not set, or was not defined in the schema.
  3157. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  3158. switch name {
  3159. case labelrelationship.FieldStatus:
  3160. return m.AddedStatus()
  3161. }
  3162. return nil, false
  3163. }
  3164. // AddField adds the value to the field with the given name. It returns an error if
  3165. // the field is not defined in the schema, or if the type mismatched the field
  3166. // type.
  3167. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  3168. switch name {
  3169. case labelrelationship.FieldStatus:
  3170. v, ok := value.(int8)
  3171. if !ok {
  3172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3173. }
  3174. m.AddStatus(v)
  3175. return nil
  3176. }
  3177. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  3178. }
  3179. // ClearedFields returns all nullable fields that were cleared during this
  3180. // mutation.
  3181. func (m *LabelRelationshipMutation) ClearedFields() []string {
  3182. var fields []string
  3183. if m.FieldCleared(labelrelationship.FieldStatus) {
  3184. fields = append(fields, labelrelationship.FieldStatus)
  3185. }
  3186. if m.FieldCleared(labelrelationship.FieldDeletedAt) {
  3187. fields = append(fields, labelrelationship.FieldDeletedAt)
  3188. }
  3189. return fields
  3190. }
  3191. // FieldCleared returns a boolean indicating if a field with the given name was
  3192. // cleared in this mutation.
  3193. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  3194. _, ok := m.clearedFields[name]
  3195. return ok
  3196. }
  3197. // ClearField clears the value of the field with the given name. It returns an
  3198. // error if the field is not defined in the schema.
  3199. func (m *LabelRelationshipMutation) ClearField(name string) error {
  3200. switch name {
  3201. case labelrelationship.FieldStatus:
  3202. m.ClearStatus()
  3203. return nil
  3204. case labelrelationship.FieldDeletedAt:
  3205. m.ClearDeletedAt()
  3206. return nil
  3207. }
  3208. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  3209. }
  3210. // ResetField resets all changes in the mutation for the field with the given name.
  3211. // It returns an error if the field is not defined in the schema.
  3212. func (m *LabelRelationshipMutation) ResetField(name string) error {
  3213. switch name {
  3214. case labelrelationship.FieldCreatedAt:
  3215. m.ResetCreatedAt()
  3216. return nil
  3217. case labelrelationship.FieldUpdatedAt:
  3218. m.ResetUpdatedAt()
  3219. return nil
  3220. case labelrelationship.FieldStatus:
  3221. m.ResetStatus()
  3222. return nil
  3223. case labelrelationship.FieldDeletedAt:
  3224. m.ResetDeletedAt()
  3225. return nil
  3226. case labelrelationship.FieldLabelID:
  3227. m.ResetLabelID()
  3228. return nil
  3229. case labelrelationship.FieldContactID:
  3230. m.ResetContactID()
  3231. return nil
  3232. }
  3233. return fmt.Errorf("unknown LabelRelationship field %s", name)
  3234. }
  3235. // AddedEdges returns all edge names that were set/added in this mutation.
  3236. func (m *LabelRelationshipMutation) AddedEdges() []string {
  3237. edges := make([]string, 0, 2)
  3238. if m.contacts != nil {
  3239. edges = append(edges, labelrelationship.EdgeContacts)
  3240. }
  3241. if m.labels != nil {
  3242. edges = append(edges, labelrelationship.EdgeLabels)
  3243. }
  3244. return edges
  3245. }
  3246. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3247. // name in this mutation.
  3248. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  3249. switch name {
  3250. case labelrelationship.EdgeContacts:
  3251. if id := m.contacts; id != nil {
  3252. return []ent.Value{*id}
  3253. }
  3254. case labelrelationship.EdgeLabels:
  3255. if id := m.labels; id != nil {
  3256. return []ent.Value{*id}
  3257. }
  3258. }
  3259. return nil
  3260. }
  3261. // RemovedEdges returns all edge names that were removed in this mutation.
  3262. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  3263. edges := make([]string, 0, 2)
  3264. return edges
  3265. }
  3266. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3267. // the given name in this mutation.
  3268. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  3269. return nil
  3270. }
  3271. // ClearedEdges returns all edge names that were cleared in this mutation.
  3272. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  3273. edges := make([]string, 0, 2)
  3274. if m.clearedcontacts {
  3275. edges = append(edges, labelrelationship.EdgeContacts)
  3276. }
  3277. if m.clearedlabels {
  3278. edges = append(edges, labelrelationship.EdgeLabels)
  3279. }
  3280. return edges
  3281. }
  3282. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3283. // was cleared in this mutation.
  3284. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  3285. switch name {
  3286. case labelrelationship.EdgeContacts:
  3287. return m.clearedcontacts
  3288. case labelrelationship.EdgeLabels:
  3289. return m.clearedlabels
  3290. }
  3291. return false
  3292. }
  3293. // ClearEdge clears the value of the edge with the given name. It returns an error
  3294. // if that edge is not defined in the schema.
  3295. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  3296. switch name {
  3297. case labelrelationship.EdgeContacts:
  3298. m.ClearContacts()
  3299. return nil
  3300. case labelrelationship.EdgeLabels:
  3301. m.ClearLabels()
  3302. return nil
  3303. }
  3304. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  3305. }
  3306. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3307. // It returns an error if the edge is not defined in the schema.
  3308. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  3309. switch name {
  3310. case labelrelationship.EdgeContacts:
  3311. m.ResetContacts()
  3312. return nil
  3313. case labelrelationship.EdgeLabels:
  3314. m.ResetLabels()
  3315. return nil
  3316. }
  3317. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  3318. }
  3319. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  3320. type MessageMutation struct {
  3321. config
  3322. op Op
  3323. typ string
  3324. id *int
  3325. wx_wxid *string
  3326. wxid *string
  3327. content *string
  3328. clearedFields map[string]struct{}
  3329. done bool
  3330. oldValue func(context.Context) (*Message, error)
  3331. predicates []predicate.Message
  3332. }
  3333. var _ ent.Mutation = (*MessageMutation)(nil)
  3334. // messageOption allows management of the mutation configuration using functional options.
  3335. type messageOption func(*MessageMutation)
  3336. // newMessageMutation creates new mutation for the Message entity.
  3337. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  3338. m := &MessageMutation{
  3339. config: c,
  3340. op: op,
  3341. typ: TypeMessage,
  3342. clearedFields: make(map[string]struct{}),
  3343. }
  3344. for _, opt := range opts {
  3345. opt(m)
  3346. }
  3347. return m
  3348. }
  3349. // withMessageID sets the ID field of the mutation.
  3350. func withMessageID(id int) messageOption {
  3351. return func(m *MessageMutation) {
  3352. var (
  3353. err error
  3354. once sync.Once
  3355. value *Message
  3356. )
  3357. m.oldValue = func(ctx context.Context) (*Message, error) {
  3358. once.Do(func() {
  3359. if m.done {
  3360. err = errors.New("querying old values post mutation is not allowed")
  3361. } else {
  3362. value, err = m.Client().Message.Get(ctx, id)
  3363. }
  3364. })
  3365. return value, err
  3366. }
  3367. m.id = &id
  3368. }
  3369. }
  3370. // withMessage sets the old Message of the mutation.
  3371. func withMessage(node *Message) messageOption {
  3372. return func(m *MessageMutation) {
  3373. m.oldValue = func(context.Context) (*Message, error) {
  3374. return node, nil
  3375. }
  3376. m.id = &node.ID
  3377. }
  3378. }
  3379. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3380. // executed in a transaction (ent.Tx), a transactional client is returned.
  3381. func (m MessageMutation) Client() *Client {
  3382. client := &Client{config: m.config}
  3383. client.init()
  3384. return client
  3385. }
  3386. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3387. // it returns an error otherwise.
  3388. func (m MessageMutation) Tx() (*Tx, error) {
  3389. if _, ok := m.driver.(*txDriver); !ok {
  3390. return nil, errors.New("ent: mutation is not running in a transaction")
  3391. }
  3392. tx := &Tx{config: m.config}
  3393. tx.init()
  3394. return tx, nil
  3395. }
  3396. // ID returns the ID value in the mutation. Note that the ID is only available
  3397. // if it was provided to the builder or after it was returned from the database.
  3398. func (m *MessageMutation) ID() (id int, exists bool) {
  3399. if m.id == nil {
  3400. return
  3401. }
  3402. return *m.id, true
  3403. }
  3404. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3405. // That means, if the mutation is applied within a transaction with an isolation level such
  3406. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3407. // or updated by the mutation.
  3408. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  3409. switch {
  3410. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3411. id, exists := m.ID()
  3412. if exists {
  3413. return []int{id}, nil
  3414. }
  3415. fallthrough
  3416. case m.op.Is(OpUpdate | OpDelete):
  3417. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  3418. default:
  3419. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3420. }
  3421. }
  3422. // SetWxWxid sets the "wx_wxid" field.
  3423. func (m *MessageMutation) SetWxWxid(s string) {
  3424. m.wx_wxid = &s
  3425. }
  3426. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  3427. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  3428. v := m.wx_wxid
  3429. if v == nil {
  3430. return
  3431. }
  3432. return *v, true
  3433. }
  3434. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  3435. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  3436. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3437. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  3438. if !m.op.Is(OpUpdateOne) {
  3439. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  3440. }
  3441. if m.id == nil || m.oldValue == nil {
  3442. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  3443. }
  3444. oldValue, err := m.oldValue(ctx)
  3445. if err != nil {
  3446. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  3447. }
  3448. return oldValue.WxWxid, nil
  3449. }
  3450. // ClearWxWxid clears the value of the "wx_wxid" field.
  3451. func (m *MessageMutation) ClearWxWxid() {
  3452. m.wx_wxid = nil
  3453. m.clearedFields[message.FieldWxWxid] = struct{}{}
  3454. }
  3455. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  3456. func (m *MessageMutation) WxWxidCleared() bool {
  3457. _, ok := m.clearedFields[message.FieldWxWxid]
  3458. return ok
  3459. }
  3460. // ResetWxWxid resets all changes to the "wx_wxid" field.
  3461. func (m *MessageMutation) ResetWxWxid() {
  3462. m.wx_wxid = nil
  3463. delete(m.clearedFields, message.FieldWxWxid)
  3464. }
  3465. // SetWxid sets the "wxid" field.
  3466. func (m *MessageMutation) SetWxid(s string) {
  3467. m.wxid = &s
  3468. }
  3469. // Wxid returns the value of the "wxid" field in the mutation.
  3470. func (m *MessageMutation) Wxid() (r string, exists bool) {
  3471. v := m.wxid
  3472. if v == nil {
  3473. return
  3474. }
  3475. return *v, true
  3476. }
  3477. // OldWxid returns the old "wxid" field's value of the Message entity.
  3478. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  3479. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3480. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  3481. if !m.op.Is(OpUpdateOne) {
  3482. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  3483. }
  3484. if m.id == nil || m.oldValue == nil {
  3485. return v, errors.New("OldWxid requires an ID field in the mutation")
  3486. }
  3487. oldValue, err := m.oldValue(ctx)
  3488. if err != nil {
  3489. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  3490. }
  3491. return oldValue.Wxid, nil
  3492. }
  3493. // ResetWxid resets all changes to the "wxid" field.
  3494. func (m *MessageMutation) ResetWxid() {
  3495. m.wxid = nil
  3496. }
  3497. // SetContent sets the "content" field.
  3498. func (m *MessageMutation) SetContent(s string) {
  3499. m.content = &s
  3500. }
  3501. // Content returns the value of the "content" field in the mutation.
  3502. func (m *MessageMutation) Content() (r string, exists bool) {
  3503. v := m.content
  3504. if v == nil {
  3505. return
  3506. }
  3507. return *v, true
  3508. }
  3509. // OldContent returns the old "content" field's value of the Message entity.
  3510. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  3511. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3512. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  3513. if !m.op.Is(OpUpdateOne) {
  3514. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  3515. }
  3516. if m.id == nil || m.oldValue == nil {
  3517. return v, errors.New("OldContent requires an ID field in the mutation")
  3518. }
  3519. oldValue, err := m.oldValue(ctx)
  3520. if err != nil {
  3521. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  3522. }
  3523. return oldValue.Content, nil
  3524. }
  3525. // ResetContent resets all changes to the "content" field.
  3526. func (m *MessageMutation) ResetContent() {
  3527. m.content = nil
  3528. }
  3529. // Where appends a list predicates to the MessageMutation builder.
  3530. func (m *MessageMutation) Where(ps ...predicate.Message) {
  3531. m.predicates = append(m.predicates, ps...)
  3532. }
  3533. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  3534. // users can use type-assertion to append predicates that do not depend on any generated package.
  3535. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  3536. p := make([]predicate.Message, len(ps))
  3537. for i := range ps {
  3538. p[i] = ps[i]
  3539. }
  3540. m.Where(p...)
  3541. }
  3542. // Op returns the operation name.
  3543. func (m *MessageMutation) Op() Op {
  3544. return m.op
  3545. }
  3546. // SetOp allows setting the mutation operation.
  3547. func (m *MessageMutation) SetOp(op Op) {
  3548. m.op = op
  3549. }
  3550. // Type returns the node type of this mutation (Message).
  3551. func (m *MessageMutation) Type() string {
  3552. return m.typ
  3553. }
  3554. // Fields returns all fields that were changed during this mutation. Note that in
  3555. // order to get all numeric fields that were incremented/decremented, call
  3556. // AddedFields().
  3557. func (m *MessageMutation) Fields() []string {
  3558. fields := make([]string, 0, 3)
  3559. if m.wx_wxid != nil {
  3560. fields = append(fields, message.FieldWxWxid)
  3561. }
  3562. if m.wxid != nil {
  3563. fields = append(fields, message.FieldWxid)
  3564. }
  3565. if m.content != nil {
  3566. fields = append(fields, message.FieldContent)
  3567. }
  3568. return fields
  3569. }
  3570. // Field returns the value of a field with the given name. The second boolean
  3571. // return value indicates that this field was not set, or was not defined in the
  3572. // schema.
  3573. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  3574. switch name {
  3575. case message.FieldWxWxid:
  3576. return m.WxWxid()
  3577. case message.FieldWxid:
  3578. return m.Wxid()
  3579. case message.FieldContent:
  3580. return m.Content()
  3581. }
  3582. return nil, false
  3583. }
  3584. // OldField returns the old value of the field from the database. An error is
  3585. // returned if the mutation operation is not UpdateOne, or the query to the
  3586. // database failed.
  3587. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3588. switch name {
  3589. case message.FieldWxWxid:
  3590. return m.OldWxWxid(ctx)
  3591. case message.FieldWxid:
  3592. return m.OldWxid(ctx)
  3593. case message.FieldContent:
  3594. return m.OldContent(ctx)
  3595. }
  3596. return nil, fmt.Errorf("unknown Message field %s", name)
  3597. }
  3598. // SetField sets the value of a field with the given name. It returns an error if
  3599. // the field is not defined in the schema, or if the type mismatched the field
  3600. // type.
  3601. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  3602. switch name {
  3603. case message.FieldWxWxid:
  3604. v, ok := value.(string)
  3605. if !ok {
  3606. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3607. }
  3608. m.SetWxWxid(v)
  3609. return nil
  3610. case message.FieldWxid:
  3611. v, ok := value.(string)
  3612. if !ok {
  3613. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3614. }
  3615. m.SetWxid(v)
  3616. return nil
  3617. case message.FieldContent:
  3618. v, ok := value.(string)
  3619. if !ok {
  3620. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3621. }
  3622. m.SetContent(v)
  3623. return nil
  3624. }
  3625. return fmt.Errorf("unknown Message field %s", name)
  3626. }
  3627. // AddedFields returns all numeric fields that were incremented/decremented during
  3628. // this mutation.
  3629. func (m *MessageMutation) AddedFields() []string {
  3630. return nil
  3631. }
  3632. // AddedField returns the numeric value that was incremented/decremented on a field
  3633. // with the given name. The second boolean return value indicates that this field
  3634. // was not set, or was not defined in the schema.
  3635. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  3636. return nil, false
  3637. }
  3638. // AddField adds the value to the field with the given name. It returns an error if
  3639. // the field is not defined in the schema, or if the type mismatched the field
  3640. // type.
  3641. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  3642. switch name {
  3643. }
  3644. return fmt.Errorf("unknown Message numeric field %s", name)
  3645. }
  3646. // ClearedFields returns all nullable fields that were cleared during this
  3647. // mutation.
  3648. func (m *MessageMutation) ClearedFields() []string {
  3649. var fields []string
  3650. if m.FieldCleared(message.FieldWxWxid) {
  3651. fields = append(fields, message.FieldWxWxid)
  3652. }
  3653. return fields
  3654. }
  3655. // FieldCleared returns a boolean indicating if a field with the given name was
  3656. // cleared in this mutation.
  3657. func (m *MessageMutation) FieldCleared(name string) bool {
  3658. _, ok := m.clearedFields[name]
  3659. return ok
  3660. }
  3661. // ClearField clears the value of the field with the given name. It returns an
  3662. // error if the field is not defined in the schema.
  3663. func (m *MessageMutation) ClearField(name string) error {
  3664. switch name {
  3665. case message.FieldWxWxid:
  3666. m.ClearWxWxid()
  3667. return nil
  3668. }
  3669. return fmt.Errorf("unknown Message nullable field %s", name)
  3670. }
  3671. // ResetField resets all changes in the mutation for the field with the given name.
  3672. // It returns an error if the field is not defined in the schema.
  3673. func (m *MessageMutation) ResetField(name string) error {
  3674. switch name {
  3675. case message.FieldWxWxid:
  3676. m.ResetWxWxid()
  3677. return nil
  3678. case message.FieldWxid:
  3679. m.ResetWxid()
  3680. return nil
  3681. case message.FieldContent:
  3682. m.ResetContent()
  3683. return nil
  3684. }
  3685. return fmt.Errorf("unknown Message field %s", name)
  3686. }
  3687. // AddedEdges returns all edge names that were set/added in this mutation.
  3688. func (m *MessageMutation) AddedEdges() []string {
  3689. edges := make([]string, 0, 0)
  3690. return edges
  3691. }
  3692. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3693. // name in this mutation.
  3694. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  3695. return nil
  3696. }
  3697. // RemovedEdges returns all edge names that were removed in this mutation.
  3698. func (m *MessageMutation) RemovedEdges() []string {
  3699. edges := make([]string, 0, 0)
  3700. return edges
  3701. }
  3702. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3703. // the given name in this mutation.
  3704. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  3705. return nil
  3706. }
  3707. // ClearedEdges returns all edge names that were cleared in this mutation.
  3708. func (m *MessageMutation) ClearedEdges() []string {
  3709. edges := make([]string, 0, 0)
  3710. return edges
  3711. }
  3712. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3713. // was cleared in this mutation.
  3714. func (m *MessageMutation) EdgeCleared(name string) bool {
  3715. return false
  3716. }
  3717. // ClearEdge clears the value of the edge with the given name. It returns an error
  3718. // if that edge is not defined in the schema.
  3719. func (m *MessageMutation) ClearEdge(name string) error {
  3720. return fmt.Errorf("unknown Message unique edge %s", name)
  3721. }
  3722. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3723. // It returns an error if the edge is not defined in the schema.
  3724. func (m *MessageMutation) ResetEdge(name string) error {
  3725. return fmt.Errorf("unknown Message edge %s", name)
  3726. }
  3727. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  3728. type MessageRecordsMutation struct {
  3729. config
  3730. op Op
  3731. typ string
  3732. id *uint64
  3733. created_at *time.Time
  3734. updated_at *time.Time
  3735. status *uint8
  3736. addstatus *int8
  3737. deleted_at *time.Time
  3738. bot_wxid *string
  3739. contact_type *int
  3740. addcontact_type *int
  3741. contact_wxid *string
  3742. content_type *int
  3743. addcontent_type *int
  3744. content *string
  3745. error_detail *string
  3746. send_time *time.Time
  3747. source_type *int
  3748. addsource_type *int
  3749. clearedFields map[string]struct{}
  3750. sop_stage *uint64
  3751. clearedsop_stage bool
  3752. sop_node *uint64
  3753. clearedsop_node bool
  3754. message_contact *uint64
  3755. clearedmessage_contact bool
  3756. done bool
  3757. oldValue func(context.Context) (*MessageRecords, error)
  3758. predicates []predicate.MessageRecords
  3759. }
  3760. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  3761. // messagerecordsOption allows management of the mutation configuration using functional options.
  3762. type messagerecordsOption func(*MessageRecordsMutation)
  3763. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  3764. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  3765. m := &MessageRecordsMutation{
  3766. config: c,
  3767. op: op,
  3768. typ: TypeMessageRecords,
  3769. clearedFields: make(map[string]struct{}),
  3770. }
  3771. for _, opt := range opts {
  3772. opt(m)
  3773. }
  3774. return m
  3775. }
  3776. // withMessageRecordsID sets the ID field of the mutation.
  3777. func withMessageRecordsID(id uint64) messagerecordsOption {
  3778. return func(m *MessageRecordsMutation) {
  3779. var (
  3780. err error
  3781. once sync.Once
  3782. value *MessageRecords
  3783. )
  3784. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  3785. once.Do(func() {
  3786. if m.done {
  3787. err = errors.New("querying old values post mutation is not allowed")
  3788. } else {
  3789. value, err = m.Client().MessageRecords.Get(ctx, id)
  3790. }
  3791. })
  3792. return value, err
  3793. }
  3794. m.id = &id
  3795. }
  3796. }
  3797. // withMessageRecords sets the old MessageRecords of the mutation.
  3798. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  3799. return func(m *MessageRecordsMutation) {
  3800. m.oldValue = func(context.Context) (*MessageRecords, error) {
  3801. return node, nil
  3802. }
  3803. m.id = &node.ID
  3804. }
  3805. }
  3806. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3807. // executed in a transaction (ent.Tx), a transactional client is returned.
  3808. func (m MessageRecordsMutation) Client() *Client {
  3809. client := &Client{config: m.config}
  3810. client.init()
  3811. return client
  3812. }
  3813. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3814. // it returns an error otherwise.
  3815. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  3816. if _, ok := m.driver.(*txDriver); !ok {
  3817. return nil, errors.New("ent: mutation is not running in a transaction")
  3818. }
  3819. tx := &Tx{config: m.config}
  3820. tx.init()
  3821. return tx, nil
  3822. }
  3823. // SetID sets the value of the id field. Note that this
  3824. // operation is only accepted on creation of MessageRecords entities.
  3825. func (m *MessageRecordsMutation) SetID(id uint64) {
  3826. m.id = &id
  3827. }
  3828. // ID returns the ID value in the mutation. Note that the ID is only available
  3829. // if it was provided to the builder or after it was returned from the database.
  3830. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  3831. if m.id == nil {
  3832. return
  3833. }
  3834. return *m.id, true
  3835. }
  3836. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3837. // That means, if the mutation is applied within a transaction with an isolation level such
  3838. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3839. // or updated by the mutation.
  3840. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  3841. switch {
  3842. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3843. id, exists := m.ID()
  3844. if exists {
  3845. return []uint64{id}, nil
  3846. }
  3847. fallthrough
  3848. case m.op.Is(OpUpdate | OpDelete):
  3849. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  3850. default:
  3851. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3852. }
  3853. }
  3854. // SetCreatedAt sets the "created_at" field.
  3855. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  3856. m.created_at = &t
  3857. }
  3858. // CreatedAt returns the value of the "created_at" field in the mutation.
  3859. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  3860. v := m.created_at
  3861. if v == nil {
  3862. return
  3863. }
  3864. return *v, true
  3865. }
  3866. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  3867. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  3868. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3869. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3870. if !m.op.Is(OpUpdateOne) {
  3871. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3872. }
  3873. if m.id == nil || m.oldValue == nil {
  3874. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3875. }
  3876. oldValue, err := m.oldValue(ctx)
  3877. if err != nil {
  3878. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3879. }
  3880. return oldValue.CreatedAt, nil
  3881. }
  3882. // ResetCreatedAt resets all changes to the "created_at" field.
  3883. func (m *MessageRecordsMutation) ResetCreatedAt() {
  3884. m.created_at = nil
  3885. }
  3886. // SetUpdatedAt sets the "updated_at" field.
  3887. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  3888. m.updated_at = &t
  3889. }
  3890. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3891. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  3892. v := m.updated_at
  3893. if v == nil {
  3894. return
  3895. }
  3896. return *v, true
  3897. }
  3898. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  3899. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  3900. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3901. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3902. if !m.op.Is(OpUpdateOne) {
  3903. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3904. }
  3905. if m.id == nil || m.oldValue == nil {
  3906. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3907. }
  3908. oldValue, err := m.oldValue(ctx)
  3909. if err != nil {
  3910. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3911. }
  3912. return oldValue.UpdatedAt, nil
  3913. }
  3914. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3915. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  3916. m.updated_at = nil
  3917. }
  3918. // SetStatus sets the "status" field.
  3919. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  3920. m.status = &u
  3921. m.addstatus = nil
  3922. }
  3923. // Status returns the value of the "status" field in the mutation.
  3924. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  3925. v := m.status
  3926. if v == nil {
  3927. return
  3928. }
  3929. return *v, true
  3930. }
  3931. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  3932. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  3933. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3934. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  3935. if !m.op.Is(OpUpdateOne) {
  3936. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3937. }
  3938. if m.id == nil || m.oldValue == nil {
  3939. return v, errors.New("OldStatus requires an ID field in the mutation")
  3940. }
  3941. oldValue, err := m.oldValue(ctx)
  3942. if err != nil {
  3943. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3944. }
  3945. return oldValue.Status, nil
  3946. }
  3947. // AddStatus adds u to the "status" field.
  3948. func (m *MessageRecordsMutation) AddStatus(u int8) {
  3949. if m.addstatus != nil {
  3950. *m.addstatus += u
  3951. } else {
  3952. m.addstatus = &u
  3953. }
  3954. }
  3955. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3956. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  3957. v := m.addstatus
  3958. if v == nil {
  3959. return
  3960. }
  3961. return *v, true
  3962. }
  3963. // ClearStatus clears the value of the "status" field.
  3964. func (m *MessageRecordsMutation) ClearStatus() {
  3965. m.status = nil
  3966. m.addstatus = nil
  3967. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  3968. }
  3969. // StatusCleared returns if the "status" field was cleared in this mutation.
  3970. func (m *MessageRecordsMutation) StatusCleared() bool {
  3971. _, ok := m.clearedFields[messagerecords.FieldStatus]
  3972. return ok
  3973. }
  3974. // ResetStatus resets all changes to the "status" field.
  3975. func (m *MessageRecordsMutation) ResetStatus() {
  3976. m.status = nil
  3977. m.addstatus = nil
  3978. delete(m.clearedFields, messagerecords.FieldStatus)
  3979. }
  3980. // SetDeletedAt sets the "deleted_at" field.
  3981. func (m *MessageRecordsMutation) SetDeletedAt(t time.Time) {
  3982. m.deleted_at = &t
  3983. }
  3984. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3985. func (m *MessageRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  3986. v := m.deleted_at
  3987. if v == nil {
  3988. return
  3989. }
  3990. return *v, true
  3991. }
  3992. // OldDeletedAt returns the old "deleted_at" field's value of the MessageRecords entity.
  3993. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  3994. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3995. func (m *MessageRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3996. if !m.op.Is(OpUpdateOne) {
  3997. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3998. }
  3999. if m.id == nil || m.oldValue == nil {
  4000. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4001. }
  4002. oldValue, err := m.oldValue(ctx)
  4003. if err != nil {
  4004. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4005. }
  4006. return oldValue.DeletedAt, nil
  4007. }
  4008. // ClearDeletedAt clears the value of the "deleted_at" field.
  4009. func (m *MessageRecordsMutation) ClearDeletedAt() {
  4010. m.deleted_at = nil
  4011. m.clearedFields[messagerecords.FieldDeletedAt] = struct{}{}
  4012. }
  4013. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4014. func (m *MessageRecordsMutation) DeletedAtCleared() bool {
  4015. _, ok := m.clearedFields[messagerecords.FieldDeletedAt]
  4016. return ok
  4017. }
  4018. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4019. func (m *MessageRecordsMutation) ResetDeletedAt() {
  4020. m.deleted_at = nil
  4021. delete(m.clearedFields, messagerecords.FieldDeletedAt)
  4022. }
  4023. // SetBotWxid sets the "bot_wxid" field.
  4024. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  4025. m.bot_wxid = &s
  4026. }
  4027. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  4028. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  4029. v := m.bot_wxid
  4030. if v == nil {
  4031. return
  4032. }
  4033. return *v, true
  4034. }
  4035. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  4036. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  4037. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4038. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  4039. if !m.op.Is(OpUpdateOne) {
  4040. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  4041. }
  4042. if m.id == nil || m.oldValue == nil {
  4043. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  4044. }
  4045. oldValue, err := m.oldValue(ctx)
  4046. if err != nil {
  4047. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  4048. }
  4049. return oldValue.BotWxid, nil
  4050. }
  4051. // ResetBotWxid resets all changes to the "bot_wxid" field.
  4052. func (m *MessageRecordsMutation) ResetBotWxid() {
  4053. m.bot_wxid = nil
  4054. }
  4055. // SetContactID sets the "contact_id" field.
  4056. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  4057. m.message_contact = &u
  4058. }
  4059. // ContactID returns the value of the "contact_id" field in the mutation.
  4060. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  4061. v := m.message_contact
  4062. if v == nil {
  4063. return
  4064. }
  4065. return *v, true
  4066. }
  4067. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  4068. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  4069. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4070. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  4071. if !m.op.Is(OpUpdateOne) {
  4072. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  4073. }
  4074. if m.id == nil || m.oldValue == nil {
  4075. return v, errors.New("OldContactID requires an ID field in the mutation")
  4076. }
  4077. oldValue, err := m.oldValue(ctx)
  4078. if err != nil {
  4079. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  4080. }
  4081. return oldValue.ContactID, nil
  4082. }
  4083. // ClearContactID clears the value of the "contact_id" field.
  4084. func (m *MessageRecordsMutation) ClearContactID() {
  4085. m.message_contact = nil
  4086. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  4087. }
  4088. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  4089. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  4090. _, ok := m.clearedFields[messagerecords.FieldContactID]
  4091. return ok
  4092. }
  4093. // ResetContactID resets all changes to the "contact_id" field.
  4094. func (m *MessageRecordsMutation) ResetContactID() {
  4095. m.message_contact = nil
  4096. delete(m.clearedFields, messagerecords.FieldContactID)
  4097. }
  4098. // SetContactType sets the "contact_type" field.
  4099. func (m *MessageRecordsMutation) SetContactType(i int) {
  4100. m.contact_type = &i
  4101. m.addcontact_type = nil
  4102. }
  4103. // ContactType returns the value of the "contact_type" field in the mutation.
  4104. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  4105. v := m.contact_type
  4106. if v == nil {
  4107. return
  4108. }
  4109. return *v, true
  4110. }
  4111. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  4112. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  4113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4114. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  4115. if !m.op.Is(OpUpdateOne) {
  4116. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  4117. }
  4118. if m.id == nil || m.oldValue == nil {
  4119. return v, errors.New("OldContactType requires an ID field in the mutation")
  4120. }
  4121. oldValue, err := m.oldValue(ctx)
  4122. if err != nil {
  4123. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  4124. }
  4125. return oldValue.ContactType, nil
  4126. }
  4127. // AddContactType adds i to the "contact_type" field.
  4128. func (m *MessageRecordsMutation) AddContactType(i int) {
  4129. if m.addcontact_type != nil {
  4130. *m.addcontact_type += i
  4131. } else {
  4132. m.addcontact_type = &i
  4133. }
  4134. }
  4135. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  4136. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  4137. v := m.addcontact_type
  4138. if v == nil {
  4139. return
  4140. }
  4141. return *v, true
  4142. }
  4143. // ResetContactType resets all changes to the "contact_type" field.
  4144. func (m *MessageRecordsMutation) ResetContactType() {
  4145. m.contact_type = nil
  4146. m.addcontact_type = nil
  4147. }
  4148. // SetContactWxid sets the "contact_wxid" field.
  4149. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  4150. m.contact_wxid = &s
  4151. }
  4152. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  4153. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  4154. v := m.contact_wxid
  4155. if v == nil {
  4156. return
  4157. }
  4158. return *v, true
  4159. }
  4160. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  4161. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  4162. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4163. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  4164. if !m.op.Is(OpUpdateOne) {
  4165. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  4166. }
  4167. if m.id == nil || m.oldValue == nil {
  4168. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  4169. }
  4170. oldValue, err := m.oldValue(ctx)
  4171. if err != nil {
  4172. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  4173. }
  4174. return oldValue.ContactWxid, nil
  4175. }
  4176. // ResetContactWxid resets all changes to the "contact_wxid" field.
  4177. func (m *MessageRecordsMutation) ResetContactWxid() {
  4178. m.contact_wxid = nil
  4179. }
  4180. // SetContentType sets the "content_type" field.
  4181. func (m *MessageRecordsMutation) SetContentType(i int) {
  4182. m.content_type = &i
  4183. m.addcontent_type = nil
  4184. }
  4185. // ContentType returns the value of the "content_type" field in the mutation.
  4186. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  4187. v := m.content_type
  4188. if v == nil {
  4189. return
  4190. }
  4191. return *v, true
  4192. }
  4193. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  4194. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  4195. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4196. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  4197. if !m.op.Is(OpUpdateOne) {
  4198. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  4199. }
  4200. if m.id == nil || m.oldValue == nil {
  4201. return v, errors.New("OldContentType requires an ID field in the mutation")
  4202. }
  4203. oldValue, err := m.oldValue(ctx)
  4204. if err != nil {
  4205. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  4206. }
  4207. return oldValue.ContentType, nil
  4208. }
  4209. // AddContentType adds i to the "content_type" field.
  4210. func (m *MessageRecordsMutation) AddContentType(i int) {
  4211. if m.addcontent_type != nil {
  4212. *m.addcontent_type += i
  4213. } else {
  4214. m.addcontent_type = &i
  4215. }
  4216. }
  4217. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  4218. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  4219. v := m.addcontent_type
  4220. if v == nil {
  4221. return
  4222. }
  4223. return *v, true
  4224. }
  4225. // ResetContentType resets all changes to the "content_type" field.
  4226. func (m *MessageRecordsMutation) ResetContentType() {
  4227. m.content_type = nil
  4228. m.addcontent_type = nil
  4229. }
  4230. // SetContent sets the "content" field.
  4231. func (m *MessageRecordsMutation) SetContent(s string) {
  4232. m.content = &s
  4233. }
  4234. // Content returns the value of the "content" field in the mutation.
  4235. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  4236. v := m.content
  4237. if v == nil {
  4238. return
  4239. }
  4240. return *v, true
  4241. }
  4242. // OldContent returns the old "content" field's value of the MessageRecords entity.
  4243. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  4244. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4245. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  4246. if !m.op.Is(OpUpdateOne) {
  4247. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  4248. }
  4249. if m.id == nil || m.oldValue == nil {
  4250. return v, errors.New("OldContent requires an ID field in the mutation")
  4251. }
  4252. oldValue, err := m.oldValue(ctx)
  4253. if err != nil {
  4254. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  4255. }
  4256. return oldValue.Content, nil
  4257. }
  4258. // ResetContent resets all changes to the "content" field.
  4259. func (m *MessageRecordsMutation) ResetContent() {
  4260. m.content = nil
  4261. }
  4262. // SetErrorDetail sets the "error_detail" field.
  4263. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  4264. m.error_detail = &s
  4265. }
  4266. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  4267. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  4268. v := m.error_detail
  4269. if v == nil {
  4270. return
  4271. }
  4272. return *v, true
  4273. }
  4274. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  4275. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  4276. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4277. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  4278. if !m.op.Is(OpUpdateOne) {
  4279. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  4280. }
  4281. if m.id == nil || m.oldValue == nil {
  4282. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  4283. }
  4284. oldValue, err := m.oldValue(ctx)
  4285. if err != nil {
  4286. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  4287. }
  4288. return oldValue.ErrorDetail, nil
  4289. }
  4290. // ResetErrorDetail resets all changes to the "error_detail" field.
  4291. func (m *MessageRecordsMutation) ResetErrorDetail() {
  4292. m.error_detail = nil
  4293. }
  4294. // SetSendTime sets the "send_time" field.
  4295. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  4296. m.send_time = &t
  4297. }
  4298. // SendTime returns the value of the "send_time" field in the mutation.
  4299. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  4300. v := m.send_time
  4301. if v == nil {
  4302. return
  4303. }
  4304. return *v, true
  4305. }
  4306. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  4307. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  4308. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4309. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  4310. if !m.op.Is(OpUpdateOne) {
  4311. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  4312. }
  4313. if m.id == nil || m.oldValue == nil {
  4314. return v, errors.New("OldSendTime requires an ID field in the mutation")
  4315. }
  4316. oldValue, err := m.oldValue(ctx)
  4317. if err != nil {
  4318. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  4319. }
  4320. return oldValue.SendTime, nil
  4321. }
  4322. // ClearSendTime clears the value of the "send_time" field.
  4323. func (m *MessageRecordsMutation) ClearSendTime() {
  4324. m.send_time = nil
  4325. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  4326. }
  4327. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  4328. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  4329. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  4330. return ok
  4331. }
  4332. // ResetSendTime resets all changes to the "send_time" field.
  4333. func (m *MessageRecordsMutation) ResetSendTime() {
  4334. m.send_time = nil
  4335. delete(m.clearedFields, messagerecords.FieldSendTime)
  4336. }
  4337. // SetSourceType sets the "source_type" field.
  4338. func (m *MessageRecordsMutation) SetSourceType(i int) {
  4339. m.source_type = &i
  4340. m.addsource_type = nil
  4341. }
  4342. // SourceType returns the value of the "source_type" field in the mutation.
  4343. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  4344. v := m.source_type
  4345. if v == nil {
  4346. return
  4347. }
  4348. return *v, true
  4349. }
  4350. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  4351. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  4352. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4353. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  4354. if !m.op.Is(OpUpdateOne) {
  4355. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  4356. }
  4357. if m.id == nil || m.oldValue == nil {
  4358. return v, errors.New("OldSourceType requires an ID field in the mutation")
  4359. }
  4360. oldValue, err := m.oldValue(ctx)
  4361. if err != nil {
  4362. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  4363. }
  4364. return oldValue.SourceType, nil
  4365. }
  4366. // AddSourceType adds i to the "source_type" field.
  4367. func (m *MessageRecordsMutation) AddSourceType(i int) {
  4368. if m.addsource_type != nil {
  4369. *m.addsource_type += i
  4370. } else {
  4371. m.addsource_type = &i
  4372. }
  4373. }
  4374. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  4375. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  4376. v := m.addsource_type
  4377. if v == nil {
  4378. return
  4379. }
  4380. return *v, true
  4381. }
  4382. // ResetSourceType resets all changes to the "source_type" field.
  4383. func (m *MessageRecordsMutation) ResetSourceType() {
  4384. m.source_type = nil
  4385. m.addsource_type = nil
  4386. }
  4387. // SetSourceID sets the "source_id" field.
  4388. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  4389. m.sop_stage = &u
  4390. }
  4391. // SourceID returns the value of the "source_id" field in the mutation.
  4392. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  4393. v := m.sop_stage
  4394. if v == nil {
  4395. return
  4396. }
  4397. return *v, true
  4398. }
  4399. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  4400. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  4401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4402. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  4403. if !m.op.Is(OpUpdateOne) {
  4404. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  4405. }
  4406. if m.id == nil || m.oldValue == nil {
  4407. return v, errors.New("OldSourceID requires an ID field in the mutation")
  4408. }
  4409. oldValue, err := m.oldValue(ctx)
  4410. if err != nil {
  4411. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  4412. }
  4413. return oldValue.SourceID, nil
  4414. }
  4415. // ClearSourceID clears the value of the "source_id" field.
  4416. func (m *MessageRecordsMutation) ClearSourceID() {
  4417. m.sop_stage = nil
  4418. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  4419. }
  4420. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  4421. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  4422. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  4423. return ok
  4424. }
  4425. // ResetSourceID resets all changes to the "source_id" field.
  4426. func (m *MessageRecordsMutation) ResetSourceID() {
  4427. m.sop_stage = nil
  4428. delete(m.clearedFields, messagerecords.FieldSourceID)
  4429. }
  4430. // SetSubSourceID sets the "sub_source_id" field.
  4431. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  4432. m.sop_node = &u
  4433. }
  4434. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  4435. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  4436. v := m.sop_node
  4437. if v == nil {
  4438. return
  4439. }
  4440. return *v, true
  4441. }
  4442. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  4443. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  4444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4445. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  4446. if !m.op.Is(OpUpdateOne) {
  4447. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  4448. }
  4449. if m.id == nil || m.oldValue == nil {
  4450. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  4451. }
  4452. oldValue, err := m.oldValue(ctx)
  4453. if err != nil {
  4454. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  4455. }
  4456. return oldValue.SubSourceID, nil
  4457. }
  4458. // ClearSubSourceID clears the value of the "sub_source_id" field.
  4459. func (m *MessageRecordsMutation) ClearSubSourceID() {
  4460. m.sop_node = nil
  4461. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  4462. }
  4463. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  4464. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  4465. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  4466. return ok
  4467. }
  4468. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  4469. func (m *MessageRecordsMutation) ResetSubSourceID() {
  4470. m.sop_node = nil
  4471. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  4472. }
  4473. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  4474. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  4475. m.sop_stage = &id
  4476. }
  4477. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  4478. func (m *MessageRecordsMutation) ClearSopStage() {
  4479. m.clearedsop_stage = true
  4480. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  4481. }
  4482. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  4483. func (m *MessageRecordsMutation) SopStageCleared() bool {
  4484. return m.SourceIDCleared() || m.clearedsop_stage
  4485. }
  4486. // SopStageID returns the "sop_stage" edge ID in the mutation.
  4487. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  4488. if m.sop_stage != nil {
  4489. return *m.sop_stage, true
  4490. }
  4491. return
  4492. }
  4493. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  4494. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  4495. // SopStageID instead. It exists only for internal usage by the builders.
  4496. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  4497. if id := m.sop_stage; id != nil {
  4498. ids = append(ids, *id)
  4499. }
  4500. return
  4501. }
  4502. // ResetSopStage resets all changes to the "sop_stage" edge.
  4503. func (m *MessageRecordsMutation) ResetSopStage() {
  4504. m.sop_stage = nil
  4505. m.clearedsop_stage = false
  4506. }
  4507. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  4508. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  4509. m.sop_node = &id
  4510. }
  4511. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  4512. func (m *MessageRecordsMutation) ClearSopNode() {
  4513. m.clearedsop_node = true
  4514. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  4515. }
  4516. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  4517. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  4518. return m.SubSourceIDCleared() || m.clearedsop_node
  4519. }
  4520. // SopNodeID returns the "sop_node" edge ID in the mutation.
  4521. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  4522. if m.sop_node != nil {
  4523. return *m.sop_node, true
  4524. }
  4525. return
  4526. }
  4527. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  4528. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  4529. // SopNodeID instead. It exists only for internal usage by the builders.
  4530. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  4531. if id := m.sop_node; id != nil {
  4532. ids = append(ids, *id)
  4533. }
  4534. return
  4535. }
  4536. // ResetSopNode resets all changes to the "sop_node" edge.
  4537. func (m *MessageRecordsMutation) ResetSopNode() {
  4538. m.sop_node = nil
  4539. m.clearedsop_node = false
  4540. }
  4541. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  4542. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  4543. m.message_contact = &id
  4544. }
  4545. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  4546. func (m *MessageRecordsMutation) ClearMessageContact() {
  4547. m.clearedmessage_contact = true
  4548. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  4549. }
  4550. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  4551. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  4552. return m.ContactIDCleared() || m.clearedmessage_contact
  4553. }
  4554. // MessageContactID returns the "message_contact" edge ID in the mutation.
  4555. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  4556. if m.message_contact != nil {
  4557. return *m.message_contact, true
  4558. }
  4559. return
  4560. }
  4561. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  4562. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  4563. // MessageContactID instead. It exists only for internal usage by the builders.
  4564. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  4565. if id := m.message_contact; id != nil {
  4566. ids = append(ids, *id)
  4567. }
  4568. return
  4569. }
  4570. // ResetMessageContact resets all changes to the "message_contact" edge.
  4571. func (m *MessageRecordsMutation) ResetMessageContact() {
  4572. m.message_contact = nil
  4573. m.clearedmessage_contact = false
  4574. }
  4575. // Where appends a list predicates to the MessageRecordsMutation builder.
  4576. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  4577. m.predicates = append(m.predicates, ps...)
  4578. }
  4579. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  4580. // users can use type-assertion to append predicates that do not depend on any generated package.
  4581. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  4582. p := make([]predicate.MessageRecords, len(ps))
  4583. for i := range ps {
  4584. p[i] = ps[i]
  4585. }
  4586. m.Where(p...)
  4587. }
  4588. // Op returns the operation name.
  4589. func (m *MessageRecordsMutation) Op() Op {
  4590. return m.op
  4591. }
  4592. // SetOp allows setting the mutation operation.
  4593. func (m *MessageRecordsMutation) SetOp(op Op) {
  4594. m.op = op
  4595. }
  4596. // Type returns the node type of this mutation (MessageRecords).
  4597. func (m *MessageRecordsMutation) Type() string {
  4598. return m.typ
  4599. }
  4600. // Fields returns all fields that were changed during this mutation. Note that in
  4601. // order to get all numeric fields that were incremented/decremented, call
  4602. // AddedFields().
  4603. func (m *MessageRecordsMutation) Fields() []string {
  4604. fields := make([]string, 0, 15)
  4605. if m.created_at != nil {
  4606. fields = append(fields, messagerecords.FieldCreatedAt)
  4607. }
  4608. if m.updated_at != nil {
  4609. fields = append(fields, messagerecords.FieldUpdatedAt)
  4610. }
  4611. if m.status != nil {
  4612. fields = append(fields, messagerecords.FieldStatus)
  4613. }
  4614. if m.deleted_at != nil {
  4615. fields = append(fields, messagerecords.FieldDeletedAt)
  4616. }
  4617. if m.bot_wxid != nil {
  4618. fields = append(fields, messagerecords.FieldBotWxid)
  4619. }
  4620. if m.message_contact != nil {
  4621. fields = append(fields, messagerecords.FieldContactID)
  4622. }
  4623. if m.contact_type != nil {
  4624. fields = append(fields, messagerecords.FieldContactType)
  4625. }
  4626. if m.contact_wxid != nil {
  4627. fields = append(fields, messagerecords.FieldContactWxid)
  4628. }
  4629. if m.content_type != nil {
  4630. fields = append(fields, messagerecords.FieldContentType)
  4631. }
  4632. if m.content != nil {
  4633. fields = append(fields, messagerecords.FieldContent)
  4634. }
  4635. if m.error_detail != nil {
  4636. fields = append(fields, messagerecords.FieldErrorDetail)
  4637. }
  4638. if m.send_time != nil {
  4639. fields = append(fields, messagerecords.FieldSendTime)
  4640. }
  4641. if m.source_type != nil {
  4642. fields = append(fields, messagerecords.FieldSourceType)
  4643. }
  4644. if m.sop_stage != nil {
  4645. fields = append(fields, messagerecords.FieldSourceID)
  4646. }
  4647. if m.sop_node != nil {
  4648. fields = append(fields, messagerecords.FieldSubSourceID)
  4649. }
  4650. return fields
  4651. }
  4652. // Field returns the value of a field with the given name. The second boolean
  4653. // return value indicates that this field was not set, or was not defined in the
  4654. // schema.
  4655. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  4656. switch name {
  4657. case messagerecords.FieldCreatedAt:
  4658. return m.CreatedAt()
  4659. case messagerecords.FieldUpdatedAt:
  4660. return m.UpdatedAt()
  4661. case messagerecords.FieldStatus:
  4662. return m.Status()
  4663. case messagerecords.FieldDeletedAt:
  4664. return m.DeletedAt()
  4665. case messagerecords.FieldBotWxid:
  4666. return m.BotWxid()
  4667. case messagerecords.FieldContactID:
  4668. return m.ContactID()
  4669. case messagerecords.FieldContactType:
  4670. return m.ContactType()
  4671. case messagerecords.FieldContactWxid:
  4672. return m.ContactWxid()
  4673. case messagerecords.FieldContentType:
  4674. return m.ContentType()
  4675. case messagerecords.FieldContent:
  4676. return m.Content()
  4677. case messagerecords.FieldErrorDetail:
  4678. return m.ErrorDetail()
  4679. case messagerecords.FieldSendTime:
  4680. return m.SendTime()
  4681. case messagerecords.FieldSourceType:
  4682. return m.SourceType()
  4683. case messagerecords.FieldSourceID:
  4684. return m.SourceID()
  4685. case messagerecords.FieldSubSourceID:
  4686. return m.SubSourceID()
  4687. }
  4688. return nil, false
  4689. }
  4690. // OldField returns the old value of the field from the database. An error is
  4691. // returned if the mutation operation is not UpdateOne, or the query to the
  4692. // database failed.
  4693. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4694. switch name {
  4695. case messagerecords.FieldCreatedAt:
  4696. return m.OldCreatedAt(ctx)
  4697. case messagerecords.FieldUpdatedAt:
  4698. return m.OldUpdatedAt(ctx)
  4699. case messagerecords.FieldStatus:
  4700. return m.OldStatus(ctx)
  4701. case messagerecords.FieldDeletedAt:
  4702. return m.OldDeletedAt(ctx)
  4703. case messagerecords.FieldBotWxid:
  4704. return m.OldBotWxid(ctx)
  4705. case messagerecords.FieldContactID:
  4706. return m.OldContactID(ctx)
  4707. case messagerecords.FieldContactType:
  4708. return m.OldContactType(ctx)
  4709. case messagerecords.FieldContactWxid:
  4710. return m.OldContactWxid(ctx)
  4711. case messagerecords.FieldContentType:
  4712. return m.OldContentType(ctx)
  4713. case messagerecords.FieldContent:
  4714. return m.OldContent(ctx)
  4715. case messagerecords.FieldErrorDetail:
  4716. return m.OldErrorDetail(ctx)
  4717. case messagerecords.FieldSendTime:
  4718. return m.OldSendTime(ctx)
  4719. case messagerecords.FieldSourceType:
  4720. return m.OldSourceType(ctx)
  4721. case messagerecords.FieldSourceID:
  4722. return m.OldSourceID(ctx)
  4723. case messagerecords.FieldSubSourceID:
  4724. return m.OldSubSourceID(ctx)
  4725. }
  4726. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  4727. }
  4728. // SetField sets the value of a field with the given name. It returns an error if
  4729. // the field is not defined in the schema, or if the type mismatched the field
  4730. // type.
  4731. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  4732. switch name {
  4733. case messagerecords.FieldCreatedAt:
  4734. v, ok := value.(time.Time)
  4735. if !ok {
  4736. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4737. }
  4738. m.SetCreatedAt(v)
  4739. return nil
  4740. case messagerecords.FieldUpdatedAt:
  4741. v, ok := value.(time.Time)
  4742. if !ok {
  4743. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4744. }
  4745. m.SetUpdatedAt(v)
  4746. return nil
  4747. case messagerecords.FieldStatus:
  4748. v, ok := value.(uint8)
  4749. if !ok {
  4750. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4751. }
  4752. m.SetStatus(v)
  4753. return nil
  4754. case messagerecords.FieldDeletedAt:
  4755. v, ok := value.(time.Time)
  4756. if !ok {
  4757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4758. }
  4759. m.SetDeletedAt(v)
  4760. return nil
  4761. case messagerecords.FieldBotWxid:
  4762. v, ok := value.(string)
  4763. if !ok {
  4764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4765. }
  4766. m.SetBotWxid(v)
  4767. return nil
  4768. case messagerecords.FieldContactID:
  4769. v, ok := value.(uint64)
  4770. if !ok {
  4771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4772. }
  4773. m.SetContactID(v)
  4774. return nil
  4775. case messagerecords.FieldContactType:
  4776. v, ok := value.(int)
  4777. if !ok {
  4778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4779. }
  4780. m.SetContactType(v)
  4781. return nil
  4782. case messagerecords.FieldContactWxid:
  4783. v, ok := value.(string)
  4784. if !ok {
  4785. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4786. }
  4787. m.SetContactWxid(v)
  4788. return nil
  4789. case messagerecords.FieldContentType:
  4790. v, ok := value.(int)
  4791. if !ok {
  4792. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4793. }
  4794. m.SetContentType(v)
  4795. return nil
  4796. case messagerecords.FieldContent:
  4797. v, ok := value.(string)
  4798. if !ok {
  4799. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4800. }
  4801. m.SetContent(v)
  4802. return nil
  4803. case messagerecords.FieldErrorDetail:
  4804. v, ok := value.(string)
  4805. if !ok {
  4806. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4807. }
  4808. m.SetErrorDetail(v)
  4809. return nil
  4810. case messagerecords.FieldSendTime:
  4811. v, ok := value.(time.Time)
  4812. if !ok {
  4813. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4814. }
  4815. m.SetSendTime(v)
  4816. return nil
  4817. case messagerecords.FieldSourceType:
  4818. v, ok := value.(int)
  4819. if !ok {
  4820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4821. }
  4822. m.SetSourceType(v)
  4823. return nil
  4824. case messagerecords.FieldSourceID:
  4825. v, ok := value.(uint64)
  4826. if !ok {
  4827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4828. }
  4829. m.SetSourceID(v)
  4830. return nil
  4831. case messagerecords.FieldSubSourceID:
  4832. v, ok := value.(uint64)
  4833. if !ok {
  4834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4835. }
  4836. m.SetSubSourceID(v)
  4837. return nil
  4838. }
  4839. return fmt.Errorf("unknown MessageRecords field %s", name)
  4840. }
  4841. // AddedFields returns all numeric fields that were incremented/decremented during
  4842. // this mutation.
  4843. func (m *MessageRecordsMutation) AddedFields() []string {
  4844. var fields []string
  4845. if m.addstatus != nil {
  4846. fields = append(fields, messagerecords.FieldStatus)
  4847. }
  4848. if m.addcontact_type != nil {
  4849. fields = append(fields, messagerecords.FieldContactType)
  4850. }
  4851. if m.addcontent_type != nil {
  4852. fields = append(fields, messagerecords.FieldContentType)
  4853. }
  4854. if m.addsource_type != nil {
  4855. fields = append(fields, messagerecords.FieldSourceType)
  4856. }
  4857. return fields
  4858. }
  4859. // AddedField returns the numeric value that was incremented/decremented on a field
  4860. // with the given name. The second boolean return value indicates that this field
  4861. // was not set, or was not defined in the schema.
  4862. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  4863. switch name {
  4864. case messagerecords.FieldStatus:
  4865. return m.AddedStatus()
  4866. case messagerecords.FieldContactType:
  4867. return m.AddedContactType()
  4868. case messagerecords.FieldContentType:
  4869. return m.AddedContentType()
  4870. case messagerecords.FieldSourceType:
  4871. return m.AddedSourceType()
  4872. }
  4873. return nil, false
  4874. }
  4875. // AddField adds the value to the field with the given name. It returns an error if
  4876. // the field is not defined in the schema, or if the type mismatched the field
  4877. // type.
  4878. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  4879. switch name {
  4880. case messagerecords.FieldStatus:
  4881. v, ok := value.(int8)
  4882. if !ok {
  4883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4884. }
  4885. m.AddStatus(v)
  4886. return nil
  4887. case messagerecords.FieldContactType:
  4888. v, ok := value.(int)
  4889. if !ok {
  4890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4891. }
  4892. m.AddContactType(v)
  4893. return nil
  4894. case messagerecords.FieldContentType:
  4895. v, ok := value.(int)
  4896. if !ok {
  4897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4898. }
  4899. m.AddContentType(v)
  4900. return nil
  4901. case messagerecords.FieldSourceType:
  4902. v, ok := value.(int)
  4903. if !ok {
  4904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4905. }
  4906. m.AddSourceType(v)
  4907. return nil
  4908. }
  4909. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  4910. }
  4911. // ClearedFields returns all nullable fields that were cleared during this
  4912. // mutation.
  4913. func (m *MessageRecordsMutation) ClearedFields() []string {
  4914. var fields []string
  4915. if m.FieldCleared(messagerecords.FieldStatus) {
  4916. fields = append(fields, messagerecords.FieldStatus)
  4917. }
  4918. if m.FieldCleared(messagerecords.FieldDeletedAt) {
  4919. fields = append(fields, messagerecords.FieldDeletedAt)
  4920. }
  4921. if m.FieldCleared(messagerecords.FieldContactID) {
  4922. fields = append(fields, messagerecords.FieldContactID)
  4923. }
  4924. if m.FieldCleared(messagerecords.FieldSendTime) {
  4925. fields = append(fields, messagerecords.FieldSendTime)
  4926. }
  4927. if m.FieldCleared(messagerecords.FieldSourceID) {
  4928. fields = append(fields, messagerecords.FieldSourceID)
  4929. }
  4930. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  4931. fields = append(fields, messagerecords.FieldSubSourceID)
  4932. }
  4933. return fields
  4934. }
  4935. // FieldCleared returns a boolean indicating if a field with the given name was
  4936. // cleared in this mutation.
  4937. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  4938. _, ok := m.clearedFields[name]
  4939. return ok
  4940. }
  4941. // ClearField clears the value of the field with the given name. It returns an
  4942. // error if the field is not defined in the schema.
  4943. func (m *MessageRecordsMutation) ClearField(name string) error {
  4944. switch name {
  4945. case messagerecords.FieldStatus:
  4946. m.ClearStatus()
  4947. return nil
  4948. case messagerecords.FieldDeletedAt:
  4949. m.ClearDeletedAt()
  4950. return nil
  4951. case messagerecords.FieldContactID:
  4952. m.ClearContactID()
  4953. return nil
  4954. case messagerecords.FieldSendTime:
  4955. m.ClearSendTime()
  4956. return nil
  4957. case messagerecords.FieldSourceID:
  4958. m.ClearSourceID()
  4959. return nil
  4960. case messagerecords.FieldSubSourceID:
  4961. m.ClearSubSourceID()
  4962. return nil
  4963. }
  4964. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  4965. }
  4966. // ResetField resets all changes in the mutation for the field with the given name.
  4967. // It returns an error if the field is not defined in the schema.
  4968. func (m *MessageRecordsMutation) ResetField(name string) error {
  4969. switch name {
  4970. case messagerecords.FieldCreatedAt:
  4971. m.ResetCreatedAt()
  4972. return nil
  4973. case messagerecords.FieldUpdatedAt:
  4974. m.ResetUpdatedAt()
  4975. return nil
  4976. case messagerecords.FieldStatus:
  4977. m.ResetStatus()
  4978. return nil
  4979. case messagerecords.FieldDeletedAt:
  4980. m.ResetDeletedAt()
  4981. return nil
  4982. case messagerecords.FieldBotWxid:
  4983. m.ResetBotWxid()
  4984. return nil
  4985. case messagerecords.FieldContactID:
  4986. m.ResetContactID()
  4987. return nil
  4988. case messagerecords.FieldContactType:
  4989. m.ResetContactType()
  4990. return nil
  4991. case messagerecords.FieldContactWxid:
  4992. m.ResetContactWxid()
  4993. return nil
  4994. case messagerecords.FieldContentType:
  4995. m.ResetContentType()
  4996. return nil
  4997. case messagerecords.FieldContent:
  4998. m.ResetContent()
  4999. return nil
  5000. case messagerecords.FieldErrorDetail:
  5001. m.ResetErrorDetail()
  5002. return nil
  5003. case messagerecords.FieldSendTime:
  5004. m.ResetSendTime()
  5005. return nil
  5006. case messagerecords.FieldSourceType:
  5007. m.ResetSourceType()
  5008. return nil
  5009. case messagerecords.FieldSourceID:
  5010. m.ResetSourceID()
  5011. return nil
  5012. case messagerecords.FieldSubSourceID:
  5013. m.ResetSubSourceID()
  5014. return nil
  5015. }
  5016. return fmt.Errorf("unknown MessageRecords field %s", name)
  5017. }
  5018. // AddedEdges returns all edge names that were set/added in this mutation.
  5019. func (m *MessageRecordsMutation) AddedEdges() []string {
  5020. edges := make([]string, 0, 3)
  5021. if m.sop_stage != nil {
  5022. edges = append(edges, messagerecords.EdgeSopStage)
  5023. }
  5024. if m.sop_node != nil {
  5025. edges = append(edges, messagerecords.EdgeSopNode)
  5026. }
  5027. if m.message_contact != nil {
  5028. edges = append(edges, messagerecords.EdgeMessageContact)
  5029. }
  5030. return edges
  5031. }
  5032. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5033. // name in this mutation.
  5034. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  5035. switch name {
  5036. case messagerecords.EdgeSopStage:
  5037. if id := m.sop_stage; id != nil {
  5038. return []ent.Value{*id}
  5039. }
  5040. case messagerecords.EdgeSopNode:
  5041. if id := m.sop_node; id != nil {
  5042. return []ent.Value{*id}
  5043. }
  5044. case messagerecords.EdgeMessageContact:
  5045. if id := m.message_contact; id != nil {
  5046. return []ent.Value{*id}
  5047. }
  5048. }
  5049. return nil
  5050. }
  5051. // RemovedEdges returns all edge names that were removed in this mutation.
  5052. func (m *MessageRecordsMutation) RemovedEdges() []string {
  5053. edges := make([]string, 0, 3)
  5054. return edges
  5055. }
  5056. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5057. // the given name in this mutation.
  5058. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  5059. return nil
  5060. }
  5061. // ClearedEdges returns all edge names that were cleared in this mutation.
  5062. func (m *MessageRecordsMutation) ClearedEdges() []string {
  5063. edges := make([]string, 0, 3)
  5064. if m.clearedsop_stage {
  5065. edges = append(edges, messagerecords.EdgeSopStage)
  5066. }
  5067. if m.clearedsop_node {
  5068. edges = append(edges, messagerecords.EdgeSopNode)
  5069. }
  5070. if m.clearedmessage_contact {
  5071. edges = append(edges, messagerecords.EdgeMessageContact)
  5072. }
  5073. return edges
  5074. }
  5075. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5076. // was cleared in this mutation.
  5077. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  5078. switch name {
  5079. case messagerecords.EdgeSopStage:
  5080. return m.clearedsop_stage
  5081. case messagerecords.EdgeSopNode:
  5082. return m.clearedsop_node
  5083. case messagerecords.EdgeMessageContact:
  5084. return m.clearedmessage_contact
  5085. }
  5086. return false
  5087. }
  5088. // ClearEdge clears the value of the edge with the given name. It returns an error
  5089. // if that edge is not defined in the schema.
  5090. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  5091. switch name {
  5092. case messagerecords.EdgeSopStage:
  5093. m.ClearSopStage()
  5094. return nil
  5095. case messagerecords.EdgeSopNode:
  5096. m.ClearSopNode()
  5097. return nil
  5098. case messagerecords.EdgeMessageContact:
  5099. m.ClearMessageContact()
  5100. return nil
  5101. }
  5102. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  5103. }
  5104. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5105. // It returns an error if the edge is not defined in the schema.
  5106. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  5107. switch name {
  5108. case messagerecords.EdgeSopStage:
  5109. m.ResetSopStage()
  5110. return nil
  5111. case messagerecords.EdgeSopNode:
  5112. m.ResetSopNode()
  5113. return nil
  5114. case messagerecords.EdgeMessageContact:
  5115. m.ResetMessageContact()
  5116. return nil
  5117. }
  5118. return fmt.Errorf("unknown MessageRecords edge %s", name)
  5119. }
  5120. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  5121. type ServerMutation struct {
  5122. config
  5123. op Op
  5124. typ string
  5125. id *uint64
  5126. created_at *time.Time
  5127. updated_at *time.Time
  5128. status *uint8
  5129. addstatus *int8
  5130. deleted_at *time.Time
  5131. name *string
  5132. public_ip *string
  5133. private_ip *string
  5134. admin_port *string
  5135. clearedFields map[string]struct{}
  5136. wxs map[uint64]struct{}
  5137. removedwxs map[uint64]struct{}
  5138. clearedwxs bool
  5139. done bool
  5140. oldValue func(context.Context) (*Server, error)
  5141. predicates []predicate.Server
  5142. }
  5143. var _ ent.Mutation = (*ServerMutation)(nil)
  5144. // serverOption allows management of the mutation configuration using functional options.
  5145. type serverOption func(*ServerMutation)
  5146. // newServerMutation creates new mutation for the Server entity.
  5147. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  5148. m := &ServerMutation{
  5149. config: c,
  5150. op: op,
  5151. typ: TypeServer,
  5152. clearedFields: make(map[string]struct{}),
  5153. }
  5154. for _, opt := range opts {
  5155. opt(m)
  5156. }
  5157. return m
  5158. }
  5159. // withServerID sets the ID field of the mutation.
  5160. func withServerID(id uint64) serverOption {
  5161. return func(m *ServerMutation) {
  5162. var (
  5163. err error
  5164. once sync.Once
  5165. value *Server
  5166. )
  5167. m.oldValue = func(ctx context.Context) (*Server, error) {
  5168. once.Do(func() {
  5169. if m.done {
  5170. err = errors.New("querying old values post mutation is not allowed")
  5171. } else {
  5172. value, err = m.Client().Server.Get(ctx, id)
  5173. }
  5174. })
  5175. return value, err
  5176. }
  5177. m.id = &id
  5178. }
  5179. }
  5180. // withServer sets the old Server of the mutation.
  5181. func withServer(node *Server) serverOption {
  5182. return func(m *ServerMutation) {
  5183. m.oldValue = func(context.Context) (*Server, error) {
  5184. return node, nil
  5185. }
  5186. m.id = &node.ID
  5187. }
  5188. }
  5189. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5190. // executed in a transaction (ent.Tx), a transactional client is returned.
  5191. func (m ServerMutation) Client() *Client {
  5192. client := &Client{config: m.config}
  5193. client.init()
  5194. return client
  5195. }
  5196. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5197. // it returns an error otherwise.
  5198. func (m ServerMutation) Tx() (*Tx, error) {
  5199. if _, ok := m.driver.(*txDriver); !ok {
  5200. return nil, errors.New("ent: mutation is not running in a transaction")
  5201. }
  5202. tx := &Tx{config: m.config}
  5203. tx.init()
  5204. return tx, nil
  5205. }
  5206. // SetID sets the value of the id field. Note that this
  5207. // operation is only accepted on creation of Server entities.
  5208. func (m *ServerMutation) SetID(id uint64) {
  5209. m.id = &id
  5210. }
  5211. // ID returns the ID value in the mutation. Note that the ID is only available
  5212. // if it was provided to the builder or after it was returned from the database.
  5213. func (m *ServerMutation) ID() (id uint64, exists bool) {
  5214. if m.id == nil {
  5215. return
  5216. }
  5217. return *m.id, true
  5218. }
  5219. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5220. // That means, if the mutation is applied within a transaction with an isolation level such
  5221. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5222. // or updated by the mutation.
  5223. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  5224. switch {
  5225. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5226. id, exists := m.ID()
  5227. if exists {
  5228. return []uint64{id}, nil
  5229. }
  5230. fallthrough
  5231. case m.op.Is(OpUpdate | OpDelete):
  5232. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  5233. default:
  5234. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5235. }
  5236. }
  5237. // SetCreatedAt sets the "created_at" field.
  5238. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  5239. m.created_at = &t
  5240. }
  5241. // CreatedAt returns the value of the "created_at" field in the mutation.
  5242. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  5243. v := m.created_at
  5244. if v == nil {
  5245. return
  5246. }
  5247. return *v, true
  5248. }
  5249. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  5250. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  5251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5252. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5253. if !m.op.Is(OpUpdateOne) {
  5254. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5255. }
  5256. if m.id == nil || m.oldValue == nil {
  5257. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5258. }
  5259. oldValue, err := m.oldValue(ctx)
  5260. if err != nil {
  5261. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5262. }
  5263. return oldValue.CreatedAt, nil
  5264. }
  5265. // ResetCreatedAt resets all changes to the "created_at" field.
  5266. func (m *ServerMutation) ResetCreatedAt() {
  5267. m.created_at = nil
  5268. }
  5269. // SetUpdatedAt sets the "updated_at" field.
  5270. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  5271. m.updated_at = &t
  5272. }
  5273. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5274. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  5275. v := m.updated_at
  5276. if v == nil {
  5277. return
  5278. }
  5279. return *v, true
  5280. }
  5281. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  5282. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  5283. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5284. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5285. if !m.op.Is(OpUpdateOne) {
  5286. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5287. }
  5288. if m.id == nil || m.oldValue == nil {
  5289. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5290. }
  5291. oldValue, err := m.oldValue(ctx)
  5292. if err != nil {
  5293. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5294. }
  5295. return oldValue.UpdatedAt, nil
  5296. }
  5297. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5298. func (m *ServerMutation) ResetUpdatedAt() {
  5299. m.updated_at = nil
  5300. }
  5301. // SetStatus sets the "status" field.
  5302. func (m *ServerMutation) SetStatus(u uint8) {
  5303. m.status = &u
  5304. m.addstatus = nil
  5305. }
  5306. // Status returns the value of the "status" field in the mutation.
  5307. func (m *ServerMutation) Status() (r uint8, exists bool) {
  5308. v := m.status
  5309. if v == nil {
  5310. return
  5311. }
  5312. return *v, true
  5313. }
  5314. // OldStatus returns the old "status" field's value of the Server entity.
  5315. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  5316. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5317. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  5318. if !m.op.Is(OpUpdateOne) {
  5319. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5320. }
  5321. if m.id == nil || m.oldValue == nil {
  5322. return v, errors.New("OldStatus requires an ID field in the mutation")
  5323. }
  5324. oldValue, err := m.oldValue(ctx)
  5325. if err != nil {
  5326. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5327. }
  5328. return oldValue.Status, nil
  5329. }
  5330. // AddStatus adds u to the "status" field.
  5331. func (m *ServerMutation) AddStatus(u int8) {
  5332. if m.addstatus != nil {
  5333. *m.addstatus += u
  5334. } else {
  5335. m.addstatus = &u
  5336. }
  5337. }
  5338. // AddedStatus returns the value that was added to the "status" field in this mutation.
  5339. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  5340. v := m.addstatus
  5341. if v == nil {
  5342. return
  5343. }
  5344. return *v, true
  5345. }
  5346. // ClearStatus clears the value of the "status" field.
  5347. func (m *ServerMutation) ClearStatus() {
  5348. m.status = nil
  5349. m.addstatus = nil
  5350. m.clearedFields[server.FieldStatus] = struct{}{}
  5351. }
  5352. // StatusCleared returns if the "status" field was cleared in this mutation.
  5353. func (m *ServerMutation) StatusCleared() bool {
  5354. _, ok := m.clearedFields[server.FieldStatus]
  5355. return ok
  5356. }
  5357. // ResetStatus resets all changes to the "status" field.
  5358. func (m *ServerMutation) ResetStatus() {
  5359. m.status = nil
  5360. m.addstatus = nil
  5361. delete(m.clearedFields, server.FieldStatus)
  5362. }
  5363. // SetDeletedAt sets the "deleted_at" field.
  5364. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  5365. m.deleted_at = &t
  5366. }
  5367. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5368. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  5369. v := m.deleted_at
  5370. if v == nil {
  5371. return
  5372. }
  5373. return *v, true
  5374. }
  5375. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  5376. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  5377. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5378. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5379. if !m.op.Is(OpUpdateOne) {
  5380. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5381. }
  5382. if m.id == nil || m.oldValue == nil {
  5383. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5384. }
  5385. oldValue, err := m.oldValue(ctx)
  5386. if err != nil {
  5387. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5388. }
  5389. return oldValue.DeletedAt, nil
  5390. }
  5391. // ClearDeletedAt clears the value of the "deleted_at" field.
  5392. func (m *ServerMutation) ClearDeletedAt() {
  5393. m.deleted_at = nil
  5394. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  5395. }
  5396. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5397. func (m *ServerMutation) DeletedAtCleared() bool {
  5398. _, ok := m.clearedFields[server.FieldDeletedAt]
  5399. return ok
  5400. }
  5401. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5402. func (m *ServerMutation) ResetDeletedAt() {
  5403. m.deleted_at = nil
  5404. delete(m.clearedFields, server.FieldDeletedAt)
  5405. }
  5406. // SetName sets the "name" field.
  5407. func (m *ServerMutation) SetName(s string) {
  5408. m.name = &s
  5409. }
  5410. // Name returns the value of the "name" field in the mutation.
  5411. func (m *ServerMutation) Name() (r string, exists bool) {
  5412. v := m.name
  5413. if v == nil {
  5414. return
  5415. }
  5416. return *v, true
  5417. }
  5418. // OldName returns the old "name" field's value of the Server entity.
  5419. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  5420. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5421. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  5422. if !m.op.Is(OpUpdateOne) {
  5423. return v, errors.New("OldName is only allowed on UpdateOne operations")
  5424. }
  5425. if m.id == nil || m.oldValue == nil {
  5426. return v, errors.New("OldName requires an ID field in the mutation")
  5427. }
  5428. oldValue, err := m.oldValue(ctx)
  5429. if err != nil {
  5430. return v, fmt.Errorf("querying old value for OldName: %w", err)
  5431. }
  5432. return oldValue.Name, nil
  5433. }
  5434. // ResetName resets all changes to the "name" field.
  5435. func (m *ServerMutation) ResetName() {
  5436. m.name = nil
  5437. }
  5438. // SetPublicIP sets the "public_ip" field.
  5439. func (m *ServerMutation) SetPublicIP(s string) {
  5440. m.public_ip = &s
  5441. }
  5442. // PublicIP returns the value of the "public_ip" field in the mutation.
  5443. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  5444. v := m.public_ip
  5445. if v == nil {
  5446. return
  5447. }
  5448. return *v, true
  5449. }
  5450. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  5451. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  5452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5453. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  5454. if !m.op.Is(OpUpdateOne) {
  5455. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  5456. }
  5457. if m.id == nil || m.oldValue == nil {
  5458. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  5459. }
  5460. oldValue, err := m.oldValue(ctx)
  5461. if err != nil {
  5462. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  5463. }
  5464. return oldValue.PublicIP, nil
  5465. }
  5466. // ResetPublicIP resets all changes to the "public_ip" field.
  5467. func (m *ServerMutation) ResetPublicIP() {
  5468. m.public_ip = nil
  5469. }
  5470. // SetPrivateIP sets the "private_ip" field.
  5471. func (m *ServerMutation) SetPrivateIP(s string) {
  5472. m.private_ip = &s
  5473. }
  5474. // PrivateIP returns the value of the "private_ip" field in the mutation.
  5475. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  5476. v := m.private_ip
  5477. if v == nil {
  5478. return
  5479. }
  5480. return *v, true
  5481. }
  5482. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  5483. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  5484. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5485. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  5486. if !m.op.Is(OpUpdateOne) {
  5487. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  5488. }
  5489. if m.id == nil || m.oldValue == nil {
  5490. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  5491. }
  5492. oldValue, err := m.oldValue(ctx)
  5493. if err != nil {
  5494. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  5495. }
  5496. return oldValue.PrivateIP, nil
  5497. }
  5498. // ResetPrivateIP resets all changes to the "private_ip" field.
  5499. func (m *ServerMutation) ResetPrivateIP() {
  5500. m.private_ip = nil
  5501. }
  5502. // SetAdminPort sets the "admin_port" field.
  5503. func (m *ServerMutation) SetAdminPort(s string) {
  5504. m.admin_port = &s
  5505. }
  5506. // AdminPort returns the value of the "admin_port" field in the mutation.
  5507. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  5508. v := m.admin_port
  5509. if v == nil {
  5510. return
  5511. }
  5512. return *v, true
  5513. }
  5514. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  5515. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  5516. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5517. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  5518. if !m.op.Is(OpUpdateOne) {
  5519. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  5520. }
  5521. if m.id == nil || m.oldValue == nil {
  5522. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  5523. }
  5524. oldValue, err := m.oldValue(ctx)
  5525. if err != nil {
  5526. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  5527. }
  5528. return oldValue.AdminPort, nil
  5529. }
  5530. // ResetAdminPort resets all changes to the "admin_port" field.
  5531. func (m *ServerMutation) ResetAdminPort() {
  5532. m.admin_port = nil
  5533. }
  5534. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  5535. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  5536. if m.wxs == nil {
  5537. m.wxs = make(map[uint64]struct{})
  5538. }
  5539. for i := range ids {
  5540. m.wxs[ids[i]] = struct{}{}
  5541. }
  5542. }
  5543. // ClearWxs clears the "wxs" edge to the Wx entity.
  5544. func (m *ServerMutation) ClearWxs() {
  5545. m.clearedwxs = true
  5546. }
  5547. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  5548. func (m *ServerMutation) WxsCleared() bool {
  5549. return m.clearedwxs
  5550. }
  5551. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  5552. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  5553. if m.removedwxs == nil {
  5554. m.removedwxs = make(map[uint64]struct{})
  5555. }
  5556. for i := range ids {
  5557. delete(m.wxs, ids[i])
  5558. m.removedwxs[ids[i]] = struct{}{}
  5559. }
  5560. }
  5561. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  5562. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  5563. for id := range m.removedwxs {
  5564. ids = append(ids, id)
  5565. }
  5566. return
  5567. }
  5568. // WxsIDs returns the "wxs" edge IDs in the mutation.
  5569. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  5570. for id := range m.wxs {
  5571. ids = append(ids, id)
  5572. }
  5573. return
  5574. }
  5575. // ResetWxs resets all changes to the "wxs" edge.
  5576. func (m *ServerMutation) ResetWxs() {
  5577. m.wxs = nil
  5578. m.clearedwxs = false
  5579. m.removedwxs = nil
  5580. }
  5581. // Where appends a list predicates to the ServerMutation builder.
  5582. func (m *ServerMutation) Where(ps ...predicate.Server) {
  5583. m.predicates = append(m.predicates, ps...)
  5584. }
  5585. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  5586. // users can use type-assertion to append predicates that do not depend on any generated package.
  5587. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  5588. p := make([]predicate.Server, len(ps))
  5589. for i := range ps {
  5590. p[i] = ps[i]
  5591. }
  5592. m.Where(p...)
  5593. }
  5594. // Op returns the operation name.
  5595. func (m *ServerMutation) Op() Op {
  5596. return m.op
  5597. }
  5598. // SetOp allows setting the mutation operation.
  5599. func (m *ServerMutation) SetOp(op Op) {
  5600. m.op = op
  5601. }
  5602. // Type returns the node type of this mutation (Server).
  5603. func (m *ServerMutation) Type() string {
  5604. return m.typ
  5605. }
  5606. // Fields returns all fields that were changed during this mutation. Note that in
  5607. // order to get all numeric fields that were incremented/decremented, call
  5608. // AddedFields().
  5609. func (m *ServerMutation) Fields() []string {
  5610. fields := make([]string, 0, 8)
  5611. if m.created_at != nil {
  5612. fields = append(fields, server.FieldCreatedAt)
  5613. }
  5614. if m.updated_at != nil {
  5615. fields = append(fields, server.FieldUpdatedAt)
  5616. }
  5617. if m.status != nil {
  5618. fields = append(fields, server.FieldStatus)
  5619. }
  5620. if m.deleted_at != nil {
  5621. fields = append(fields, server.FieldDeletedAt)
  5622. }
  5623. if m.name != nil {
  5624. fields = append(fields, server.FieldName)
  5625. }
  5626. if m.public_ip != nil {
  5627. fields = append(fields, server.FieldPublicIP)
  5628. }
  5629. if m.private_ip != nil {
  5630. fields = append(fields, server.FieldPrivateIP)
  5631. }
  5632. if m.admin_port != nil {
  5633. fields = append(fields, server.FieldAdminPort)
  5634. }
  5635. return fields
  5636. }
  5637. // Field returns the value of a field with the given name. The second boolean
  5638. // return value indicates that this field was not set, or was not defined in the
  5639. // schema.
  5640. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  5641. switch name {
  5642. case server.FieldCreatedAt:
  5643. return m.CreatedAt()
  5644. case server.FieldUpdatedAt:
  5645. return m.UpdatedAt()
  5646. case server.FieldStatus:
  5647. return m.Status()
  5648. case server.FieldDeletedAt:
  5649. return m.DeletedAt()
  5650. case server.FieldName:
  5651. return m.Name()
  5652. case server.FieldPublicIP:
  5653. return m.PublicIP()
  5654. case server.FieldPrivateIP:
  5655. return m.PrivateIP()
  5656. case server.FieldAdminPort:
  5657. return m.AdminPort()
  5658. }
  5659. return nil, false
  5660. }
  5661. // OldField returns the old value of the field from the database. An error is
  5662. // returned if the mutation operation is not UpdateOne, or the query to the
  5663. // database failed.
  5664. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5665. switch name {
  5666. case server.FieldCreatedAt:
  5667. return m.OldCreatedAt(ctx)
  5668. case server.FieldUpdatedAt:
  5669. return m.OldUpdatedAt(ctx)
  5670. case server.FieldStatus:
  5671. return m.OldStatus(ctx)
  5672. case server.FieldDeletedAt:
  5673. return m.OldDeletedAt(ctx)
  5674. case server.FieldName:
  5675. return m.OldName(ctx)
  5676. case server.FieldPublicIP:
  5677. return m.OldPublicIP(ctx)
  5678. case server.FieldPrivateIP:
  5679. return m.OldPrivateIP(ctx)
  5680. case server.FieldAdminPort:
  5681. return m.OldAdminPort(ctx)
  5682. }
  5683. return nil, fmt.Errorf("unknown Server field %s", name)
  5684. }
  5685. // SetField sets the value of a field with the given name. It returns an error if
  5686. // the field is not defined in the schema, or if the type mismatched the field
  5687. // type.
  5688. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  5689. switch name {
  5690. case server.FieldCreatedAt:
  5691. v, ok := value.(time.Time)
  5692. if !ok {
  5693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5694. }
  5695. m.SetCreatedAt(v)
  5696. return nil
  5697. case server.FieldUpdatedAt:
  5698. v, ok := value.(time.Time)
  5699. if !ok {
  5700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5701. }
  5702. m.SetUpdatedAt(v)
  5703. return nil
  5704. case server.FieldStatus:
  5705. v, ok := value.(uint8)
  5706. if !ok {
  5707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5708. }
  5709. m.SetStatus(v)
  5710. return nil
  5711. case server.FieldDeletedAt:
  5712. v, ok := value.(time.Time)
  5713. if !ok {
  5714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5715. }
  5716. m.SetDeletedAt(v)
  5717. return nil
  5718. case server.FieldName:
  5719. v, ok := value.(string)
  5720. if !ok {
  5721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5722. }
  5723. m.SetName(v)
  5724. return nil
  5725. case server.FieldPublicIP:
  5726. v, ok := value.(string)
  5727. if !ok {
  5728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5729. }
  5730. m.SetPublicIP(v)
  5731. return nil
  5732. case server.FieldPrivateIP:
  5733. v, ok := value.(string)
  5734. if !ok {
  5735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5736. }
  5737. m.SetPrivateIP(v)
  5738. return nil
  5739. case server.FieldAdminPort:
  5740. v, ok := value.(string)
  5741. if !ok {
  5742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5743. }
  5744. m.SetAdminPort(v)
  5745. return nil
  5746. }
  5747. return fmt.Errorf("unknown Server field %s", name)
  5748. }
  5749. // AddedFields returns all numeric fields that were incremented/decremented during
  5750. // this mutation.
  5751. func (m *ServerMutation) AddedFields() []string {
  5752. var fields []string
  5753. if m.addstatus != nil {
  5754. fields = append(fields, server.FieldStatus)
  5755. }
  5756. return fields
  5757. }
  5758. // AddedField returns the numeric value that was incremented/decremented on a field
  5759. // with the given name. The second boolean return value indicates that this field
  5760. // was not set, or was not defined in the schema.
  5761. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  5762. switch name {
  5763. case server.FieldStatus:
  5764. return m.AddedStatus()
  5765. }
  5766. return nil, false
  5767. }
  5768. // AddField adds the value to the field with the given name. It returns an error if
  5769. // the field is not defined in the schema, or if the type mismatched the field
  5770. // type.
  5771. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  5772. switch name {
  5773. case server.FieldStatus:
  5774. v, ok := value.(int8)
  5775. if !ok {
  5776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5777. }
  5778. m.AddStatus(v)
  5779. return nil
  5780. }
  5781. return fmt.Errorf("unknown Server numeric field %s", name)
  5782. }
  5783. // ClearedFields returns all nullable fields that were cleared during this
  5784. // mutation.
  5785. func (m *ServerMutation) ClearedFields() []string {
  5786. var fields []string
  5787. if m.FieldCleared(server.FieldStatus) {
  5788. fields = append(fields, server.FieldStatus)
  5789. }
  5790. if m.FieldCleared(server.FieldDeletedAt) {
  5791. fields = append(fields, server.FieldDeletedAt)
  5792. }
  5793. return fields
  5794. }
  5795. // FieldCleared returns a boolean indicating if a field with the given name was
  5796. // cleared in this mutation.
  5797. func (m *ServerMutation) FieldCleared(name string) bool {
  5798. _, ok := m.clearedFields[name]
  5799. return ok
  5800. }
  5801. // ClearField clears the value of the field with the given name. It returns an
  5802. // error if the field is not defined in the schema.
  5803. func (m *ServerMutation) ClearField(name string) error {
  5804. switch name {
  5805. case server.FieldStatus:
  5806. m.ClearStatus()
  5807. return nil
  5808. case server.FieldDeletedAt:
  5809. m.ClearDeletedAt()
  5810. return nil
  5811. }
  5812. return fmt.Errorf("unknown Server nullable field %s", name)
  5813. }
  5814. // ResetField resets all changes in the mutation for the field with the given name.
  5815. // It returns an error if the field is not defined in the schema.
  5816. func (m *ServerMutation) ResetField(name string) error {
  5817. switch name {
  5818. case server.FieldCreatedAt:
  5819. m.ResetCreatedAt()
  5820. return nil
  5821. case server.FieldUpdatedAt:
  5822. m.ResetUpdatedAt()
  5823. return nil
  5824. case server.FieldStatus:
  5825. m.ResetStatus()
  5826. return nil
  5827. case server.FieldDeletedAt:
  5828. m.ResetDeletedAt()
  5829. return nil
  5830. case server.FieldName:
  5831. m.ResetName()
  5832. return nil
  5833. case server.FieldPublicIP:
  5834. m.ResetPublicIP()
  5835. return nil
  5836. case server.FieldPrivateIP:
  5837. m.ResetPrivateIP()
  5838. return nil
  5839. case server.FieldAdminPort:
  5840. m.ResetAdminPort()
  5841. return nil
  5842. }
  5843. return fmt.Errorf("unknown Server field %s", name)
  5844. }
  5845. // AddedEdges returns all edge names that were set/added in this mutation.
  5846. func (m *ServerMutation) AddedEdges() []string {
  5847. edges := make([]string, 0, 1)
  5848. if m.wxs != nil {
  5849. edges = append(edges, server.EdgeWxs)
  5850. }
  5851. return edges
  5852. }
  5853. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5854. // name in this mutation.
  5855. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  5856. switch name {
  5857. case server.EdgeWxs:
  5858. ids := make([]ent.Value, 0, len(m.wxs))
  5859. for id := range m.wxs {
  5860. ids = append(ids, id)
  5861. }
  5862. return ids
  5863. }
  5864. return nil
  5865. }
  5866. // RemovedEdges returns all edge names that were removed in this mutation.
  5867. func (m *ServerMutation) RemovedEdges() []string {
  5868. edges := make([]string, 0, 1)
  5869. if m.removedwxs != nil {
  5870. edges = append(edges, server.EdgeWxs)
  5871. }
  5872. return edges
  5873. }
  5874. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5875. // the given name in this mutation.
  5876. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  5877. switch name {
  5878. case server.EdgeWxs:
  5879. ids := make([]ent.Value, 0, len(m.removedwxs))
  5880. for id := range m.removedwxs {
  5881. ids = append(ids, id)
  5882. }
  5883. return ids
  5884. }
  5885. return nil
  5886. }
  5887. // ClearedEdges returns all edge names that were cleared in this mutation.
  5888. func (m *ServerMutation) ClearedEdges() []string {
  5889. edges := make([]string, 0, 1)
  5890. if m.clearedwxs {
  5891. edges = append(edges, server.EdgeWxs)
  5892. }
  5893. return edges
  5894. }
  5895. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5896. // was cleared in this mutation.
  5897. func (m *ServerMutation) EdgeCleared(name string) bool {
  5898. switch name {
  5899. case server.EdgeWxs:
  5900. return m.clearedwxs
  5901. }
  5902. return false
  5903. }
  5904. // ClearEdge clears the value of the edge with the given name. It returns an error
  5905. // if that edge is not defined in the schema.
  5906. func (m *ServerMutation) ClearEdge(name string) error {
  5907. switch name {
  5908. }
  5909. return fmt.Errorf("unknown Server unique edge %s", name)
  5910. }
  5911. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5912. // It returns an error if the edge is not defined in the schema.
  5913. func (m *ServerMutation) ResetEdge(name string) error {
  5914. switch name {
  5915. case server.EdgeWxs:
  5916. m.ResetWxs()
  5917. return nil
  5918. }
  5919. return fmt.Errorf("unknown Server edge %s", name)
  5920. }
  5921. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  5922. type SopNodeMutation struct {
  5923. config
  5924. op Op
  5925. typ string
  5926. id *uint64
  5927. created_at *time.Time
  5928. updated_at *time.Time
  5929. status *uint8
  5930. addstatus *int8
  5931. deleted_at *time.Time
  5932. parent_id *uint64
  5933. addparent_id *int64
  5934. name *string
  5935. condition_type *int
  5936. addcondition_type *int
  5937. condition_list *[]string
  5938. appendcondition_list []string
  5939. action_message *[]custom_types.Action
  5940. appendaction_message []custom_types.Action
  5941. action_label *[]uint64
  5942. appendaction_label []uint64
  5943. clearedFields map[string]struct{}
  5944. sop_stage *uint64
  5945. clearedsop_stage bool
  5946. node_messages map[uint64]struct{}
  5947. removednode_messages map[uint64]struct{}
  5948. clearednode_messages bool
  5949. done bool
  5950. oldValue func(context.Context) (*SopNode, error)
  5951. predicates []predicate.SopNode
  5952. }
  5953. var _ ent.Mutation = (*SopNodeMutation)(nil)
  5954. // sopnodeOption allows management of the mutation configuration using functional options.
  5955. type sopnodeOption func(*SopNodeMutation)
  5956. // newSopNodeMutation creates new mutation for the SopNode entity.
  5957. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  5958. m := &SopNodeMutation{
  5959. config: c,
  5960. op: op,
  5961. typ: TypeSopNode,
  5962. clearedFields: make(map[string]struct{}),
  5963. }
  5964. for _, opt := range opts {
  5965. opt(m)
  5966. }
  5967. return m
  5968. }
  5969. // withSopNodeID sets the ID field of the mutation.
  5970. func withSopNodeID(id uint64) sopnodeOption {
  5971. return func(m *SopNodeMutation) {
  5972. var (
  5973. err error
  5974. once sync.Once
  5975. value *SopNode
  5976. )
  5977. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  5978. once.Do(func() {
  5979. if m.done {
  5980. err = errors.New("querying old values post mutation is not allowed")
  5981. } else {
  5982. value, err = m.Client().SopNode.Get(ctx, id)
  5983. }
  5984. })
  5985. return value, err
  5986. }
  5987. m.id = &id
  5988. }
  5989. }
  5990. // withSopNode sets the old SopNode of the mutation.
  5991. func withSopNode(node *SopNode) sopnodeOption {
  5992. return func(m *SopNodeMutation) {
  5993. m.oldValue = func(context.Context) (*SopNode, error) {
  5994. return node, nil
  5995. }
  5996. m.id = &node.ID
  5997. }
  5998. }
  5999. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6000. // executed in a transaction (ent.Tx), a transactional client is returned.
  6001. func (m SopNodeMutation) Client() *Client {
  6002. client := &Client{config: m.config}
  6003. client.init()
  6004. return client
  6005. }
  6006. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6007. // it returns an error otherwise.
  6008. func (m SopNodeMutation) Tx() (*Tx, error) {
  6009. if _, ok := m.driver.(*txDriver); !ok {
  6010. return nil, errors.New("ent: mutation is not running in a transaction")
  6011. }
  6012. tx := &Tx{config: m.config}
  6013. tx.init()
  6014. return tx, nil
  6015. }
  6016. // SetID sets the value of the id field. Note that this
  6017. // operation is only accepted on creation of SopNode entities.
  6018. func (m *SopNodeMutation) SetID(id uint64) {
  6019. m.id = &id
  6020. }
  6021. // ID returns the ID value in the mutation. Note that the ID is only available
  6022. // if it was provided to the builder or after it was returned from the database.
  6023. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  6024. if m.id == nil {
  6025. return
  6026. }
  6027. return *m.id, true
  6028. }
  6029. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6030. // That means, if the mutation is applied within a transaction with an isolation level such
  6031. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6032. // or updated by the mutation.
  6033. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  6034. switch {
  6035. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6036. id, exists := m.ID()
  6037. if exists {
  6038. return []uint64{id}, nil
  6039. }
  6040. fallthrough
  6041. case m.op.Is(OpUpdate | OpDelete):
  6042. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  6043. default:
  6044. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6045. }
  6046. }
  6047. // SetCreatedAt sets the "created_at" field.
  6048. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  6049. m.created_at = &t
  6050. }
  6051. // CreatedAt returns the value of the "created_at" field in the mutation.
  6052. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  6053. v := m.created_at
  6054. if v == nil {
  6055. return
  6056. }
  6057. return *v, true
  6058. }
  6059. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  6060. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  6061. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6062. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6063. if !m.op.Is(OpUpdateOne) {
  6064. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6065. }
  6066. if m.id == nil || m.oldValue == nil {
  6067. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6068. }
  6069. oldValue, err := m.oldValue(ctx)
  6070. if err != nil {
  6071. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6072. }
  6073. return oldValue.CreatedAt, nil
  6074. }
  6075. // ResetCreatedAt resets all changes to the "created_at" field.
  6076. func (m *SopNodeMutation) ResetCreatedAt() {
  6077. m.created_at = nil
  6078. }
  6079. // SetUpdatedAt sets the "updated_at" field.
  6080. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  6081. m.updated_at = &t
  6082. }
  6083. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6084. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  6085. v := m.updated_at
  6086. if v == nil {
  6087. return
  6088. }
  6089. return *v, true
  6090. }
  6091. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  6092. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  6093. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6094. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6095. if !m.op.Is(OpUpdateOne) {
  6096. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6097. }
  6098. if m.id == nil || m.oldValue == nil {
  6099. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6100. }
  6101. oldValue, err := m.oldValue(ctx)
  6102. if err != nil {
  6103. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6104. }
  6105. return oldValue.UpdatedAt, nil
  6106. }
  6107. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6108. func (m *SopNodeMutation) ResetUpdatedAt() {
  6109. m.updated_at = nil
  6110. }
  6111. // SetStatus sets the "status" field.
  6112. func (m *SopNodeMutation) SetStatus(u uint8) {
  6113. m.status = &u
  6114. m.addstatus = nil
  6115. }
  6116. // Status returns the value of the "status" field in the mutation.
  6117. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  6118. v := m.status
  6119. if v == nil {
  6120. return
  6121. }
  6122. return *v, true
  6123. }
  6124. // OldStatus returns the old "status" field's value of the SopNode entity.
  6125. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  6126. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6127. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  6128. if !m.op.Is(OpUpdateOne) {
  6129. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  6130. }
  6131. if m.id == nil || m.oldValue == nil {
  6132. return v, errors.New("OldStatus requires an ID field in the mutation")
  6133. }
  6134. oldValue, err := m.oldValue(ctx)
  6135. if err != nil {
  6136. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  6137. }
  6138. return oldValue.Status, nil
  6139. }
  6140. // AddStatus adds u to the "status" field.
  6141. func (m *SopNodeMutation) AddStatus(u int8) {
  6142. if m.addstatus != nil {
  6143. *m.addstatus += u
  6144. } else {
  6145. m.addstatus = &u
  6146. }
  6147. }
  6148. // AddedStatus returns the value that was added to the "status" field in this mutation.
  6149. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  6150. v := m.addstatus
  6151. if v == nil {
  6152. return
  6153. }
  6154. return *v, true
  6155. }
  6156. // ClearStatus clears the value of the "status" field.
  6157. func (m *SopNodeMutation) ClearStatus() {
  6158. m.status = nil
  6159. m.addstatus = nil
  6160. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  6161. }
  6162. // StatusCleared returns if the "status" field was cleared in this mutation.
  6163. func (m *SopNodeMutation) StatusCleared() bool {
  6164. _, ok := m.clearedFields[sopnode.FieldStatus]
  6165. return ok
  6166. }
  6167. // ResetStatus resets all changes to the "status" field.
  6168. func (m *SopNodeMutation) ResetStatus() {
  6169. m.status = nil
  6170. m.addstatus = nil
  6171. delete(m.clearedFields, sopnode.FieldStatus)
  6172. }
  6173. // SetDeletedAt sets the "deleted_at" field.
  6174. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  6175. m.deleted_at = &t
  6176. }
  6177. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6178. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  6179. v := m.deleted_at
  6180. if v == nil {
  6181. return
  6182. }
  6183. return *v, true
  6184. }
  6185. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  6186. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  6187. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6188. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6189. if !m.op.Is(OpUpdateOne) {
  6190. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6191. }
  6192. if m.id == nil || m.oldValue == nil {
  6193. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6194. }
  6195. oldValue, err := m.oldValue(ctx)
  6196. if err != nil {
  6197. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6198. }
  6199. return oldValue.DeletedAt, nil
  6200. }
  6201. // ClearDeletedAt clears the value of the "deleted_at" field.
  6202. func (m *SopNodeMutation) ClearDeletedAt() {
  6203. m.deleted_at = nil
  6204. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  6205. }
  6206. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6207. func (m *SopNodeMutation) DeletedAtCleared() bool {
  6208. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  6209. return ok
  6210. }
  6211. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6212. func (m *SopNodeMutation) ResetDeletedAt() {
  6213. m.deleted_at = nil
  6214. delete(m.clearedFields, sopnode.FieldDeletedAt)
  6215. }
  6216. // SetStageID sets the "stage_id" field.
  6217. func (m *SopNodeMutation) SetStageID(u uint64) {
  6218. m.sop_stage = &u
  6219. }
  6220. // StageID returns the value of the "stage_id" field in the mutation.
  6221. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  6222. v := m.sop_stage
  6223. if v == nil {
  6224. return
  6225. }
  6226. return *v, true
  6227. }
  6228. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  6229. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  6230. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6231. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  6232. if !m.op.Is(OpUpdateOne) {
  6233. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  6234. }
  6235. if m.id == nil || m.oldValue == nil {
  6236. return v, errors.New("OldStageID requires an ID field in the mutation")
  6237. }
  6238. oldValue, err := m.oldValue(ctx)
  6239. if err != nil {
  6240. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  6241. }
  6242. return oldValue.StageID, nil
  6243. }
  6244. // ResetStageID resets all changes to the "stage_id" field.
  6245. func (m *SopNodeMutation) ResetStageID() {
  6246. m.sop_stage = nil
  6247. }
  6248. // SetParentID sets the "parent_id" field.
  6249. func (m *SopNodeMutation) SetParentID(u uint64) {
  6250. m.parent_id = &u
  6251. m.addparent_id = nil
  6252. }
  6253. // ParentID returns the value of the "parent_id" field in the mutation.
  6254. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  6255. v := m.parent_id
  6256. if v == nil {
  6257. return
  6258. }
  6259. return *v, true
  6260. }
  6261. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  6262. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  6263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6264. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  6265. if !m.op.Is(OpUpdateOne) {
  6266. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  6267. }
  6268. if m.id == nil || m.oldValue == nil {
  6269. return v, errors.New("OldParentID requires an ID field in the mutation")
  6270. }
  6271. oldValue, err := m.oldValue(ctx)
  6272. if err != nil {
  6273. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  6274. }
  6275. return oldValue.ParentID, nil
  6276. }
  6277. // AddParentID adds u to the "parent_id" field.
  6278. func (m *SopNodeMutation) AddParentID(u int64) {
  6279. if m.addparent_id != nil {
  6280. *m.addparent_id += u
  6281. } else {
  6282. m.addparent_id = &u
  6283. }
  6284. }
  6285. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  6286. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  6287. v := m.addparent_id
  6288. if v == nil {
  6289. return
  6290. }
  6291. return *v, true
  6292. }
  6293. // ResetParentID resets all changes to the "parent_id" field.
  6294. func (m *SopNodeMutation) ResetParentID() {
  6295. m.parent_id = nil
  6296. m.addparent_id = nil
  6297. }
  6298. // SetName sets the "name" field.
  6299. func (m *SopNodeMutation) SetName(s string) {
  6300. m.name = &s
  6301. }
  6302. // Name returns the value of the "name" field in the mutation.
  6303. func (m *SopNodeMutation) Name() (r string, exists bool) {
  6304. v := m.name
  6305. if v == nil {
  6306. return
  6307. }
  6308. return *v, true
  6309. }
  6310. // OldName returns the old "name" field's value of the SopNode entity.
  6311. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  6312. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6313. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  6314. if !m.op.Is(OpUpdateOne) {
  6315. return v, errors.New("OldName is only allowed on UpdateOne operations")
  6316. }
  6317. if m.id == nil || m.oldValue == nil {
  6318. return v, errors.New("OldName requires an ID field in the mutation")
  6319. }
  6320. oldValue, err := m.oldValue(ctx)
  6321. if err != nil {
  6322. return v, fmt.Errorf("querying old value for OldName: %w", err)
  6323. }
  6324. return oldValue.Name, nil
  6325. }
  6326. // ResetName resets all changes to the "name" field.
  6327. func (m *SopNodeMutation) ResetName() {
  6328. m.name = nil
  6329. }
  6330. // SetConditionType sets the "condition_type" field.
  6331. func (m *SopNodeMutation) SetConditionType(i int) {
  6332. m.condition_type = &i
  6333. m.addcondition_type = nil
  6334. }
  6335. // ConditionType returns the value of the "condition_type" field in the mutation.
  6336. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  6337. v := m.condition_type
  6338. if v == nil {
  6339. return
  6340. }
  6341. return *v, true
  6342. }
  6343. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  6344. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  6345. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6346. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  6347. if !m.op.Is(OpUpdateOne) {
  6348. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  6349. }
  6350. if m.id == nil || m.oldValue == nil {
  6351. return v, errors.New("OldConditionType requires an ID field in the mutation")
  6352. }
  6353. oldValue, err := m.oldValue(ctx)
  6354. if err != nil {
  6355. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  6356. }
  6357. return oldValue.ConditionType, nil
  6358. }
  6359. // AddConditionType adds i to the "condition_type" field.
  6360. func (m *SopNodeMutation) AddConditionType(i int) {
  6361. if m.addcondition_type != nil {
  6362. *m.addcondition_type += i
  6363. } else {
  6364. m.addcondition_type = &i
  6365. }
  6366. }
  6367. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  6368. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  6369. v := m.addcondition_type
  6370. if v == nil {
  6371. return
  6372. }
  6373. return *v, true
  6374. }
  6375. // ResetConditionType resets all changes to the "condition_type" field.
  6376. func (m *SopNodeMutation) ResetConditionType() {
  6377. m.condition_type = nil
  6378. m.addcondition_type = nil
  6379. }
  6380. // SetConditionList sets the "condition_list" field.
  6381. func (m *SopNodeMutation) SetConditionList(s []string) {
  6382. m.condition_list = &s
  6383. m.appendcondition_list = nil
  6384. }
  6385. // ConditionList returns the value of the "condition_list" field in the mutation.
  6386. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  6387. v := m.condition_list
  6388. if v == nil {
  6389. return
  6390. }
  6391. return *v, true
  6392. }
  6393. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  6394. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  6395. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6396. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  6397. if !m.op.Is(OpUpdateOne) {
  6398. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  6399. }
  6400. if m.id == nil || m.oldValue == nil {
  6401. return v, errors.New("OldConditionList requires an ID field in the mutation")
  6402. }
  6403. oldValue, err := m.oldValue(ctx)
  6404. if err != nil {
  6405. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  6406. }
  6407. return oldValue.ConditionList, nil
  6408. }
  6409. // AppendConditionList adds s to the "condition_list" field.
  6410. func (m *SopNodeMutation) AppendConditionList(s []string) {
  6411. m.appendcondition_list = append(m.appendcondition_list, s...)
  6412. }
  6413. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  6414. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  6415. if len(m.appendcondition_list) == 0 {
  6416. return nil, false
  6417. }
  6418. return m.appendcondition_list, true
  6419. }
  6420. // ClearConditionList clears the value of the "condition_list" field.
  6421. func (m *SopNodeMutation) ClearConditionList() {
  6422. m.condition_list = nil
  6423. m.appendcondition_list = nil
  6424. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  6425. }
  6426. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  6427. func (m *SopNodeMutation) ConditionListCleared() bool {
  6428. _, ok := m.clearedFields[sopnode.FieldConditionList]
  6429. return ok
  6430. }
  6431. // ResetConditionList resets all changes to the "condition_list" field.
  6432. func (m *SopNodeMutation) ResetConditionList() {
  6433. m.condition_list = nil
  6434. m.appendcondition_list = nil
  6435. delete(m.clearedFields, sopnode.FieldConditionList)
  6436. }
  6437. // SetActionMessage sets the "action_message" field.
  6438. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  6439. m.action_message = &ct
  6440. m.appendaction_message = nil
  6441. }
  6442. // ActionMessage returns the value of the "action_message" field in the mutation.
  6443. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  6444. v := m.action_message
  6445. if v == nil {
  6446. return
  6447. }
  6448. return *v, true
  6449. }
  6450. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  6451. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  6452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6453. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  6454. if !m.op.Is(OpUpdateOne) {
  6455. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  6456. }
  6457. if m.id == nil || m.oldValue == nil {
  6458. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  6459. }
  6460. oldValue, err := m.oldValue(ctx)
  6461. if err != nil {
  6462. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  6463. }
  6464. return oldValue.ActionMessage, nil
  6465. }
  6466. // AppendActionMessage adds ct to the "action_message" field.
  6467. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  6468. m.appendaction_message = append(m.appendaction_message, ct...)
  6469. }
  6470. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  6471. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  6472. if len(m.appendaction_message) == 0 {
  6473. return nil, false
  6474. }
  6475. return m.appendaction_message, true
  6476. }
  6477. // ClearActionMessage clears the value of the "action_message" field.
  6478. func (m *SopNodeMutation) ClearActionMessage() {
  6479. m.action_message = nil
  6480. m.appendaction_message = nil
  6481. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  6482. }
  6483. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  6484. func (m *SopNodeMutation) ActionMessageCleared() bool {
  6485. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  6486. return ok
  6487. }
  6488. // ResetActionMessage resets all changes to the "action_message" field.
  6489. func (m *SopNodeMutation) ResetActionMessage() {
  6490. m.action_message = nil
  6491. m.appendaction_message = nil
  6492. delete(m.clearedFields, sopnode.FieldActionMessage)
  6493. }
  6494. // SetActionLabel sets the "action_label" field.
  6495. func (m *SopNodeMutation) SetActionLabel(u []uint64) {
  6496. m.action_label = &u
  6497. m.appendaction_label = nil
  6498. }
  6499. // ActionLabel returns the value of the "action_label" field in the mutation.
  6500. func (m *SopNodeMutation) ActionLabel() (r []uint64, exists bool) {
  6501. v := m.action_label
  6502. if v == nil {
  6503. return
  6504. }
  6505. return *v, true
  6506. }
  6507. // OldActionLabel returns the old "action_label" field's value of the SopNode entity.
  6508. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  6509. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6510. func (m *SopNodeMutation) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  6511. if !m.op.Is(OpUpdateOne) {
  6512. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  6513. }
  6514. if m.id == nil || m.oldValue == nil {
  6515. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  6516. }
  6517. oldValue, err := m.oldValue(ctx)
  6518. if err != nil {
  6519. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  6520. }
  6521. return oldValue.ActionLabel, nil
  6522. }
  6523. // AppendActionLabel adds u to the "action_label" field.
  6524. func (m *SopNodeMutation) AppendActionLabel(u []uint64) {
  6525. m.appendaction_label = append(m.appendaction_label, u...)
  6526. }
  6527. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  6528. func (m *SopNodeMutation) AppendedActionLabel() ([]uint64, bool) {
  6529. if len(m.appendaction_label) == 0 {
  6530. return nil, false
  6531. }
  6532. return m.appendaction_label, true
  6533. }
  6534. // ClearActionLabel clears the value of the "action_label" field.
  6535. func (m *SopNodeMutation) ClearActionLabel() {
  6536. m.action_label = nil
  6537. m.appendaction_label = nil
  6538. m.clearedFields[sopnode.FieldActionLabel] = struct{}{}
  6539. }
  6540. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  6541. func (m *SopNodeMutation) ActionLabelCleared() bool {
  6542. _, ok := m.clearedFields[sopnode.FieldActionLabel]
  6543. return ok
  6544. }
  6545. // ResetActionLabel resets all changes to the "action_label" field.
  6546. func (m *SopNodeMutation) ResetActionLabel() {
  6547. m.action_label = nil
  6548. m.appendaction_label = nil
  6549. delete(m.clearedFields, sopnode.FieldActionLabel)
  6550. }
  6551. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  6552. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  6553. m.sop_stage = &id
  6554. }
  6555. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  6556. func (m *SopNodeMutation) ClearSopStage() {
  6557. m.clearedsop_stage = true
  6558. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  6559. }
  6560. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  6561. func (m *SopNodeMutation) SopStageCleared() bool {
  6562. return m.clearedsop_stage
  6563. }
  6564. // SopStageID returns the "sop_stage" edge ID in the mutation.
  6565. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  6566. if m.sop_stage != nil {
  6567. return *m.sop_stage, true
  6568. }
  6569. return
  6570. }
  6571. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  6572. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  6573. // SopStageID instead. It exists only for internal usage by the builders.
  6574. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  6575. if id := m.sop_stage; id != nil {
  6576. ids = append(ids, *id)
  6577. }
  6578. return
  6579. }
  6580. // ResetSopStage resets all changes to the "sop_stage" edge.
  6581. func (m *SopNodeMutation) ResetSopStage() {
  6582. m.sop_stage = nil
  6583. m.clearedsop_stage = false
  6584. }
  6585. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  6586. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  6587. if m.node_messages == nil {
  6588. m.node_messages = make(map[uint64]struct{})
  6589. }
  6590. for i := range ids {
  6591. m.node_messages[ids[i]] = struct{}{}
  6592. }
  6593. }
  6594. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  6595. func (m *SopNodeMutation) ClearNodeMessages() {
  6596. m.clearednode_messages = true
  6597. }
  6598. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  6599. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  6600. return m.clearednode_messages
  6601. }
  6602. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  6603. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  6604. if m.removednode_messages == nil {
  6605. m.removednode_messages = make(map[uint64]struct{})
  6606. }
  6607. for i := range ids {
  6608. delete(m.node_messages, ids[i])
  6609. m.removednode_messages[ids[i]] = struct{}{}
  6610. }
  6611. }
  6612. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  6613. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  6614. for id := range m.removednode_messages {
  6615. ids = append(ids, id)
  6616. }
  6617. return
  6618. }
  6619. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  6620. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  6621. for id := range m.node_messages {
  6622. ids = append(ids, id)
  6623. }
  6624. return
  6625. }
  6626. // ResetNodeMessages resets all changes to the "node_messages" edge.
  6627. func (m *SopNodeMutation) ResetNodeMessages() {
  6628. m.node_messages = nil
  6629. m.clearednode_messages = false
  6630. m.removednode_messages = nil
  6631. }
  6632. // Where appends a list predicates to the SopNodeMutation builder.
  6633. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  6634. m.predicates = append(m.predicates, ps...)
  6635. }
  6636. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  6637. // users can use type-assertion to append predicates that do not depend on any generated package.
  6638. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  6639. p := make([]predicate.SopNode, len(ps))
  6640. for i := range ps {
  6641. p[i] = ps[i]
  6642. }
  6643. m.Where(p...)
  6644. }
  6645. // Op returns the operation name.
  6646. func (m *SopNodeMutation) Op() Op {
  6647. return m.op
  6648. }
  6649. // SetOp allows setting the mutation operation.
  6650. func (m *SopNodeMutation) SetOp(op Op) {
  6651. m.op = op
  6652. }
  6653. // Type returns the node type of this mutation (SopNode).
  6654. func (m *SopNodeMutation) Type() string {
  6655. return m.typ
  6656. }
  6657. // Fields returns all fields that were changed during this mutation. Note that in
  6658. // order to get all numeric fields that were incremented/decremented, call
  6659. // AddedFields().
  6660. func (m *SopNodeMutation) Fields() []string {
  6661. fields := make([]string, 0, 11)
  6662. if m.created_at != nil {
  6663. fields = append(fields, sopnode.FieldCreatedAt)
  6664. }
  6665. if m.updated_at != nil {
  6666. fields = append(fields, sopnode.FieldUpdatedAt)
  6667. }
  6668. if m.status != nil {
  6669. fields = append(fields, sopnode.FieldStatus)
  6670. }
  6671. if m.deleted_at != nil {
  6672. fields = append(fields, sopnode.FieldDeletedAt)
  6673. }
  6674. if m.sop_stage != nil {
  6675. fields = append(fields, sopnode.FieldStageID)
  6676. }
  6677. if m.parent_id != nil {
  6678. fields = append(fields, sopnode.FieldParentID)
  6679. }
  6680. if m.name != nil {
  6681. fields = append(fields, sopnode.FieldName)
  6682. }
  6683. if m.condition_type != nil {
  6684. fields = append(fields, sopnode.FieldConditionType)
  6685. }
  6686. if m.condition_list != nil {
  6687. fields = append(fields, sopnode.FieldConditionList)
  6688. }
  6689. if m.action_message != nil {
  6690. fields = append(fields, sopnode.FieldActionMessage)
  6691. }
  6692. if m.action_label != nil {
  6693. fields = append(fields, sopnode.FieldActionLabel)
  6694. }
  6695. return fields
  6696. }
  6697. // Field returns the value of a field with the given name. The second boolean
  6698. // return value indicates that this field was not set, or was not defined in the
  6699. // schema.
  6700. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  6701. switch name {
  6702. case sopnode.FieldCreatedAt:
  6703. return m.CreatedAt()
  6704. case sopnode.FieldUpdatedAt:
  6705. return m.UpdatedAt()
  6706. case sopnode.FieldStatus:
  6707. return m.Status()
  6708. case sopnode.FieldDeletedAt:
  6709. return m.DeletedAt()
  6710. case sopnode.FieldStageID:
  6711. return m.StageID()
  6712. case sopnode.FieldParentID:
  6713. return m.ParentID()
  6714. case sopnode.FieldName:
  6715. return m.Name()
  6716. case sopnode.FieldConditionType:
  6717. return m.ConditionType()
  6718. case sopnode.FieldConditionList:
  6719. return m.ConditionList()
  6720. case sopnode.FieldActionMessage:
  6721. return m.ActionMessage()
  6722. case sopnode.FieldActionLabel:
  6723. return m.ActionLabel()
  6724. }
  6725. return nil, false
  6726. }
  6727. // OldField returns the old value of the field from the database. An error is
  6728. // returned if the mutation operation is not UpdateOne, or the query to the
  6729. // database failed.
  6730. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6731. switch name {
  6732. case sopnode.FieldCreatedAt:
  6733. return m.OldCreatedAt(ctx)
  6734. case sopnode.FieldUpdatedAt:
  6735. return m.OldUpdatedAt(ctx)
  6736. case sopnode.FieldStatus:
  6737. return m.OldStatus(ctx)
  6738. case sopnode.FieldDeletedAt:
  6739. return m.OldDeletedAt(ctx)
  6740. case sopnode.FieldStageID:
  6741. return m.OldStageID(ctx)
  6742. case sopnode.FieldParentID:
  6743. return m.OldParentID(ctx)
  6744. case sopnode.FieldName:
  6745. return m.OldName(ctx)
  6746. case sopnode.FieldConditionType:
  6747. return m.OldConditionType(ctx)
  6748. case sopnode.FieldConditionList:
  6749. return m.OldConditionList(ctx)
  6750. case sopnode.FieldActionMessage:
  6751. return m.OldActionMessage(ctx)
  6752. case sopnode.FieldActionLabel:
  6753. return m.OldActionLabel(ctx)
  6754. }
  6755. return nil, fmt.Errorf("unknown SopNode field %s", name)
  6756. }
  6757. // SetField sets the value of a field with the given name. It returns an error if
  6758. // the field is not defined in the schema, or if the type mismatched the field
  6759. // type.
  6760. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  6761. switch name {
  6762. case sopnode.FieldCreatedAt:
  6763. v, ok := value.(time.Time)
  6764. if !ok {
  6765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6766. }
  6767. m.SetCreatedAt(v)
  6768. return nil
  6769. case sopnode.FieldUpdatedAt:
  6770. v, ok := value.(time.Time)
  6771. if !ok {
  6772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6773. }
  6774. m.SetUpdatedAt(v)
  6775. return nil
  6776. case sopnode.FieldStatus:
  6777. v, ok := value.(uint8)
  6778. if !ok {
  6779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6780. }
  6781. m.SetStatus(v)
  6782. return nil
  6783. case sopnode.FieldDeletedAt:
  6784. v, ok := value.(time.Time)
  6785. if !ok {
  6786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6787. }
  6788. m.SetDeletedAt(v)
  6789. return nil
  6790. case sopnode.FieldStageID:
  6791. v, ok := value.(uint64)
  6792. if !ok {
  6793. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6794. }
  6795. m.SetStageID(v)
  6796. return nil
  6797. case sopnode.FieldParentID:
  6798. v, ok := value.(uint64)
  6799. if !ok {
  6800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6801. }
  6802. m.SetParentID(v)
  6803. return nil
  6804. case sopnode.FieldName:
  6805. v, ok := value.(string)
  6806. if !ok {
  6807. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6808. }
  6809. m.SetName(v)
  6810. return nil
  6811. case sopnode.FieldConditionType:
  6812. v, ok := value.(int)
  6813. if !ok {
  6814. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6815. }
  6816. m.SetConditionType(v)
  6817. return nil
  6818. case sopnode.FieldConditionList:
  6819. v, ok := value.([]string)
  6820. if !ok {
  6821. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6822. }
  6823. m.SetConditionList(v)
  6824. return nil
  6825. case sopnode.FieldActionMessage:
  6826. v, ok := value.([]custom_types.Action)
  6827. if !ok {
  6828. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6829. }
  6830. m.SetActionMessage(v)
  6831. return nil
  6832. case sopnode.FieldActionLabel:
  6833. v, ok := value.([]uint64)
  6834. if !ok {
  6835. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6836. }
  6837. m.SetActionLabel(v)
  6838. return nil
  6839. }
  6840. return fmt.Errorf("unknown SopNode field %s", name)
  6841. }
  6842. // AddedFields returns all numeric fields that were incremented/decremented during
  6843. // this mutation.
  6844. func (m *SopNodeMutation) AddedFields() []string {
  6845. var fields []string
  6846. if m.addstatus != nil {
  6847. fields = append(fields, sopnode.FieldStatus)
  6848. }
  6849. if m.addparent_id != nil {
  6850. fields = append(fields, sopnode.FieldParentID)
  6851. }
  6852. if m.addcondition_type != nil {
  6853. fields = append(fields, sopnode.FieldConditionType)
  6854. }
  6855. return fields
  6856. }
  6857. // AddedField returns the numeric value that was incremented/decremented on a field
  6858. // with the given name. The second boolean return value indicates that this field
  6859. // was not set, or was not defined in the schema.
  6860. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  6861. switch name {
  6862. case sopnode.FieldStatus:
  6863. return m.AddedStatus()
  6864. case sopnode.FieldParentID:
  6865. return m.AddedParentID()
  6866. case sopnode.FieldConditionType:
  6867. return m.AddedConditionType()
  6868. }
  6869. return nil, false
  6870. }
  6871. // AddField adds the value to the field with the given name. It returns an error if
  6872. // the field is not defined in the schema, or if the type mismatched the field
  6873. // type.
  6874. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  6875. switch name {
  6876. case sopnode.FieldStatus:
  6877. v, ok := value.(int8)
  6878. if !ok {
  6879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6880. }
  6881. m.AddStatus(v)
  6882. return nil
  6883. case sopnode.FieldParentID:
  6884. v, ok := value.(int64)
  6885. if !ok {
  6886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6887. }
  6888. m.AddParentID(v)
  6889. return nil
  6890. case sopnode.FieldConditionType:
  6891. v, ok := value.(int)
  6892. if !ok {
  6893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6894. }
  6895. m.AddConditionType(v)
  6896. return nil
  6897. }
  6898. return fmt.Errorf("unknown SopNode numeric field %s", name)
  6899. }
  6900. // ClearedFields returns all nullable fields that were cleared during this
  6901. // mutation.
  6902. func (m *SopNodeMutation) ClearedFields() []string {
  6903. var fields []string
  6904. if m.FieldCleared(sopnode.FieldStatus) {
  6905. fields = append(fields, sopnode.FieldStatus)
  6906. }
  6907. if m.FieldCleared(sopnode.FieldDeletedAt) {
  6908. fields = append(fields, sopnode.FieldDeletedAt)
  6909. }
  6910. if m.FieldCleared(sopnode.FieldConditionList) {
  6911. fields = append(fields, sopnode.FieldConditionList)
  6912. }
  6913. if m.FieldCleared(sopnode.FieldActionMessage) {
  6914. fields = append(fields, sopnode.FieldActionMessage)
  6915. }
  6916. if m.FieldCleared(sopnode.FieldActionLabel) {
  6917. fields = append(fields, sopnode.FieldActionLabel)
  6918. }
  6919. return fields
  6920. }
  6921. // FieldCleared returns a boolean indicating if a field with the given name was
  6922. // cleared in this mutation.
  6923. func (m *SopNodeMutation) FieldCleared(name string) bool {
  6924. _, ok := m.clearedFields[name]
  6925. return ok
  6926. }
  6927. // ClearField clears the value of the field with the given name. It returns an
  6928. // error if the field is not defined in the schema.
  6929. func (m *SopNodeMutation) ClearField(name string) error {
  6930. switch name {
  6931. case sopnode.FieldStatus:
  6932. m.ClearStatus()
  6933. return nil
  6934. case sopnode.FieldDeletedAt:
  6935. m.ClearDeletedAt()
  6936. return nil
  6937. case sopnode.FieldConditionList:
  6938. m.ClearConditionList()
  6939. return nil
  6940. case sopnode.FieldActionMessage:
  6941. m.ClearActionMessage()
  6942. return nil
  6943. case sopnode.FieldActionLabel:
  6944. m.ClearActionLabel()
  6945. return nil
  6946. }
  6947. return fmt.Errorf("unknown SopNode nullable field %s", name)
  6948. }
  6949. // ResetField resets all changes in the mutation for the field with the given name.
  6950. // It returns an error if the field is not defined in the schema.
  6951. func (m *SopNodeMutation) ResetField(name string) error {
  6952. switch name {
  6953. case sopnode.FieldCreatedAt:
  6954. m.ResetCreatedAt()
  6955. return nil
  6956. case sopnode.FieldUpdatedAt:
  6957. m.ResetUpdatedAt()
  6958. return nil
  6959. case sopnode.FieldStatus:
  6960. m.ResetStatus()
  6961. return nil
  6962. case sopnode.FieldDeletedAt:
  6963. m.ResetDeletedAt()
  6964. return nil
  6965. case sopnode.FieldStageID:
  6966. m.ResetStageID()
  6967. return nil
  6968. case sopnode.FieldParentID:
  6969. m.ResetParentID()
  6970. return nil
  6971. case sopnode.FieldName:
  6972. m.ResetName()
  6973. return nil
  6974. case sopnode.FieldConditionType:
  6975. m.ResetConditionType()
  6976. return nil
  6977. case sopnode.FieldConditionList:
  6978. m.ResetConditionList()
  6979. return nil
  6980. case sopnode.FieldActionMessage:
  6981. m.ResetActionMessage()
  6982. return nil
  6983. case sopnode.FieldActionLabel:
  6984. m.ResetActionLabel()
  6985. return nil
  6986. }
  6987. return fmt.Errorf("unknown SopNode field %s", name)
  6988. }
  6989. // AddedEdges returns all edge names that were set/added in this mutation.
  6990. func (m *SopNodeMutation) AddedEdges() []string {
  6991. edges := make([]string, 0, 2)
  6992. if m.sop_stage != nil {
  6993. edges = append(edges, sopnode.EdgeSopStage)
  6994. }
  6995. if m.node_messages != nil {
  6996. edges = append(edges, sopnode.EdgeNodeMessages)
  6997. }
  6998. return edges
  6999. }
  7000. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7001. // name in this mutation.
  7002. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  7003. switch name {
  7004. case sopnode.EdgeSopStage:
  7005. if id := m.sop_stage; id != nil {
  7006. return []ent.Value{*id}
  7007. }
  7008. case sopnode.EdgeNodeMessages:
  7009. ids := make([]ent.Value, 0, len(m.node_messages))
  7010. for id := range m.node_messages {
  7011. ids = append(ids, id)
  7012. }
  7013. return ids
  7014. }
  7015. return nil
  7016. }
  7017. // RemovedEdges returns all edge names that were removed in this mutation.
  7018. func (m *SopNodeMutation) RemovedEdges() []string {
  7019. edges := make([]string, 0, 2)
  7020. if m.removednode_messages != nil {
  7021. edges = append(edges, sopnode.EdgeNodeMessages)
  7022. }
  7023. return edges
  7024. }
  7025. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7026. // the given name in this mutation.
  7027. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  7028. switch name {
  7029. case sopnode.EdgeNodeMessages:
  7030. ids := make([]ent.Value, 0, len(m.removednode_messages))
  7031. for id := range m.removednode_messages {
  7032. ids = append(ids, id)
  7033. }
  7034. return ids
  7035. }
  7036. return nil
  7037. }
  7038. // ClearedEdges returns all edge names that were cleared in this mutation.
  7039. func (m *SopNodeMutation) ClearedEdges() []string {
  7040. edges := make([]string, 0, 2)
  7041. if m.clearedsop_stage {
  7042. edges = append(edges, sopnode.EdgeSopStage)
  7043. }
  7044. if m.clearednode_messages {
  7045. edges = append(edges, sopnode.EdgeNodeMessages)
  7046. }
  7047. return edges
  7048. }
  7049. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7050. // was cleared in this mutation.
  7051. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  7052. switch name {
  7053. case sopnode.EdgeSopStage:
  7054. return m.clearedsop_stage
  7055. case sopnode.EdgeNodeMessages:
  7056. return m.clearednode_messages
  7057. }
  7058. return false
  7059. }
  7060. // ClearEdge clears the value of the edge with the given name. It returns an error
  7061. // if that edge is not defined in the schema.
  7062. func (m *SopNodeMutation) ClearEdge(name string) error {
  7063. switch name {
  7064. case sopnode.EdgeSopStage:
  7065. m.ClearSopStage()
  7066. return nil
  7067. }
  7068. return fmt.Errorf("unknown SopNode unique edge %s", name)
  7069. }
  7070. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7071. // It returns an error if the edge is not defined in the schema.
  7072. func (m *SopNodeMutation) ResetEdge(name string) error {
  7073. switch name {
  7074. case sopnode.EdgeSopStage:
  7075. m.ResetSopStage()
  7076. return nil
  7077. case sopnode.EdgeNodeMessages:
  7078. m.ResetNodeMessages()
  7079. return nil
  7080. }
  7081. return fmt.Errorf("unknown SopNode edge %s", name)
  7082. }
  7083. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  7084. type SopStageMutation struct {
  7085. config
  7086. op Op
  7087. typ string
  7088. id *uint64
  7089. created_at *time.Time
  7090. updated_at *time.Time
  7091. status *uint8
  7092. addstatus *int8
  7093. deleted_at *time.Time
  7094. name *string
  7095. condition_type *int
  7096. addcondition_type *int
  7097. condition_operator *int
  7098. addcondition_operator *int
  7099. condition_list *[]custom_types.Condition
  7100. appendcondition_list []custom_types.Condition
  7101. action_message *[]custom_types.Action
  7102. appendaction_message []custom_types.Action
  7103. action_label *[]uint64
  7104. appendaction_label []uint64
  7105. index_sort *int
  7106. addindex_sort *int
  7107. clearedFields map[string]struct{}
  7108. sop_task *uint64
  7109. clearedsop_task bool
  7110. stage_nodes map[uint64]struct{}
  7111. removedstage_nodes map[uint64]struct{}
  7112. clearedstage_nodes bool
  7113. stage_messages map[uint64]struct{}
  7114. removedstage_messages map[uint64]struct{}
  7115. clearedstage_messages bool
  7116. done bool
  7117. oldValue func(context.Context) (*SopStage, error)
  7118. predicates []predicate.SopStage
  7119. }
  7120. var _ ent.Mutation = (*SopStageMutation)(nil)
  7121. // sopstageOption allows management of the mutation configuration using functional options.
  7122. type sopstageOption func(*SopStageMutation)
  7123. // newSopStageMutation creates new mutation for the SopStage entity.
  7124. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  7125. m := &SopStageMutation{
  7126. config: c,
  7127. op: op,
  7128. typ: TypeSopStage,
  7129. clearedFields: make(map[string]struct{}),
  7130. }
  7131. for _, opt := range opts {
  7132. opt(m)
  7133. }
  7134. return m
  7135. }
  7136. // withSopStageID sets the ID field of the mutation.
  7137. func withSopStageID(id uint64) sopstageOption {
  7138. return func(m *SopStageMutation) {
  7139. var (
  7140. err error
  7141. once sync.Once
  7142. value *SopStage
  7143. )
  7144. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  7145. once.Do(func() {
  7146. if m.done {
  7147. err = errors.New("querying old values post mutation is not allowed")
  7148. } else {
  7149. value, err = m.Client().SopStage.Get(ctx, id)
  7150. }
  7151. })
  7152. return value, err
  7153. }
  7154. m.id = &id
  7155. }
  7156. }
  7157. // withSopStage sets the old SopStage of the mutation.
  7158. func withSopStage(node *SopStage) sopstageOption {
  7159. return func(m *SopStageMutation) {
  7160. m.oldValue = func(context.Context) (*SopStage, error) {
  7161. return node, nil
  7162. }
  7163. m.id = &node.ID
  7164. }
  7165. }
  7166. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7167. // executed in a transaction (ent.Tx), a transactional client is returned.
  7168. func (m SopStageMutation) Client() *Client {
  7169. client := &Client{config: m.config}
  7170. client.init()
  7171. return client
  7172. }
  7173. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7174. // it returns an error otherwise.
  7175. func (m SopStageMutation) Tx() (*Tx, error) {
  7176. if _, ok := m.driver.(*txDriver); !ok {
  7177. return nil, errors.New("ent: mutation is not running in a transaction")
  7178. }
  7179. tx := &Tx{config: m.config}
  7180. tx.init()
  7181. return tx, nil
  7182. }
  7183. // SetID sets the value of the id field. Note that this
  7184. // operation is only accepted on creation of SopStage entities.
  7185. func (m *SopStageMutation) SetID(id uint64) {
  7186. m.id = &id
  7187. }
  7188. // ID returns the ID value in the mutation. Note that the ID is only available
  7189. // if it was provided to the builder or after it was returned from the database.
  7190. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  7191. if m.id == nil {
  7192. return
  7193. }
  7194. return *m.id, true
  7195. }
  7196. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7197. // That means, if the mutation is applied within a transaction with an isolation level such
  7198. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7199. // or updated by the mutation.
  7200. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  7201. switch {
  7202. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7203. id, exists := m.ID()
  7204. if exists {
  7205. return []uint64{id}, nil
  7206. }
  7207. fallthrough
  7208. case m.op.Is(OpUpdate | OpDelete):
  7209. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  7210. default:
  7211. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7212. }
  7213. }
  7214. // SetCreatedAt sets the "created_at" field.
  7215. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  7216. m.created_at = &t
  7217. }
  7218. // CreatedAt returns the value of the "created_at" field in the mutation.
  7219. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  7220. v := m.created_at
  7221. if v == nil {
  7222. return
  7223. }
  7224. return *v, true
  7225. }
  7226. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  7227. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  7228. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7229. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7230. if !m.op.Is(OpUpdateOne) {
  7231. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7232. }
  7233. if m.id == nil || m.oldValue == nil {
  7234. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7235. }
  7236. oldValue, err := m.oldValue(ctx)
  7237. if err != nil {
  7238. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7239. }
  7240. return oldValue.CreatedAt, nil
  7241. }
  7242. // ResetCreatedAt resets all changes to the "created_at" field.
  7243. func (m *SopStageMutation) ResetCreatedAt() {
  7244. m.created_at = nil
  7245. }
  7246. // SetUpdatedAt sets the "updated_at" field.
  7247. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  7248. m.updated_at = &t
  7249. }
  7250. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7251. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  7252. v := m.updated_at
  7253. if v == nil {
  7254. return
  7255. }
  7256. return *v, true
  7257. }
  7258. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  7259. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  7260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7261. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7262. if !m.op.Is(OpUpdateOne) {
  7263. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7264. }
  7265. if m.id == nil || m.oldValue == nil {
  7266. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7267. }
  7268. oldValue, err := m.oldValue(ctx)
  7269. if err != nil {
  7270. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7271. }
  7272. return oldValue.UpdatedAt, nil
  7273. }
  7274. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7275. func (m *SopStageMutation) ResetUpdatedAt() {
  7276. m.updated_at = nil
  7277. }
  7278. // SetStatus sets the "status" field.
  7279. func (m *SopStageMutation) SetStatus(u uint8) {
  7280. m.status = &u
  7281. m.addstatus = nil
  7282. }
  7283. // Status returns the value of the "status" field in the mutation.
  7284. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  7285. v := m.status
  7286. if v == nil {
  7287. return
  7288. }
  7289. return *v, true
  7290. }
  7291. // OldStatus returns the old "status" field's value of the SopStage entity.
  7292. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  7293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7294. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7295. if !m.op.Is(OpUpdateOne) {
  7296. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7297. }
  7298. if m.id == nil || m.oldValue == nil {
  7299. return v, errors.New("OldStatus requires an ID field in the mutation")
  7300. }
  7301. oldValue, err := m.oldValue(ctx)
  7302. if err != nil {
  7303. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7304. }
  7305. return oldValue.Status, nil
  7306. }
  7307. // AddStatus adds u to the "status" field.
  7308. func (m *SopStageMutation) AddStatus(u int8) {
  7309. if m.addstatus != nil {
  7310. *m.addstatus += u
  7311. } else {
  7312. m.addstatus = &u
  7313. }
  7314. }
  7315. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7316. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  7317. v := m.addstatus
  7318. if v == nil {
  7319. return
  7320. }
  7321. return *v, true
  7322. }
  7323. // ClearStatus clears the value of the "status" field.
  7324. func (m *SopStageMutation) ClearStatus() {
  7325. m.status = nil
  7326. m.addstatus = nil
  7327. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  7328. }
  7329. // StatusCleared returns if the "status" field was cleared in this mutation.
  7330. func (m *SopStageMutation) StatusCleared() bool {
  7331. _, ok := m.clearedFields[sopstage.FieldStatus]
  7332. return ok
  7333. }
  7334. // ResetStatus resets all changes to the "status" field.
  7335. func (m *SopStageMutation) ResetStatus() {
  7336. m.status = nil
  7337. m.addstatus = nil
  7338. delete(m.clearedFields, sopstage.FieldStatus)
  7339. }
  7340. // SetDeletedAt sets the "deleted_at" field.
  7341. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  7342. m.deleted_at = &t
  7343. }
  7344. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7345. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  7346. v := m.deleted_at
  7347. if v == nil {
  7348. return
  7349. }
  7350. return *v, true
  7351. }
  7352. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  7353. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  7354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7355. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7356. if !m.op.Is(OpUpdateOne) {
  7357. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7358. }
  7359. if m.id == nil || m.oldValue == nil {
  7360. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7361. }
  7362. oldValue, err := m.oldValue(ctx)
  7363. if err != nil {
  7364. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7365. }
  7366. return oldValue.DeletedAt, nil
  7367. }
  7368. // ClearDeletedAt clears the value of the "deleted_at" field.
  7369. func (m *SopStageMutation) ClearDeletedAt() {
  7370. m.deleted_at = nil
  7371. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  7372. }
  7373. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7374. func (m *SopStageMutation) DeletedAtCleared() bool {
  7375. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  7376. return ok
  7377. }
  7378. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7379. func (m *SopStageMutation) ResetDeletedAt() {
  7380. m.deleted_at = nil
  7381. delete(m.clearedFields, sopstage.FieldDeletedAt)
  7382. }
  7383. // SetTaskID sets the "task_id" field.
  7384. func (m *SopStageMutation) SetTaskID(u uint64) {
  7385. m.sop_task = &u
  7386. }
  7387. // TaskID returns the value of the "task_id" field in the mutation.
  7388. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  7389. v := m.sop_task
  7390. if v == nil {
  7391. return
  7392. }
  7393. return *v, true
  7394. }
  7395. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  7396. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  7397. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7398. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  7399. if !m.op.Is(OpUpdateOne) {
  7400. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  7401. }
  7402. if m.id == nil || m.oldValue == nil {
  7403. return v, errors.New("OldTaskID requires an ID field in the mutation")
  7404. }
  7405. oldValue, err := m.oldValue(ctx)
  7406. if err != nil {
  7407. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  7408. }
  7409. return oldValue.TaskID, nil
  7410. }
  7411. // ResetTaskID resets all changes to the "task_id" field.
  7412. func (m *SopStageMutation) ResetTaskID() {
  7413. m.sop_task = nil
  7414. }
  7415. // SetName sets the "name" field.
  7416. func (m *SopStageMutation) SetName(s string) {
  7417. m.name = &s
  7418. }
  7419. // Name returns the value of the "name" field in the mutation.
  7420. func (m *SopStageMutation) Name() (r string, exists bool) {
  7421. v := m.name
  7422. if v == nil {
  7423. return
  7424. }
  7425. return *v, true
  7426. }
  7427. // OldName returns the old "name" field's value of the SopStage entity.
  7428. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  7429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7430. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  7431. if !m.op.Is(OpUpdateOne) {
  7432. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7433. }
  7434. if m.id == nil || m.oldValue == nil {
  7435. return v, errors.New("OldName requires an ID field in the mutation")
  7436. }
  7437. oldValue, err := m.oldValue(ctx)
  7438. if err != nil {
  7439. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7440. }
  7441. return oldValue.Name, nil
  7442. }
  7443. // ResetName resets all changes to the "name" field.
  7444. func (m *SopStageMutation) ResetName() {
  7445. m.name = nil
  7446. }
  7447. // SetConditionType sets the "condition_type" field.
  7448. func (m *SopStageMutation) SetConditionType(i int) {
  7449. m.condition_type = &i
  7450. m.addcondition_type = nil
  7451. }
  7452. // ConditionType returns the value of the "condition_type" field in the mutation.
  7453. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  7454. v := m.condition_type
  7455. if v == nil {
  7456. return
  7457. }
  7458. return *v, true
  7459. }
  7460. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  7461. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  7462. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7463. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  7464. if !m.op.Is(OpUpdateOne) {
  7465. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  7466. }
  7467. if m.id == nil || m.oldValue == nil {
  7468. return v, errors.New("OldConditionType requires an ID field in the mutation")
  7469. }
  7470. oldValue, err := m.oldValue(ctx)
  7471. if err != nil {
  7472. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  7473. }
  7474. return oldValue.ConditionType, nil
  7475. }
  7476. // AddConditionType adds i to the "condition_type" field.
  7477. func (m *SopStageMutation) AddConditionType(i int) {
  7478. if m.addcondition_type != nil {
  7479. *m.addcondition_type += i
  7480. } else {
  7481. m.addcondition_type = &i
  7482. }
  7483. }
  7484. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  7485. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  7486. v := m.addcondition_type
  7487. if v == nil {
  7488. return
  7489. }
  7490. return *v, true
  7491. }
  7492. // ResetConditionType resets all changes to the "condition_type" field.
  7493. func (m *SopStageMutation) ResetConditionType() {
  7494. m.condition_type = nil
  7495. m.addcondition_type = nil
  7496. }
  7497. // SetConditionOperator sets the "condition_operator" field.
  7498. func (m *SopStageMutation) SetConditionOperator(i int) {
  7499. m.condition_operator = &i
  7500. m.addcondition_operator = nil
  7501. }
  7502. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  7503. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  7504. v := m.condition_operator
  7505. if v == nil {
  7506. return
  7507. }
  7508. return *v, true
  7509. }
  7510. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  7511. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  7512. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7513. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  7514. if !m.op.Is(OpUpdateOne) {
  7515. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  7516. }
  7517. if m.id == nil || m.oldValue == nil {
  7518. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  7519. }
  7520. oldValue, err := m.oldValue(ctx)
  7521. if err != nil {
  7522. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  7523. }
  7524. return oldValue.ConditionOperator, nil
  7525. }
  7526. // AddConditionOperator adds i to the "condition_operator" field.
  7527. func (m *SopStageMutation) AddConditionOperator(i int) {
  7528. if m.addcondition_operator != nil {
  7529. *m.addcondition_operator += i
  7530. } else {
  7531. m.addcondition_operator = &i
  7532. }
  7533. }
  7534. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  7535. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  7536. v := m.addcondition_operator
  7537. if v == nil {
  7538. return
  7539. }
  7540. return *v, true
  7541. }
  7542. // ResetConditionOperator resets all changes to the "condition_operator" field.
  7543. func (m *SopStageMutation) ResetConditionOperator() {
  7544. m.condition_operator = nil
  7545. m.addcondition_operator = nil
  7546. }
  7547. // SetConditionList sets the "condition_list" field.
  7548. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  7549. m.condition_list = &ct
  7550. m.appendcondition_list = nil
  7551. }
  7552. // ConditionList returns the value of the "condition_list" field in the mutation.
  7553. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  7554. v := m.condition_list
  7555. if v == nil {
  7556. return
  7557. }
  7558. return *v, true
  7559. }
  7560. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  7561. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  7562. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7563. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  7564. if !m.op.Is(OpUpdateOne) {
  7565. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  7566. }
  7567. if m.id == nil || m.oldValue == nil {
  7568. return v, errors.New("OldConditionList requires an ID field in the mutation")
  7569. }
  7570. oldValue, err := m.oldValue(ctx)
  7571. if err != nil {
  7572. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  7573. }
  7574. return oldValue.ConditionList, nil
  7575. }
  7576. // AppendConditionList adds ct to the "condition_list" field.
  7577. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  7578. m.appendcondition_list = append(m.appendcondition_list, ct...)
  7579. }
  7580. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  7581. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  7582. if len(m.appendcondition_list) == 0 {
  7583. return nil, false
  7584. }
  7585. return m.appendcondition_list, true
  7586. }
  7587. // ResetConditionList resets all changes to the "condition_list" field.
  7588. func (m *SopStageMutation) ResetConditionList() {
  7589. m.condition_list = nil
  7590. m.appendcondition_list = nil
  7591. }
  7592. // SetActionMessage sets the "action_message" field.
  7593. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  7594. m.action_message = &ct
  7595. m.appendaction_message = nil
  7596. }
  7597. // ActionMessage returns the value of the "action_message" field in the mutation.
  7598. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  7599. v := m.action_message
  7600. if v == nil {
  7601. return
  7602. }
  7603. return *v, true
  7604. }
  7605. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  7606. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  7607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7608. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  7609. if !m.op.Is(OpUpdateOne) {
  7610. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  7611. }
  7612. if m.id == nil || m.oldValue == nil {
  7613. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  7614. }
  7615. oldValue, err := m.oldValue(ctx)
  7616. if err != nil {
  7617. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  7618. }
  7619. return oldValue.ActionMessage, nil
  7620. }
  7621. // AppendActionMessage adds ct to the "action_message" field.
  7622. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  7623. m.appendaction_message = append(m.appendaction_message, ct...)
  7624. }
  7625. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  7626. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  7627. if len(m.appendaction_message) == 0 {
  7628. return nil, false
  7629. }
  7630. return m.appendaction_message, true
  7631. }
  7632. // ClearActionMessage clears the value of the "action_message" field.
  7633. func (m *SopStageMutation) ClearActionMessage() {
  7634. m.action_message = nil
  7635. m.appendaction_message = nil
  7636. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  7637. }
  7638. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  7639. func (m *SopStageMutation) ActionMessageCleared() bool {
  7640. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  7641. return ok
  7642. }
  7643. // ResetActionMessage resets all changes to the "action_message" field.
  7644. func (m *SopStageMutation) ResetActionMessage() {
  7645. m.action_message = nil
  7646. m.appendaction_message = nil
  7647. delete(m.clearedFields, sopstage.FieldActionMessage)
  7648. }
  7649. // SetActionLabel sets the "action_label" field.
  7650. func (m *SopStageMutation) SetActionLabel(u []uint64) {
  7651. m.action_label = &u
  7652. m.appendaction_label = nil
  7653. }
  7654. // ActionLabel returns the value of the "action_label" field in the mutation.
  7655. func (m *SopStageMutation) ActionLabel() (r []uint64, exists bool) {
  7656. v := m.action_label
  7657. if v == nil {
  7658. return
  7659. }
  7660. return *v, true
  7661. }
  7662. // OldActionLabel returns the old "action_label" field's value of the SopStage entity.
  7663. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  7664. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7665. func (m *SopStageMutation) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  7666. if !m.op.Is(OpUpdateOne) {
  7667. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  7668. }
  7669. if m.id == nil || m.oldValue == nil {
  7670. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  7671. }
  7672. oldValue, err := m.oldValue(ctx)
  7673. if err != nil {
  7674. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  7675. }
  7676. return oldValue.ActionLabel, nil
  7677. }
  7678. // AppendActionLabel adds u to the "action_label" field.
  7679. func (m *SopStageMutation) AppendActionLabel(u []uint64) {
  7680. m.appendaction_label = append(m.appendaction_label, u...)
  7681. }
  7682. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  7683. func (m *SopStageMutation) AppendedActionLabel() ([]uint64, bool) {
  7684. if len(m.appendaction_label) == 0 {
  7685. return nil, false
  7686. }
  7687. return m.appendaction_label, true
  7688. }
  7689. // ClearActionLabel clears the value of the "action_label" field.
  7690. func (m *SopStageMutation) ClearActionLabel() {
  7691. m.action_label = nil
  7692. m.appendaction_label = nil
  7693. m.clearedFields[sopstage.FieldActionLabel] = struct{}{}
  7694. }
  7695. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  7696. func (m *SopStageMutation) ActionLabelCleared() bool {
  7697. _, ok := m.clearedFields[sopstage.FieldActionLabel]
  7698. return ok
  7699. }
  7700. // ResetActionLabel resets all changes to the "action_label" field.
  7701. func (m *SopStageMutation) ResetActionLabel() {
  7702. m.action_label = nil
  7703. m.appendaction_label = nil
  7704. delete(m.clearedFields, sopstage.FieldActionLabel)
  7705. }
  7706. // SetIndexSort sets the "index_sort" field.
  7707. func (m *SopStageMutation) SetIndexSort(i int) {
  7708. m.index_sort = &i
  7709. m.addindex_sort = nil
  7710. }
  7711. // IndexSort returns the value of the "index_sort" field in the mutation.
  7712. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  7713. v := m.index_sort
  7714. if v == nil {
  7715. return
  7716. }
  7717. return *v, true
  7718. }
  7719. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  7720. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  7721. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7722. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  7723. if !m.op.Is(OpUpdateOne) {
  7724. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  7725. }
  7726. if m.id == nil || m.oldValue == nil {
  7727. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  7728. }
  7729. oldValue, err := m.oldValue(ctx)
  7730. if err != nil {
  7731. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  7732. }
  7733. return oldValue.IndexSort, nil
  7734. }
  7735. // AddIndexSort adds i to the "index_sort" field.
  7736. func (m *SopStageMutation) AddIndexSort(i int) {
  7737. if m.addindex_sort != nil {
  7738. *m.addindex_sort += i
  7739. } else {
  7740. m.addindex_sort = &i
  7741. }
  7742. }
  7743. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  7744. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  7745. v := m.addindex_sort
  7746. if v == nil {
  7747. return
  7748. }
  7749. return *v, true
  7750. }
  7751. // ClearIndexSort clears the value of the "index_sort" field.
  7752. func (m *SopStageMutation) ClearIndexSort() {
  7753. m.index_sort = nil
  7754. m.addindex_sort = nil
  7755. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  7756. }
  7757. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  7758. func (m *SopStageMutation) IndexSortCleared() bool {
  7759. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  7760. return ok
  7761. }
  7762. // ResetIndexSort resets all changes to the "index_sort" field.
  7763. func (m *SopStageMutation) ResetIndexSort() {
  7764. m.index_sort = nil
  7765. m.addindex_sort = nil
  7766. delete(m.clearedFields, sopstage.FieldIndexSort)
  7767. }
  7768. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  7769. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  7770. m.sop_task = &id
  7771. }
  7772. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  7773. func (m *SopStageMutation) ClearSopTask() {
  7774. m.clearedsop_task = true
  7775. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  7776. }
  7777. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  7778. func (m *SopStageMutation) SopTaskCleared() bool {
  7779. return m.clearedsop_task
  7780. }
  7781. // SopTaskID returns the "sop_task" edge ID in the mutation.
  7782. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  7783. if m.sop_task != nil {
  7784. return *m.sop_task, true
  7785. }
  7786. return
  7787. }
  7788. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  7789. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  7790. // SopTaskID instead. It exists only for internal usage by the builders.
  7791. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  7792. if id := m.sop_task; id != nil {
  7793. ids = append(ids, *id)
  7794. }
  7795. return
  7796. }
  7797. // ResetSopTask resets all changes to the "sop_task" edge.
  7798. func (m *SopStageMutation) ResetSopTask() {
  7799. m.sop_task = nil
  7800. m.clearedsop_task = false
  7801. }
  7802. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  7803. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  7804. if m.stage_nodes == nil {
  7805. m.stage_nodes = make(map[uint64]struct{})
  7806. }
  7807. for i := range ids {
  7808. m.stage_nodes[ids[i]] = struct{}{}
  7809. }
  7810. }
  7811. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  7812. func (m *SopStageMutation) ClearStageNodes() {
  7813. m.clearedstage_nodes = true
  7814. }
  7815. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  7816. func (m *SopStageMutation) StageNodesCleared() bool {
  7817. return m.clearedstage_nodes
  7818. }
  7819. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  7820. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  7821. if m.removedstage_nodes == nil {
  7822. m.removedstage_nodes = make(map[uint64]struct{})
  7823. }
  7824. for i := range ids {
  7825. delete(m.stage_nodes, ids[i])
  7826. m.removedstage_nodes[ids[i]] = struct{}{}
  7827. }
  7828. }
  7829. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  7830. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  7831. for id := range m.removedstage_nodes {
  7832. ids = append(ids, id)
  7833. }
  7834. return
  7835. }
  7836. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  7837. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  7838. for id := range m.stage_nodes {
  7839. ids = append(ids, id)
  7840. }
  7841. return
  7842. }
  7843. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  7844. func (m *SopStageMutation) ResetStageNodes() {
  7845. m.stage_nodes = nil
  7846. m.clearedstage_nodes = false
  7847. m.removedstage_nodes = nil
  7848. }
  7849. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  7850. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  7851. if m.stage_messages == nil {
  7852. m.stage_messages = make(map[uint64]struct{})
  7853. }
  7854. for i := range ids {
  7855. m.stage_messages[ids[i]] = struct{}{}
  7856. }
  7857. }
  7858. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  7859. func (m *SopStageMutation) ClearStageMessages() {
  7860. m.clearedstage_messages = true
  7861. }
  7862. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  7863. func (m *SopStageMutation) StageMessagesCleared() bool {
  7864. return m.clearedstage_messages
  7865. }
  7866. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  7867. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  7868. if m.removedstage_messages == nil {
  7869. m.removedstage_messages = make(map[uint64]struct{})
  7870. }
  7871. for i := range ids {
  7872. delete(m.stage_messages, ids[i])
  7873. m.removedstage_messages[ids[i]] = struct{}{}
  7874. }
  7875. }
  7876. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  7877. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  7878. for id := range m.removedstage_messages {
  7879. ids = append(ids, id)
  7880. }
  7881. return
  7882. }
  7883. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  7884. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  7885. for id := range m.stage_messages {
  7886. ids = append(ids, id)
  7887. }
  7888. return
  7889. }
  7890. // ResetStageMessages resets all changes to the "stage_messages" edge.
  7891. func (m *SopStageMutation) ResetStageMessages() {
  7892. m.stage_messages = nil
  7893. m.clearedstage_messages = false
  7894. m.removedstage_messages = nil
  7895. }
  7896. // Where appends a list predicates to the SopStageMutation builder.
  7897. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  7898. m.predicates = append(m.predicates, ps...)
  7899. }
  7900. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  7901. // users can use type-assertion to append predicates that do not depend on any generated package.
  7902. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  7903. p := make([]predicate.SopStage, len(ps))
  7904. for i := range ps {
  7905. p[i] = ps[i]
  7906. }
  7907. m.Where(p...)
  7908. }
  7909. // Op returns the operation name.
  7910. func (m *SopStageMutation) Op() Op {
  7911. return m.op
  7912. }
  7913. // SetOp allows setting the mutation operation.
  7914. func (m *SopStageMutation) SetOp(op Op) {
  7915. m.op = op
  7916. }
  7917. // Type returns the node type of this mutation (SopStage).
  7918. func (m *SopStageMutation) Type() string {
  7919. return m.typ
  7920. }
  7921. // Fields returns all fields that were changed during this mutation. Note that in
  7922. // order to get all numeric fields that were incremented/decremented, call
  7923. // AddedFields().
  7924. func (m *SopStageMutation) Fields() []string {
  7925. fields := make([]string, 0, 12)
  7926. if m.created_at != nil {
  7927. fields = append(fields, sopstage.FieldCreatedAt)
  7928. }
  7929. if m.updated_at != nil {
  7930. fields = append(fields, sopstage.FieldUpdatedAt)
  7931. }
  7932. if m.status != nil {
  7933. fields = append(fields, sopstage.FieldStatus)
  7934. }
  7935. if m.deleted_at != nil {
  7936. fields = append(fields, sopstage.FieldDeletedAt)
  7937. }
  7938. if m.sop_task != nil {
  7939. fields = append(fields, sopstage.FieldTaskID)
  7940. }
  7941. if m.name != nil {
  7942. fields = append(fields, sopstage.FieldName)
  7943. }
  7944. if m.condition_type != nil {
  7945. fields = append(fields, sopstage.FieldConditionType)
  7946. }
  7947. if m.condition_operator != nil {
  7948. fields = append(fields, sopstage.FieldConditionOperator)
  7949. }
  7950. if m.condition_list != nil {
  7951. fields = append(fields, sopstage.FieldConditionList)
  7952. }
  7953. if m.action_message != nil {
  7954. fields = append(fields, sopstage.FieldActionMessage)
  7955. }
  7956. if m.action_label != nil {
  7957. fields = append(fields, sopstage.FieldActionLabel)
  7958. }
  7959. if m.index_sort != nil {
  7960. fields = append(fields, sopstage.FieldIndexSort)
  7961. }
  7962. return fields
  7963. }
  7964. // Field returns the value of a field with the given name. The second boolean
  7965. // return value indicates that this field was not set, or was not defined in the
  7966. // schema.
  7967. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  7968. switch name {
  7969. case sopstage.FieldCreatedAt:
  7970. return m.CreatedAt()
  7971. case sopstage.FieldUpdatedAt:
  7972. return m.UpdatedAt()
  7973. case sopstage.FieldStatus:
  7974. return m.Status()
  7975. case sopstage.FieldDeletedAt:
  7976. return m.DeletedAt()
  7977. case sopstage.FieldTaskID:
  7978. return m.TaskID()
  7979. case sopstage.FieldName:
  7980. return m.Name()
  7981. case sopstage.FieldConditionType:
  7982. return m.ConditionType()
  7983. case sopstage.FieldConditionOperator:
  7984. return m.ConditionOperator()
  7985. case sopstage.FieldConditionList:
  7986. return m.ConditionList()
  7987. case sopstage.FieldActionMessage:
  7988. return m.ActionMessage()
  7989. case sopstage.FieldActionLabel:
  7990. return m.ActionLabel()
  7991. case sopstage.FieldIndexSort:
  7992. return m.IndexSort()
  7993. }
  7994. return nil, false
  7995. }
  7996. // OldField returns the old value of the field from the database. An error is
  7997. // returned if the mutation operation is not UpdateOne, or the query to the
  7998. // database failed.
  7999. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8000. switch name {
  8001. case sopstage.FieldCreatedAt:
  8002. return m.OldCreatedAt(ctx)
  8003. case sopstage.FieldUpdatedAt:
  8004. return m.OldUpdatedAt(ctx)
  8005. case sopstage.FieldStatus:
  8006. return m.OldStatus(ctx)
  8007. case sopstage.FieldDeletedAt:
  8008. return m.OldDeletedAt(ctx)
  8009. case sopstage.FieldTaskID:
  8010. return m.OldTaskID(ctx)
  8011. case sopstage.FieldName:
  8012. return m.OldName(ctx)
  8013. case sopstage.FieldConditionType:
  8014. return m.OldConditionType(ctx)
  8015. case sopstage.FieldConditionOperator:
  8016. return m.OldConditionOperator(ctx)
  8017. case sopstage.FieldConditionList:
  8018. return m.OldConditionList(ctx)
  8019. case sopstage.FieldActionMessage:
  8020. return m.OldActionMessage(ctx)
  8021. case sopstage.FieldActionLabel:
  8022. return m.OldActionLabel(ctx)
  8023. case sopstage.FieldIndexSort:
  8024. return m.OldIndexSort(ctx)
  8025. }
  8026. return nil, fmt.Errorf("unknown SopStage field %s", name)
  8027. }
  8028. // SetField sets the value of a field with the given name. It returns an error if
  8029. // the field is not defined in the schema, or if the type mismatched the field
  8030. // type.
  8031. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  8032. switch name {
  8033. case sopstage.FieldCreatedAt:
  8034. v, ok := value.(time.Time)
  8035. if !ok {
  8036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8037. }
  8038. m.SetCreatedAt(v)
  8039. return nil
  8040. case sopstage.FieldUpdatedAt:
  8041. v, ok := value.(time.Time)
  8042. if !ok {
  8043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8044. }
  8045. m.SetUpdatedAt(v)
  8046. return nil
  8047. case sopstage.FieldStatus:
  8048. v, ok := value.(uint8)
  8049. if !ok {
  8050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8051. }
  8052. m.SetStatus(v)
  8053. return nil
  8054. case sopstage.FieldDeletedAt:
  8055. v, ok := value.(time.Time)
  8056. if !ok {
  8057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8058. }
  8059. m.SetDeletedAt(v)
  8060. return nil
  8061. case sopstage.FieldTaskID:
  8062. v, ok := value.(uint64)
  8063. if !ok {
  8064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8065. }
  8066. m.SetTaskID(v)
  8067. return nil
  8068. case sopstage.FieldName:
  8069. v, ok := value.(string)
  8070. if !ok {
  8071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8072. }
  8073. m.SetName(v)
  8074. return nil
  8075. case sopstage.FieldConditionType:
  8076. v, ok := value.(int)
  8077. if !ok {
  8078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8079. }
  8080. m.SetConditionType(v)
  8081. return nil
  8082. case sopstage.FieldConditionOperator:
  8083. v, ok := value.(int)
  8084. if !ok {
  8085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8086. }
  8087. m.SetConditionOperator(v)
  8088. return nil
  8089. case sopstage.FieldConditionList:
  8090. v, ok := value.([]custom_types.Condition)
  8091. if !ok {
  8092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8093. }
  8094. m.SetConditionList(v)
  8095. return nil
  8096. case sopstage.FieldActionMessage:
  8097. v, ok := value.([]custom_types.Action)
  8098. if !ok {
  8099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8100. }
  8101. m.SetActionMessage(v)
  8102. return nil
  8103. case sopstage.FieldActionLabel:
  8104. v, ok := value.([]uint64)
  8105. if !ok {
  8106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8107. }
  8108. m.SetActionLabel(v)
  8109. return nil
  8110. case sopstage.FieldIndexSort:
  8111. v, ok := value.(int)
  8112. if !ok {
  8113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8114. }
  8115. m.SetIndexSort(v)
  8116. return nil
  8117. }
  8118. return fmt.Errorf("unknown SopStage field %s", name)
  8119. }
  8120. // AddedFields returns all numeric fields that were incremented/decremented during
  8121. // this mutation.
  8122. func (m *SopStageMutation) AddedFields() []string {
  8123. var fields []string
  8124. if m.addstatus != nil {
  8125. fields = append(fields, sopstage.FieldStatus)
  8126. }
  8127. if m.addcondition_type != nil {
  8128. fields = append(fields, sopstage.FieldConditionType)
  8129. }
  8130. if m.addcondition_operator != nil {
  8131. fields = append(fields, sopstage.FieldConditionOperator)
  8132. }
  8133. if m.addindex_sort != nil {
  8134. fields = append(fields, sopstage.FieldIndexSort)
  8135. }
  8136. return fields
  8137. }
  8138. // AddedField returns the numeric value that was incremented/decremented on a field
  8139. // with the given name. The second boolean return value indicates that this field
  8140. // was not set, or was not defined in the schema.
  8141. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  8142. switch name {
  8143. case sopstage.FieldStatus:
  8144. return m.AddedStatus()
  8145. case sopstage.FieldConditionType:
  8146. return m.AddedConditionType()
  8147. case sopstage.FieldConditionOperator:
  8148. return m.AddedConditionOperator()
  8149. case sopstage.FieldIndexSort:
  8150. return m.AddedIndexSort()
  8151. }
  8152. return nil, false
  8153. }
  8154. // AddField adds the value to the field with the given name. It returns an error if
  8155. // the field is not defined in the schema, or if the type mismatched the field
  8156. // type.
  8157. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  8158. switch name {
  8159. case sopstage.FieldStatus:
  8160. v, ok := value.(int8)
  8161. if !ok {
  8162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8163. }
  8164. m.AddStatus(v)
  8165. return nil
  8166. case sopstage.FieldConditionType:
  8167. v, ok := value.(int)
  8168. if !ok {
  8169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8170. }
  8171. m.AddConditionType(v)
  8172. return nil
  8173. case sopstage.FieldConditionOperator:
  8174. v, ok := value.(int)
  8175. if !ok {
  8176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8177. }
  8178. m.AddConditionOperator(v)
  8179. return nil
  8180. case sopstage.FieldIndexSort:
  8181. v, ok := value.(int)
  8182. if !ok {
  8183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8184. }
  8185. m.AddIndexSort(v)
  8186. return nil
  8187. }
  8188. return fmt.Errorf("unknown SopStage numeric field %s", name)
  8189. }
  8190. // ClearedFields returns all nullable fields that were cleared during this
  8191. // mutation.
  8192. func (m *SopStageMutation) ClearedFields() []string {
  8193. var fields []string
  8194. if m.FieldCleared(sopstage.FieldStatus) {
  8195. fields = append(fields, sopstage.FieldStatus)
  8196. }
  8197. if m.FieldCleared(sopstage.FieldDeletedAt) {
  8198. fields = append(fields, sopstage.FieldDeletedAt)
  8199. }
  8200. if m.FieldCleared(sopstage.FieldActionMessage) {
  8201. fields = append(fields, sopstage.FieldActionMessage)
  8202. }
  8203. if m.FieldCleared(sopstage.FieldActionLabel) {
  8204. fields = append(fields, sopstage.FieldActionLabel)
  8205. }
  8206. if m.FieldCleared(sopstage.FieldIndexSort) {
  8207. fields = append(fields, sopstage.FieldIndexSort)
  8208. }
  8209. return fields
  8210. }
  8211. // FieldCleared returns a boolean indicating if a field with the given name was
  8212. // cleared in this mutation.
  8213. func (m *SopStageMutation) FieldCleared(name string) bool {
  8214. _, ok := m.clearedFields[name]
  8215. return ok
  8216. }
  8217. // ClearField clears the value of the field with the given name. It returns an
  8218. // error if the field is not defined in the schema.
  8219. func (m *SopStageMutation) ClearField(name string) error {
  8220. switch name {
  8221. case sopstage.FieldStatus:
  8222. m.ClearStatus()
  8223. return nil
  8224. case sopstage.FieldDeletedAt:
  8225. m.ClearDeletedAt()
  8226. return nil
  8227. case sopstage.FieldActionMessage:
  8228. m.ClearActionMessage()
  8229. return nil
  8230. case sopstage.FieldActionLabel:
  8231. m.ClearActionLabel()
  8232. return nil
  8233. case sopstage.FieldIndexSort:
  8234. m.ClearIndexSort()
  8235. return nil
  8236. }
  8237. return fmt.Errorf("unknown SopStage nullable field %s", name)
  8238. }
  8239. // ResetField resets all changes in the mutation for the field with the given name.
  8240. // It returns an error if the field is not defined in the schema.
  8241. func (m *SopStageMutation) ResetField(name string) error {
  8242. switch name {
  8243. case sopstage.FieldCreatedAt:
  8244. m.ResetCreatedAt()
  8245. return nil
  8246. case sopstage.FieldUpdatedAt:
  8247. m.ResetUpdatedAt()
  8248. return nil
  8249. case sopstage.FieldStatus:
  8250. m.ResetStatus()
  8251. return nil
  8252. case sopstage.FieldDeletedAt:
  8253. m.ResetDeletedAt()
  8254. return nil
  8255. case sopstage.FieldTaskID:
  8256. m.ResetTaskID()
  8257. return nil
  8258. case sopstage.FieldName:
  8259. m.ResetName()
  8260. return nil
  8261. case sopstage.FieldConditionType:
  8262. m.ResetConditionType()
  8263. return nil
  8264. case sopstage.FieldConditionOperator:
  8265. m.ResetConditionOperator()
  8266. return nil
  8267. case sopstage.FieldConditionList:
  8268. m.ResetConditionList()
  8269. return nil
  8270. case sopstage.FieldActionMessage:
  8271. m.ResetActionMessage()
  8272. return nil
  8273. case sopstage.FieldActionLabel:
  8274. m.ResetActionLabel()
  8275. return nil
  8276. case sopstage.FieldIndexSort:
  8277. m.ResetIndexSort()
  8278. return nil
  8279. }
  8280. return fmt.Errorf("unknown SopStage field %s", name)
  8281. }
  8282. // AddedEdges returns all edge names that were set/added in this mutation.
  8283. func (m *SopStageMutation) AddedEdges() []string {
  8284. edges := make([]string, 0, 3)
  8285. if m.sop_task != nil {
  8286. edges = append(edges, sopstage.EdgeSopTask)
  8287. }
  8288. if m.stage_nodes != nil {
  8289. edges = append(edges, sopstage.EdgeStageNodes)
  8290. }
  8291. if m.stage_messages != nil {
  8292. edges = append(edges, sopstage.EdgeStageMessages)
  8293. }
  8294. return edges
  8295. }
  8296. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8297. // name in this mutation.
  8298. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  8299. switch name {
  8300. case sopstage.EdgeSopTask:
  8301. if id := m.sop_task; id != nil {
  8302. return []ent.Value{*id}
  8303. }
  8304. case sopstage.EdgeStageNodes:
  8305. ids := make([]ent.Value, 0, len(m.stage_nodes))
  8306. for id := range m.stage_nodes {
  8307. ids = append(ids, id)
  8308. }
  8309. return ids
  8310. case sopstage.EdgeStageMessages:
  8311. ids := make([]ent.Value, 0, len(m.stage_messages))
  8312. for id := range m.stage_messages {
  8313. ids = append(ids, id)
  8314. }
  8315. return ids
  8316. }
  8317. return nil
  8318. }
  8319. // RemovedEdges returns all edge names that were removed in this mutation.
  8320. func (m *SopStageMutation) RemovedEdges() []string {
  8321. edges := make([]string, 0, 3)
  8322. if m.removedstage_nodes != nil {
  8323. edges = append(edges, sopstage.EdgeStageNodes)
  8324. }
  8325. if m.removedstage_messages != nil {
  8326. edges = append(edges, sopstage.EdgeStageMessages)
  8327. }
  8328. return edges
  8329. }
  8330. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8331. // the given name in this mutation.
  8332. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  8333. switch name {
  8334. case sopstage.EdgeStageNodes:
  8335. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  8336. for id := range m.removedstage_nodes {
  8337. ids = append(ids, id)
  8338. }
  8339. return ids
  8340. case sopstage.EdgeStageMessages:
  8341. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  8342. for id := range m.removedstage_messages {
  8343. ids = append(ids, id)
  8344. }
  8345. return ids
  8346. }
  8347. return nil
  8348. }
  8349. // ClearedEdges returns all edge names that were cleared in this mutation.
  8350. func (m *SopStageMutation) ClearedEdges() []string {
  8351. edges := make([]string, 0, 3)
  8352. if m.clearedsop_task {
  8353. edges = append(edges, sopstage.EdgeSopTask)
  8354. }
  8355. if m.clearedstage_nodes {
  8356. edges = append(edges, sopstage.EdgeStageNodes)
  8357. }
  8358. if m.clearedstage_messages {
  8359. edges = append(edges, sopstage.EdgeStageMessages)
  8360. }
  8361. return edges
  8362. }
  8363. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8364. // was cleared in this mutation.
  8365. func (m *SopStageMutation) EdgeCleared(name string) bool {
  8366. switch name {
  8367. case sopstage.EdgeSopTask:
  8368. return m.clearedsop_task
  8369. case sopstage.EdgeStageNodes:
  8370. return m.clearedstage_nodes
  8371. case sopstage.EdgeStageMessages:
  8372. return m.clearedstage_messages
  8373. }
  8374. return false
  8375. }
  8376. // ClearEdge clears the value of the edge with the given name. It returns an error
  8377. // if that edge is not defined in the schema.
  8378. func (m *SopStageMutation) ClearEdge(name string) error {
  8379. switch name {
  8380. case sopstage.EdgeSopTask:
  8381. m.ClearSopTask()
  8382. return nil
  8383. }
  8384. return fmt.Errorf("unknown SopStage unique edge %s", name)
  8385. }
  8386. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8387. // It returns an error if the edge is not defined in the schema.
  8388. func (m *SopStageMutation) ResetEdge(name string) error {
  8389. switch name {
  8390. case sopstage.EdgeSopTask:
  8391. m.ResetSopTask()
  8392. return nil
  8393. case sopstage.EdgeStageNodes:
  8394. m.ResetStageNodes()
  8395. return nil
  8396. case sopstage.EdgeStageMessages:
  8397. m.ResetStageMessages()
  8398. return nil
  8399. }
  8400. return fmt.Errorf("unknown SopStage edge %s", name)
  8401. }
  8402. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  8403. type SopTaskMutation struct {
  8404. config
  8405. op Op
  8406. typ string
  8407. id *uint64
  8408. created_at *time.Time
  8409. updated_at *time.Time
  8410. status *uint8
  8411. addstatus *int8
  8412. deleted_at *time.Time
  8413. name *string
  8414. bot_wxid_list *[]string
  8415. appendbot_wxid_list []string
  8416. _type *int
  8417. add_type *int
  8418. plan_start_time *time.Time
  8419. plan_end_time *time.Time
  8420. creator_id *string
  8421. clearedFields map[string]struct{}
  8422. task_stages map[uint64]struct{}
  8423. removedtask_stages map[uint64]struct{}
  8424. clearedtask_stages bool
  8425. done bool
  8426. oldValue func(context.Context) (*SopTask, error)
  8427. predicates []predicate.SopTask
  8428. }
  8429. var _ ent.Mutation = (*SopTaskMutation)(nil)
  8430. // soptaskOption allows management of the mutation configuration using functional options.
  8431. type soptaskOption func(*SopTaskMutation)
  8432. // newSopTaskMutation creates new mutation for the SopTask entity.
  8433. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  8434. m := &SopTaskMutation{
  8435. config: c,
  8436. op: op,
  8437. typ: TypeSopTask,
  8438. clearedFields: make(map[string]struct{}),
  8439. }
  8440. for _, opt := range opts {
  8441. opt(m)
  8442. }
  8443. return m
  8444. }
  8445. // withSopTaskID sets the ID field of the mutation.
  8446. func withSopTaskID(id uint64) soptaskOption {
  8447. return func(m *SopTaskMutation) {
  8448. var (
  8449. err error
  8450. once sync.Once
  8451. value *SopTask
  8452. )
  8453. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  8454. once.Do(func() {
  8455. if m.done {
  8456. err = errors.New("querying old values post mutation is not allowed")
  8457. } else {
  8458. value, err = m.Client().SopTask.Get(ctx, id)
  8459. }
  8460. })
  8461. return value, err
  8462. }
  8463. m.id = &id
  8464. }
  8465. }
  8466. // withSopTask sets the old SopTask of the mutation.
  8467. func withSopTask(node *SopTask) soptaskOption {
  8468. return func(m *SopTaskMutation) {
  8469. m.oldValue = func(context.Context) (*SopTask, error) {
  8470. return node, nil
  8471. }
  8472. m.id = &node.ID
  8473. }
  8474. }
  8475. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8476. // executed in a transaction (ent.Tx), a transactional client is returned.
  8477. func (m SopTaskMutation) Client() *Client {
  8478. client := &Client{config: m.config}
  8479. client.init()
  8480. return client
  8481. }
  8482. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8483. // it returns an error otherwise.
  8484. func (m SopTaskMutation) Tx() (*Tx, error) {
  8485. if _, ok := m.driver.(*txDriver); !ok {
  8486. return nil, errors.New("ent: mutation is not running in a transaction")
  8487. }
  8488. tx := &Tx{config: m.config}
  8489. tx.init()
  8490. return tx, nil
  8491. }
  8492. // SetID sets the value of the id field. Note that this
  8493. // operation is only accepted on creation of SopTask entities.
  8494. func (m *SopTaskMutation) SetID(id uint64) {
  8495. m.id = &id
  8496. }
  8497. // ID returns the ID value in the mutation. Note that the ID is only available
  8498. // if it was provided to the builder or after it was returned from the database.
  8499. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  8500. if m.id == nil {
  8501. return
  8502. }
  8503. return *m.id, true
  8504. }
  8505. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8506. // That means, if the mutation is applied within a transaction with an isolation level such
  8507. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8508. // or updated by the mutation.
  8509. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  8510. switch {
  8511. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8512. id, exists := m.ID()
  8513. if exists {
  8514. return []uint64{id}, nil
  8515. }
  8516. fallthrough
  8517. case m.op.Is(OpUpdate | OpDelete):
  8518. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  8519. default:
  8520. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8521. }
  8522. }
  8523. // SetCreatedAt sets the "created_at" field.
  8524. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  8525. m.created_at = &t
  8526. }
  8527. // CreatedAt returns the value of the "created_at" field in the mutation.
  8528. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  8529. v := m.created_at
  8530. if v == nil {
  8531. return
  8532. }
  8533. return *v, true
  8534. }
  8535. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  8536. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  8537. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8538. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8539. if !m.op.Is(OpUpdateOne) {
  8540. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8541. }
  8542. if m.id == nil || m.oldValue == nil {
  8543. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8544. }
  8545. oldValue, err := m.oldValue(ctx)
  8546. if err != nil {
  8547. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8548. }
  8549. return oldValue.CreatedAt, nil
  8550. }
  8551. // ResetCreatedAt resets all changes to the "created_at" field.
  8552. func (m *SopTaskMutation) ResetCreatedAt() {
  8553. m.created_at = nil
  8554. }
  8555. // SetUpdatedAt sets the "updated_at" field.
  8556. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  8557. m.updated_at = &t
  8558. }
  8559. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8560. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  8561. v := m.updated_at
  8562. if v == nil {
  8563. return
  8564. }
  8565. return *v, true
  8566. }
  8567. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  8568. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  8569. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8570. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8571. if !m.op.Is(OpUpdateOne) {
  8572. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8573. }
  8574. if m.id == nil || m.oldValue == nil {
  8575. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8576. }
  8577. oldValue, err := m.oldValue(ctx)
  8578. if err != nil {
  8579. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8580. }
  8581. return oldValue.UpdatedAt, nil
  8582. }
  8583. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8584. func (m *SopTaskMutation) ResetUpdatedAt() {
  8585. m.updated_at = nil
  8586. }
  8587. // SetStatus sets the "status" field.
  8588. func (m *SopTaskMutation) SetStatus(u uint8) {
  8589. m.status = &u
  8590. m.addstatus = nil
  8591. }
  8592. // Status returns the value of the "status" field in the mutation.
  8593. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  8594. v := m.status
  8595. if v == nil {
  8596. return
  8597. }
  8598. return *v, true
  8599. }
  8600. // OldStatus returns the old "status" field's value of the SopTask entity.
  8601. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  8602. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8603. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  8604. if !m.op.Is(OpUpdateOne) {
  8605. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  8606. }
  8607. if m.id == nil || m.oldValue == nil {
  8608. return v, errors.New("OldStatus requires an ID field in the mutation")
  8609. }
  8610. oldValue, err := m.oldValue(ctx)
  8611. if err != nil {
  8612. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  8613. }
  8614. return oldValue.Status, nil
  8615. }
  8616. // AddStatus adds u to the "status" field.
  8617. func (m *SopTaskMutation) AddStatus(u int8) {
  8618. if m.addstatus != nil {
  8619. *m.addstatus += u
  8620. } else {
  8621. m.addstatus = &u
  8622. }
  8623. }
  8624. // AddedStatus returns the value that was added to the "status" field in this mutation.
  8625. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  8626. v := m.addstatus
  8627. if v == nil {
  8628. return
  8629. }
  8630. return *v, true
  8631. }
  8632. // ClearStatus clears the value of the "status" field.
  8633. func (m *SopTaskMutation) ClearStatus() {
  8634. m.status = nil
  8635. m.addstatus = nil
  8636. m.clearedFields[soptask.FieldStatus] = struct{}{}
  8637. }
  8638. // StatusCleared returns if the "status" field was cleared in this mutation.
  8639. func (m *SopTaskMutation) StatusCleared() bool {
  8640. _, ok := m.clearedFields[soptask.FieldStatus]
  8641. return ok
  8642. }
  8643. // ResetStatus resets all changes to the "status" field.
  8644. func (m *SopTaskMutation) ResetStatus() {
  8645. m.status = nil
  8646. m.addstatus = nil
  8647. delete(m.clearedFields, soptask.FieldStatus)
  8648. }
  8649. // SetDeletedAt sets the "deleted_at" field.
  8650. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  8651. m.deleted_at = &t
  8652. }
  8653. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8654. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  8655. v := m.deleted_at
  8656. if v == nil {
  8657. return
  8658. }
  8659. return *v, true
  8660. }
  8661. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  8662. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  8663. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8664. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8665. if !m.op.Is(OpUpdateOne) {
  8666. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8667. }
  8668. if m.id == nil || m.oldValue == nil {
  8669. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8670. }
  8671. oldValue, err := m.oldValue(ctx)
  8672. if err != nil {
  8673. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8674. }
  8675. return oldValue.DeletedAt, nil
  8676. }
  8677. // ClearDeletedAt clears the value of the "deleted_at" field.
  8678. func (m *SopTaskMutation) ClearDeletedAt() {
  8679. m.deleted_at = nil
  8680. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  8681. }
  8682. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8683. func (m *SopTaskMutation) DeletedAtCleared() bool {
  8684. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  8685. return ok
  8686. }
  8687. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8688. func (m *SopTaskMutation) ResetDeletedAt() {
  8689. m.deleted_at = nil
  8690. delete(m.clearedFields, soptask.FieldDeletedAt)
  8691. }
  8692. // SetName sets the "name" field.
  8693. func (m *SopTaskMutation) SetName(s string) {
  8694. m.name = &s
  8695. }
  8696. // Name returns the value of the "name" field in the mutation.
  8697. func (m *SopTaskMutation) Name() (r string, exists bool) {
  8698. v := m.name
  8699. if v == nil {
  8700. return
  8701. }
  8702. return *v, true
  8703. }
  8704. // OldName returns the old "name" field's value of the SopTask entity.
  8705. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  8706. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8707. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  8708. if !m.op.Is(OpUpdateOne) {
  8709. return v, errors.New("OldName is only allowed on UpdateOne operations")
  8710. }
  8711. if m.id == nil || m.oldValue == nil {
  8712. return v, errors.New("OldName requires an ID field in the mutation")
  8713. }
  8714. oldValue, err := m.oldValue(ctx)
  8715. if err != nil {
  8716. return v, fmt.Errorf("querying old value for OldName: %w", err)
  8717. }
  8718. return oldValue.Name, nil
  8719. }
  8720. // ResetName resets all changes to the "name" field.
  8721. func (m *SopTaskMutation) ResetName() {
  8722. m.name = nil
  8723. }
  8724. // SetBotWxidList sets the "bot_wxid_list" field.
  8725. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  8726. m.bot_wxid_list = &s
  8727. m.appendbot_wxid_list = nil
  8728. }
  8729. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  8730. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  8731. v := m.bot_wxid_list
  8732. if v == nil {
  8733. return
  8734. }
  8735. return *v, true
  8736. }
  8737. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  8738. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  8739. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8740. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  8741. if !m.op.Is(OpUpdateOne) {
  8742. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  8743. }
  8744. if m.id == nil || m.oldValue == nil {
  8745. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  8746. }
  8747. oldValue, err := m.oldValue(ctx)
  8748. if err != nil {
  8749. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  8750. }
  8751. return oldValue.BotWxidList, nil
  8752. }
  8753. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  8754. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  8755. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  8756. }
  8757. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  8758. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  8759. if len(m.appendbot_wxid_list) == 0 {
  8760. return nil, false
  8761. }
  8762. return m.appendbot_wxid_list, true
  8763. }
  8764. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  8765. func (m *SopTaskMutation) ClearBotWxidList() {
  8766. m.bot_wxid_list = nil
  8767. m.appendbot_wxid_list = nil
  8768. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  8769. }
  8770. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  8771. func (m *SopTaskMutation) BotWxidListCleared() bool {
  8772. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  8773. return ok
  8774. }
  8775. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  8776. func (m *SopTaskMutation) ResetBotWxidList() {
  8777. m.bot_wxid_list = nil
  8778. m.appendbot_wxid_list = nil
  8779. delete(m.clearedFields, soptask.FieldBotWxidList)
  8780. }
  8781. // SetType sets the "type" field.
  8782. func (m *SopTaskMutation) SetType(i int) {
  8783. m._type = &i
  8784. m.add_type = nil
  8785. }
  8786. // GetType returns the value of the "type" field in the mutation.
  8787. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  8788. v := m._type
  8789. if v == nil {
  8790. return
  8791. }
  8792. return *v, true
  8793. }
  8794. // OldType returns the old "type" field's value of the SopTask entity.
  8795. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  8796. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8797. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  8798. if !m.op.Is(OpUpdateOne) {
  8799. return v, errors.New("OldType is only allowed on UpdateOne operations")
  8800. }
  8801. if m.id == nil || m.oldValue == nil {
  8802. return v, errors.New("OldType requires an ID field in the mutation")
  8803. }
  8804. oldValue, err := m.oldValue(ctx)
  8805. if err != nil {
  8806. return v, fmt.Errorf("querying old value for OldType: %w", err)
  8807. }
  8808. return oldValue.Type, nil
  8809. }
  8810. // AddType adds i to the "type" field.
  8811. func (m *SopTaskMutation) AddType(i int) {
  8812. if m.add_type != nil {
  8813. *m.add_type += i
  8814. } else {
  8815. m.add_type = &i
  8816. }
  8817. }
  8818. // AddedType returns the value that was added to the "type" field in this mutation.
  8819. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  8820. v := m.add_type
  8821. if v == nil {
  8822. return
  8823. }
  8824. return *v, true
  8825. }
  8826. // ResetType resets all changes to the "type" field.
  8827. func (m *SopTaskMutation) ResetType() {
  8828. m._type = nil
  8829. m.add_type = nil
  8830. }
  8831. // SetPlanStartTime sets the "plan_start_time" field.
  8832. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  8833. m.plan_start_time = &t
  8834. }
  8835. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  8836. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  8837. v := m.plan_start_time
  8838. if v == nil {
  8839. return
  8840. }
  8841. return *v, true
  8842. }
  8843. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  8844. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  8845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8846. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  8847. if !m.op.Is(OpUpdateOne) {
  8848. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  8849. }
  8850. if m.id == nil || m.oldValue == nil {
  8851. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  8852. }
  8853. oldValue, err := m.oldValue(ctx)
  8854. if err != nil {
  8855. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  8856. }
  8857. return oldValue.PlanStartTime, nil
  8858. }
  8859. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  8860. func (m *SopTaskMutation) ClearPlanStartTime() {
  8861. m.plan_start_time = nil
  8862. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  8863. }
  8864. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  8865. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  8866. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  8867. return ok
  8868. }
  8869. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  8870. func (m *SopTaskMutation) ResetPlanStartTime() {
  8871. m.plan_start_time = nil
  8872. delete(m.clearedFields, soptask.FieldPlanStartTime)
  8873. }
  8874. // SetPlanEndTime sets the "plan_end_time" field.
  8875. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  8876. m.plan_end_time = &t
  8877. }
  8878. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  8879. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  8880. v := m.plan_end_time
  8881. if v == nil {
  8882. return
  8883. }
  8884. return *v, true
  8885. }
  8886. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  8887. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  8888. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8889. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  8890. if !m.op.Is(OpUpdateOne) {
  8891. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  8892. }
  8893. if m.id == nil || m.oldValue == nil {
  8894. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  8895. }
  8896. oldValue, err := m.oldValue(ctx)
  8897. if err != nil {
  8898. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  8899. }
  8900. return oldValue.PlanEndTime, nil
  8901. }
  8902. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  8903. func (m *SopTaskMutation) ClearPlanEndTime() {
  8904. m.plan_end_time = nil
  8905. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  8906. }
  8907. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  8908. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  8909. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  8910. return ok
  8911. }
  8912. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  8913. func (m *SopTaskMutation) ResetPlanEndTime() {
  8914. m.plan_end_time = nil
  8915. delete(m.clearedFields, soptask.FieldPlanEndTime)
  8916. }
  8917. // SetCreatorID sets the "creator_id" field.
  8918. func (m *SopTaskMutation) SetCreatorID(s string) {
  8919. m.creator_id = &s
  8920. }
  8921. // CreatorID returns the value of the "creator_id" field in the mutation.
  8922. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  8923. v := m.creator_id
  8924. if v == nil {
  8925. return
  8926. }
  8927. return *v, true
  8928. }
  8929. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  8930. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  8931. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8932. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  8933. if !m.op.Is(OpUpdateOne) {
  8934. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  8935. }
  8936. if m.id == nil || m.oldValue == nil {
  8937. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  8938. }
  8939. oldValue, err := m.oldValue(ctx)
  8940. if err != nil {
  8941. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  8942. }
  8943. return oldValue.CreatorID, nil
  8944. }
  8945. // ClearCreatorID clears the value of the "creator_id" field.
  8946. func (m *SopTaskMutation) ClearCreatorID() {
  8947. m.creator_id = nil
  8948. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  8949. }
  8950. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  8951. func (m *SopTaskMutation) CreatorIDCleared() bool {
  8952. _, ok := m.clearedFields[soptask.FieldCreatorID]
  8953. return ok
  8954. }
  8955. // ResetCreatorID resets all changes to the "creator_id" field.
  8956. func (m *SopTaskMutation) ResetCreatorID() {
  8957. m.creator_id = nil
  8958. delete(m.clearedFields, soptask.FieldCreatorID)
  8959. }
  8960. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  8961. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  8962. if m.task_stages == nil {
  8963. m.task_stages = make(map[uint64]struct{})
  8964. }
  8965. for i := range ids {
  8966. m.task_stages[ids[i]] = struct{}{}
  8967. }
  8968. }
  8969. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  8970. func (m *SopTaskMutation) ClearTaskStages() {
  8971. m.clearedtask_stages = true
  8972. }
  8973. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  8974. func (m *SopTaskMutation) TaskStagesCleared() bool {
  8975. return m.clearedtask_stages
  8976. }
  8977. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  8978. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  8979. if m.removedtask_stages == nil {
  8980. m.removedtask_stages = make(map[uint64]struct{})
  8981. }
  8982. for i := range ids {
  8983. delete(m.task_stages, ids[i])
  8984. m.removedtask_stages[ids[i]] = struct{}{}
  8985. }
  8986. }
  8987. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  8988. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  8989. for id := range m.removedtask_stages {
  8990. ids = append(ids, id)
  8991. }
  8992. return
  8993. }
  8994. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  8995. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  8996. for id := range m.task_stages {
  8997. ids = append(ids, id)
  8998. }
  8999. return
  9000. }
  9001. // ResetTaskStages resets all changes to the "task_stages" edge.
  9002. func (m *SopTaskMutation) ResetTaskStages() {
  9003. m.task_stages = nil
  9004. m.clearedtask_stages = false
  9005. m.removedtask_stages = nil
  9006. }
  9007. // Where appends a list predicates to the SopTaskMutation builder.
  9008. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  9009. m.predicates = append(m.predicates, ps...)
  9010. }
  9011. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  9012. // users can use type-assertion to append predicates that do not depend on any generated package.
  9013. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  9014. p := make([]predicate.SopTask, len(ps))
  9015. for i := range ps {
  9016. p[i] = ps[i]
  9017. }
  9018. m.Where(p...)
  9019. }
  9020. // Op returns the operation name.
  9021. func (m *SopTaskMutation) Op() Op {
  9022. return m.op
  9023. }
  9024. // SetOp allows setting the mutation operation.
  9025. func (m *SopTaskMutation) SetOp(op Op) {
  9026. m.op = op
  9027. }
  9028. // Type returns the node type of this mutation (SopTask).
  9029. func (m *SopTaskMutation) Type() string {
  9030. return m.typ
  9031. }
  9032. // Fields returns all fields that were changed during this mutation. Note that in
  9033. // order to get all numeric fields that were incremented/decremented, call
  9034. // AddedFields().
  9035. func (m *SopTaskMutation) Fields() []string {
  9036. fields := make([]string, 0, 10)
  9037. if m.created_at != nil {
  9038. fields = append(fields, soptask.FieldCreatedAt)
  9039. }
  9040. if m.updated_at != nil {
  9041. fields = append(fields, soptask.FieldUpdatedAt)
  9042. }
  9043. if m.status != nil {
  9044. fields = append(fields, soptask.FieldStatus)
  9045. }
  9046. if m.deleted_at != nil {
  9047. fields = append(fields, soptask.FieldDeletedAt)
  9048. }
  9049. if m.name != nil {
  9050. fields = append(fields, soptask.FieldName)
  9051. }
  9052. if m.bot_wxid_list != nil {
  9053. fields = append(fields, soptask.FieldBotWxidList)
  9054. }
  9055. if m._type != nil {
  9056. fields = append(fields, soptask.FieldType)
  9057. }
  9058. if m.plan_start_time != nil {
  9059. fields = append(fields, soptask.FieldPlanStartTime)
  9060. }
  9061. if m.plan_end_time != nil {
  9062. fields = append(fields, soptask.FieldPlanEndTime)
  9063. }
  9064. if m.creator_id != nil {
  9065. fields = append(fields, soptask.FieldCreatorID)
  9066. }
  9067. return fields
  9068. }
  9069. // Field returns the value of a field with the given name. The second boolean
  9070. // return value indicates that this field was not set, or was not defined in the
  9071. // schema.
  9072. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  9073. switch name {
  9074. case soptask.FieldCreatedAt:
  9075. return m.CreatedAt()
  9076. case soptask.FieldUpdatedAt:
  9077. return m.UpdatedAt()
  9078. case soptask.FieldStatus:
  9079. return m.Status()
  9080. case soptask.FieldDeletedAt:
  9081. return m.DeletedAt()
  9082. case soptask.FieldName:
  9083. return m.Name()
  9084. case soptask.FieldBotWxidList:
  9085. return m.BotWxidList()
  9086. case soptask.FieldType:
  9087. return m.GetType()
  9088. case soptask.FieldPlanStartTime:
  9089. return m.PlanStartTime()
  9090. case soptask.FieldPlanEndTime:
  9091. return m.PlanEndTime()
  9092. case soptask.FieldCreatorID:
  9093. return m.CreatorID()
  9094. }
  9095. return nil, false
  9096. }
  9097. // OldField returns the old value of the field from the database. An error is
  9098. // returned if the mutation operation is not UpdateOne, or the query to the
  9099. // database failed.
  9100. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9101. switch name {
  9102. case soptask.FieldCreatedAt:
  9103. return m.OldCreatedAt(ctx)
  9104. case soptask.FieldUpdatedAt:
  9105. return m.OldUpdatedAt(ctx)
  9106. case soptask.FieldStatus:
  9107. return m.OldStatus(ctx)
  9108. case soptask.FieldDeletedAt:
  9109. return m.OldDeletedAt(ctx)
  9110. case soptask.FieldName:
  9111. return m.OldName(ctx)
  9112. case soptask.FieldBotWxidList:
  9113. return m.OldBotWxidList(ctx)
  9114. case soptask.FieldType:
  9115. return m.OldType(ctx)
  9116. case soptask.FieldPlanStartTime:
  9117. return m.OldPlanStartTime(ctx)
  9118. case soptask.FieldPlanEndTime:
  9119. return m.OldPlanEndTime(ctx)
  9120. case soptask.FieldCreatorID:
  9121. return m.OldCreatorID(ctx)
  9122. }
  9123. return nil, fmt.Errorf("unknown SopTask field %s", name)
  9124. }
  9125. // SetField sets the value of a field with the given name. It returns an error if
  9126. // the field is not defined in the schema, or if the type mismatched the field
  9127. // type.
  9128. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  9129. switch name {
  9130. case soptask.FieldCreatedAt:
  9131. v, ok := value.(time.Time)
  9132. if !ok {
  9133. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9134. }
  9135. m.SetCreatedAt(v)
  9136. return nil
  9137. case soptask.FieldUpdatedAt:
  9138. v, ok := value.(time.Time)
  9139. if !ok {
  9140. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9141. }
  9142. m.SetUpdatedAt(v)
  9143. return nil
  9144. case soptask.FieldStatus:
  9145. v, ok := value.(uint8)
  9146. if !ok {
  9147. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9148. }
  9149. m.SetStatus(v)
  9150. return nil
  9151. case soptask.FieldDeletedAt:
  9152. v, ok := value.(time.Time)
  9153. if !ok {
  9154. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9155. }
  9156. m.SetDeletedAt(v)
  9157. return nil
  9158. case soptask.FieldName:
  9159. v, ok := value.(string)
  9160. if !ok {
  9161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9162. }
  9163. m.SetName(v)
  9164. return nil
  9165. case soptask.FieldBotWxidList:
  9166. v, ok := value.([]string)
  9167. if !ok {
  9168. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9169. }
  9170. m.SetBotWxidList(v)
  9171. return nil
  9172. case soptask.FieldType:
  9173. v, ok := value.(int)
  9174. if !ok {
  9175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9176. }
  9177. m.SetType(v)
  9178. return nil
  9179. case soptask.FieldPlanStartTime:
  9180. v, ok := value.(time.Time)
  9181. if !ok {
  9182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9183. }
  9184. m.SetPlanStartTime(v)
  9185. return nil
  9186. case soptask.FieldPlanEndTime:
  9187. v, ok := value.(time.Time)
  9188. if !ok {
  9189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9190. }
  9191. m.SetPlanEndTime(v)
  9192. return nil
  9193. case soptask.FieldCreatorID:
  9194. v, ok := value.(string)
  9195. if !ok {
  9196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9197. }
  9198. m.SetCreatorID(v)
  9199. return nil
  9200. }
  9201. return fmt.Errorf("unknown SopTask field %s", name)
  9202. }
  9203. // AddedFields returns all numeric fields that were incremented/decremented during
  9204. // this mutation.
  9205. func (m *SopTaskMutation) AddedFields() []string {
  9206. var fields []string
  9207. if m.addstatus != nil {
  9208. fields = append(fields, soptask.FieldStatus)
  9209. }
  9210. if m.add_type != nil {
  9211. fields = append(fields, soptask.FieldType)
  9212. }
  9213. return fields
  9214. }
  9215. // AddedField returns the numeric value that was incremented/decremented on a field
  9216. // with the given name. The second boolean return value indicates that this field
  9217. // was not set, or was not defined in the schema.
  9218. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  9219. switch name {
  9220. case soptask.FieldStatus:
  9221. return m.AddedStatus()
  9222. case soptask.FieldType:
  9223. return m.AddedType()
  9224. }
  9225. return nil, false
  9226. }
  9227. // AddField adds the value to the field with the given name. It returns an error if
  9228. // the field is not defined in the schema, or if the type mismatched the field
  9229. // type.
  9230. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  9231. switch name {
  9232. case soptask.FieldStatus:
  9233. v, ok := value.(int8)
  9234. if !ok {
  9235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9236. }
  9237. m.AddStatus(v)
  9238. return nil
  9239. case soptask.FieldType:
  9240. v, ok := value.(int)
  9241. if !ok {
  9242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9243. }
  9244. m.AddType(v)
  9245. return nil
  9246. }
  9247. return fmt.Errorf("unknown SopTask numeric field %s", name)
  9248. }
  9249. // ClearedFields returns all nullable fields that were cleared during this
  9250. // mutation.
  9251. func (m *SopTaskMutation) ClearedFields() []string {
  9252. var fields []string
  9253. if m.FieldCleared(soptask.FieldStatus) {
  9254. fields = append(fields, soptask.FieldStatus)
  9255. }
  9256. if m.FieldCleared(soptask.FieldDeletedAt) {
  9257. fields = append(fields, soptask.FieldDeletedAt)
  9258. }
  9259. if m.FieldCleared(soptask.FieldBotWxidList) {
  9260. fields = append(fields, soptask.FieldBotWxidList)
  9261. }
  9262. if m.FieldCleared(soptask.FieldPlanStartTime) {
  9263. fields = append(fields, soptask.FieldPlanStartTime)
  9264. }
  9265. if m.FieldCleared(soptask.FieldPlanEndTime) {
  9266. fields = append(fields, soptask.FieldPlanEndTime)
  9267. }
  9268. if m.FieldCleared(soptask.FieldCreatorID) {
  9269. fields = append(fields, soptask.FieldCreatorID)
  9270. }
  9271. return fields
  9272. }
  9273. // FieldCleared returns a boolean indicating if a field with the given name was
  9274. // cleared in this mutation.
  9275. func (m *SopTaskMutation) FieldCleared(name string) bool {
  9276. _, ok := m.clearedFields[name]
  9277. return ok
  9278. }
  9279. // ClearField clears the value of the field with the given name. It returns an
  9280. // error if the field is not defined in the schema.
  9281. func (m *SopTaskMutation) ClearField(name string) error {
  9282. switch name {
  9283. case soptask.FieldStatus:
  9284. m.ClearStatus()
  9285. return nil
  9286. case soptask.FieldDeletedAt:
  9287. m.ClearDeletedAt()
  9288. return nil
  9289. case soptask.FieldBotWxidList:
  9290. m.ClearBotWxidList()
  9291. return nil
  9292. case soptask.FieldPlanStartTime:
  9293. m.ClearPlanStartTime()
  9294. return nil
  9295. case soptask.FieldPlanEndTime:
  9296. m.ClearPlanEndTime()
  9297. return nil
  9298. case soptask.FieldCreatorID:
  9299. m.ClearCreatorID()
  9300. return nil
  9301. }
  9302. return fmt.Errorf("unknown SopTask nullable field %s", name)
  9303. }
  9304. // ResetField resets all changes in the mutation for the field with the given name.
  9305. // It returns an error if the field is not defined in the schema.
  9306. func (m *SopTaskMutation) ResetField(name string) error {
  9307. switch name {
  9308. case soptask.FieldCreatedAt:
  9309. m.ResetCreatedAt()
  9310. return nil
  9311. case soptask.FieldUpdatedAt:
  9312. m.ResetUpdatedAt()
  9313. return nil
  9314. case soptask.FieldStatus:
  9315. m.ResetStatus()
  9316. return nil
  9317. case soptask.FieldDeletedAt:
  9318. m.ResetDeletedAt()
  9319. return nil
  9320. case soptask.FieldName:
  9321. m.ResetName()
  9322. return nil
  9323. case soptask.FieldBotWxidList:
  9324. m.ResetBotWxidList()
  9325. return nil
  9326. case soptask.FieldType:
  9327. m.ResetType()
  9328. return nil
  9329. case soptask.FieldPlanStartTime:
  9330. m.ResetPlanStartTime()
  9331. return nil
  9332. case soptask.FieldPlanEndTime:
  9333. m.ResetPlanEndTime()
  9334. return nil
  9335. case soptask.FieldCreatorID:
  9336. m.ResetCreatorID()
  9337. return nil
  9338. }
  9339. return fmt.Errorf("unknown SopTask field %s", name)
  9340. }
  9341. // AddedEdges returns all edge names that were set/added in this mutation.
  9342. func (m *SopTaskMutation) AddedEdges() []string {
  9343. edges := make([]string, 0, 1)
  9344. if m.task_stages != nil {
  9345. edges = append(edges, soptask.EdgeTaskStages)
  9346. }
  9347. return edges
  9348. }
  9349. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9350. // name in this mutation.
  9351. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  9352. switch name {
  9353. case soptask.EdgeTaskStages:
  9354. ids := make([]ent.Value, 0, len(m.task_stages))
  9355. for id := range m.task_stages {
  9356. ids = append(ids, id)
  9357. }
  9358. return ids
  9359. }
  9360. return nil
  9361. }
  9362. // RemovedEdges returns all edge names that were removed in this mutation.
  9363. func (m *SopTaskMutation) RemovedEdges() []string {
  9364. edges := make([]string, 0, 1)
  9365. if m.removedtask_stages != nil {
  9366. edges = append(edges, soptask.EdgeTaskStages)
  9367. }
  9368. return edges
  9369. }
  9370. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9371. // the given name in this mutation.
  9372. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  9373. switch name {
  9374. case soptask.EdgeTaskStages:
  9375. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  9376. for id := range m.removedtask_stages {
  9377. ids = append(ids, id)
  9378. }
  9379. return ids
  9380. }
  9381. return nil
  9382. }
  9383. // ClearedEdges returns all edge names that were cleared in this mutation.
  9384. func (m *SopTaskMutation) ClearedEdges() []string {
  9385. edges := make([]string, 0, 1)
  9386. if m.clearedtask_stages {
  9387. edges = append(edges, soptask.EdgeTaskStages)
  9388. }
  9389. return edges
  9390. }
  9391. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9392. // was cleared in this mutation.
  9393. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  9394. switch name {
  9395. case soptask.EdgeTaskStages:
  9396. return m.clearedtask_stages
  9397. }
  9398. return false
  9399. }
  9400. // ClearEdge clears the value of the edge with the given name. It returns an error
  9401. // if that edge is not defined in the schema.
  9402. func (m *SopTaskMutation) ClearEdge(name string) error {
  9403. switch name {
  9404. }
  9405. return fmt.Errorf("unknown SopTask unique edge %s", name)
  9406. }
  9407. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9408. // It returns an error if the edge is not defined in the schema.
  9409. func (m *SopTaskMutation) ResetEdge(name string) error {
  9410. switch name {
  9411. case soptask.EdgeTaskStages:
  9412. m.ResetTaskStages()
  9413. return nil
  9414. }
  9415. return fmt.Errorf("unknown SopTask edge %s", name)
  9416. }
  9417. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  9418. type WxMutation struct {
  9419. config
  9420. op Op
  9421. typ string
  9422. id *uint64
  9423. created_at *time.Time
  9424. updated_at *time.Time
  9425. status *uint8
  9426. addstatus *int8
  9427. deleted_at *time.Time
  9428. port *string
  9429. process_id *string
  9430. callback *string
  9431. wxid *string
  9432. account *string
  9433. nickname *string
  9434. tel *string
  9435. head_big *string
  9436. clearedFields map[string]struct{}
  9437. server *uint64
  9438. clearedserver bool
  9439. done bool
  9440. oldValue func(context.Context) (*Wx, error)
  9441. predicates []predicate.Wx
  9442. }
  9443. var _ ent.Mutation = (*WxMutation)(nil)
  9444. // wxOption allows management of the mutation configuration using functional options.
  9445. type wxOption func(*WxMutation)
  9446. // newWxMutation creates new mutation for the Wx entity.
  9447. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  9448. m := &WxMutation{
  9449. config: c,
  9450. op: op,
  9451. typ: TypeWx,
  9452. clearedFields: make(map[string]struct{}),
  9453. }
  9454. for _, opt := range opts {
  9455. opt(m)
  9456. }
  9457. return m
  9458. }
  9459. // withWxID sets the ID field of the mutation.
  9460. func withWxID(id uint64) wxOption {
  9461. return func(m *WxMutation) {
  9462. var (
  9463. err error
  9464. once sync.Once
  9465. value *Wx
  9466. )
  9467. m.oldValue = func(ctx context.Context) (*Wx, error) {
  9468. once.Do(func() {
  9469. if m.done {
  9470. err = errors.New("querying old values post mutation is not allowed")
  9471. } else {
  9472. value, err = m.Client().Wx.Get(ctx, id)
  9473. }
  9474. })
  9475. return value, err
  9476. }
  9477. m.id = &id
  9478. }
  9479. }
  9480. // withWx sets the old Wx of the mutation.
  9481. func withWx(node *Wx) wxOption {
  9482. return func(m *WxMutation) {
  9483. m.oldValue = func(context.Context) (*Wx, error) {
  9484. return node, nil
  9485. }
  9486. m.id = &node.ID
  9487. }
  9488. }
  9489. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9490. // executed in a transaction (ent.Tx), a transactional client is returned.
  9491. func (m WxMutation) Client() *Client {
  9492. client := &Client{config: m.config}
  9493. client.init()
  9494. return client
  9495. }
  9496. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9497. // it returns an error otherwise.
  9498. func (m WxMutation) Tx() (*Tx, error) {
  9499. if _, ok := m.driver.(*txDriver); !ok {
  9500. return nil, errors.New("ent: mutation is not running in a transaction")
  9501. }
  9502. tx := &Tx{config: m.config}
  9503. tx.init()
  9504. return tx, nil
  9505. }
  9506. // SetID sets the value of the id field. Note that this
  9507. // operation is only accepted on creation of Wx entities.
  9508. func (m *WxMutation) SetID(id uint64) {
  9509. m.id = &id
  9510. }
  9511. // ID returns the ID value in the mutation. Note that the ID is only available
  9512. // if it was provided to the builder or after it was returned from the database.
  9513. func (m *WxMutation) ID() (id uint64, exists bool) {
  9514. if m.id == nil {
  9515. return
  9516. }
  9517. return *m.id, true
  9518. }
  9519. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9520. // That means, if the mutation is applied within a transaction with an isolation level such
  9521. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9522. // or updated by the mutation.
  9523. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  9524. switch {
  9525. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9526. id, exists := m.ID()
  9527. if exists {
  9528. return []uint64{id}, nil
  9529. }
  9530. fallthrough
  9531. case m.op.Is(OpUpdate | OpDelete):
  9532. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  9533. default:
  9534. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9535. }
  9536. }
  9537. // SetCreatedAt sets the "created_at" field.
  9538. func (m *WxMutation) SetCreatedAt(t time.Time) {
  9539. m.created_at = &t
  9540. }
  9541. // CreatedAt returns the value of the "created_at" field in the mutation.
  9542. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  9543. v := m.created_at
  9544. if v == nil {
  9545. return
  9546. }
  9547. return *v, true
  9548. }
  9549. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  9550. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  9551. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9552. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9553. if !m.op.Is(OpUpdateOne) {
  9554. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9555. }
  9556. if m.id == nil || m.oldValue == nil {
  9557. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9558. }
  9559. oldValue, err := m.oldValue(ctx)
  9560. if err != nil {
  9561. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9562. }
  9563. return oldValue.CreatedAt, nil
  9564. }
  9565. // ResetCreatedAt resets all changes to the "created_at" field.
  9566. func (m *WxMutation) ResetCreatedAt() {
  9567. m.created_at = nil
  9568. }
  9569. // SetUpdatedAt sets the "updated_at" field.
  9570. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  9571. m.updated_at = &t
  9572. }
  9573. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9574. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  9575. v := m.updated_at
  9576. if v == nil {
  9577. return
  9578. }
  9579. return *v, true
  9580. }
  9581. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  9582. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  9583. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9584. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9585. if !m.op.Is(OpUpdateOne) {
  9586. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9587. }
  9588. if m.id == nil || m.oldValue == nil {
  9589. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9590. }
  9591. oldValue, err := m.oldValue(ctx)
  9592. if err != nil {
  9593. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9594. }
  9595. return oldValue.UpdatedAt, nil
  9596. }
  9597. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9598. func (m *WxMutation) ResetUpdatedAt() {
  9599. m.updated_at = nil
  9600. }
  9601. // SetStatus sets the "status" field.
  9602. func (m *WxMutation) SetStatus(u uint8) {
  9603. m.status = &u
  9604. m.addstatus = nil
  9605. }
  9606. // Status returns the value of the "status" field in the mutation.
  9607. func (m *WxMutation) Status() (r uint8, exists bool) {
  9608. v := m.status
  9609. if v == nil {
  9610. return
  9611. }
  9612. return *v, true
  9613. }
  9614. // OldStatus returns the old "status" field's value of the Wx entity.
  9615. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  9616. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9617. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  9618. if !m.op.Is(OpUpdateOne) {
  9619. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9620. }
  9621. if m.id == nil || m.oldValue == nil {
  9622. return v, errors.New("OldStatus requires an ID field in the mutation")
  9623. }
  9624. oldValue, err := m.oldValue(ctx)
  9625. if err != nil {
  9626. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9627. }
  9628. return oldValue.Status, nil
  9629. }
  9630. // AddStatus adds u to the "status" field.
  9631. func (m *WxMutation) AddStatus(u int8) {
  9632. if m.addstatus != nil {
  9633. *m.addstatus += u
  9634. } else {
  9635. m.addstatus = &u
  9636. }
  9637. }
  9638. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9639. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  9640. v := m.addstatus
  9641. if v == nil {
  9642. return
  9643. }
  9644. return *v, true
  9645. }
  9646. // ClearStatus clears the value of the "status" field.
  9647. func (m *WxMutation) ClearStatus() {
  9648. m.status = nil
  9649. m.addstatus = nil
  9650. m.clearedFields[wx.FieldStatus] = struct{}{}
  9651. }
  9652. // StatusCleared returns if the "status" field was cleared in this mutation.
  9653. func (m *WxMutation) StatusCleared() bool {
  9654. _, ok := m.clearedFields[wx.FieldStatus]
  9655. return ok
  9656. }
  9657. // ResetStatus resets all changes to the "status" field.
  9658. func (m *WxMutation) ResetStatus() {
  9659. m.status = nil
  9660. m.addstatus = nil
  9661. delete(m.clearedFields, wx.FieldStatus)
  9662. }
  9663. // SetDeletedAt sets the "deleted_at" field.
  9664. func (m *WxMutation) SetDeletedAt(t time.Time) {
  9665. m.deleted_at = &t
  9666. }
  9667. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9668. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  9669. v := m.deleted_at
  9670. if v == nil {
  9671. return
  9672. }
  9673. return *v, true
  9674. }
  9675. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  9676. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  9677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9678. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9679. if !m.op.Is(OpUpdateOne) {
  9680. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9681. }
  9682. if m.id == nil || m.oldValue == nil {
  9683. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9684. }
  9685. oldValue, err := m.oldValue(ctx)
  9686. if err != nil {
  9687. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9688. }
  9689. return oldValue.DeletedAt, nil
  9690. }
  9691. // ClearDeletedAt clears the value of the "deleted_at" field.
  9692. func (m *WxMutation) ClearDeletedAt() {
  9693. m.deleted_at = nil
  9694. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  9695. }
  9696. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9697. func (m *WxMutation) DeletedAtCleared() bool {
  9698. _, ok := m.clearedFields[wx.FieldDeletedAt]
  9699. return ok
  9700. }
  9701. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9702. func (m *WxMutation) ResetDeletedAt() {
  9703. m.deleted_at = nil
  9704. delete(m.clearedFields, wx.FieldDeletedAt)
  9705. }
  9706. // SetServerID sets the "server_id" field.
  9707. func (m *WxMutation) SetServerID(u uint64) {
  9708. m.server = &u
  9709. }
  9710. // ServerID returns the value of the "server_id" field in the mutation.
  9711. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  9712. v := m.server
  9713. if v == nil {
  9714. return
  9715. }
  9716. return *v, true
  9717. }
  9718. // OldServerID returns the old "server_id" field's value of the Wx entity.
  9719. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  9720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9721. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  9722. if !m.op.Is(OpUpdateOne) {
  9723. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  9724. }
  9725. if m.id == nil || m.oldValue == nil {
  9726. return v, errors.New("OldServerID requires an ID field in the mutation")
  9727. }
  9728. oldValue, err := m.oldValue(ctx)
  9729. if err != nil {
  9730. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  9731. }
  9732. return oldValue.ServerID, nil
  9733. }
  9734. // ClearServerID clears the value of the "server_id" field.
  9735. func (m *WxMutation) ClearServerID() {
  9736. m.server = nil
  9737. m.clearedFields[wx.FieldServerID] = struct{}{}
  9738. }
  9739. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  9740. func (m *WxMutation) ServerIDCleared() bool {
  9741. _, ok := m.clearedFields[wx.FieldServerID]
  9742. return ok
  9743. }
  9744. // ResetServerID resets all changes to the "server_id" field.
  9745. func (m *WxMutation) ResetServerID() {
  9746. m.server = nil
  9747. delete(m.clearedFields, wx.FieldServerID)
  9748. }
  9749. // SetPort sets the "port" field.
  9750. func (m *WxMutation) SetPort(s string) {
  9751. m.port = &s
  9752. }
  9753. // Port returns the value of the "port" field in the mutation.
  9754. func (m *WxMutation) Port() (r string, exists bool) {
  9755. v := m.port
  9756. if v == nil {
  9757. return
  9758. }
  9759. return *v, true
  9760. }
  9761. // OldPort returns the old "port" field's value of the Wx entity.
  9762. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  9763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9764. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  9765. if !m.op.Is(OpUpdateOne) {
  9766. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  9767. }
  9768. if m.id == nil || m.oldValue == nil {
  9769. return v, errors.New("OldPort requires an ID field in the mutation")
  9770. }
  9771. oldValue, err := m.oldValue(ctx)
  9772. if err != nil {
  9773. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  9774. }
  9775. return oldValue.Port, nil
  9776. }
  9777. // ResetPort resets all changes to the "port" field.
  9778. func (m *WxMutation) ResetPort() {
  9779. m.port = nil
  9780. }
  9781. // SetProcessID sets the "process_id" field.
  9782. func (m *WxMutation) SetProcessID(s string) {
  9783. m.process_id = &s
  9784. }
  9785. // ProcessID returns the value of the "process_id" field in the mutation.
  9786. func (m *WxMutation) ProcessID() (r string, exists bool) {
  9787. v := m.process_id
  9788. if v == nil {
  9789. return
  9790. }
  9791. return *v, true
  9792. }
  9793. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  9794. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  9795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9796. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  9797. if !m.op.Is(OpUpdateOne) {
  9798. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  9799. }
  9800. if m.id == nil || m.oldValue == nil {
  9801. return v, errors.New("OldProcessID requires an ID field in the mutation")
  9802. }
  9803. oldValue, err := m.oldValue(ctx)
  9804. if err != nil {
  9805. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  9806. }
  9807. return oldValue.ProcessID, nil
  9808. }
  9809. // ResetProcessID resets all changes to the "process_id" field.
  9810. func (m *WxMutation) ResetProcessID() {
  9811. m.process_id = nil
  9812. }
  9813. // SetCallback sets the "callback" field.
  9814. func (m *WxMutation) SetCallback(s string) {
  9815. m.callback = &s
  9816. }
  9817. // Callback returns the value of the "callback" field in the mutation.
  9818. func (m *WxMutation) Callback() (r string, exists bool) {
  9819. v := m.callback
  9820. if v == nil {
  9821. return
  9822. }
  9823. return *v, true
  9824. }
  9825. // OldCallback returns the old "callback" field's value of the Wx entity.
  9826. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  9827. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9828. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  9829. if !m.op.Is(OpUpdateOne) {
  9830. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  9831. }
  9832. if m.id == nil || m.oldValue == nil {
  9833. return v, errors.New("OldCallback requires an ID field in the mutation")
  9834. }
  9835. oldValue, err := m.oldValue(ctx)
  9836. if err != nil {
  9837. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  9838. }
  9839. return oldValue.Callback, nil
  9840. }
  9841. // ResetCallback resets all changes to the "callback" field.
  9842. func (m *WxMutation) ResetCallback() {
  9843. m.callback = nil
  9844. }
  9845. // SetWxid sets the "wxid" field.
  9846. func (m *WxMutation) SetWxid(s string) {
  9847. m.wxid = &s
  9848. }
  9849. // Wxid returns the value of the "wxid" field in the mutation.
  9850. func (m *WxMutation) Wxid() (r string, exists bool) {
  9851. v := m.wxid
  9852. if v == nil {
  9853. return
  9854. }
  9855. return *v, true
  9856. }
  9857. // OldWxid returns the old "wxid" field's value of the Wx entity.
  9858. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  9859. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9860. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  9861. if !m.op.Is(OpUpdateOne) {
  9862. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  9863. }
  9864. if m.id == nil || m.oldValue == nil {
  9865. return v, errors.New("OldWxid requires an ID field in the mutation")
  9866. }
  9867. oldValue, err := m.oldValue(ctx)
  9868. if err != nil {
  9869. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  9870. }
  9871. return oldValue.Wxid, nil
  9872. }
  9873. // ResetWxid resets all changes to the "wxid" field.
  9874. func (m *WxMutation) ResetWxid() {
  9875. m.wxid = nil
  9876. }
  9877. // SetAccount sets the "account" field.
  9878. func (m *WxMutation) SetAccount(s string) {
  9879. m.account = &s
  9880. }
  9881. // Account returns the value of the "account" field in the mutation.
  9882. func (m *WxMutation) Account() (r string, exists bool) {
  9883. v := m.account
  9884. if v == nil {
  9885. return
  9886. }
  9887. return *v, true
  9888. }
  9889. // OldAccount returns the old "account" field's value of the Wx entity.
  9890. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  9891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9892. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  9893. if !m.op.Is(OpUpdateOne) {
  9894. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  9895. }
  9896. if m.id == nil || m.oldValue == nil {
  9897. return v, errors.New("OldAccount requires an ID field in the mutation")
  9898. }
  9899. oldValue, err := m.oldValue(ctx)
  9900. if err != nil {
  9901. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  9902. }
  9903. return oldValue.Account, nil
  9904. }
  9905. // ResetAccount resets all changes to the "account" field.
  9906. func (m *WxMutation) ResetAccount() {
  9907. m.account = nil
  9908. }
  9909. // SetNickname sets the "nickname" field.
  9910. func (m *WxMutation) SetNickname(s string) {
  9911. m.nickname = &s
  9912. }
  9913. // Nickname returns the value of the "nickname" field in the mutation.
  9914. func (m *WxMutation) Nickname() (r string, exists bool) {
  9915. v := m.nickname
  9916. if v == nil {
  9917. return
  9918. }
  9919. return *v, true
  9920. }
  9921. // OldNickname returns the old "nickname" field's value of the Wx entity.
  9922. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  9923. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9924. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  9925. if !m.op.Is(OpUpdateOne) {
  9926. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  9927. }
  9928. if m.id == nil || m.oldValue == nil {
  9929. return v, errors.New("OldNickname requires an ID field in the mutation")
  9930. }
  9931. oldValue, err := m.oldValue(ctx)
  9932. if err != nil {
  9933. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  9934. }
  9935. return oldValue.Nickname, nil
  9936. }
  9937. // ResetNickname resets all changes to the "nickname" field.
  9938. func (m *WxMutation) ResetNickname() {
  9939. m.nickname = nil
  9940. }
  9941. // SetTel sets the "tel" field.
  9942. func (m *WxMutation) SetTel(s string) {
  9943. m.tel = &s
  9944. }
  9945. // Tel returns the value of the "tel" field in the mutation.
  9946. func (m *WxMutation) Tel() (r string, exists bool) {
  9947. v := m.tel
  9948. if v == nil {
  9949. return
  9950. }
  9951. return *v, true
  9952. }
  9953. // OldTel returns the old "tel" field's value of the Wx entity.
  9954. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  9955. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9956. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  9957. if !m.op.Is(OpUpdateOne) {
  9958. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  9959. }
  9960. if m.id == nil || m.oldValue == nil {
  9961. return v, errors.New("OldTel requires an ID field in the mutation")
  9962. }
  9963. oldValue, err := m.oldValue(ctx)
  9964. if err != nil {
  9965. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  9966. }
  9967. return oldValue.Tel, nil
  9968. }
  9969. // ResetTel resets all changes to the "tel" field.
  9970. func (m *WxMutation) ResetTel() {
  9971. m.tel = nil
  9972. }
  9973. // SetHeadBig sets the "head_big" field.
  9974. func (m *WxMutation) SetHeadBig(s string) {
  9975. m.head_big = &s
  9976. }
  9977. // HeadBig returns the value of the "head_big" field in the mutation.
  9978. func (m *WxMutation) HeadBig() (r string, exists bool) {
  9979. v := m.head_big
  9980. if v == nil {
  9981. return
  9982. }
  9983. return *v, true
  9984. }
  9985. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  9986. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  9987. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9988. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  9989. if !m.op.Is(OpUpdateOne) {
  9990. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  9991. }
  9992. if m.id == nil || m.oldValue == nil {
  9993. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  9994. }
  9995. oldValue, err := m.oldValue(ctx)
  9996. if err != nil {
  9997. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  9998. }
  9999. return oldValue.HeadBig, nil
  10000. }
  10001. // ResetHeadBig resets all changes to the "head_big" field.
  10002. func (m *WxMutation) ResetHeadBig() {
  10003. m.head_big = nil
  10004. }
  10005. // ClearServer clears the "server" edge to the Server entity.
  10006. func (m *WxMutation) ClearServer() {
  10007. m.clearedserver = true
  10008. m.clearedFields[wx.FieldServerID] = struct{}{}
  10009. }
  10010. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  10011. func (m *WxMutation) ServerCleared() bool {
  10012. return m.ServerIDCleared() || m.clearedserver
  10013. }
  10014. // ServerIDs returns the "server" edge IDs in the mutation.
  10015. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  10016. // ServerID instead. It exists only for internal usage by the builders.
  10017. func (m *WxMutation) ServerIDs() (ids []uint64) {
  10018. if id := m.server; id != nil {
  10019. ids = append(ids, *id)
  10020. }
  10021. return
  10022. }
  10023. // ResetServer resets all changes to the "server" edge.
  10024. func (m *WxMutation) ResetServer() {
  10025. m.server = nil
  10026. m.clearedserver = false
  10027. }
  10028. // Where appends a list predicates to the WxMutation builder.
  10029. func (m *WxMutation) Where(ps ...predicate.Wx) {
  10030. m.predicates = append(m.predicates, ps...)
  10031. }
  10032. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  10033. // users can use type-assertion to append predicates that do not depend on any generated package.
  10034. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  10035. p := make([]predicate.Wx, len(ps))
  10036. for i := range ps {
  10037. p[i] = ps[i]
  10038. }
  10039. m.Where(p...)
  10040. }
  10041. // Op returns the operation name.
  10042. func (m *WxMutation) Op() Op {
  10043. return m.op
  10044. }
  10045. // SetOp allows setting the mutation operation.
  10046. func (m *WxMutation) SetOp(op Op) {
  10047. m.op = op
  10048. }
  10049. // Type returns the node type of this mutation (Wx).
  10050. func (m *WxMutation) Type() string {
  10051. return m.typ
  10052. }
  10053. // Fields returns all fields that were changed during this mutation. Note that in
  10054. // order to get all numeric fields that were incremented/decremented, call
  10055. // AddedFields().
  10056. func (m *WxMutation) Fields() []string {
  10057. fields := make([]string, 0, 13)
  10058. if m.created_at != nil {
  10059. fields = append(fields, wx.FieldCreatedAt)
  10060. }
  10061. if m.updated_at != nil {
  10062. fields = append(fields, wx.FieldUpdatedAt)
  10063. }
  10064. if m.status != nil {
  10065. fields = append(fields, wx.FieldStatus)
  10066. }
  10067. if m.deleted_at != nil {
  10068. fields = append(fields, wx.FieldDeletedAt)
  10069. }
  10070. if m.server != nil {
  10071. fields = append(fields, wx.FieldServerID)
  10072. }
  10073. if m.port != nil {
  10074. fields = append(fields, wx.FieldPort)
  10075. }
  10076. if m.process_id != nil {
  10077. fields = append(fields, wx.FieldProcessID)
  10078. }
  10079. if m.callback != nil {
  10080. fields = append(fields, wx.FieldCallback)
  10081. }
  10082. if m.wxid != nil {
  10083. fields = append(fields, wx.FieldWxid)
  10084. }
  10085. if m.account != nil {
  10086. fields = append(fields, wx.FieldAccount)
  10087. }
  10088. if m.nickname != nil {
  10089. fields = append(fields, wx.FieldNickname)
  10090. }
  10091. if m.tel != nil {
  10092. fields = append(fields, wx.FieldTel)
  10093. }
  10094. if m.head_big != nil {
  10095. fields = append(fields, wx.FieldHeadBig)
  10096. }
  10097. return fields
  10098. }
  10099. // Field returns the value of a field with the given name. The second boolean
  10100. // return value indicates that this field was not set, or was not defined in the
  10101. // schema.
  10102. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  10103. switch name {
  10104. case wx.FieldCreatedAt:
  10105. return m.CreatedAt()
  10106. case wx.FieldUpdatedAt:
  10107. return m.UpdatedAt()
  10108. case wx.FieldStatus:
  10109. return m.Status()
  10110. case wx.FieldDeletedAt:
  10111. return m.DeletedAt()
  10112. case wx.FieldServerID:
  10113. return m.ServerID()
  10114. case wx.FieldPort:
  10115. return m.Port()
  10116. case wx.FieldProcessID:
  10117. return m.ProcessID()
  10118. case wx.FieldCallback:
  10119. return m.Callback()
  10120. case wx.FieldWxid:
  10121. return m.Wxid()
  10122. case wx.FieldAccount:
  10123. return m.Account()
  10124. case wx.FieldNickname:
  10125. return m.Nickname()
  10126. case wx.FieldTel:
  10127. return m.Tel()
  10128. case wx.FieldHeadBig:
  10129. return m.HeadBig()
  10130. }
  10131. return nil, false
  10132. }
  10133. // OldField returns the old value of the field from the database. An error is
  10134. // returned if the mutation operation is not UpdateOne, or the query to the
  10135. // database failed.
  10136. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10137. switch name {
  10138. case wx.FieldCreatedAt:
  10139. return m.OldCreatedAt(ctx)
  10140. case wx.FieldUpdatedAt:
  10141. return m.OldUpdatedAt(ctx)
  10142. case wx.FieldStatus:
  10143. return m.OldStatus(ctx)
  10144. case wx.FieldDeletedAt:
  10145. return m.OldDeletedAt(ctx)
  10146. case wx.FieldServerID:
  10147. return m.OldServerID(ctx)
  10148. case wx.FieldPort:
  10149. return m.OldPort(ctx)
  10150. case wx.FieldProcessID:
  10151. return m.OldProcessID(ctx)
  10152. case wx.FieldCallback:
  10153. return m.OldCallback(ctx)
  10154. case wx.FieldWxid:
  10155. return m.OldWxid(ctx)
  10156. case wx.FieldAccount:
  10157. return m.OldAccount(ctx)
  10158. case wx.FieldNickname:
  10159. return m.OldNickname(ctx)
  10160. case wx.FieldTel:
  10161. return m.OldTel(ctx)
  10162. case wx.FieldHeadBig:
  10163. return m.OldHeadBig(ctx)
  10164. }
  10165. return nil, fmt.Errorf("unknown Wx field %s", name)
  10166. }
  10167. // SetField sets the value of a field with the given name. It returns an error if
  10168. // the field is not defined in the schema, or if the type mismatched the field
  10169. // type.
  10170. func (m *WxMutation) SetField(name string, value ent.Value) error {
  10171. switch name {
  10172. case wx.FieldCreatedAt:
  10173. v, ok := value.(time.Time)
  10174. if !ok {
  10175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10176. }
  10177. m.SetCreatedAt(v)
  10178. return nil
  10179. case wx.FieldUpdatedAt:
  10180. v, ok := value.(time.Time)
  10181. if !ok {
  10182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10183. }
  10184. m.SetUpdatedAt(v)
  10185. return nil
  10186. case wx.FieldStatus:
  10187. v, ok := value.(uint8)
  10188. if !ok {
  10189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10190. }
  10191. m.SetStatus(v)
  10192. return nil
  10193. case wx.FieldDeletedAt:
  10194. v, ok := value.(time.Time)
  10195. if !ok {
  10196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10197. }
  10198. m.SetDeletedAt(v)
  10199. return nil
  10200. case wx.FieldServerID:
  10201. v, ok := value.(uint64)
  10202. if !ok {
  10203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10204. }
  10205. m.SetServerID(v)
  10206. return nil
  10207. case wx.FieldPort:
  10208. v, ok := value.(string)
  10209. if !ok {
  10210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10211. }
  10212. m.SetPort(v)
  10213. return nil
  10214. case wx.FieldProcessID:
  10215. v, ok := value.(string)
  10216. if !ok {
  10217. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10218. }
  10219. m.SetProcessID(v)
  10220. return nil
  10221. case wx.FieldCallback:
  10222. v, ok := value.(string)
  10223. if !ok {
  10224. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10225. }
  10226. m.SetCallback(v)
  10227. return nil
  10228. case wx.FieldWxid:
  10229. v, ok := value.(string)
  10230. if !ok {
  10231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10232. }
  10233. m.SetWxid(v)
  10234. return nil
  10235. case wx.FieldAccount:
  10236. v, ok := value.(string)
  10237. if !ok {
  10238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10239. }
  10240. m.SetAccount(v)
  10241. return nil
  10242. case wx.FieldNickname:
  10243. v, ok := value.(string)
  10244. if !ok {
  10245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10246. }
  10247. m.SetNickname(v)
  10248. return nil
  10249. case wx.FieldTel:
  10250. v, ok := value.(string)
  10251. if !ok {
  10252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10253. }
  10254. m.SetTel(v)
  10255. return nil
  10256. case wx.FieldHeadBig:
  10257. v, ok := value.(string)
  10258. if !ok {
  10259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10260. }
  10261. m.SetHeadBig(v)
  10262. return nil
  10263. }
  10264. return fmt.Errorf("unknown Wx field %s", name)
  10265. }
  10266. // AddedFields returns all numeric fields that were incremented/decremented during
  10267. // this mutation.
  10268. func (m *WxMutation) AddedFields() []string {
  10269. var fields []string
  10270. if m.addstatus != nil {
  10271. fields = append(fields, wx.FieldStatus)
  10272. }
  10273. return fields
  10274. }
  10275. // AddedField returns the numeric value that was incremented/decremented on a field
  10276. // with the given name. The second boolean return value indicates that this field
  10277. // was not set, or was not defined in the schema.
  10278. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  10279. switch name {
  10280. case wx.FieldStatus:
  10281. return m.AddedStatus()
  10282. }
  10283. return nil, false
  10284. }
  10285. // AddField adds the value to the field with the given name. It returns an error if
  10286. // the field is not defined in the schema, or if the type mismatched the field
  10287. // type.
  10288. func (m *WxMutation) AddField(name string, value ent.Value) error {
  10289. switch name {
  10290. case wx.FieldStatus:
  10291. v, ok := value.(int8)
  10292. if !ok {
  10293. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10294. }
  10295. m.AddStatus(v)
  10296. return nil
  10297. }
  10298. return fmt.Errorf("unknown Wx numeric field %s", name)
  10299. }
  10300. // ClearedFields returns all nullable fields that were cleared during this
  10301. // mutation.
  10302. func (m *WxMutation) ClearedFields() []string {
  10303. var fields []string
  10304. if m.FieldCleared(wx.FieldStatus) {
  10305. fields = append(fields, wx.FieldStatus)
  10306. }
  10307. if m.FieldCleared(wx.FieldDeletedAt) {
  10308. fields = append(fields, wx.FieldDeletedAt)
  10309. }
  10310. if m.FieldCleared(wx.FieldServerID) {
  10311. fields = append(fields, wx.FieldServerID)
  10312. }
  10313. return fields
  10314. }
  10315. // FieldCleared returns a boolean indicating if a field with the given name was
  10316. // cleared in this mutation.
  10317. func (m *WxMutation) FieldCleared(name string) bool {
  10318. _, ok := m.clearedFields[name]
  10319. return ok
  10320. }
  10321. // ClearField clears the value of the field with the given name. It returns an
  10322. // error if the field is not defined in the schema.
  10323. func (m *WxMutation) ClearField(name string) error {
  10324. switch name {
  10325. case wx.FieldStatus:
  10326. m.ClearStatus()
  10327. return nil
  10328. case wx.FieldDeletedAt:
  10329. m.ClearDeletedAt()
  10330. return nil
  10331. case wx.FieldServerID:
  10332. m.ClearServerID()
  10333. return nil
  10334. }
  10335. return fmt.Errorf("unknown Wx nullable field %s", name)
  10336. }
  10337. // ResetField resets all changes in the mutation for the field with the given name.
  10338. // It returns an error if the field is not defined in the schema.
  10339. func (m *WxMutation) ResetField(name string) error {
  10340. switch name {
  10341. case wx.FieldCreatedAt:
  10342. m.ResetCreatedAt()
  10343. return nil
  10344. case wx.FieldUpdatedAt:
  10345. m.ResetUpdatedAt()
  10346. return nil
  10347. case wx.FieldStatus:
  10348. m.ResetStatus()
  10349. return nil
  10350. case wx.FieldDeletedAt:
  10351. m.ResetDeletedAt()
  10352. return nil
  10353. case wx.FieldServerID:
  10354. m.ResetServerID()
  10355. return nil
  10356. case wx.FieldPort:
  10357. m.ResetPort()
  10358. return nil
  10359. case wx.FieldProcessID:
  10360. m.ResetProcessID()
  10361. return nil
  10362. case wx.FieldCallback:
  10363. m.ResetCallback()
  10364. return nil
  10365. case wx.FieldWxid:
  10366. m.ResetWxid()
  10367. return nil
  10368. case wx.FieldAccount:
  10369. m.ResetAccount()
  10370. return nil
  10371. case wx.FieldNickname:
  10372. m.ResetNickname()
  10373. return nil
  10374. case wx.FieldTel:
  10375. m.ResetTel()
  10376. return nil
  10377. case wx.FieldHeadBig:
  10378. m.ResetHeadBig()
  10379. return nil
  10380. }
  10381. return fmt.Errorf("unknown Wx field %s", name)
  10382. }
  10383. // AddedEdges returns all edge names that were set/added in this mutation.
  10384. func (m *WxMutation) AddedEdges() []string {
  10385. edges := make([]string, 0, 1)
  10386. if m.server != nil {
  10387. edges = append(edges, wx.EdgeServer)
  10388. }
  10389. return edges
  10390. }
  10391. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10392. // name in this mutation.
  10393. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  10394. switch name {
  10395. case wx.EdgeServer:
  10396. if id := m.server; id != nil {
  10397. return []ent.Value{*id}
  10398. }
  10399. }
  10400. return nil
  10401. }
  10402. // RemovedEdges returns all edge names that were removed in this mutation.
  10403. func (m *WxMutation) RemovedEdges() []string {
  10404. edges := make([]string, 0, 1)
  10405. return edges
  10406. }
  10407. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10408. // the given name in this mutation.
  10409. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  10410. return nil
  10411. }
  10412. // ClearedEdges returns all edge names that were cleared in this mutation.
  10413. func (m *WxMutation) ClearedEdges() []string {
  10414. edges := make([]string, 0, 1)
  10415. if m.clearedserver {
  10416. edges = append(edges, wx.EdgeServer)
  10417. }
  10418. return edges
  10419. }
  10420. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10421. // was cleared in this mutation.
  10422. func (m *WxMutation) EdgeCleared(name string) bool {
  10423. switch name {
  10424. case wx.EdgeServer:
  10425. return m.clearedserver
  10426. }
  10427. return false
  10428. }
  10429. // ClearEdge clears the value of the edge with the given name. It returns an error
  10430. // if that edge is not defined in the schema.
  10431. func (m *WxMutation) ClearEdge(name string) error {
  10432. switch name {
  10433. case wx.EdgeServer:
  10434. m.ClearServer()
  10435. return nil
  10436. }
  10437. return fmt.Errorf("unknown Wx unique edge %s", name)
  10438. }
  10439. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10440. // It returns an error if the edge is not defined in the schema.
  10441. func (m *WxMutation) ResetEdge(name string) error {
  10442. switch name {
  10443. case wx.EdgeServer:
  10444. m.ResetServer()
  10445. return nil
  10446. }
  10447. return fmt.Errorf("unknown Wx edge %s", name)
  10448. }