mutation.go 406 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "sync"
  8. "time"
  9. "wechat-api/ent/batchmsg"
  10. "wechat-api/ent/contact"
  11. "wechat-api/ent/custom_types"
  12. "wechat-api/ent/label"
  13. "wechat-api/ent/labelrelationship"
  14. "wechat-api/ent/message"
  15. "wechat-api/ent/messagerecords"
  16. "wechat-api/ent/msg"
  17. "wechat-api/ent/predicate"
  18. "wechat-api/ent/server"
  19. "wechat-api/ent/sopnode"
  20. "wechat-api/ent/sopstage"
  21. "wechat-api/ent/soptask"
  22. "wechat-api/ent/wx"
  23. "entgo.io/ent"
  24. "entgo.io/ent/dialect/sql"
  25. )
  26. const (
  27. // Operation types.
  28. OpCreate = ent.OpCreate
  29. OpDelete = ent.OpDelete
  30. OpDeleteOne = ent.OpDeleteOne
  31. OpUpdate = ent.OpUpdate
  32. OpUpdateOne = ent.OpUpdateOne
  33. // Node types.
  34. TypeBatchMsg = "BatchMsg"
  35. TypeContact = "Contact"
  36. TypeLabel = "Label"
  37. TypeLabelRelationship = "LabelRelationship"
  38. TypeMessage = "Message"
  39. TypeMessageRecords = "MessageRecords"
  40. TypeMsg = "Msg"
  41. TypeServer = "Server"
  42. TypeSopNode = "SopNode"
  43. TypeSopStage = "SopStage"
  44. TypeSopTask = "SopTask"
  45. TypeWx = "Wx"
  46. )
  47. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  48. type BatchMsgMutation struct {
  49. config
  50. op Op
  51. typ string
  52. id *uint64
  53. created_at *time.Time
  54. updated_at *time.Time
  55. deleted_at *time.Time
  56. status *uint8
  57. addstatus *int8
  58. batch_no *string
  59. fromwxid *string
  60. msg *string
  61. tag *string
  62. total *int32
  63. addtotal *int32
  64. success *int32
  65. addsuccess *int32
  66. fail *int32
  67. addfail *int32
  68. start_time *time.Time
  69. stop_time *time.Time
  70. clearedFields map[string]struct{}
  71. done bool
  72. oldValue func(context.Context) (*BatchMsg, error)
  73. predicates []predicate.BatchMsg
  74. }
  75. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  76. // batchmsgOption allows management of the mutation configuration using functional options.
  77. type batchmsgOption func(*BatchMsgMutation)
  78. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  79. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  80. m := &BatchMsgMutation{
  81. config: c,
  82. op: op,
  83. typ: TypeBatchMsg,
  84. clearedFields: make(map[string]struct{}),
  85. }
  86. for _, opt := range opts {
  87. opt(m)
  88. }
  89. return m
  90. }
  91. // withBatchMsgID sets the ID field of the mutation.
  92. func withBatchMsgID(id uint64) batchmsgOption {
  93. return func(m *BatchMsgMutation) {
  94. var (
  95. err error
  96. once sync.Once
  97. value *BatchMsg
  98. )
  99. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  100. once.Do(func() {
  101. if m.done {
  102. err = errors.New("querying old values post mutation is not allowed")
  103. } else {
  104. value, err = m.Client().BatchMsg.Get(ctx, id)
  105. }
  106. })
  107. return value, err
  108. }
  109. m.id = &id
  110. }
  111. }
  112. // withBatchMsg sets the old BatchMsg of the mutation.
  113. func withBatchMsg(node *BatchMsg) batchmsgOption {
  114. return func(m *BatchMsgMutation) {
  115. m.oldValue = func(context.Context) (*BatchMsg, error) {
  116. return node, nil
  117. }
  118. m.id = &node.ID
  119. }
  120. }
  121. // Client returns a new `ent.Client` from the mutation. If the mutation was
  122. // executed in a transaction (ent.Tx), a transactional client is returned.
  123. func (m BatchMsgMutation) Client() *Client {
  124. client := &Client{config: m.config}
  125. client.init()
  126. return client
  127. }
  128. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  129. // it returns an error otherwise.
  130. func (m BatchMsgMutation) Tx() (*Tx, error) {
  131. if _, ok := m.driver.(*txDriver); !ok {
  132. return nil, errors.New("ent: mutation is not running in a transaction")
  133. }
  134. tx := &Tx{config: m.config}
  135. tx.init()
  136. return tx, nil
  137. }
  138. // SetID sets the value of the id field. Note that this
  139. // operation is only accepted on creation of BatchMsg entities.
  140. func (m *BatchMsgMutation) SetID(id uint64) {
  141. m.id = &id
  142. }
  143. // ID returns the ID value in the mutation. Note that the ID is only available
  144. // if it was provided to the builder or after it was returned from the database.
  145. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  146. if m.id == nil {
  147. return
  148. }
  149. return *m.id, true
  150. }
  151. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  152. // That means, if the mutation is applied within a transaction with an isolation level such
  153. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  154. // or updated by the mutation.
  155. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  156. switch {
  157. case m.op.Is(OpUpdateOne | OpDeleteOne):
  158. id, exists := m.ID()
  159. if exists {
  160. return []uint64{id}, nil
  161. }
  162. fallthrough
  163. case m.op.Is(OpUpdate | OpDelete):
  164. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  165. default:
  166. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  167. }
  168. }
  169. // SetCreatedAt sets the "created_at" field.
  170. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  171. m.created_at = &t
  172. }
  173. // CreatedAt returns the value of the "created_at" field in the mutation.
  174. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  175. v := m.created_at
  176. if v == nil {
  177. return
  178. }
  179. return *v, true
  180. }
  181. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  182. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  183. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  184. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  185. if !m.op.Is(OpUpdateOne) {
  186. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  187. }
  188. if m.id == nil || m.oldValue == nil {
  189. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  190. }
  191. oldValue, err := m.oldValue(ctx)
  192. if err != nil {
  193. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  194. }
  195. return oldValue.CreatedAt, nil
  196. }
  197. // ResetCreatedAt resets all changes to the "created_at" field.
  198. func (m *BatchMsgMutation) ResetCreatedAt() {
  199. m.created_at = nil
  200. }
  201. // SetUpdatedAt sets the "updated_at" field.
  202. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  203. m.updated_at = &t
  204. }
  205. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  206. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  207. v := m.updated_at
  208. if v == nil {
  209. return
  210. }
  211. return *v, true
  212. }
  213. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  214. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  215. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  216. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  217. if !m.op.Is(OpUpdateOne) {
  218. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  219. }
  220. if m.id == nil || m.oldValue == nil {
  221. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  222. }
  223. oldValue, err := m.oldValue(ctx)
  224. if err != nil {
  225. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  226. }
  227. return oldValue.UpdatedAt, nil
  228. }
  229. // ResetUpdatedAt resets all changes to the "updated_at" field.
  230. func (m *BatchMsgMutation) ResetUpdatedAt() {
  231. m.updated_at = nil
  232. }
  233. // SetDeletedAt sets the "deleted_at" field.
  234. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  235. m.deleted_at = &t
  236. }
  237. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  238. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  239. v := m.deleted_at
  240. if v == nil {
  241. return
  242. }
  243. return *v, true
  244. }
  245. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  246. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  247. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  248. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  249. if !m.op.Is(OpUpdateOne) {
  250. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  251. }
  252. if m.id == nil || m.oldValue == nil {
  253. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  254. }
  255. oldValue, err := m.oldValue(ctx)
  256. if err != nil {
  257. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  258. }
  259. return oldValue.DeletedAt, nil
  260. }
  261. // ClearDeletedAt clears the value of the "deleted_at" field.
  262. func (m *BatchMsgMutation) ClearDeletedAt() {
  263. m.deleted_at = nil
  264. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  265. }
  266. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  267. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  268. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  269. return ok
  270. }
  271. // ResetDeletedAt resets all changes to the "deleted_at" field.
  272. func (m *BatchMsgMutation) ResetDeletedAt() {
  273. m.deleted_at = nil
  274. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  275. }
  276. // SetStatus sets the "status" field.
  277. func (m *BatchMsgMutation) SetStatus(u uint8) {
  278. m.status = &u
  279. m.addstatus = nil
  280. }
  281. // Status returns the value of the "status" field in the mutation.
  282. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  283. v := m.status
  284. if v == nil {
  285. return
  286. }
  287. return *v, true
  288. }
  289. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  290. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  291. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  292. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  293. if !m.op.Is(OpUpdateOne) {
  294. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  295. }
  296. if m.id == nil || m.oldValue == nil {
  297. return v, errors.New("OldStatus requires an ID field in the mutation")
  298. }
  299. oldValue, err := m.oldValue(ctx)
  300. if err != nil {
  301. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  302. }
  303. return oldValue.Status, nil
  304. }
  305. // AddStatus adds u to the "status" field.
  306. func (m *BatchMsgMutation) AddStatus(u int8) {
  307. if m.addstatus != nil {
  308. *m.addstatus += u
  309. } else {
  310. m.addstatus = &u
  311. }
  312. }
  313. // AddedStatus returns the value that was added to the "status" field in this mutation.
  314. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  315. v := m.addstatus
  316. if v == nil {
  317. return
  318. }
  319. return *v, true
  320. }
  321. // ClearStatus clears the value of the "status" field.
  322. func (m *BatchMsgMutation) ClearStatus() {
  323. m.status = nil
  324. m.addstatus = nil
  325. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  326. }
  327. // StatusCleared returns if the "status" field was cleared in this mutation.
  328. func (m *BatchMsgMutation) StatusCleared() bool {
  329. _, ok := m.clearedFields[batchmsg.FieldStatus]
  330. return ok
  331. }
  332. // ResetStatus resets all changes to the "status" field.
  333. func (m *BatchMsgMutation) ResetStatus() {
  334. m.status = nil
  335. m.addstatus = nil
  336. delete(m.clearedFields, batchmsg.FieldStatus)
  337. }
  338. // SetBatchNo sets the "batch_no" field.
  339. func (m *BatchMsgMutation) SetBatchNo(s string) {
  340. m.batch_no = &s
  341. }
  342. // BatchNo returns the value of the "batch_no" field in the mutation.
  343. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  344. v := m.batch_no
  345. if v == nil {
  346. return
  347. }
  348. return *v, true
  349. }
  350. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  351. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  352. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  353. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  354. if !m.op.Is(OpUpdateOne) {
  355. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  356. }
  357. if m.id == nil || m.oldValue == nil {
  358. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  359. }
  360. oldValue, err := m.oldValue(ctx)
  361. if err != nil {
  362. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  363. }
  364. return oldValue.BatchNo, nil
  365. }
  366. // ClearBatchNo clears the value of the "batch_no" field.
  367. func (m *BatchMsgMutation) ClearBatchNo() {
  368. m.batch_no = nil
  369. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  370. }
  371. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  372. func (m *BatchMsgMutation) BatchNoCleared() bool {
  373. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  374. return ok
  375. }
  376. // ResetBatchNo resets all changes to the "batch_no" field.
  377. func (m *BatchMsgMutation) ResetBatchNo() {
  378. m.batch_no = nil
  379. delete(m.clearedFields, batchmsg.FieldBatchNo)
  380. }
  381. // SetFromwxid sets the "fromwxid" field.
  382. func (m *BatchMsgMutation) SetFromwxid(s string) {
  383. m.fromwxid = &s
  384. }
  385. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  386. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  387. v := m.fromwxid
  388. if v == nil {
  389. return
  390. }
  391. return *v, true
  392. }
  393. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  394. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  395. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  396. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  397. if !m.op.Is(OpUpdateOne) {
  398. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  399. }
  400. if m.id == nil || m.oldValue == nil {
  401. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  402. }
  403. oldValue, err := m.oldValue(ctx)
  404. if err != nil {
  405. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  406. }
  407. return oldValue.Fromwxid, nil
  408. }
  409. // ClearFromwxid clears the value of the "fromwxid" field.
  410. func (m *BatchMsgMutation) ClearFromwxid() {
  411. m.fromwxid = nil
  412. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  413. }
  414. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  415. func (m *BatchMsgMutation) FromwxidCleared() bool {
  416. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  417. return ok
  418. }
  419. // ResetFromwxid resets all changes to the "fromwxid" field.
  420. func (m *BatchMsgMutation) ResetFromwxid() {
  421. m.fromwxid = nil
  422. delete(m.clearedFields, batchmsg.FieldFromwxid)
  423. }
  424. // SetMsg sets the "msg" field.
  425. func (m *BatchMsgMutation) SetMsg(s string) {
  426. m.msg = &s
  427. }
  428. // Msg returns the value of the "msg" field in the mutation.
  429. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  430. v := m.msg
  431. if v == nil {
  432. return
  433. }
  434. return *v, true
  435. }
  436. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  437. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  438. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  439. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  440. if !m.op.Is(OpUpdateOne) {
  441. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  442. }
  443. if m.id == nil || m.oldValue == nil {
  444. return v, errors.New("OldMsg requires an ID field in the mutation")
  445. }
  446. oldValue, err := m.oldValue(ctx)
  447. if err != nil {
  448. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  449. }
  450. return oldValue.Msg, nil
  451. }
  452. // ClearMsg clears the value of the "msg" field.
  453. func (m *BatchMsgMutation) ClearMsg() {
  454. m.msg = nil
  455. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  456. }
  457. // MsgCleared returns if the "msg" field was cleared in this mutation.
  458. func (m *BatchMsgMutation) MsgCleared() bool {
  459. _, ok := m.clearedFields[batchmsg.FieldMsg]
  460. return ok
  461. }
  462. // ResetMsg resets all changes to the "msg" field.
  463. func (m *BatchMsgMutation) ResetMsg() {
  464. m.msg = nil
  465. delete(m.clearedFields, batchmsg.FieldMsg)
  466. }
  467. // SetTag sets the "tag" field.
  468. func (m *BatchMsgMutation) SetTag(s string) {
  469. m.tag = &s
  470. }
  471. // Tag returns the value of the "tag" field in the mutation.
  472. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  473. v := m.tag
  474. if v == nil {
  475. return
  476. }
  477. return *v, true
  478. }
  479. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  480. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  481. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  482. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  483. if !m.op.Is(OpUpdateOne) {
  484. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  485. }
  486. if m.id == nil || m.oldValue == nil {
  487. return v, errors.New("OldTag requires an ID field in the mutation")
  488. }
  489. oldValue, err := m.oldValue(ctx)
  490. if err != nil {
  491. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  492. }
  493. return oldValue.Tag, nil
  494. }
  495. // ClearTag clears the value of the "tag" field.
  496. func (m *BatchMsgMutation) ClearTag() {
  497. m.tag = nil
  498. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  499. }
  500. // TagCleared returns if the "tag" field was cleared in this mutation.
  501. func (m *BatchMsgMutation) TagCleared() bool {
  502. _, ok := m.clearedFields[batchmsg.FieldTag]
  503. return ok
  504. }
  505. // ResetTag resets all changes to the "tag" field.
  506. func (m *BatchMsgMutation) ResetTag() {
  507. m.tag = nil
  508. delete(m.clearedFields, batchmsg.FieldTag)
  509. }
  510. // SetTotal sets the "total" field.
  511. func (m *BatchMsgMutation) SetTotal(i int32) {
  512. m.total = &i
  513. m.addtotal = nil
  514. }
  515. // Total returns the value of the "total" field in the mutation.
  516. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  517. v := m.total
  518. if v == nil {
  519. return
  520. }
  521. return *v, true
  522. }
  523. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  524. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  526. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  527. if !m.op.Is(OpUpdateOne) {
  528. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  529. }
  530. if m.id == nil || m.oldValue == nil {
  531. return v, errors.New("OldTotal requires an ID field in the mutation")
  532. }
  533. oldValue, err := m.oldValue(ctx)
  534. if err != nil {
  535. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  536. }
  537. return oldValue.Total, nil
  538. }
  539. // AddTotal adds i to the "total" field.
  540. func (m *BatchMsgMutation) AddTotal(i int32) {
  541. if m.addtotal != nil {
  542. *m.addtotal += i
  543. } else {
  544. m.addtotal = &i
  545. }
  546. }
  547. // AddedTotal returns the value that was added to the "total" field in this mutation.
  548. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  549. v := m.addtotal
  550. if v == nil {
  551. return
  552. }
  553. return *v, true
  554. }
  555. // ClearTotal clears the value of the "total" field.
  556. func (m *BatchMsgMutation) ClearTotal() {
  557. m.total = nil
  558. m.addtotal = nil
  559. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  560. }
  561. // TotalCleared returns if the "total" field was cleared in this mutation.
  562. func (m *BatchMsgMutation) TotalCleared() bool {
  563. _, ok := m.clearedFields[batchmsg.FieldTotal]
  564. return ok
  565. }
  566. // ResetTotal resets all changes to the "total" field.
  567. func (m *BatchMsgMutation) ResetTotal() {
  568. m.total = nil
  569. m.addtotal = nil
  570. delete(m.clearedFields, batchmsg.FieldTotal)
  571. }
  572. // SetSuccess sets the "success" field.
  573. func (m *BatchMsgMutation) SetSuccess(i int32) {
  574. m.success = &i
  575. m.addsuccess = nil
  576. }
  577. // Success returns the value of the "success" field in the mutation.
  578. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  579. v := m.success
  580. if v == nil {
  581. return
  582. }
  583. return *v, true
  584. }
  585. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  586. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  587. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  588. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  589. if !m.op.Is(OpUpdateOne) {
  590. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  591. }
  592. if m.id == nil || m.oldValue == nil {
  593. return v, errors.New("OldSuccess requires an ID field in the mutation")
  594. }
  595. oldValue, err := m.oldValue(ctx)
  596. if err != nil {
  597. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  598. }
  599. return oldValue.Success, nil
  600. }
  601. // AddSuccess adds i to the "success" field.
  602. func (m *BatchMsgMutation) AddSuccess(i int32) {
  603. if m.addsuccess != nil {
  604. *m.addsuccess += i
  605. } else {
  606. m.addsuccess = &i
  607. }
  608. }
  609. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  610. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  611. v := m.addsuccess
  612. if v == nil {
  613. return
  614. }
  615. return *v, true
  616. }
  617. // ClearSuccess clears the value of the "success" field.
  618. func (m *BatchMsgMutation) ClearSuccess() {
  619. m.success = nil
  620. m.addsuccess = nil
  621. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  622. }
  623. // SuccessCleared returns if the "success" field was cleared in this mutation.
  624. func (m *BatchMsgMutation) SuccessCleared() bool {
  625. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  626. return ok
  627. }
  628. // ResetSuccess resets all changes to the "success" field.
  629. func (m *BatchMsgMutation) ResetSuccess() {
  630. m.success = nil
  631. m.addsuccess = nil
  632. delete(m.clearedFields, batchmsg.FieldSuccess)
  633. }
  634. // SetFail sets the "fail" field.
  635. func (m *BatchMsgMutation) SetFail(i int32) {
  636. m.fail = &i
  637. m.addfail = nil
  638. }
  639. // Fail returns the value of the "fail" field in the mutation.
  640. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  641. v := m.fail
  642. if v == nil {
  643. return
  644. }
  645. return *v, true
  646. }
  647. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  648. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  650. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  651. if !m.op.Is(OpUpdateOne) {
  652. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  653. }
  654. if m.id == nil || m.oldValue == nil {
  655. return v, errors.New("OldFail requires an ID field in the mutation")
  656. }
  657. oldValue, err := m.oldValue(ctx)
  658. if err != nil {
  659. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  660. }
  661. return oldValue.Fail, nil
  662. }
  663. // AddFail adds i to the "fail" field.
  664. func (m *BatchMsgMutation) AddFail(i int32) {
  665. if m.addfail != nil {
  666. *m.addfail += i
  667. } else {
  668. m.addfail = &i
  669. }
  670. }
  671. // AddedFail returns the value that was added to the "fail" field in this mutation.
  672. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  673. v := m.addfail
  674. if v == nil {
  675. return
  676. }
  677. return *v, true
  678. }
  679. // ClearFail clears the value of the "fail" field.
  680. func (m *BatchMsgMutation) ClearFail() {
  681. m.fail = nil
  682. m.addfail = nil
  683. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  684. }
  685. // FailCleared returns if the "fail" field was cleared in this mutation.
  686. func (m *BatchMsgMutation) FailCleared() bool {
  687. _, ok := m.clearedFields[batchmsg.FieldFail]
  688. return ok
  689. }
  690. // ResetFail resets all changes to the "fail" field.
  691. func (m *BatchMsgMutation) ResetFail() {
  692. m.fail = nil
  693. m.addfail = nil
  694. delete(m.clearedFields, batchmsg.FieldFail)
  695. }
  696. // SetStartTime sets the "start_time" field.
  697. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  698. m.start_time = &t
  699. }
  700. // StartTime returns the value of the "start_time" field in the mutation.
  701. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  702. v := m.start_time
  703. if v == nil {
  704. return
  705. }
  706. return *v, true
  707. }
  708. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  709. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  710. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  711. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  712. if !m.op.Is(OpUpdateOne) {
  713. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  714. }
  715. if m.id == nil || m.oldValue == nil {
  716. return v, errors.New("OldStartTime requires an ID field in the mutation")
  717. }
  718. oldValue, err := m.oldValue(ctx)
  719. if err != nil {
  720. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  721. }
  722. return oldValue.StartTime, nil
  723. }
  724. // ClearStartTime clears the value of the "start_time" field.
  725. func (m *BatchMsgMutation) ClearStartTime() {
  726. m.start_time = nil
  727. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  728. }
  729. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  730. func (m *BatchMsgMutation) StartTimeCleared() bool {
  731. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  732. return ok
  733. }
  734. // ResetStartTime resets all changes to the "start_time" field.
  735. func (m *BatchMsgMutation) ResetStartTime() {
  736. m.start_time = nil
  737. delete(m.clearedFields, batchmsg.FieldStartTime)
  738. }
  739. // SetStopTime sets the "stop_time" field.
  740. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  741. m.stop_time = &t
  742. }
  743. // StopTime returns the value of the "stop_time" field in the mutation.
  744. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  745. v := m.stop_time
  746. if v == nil {
  747. return
  748. }
  749. return *v, true
  750. }
  751. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  752. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  753. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  754. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  755. if !m.op.Is(OpUpdateOne) {
  756. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  757. }
  758. if m.id == nil || m.oldValue == nil {
  759. return v, errors.New("OldStopTime requires an ID field in the mutation")
  760. }
  761. oldValue, err := m.oldValue(ctx)
  762. if err != nil {
  763. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  764. }
  765. return oldValue.StopTime, nil
  766. }
  767. // ClearStopTime clears the value of the "stop_time" field.
  768. func (m *BatchMsgMutation) ClearStopTime() {
  769. m.stop_time = nil
  770. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  771. }
  772. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  773. func (m *BatchMsgMutation) StopTimeCleared() bool {
  774. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  775. return ok
  776. }
  777. // ResetStopTime resets all changes to the "stop_time" field.
  778. func (m *BatchMsgMutation) ResetStopTime() {
  779. m.stop_time = nil
  780. delete(m.clearedFields, batchmsg.FieldStopTime)
  781. }
  782. // Where appends a list predicates to the BatchMsgMutation builder.
  783. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  784. m.predicates = append(m.predicates, ps...)
  785. }
  786. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  787. // users can use type-assertion to append predicates that do not depend on any generated package.
  788. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  789. p := make([]predicate.BatchMsg, len(ps))
  790. for i := range ps {
  791. p[i] = ps[i]
  792. }
  793. m.Where(p...)
  794. }
  795. // Op returns the operation name.
  796. func (m *BatchMsgMutation) Op() Op {
  797. return m.op
  798. }
  799. // SetOp allows setting the mutation operation.
  800. func (m *BatchMsgMutation) SetOp(op Op) {
  801. m.op = op
  802. }
  803. // Type returns the node type of this mutation (BatchMsg).
  804. func (m *BatchMsgMutation) Type() string {
  805. return m.typ
  806. }
  807. // Fields returns all fields that were changed during this mutation. Note that in
  808. // order to get all numeric fields that were incremented/decremented, call
  809. // AddedFields().
  810. func (m *BatchMsgMutation) Fields() []string {
  811. fields := make([]string, 0, 13)
  812. if m.created_at != nil {
  813. fields = append(fields, batchmsg.FieldCreatedAt)
  814. }
  815. if m.updated_at != nil {
  816. fields = append(fields, batchmsg.FieldUpdatedAt)
  817. }
  818. if m.deleted_at != nil {
  819. fields = append(fields, batchmsg.FieldDeletedAt)
  820. }
  821. if m.status != nil {
  822. fields = append(fields, batchmsg.FieldStatus)
  823. }
  824. if m.batch_no != nil {
  825. fields = append(fields, batchmsg.FieldBatchNo)
  826. }
  827. if m.fromwxid != nil {
  828. fields = append(fields, batchmsg.FieldFromwxid)
  829. }
  830. if m.msg != nil {
  831. fields = append(fields, batchmsg.FieldMsg)
  832. }
  833. if m.tag != nil {
  834. fields = append(fields, batchmsg.FieldTag)
  835. }
  836. if m.total != nil {
  837. fields = append(fields, batchmsg.FieldTotal)
  838. }
  839. if m.success != nil {
  840. fields = append(fields, batchmsg.FieldSuccess)
  841. }
  842. if m.fail != nil {
  843. fields = append(fields, batchmsg.FieldFail)
  844. }
  845. if m.start_time != nil {
  846. fields = append(fields, batchmsg.FieldStartTime)
  847. }
  848. if m.stop_time != nil {
  849. fields = append(fields, batchmsg.FieldStopTime)
  850. }
  851. return fields
  852. }
  853. // Field returns the value of a field with the given name. The second boolean
  854. // return value indicates that this field was not set, or was not defined in the
  855. // schema.
  856. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  857. switch name {
  858. case batchmsg.FieldCreatedAt:
  859. return m.CreatedAt()
  860. case batchmsg.FieldUpdatedAt:
  861. return m.UpdatedAt()
  862. case batchmsg.FieldDeletedAt:
  863. return m.DeletedAt()
  864. case batchmsg.FieldStatus:
  865. return m.Status()
  866. case batchmsg.FieldBatchNo:
  867. return m.BatchNo()
  868. case batchmsg.FieldFromwxid:
  869. return m.Fromwxid()
  870. case batchmsg.FieldMsg:
  871. return m.Msg()
  872. case batchmsg.FieldTag:
  873. return m.Tag()
  874. case batchmsg.FieldTotal:
  875. return m.Total()
  876. case batchmsg.FieldSuccess:
  877. return m.Success()
  878. case batchmsg.FieldFail:
  879. return m.Fail()
  880. case batchmsg.FieldStartTime:
  881. return m.StartTime()
  882. case batchmsg.FieldStopTime:
  883. return m.StopTime()
  884. }
  885. return nil, false
  886. }
  887. // OldField returns the old value of the field from the database. An error is
  888. // returned if the mutation operation is not UpdateOne, or the query to the
  889. // database failed.
  890. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  891. switch name {
  892. case batchmsg.FieldCreatedAt:
  893. return m.OldCreatedAt(ctx)
  894. case batchmsg.FieldUpdatedAt:
  895. return m.OldUpdatedAt(ctx)
  896. case batchmsg.FieldDeletedAt:
  897. return m.OldDeletedAt(ctx)
  898. case batchmsg.FieldStatus:
  899. return m.OldStatus(ctx)
  900. case batchmsg.FieldBatchNo:
  901. return m.OldBatchNo(ctx)
  902. case batchmsg.FieldFromwxid:
  903. return m.OldFromwxid(ctx)
  904. case batchmsg.FieldMsg:
  905. return m.OldMsg(ctx)
  906. case batchmsg.FieldTag:
  907. return m.OldTag(ctx)
  908. case batchmsg.FieldTotal:
  909. return m.OldTotal(ctx)
  910. case batchmsg.FieldSuccess:
  911. return m.OldSuccess(ctx)
  912. case batchmsg.FieldFail:
  913. return m.OldFail(ctx)
  914. case batchmsg.FieldStartTime:
  915. return m.OldStartTime(ctx)
  916. case batchmsg.FieldStopTime:
  917. return m.OldStopTime(ctx)
  918. }
  919. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  920. }
  921. // SetField sets the value of a field with the given name. It returns an error if
  922. // the field is not defined in the schema, or if the type mismatched the field
  923. // type.
  924. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  925. switch name {
  926. case batchmsg.FieldCreatedAt:
  927. v, ok := value.(time.Time)
  928. if !ok {
  929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  930. }
  931. m.SetCreatedAt(v)
  932. return nil
  933. case batchmsg.FieldUpdatedAt:
  934. v, ok := value.(time.Time)
  935. if !ok {
  936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  937. }
  938. m.SetUpdatedAt(v)
  939. return nil
  940. case batchmsg.FieldDeletedAt:
  941. v, ok := value.(time.Time)
  942. if !ok {
  943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  944. }
  945. m.SetDeletedAt(v)
  946. return nil
  947. case batchmsg.FieldStatus:
  948. v, ok := value.(uint8)
  949. if !ok {
  950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  951. }
  952. m.SetStatus(v)
  953. return nil
  954. case batchmsg.FieldBatchNo:
  955. v, ok := value.(string)
  956. if !ok {
  957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  958. }
  959. m.SetBatchNo(v)
  960. return nil
  961. case batchmsg.FieldFromwxid:
  962. v, ok := value.(string)
  963. if !ok {
  964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  965. }
  966. m.SetFromwxid(v)
  967. return nil
  968. case batchmsg.FieldMsg:
  969. v, ok := value.(string)
  970. if !ok {
  971. return fmt.Errorf("unexpected type %T for field %s", value, name)
  972. }
  973. m.SetMsg(v)
  974. return nil
  975. case batchmsg.FieldTag:
  976. v, ok := value.(string)
  977. if !ok {
  978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  979. }
  980. m.SetTag(v)
  981. return nil
  982. case batchmsg.FieldTotal:
  983. v, ok := value.(int32)
  984. if !ok {
  985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  986. }
  987. m.SetTotal(v)
  988. return nil
  989. case batchmsg.FieldSuccess:
  990. v, ok := value.(int32)
  991. if !ok {
  992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  993. }
  994. m.SetSuccess(v)
  995. return nil
  996. case batchmsg.FieldFail:
  997. v, ok := value.(int32)
  998. if !ok {
  999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1000. }
  1001. m.SetFail(v)
  1002. return nil
  1003. case batchmsg.FieldStartTime:
  1004. v, ok := value.(time.Time)
  1005. if !ok {
  1006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1007. }
  1008. m.SetStartTime(v)
  1009. return nil
  1010. case batchmsg.FieldStopTime:
  1011. v, ok := value.(time.Time)
  1012. if !ok {
  1013. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1014. }
  1015. m.SetStopTime(v)
  1016. return nil
  1017. }
  1018. return fmt.Errorf("unknown BatchMsg field %s", name)
  1019. }
  1020. // AddedFields returns all numeric fields that were incremented/decremented during
  1021. // this mutation.
  1022. func (m *BatchMsgMutation) AddedFields() []string {
  1023. var fields []string
  1024. if m.addstatus != nil {
  1025. fields = append(fields, batchmsg.FieldStatus)
  1026. }
  1027. if m.addtotal != nil {
  1028. fields = append(fields, batchmsg.FieldTotal)
  1029. }
  1030. if m.addsuccess != nil {
  1031. fields = append(fields, batchmsg.FieldSuccess)
  1032. }
  1033. if m.addfail != nil {
  1034. fields = append(fields, batchmsg.FieldFail)
  1035. }
  1036. return fields
  1037. }
  1038. // AddedField returns the numeric value that was incremented/decremented on a field
  1039. // with the given name. The second boolean return value indicates that this field
  1040. // was not set, or was not defined in the schema.
  1041. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  1042. switch name {
  1043. case batchmsg.FieldStatus:
  1044. return m.AddedStatus()
  1045. case batchmsg.FieldTotal:
  1046. return m.AddedTotal()
  1047. case batchmsg.FieldSuccess:
  1048. return m.AddedSuccess()
  1049. case batchmsg.FieldFail:
  1050. return m.AddedFail()
  1051. }
  1052. return nil, false
  1053. }
  1054. // AddField adds the value to the field with the given name. It returns an error if
  1055. // the field is not defined in the schema, or if the type mismatched the field
  1056. // type.
  1057. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  1058. switch name {
  1059. case batchmsg.FieldStatus:
  1060. v, ok := value.(int8)
  1061. if !ok {
  1062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1063. }
  1064. m.AddStatus(v)
  1065. return nil
  1066. case batchmsg.FieldTotal:
  1067. v, ok := value.(int32)
  1068. if !ok {
  1069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1070. }
  1071. m.AddTotal(v)
  1072. return nil
  1073. case batchmsg.FieldSuccess:
  1074. v, ok := value.(int32)
  1075. if !ok {
  1076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1077. }
  1078. m.AddSuccess(v)
  1079. return nil
  1080. case batchmsg.FieldFail:
  1081. v, ok := value.(int32)
  1082. if !ok {
  1083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1084. }
  1085. m.AddFail(v)
  1086. return nil
  1087. }
  1088. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  1089. }
  1090. // ClearedFields returns all nullable fields that were cleared during this
  1091. // mutation.
  1092. func (m *BatchMsgMutation) ClearedFields() []string {
  1093. var fields []string
  1094. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  1095. fields = append(fields, batchmsg.FieldDeletedAt)
  1096. }
  1097. if m.FieldCleared(batchmsg.FieldStatus) {
  1098. fields = append(fields, batchmsg.FieldStatus)
  1099. }
  1100. if m.FieldCleared(batchmsg.FieldBatchNo) {
  1101. fields = append(fields, batchmsg.FieldBatchNo)
  1102. }
  1103. if m.FieldCleared(batchmsg.FieldFromwxid) {
  1104. fields = append(fields, batchmsg.FieldFromwxid)
  1105. }
  1106. if m.FieldCleared(batchmsg.FieldMsg) {
  1107. fields = append(fields, batchmsg.FieldMsg)
  1108. }
  1109. if m.FieldCleared(batchmsg.FieldTag) {
  1110. fields = append(fields, batchmsg.FieldTag)
  1111. }
  1112. if m.FieldCleared(batchmsg.FieldTotal) {
  1113. fields = append(fields, batchmsg.FieldTotal)
  1114. }
  1115. if m.FieldCleared(batchmsg.FieldSuccess) {
  1116. fields = append(fields, batchmsg.FieldSuccess)
  1117. }
  1118. if m.FieldCleared(batchmsg.FieldFail) {
  1119. fields = append(fields, batchmsg.FieldFail)
  1120. }
  1121. if m.FieldCleared(batchmsg.FieldStartTime) {
  1122. fields = append(fields, batchmsg.FieldStartTime)
  1123. }
  1124. if m.FieldCleared(batchmsg.FieldStopTime) {
  1125. fields = append(fields, batchmsg.FieldStopTime)
  1126. }
  1127. return fields
  1128. }
  1129. // FieldCleared returns a boolean indicating if a field with the given name was
  1130. // cleared in this mutation.
  1131. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  1132. _, ok := m.clearedFields[name]
  1133. return ok
  1134. }
  1135. // ClearField clears the value of the field with the given name. It returns an
  1136. // error if the field is not defined in the schema.
  1137. func (m *BatchMsgMutation) ClearField(name string) error {
  1138. switch name {
  1139. case batchmsg.FieldDeletedAt:
  1140. m.ClearDeletedAt()
  1141. return nil
  1142. case batchmsg.FieldStatus:
  1143. m.ClearStatus()
  1144. return nil
  1145. case batchmsg.FieldBatchNo:
  1146. m.ClearBatchNo()
  1147. return nil
  1148. case batchmsg.FieldFromwxid:
  1149. m.ClearFromwxid()
  1150. return nil
  1151. case batchmsg.FieldMsg:
  1152. m.ClearMsg()
  1153. return nil
  1154. case batchmsg.FieldTag:
  1155. m.ClearTag()
  1156. return nil
  1157. case batchmsg.FieldTotal:
  1158. m.ClearTotal()
  1159. return nil
  1160. case batchmsg.FieldSuccess:
  1161. m.ClearSuccess()
  1162. return nil
  1163. case batchmsg.FieldFail:
  1164. m.ClearFail()
  1165. return nil
  1166. case batchmsg.FieldStartTime:
  1167. m.ClearStartTime()
  1168. return nil
  1169. case batchmsg.FieldStopTime:
  1170. m.ClearStopTime()
  1171. return nil
  1172. }
  1173. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  1174. }
  1175. // ResetField resets all changes in the mutation for the field with the given name.
  1176. // It returns an error if the field is not defined in the schema.
  1177. func (m *BatchMsgMutation) ResetField(name string) error {
  1178. switch name {
  1179. case batchmsg.FieldCreatedAt:
  1180. m.ResetCreatedAt()
  1181. return nil
  1182. case batchmsg.FieldUpdatedAt:
  1183. m.ResetUpdatedAt()
  1184. return nil
  1185. case batchmsg.FieldDeletedAt:
  1186. m.ResetDeletedAt()
  1187. return nil
  1188. case batchmsg.FieldStatus:
  1189. m.ResetStatus()
  1190. return nil
  1191. case batchmsg.FieldBatchNo:
  1192. m.ResetBatchNo()
  1193. return nil
  1194. case batchmsg.FieldFromwxid:
  1195. m.ResetFromwxid()
  1196. return nil
  1197. case batchmsg.FieldMsg:
  1198. m.ResetMsg()
  1199. return nil
  1200. case batchmsg.FieldTag:
  1201. m.ResetTag()
  1202. return nil
  1203. case batchmsg.FieldTotal:
  1204. m.ResetTotal()
  1205. return nil
  1206. case batchmsg.FieldSuccess:
  1207. m.ResetSuccess()
  1208. return nil
  1209. case batchmsg.FieldFail:
  1210. m.ResetFail()
  1211. return nil
  1212. case batchmsg.FieldStartTime:
  1213. m.ResetStartTime()
  1214. return nil
  1215. case batchmsg.FieldStopTime:
  1216. m.ResetStopTime()
  1217. return nil
  1218. }
  1219. return fmt.Errorf("unknown BatchMsg field %s", name)
  1220. }
  1221. // AddedEdges returns all edge names that were set/added in this mutation.
  1222. func (m *BatchMsgMutation) AddedEdges() []string {
  1223. edges := make([]string, 0, 0)
  1224. return edges
  1225. }
  1226. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1227. // name in this mutation.
  1228. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  1229. return nil
  1230. }
  1231. // RemovedEdges returns all edge names that were removed in this mutation.
  1232. func (m *BatchMsgMutation) RemovedEdges() []string {
  1233. edges := make([]string, 0, 0)
  1234. return edges
  1235. }
  1236. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1237. // the given name in this mutation.
  1238. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  1239. return nil
  1240. }
  1241. // ClearedEdges returns all edge names that were cleared in this mutation.
  1242. func (m *BatchMsgMutation) ClearedEdges() []string {
  1243. edges := make([]string, 0, 0)
  1244. return edges
  1245. }
  1246. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1247. // was cleared in this mutation.
  1248. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  1249. return false
  1250. }
  1251. // ClearEdge clears the value of the edge with the given name. It returns an error
  1252. // if that edge is not defined in the schema.
  1253. func (m *BatchMsgMutation) ClearEdge(name string) error {
  1254. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  1255. }
  1256. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1257. // It returns an error if the edge is not defined in the schema.
  1258. func (m *BatchMsgMutation) ResetEdge(name string) error {
  1259. return fmt.Errorf("unknown BatchMsg edge %s", name)
  1260. }
  1261. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  1262. type ContactMutation struct {
  1263. config
  1264. op Op
  1265. typ string
  1266. id *uint64
  1267. created_at *time.Time
  1268. updated_at *time.Time
  1269. status *uint8
  1270. addstatus *int8
  1271. deleted_at *time.Time
  1272. wx_wxid *string
  1273. _type *int
  1274. add_type *int
  1275. wxid *string
  1276. account *string
  1277. nickname *string
  1278. markname *string
  1279. headimg *string
  1280. sex *int
  1281. addsex *int
  1282. starrole *string
  1283. dontseeit *int
  1284. adddontseeit *int
  1285. dontseeme *int
  1286. adddontseeme *int
  1287. lag *string
  1288. gid *string
  1289. gname *string
  1290. v3 *string
  1291. clearedFields map[string]struct{}
  1292. contact_relationships map[uint64]struct{}
  1293. removedcontact_relationships map[uint64]struct{}
  1294. clearedcontact_relationships bool
  1295. contact_messages map[uint64]struct{}
  1296. removedcontact_messages map[uint64]struct{}
  1297. clearedcontact_messages bool
  1298. done bool
  1299. oldValue func(context.Context) (*Contact, error)
  1300. predicates []predicate.Contact
  1301. }
  1302. var _ ent.Mutation = (*ContactMutation)(nil)
  1303. // contactOption allows management of the mutation configuration using functional options.
  1304. type contactOption func(*ContactMutation)
  1305. // newContactMutation creates new mutation for the Contact entity.
  1306. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  1307. m := &ContactMutation{
  1308. config: c,
  1309. op: op,
  1310. typ: TypeContact,
  1311. clearedFields: make(map[string]struct{}),
  1312. }
  1313. for _, opt := range opts {
  1314. opt(m)
  1315. }
  1316. return m
  1317. }
  1318. // withContactID sets the ID field of the mutation.
  1319. func withContactID(id uint64) contactOption {
  1320. return func(m *ContactMutation) {
  1321. var (
  1322. err error
  1323. once sync.Once
  1324. value *Contact
  1325. )
  1326. m.oldValue = func(ctx context.Context) (*Contact, error) {
  1327. once.Do(func() {
  1328. if m.done {
  1329. err = errors.New("querying old values post mutation is not allowed")
  1330. } else {
  1331. value, err = m.Client().Contact.Get(ctx, id)
  1332. }
  1333. })
  1334. return value, err
  1335. }
  1336. m.id = &id
  1337. }
  1338. }
  1339. // withContact sets the old Contact of the mutation.
  1340. func withContact(node *Contact) contactOption {
  1341. return func(m *ContactMutation) {
  1342. m.oldValue = func(context.Context) (*Contact, error) {
  1343. return node, nil
  1344. }
  1345. m.id = &node.ID
  1346. }
  1347. }
  1348. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1349. // executed in a transaction (ent.Tx), a transactional client is returned.
  1350. func (m ContactMutation) Client() *Client {
  1351. client := &Client{config: m.config}
  1352. client.init()
  1353. return client
  1354. }
  1355. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1356. // it returns an error otherwise.
  1357. func (m ContactMutation) Tx() (*Tx, error) {
  1358. if _, ok := m.driver.(*txDriver); !ok {
  1359. return nil, errors.New("ent: mutation is not running in a transaction")
  1360. }
  1361. tx := &Tx{config: m.config}
  1362. tx.init()
  1363. return tx, nil
  1364. }
  1365. // SetID sets the value of the id field. Note that this
  1366. // operation is only accepted on creation of Contact entities.
  1367. func (m *ContactMutation) SetID(id uint64) {
  1368. m.id = &id
  1369. }
  1370. // ID returns the ID value in the mutation. Note that the ID is only available
  1371. // if it was provided to the builder or after it was returned from the database.
  1372. func (m *ContactMutation) ID() (id uint64, exists bool) {
  1373. if m.id == nil {
  1374. return
  1375. }
  1376. return *m.id, true
  1377. }
  1378. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1379. // That means, if the mutation is applied within a transaction with an isolation level such
  1380. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1381. // or updated by the mutation.
  1382. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  1383. switch {
  1384. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1385. id, exists := m.ID()
  1386. if exists {
  1387. return []uint64{id}, nil
  1388. }
  1389. fallthrough
  1390. case m.op.Is(OpUpdate | OpDelete):
  1391. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  1392. default:
  1393. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1394. }
  1395. }
  1396. // SetCreatedAt sets the "created_at" field.
  1397. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  1398. m.created_at = &t
  1399. }
  1400. // CreatedAt returns the value of the "created_at" field in the mutation.
  1401. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  1402. v := m.created_at
  1403. if v == nil {
  1404. return
  1405. }
  1406. return *v, true
  1407. }
  1408. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  1409. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1410. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1411. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  1412. if !m.op.Is(OpUpdateOne) {
  1413. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  1414. }
  1415. if m.id == nil || m.oldValue == nil {
  1416. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  1417. }
  1418. oldValue, err := m.oldValue(ctx)
  1419. if err != nil {
  1420. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  1421. }
  1422. return oldValue.CreatedAt, nil
  1423. }
  1424. // ResetCreatedAt resets all changes to the "created_at" field.
  1425. func (m *ContactMutation) ResetCreatedAt() {
  1426. m.created_at = nil
  1427. }
  1428. // SetUpdatedAt sets the "updated_at" field.
  1429. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  1430. m.updated_at = &t
  1431. }
  1432. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  1433. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  1434. v := m.updated_at
  1435. if v == nil {
  1436. return
  1437. }
  1438. return *v, true
  1439. }
  1440. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  1441. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1443. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  1444. if !m.op.Is(OpUpdateOne) {
  1445. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  1446. }
  1447. if m.id == nil || m.oldValue == nil {
  1448. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  1449. }
  1450. oldValue, err := m.oldValue(ctx)
  1451. if err != nil {
  1452. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  1453. }
  1454. return oldValue.UpdatedAt, nil
  1455. }
  1456. // ResetUpdatedAt resets all changes to the "updated_at" field.
  1457. func (m *ContactMutation) ResetUpdatedAt() {
  1458. m.updated_at = nil
  1459. }
  1460. // SetStatus sets the "status" field.
  1461. func (m *ContactMutation) SetStatus(u uint8) {
  1462. m.status = &u
  1463. m.addstatus = nil
  1464. }
  1465. // Status returns the value of the "status" field in the mutation.
  1466. func (m *ContactMutation) Status() (r uint8, exists bool) {
  1467. v := m.status
  1468. if v == nil {
  1469. return
  1470. }
  1471. return *v, true
  1472. }
  1473. // OldStatus returns the old "status" field's value of the Contact entity.
  1474. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1475. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1476. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  1477. if !m.op.Is(OpUpdateOne) {
  1478. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  1479. }
  1480. if m.id == nil || m.oldValue == nil {
  1481. return v, errors.New("OldStatus requires an ID field in the mutation")
  1482. }
  1483. oldValue, err := m.oldValue(ctx)
  1484. if err != nil {
  1485. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  1486. }
  1487. return oldValue.Status, nil
  1488. }
  1489. // AddStatus adds u to the "status" field.
  1490. func (m *ContactMutation) AddStatus(u int8) {
  1491. if m.addstatus != nil {
  1492. *m.addstatus += u
  1493. } else {
  1494. m.addstatus = &u
  1495. }
  1496. }
  1497. // AddedStatus returns the value that was added to the "status" field in this mutation.
  1498. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  1499. v := m.addstatus
  1500. if v == nil {
  1501. return
  1502. }
  1503. return *v, true
  1504. }
  1505. // ClearStatus clears the value of the "status" field.
  1506. func (m *ContactMutation) ClearStatus() {
  1507. m.status = nil
  1508. m.addstatus = nil
  1509. m.clearedFields[contact.FieldStatus] = struct{}{}
  1510. }
  1511. // StatusCleared returns if the "status" field was cleared in this mutation.
  1512. func (m *ContactMutation) StatusCleared() bool {
  1513. _, ok := m.clearedFields[contact.FieldStatus]
  1514. return ok
  1515. }
  1516. // ResetStatus resets all changes to the "status" field.
  1517. func (m *ContactMutation) ResetStatus() {
  1518. m.status = nil
  1519. m.addstatus = nil
  1520. delete(m.clearedFields, contact.FieldStatus)
  1521. }
  1522. // SetDeletedAt sets the "deleted_at" field.
  1523. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  1524. m.deleted_at = &t
  1525. }
  1526. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  1527. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  1528. v := m.deleted_at
  1529. if v == nil {
  1530. return
  1531. }
  1532. return *v, true
  1533. }
  1534. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  1535. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1537. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  1538. if !m.op.Is(OpUpdateOne) {
  1539. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  1540. }
  1541. if m.id == nil || m.oldValue == nil {
  1542. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  1543. }
  1544. oldValue, err := m.oldValue(ctx)
  1545. if err != nil {
  1546. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  1547. }
  1548. return oldValue.DeletedAt, nil
  1549. }
  1550. // ClearDeletedAt clears the value of the "deleted_at" field.
  1551. func (m *ContactMutation) ClearDeletedAt() {
  1552. m.deleted_at = nil
  1553. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  1554. }
  1555. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  1556. func (m *ContactMutation) DeletedAtCleared() bool {
  1557. _, ok := m.clearedFields[contact.FieldDeletedAt]
  1558. return ok
  1559. }
  1560. // ResetDeletedAt resets all changes to the "deleted_at" field.
  1561. func (m *ContactMutation) ResetDeletedAt() {
  1562. m.deleted_at = nil
  1563. delete(m.clearedFields, contact.FieldDeletedAt)
  1564. }
  1565. // SetWxWxid sets the "wx_wxid" field.
  1566. func (m *ContactMutation) SetWxWxid(s string) {
  1567. m.wx_wxid = &s
  1568. }
  1569. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  1570. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  1571. v := m.wx_wxid
  1572. if v == nil {
  1573. return
  1574. }
  1575. return *v, true
  1576. }
  1577. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  1578. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1579. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1580. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  1581. if !m.op.Is(OpUpdateOne) {
  1582. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  1583. }
  1584. if m.id == nil || m.oldValue == nil {
  1585. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  1586. }
  1587. oldValue, err := m.oldValue(ctx)
  1588. if err != nil {
  1589. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  1590. }
  1591. return oldValue.WxWxid, nil
  1592. }
  1593. // ClearWxWxid clears the value of the "wx_wxid" field.
  1594. func (m *ContactMutation) ClearWxWxid() {
  1595. m.wx_wxid = nil
  1596. m.clearedFields[contact.FieldWxWxid] = struct{}{}
  1597. }
  1598. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  1599. func (m *ContactMutation) WxWxidCleared() bool {
  1600. _, ok := m.clearedFields[contact.FieldWxWxid]
  1601. return ok
  1602. }
  1603. // ResetWxWxid resets all changes to the "wx_wxid" field.
  1604. func (m *ContactMutation) ResetWxWxid() {
  1605. m.wx_wxid = nil
  1606. delete(m.clearedFields, contact.FieldWxWxid)
  1607. }
  1608. // SetType sets the "type" field.
  1609. func (m *ContactMutation) SetType(i int) {
  1610. m._type = &i
  1611. m.add_type = nil
  1612. }
  1613. // GetType returns the value of the "type" field in the mutation.
  1614. func (m *ContactMutation) GetType() (r int, exists bool) {
  1615. v := m._type
  1616. if v == nil {
  1617. return
  1618. }
  1619. return *v, true
  1620. }
  1621. // OldType returns the old "type" field's value of the Contact entity.
  1622. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1623. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1624. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  1625. if !m.op.Is(OpUpdateOne) {
  1626. return v, errors.New("OldType is only allowed on UpdateOne operations")
  1627. }
  1628. if m.id == nil || m.oldValue == nil {
  1629. return v, errors.New("OldType requires an ID field in the mutation")
  1630. }
  1631. oldValue, err := m.oldValue(ctx)
  1632. if err != nil {
  1633. return v, fmt.Errorf("querying old value for OldType: %w", err)
  1634. }
  1635. return oldValue.Type, nil
  1636. }
  1637. // AddType adds i to the "type" field.
  1638. func (m *ContactMutation) AddType(i int) {
  1639. if m.add_type != nil {
  1640. *m.add_type += i
  1641. } else {
  1642. m.add_type = &i
  1643. }
  1644. }
  1645. // AddedType returns the value that was added to the "type" field in this mutation.
  1646. func (m *ContactMutation) AddedType() (r int, exists bool) {
  1647. v := m.add_type
  1648. if v == nil {
  1649. return
  1650. }
  1651. return *v, true
  1652. }
  1653. // ClearType clears the value of the "type" field.
  1654. func (m *ContactMutation) ClearType() {
  1655. m._type = nil
  1656. m.add_type = nil
  1657. m.clearedFields[contact.FieldType] = struct{}{}
  1658. }
  1659. // TypeCleared returns if the "type" field was cleared in this mutation.
  1660. func (m *ContactMutation) TypeCleared() bool {
  1661. _, ok := m.clearedFields[contact.FieldType]
  1662. return ok
  1663. }
  1664. // ResetType resets all changes to the "type" field.
  1665. func (m *ContactMutation) ResetType() {
  1666. m._type = nil
  1667. m.add_type = nil
  1668. delete(m.clearedFields, contact.FieldType)
  1669. }
  1670. // SetWxid sets the "wxid" field.
  1671. func (m *ContactMutation) SetWxid(s string) {
  1672. m.wxid = &s
  1673. }
  1674. // Wxid returns the value of the "wxid" field in the mutation.
  1675. func (m *ContactMutation) Wxid() (r string, exists bool) {
  1676. v := m.wxid
  1677. if v == nil {
  1678. return
  1679. }
  1680. return *v, true
  1681. }
  1682. // OldWxid returns the old "wxid" field's value of the Contact entity.
  1683. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1684. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1685. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  1686. if !m.op.Is(OpUpdateOne) {
  1687. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  1688. }
  1689. if m.id == nil || m.oldValue == nil {
  1690. return v, errors.New("OldWxid requires an ID field in the mutation")
  1691. }
  1692. oldValue, err := m.oldValue(ctx)
  1693. if err != nil {
  1694. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  1695. }
  1696. return oldValue.Wxid, nil
  1697. }
  1698. // ResetWxid resets all changes to the "wxid" field.
  1699. func (m *ContactMutation) ResetWxid() {
  1700. m.wxid = nil
  1701. }
  1702. // SetAccount sets the "account" field.
  1703. func (m *ContactMutation) SetAccount(s string) {
  1704. m.account = &s
  1705. }
  1706. // Account returns the value of the "account" field in the mutation.
  1707. func (m *ContactMutation) Account() (r string, exists bool) {
  1708. v := m.account
  1709. if v == nil {
  1710. return
  1711. }
  1712. return *v, true
  1713. }
  1714. // OldAccount returns the old "account" field's value of the Contact entity.
  1715. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1716. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1717. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  1718. if !m.op.Is(OpUpdateOne) {
  1719. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  1720. }
  1721. if m.id == nil || m.oldValue == nil {
  1722. return v, errors.New("OldAccount requires an ID field in the mutation")
  1723. }
  1724. oldValue, err := m.oldValue(ctx)
  1725. if err != nil {
  1726. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  1727. }
  1728. return oldValue.Account, nil
  1729. }
  1730. // ResetAccount resets all changes to the "account" field.
  1731. func (m *ContactMutation) ResetAccount() {
  1732. m.account = nil
  1733. }
  1734. // SetNickname sets the "nickname" field.
  1735. func (m *ContactMutation) SetNickname(s string) {
  1736. m.nickname = &s
  1737. }
  1738. // Nickname returns the value of the "nickname" field in the mutation.
  1739. func (m *ContactMutation) Nickname() (r string, exists bool) {
  1740. v := m.nickname
  1741. if v == nil {
  1742. return
  1743. }
  1744. return *v, true
  1745. }
  1746. // OldNickname returns the old "nickname" field's value of the Contact entity.
  1747. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1748. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1749. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  1750. if !m.op.Is(OpUpdateOne) {
  1751. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  1752. }
  1753. if m.id == nil || m.oldValue == nil {
  1754. return v, errors.New("OldNickname requires an ID field in the mutation")
  1755. }
  1756. oldValue, err := m.oldValue(ctx)
  1757. if err != nil {
  1758. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  1759. }
  1760. return oldValue.Nickname, nil
  1761. }
  1762. // ResetNickname resets all changes to the "nickname" field.
  1763. func (m *ContactMutation) ResetNickname() {
  1764. m.nickname = nil
  1765. }
  1766. // SetMarkname sets the "markname" field.
  1767. func (m *ContactMutation) SetMarkname(s string) {
  1768. m.markname = &s
  1769. }
  1770. // Markname returns the value of the "markname" field in the mutation.
  1771. func (m *ContactMutation) Markname() (r string, exists bool) {
  1772. v := m.markname
  1773. if v == nil {
  1774. return
  1775. }
  1776. return *v, true
  1777. }
  1778. // OldMarkname returns the old "markname" field's value of the Contact entity.
  1779. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1781. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  1782. if !m.op.Is(OpUpdateOne) {
  1783. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  1784. }
  1785. if m.id == nil || m.oldValue == nil {
  1786. return v, errors.New("OldMarkname requires an ID field in the mutation")
  1787. }
  1788. oldValue, err := m.oldValue(ctx)
  1789. if err != nil {
  1790. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  1791. }
  1792. return oldValue.Markname, nil
  1793. }
  1794. // ResetMarkname resets all changes to the "markname" field.
  1795. func (m *ContactMutation) ResetMarkname() {
  1796. m.markname = nil
  1797. }
  1798. // SetHeadimg sets the "headimg" field.
  1799. func (m *ContactMutation) SetHeadimg(s string) {
  1800. m.headimg = &s
  1801. }
  1802. // Headimg returns the value of the "headimg" field in the mutation.
  1803. func (m *ContactMutation) Headimg() (r string, exists bool) {
  1804. v := m.headimg
  1805. if v == nil {
  1806. return
  1807. }
  1808. return *v, true
  1809. }
  1810. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  1811. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1812. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1813. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  1814. if !m.op.Is(OpUpdateOne) {
  1815. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  1816. }
  1817. if m.id == nil || m.oldValue == nil {
  1818. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  1819. }
  1820. oldValue, err := m.oldValue(ctx)
  1821. if err != nil {
  1822. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  1823. }
  1824. return oldValue.Headimg, nil
  1825. }
  1826. // ResetHeadimg resets all changes to the "headimg" field.
  1827. func (m *ContactMutation) ResetHeadimg() {
  1828. m.headimg = nil
  1829. }
  1830. // SetSex sets the "sex" field.
  1831. func (m *ContactMutation) SetSex(i int) {
  1832. m.sex = &i
  1833. m.addsex = nil
  1834. }
  1835. // Sex returns the value of the "sex" field in the mutation.
  1836. func (m *ContactMutation) Sex() (r int, exists bool) {
  1837. v := m.sex
  1838. if v == nil {
  1839. return
  1840. }
  1841. return *v, true
  1842. }
  1843. // OldSex returns the old "sex" field's value of the Contact entity.
  1844. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1846. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  1847. if !m.op.Is(OpUpdateOne) {
  1848. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  1849. }
  1850. if m.id == nil || m.oldValue == nil {
  1851. return v, errors.New("OldSex requires an ID field in the mutation")
  1852. }
  1853. oldValue, err := m.oldValue(ctx)
  1854. if err != nil {
  1855. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  1856. }
  1857. return oldValue.Sex, nil
  1858. }
  1859. // AddSex adds i to the "sex" field.
  1860. func (m *ContactMutation) AddSex(i int) {
  1861. if m.addsex != nil {
  1862. *m.addsex += i
  1863. } else {
  1864. m.addsex = &i
  1865. }
  1866. }
  1867. // AddedSex returns the value that was added to the "sex" field in this mutation.
  1868. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  1869. v := m.addsex
  1870. if v == nil {
  1871. return
  1872. }
  1873. return *v, true
  1874. }
  1875. // ResetSex resets all changes to the "sex" field.
  1876. func (m *ContactMutation) ResetSex() {
  1877. m.sex = nil
  1878. m.addsex = nil
  1879. }
  1880. // SetStarrole sets the "starrole" field.
  1881. func (m *ContactMutation) SetStarrole(s string) {
  1882. m.starrole = &s
  1883. }
  1884. // Starrole returns the value of the "starrole" field in the mutation.
  1885. func (m *ContactMutation) Starrole() (r string, exists bool) {
  1886. v := m.starrole
  1887. if v == nil {
  1888. return
  1889. }
  1890. return *v, true
  1891. }
  1892. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  1893. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1894. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1895. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  1896. if !m.op.Is(OpUpdateOne) {
  1897. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  1898. }
  1899. if m.id == nil || m.oldValue == nil {
  1900. return v, errors.New("OldStarrole requires an ID field in the mutation")
  1901. }
  1902. oldValue, err := m.oldValue(ctx)
  1903. if err != nil {
  1904. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  1905. }
  1906. return oldValue.Starrole, nil
  1907. }
  1908. // ResetStarrole resets all changes to the "starrole" field.
  1909. func (m *ContactMutation) ResetStarrole() {
  1910. m.starrole = nil
  1911. }
  1912. // SetDontseeit sets the "dontseeit" field.
  1913. func (m *ContactMutation) SetDontseeit(i int) {
  1914. m.dontseeit = &i
  1915. m.adddontseeit = nil
  1916. }
  1917. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  1918. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  1919. v := m.dontseeit
  1920. if v == nil {
  1921. return
  1922. }
  1923. return *v, true
  1924. }
  1925. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  1926. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1927. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1928. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  1929. if !m.op.Is(OpUpdateOne) {
  1930. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  1931. }
  1932. if m.id == nil || m.oldValue == nil {
  1933. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  1934. }
  1935. oldValue, err := m.oldValue(ctx)
  1936. if err != nil {
  1937. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  1938. }
  1939. return oldValue.Dontseeit, nil
  1940. }
  1941. // AddDontseeit adds i to the "dontseeit" field.
  1942. func (m *ContactMutation) AddDontseeit(i int) {
  1943. if m.adddontseeit != nil {
  1944. *m.adddontseeit += i
  1945. } else {
  1946. m.adddontseeit = &i
  1947. }
  1948. }
  1949. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  1950. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  1951. v := m.adddontseeit
  1952. if v == nil {
  1953. return
  1954. }
  1955. return *v, true
  1956. }
  1957. // ResetDontseeit resets all changes to the "dontseeit" field.
  1958. func (m *ContactMutation) ResetDontseeit() {
  1959. m.dontseeit = nil
  1960. m.adddontseeit = nil
  1961. }
  1962. // SetDontseeme sets the "dontseeme" field.
  1963. func (m *ContactMutation) SetDontseeme(i int) {
  1964. m.dontseeme = &i
  1965. m.adddontseeme = nil
  1966. }
  1967. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  1968. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  1969. v := m.dontseeme
  1970. if v == nil {
  1971. return
  1972. }
  1973. return *v, true
  1974. }
  1975. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  1976. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  1977. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1978. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  1979. if !m.op.Is(OpUpdateOne) {
  1980. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  1981. }
  1982. if m.id == nil || m.oldValue == nil {
  1983. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  1984. }
  1985. oldValue, err := m.oldValue(ctx)
  1986. if err != nil {
  1987. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  1988. }
  1989. return oldValue.Dontseeme, nil
  1990. }
  1991. // AddDontseeme adds i to the "dontseeme" field.
  1992. func (m *ContactMutation) AddDontseeme(i int) {
  1993. if m.adddontseeme != nil {
  1994. *m.adddontseeme += i
  1995. } else {
  1996. m.adddontseeme = &i
  1997. }
  1998. }
  1999. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  2000. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  2001. v := m.adddontseeme
  2002. if v == nil {
  2003. return
  2004. }
  2005. return *v, true
  2006. }
  2007. // ResetDontseeme resets all changes to the "dontseeme" field.
  2008. func (m *ContactMutation) ResetDontseeme() {
  2009. m.dontseeme = nil
  2010. m.adddontseeme = nil
  2011. }
  2012. // SetLag sets the "lag" field.
  2013. func (m *ContactMutation) SetLag(s string) {
  2014. m.lag = &s
  2015. }
  2016. // Lag returns the value of the "lag" field in the mutation.
  2017. func (m *ContactMutation) Lag() (r string, exists bool) {
  2018. v := m.lag
  2019. if v == nil {
  2020. return
  2021. }
  2022. return *v, true
  2023. }
  2024. // OldLag returns the old "lag" field's value of the Contact entity.
  2025. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2026. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2027. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  2028. if !m.op.Is(OpUpdateOne) {
  2029. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  2030. }
  2031. if m.id == nil || m.oldValue == nil {
  2032. return v, errors.New("OldLag requires an ID field in the mutation")
  2033. }
  2034. oldValue, err := m.oldValue(ctx)
  2035. if err != nil {
  2036. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  2037. }
  2038. return oldValue.Lag, nil
  2039. }
  2040. // ResetLag resets all changes to the "lag" field.
  2041. func (m *ContactMutation) ResetLag() {
  2042. m.lag = nil
  2043. }
  2044. // SetGid sets the "gid" field.
  2045. func (m *ContactMutation) SetGid(s string) {
  2046. m.gid = &s
  2047. }
  2048. // Gid returns the value of the "gid" field in the mutation.
  2049. func (m *ContactMutation) Gid() (r string, exists bool) {
  2050. v := m.gid
  2051. if v == nil {
  2052. return
  2053. }
  2054. return *v, true
  2055. }
  2056. // OldGid returns the old "gid" field's value of the Contact entity.
  2057. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2058. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2059. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  2060. if !m.op.Is(OpUpdateOne) {
  2061. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  2062. }
  2063. if m.id == nil || m.oldValue == nil {
  2064. return v, errors.New("OldGid requires an ID field in the mutation")
  2065. }
  2066. oldValue, err := m.oldValue(ctx)
  2067. if err != nil {
  2068. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  2069. }
  2070. return oldValue.Gid, nil
  2071. }
  2072. // ResetGid resets all changes to the "gid" field.
  2073. func (m *ContactMutation) ResetGid() {
  2074. m.gid = nil
  2075. }
  2076. // SetGname sets the "gname" field.
  2077. func (m *ContactMutation) SetGname(s string) {
  2078. m.gname = &s
  2079. }
  2080. // Gname returns the value of the "gname" field in the mutation.
  2081. func (m *ContactMutation) Gname() (r string, exists bool) {
  2082. v := m.gname
  2083. if v == nil {
  2084. return
  2085. }
  2086. return *v, true
  2087. }
  2088. // OldGname returns the old "gname" field's value of the Contact entity.
  2089. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2090. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2091. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  2092. if !m.op.Is(OpUpdateOne) {
  2093. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  2094. }
  2095. if m.id == nil || m.oldValue == nil {
  2096. return v, errors.New("OldGname requires an ID field in the mutation")
  2097. }
  2098. oldValue, err := m.oldValue(ctx)
  2099. if err != nil {
  2100. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  2101. }
  2102. return oldValue.Gname, nil
  2103. }
  2104. // ResetGname resets all changes to the "gname" field.
  2105. func (m *ContactMutation) ResetGname() {
  2106. m.gname = nil
  2107. }
  2108. // SetV3 sets the "v3" field.
  2109. func (m *ContactMutation) SetV3(s string) {
  2110. m.v3 = &s
  2111. }
  2112. // V3 returns the value of the "v3" field in the mutation.
  2113. func (m *ContactMutation) V3() (r string, exists bool) {
  2114. v := m.v3
  2115. if v == nil {
  2116. return
  2117. }
  2118. return *v, true
  2119. }
  2120. // OldV3 returns the old "v3" field's value of the Contact entity.
  2121. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2122. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2123. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  2124. if !m.op.Is(OpUpdateOne) {
  2125. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  2126. }
  2127. if m.id == nil || m.oldValue == nil {
  2128. return v, errors.New("OldV3 requires an ID field in the mutation")
  2129. }
  2130. oldValue, err := m.oldValue(ctx)
  2131. if err != nil {
  2132. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  2133. }
  2134. return oldValue.V3, nil
  2135. }
  2136. // ResetV3 resets all changes to the "v3" field.
  2137. func (m *ContactMutation) ResetV3() {
  2138. m.v3 = nil
  2139. }
  2140. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  2141. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  2142. if m.contact_relationships == nil {
  2143. m.contact_relationships = make(map[uint64]struct{})
  2144. }
  2145. for i := range ids {
  2146. m.contact_relationships[ids[i]] = struct{}{}
  2147. }
  2148. }
  2149. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  2150. func (m *ContactMutation) ClearContactRelationships() {
  2151. m.clearedcontact_relationships = true
  2152. }
  2153. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  2154. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  2155. return m.clearedcontact_relationships
  2156. }
  2157. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  2158. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  2159. if m.removedcontact_relationships == nil {
  2160. m.removedcontact_relationships = make(map[uint64]struct{})
  2161. }
  2162. for i := range ids {
  2163. delete(m.contact_relationships, ids[i])
  2164. m.removedcontact_relationships[ids[i]] = struct{}{}
  2165. }
  2166. }
  2167. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  2168. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  2169. for id := range m.removedcontact_relationships {
  2170. ids = append(ids, id)
  2171. }
  2172. return
  2173. }
  2174. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  2175. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  2176. for id := range m.contact_relationships {
  2177. ids = append(ids, id)
  2178. }
  2179. return
  2180. }
  2181. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  2182. func (m *ContactMutation) ResetContactRelationships() {
  2183. m.contact_relationships = nil
  2184. m.clearedcontact_relationships = false
  2185. m.removedcontact_relationships = nil
  2186. }
  2187. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  2188. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  2189. if m.contact_messages == nil {
  2190. m.contact_messages = make(map[uint64]struct{})
  2191. }
  2192. for i := range ids {
  2193. m.contact_messages[ids[i]] = struct{}{}
  2194. }
  2195. }
  2196. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  2197. func (m *ContactMutation) ClearContactMessages() {
  2198. m.clearedcontact_messages = true
  2199. }
  2200. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  2201. func (m *ContactMutation) ContactMessagesCleared() bool {
  2202. return m.clearedcontact_messages
  2203. }
  2204. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  2205. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  2206. if m.removedcontact_messages == nil {
  2207. m.removedcontact_messages = make(map[uint64]struct{})
  2208. }
  2209. for i := range ids {
  2210. delete(m.contact_messages, ids[i])
  2211. m.removedcontact_messages[ids[i]] = struct{}{}
  2212. }
  2213. }
  2214. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  2215. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  2216. for id := range m.removedcontact_messages {
  2217. ids = append(ids, id)
  2218. }
  2219. return
  2220. }
  2221. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  2222. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  2223. for id := range m.contact_messages {
  2224. ids = append(ids, id)
  2225. }
  2226. return
  2227. }
  2228. // ResetContactMessages resets all changes to the "contact_messages" edge.
  2229. func (m *ContactMutation) ResetContactMessages() {
  2230. m.contact_messages = nil
  2231. m.clearedcontact_messages = false
  2232. m.removedcontact_messages = nil
  2233. }
  2234. // Where appends a list predicates to the ContactMutation builder.
  2235. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  2236. m.predicates = append(m.predicates, ps...)
  2237. }
  2238. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  2239. // users can use type-assertion to append predicates that do not depend on any generated package.
  2240. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  2241. p := make([]predicate.Contact, len(ps))
  2242. for i := range ps {
  2243. p[i] = ps[i]
  2244. }
  2245. m.Where(p...)
  2246. }
  2247. // Op returns the operation name.
  2248. func (m *ContactMutation) Op() Op {
  2249. return m.op
  2250. }
  2251. // SetOp allows setting the mutation operation.
  2252. func (m *ContactMutation) SetOp(op Op) {
  2253. m.op = op
  2254. }
  2255. // Type returns the node type of this mutation (Contact).
  2256. func (m *ContactMutation) Type() string {
  2257. return m.typ
  2258. }
  2259. // Fields returns all fields that were changed during this mutation. Note that in
  2260. // order to get all numeric fields that were incremented/decremented, call
  2261. // AddedFields().
  2262. func (m *ContactMutation) Fields() []string {
  2263. fields := make([]string, 0, 19)
  2264. if m.created_at != nil {
  2265. fields = append(fields, contact.FieldCreatedAt)
  2266. }
  2267. if m.updated_at != nil {
  2268. fields = append(fields, contact.FieldUpdatedAt)
  2269. }
  2270. if m.status != nil {
  2271. fields = append(fields, contact.FieldStatus)
  2272. }
  2273. if m.deleted_at != nil {
  2274. fields = append(fields, contact.FieldDeletedAt)
  2275. }
  2276. if m.wx_wxid != nil {
  2277. fields = append(fields, contact.FieldWxWxid)
  2278. }
  2279. if m._type != nil {
  2280. fields = append(fields, contact.FieldType)
  2281. }
  2282. if m.wxid != nil {
  2283. fields = append(fields, contact.FieldWxid)
  2284. }
  2285. if m.account != nil {
  2286. fields = append(fields, contact.FieldAccount)
  2287. }
  2288. if m.nickname != nil {
  2289. fields = append(fields, contact.FieldNickname)
  2290. }
  2291. if m.markname != nil {
  2292. fields = append(fields, contact.FieldMarkname)
  2293. }
  2294. if m.headimg != nil {
  2295. fields = append(fields, contact.FieldHeadimg)
  2296. }
  2297. if m.sex != nil {
  2298. fields = append(fields, contact.FieldSex)
  2299. }
  2300. if m.starrole != nil {
  2301. fields = append(fields, contact.FieldStarrole)
  2302. }
  2303. if m.dontseeit != nil {
  2304. fields = append(fields, contact.FieldDontseeit)
  2305. }
  2306. if m.dontseeme != nil {
  2307. fields = append(fields, contact.FieldDontseeme)
  2308. }
  2309. if m.lag != nil {
  2310. fields = append(fields, contact.FieldLag)
  2311. }
  2312. if m.gid != nil {
  2313. fields = append(fields, contact.FieldGid)
  2314. }
  2315. if m.gname != nil {
  2316. fields = append(fields, contact.FieldGname)
  2317. }
  2318. if m.v3 != nil {
  2319. fields = append(fields, contact.FieldV3)
  2320. }
  2321. return fields
  2322. }
  2323. // Field returns the value of a field with the given name. The second boolean
  2324. // return value indicates that this field was not set, or was not defined in the
  2325. // schema.
  2326. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  2327. switch name {
  2328. case contact.FieldCreatedAt:
  2329. return m.CreatedAt()
  2330. case contact.FieldUpdatedAt:
  2331. return m.UpdatedAt()
  2332. case contact.FieldStatus:
  2333. return m.Status()
  2334. case contact.FieldDeletedAt:
  2335. return m.DeletedAt()
  2336. case contact.FieldWxWxid:
  2337. return m.WxWxid()
  2338. case contact.FieldType:
  2339. return m.GetType()
  2340. case contact.FieldWxid:
  2341. return m.Wxid()
  2342. case contact.FieldAccount:
  2343. return m.Account()
  2344. case contact.FieldNickname:
  2345. return m.Nickname()
  2346. case contact.FieldMarkname:
  2347. return m.Markname()
  2348. case contact.FieldHeadimg:
  2349. return m.Headimg()
  2350. case contact.FieldSex:
  2351. return m.Sex()
  2352. case contact.FieldStarrole:
  2353. return m.Starrole()
  2354. case contact.FieldDontseeit:
  2355. return m.Dontseeit()
  2356. case contact.FieldDontseeme:
  2357. return m.Dontseeme()
  2358. case contact.FieldLag:
  2359. return m.Lag()
  2360. case contact.FieldGid:
  2361. return m.Gid()
  2362. case contact.FieldGname:
  2363. return m.Gname()
  2364. case contact.FieldV3:
  2365. return m.V3()
  2366. }
  2367. return nil, false
  2368. }
  2369. // OldField returns the old value of the field from the database. An error is
  2370. // returned if the mutation operation is not UpdateOne, or the query to the
  2371. // database failed.
  2372. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2373. switch name {
  2374. case contact.FieldCreatedAt:
  2375. return m.OldCreatedAt(ctx)
  2376. case contact.FieldUpdatedAt:
  2377. return m.OldUpdatedAt(ctx)
  2378. case contact.FieldStatus:
  2379. return m.OldStatus(ctx)
  2380. case contact.FieldDeletedAt:
  2381. return m.OldDeletedAt(ctx)
  2382. case contact.FieldWxWxid:
  2383. return m.OldWxWxid(ctx)
  2384. case contact.FieldType:
  2385. return m.OldType(ctx)
  2386. case contact.FieldWxid:
  2387. return m.OldWxid(ctx)
  2388. case contact.FieldAccount:
  2389. return m.OldAccount(ctx)
  2390. case contact.FieldNickname:
  2391. return m.OldNickname(ctx)
  2392. case contact.FieldMarkname:
  2393. return m.OldMarkname(ctx)
  2394. case contact.FieldHeadimg:
  2395. return m.OldHeadimg(ctx)
  2396. case contact.FieldSex:
  2397. return m.OldSex(ctx)
  2398. case contact.FieldStarrole:
  2399. return m.OldStarrole(ctx)
  2400. case contact.FieldDontseeit:
  2401. return m.OldDontseeit(ctx)
  2402. case contact.FieldDontseeme:
  2403. return m.OldDontseeme(ctx)
  2404. case contact.FieldLag:
  2405. return m.OldLag(ctx)
  2406. case contact.FieldGid:
  2407. return m.OldGid(ctx)
  2408. case contact.FieldGname:
  2409. return m.OldGname(ctx)
  2410. case contact.FieldV3:
  2411. return m.OldV3(ctx)
  2412. }
  2413. return nil, fmt.Errorf("unknown Contact field %s", name)
  2414. }
  2415. // SetField sets the value of a field with the given name. It returns an error if
  2416. // the field is not defined in the schema, or if the type mismatched the field
  2417. // type.
  2418. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  2419. switch name {
  2420. case contact.FieldCreatedAt:
  2421. v, ok := value.(time.Time)
  2422. if !ok {
  2423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2424. }
  2425. m.SetCreatedAt(v)
  2426. return nil
  2427. case contact.FieldUpdatedAt:
  2428. v, ok := value.(time.Time)
  2429. if !ok {
  2430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2431. }
  2432. m.SetUpdatedAt(v)
  2433. return nil
  2434. case contact.FieldStatus:
  2435. v, ok := value.(uint8)
  2436. if !ok {
  2437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2438. }
  2439. m.SetStatus(v)
  2440. return nil
  2441. case contact.FieldDeletedAt:
  2442. v, ok := value.(time.Time)
  2443. if !ok {
  2444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2445. }
  2446. m.SetDeletedAt(v)
  2447. return nil
  2448. case contact.FieldWxWxid:
  2449. v, ok := value.(string)
  2450. if !ok {
  2451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2452. }
  2453. m.SetWxWxid(v)
  2454. return nil
  2455. case contact.FieldType:
  2456. v, ok := value.(int)
  2457. if !ok {
  2458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2459. }
  2460. m.SetType(v)
  2461. return nil
  2462. case contact.FieldWxid:
  2463. v, ok := value.(string)
  2464. if !ok {
  2465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2466. }
  2467. m.SetWxid(v)
  2468. return nil
  2469. case contact.FieldAccount:
  2470. v, ok := value.(string)
  2471. if !ok {
  2472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2473. }
  2474. m.SetAccount(v)
  2475. return nil
  2476. case contact.FieldNickname:
  2477. v, ok := value.(string)
  2478. if !ok {
  2479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2480. }
  2481. m.SetNickname(v)
  2482. return nil
  2483. case contact.FieldMarkname:
  2484. v, ok := value.(string)
  2485. if !ok {
  2486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2487. }
  2488. m.SetMarkname(v)
  2489. return nil
  2490. case contact.FieldHeadimg:
  2491. v, ok := value.(string)
  2492. if !ok {
  2493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2494. }
  2495. m.SetHeadimg(v)
  2496. return nil
  2497. case contact.FieldSex:
  2498. v, ok := value.(int)
  2499. if !ok {
  2500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2501. }
  2502. m.SetSex(v)
  2503. return nil
  2504. case contact.FieldStarrole:
  2505. v, ok := value.(string)
  2506. if !ok {
  2507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2508. }
  2509. m.SetStarrole(v)
  2510. return nil
  2511. case contact.FieldDontseeit:
  2512. v, ok := value.(int)
  2513. if !ok {
  2514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2515. }
  2516. m.SetDontseeit(v)
  2517. return nil
  2518. case contact.FieldDontseeme:
  2519. v, ok := value.(int)
  2520. if !ok {
  2521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2522. }
  2523. m.SetDontseeme(v)
  2524. return nil
  2525. case contact.FieldLag:
  2526. v, ok := value.(string)
  2527. if !ok {
  2528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2529. }
  2530. m.SetLag(v)
  2531. return nil
  2532. case contact.FieldGid:
  2533. v, ok := value.(string)
  2534. if !ok {
  2535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2536. }
  2537. m.SetGid(v)
  2538. return nil
  2539. case contact.FieldGname:
  2540. v, ok := value.(string)
  2541. if !ok {
  2542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2543. }
  2544. m.SetGname(v)
  2545. return nil
  2546. case contact.FieldV3:
  2547. v, ok := value.(string)
  2548. if !ok {
  2549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2550. }
  2551. m.SetV3(v)
  2552. return nil
  2553. }
  2554. return fmt.Errorf("unknown Contact field %s", name)
  2555. }
  2556. // AddedFields returns all numeric fields that were incremented/decremented during
  2557. // this mutation.
  2558. func (m *ContactMutation) AddedFields() []string {
  2559. var fields []string
  2560. if m.addstatus != nil {
  2561. fields = append(fields, contact.FieldStatus)
  2562. }
  2563. if m.add_type != nil {
  2564. fields = append(fields, contact.FieldType)
  2565. }
  2566. if m.addsex != nil {
  2567. fields = append(fields, contact.FieldSex)
  2568. }
  2569. if m.adddontseeit != nil {
  2570. fields = append(fields, contact.FieldDontseeit)
  2571. }
  2572. if m.adddontseeme != nil {
  2573. fields = append(fields, contact.FieldDontseeme)
  2574. }
  2575. return fields
  2576. }
  2577. // AddedField returns the numeric value that was incremented/decremented on a field
  2578. // with the given name. The second boolean return value indicates that this field
  2579. // was not set, or was not defined in the schema.
  2580. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  2581. switch name {
  2582. case contact.FieldStatus:
  2583. return m.AddedStatus()
  2584. case contact.FieldType:
  2585. return m.AddedType()
  2586. case contact.FieldSex:
  2587. return m.AddedSex()
  2588. case contact.FieldDontseeit:
  2589. return m.AddedDontseeit()
  2590. case contact.FieldDontseeme:
  2591. return m.AddedDontseeme()
  2592. }
  2593. return nil, false
  2594. }
  2595. // AddField adds the value to the field with the given name. It returns an error if
  2596. // the field is not defined in the schema, or if the type mismatched the field
  2597. // type.
  2598. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  2599. switch name {
  2600. case contact.FieldStatus:
  2601. v, ok := value.(int8)
  2602. if !ok {
  2603. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2604. }
  2605. m.AddStatus(v)
  2606. return nil
  2607. case contact.FieldType:
  2608. v, ok := value.(int)
  2609. if !ok {
  2610. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2611. }
  2612. m.AddType(v)
  2613. return nil
  2614. case contact.FieldSex:
  2615. v, ok := value.(int)
  2616. if !ok {
  2617. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2618. }
  2619. m.AddSex(v)
  2620. return nil
  2621. case contact.FieldDontseeit:
  2622. v, ok := value.(int)
  2623. if !ok {
  2624. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2625. }
  2626. m.AddDontseeit(v)
  2627. return nil
  2628. case contact.FieldDontseeme:
  2629. v, ok := value.(int)
  2630. if !ok {
  2631. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2632. }
  2633. m.AddDontseeme(v)
  2634. return nil
  2635. }
  2636. return fmt.Errorf("unknown Contact numeric field %s", name)
  2637. }
  2638. // ClearedFields returns all nullable fields that were cleared during this
  2639. // mutation.
  2640. func (m *ContactMutation) ClearedFields() []string {
  2641. var fields []string
  2642. if m.FieldCleared(contact.FieldStatus) {
  2643. fields = append(fields, contact.FieldStatus)
  2644. }
  2645. if m.FieldCleared(contact.FieldDeletedAt) {
  2646. fields = append(fields, contact.FieldDeletedAt)
  2647. }
  2648. if m.FieldCleared(contact.FieldWxWxid) {
  2649. fields = append(fields, contact.FieldWxWxid)
  2650. }
  2651. if m.FieldCleared(contact.FieldType) {
  2652. fields = append(fields, contact.FieldType)
  2653. }
  2654. return fields
  2655. }
  2656. // FieldCleared returns a boolean indicating if a field with the given name was
  2657. // cleared in this mutation.
  2658. func (m *ContactMutation) FieldCleared(name string) bool {
  2659. _, ok := m.clearedFields[name]
  2660. return ok
  2661. }
  2662. // ClearField clears the value of the field with the given name. It returns an
  2663. // error if the field is not defined in the schema.
  2664. func (m *ContactMutation) ClearField(name string) error {
  2665. switch name {
  2666. case contact.FieldStatus:
  2667. m.ClearStatus()
  2668. return nil
  2669. case contact.FieldDeletedAt:
  2670. m.ClearDeletedAt()
  2671. return nil
  2672. case contact.FieldWxWxid:
  2673. m.ClearWxWxid()
  2674. return nil
  2675. case contact.FieldType:
  2676. m.ClearType()
  2677. return nil
  2678. }
  2679. return fmt.Errorf("unknown Contact nullable field %s", name)
  2680. }
  2681. // ResetField resets all changes in the mutation for the field with the given name.
  2682. // It returns an error if the field is not defined in the schema.
  2683. func (m *ContactMutation) ResetField(name string) error {
  2684. switch name {
  2685. case contact.FieldCreatedAt:
  2686. m.ResetCreatedAt()
  2687. return nil
  2688. case contact.FieldUpdatedAt:
  2689. m.ResetUpdatedAt()
  2690. return nil
  2691. case contact.FieldStatus:
  2692. m.ResetStatus()
  2693. return nil
  2694. case contact.FieldDeletedAt:
  2695. m.ResetDeletedAt()
  2696. return nil
  2697. case contact.FieldWxWxid:
  2698. m.ResetWxWxid()
  2699. return nil
  2700. case contact.FieldType:
  2701. m.ResetType()
  2702. return nil
  2703. case contact.FieldWxid:
  2704. m.ResetWxid()
  2705. return nil
  2706. case contact.FieldAccount:
  2707. m.ResetAccount()
  2708. return nil
  2709. case contact.FieldNickname:
  2710. m.ResetNickname()
  2711. return nil
  2712. case contact.FieldMarkname:
  2713. m.ResetMarkname()
  2714. return nil
  2715. case contact.FieldHeadimg:
  2716. m.ResetHeadimg()
  2717. return nil
  2718. case contact.FieldSex:
  2719. m.ResetSex()
  2720. return nil
  2721. case contact.FieldStarrole:
  2722. m.ResetStarrole()
  2723. return nil
  2724. case contact.FieldDontseeit:
  2725. m.ResetDontseeit()
  2726. return nil
  2727. case contact.FieldDontseeme:
  2728. m.ResetDontseeme()
  2729. return nil
  2730. case contact.FieldLag:
  2731. m.ResetLag()
  2732. return nil
  2733. case contact.FieldGid:
  2734. m.ResetGid()
  2735. return nil
  2736. case contact.FieldGname:
  2737. m.ResetGname()
  2738. return nil
  2739. case contact.FieldV3:
  2740. m.ResetV3()
  2741. return nil
  2742. }
  2743. return fmt.Errorf("unknown Contact field %s", name)
  2744. }
  2745. // AddedEdges returns all edge names that were set/added in this mutation.
  2746. func (m *ContactMutation) AddedEdges() []string {
  2747. edges := make([]string, 0, 2)
  2748. if m.contact_relationships != nil {
  2749. edges = append(edges, contact.EdgeContactRelationships)
  2750. }
  2751. if m.contact_messages != nil {
  2752. edges = append(edges, contact.EdgeContactMessages)
  2753. }
  2754. return edges
  2755. }
  2756. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2757. // name in this mutation.
  2758. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  2759. switch name {
  2760. case contact.EdgeContactRelationships:
  2761. ids := make([]ent.Value, 0, len(m.contact_relationships))
  2762. for id := range m.contact_relationships {
  2763. ids = append(ids, id)
  2764. }
  2765. return ids
  2766. case contact.EdgeContactMessages:
  2767. ids := make([]ent.Value, 0, len(m.contact_messages))
  2768. for id := range m.contact_messages {
  2769. ids = append(ids, id)
  2770. }
  2771. return ids
  2772. }
  2773. return nil
  2774. }
  2775. // RemovedEdges returns all edge names that were removed in this mutation.
  2776. func (m *ContactMutation) RemovedEdges() []string {
  2777. edges := make([]string, 0, 2)
  2778. if m.removedcontact_relationships != nil {
  2779. edges = append(edges, contact.EdgeContactRelationships)
  2780. }
  2781. if m.removedcontact_messages != nil {
  2782. edges = append(edges, contact.EdgeContactMessages)
  2783. }
  2784. return edges
  2785. }
  2786. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2787. // the given name in this mutation.
  2788. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  2789. switch name {
  2790. case contact.EdgeContactRelationships:
  2791. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  2792. for id := range m.removedcontact_relationships {
  2793. ids = append(ids, id)
  2794. }
  2795. return ids
  2796. case contact.EdgeContactMessages:
  2797. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  2798. for id := range m.removedcontact_messages {
  2799. ids = append(ids, id)
  2800. }
  2801. return ids
  2802. }
  2803. return nil
  2804. }
  2805. // ClearedEdges returns all edge names that were cleared in this mutation.
  2806. func (m *ContactMutation) ClearedEdges() []string {
  2807. edges := make([]string, 0, 2)
  2808. if m.clearedcontact_relationships {
  2809. edges = append(edges, contact.EdgeContactRelationships)
  2810. }
  2811. if m.clearedcontact_messages {
  2812. edges = append(edges, contact.EdgeContactMessages)
  2813. }
  2814. return edges
  2815. }
  2816. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2817. // was cleared in this mutation.
  2818. func (m *ContactMutation) EdgeCleared(name string) bool {
  2819. switch name {
  2820. case contact.EdgeContactRelationships:
  2821. return m.clearedcontact_relationships
  2822. case contact.EdgeContactMessages:
  2823. return m.clearedcontact_messages
  2824. }
  2825. return false
  2826. }
  2827. // ClearEdge clears the value of the edge with the given name. It returns an error
  2828. // if that edge is not defined in the schema.
  2829. func (m *ContactMutation) ClearEdge(name string) error {
  2830. switch name {
  2831. }
  2832. return fmt.Errorf("unknown Contact unique edge %s", name)
  2833. }
  2834. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2835. // It returns an error if the edge is not defined in the schema.
  2836. func (m *ContactMutation) ResetEdge(name string) error {
  2837. switch name {
  2838. case contact.EdgeContactRelationships:
  2839. m.ResetContactRelationships()
  2840. return nil
  2841. case contact.EdgeContactMessages:
  2842. m.ResetContactMessages()
  2843. return nil
  2844. }
  2845. return fmt.Errorf("unknown Contact edge %s", name)
  2846. }
  2847. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  2848. type LabelMutation struct {
  2849. config
  2850. op Op
  2851. typ string
  2852. id *uint64
  2853. created_at *time.Time
  2854. updated_at *time.Time
  2855. status *uint8
  2856. addstatus *int8
  2857. deleted_at *time.Time
  2858. _type *int
  2859. add_type *int
  2860. name *string
  2861. from *int
  2862. addfrom *int
  2863. mode *int
  2864. addmode *int
  2865. conditions *string
  2866. clearedFields map[string]struct{}
  2867. label_relationships map[uint64]struct{}
  2868. removedlabel_relationships map[uint64]struct{}
  2869. clearedlabel_relationships bool
  2870. done bool
  2871. oldValue func(context.Context) (*Label, error)
  2872. predicates []predicate.Label
  2873. }
  2874. var _ ent.Mutation = (*LabelMutation)(nil)
  2875. // labelOption allows management of the mutation configuration using functional options.
  2876. type labelOption func(*LabelMutation)
  2877. // newLabelMutation creates new mutation for the Label entity.
  2878. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  2879. m := &LabelMutation{
  2880. config: c,
  2881. op: op,
  2882. typ: TypeLabel,
  2883. clearedFields: make(map[string]struct{}),
  2884. }
  2885. for _, opt := range opts {
  2886. opt(m)
  2887. }
  2888. return m
  2889. }
  2890. // withLabelID sets the ID field of the mutation.
  2891. func withLabelID(id uint64) labelOption {
  2892. return func(m *LabelMutation) {
  2893. var (
  2894. err error
  2895. once sync.Once
  2896. value *Label
  2897. )
  2898. m.oldValue = func(ctx context.Context) (*Label, error) {
  2899. once.Do(func() {
  2900. if m.done {
  2901. err = errors.New("querying old values post mutation is not allowed")
  2902. } else {
  2903. value, err = m.Client().Label.Get(ctx, id)
  2904. }
  2905. })
  2906. return value, err
  2907. }
  2908. m.id = &id
  2909. }
  2910. }
  2911. // withLabel sets the old Label of the mutation.
  2912. func withLabel(node *Label) labelOption {
  2913. return func(m *LabelMutation) {
  2914. m.oldValue = func(context.Context) (*Label, error) {
  2915. return node, nil
  2916. }
  2917. m.id = &node.ID
  2918. }
  2919. }
  2920. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2921. // executed in a transaction (ent.Tx), a transactional client is returned.
  2922. func (m LabelMutation) Client() *Client {
  2923. client := &Client{config: m.config}
  2924. client.init()
  2925. return client
  2926. }
  2927. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2928. // it returns an error otherwise.
  2929. func (m LabelMutation) Tx() (*Tx, error) {
  2930. if _, ok := m.driver.(*txDriver); !ok {
  2931. return nil, errors.New("ent: mutation is not running in a transaction")
  2932. }
  2933. tx := &Tx{config: m.config}
  2934. tx.init()
  2935. return tx, nil
  2936. }
  2937. // SetID sets the value of the id field. Note that this
  2938. // operation is only accepted on creation of Label entities.
  2939. func (m *LabelMutation) SetID(id uint64) {
  2940. m.id = &id
  2941. }
  2942. // ID returns the ID value in the mutation. Note that the ID is only available
  2943. // if it was provided to the builder or after it was returned from the database.
  2944. func (m *LabelMutation) ID() (id uint64, exists bool) {
  2945. if m.id == nil {
  2946. return
  2947. }
  2948. return *m.id, true
  2949. }
  2950. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2951. // That means, if the mutation is applied within a transaction with an isolation level such
  2952. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2953. // or updated by the mutation.
  2954. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  2955. switch {
  2956. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2957. id, exists := m.ID()
  2958. if exists {
  2959. return []uint64{id}, nil
  2960. }
  2961. fallthrough
  2962. case m.op.Is(OpUpdate | OpDelete):
  2963. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  2964. default:
  2965. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2966. }
  2967. }
  2968. // SetCreatedAt sets the "created_at" field.
  2969. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  2970. m.created_at = &t
  2971. }
  2972. // CreatedAt returns the value of the "created_at" field in the mutation.
  2973. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  2974. v := m.created_at
  2975. if v == nil {
  2976. return
  2977. }
  2978. return *v, true
  2979. }
  2980. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  2981. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  2982. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2983. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2984. if !m.op.Is(OpUpdateOne) {
  2985. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2986. }
  2987. if m.id == nil || m.oldValue == nil {
  2988. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2989. }
  2990. oldValue, err := m.oldValue(ctx)
  2991. if err != nil {
  2992. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2993. }
  2994. return oldValue.CreatedAt, nil
  2995. }
  2996. // ResetCreatedAt resets all changes to the "created_at" field.
  2997. func (m *LabelMutation) ResetCreatedAt() {
  2998. m.created_at = nil
  2999. }
  3000. // SetUpdatedAt sets the "updated_at" field.
  3001. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  3002. m.updated_at = &t
  3003. }
  3004. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3005. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  3006. v := m.updated_at
  3007. if v == nil {
  3008. return
  3009. }
  3010. return *v, true
  3011. }
  3012. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  3013. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  3014. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3015. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3016. if !m.op.Is(OpUpdateOne) {
  3017. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3018. }
  3019. if m.id == nil || m.oldValue == nil {
  3020. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3021. }
  3022. oldValue, err := m.oldValue(ctx)
  3023. if err != nil {
  3024. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3025. }
  3026. return oldValue.UpdatedAt, nil
  3027. }
  3028. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3029. func (m *LabelMutation) ResetUpdatedAt() {
  3030. m.updated_at = nil
  3031. }
  3032. // SetStatus sets the "status" field.
  3033. func (m *LabelMutation) SetStatus(u uint8) {
  3034. m.status = &u
  3035. m.addstatus = nil
  3036. }
  3037. // Status returns the value of the "status" field in the mutation.
  3038. func (m *LabelMutation) Status() (r uint8, exists bool) {
  3039. v := m.status
  3040. if v == nil {
  3041. return
  3042. }
  3043. return *v, true
  3044. }
  3045. // OldStatus returns the old "status" field's value of the Label entity.
  3046. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  3047. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3048. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  3049. if !m.op.Is(OpUpdateOne) {
  3050. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3051. }
  3052. if m.id == nil || m.oldValue == nil {
  3053. return v, errors.New("OldStatus requires an ID field in the mutation")
  3054. }
  3055. oldValue, err := m.oldValue(ctx)
  3056. if err != nil {
  3057. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3058. }
  3059. return oldValue.Status, nil
  3060. }
  3061. // AddStatus adds u to the "status" field.
  3062. func (m *LabelMutation) AddStatus(u int8) {
  3063. if m.addstatus != nil {
  3064. *m.addstatus += u
  3065. } else {
  3066. m.addstatus = &u
  3067. }
  3068. }
  3069. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3070. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  3071. v := m.addstatus
  3072. if v == nil {
  3073. return
  3074. }
  3075. return *v, true
  3076. }
  3077. // ClearStatus clears the value of the "status" field.
  3078. func (m *LabelMutation) ClearStatus() {
  3079. m.status = nil
  3080. m.addstatus = nil
  3081. m.clearedFields[label.FieldStatus] = struct{}{}
  3082. }
  3083. // StatusCleared returns if the "status" field was cleared in this mutation.
  3084. func (m *LabelMutation) StatusCleared() bool {
  3085. _, ok := m.clearedFields[label.FieldStatus]
  3086. return ok
  3087. }
  3088. // ResetStatus resets all changes to the "status" field.
  3089. func (m *LabelMutation) ResetStatus() {
  3090. m.status = nil
  3091. m.addstatus = nil
  3092. delete(m.clearedFields, label.FieldStatus)
  3093. }
  3094. // SetDeletedAt sets the "deleted_at" field.
  3095. func (m *LabelMutation) SetDeletedAt(t time.Time) {
  3096. m.deleted_at = &t
  3097. }
  3098. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3099. func (m *LabelMutation) DeletedAt() (r time.Time, exists bool) {
  3100. v := m.deleted_at
  3101. if v == nil {
  3102. return
  3103. }
  3104. return *v, true
  3105. }
  3106. // OldDeletedAt returns the old "deleted_at" field's value of the Label entity.
  3107. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  3108. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3109. func (m *LabelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3110. if !m.op.Is(OpUpdateOne) {
  3111. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3112. }
  3113. if m.id == nil || m.oldValue == nil {
  3114. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3115. }
  3116. oldValue, err := m.oldValue(ctx)
  3117. if err != nil {
  3118. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3119. }
  3120. return oldValue.DeletedAt, nil
  3121. }
  3122. // ClearDeletedAt clears the value of the "deleted_at" field.
  3123. func (m *LabelMutation) ClearDeletedAt() {
  3124. m.deleted_at = nil
  3125. m.clearedFields[label.FieldDeletedAt] = struct{}{}
  3126. }
  3127. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3128. func (m *LabelMutation) DeletedAtCleared() bool {
  3129. _, ok := m.clearedFields[label.FieldDeletedAt]
  3130. return ok
  3131. }
  3132. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3133. func (m *LabelMutation) ResetDeletedAt() {
  3134. m.deleted_at = nil
  3135. delete(m.clearedFields, label.FieldDeletedAt)
  3136. }
  3137. // SetType sets the "type" field.
  3138. func (m *LabelMutation) SetType(i int) {
  3139. m._type = &i
  3140. m.add_type = nil
  3141. }
  3142. // GetType returns the value of the "type" field in the mutation.
  3143. func (m *LabelMutation) GetType() (r int, exists bool) {
  3144. v := m._type
  3145. if v == nil {
  3146. return
  3147. }
  3148. return *v, true
  3149. }
  3150. // OldType returns the old "type" field's value of the Label entity.
  3151. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  3152. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3153. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  3154. if !m.op.Is(OpUpdateOne) {
  3155. return v, errors.New("OldType is only allowed on UpdateOne operations")
  3156. }
  3157. if m.id == nil || m.oldValue == nil {
  3158. return v, errors.New("OldType requires an ID field in the mutation")
  3159. }
  3160. oldValue, err := m.oldValue(ctx)
  3161. if err != nil {
  3162. return v, fmt.Errorf("querying old value for OldType: %w", err)
  3163. }
  3164. return oldValue.Type, nil
  3165. }
  3166. // AddType adds i to the "type" field.
  3167. func (m *LabelMutation) AddType(i int) {
  3168. if m.add_type != nil {
  3169. *m.add_type += i
  3170. } else {
  3171. m.add_type = &i
  3172. }
  3173. }
  3174. // AddedType returns the value that was added to the "type" field in this mutation.
  3175. func (m *LabelMutation) AddedType() (r int, exists bool) {
  3176. v := m.add_type
  3177. if v == nil {
  3178. return
  3179. }
  3180. return *v, true
  3181. }
  3182. // ResetType resets all changes to the "type" field.
  3183. func (m *LabelMutation) ResetType() {
  3184. m._type = nil
  3185. m.add_type = nil
  3186. }
  3187. // SetName sets the "name" field.
  3188. func (m *LabelMutation) SetName(s string) {
  3189. m.name = &s
  3190. }
  3191. // Name returns the value of the "name" field in the mutation.
  3192. func (m *LabelMutation) Name() (r string, exists bool) {
  3193. v := m.name
  3194. if v == nil {
  3195. return
  3196. }
  3197. return *v, true
  3198. }
  3199. // OldName returns the old "name" field's value of the Label entity.
  3200. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  3201. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3202. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  3203. if !m.op.Is(OpUpdateOne) {
  3204. return v, errors.New("OldName is only allowed on UpdateOne operations")
  3205. }
  3206. if m.id == nil || m.oldValue == nil {
  3207. return v, errors.New("OldName requires an ID field in the mutation")
  3208. }
  3209. oldValue, err := m.oldValue(ctx)
  3210. if err != nil {
  3211. return v, fmt.Errorf("querying old value for OldName: %w", err)
  3212. }
  3213. return oldValue.Name, nil
  3214. }
  3215. // ResetName resets all changes to the "name" field.
  3216. func (m *LabelMutation) ResetName() {
  3217. m.name = nil
  3218. }
  3219. // SetFrom sets the "from" field.
  3220. func (m *LabelMutation) SetFrom(i int) {
  3221. m.from = &i
  3222. m.addfrom = nil
  3223. }
  3224. // From returns the value of the "from" field in the mutation.
  3225. func (m *LabelMutation) From() (r int, exists bool) {
  3226. v := m.from
  3227. if v == nil {
  3228. return
  3229. }
  3230. return *v, true
  3231. }
  3232. // OldFrom returns the old "from" field's value of the Label entity.
  3233. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  3234. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3235. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  3236. if !m.op.Is(OpUpdateOne) {
  3237. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  3238. }
  3239. if m.id == nil || m.oldValue == nil {
  3240. return v, errors.New("OldFrom requires an ID field in the mutation")
  3241. }
  3242. oldValue, err := m.oldValue(ctx)
  3243. if err != nil {
  3244. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  3245. }
  3246. return oldValue.From, nil
  3247. }
  3248. // AddFrom adds i to the "from" field.
  3249. func (m *LabelMutation) AddFrom(i int) {
  3250. if m.addfrom != nil {
  3251. *m.addfrom += i
  3252. } else {
  3253. m.addfrom = &i
  3254. }
  3255. }
  3256. // AddedFrom returns the value that was added to the "from" field in this mutation.
  3257. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  3258. v := m.addfrom
  3259. if v == nil {
  3260. return
  3261. }
  3262. return *v, true
  3263. }
  3264. // ResetFrom resets all changes to the "from" field.
  3265. func (m *LabelMutation) ResetFrom() {
  3266. m.from = nil
  3267. m.addfrom = nil
  3268. }
  3269. // SetMode sets the "mode" field.
  3270. func (m *LabelMutation) SetMode(i int) {
  3271. m.mode = &i
  3272. m.addmode = nil
  3273. }
  3274. // Mode returns the value of the "mode" field in the mutation.
  3275. func (m *LabelMutation) Mode() (r int, exists bool) {
  3276. v := m.mode
  3277. if v == nil {
  3278. return
  3279. }
  3280. return *v, true
  3281. }
  3282. // OldMode returns the old "mode" field's value of the Label entity.
  3283. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  3284. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3285. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  3286. if !m.op.Is(OpUpdateOne) {
  3287. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  3288. }
  3289. if m.id == nil || m.oldValue == nil {
  3290. return v, errors.New("OldMode requires an ID field in the mutation")
  3291. }
  3292. oldValue, err := m.oldValue(ctx)
  3293. if err != nil {
  3294. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  3295. }
  3296. return oldValue.Mode, nil
  3297. }
  3298. // AddMode adds i to the "mode" field.
  3299. func (m *LabelMutation) AddMode(i int) {
  3300. if m.addmode != nil {
  3301. *m.addmode += i
  3302. } else {
  3303. m.addmode = &i
  3304. }
  3305. }
  3306. // AddedMode returns the value that was added to the "mode" field in this mutation.
  3307. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  3308. v := m.addmode
  3309. if v == nil {
  3310. return
  3311. }
  3312. return *v, true
  3313. }
  3314. // ResetMode resets all changes to the "mode" field.
  3315. func (m *LabelMutation) ResetMode() {
  3316. m.mode = nil
  3317. m.addmode = nil
  3318. }
  3319. // SetConditions sets the "conditions" field.
  3320. func (m *LabelMutation) SetConditions(s string) {
  3321. m.conditions = &s
  3322. }
  3323. // Conditions returns the value of the "conditions" field in the mutation.
  3324. func (m *LabelMutation) Conditions() (r string, exists bool) {
  3325. v := m.conditions
  3326. if v == nil {
  3327. return
  3328. }
  3329. return *v, true
  3330. }
  3331. // OldConditions returns the old "conditions" field's value of the Label entity.
  3332. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  3333. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3334. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  3335. if !m.op.Is(OpUpdateOne) {
  3336. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  3337. }
  3338. if m.id == nil || m.oldValue == nil {
  3339. return v, errors.New("OldConditions requires an ID field in the mutation")
  3340. }
  3341. oldValue, err := m.oldValue(ctx)
  3342. if err != nil {
  3343. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  3344. }
  3345. return oldValue.Conditions, nil
  3346. }
  3347. // ClearConditions clears the value of the "conditions" field.
  3348. func (m *LabelMutation) ClearConditions() {
  3349. m.conditions = nil
  3350. m.clearedFields[label.FieldConditions] = struct{}{}
  3351. }
  3352. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  3353. func (m *LabelMutation) ConditionsCleared() bool {
  3354. _, ok := m.clearedFields[label.FieldConditions]
  3355. return ok
  3356. }
  3357. // ResetConditions resets all changes to the "conditions" field.
  3358. func (m *LabelMutation) ResetConditions() {
  3359. m.conditions = nil
  3360. delete(m.clearedFields, label.FieldConditions)
  3361. }
  3362. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  3363. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  3364. if m.label_relationships == nil {
  3365. m.label_relationships = make(map[uint64]struct{})
  3366. }
  3367. for i := range ids {
  3368. m.label_relationships[ids[i]] = struct{}{}
  3369. }
  3370. }
  3371. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  3372. func (m *LabelMutation) ClearLabelRelationships() {
  3373. m.clearedlabel_relationships = true
  3374. }
  3375. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  3376. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  3377. return m.clearedlabel_relationships
  3378. }
  3379. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  3380. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  3381. if m.removedlabel_relationships == nil {
  3382. m.removedlabel_relationships = make(map[uint64]struct{})
  3383. }
  3384. for i := range ids {
  3385. delete(m.label_relationships, ids[i])
  3386. m.removedlabel_relationships[ids[i]] = struct{}{}
  3387. }
  3388. }
  3389. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  3390. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  3391. for id := range m.removedlabel_relationships {
  3392. ids = append(ids, id)
  3393. }
  3394. return
  3395. }
  3396. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  3397. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  3398. for id := range m.label_relationships {
  3399. ids = append(ids, id)
  3400. }
  3401. return
  3402. }
  3403. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  3404. func (m *LabelMutation) ResetLabelRelationships() {
  3405. m.label_relationships = nil
  3406. m.clearedlabel_relationships = false
  3407. m.removedlabel_relationships = nil
  3408. }
  3409. // Where appends a list predicates to the LabelMutation builder.
  3410. func (m *LabelMutation) Where(ps ...predicate.Label) {
  3411. m.predicates = append(m.predicates, ps...)
  3412. }
  3413. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  3414. // users can use type-assertion to append predicates that do not depend on any generated package.
  3415. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  3416. p := make([]predicate.Label, len(ps))
  3417. for i := range ps {
  3418. p[i] = ps[i]
  3419. }
  3420. m.Where(p...)
  3421. }
  3422. // Op returns the operation name.
  3423. func (m *LabelMutation) Op() Op {
  3424. return m.op
  3425. }
  3426. // SetOp allows setting the mutation operation.
  3427. func (m *LabelMutation) SetOp(op Op) {
  3428. m.op = op
  3429. }
  3430. // Type returns the node type of this mutation (Label).
  3431. func (m *LabelMutation) Type() string {
  3432. return m.typ
  3433. }
  3434. // Fields returns all fields that were changed during this mutation. Note that in
  3435. // order to get all numeric fields that were incremented/decremented, call
  3436. // AddedFields().
  3437. func (m *LabelMutation) Fields() []string {
  3438. fields := make([]string, 0, 9)
  3439. if m.created_at != nil {
  3440. fields = append(fields, label.FieldCreatedAt)
  3441. }
  3442. if m.updated_at != nil {
  3443. fields = append(fields, label.FieldUpdatedAt)
  3444. }
  3445. if m.status != nil {
  3446. fields = append(fields, label.FieldStatus)
  3447. }
  3448. if m.deleted_at != nil {
  3449. fields = append(fields, label.FieldDeletedAt)
  3450. }
  3451. if m._type != nil {
  3452. fields = append(fields, label.FieldType)
  3453. }
  3454. if m.name != nil {
  3455. fields = append(fields, label.FieldName)
  3456. }
  3457. if m.from != nil {
  3458. fields = append(fields, label.FieldFrom)
  3459. }
  3460. if m.mode != nil {
  3461. fields = append(fields, label.FieldMode)
  3462. }
  3463. if m.conditions != nil {
  3464. fields = append(fields, label.FieldConditions)
  3465. }
  3466. return fields
  3467. }
  3468. // Field returns the value of a field with the given name. The second boolean
  3469. // return value indicates that this field was not set, or was not defined in the
  3470. // schema.
  3471. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  3472. switch name {
  3473. case label.FieldCreatedAt:
  3474. return m.CreatedAt()
  3475. case label.FieldUpdatedAt:
  3476. return m.UpdatedAt()
  3477. case label.FieldStatus:
  3478. return m.Status()
  3479. case label.FieldDeletedAt:
  3480. return m.DeletedAt()
  3481. case label.FieldType:
  3482. return m.GetType()
  3483. case label.FieldName:
  3484. return m.Name()
  3485. case label.FieldFrom:
  3486. return m.From()
  3487. case label.FieldMode:
  3488. return m.Mode()
  3489. case label.FieldConditions:
  3490. return m.Conditions()
  3491. }
  3492. return nil, false
  3493. }
  3494. // OldField returns the old value of the field from the database. An error is
  3495. // returned if the mutation operation is not UpdateOne, or the query to the
  3496. // database failed.
  3497. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3498. switch name {
  3499. case label.FieldCreatedAt:
  3500. return m.OldCreatedAt(ctx)
  3501. case label.FieldUpdatedAt:
  3502. return m.OldUpdatedAt(ctx)
  3503. case label.FieldStatus:
  3504. return m.OldStatus(ctx)
  3505. case label.FieldDeletedAt:
  3506. return m.OldDeletedAt(ctx)
  3507. case label.FieldType:
  3508. return m.OldType(ctx)
  3509. case label.FieldName:
  3510. return m.OldName(ctx)
  3511. case label.FieldFrom:
  3512. return m.OldFrom(ctx)
  3513. case label.FieldMode:
  3514. return m.OldMode(ctx)
  3515. case label.FieldConditions:
  3516. return m.OldConditions(ctx)
  3517. }
  3518. return nil, fmt.Errorf("unknown Label field %s", name)
  3519. }
  3520. // SetField sets the value of a field with the given name. It returns an error if
  3521. // the field is not defined in the schema, or if the type mismatched the field
  3522. // type.
  3523. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  3524. switch name {
  3525. case label.FieldCreatedAt:
  3526. v, ok := value.(time.Time)
  3527. if !ok {
  3528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3529. }
  3530. m.SetCreatedAt(v)
  3531. return nil
  3532. case label.FieldUpdatedAt:
  3533. v, ok := value.(time.Time)
  3534. if !ok {
  3535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3536. }
  3537. m.SetUpdatedAt(v)
  3538. return nil
  3539. case label.FieldStatus:
  3540. v, ok := value.(uint8)
  3541. if !ok {
  3542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3543. }
  3544. m.SetStatus(v)
  3545. return nil
  3546. case label.FieldDeletedAt:
  3547. v, ok := value.(time.Time)
  3548. if !ok {
  3549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3550. }
  3551. m.SetDeletedAt(v)
  3552. return nil
  3553. case label.FieldType:
  3554. v, ok := value.(int)
  3555. if !ok {
  3556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3557. }
  3558. m.SetType(v)
  3559. return nil
  3560. case label.FieldName:
  3561. v, ok := value.(string)
  3562. if !ok {
  3563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3564. }
  3565. m.SetName(v)
  3566. return nil
  3567. case label.FieldFrom:
  3568. v, ok := value.(int)
  3569. if !ok {
  3570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3571. }
  3572. m.SetFrom(v)
  3573. return nil
  3574. case label.FieldMode:
  3575. v, ok := value.(int)
  3576. if !ok {
  3577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3578. }
  3579. m.SetMode(v)
  3580. return nil
  3581. case label.FieldConditions:
  3582. v, ok := value.(string)
  3583. if !ok {
  3584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3585. }
  3586. m.SetConditions(v)
  3587. return nil
  3588. }
  3589. return fmt.Errorf("unknown Label field %s", name)
  3590. }
  3591. // AddedFields returns all numeric fields that were incremented/decremented during
  3592. // this mutation.
  3593. func (m *LabelMutation) AddedFields() []string {
  3594. var fields []string
  3595. if m.addstatus != nil {
  3596. fields = append(fields, label.FieldStatus)
  3597. }
  3598. if m.add_type != nil {
  3599. fields = append(fields, label.FieldType)
  3600. }
  3601. if m.addfrom != nil {
  3602. fields = append(fields, label.FieldFrom)
  3603. }
  3604. if m.addmode != nil {
  3605. fields = append(fields, label.FieldMode)
  3606. }
  3607. return fields
  3608. }
  3609. // AddedField returns the numeric value that was incremented/decremented on a field
  3610. // with the given name. The second boolean return value indicates that this field
  3611. // was not set, or was not defined in the schema.
  3612. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  3613. switch name {
  3614. case label.FieldStatus:
  3615. return m.AddedStatus()
  3616. case label.FieldType:
  3617. return m.AddedType()
  3618. case label.FieldFrom:
  3619. return m.AddedFrom()
  3620. case label.FieldMode:
  3621. return m.AddedMode()
  3622. }
  3623. return nil, false
  3624. }
  3625. // AddField adds the value to the field with the given name. It returns an error if
  3626. // the field is not defined in the schema, or if the type mismatched the field
  3627. // type.
  3628. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  3629. switch name {
  3630. case label.FieldStatus:
  3631. v, ok := value.(int8)
  3632. if !ok {
  3633. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3634. }
  3635. m.AddStatus(v)
  3636. return nil
  3637. case label.FieldType:
  3638. v, ok := value.(int)
  3639. if !ok {
  3640. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3641. }
  3642. m.AddType(v)
  3643. return nil
  3644. case label.FieldFrom:
  3645. v, ok := value.(int)
  3646. if !ok {
  3647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3648. }
  3649. m.AddFrom(v)
  3650. return nil
  3651. case label.FieldMode:
  3652. v, ok := value.(int)
  3653. if !ok {
  3654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3655. }
  3656. m.AddMode(v)
  3657. return nil
  3658. }
  3659. return fmt.Errorf("unknown Label numeric field %s", name)
  3660. }
  3661. // ClearedFields returns all nullable fields that were cleared during this
  3662. // mutation.
  3663. func (m *LabelMutation) ClearedFields() []string {
  3664. var fields []string
  3665. if m.FieldCleared(label.FieldStatus) {
  3666. fields = append(fields, label.FieldStatus)
  3667. }
  3668. if m.FieldCleared(label.FieldDeletedAt) {
  3669. fields = append(fields, label.FieldDeletedAt)
  3670. }
  3671. if m.FieldCleared(label.FieldConditions) {
  3672. fields = append(fields, label.FieldConditions)
  3673. }
  3674. return fields
  3675. }
  3676. // FieldCleared returns a boolean indicating if a field with the given name was
  3677. // cleared in this mutation.
  3678. func (m *LabelMutation) FieldCleared(name string) bool {
  3679. _, ok := m.clearedFields[name]
  3680. return ok
  3681. }
  3682. // ClearField clears the value of the field with the given name. It returns an
  3683. // error if the field is not defined in the schema.
  3684. func (m *LabelMutation) ClearField(name string) error {
  3685. switch name {
  3686. case label.FieldStatus:
  3687. m.ClearStatus()
  3688. return nil
  3689. case label.FieldDeletedAt:
  3690. m.ClearDeletedAt()
  3691. return nil
  3692. case label.FieldConditions:
  3693. m.ClearConditions()
  3694. return nil
  3695. }
  3696. return fmt.Errorf("unknown Label nullable field %s", name)
  3697. }
  3698. // ResetField resets all changes in the mutation for the field with the given name.
  3699. // It returns an error if the field is not defined in the schema.
  3700. func (m *LabelMutation) ResetField(name string) error {
  3701. switch name {
  3702. case label.FieldCreatedAt:
  3703. m.ResetCreatedAt()
  3704. return nil
  3705. case label.FieldUpdatedAt:
  3706. m.ResetUpdatedAt()
  3707. return nil
  3708. case label.FieldStatus:
  3709. m.ResetStatus()
  3710. return nil
  3711. case label.FieldDeletedAt:
  3712. m.ResetDeletedAt()
  3713. return nil
  3714. case label.FieldType:
  3715. m.ResetType()
  3716. return nil
  3717. case label.FieldName:
  3718. m.ResetName()
  3719. return nil
  3720. case label.FieldFrom:
  3721. m.ResetFrom()
  3722. return nil
  3723. case label.FieldMode:
  3724. m.ResetMode()
  3725. return nil
  3726. case label.FieldConditions:
  3727. m.ResetConditions()
  3728. return nil
  3729. }
  3730. return fmt.Errorf("unknown Label field %s", name)
  3731. }
  3732. // AddedEdges returns all edge names that were set/added in this mutation.
  3733. func (m *LabelMutation) AddedEdges() []string {
  3734. edges := make([]string, 0, 1)
  3735. if m.label_relationships != nil {
  3736. edges = append(edges, label.EdgeLabelRelationships)
  3737. }
  3738. return edges
  3739. }
  3740. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3741. // name in this mutation.
  3742. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  3743. switch name {
  3744. case label.EdgeLabelRelationships:
  3745. ids := make([]ent.Value, 0, len(m.label_relationships))
  3746. for id := range m.label_relationships {
  3747. ids = append(ids, id)
  3748. }
  3749. return ids
  3750. }
  3751. return nil
  3752. }
  3753. // RemovedEdges returns all edge names that were removed in this mutation.
  3754. func (m *LabelMutation) RemovedEdges() []string {
  3755. edges := make([]string, 0, 1)
  3756. if m.removedlabel_relationships != nil {
  3757. edges = append(edges, label.EdgeLabelRelationships)
  3758. }
  3759. return edges
  3760. }
  3761. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3762. // the given name in this mutation.
  3763. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  3764. switch name {
  3765. case label.EdgeLabelRelationships:
  3766. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  3767. for id := range m.removedlabel_relationships {
  3768. ids = append(ids, id)
  3769. }
  3770. return ids
  3771. }
  3772. return nil
  3773. }
  3774. // ClearedEdges returns all edge names that were cleared in this mutation.
  3775. func (m *LabelMutation) ClearedEdges() []string {
  3776. edges := make([]string, 0, 1)
  3777. if m.clearedlabel_relationships {
  3778. edges = append(edges, label.EdgeLabelRelationships)
  3779. }
  3780. return edges
  3781. }
  3782. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3783. // was cleared in this mutation.
  3784. func (m *LabelMutation) EdgeCleared(name string) bool {
  3785. switch name {
  3786. case label.EdgeLabelRelationships:
  3787. return m.clearedlabel_relationships
  3788. }
  3789. return false
  3790. }
  3791. // ClearEdge clears the value of the edge with the given name. It returns an error
  3792. // if that edge is not defined in the schema.
  3793. func (m *LabelMutation) ClearEdge(name string) error {
  3794. switch name {
  3795. }
  3796. return fmt.Errorf("unknown Label unique edge %s", name)
  3797. }
  3798. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3799. // It returns an error if the edge is not defined in the schema.
  3800. func (m *LabelMutation) ResetEdge(name string) error {
  3801. switch name {
  3802. case label.EdgeLabelRelationships:
  3803. m.ResetLabelRelationships()
  3804. return nil
  3805. }
  3806. return fmt.Errorf("unknown Label edge %s", name)
  3807. }
  3808. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  3809. type LabelRelationshipMutation struct {
  3810. config
  3811. op Op
  3812. typ string
  3813. id *uint64
  3814. created_at *time.Time
  3815. updated_at *time.Time
  3816. status *uint8
  3817. addstatus *int8
  3818. deleted_at *time.Time
  3819. clearedFields map[string]struct{}
  3820. contacts *uint64
  3821. clearedcontacts bool
  3822. labels *uint64
  3823. clearedlabels bool
  3824. done bool
  3825. oldValue func(context.Context) (*LabelRelationship, error)
  3826. predicates []predicate.LabelRelationship
  3827. }
  3828. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  3829. // labelrelationshipOption allows management of the mutation configuration using functional options.
  3830. type labelrelationshipOption func(*LabelRelationshipMutation)
  3831. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  3832. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  3833. m := &LabelRelationshipMutation{
  3834. config: c,
  3835. op: op,
  3836. typ: TypeLabelRelationship,
  3837. clearedFields: make(map[string]struct{}),
  3838. }
  3839. for _, opt := range opts {
  3840. opt(m)
  3841. }
  3842. return m
  3843. }
  3844. // withLabelRelationshipID sets the ID field of the mutation.
  3845. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  3846. return func(m *LabelRelationshipMutation) {
  3847. var (
  3848. err error
  3849. once sync.Once
  3850. value *LabelRelationship
  3851. )
  3852. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  3853. once.Do(func() {
  3854. if m.done {
  3855. err = errors.New("querying old values post mutation is not allowed")
  3856. } else {
  3857. value, err = m.Client().LabelRelationship.Get(ctx, id)
  3858. }
  3859. })
  3860. return value, err
  3861. }
  3862. m.id = &id
  3863. }
  3864. }
  3865. // withLabelRelationship sets the old LabelRelationship of the mutation.
  3866. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  3867. return func(m *LabelRelationshipMutation) {
  3868. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  3869. return node, nil
  3870. }
  3871. m.id = &node.ID
  3872. }
  3873. }
  3874. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3875. // executed in a transaction (ent.Tx), a transactional client is returned.
  3876. func (m LabelRelationshipMutation) Client() *Client {
  3877. client := &Client{config: m.config}
  3878. client.init()
  3879. return client
  3880. }
  3881. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3882. // it returns an error otherwise.
  3883. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  3884. if _, ok := m.driver.(*txDriver); !ok {
  3885. return nil, errors.New("ent: mutation is not running in a transaction")
  3886. }
  3887. tx := &Tx{config: m.config}
  3888. tx.init()
  3889. return tx, nil
  3890. }
  3891. // SetID sets the value of the id field. Note that this
  3892. // operation is only accepted on creation of LabelRelationship entities.
  3893. func (m *LabelRelationshipMutation) SetID(id uint64) {
  3894. m.id = &id
  3895. }
  3896. // ID returns the ID value in the mutation. Note that the ID is only available
  3897. // if it was provided to the builder or after it was returned from the database.
  3898. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  3899. if m.id == nil {
  3900. return
  3901. }
  3902. return *m.id, true
  3903. }
  3904. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3905. // That means, if the mutation is applied within a transaction with an isolation level such
  3906. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3907. // or updated by the mutation.
  3908. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  3909. switch {
  3910. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3911. id, exists := m.ID()
  3912. if exists {
  3913. return []uint64{id}, nil
  3914. }
  3915. fallthrough
  3916. case m.op.Is(OpUpdate | OpDelete):
  3917. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  3918. default:
  3919. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3920. }
  3921. }
  3922. // SetCreatedAt sets the "created_at" field.
  3923. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  3924. m.created_at = &t
  3925. }
  3926. // CreatedAt returns the value of the "created_at" field in the mutation.
  3927. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  3928. v := m.created_at
  3929. if v == nil {
  3930. return
  3931. }
  3932. return *v, true
  3933. }
  3934. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  3935. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  3936. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3937. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3938. if !m.op.Is(OpUpdateOne) {
  3939. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3940. }
  3941. if m.id == nil || m.oldValue == nil {
  3942. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3943. }
  3944. oldValue, err := m.oldValue(ctx)
  3945. if err != nil {
  3946. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3947. }
  3948. return oldValue.CreatedAt, nil
  3949. }
  3950. // ResetCreatedAt resets all changes to the "created_at" field.
  3951. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  3952. m.created_at = nil
  3953. }
  3954. // SetUpdatedAt sets the "updated_at" field.
  3955. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  3956. m.updated_at = &t
  3957. }
  3958. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3959. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  3960. v := m.updated_at
  3961. if v == nil {
  3962. return
  3963. }
  3964. return *v, true
  3965. }
  3966. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  3967. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  3968. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3969. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3970. if !m.op.Is(OpUpdateOne) {
  3971. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3972. }
  3973. if m.id == nil || m.oldValue == nil {
  3974. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3975. }
  3976. oldValue, err := m.oldValue(ctx)
  3977. if err != nil {
  3978. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3979. }
  3980. return oldValue.UpdatedAt, nil
  3981. }
  3982. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3983. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  3984. m.updated_at = nil
  3985. }
  3986. // SetStatus sets the "status" field.
  3987. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  3988. m.status = &u
  3989. m.addstatus = nil
  3990. }
  3991. // Status returns the value of the "status" field in the mutation.
  3992. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  3993. v := m.status
  3994. if v == nil {
  3995. return
  3996. }
  3997. return *v, true
  3998. }
  3999. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  4000. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  4001. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4002. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  4003. if !m.op.Is(OpUpdateOne) {
  4004. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  4005. }
  4006. if m.id == nil || m.oldValue == nil {
  4007. return v, errors.New("OldStatus requires an ID field in the mutation")
  4008. }
  4009. oldValue, err := m.oldValue(ctx)
  4010. if err != nil {
  4011. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  4012. }
  4013. return oldValue.Status, nil
  4014. }
  4015. // AddStatus adds u to the "status" field.
  4016. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  4017. if m.addstatus != nil {
  4018. *m.addstatus += u
  4019. } else {
  4020. m.addstatus = &u
  4021. }
  4022. }
  4023. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4024. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  4025. v := m.addstatus
  4026. if v == nil {
  4027. return
  4028. }
  4029. return *v, true
  4030. }
  4031. // ClearStatus clears the value of the "status" field.
  4032. func (m *LabelRelationshipMutation) ClearStatus() {
  4033. m.status = nil
  4034. m.addstatus = nil
  4035. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  4036. }
  4037. // StatusCleared returns if the "status" field was cleared in this mutation.
  4038. func (m *LabelRelationshipMutation) StatusCleared() bool {
  4039. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  4040. return ok
  4041. }
  4042. // ResetStatus resets all changes to the "status" field.
  4043. func (m *LabelRelationshipMutation) ResetStatus() {
  4044. m.status = nil
  4045. m.addstatus = nil
  4046. delete(m.clearedFields, labelrelationship.FieldStatus)
  4047. }
  4048. // SetDeletedAt sets the "deleted_at" field.
  4049. func (m *LabelRelationshipMutation) SetDeletedAt(t time.Time) {
  4050. m.deleted_at = &t
  4051. }
  4052. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4053. func (m *LabelRelationshipMutation) DeletedAt() (r time.Time, exists bool) {
  4054. v := m.deleted_at
  4055. if v == nil {
  4056. return
  4057. }
  4058. return *v, true
  4059. }
  4060. // OldDeletedAt returns the old "deleted_at" field's value of the LabelRelationship entity.
  4061. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  4062. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4063. func (m *LabelRelationshipMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4064. if !m.op.Is(OpUpdateOne) {
  4065. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4066. }
  4067. if m.id == nil || m.oldValue == nil {
  4068. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4069. }
  4070. oldValue, err := m.oldValue(ctx)
  4071. if err != nil {
  4072. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4073. }
  4074. return oldValue.DeletedAt, nil
  4075. }
  4076. // ClearDeletedAt clears the value of the "deleted_at" field.
  4077. func (m *LabelRelationshipMutation) ClearDeletedAt() {
  4078. m.deleted_at = nil
  4079. m.clearedFields[labelrelationship.FieldDeletedAt] = struct{}{}
  4080. }
  4081. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4082. func (m *LabelRelationshipMutation) DeletedAtCleared() bool {
  4083. _, ok := m.clearedFields[labelrelationship.FieldDeletedAt]
  4084. return ok
  4085. }
  4086. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4087. func (m *LabelRelationshipMutation) ResetDeletedAt() {
  4088. m.deleted_at = nil
  4089. delete(m.clearedFields, labelrelationship.FieldDeletedAt)
  4090. }
  4091. // SetLabelID sets the "label_id" field.
  4092. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  4093. m.labels = &u
  4094. }
  4095. // LabelID returns the value of the "label_id" field in the mutation.
  4096. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  4097. v := m.labels
  4098. if v == nil {
  4099. return
  4100. }
  4101. return *v, true
  4102. }
  4103. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  4104. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  4105. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4106. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  4107. if !m.op.Is(OpUpdateOne) {
  4108. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  4109. }
  4110. if m.id == nil || m.oldValue == nil {
  4111. return v, errors.New("OldLabelID requires an ID field in the mutation")
  4112. }
  4113. oldValue, err := m.oldValue(ctx)
  4114. if err != nil {
  4115. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  4116. }
  4117. return oldValue.LabelID, nil
  4118. }
  4119. // ResetLabelID resets all changes to the "label_id" field.
  4120. func (m *LabelRelationshipMutation) ResetLabelID() {
  4121. m.labels = nil
  4122. }
  4123. // SetContactID sets the "contact_id" field.
  4124. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  4125. m.contacts = &u
  4126. }
  4127. // ContactID returns the value of the "contact_id" field in the mutation.
  4128. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  4129. v := m.contacts
  4130. if v == nil {
  4131. return
  4132. }
  4133. return *v, true
  4134. }
  4135. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  4136. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  4137. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4138. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  4139. if !m.op.Is(OpUpdateOne) {
  4140. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  4141. }
  4142. if m.id == nil || m.oldValue == nil {
  4143. return v, errors.New("OldContactID requires an ID field in the mutation")
  4144. }
  4145. oldValue, err := m.oldValue(ctx)
  4146. if err != nil {
  4147. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  4148. }
  4149. return oldValue.ContactID, nil
  4150. }
  4151. // ResetContactID resets all changes to the "contact_id" field.
  4152. func (m *LabelRelationshipMutation) ResetContactID() {
  4153. m.contacts = nil
  4154. }
  4155. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  4156. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  4157. m.contacts = &id
  4158. }
  4159. // ClearContacts clears the "contacts" edge to the Contact entity.
  4160. func (m *LabelRelationshipMutation) ClearContacts() {
  4161. m.clearedcontacts = true
  4162. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  4163. }
  4164. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  4165. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  4166. return m.clearedcontacts
  4167. }
  4168. // ContactsID returns the "contacts" edge ID in the mutation.
  4169. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  4170. if m.contacts != nil {
  4171. return *m.contacts, true
  4172. }
  4173. return
  4174. }
  4175. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  4176. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  4177. // ContactsID instead. It exists only for internal usage by the builders.
  4178. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  4179. if id := m.contacts; id != nil {
  4180. ids = append(ids, *id)
  4181. }
  4182. return
  4183. }
  4184. // ResetContacts resets all changes to the "contacts" edge.
  4185. func (m *LabelRelationshipMutation) ResetContacts() {
  4186. m.contacts = nil
  4187. m.clearedcontacts = false
  4188. }
  4189. // SetLabelsID sets the "labels" edge to the Label entity by id.
  4190. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  4191. m.labels = &id
  4192. }
  4193. // ClearLabels clears the "labels" edge to the Label entity.
  4194. func (m *LabelRelationshipMutation) ClearLabels() {
  4195. m.clearedlabels = true
  4196. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  4197. }
  4198. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  4199. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  4200. return m.clearedlabels
  4201. }
  4202. // LabelsID returns the "labels" edge ID in the mutation.
  4203. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  4204. if m.labels != nil {
  4205. return *m.labels, true
  4206. }
  4207. return
  4208. }
  4209. // LabelsIDs returns the "labels" edge IDs in the mutation.
  4210. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  4211. // LabelsID instead. It exists only for internal usage by the builders.
  4212. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  4213. if id := m.labels; id != nil {
  4214. ids = append(ids, *id)
  4215. }
  4216. return
  4217. }
  4218. // ResetLabels resets all changes to the "labels" edge.
  4219. func (m *LabelRelationshipMutation) ResetLabels() {
  4220. m.labels = nil
  4221. m.clearedlabels = false
  4222. }
  4223. // Where appends a list predicates to the LabelRelationshipMutation builder.
  4224. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  4225. m.predicates = append(m.predicates, ps...)
  4226. }
  4227. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  4228. // users can use type-assertion to append predicates that do not depend on any generated package.
  4229. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  4230. p := make([]predicate.LabelRelationship, len(ps))
  4231. for i := range ps {
  4232. p[i] = ps[i]
  4233. }
  4234. m.Where(p...)
  4235. }
  4236. // Op returns the operation name.
  4237. func (m *LabelRelationshipMutation) Op() Op {
  4238. return m.op
  4239. }
  4240. // SetOp allows setting the mutation operation.
  4241. func (m *LabelRelationshipMutation) SetOp(op Op) {
  4242. m.op = op
  4243. }
  4244. // Type returns the node type of this mutation (LabelRelationship).
  4245. func (m *LabelRelationshipMutation) Type() string {
  4246. return m.typ
  4247. }
  4248. // Fields returns all fields that were changed during this mutation. Note that in
  4249. // order to get all numeric fields that were incremented/decremented, call
  4250. // AddedFields().
  4251. func (m *LabelRelationshipMutation) Fields() []string {
  4252. fields := make([]string, 0, 6)
  4253. if m.created_at != nil {
  4254. fields = append(fields, labelrelationship.FieldCreatedAt)
  4255. }
  4256. if m.updated_at != nil {
  4257. fields = append(fields, labelrelationship.FieldUpdatedAt)
  4258. }
  4259. if m.status != nil {
  4260. fields = append(fields, labelrelationship.FieldStatus)
  4261. }
  4262. if m.deleted_at != nil {
  4263. fields = append(fields, labelrelationship.FieldDeletedAt)
  4264. }
  4265. if m.labels != nil {
  4266. fields = append(fields, labelrelationship.FieldLabelID)
  4267. }
  4268. if m.contacts != nil {
  4269. fields = append(fields, labelrelationship.FieldContactID)
  4270. }
  4271. return fields
  4272. }
  4273. // Field returns the value of a field with the given name. The second boolean
  4274. // return value indicates that this field was not set, or was not defined in the
  4275. // schema.
  4276. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  4277. switch name {
  4278. case labelrelationship.FieldCreatedAt:
  4279. return m.CreatedAt()
  4280. case labelrelationship.FieldUpdatedAt:
  4281. return m.UpdatedAt()
  4282. case labelrelationship.FieldStatus:
  4283. return m.Status()
  4284. case labelrelationship.FieldDeletedAt:
  4285. return m.DeletedAt()
  4286. case labelrelationship.FieldLabelID:
  4287. return m.LabelID()
  4288. case labelrelationship.FieldContactID:
  4289. return m.ContactID()
  4290. }
  4291. return nil, false
  4292. }
  4293. // OldField returns the old value of the field from the database. An error is
  4294. // returned if the mutation operation is not UpdateOne, or the query to the
  4295. // database failed.
  4296. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4297. switch name {
  4298. case labelrelationship.FieldCreatedAt:
  4299. return m.OldCreatedAt(ctx)
  4300. case labelrelationship.FieldUpdatedAt:
  4301. return m.OldUpdatedAt(ctx)
  4302. case labelrelationship.FieldStatus:
  4303. return m.OldStatus(ctx)
  4304. case labelrelationship.FieldDeletedAt:
  4305. return m.OldDeletedAt(ctx)
  4306. case labelrelationship.FieldLabelID:
  4307. return m.OldLabelID(ctx)
  4308. case labelrelationship.FieldContactID:
  4309. return m.OldContactID(ctx)
  4310. }
  4311. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  4312. }
  4313. // SetField sets the value of a field with the given name. It returns an error if
  4314. // the field is not defined in the schema, or if the type mismatched the field
  4315. // type.
  4316. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  4317. switch name {
  4318. case labelrelationship.FieldCreatedAt:
  4319. v, ok := value.(time.Time)
  4320. if !ok {
  4321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4322. }
  4323. m.SetCreatedAt(v)
  4324. return nil
  4325. case labelrelationship.FieldUpdatedAt:
  4326. v, ok := value.(time.Time)
  4327. if !ok {
  4328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4329. }
  4330. m.SetUpdatedAt(v)
  4331. return nil
  4332. case labelrelationship.FieldStatus:
  4333. v, ok := value.(uint8)
  4334. if !ok {
  4335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4336. }
  4337. m.SetStatus(v)
  4338. return nil
  4339. case labelrelationship.FieldDeletedAt:
  4340. v, ok := value.(time.Time)
  4341. if !ok {
  4342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4343. }
  4344. m.SetDeletedAt(v)
  4345. return nil
  4346. case labelrelationship.FieldLabelID:
  4347. v, ok := value.(uint64)
  4348. if !ok {
  4349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4350. }
  4351. m.SetLabelID(v)
  4352. return nil
  4353. case labelrelationship.FieldContactID:
  4354. v, ok := value.(uint64)
  4355. if !ok {
  4356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4357. }
  4358. m.SetContactID(v)
  4359. return nil
  4360. }
  4361. return fmt.Errorf("unknown LabelRelationship field %s", name)
  4362. }
  4363. // AddedFields returns all numeric fields that were incremented/decremented during
  4364. // this mutation.
  4365. func (m *LabelRelationshipMutation) AddedFields() []string {
  4366. var fields []string
  4367. if m.addstatus != nil {
  4368. fields = append(fields, labelrelationship.FieldStatus)
  4369. }
  4370. return fields
  4371. }
  4372. // AddedField returns the numeric value that was incremented/decremented on a field
  4373. // with the given name. The second boolean return value indicates that this field
  4374. // was not set, or was not defined in the schema.
  4375. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  4376. switch name {
  4377. case labelrelationship.FieldStatus:
  4378. return m.AddedStatus()
  4379. }
  4380. return nil, false
  4381. }
  4382. // AddField adds the value to the field with the given name. It returns an error if
  4383. // the field is not defined in the schema, or if the type mismatched the field
  4384. // type.
  4385. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  4386. switch name {
  4387. case labelrelationship.FieldStatus:
  4388. v, ok := value.(int8)
  4389. if !ok {
  4390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4391. }
  4392. m.AddStatus(v)
  4393. return nil
  4394. }
  4395. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  4396. }
  4397. // ClearedFields returns all nullable fields that were cleared during this
  4398. // mutation.
  4399. func (m *LabelRelationshipMutation) ClearedFields() []string {
  4400. var fields []string
  4401. if m.FieldCleared(labelrelationship.FieldStatus) {
  4402. fields = append(fields, labelrelationship.FieldStatus)
  4403. }
  4404. if m.FieldCleared(labelrelationship.FieldDeletedAt) {
  4405. fields = append(fields, labelrelationship.FieldDeletedAt)
  4406. }
  4407. return fields
  4408. }
  4409. // FieldCleared returns a boolean indicating if a field with the given name was
  4410. // cleared in this mutation.
  4411. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  4412. _, ok := m.clearedFields[name]
  4413. return ok
  4414. }
  4415. // ClearField clears the value of the field with the given name. It returns an
  4416. // error if the field is not defined in the schema.
  4417. func (m *LabelRelationshipMutation) ClearField(name string) error {
  4418. switch name {
  4419. case labelrelationship.FieldStatus:
  4420. m.ClearStatus()
  4421. return nil
  4422. case labelrelationship.FieldDeletedAt:
  4423. m.ClearDeletedAt()
  4424. return nil
  4425. }
  4426. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  4427. }
  4428. // ResetField resets all changes in the mutation for the field with the given name.
  4429. // It returns an error if the field is not defined in the schema.
  4430. func (m *LabelRelationshipMutation) ResetField(name string) error {
  4431. switch name {
  4432. case labelrelationship.FieldCreatedAt:
  4433. m.ResetCreatedAt()
  4434. return nil
  4435. case labelrelationship.FieldUpdatedAt:
  4436. m.ResetUpdatedAt()
  4437. return nil
  4438. case labelrelationship.FieldStatus:
  4439. m.ResetStatus()
  4440. return nil
  4441. case labelrelationship.FieldDeletedAt:
  4442. m.ResetDeletedAt()
  4443. return nil
  4444. case labelrelationship.FieldLabelID:
  4445. m.ResetLabelID()
  4446. return nil
  4447. case labelrelationship.FieldContactID:
  4448. m.ResetContactID()
  4449. return nil
  4450. }
  4451. return fmt.Errorf("unknown LabelRelationship field %s", name)
  4452. }
  4453. // AddedEdges returns all edge names that were set/added in this mutation.
  4454. func (m *LabelRelationshipMutation) AddedEdges() []string {
  4455. edges := make([]string, 0, 2)
  4456. if m.contacts != nil {
  4457. edges = append(edges, labelrelationship.EdgeContacts)
  4458. }
  4459. if m.labels != nil {
  4460. edges = append(edges, labelrelationship.EdgeLabels)
  4461. }
  4462. return edges
  4463. }
  4464. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4465. // name in this mutation.
  4466. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  4467. switch name {
  4468. case labelrelationship.EdgeContacts:
  4469. if id := m.contacts; id != nil {
  4470. return []ent.Value{*id}
  4471. }
  4472. case labelrelationship.EdgeLabels:
  4473. if id := m.labels; id != nil {
  4474. return []ent.Value{*id}
  4475. }
  4476. }
  4477. return nil
  4478. }
  4479. // RemovedEdges returns all edge names that were removed in this mutation.
  4480. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  4481. edges := make([]string, 0, 2)
  4482. return edges
  4483. }
  4484. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4485. // the given name in this mutation.
  4486. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  4487. return nil
  4488. }
  4489. // ClearedEdges returns all edge names that were cleared in this mutation.
  4490. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  4491. edges := make([]string, 0, 2)
  4492. if m.clearedcontacts {
  4493. edges = append(edges, labelrelationship.EdgeContacts)
  4494. }
  4495. if m.clearedlabels {
  4496. edges = append(edges, labelrelationship.EdgeLabels)
  4497. }
  4498. return edges
  4499. }
  4500. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4501. // was cleared in this mutation.
  4502. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  4503. switch name {
  4504. case labelrelationship.EdgeContacts:
  4505. return m.clearedcontacts
  4506. case labelrelationship.EdgeLabels:
  4507. return m.clearedlabels
  4508. }
  4509. return false
  4510. }
  4511. // ClearEdge clears the value of the edge with the given name. It returns an error
  4512. // if that edge is not defined in the schema.
  4513. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  4514. switch name {
  4515. case labelrelationship.EdgeContacts:
  4516. m.ClearContacts()
  4517. return nil
  4518. case labelrelationship.EdgeLabels:
  4519. m.ClearLabels()
  4520. return nil
  4521. }
  4522. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  4523. }
  4524. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4525. // It returns an error if the edge is not defined in the schema.
  4526. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  4527. switch name {
  4528. case labelrelationship.EdgeContacts:
  4529. m.ResetContacts()
  4530. return nil
  4531. case labelrelationship.EdgeLabels:
  4532. m.ResetLabels()
  4533. return nil
  4534. }
  4535. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  4536. }
  4537. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  4538. type MessageMutation struct {
  4539. config
  4540. op Op
  4541. typ string
  4542. id *int
  4543. wx_wxid *string
  4544. wxid *string
  4545. content *string
  4546. clearedFields map[string]struct{}
  4547. done bool
  4548. oldValue func(context.Context) (*Message, error)
  4549. predicates []predicate.Message
  4550. }
  4551. var _ ent.Mutation = (*MessageMutation)(nil)
  4552. // messageOption allows management of the mutation configuration using functional options.
  4553. type messageOption func(*MessageMutation)
  4554. // newMessageMutation creates new mutation for the Message entity.
  4555. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  4556. m := &MessageMutation{
  4557. config: c,
  4558. op: op,
  4559. typ: TypeMessage,
  4560. clearedFields: make(map[string]struct{}),
  4561. }
  4562. for _, opt := range opts {
  4563. opt(m)
  4564. }
  4565. return m
  4566. }
  4567. // withMessageID sets the ID field of the mutation.
  4568. func withMessageID(id int) messageOption {
  4569. return func(m *MessageMutation) {
  4570. var (
  4571. err error
  4572. once sync.Once
  4573. value *Message
  4574. )
  4575. m.oldValue = func(ctx context.Context) (*Message, error) {
  4576. once.Do(func() {
  4577. if m.done {
  4578. err = errors.New("querying old values post mutation is not allowed")
  4579. } else {
  4580. value, err = m.Client().Message.Get(ctx, id)
  4581. }
  4582. })
  4583. return value, err
  4584. }
  4585. m.id = &id
  4586. }
  4587. }
  4588. // withMessage sets the old Message of the mutation.
  4589. func withMessage(node *Message) messageOption {
  4590. return func(m *MessageMutation) {
  4591. m.oldValue = func(context.Context) (*Message, error) {
  4592. return node, nil
  4593. }
  4594. m.id = &node.ID
  4595. }
  4596. }
  4597. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4598. // executed in a transaction (ent.Tx), a transactional client is returned.
  4599. func (m MessageMutation) Client() *Client {
  4600. client := &Client{config: m.config}
  4601. client.init()
  4602. return client
  4603. }
  4604. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4605. // it returns an error otherwise.
  4606. func (m MessageMutation) Tx() (*Tx, error) {
  4607. if _, ok := m.driver.(*txDriver); !ok {
  4608. return nil, errors.New("ent: mutation is not running in a transaction")
  4609. }
  4610. tx := &Tx{config: m.config}
  4611. tx.init()
  4612. return tx, nil
  4613. }
  4614. // ID returns the ID value in the mutation. Note that the ID is only available
  4615. // if it was provided to the builder or after it was returned from the database.
  4616. func (m *MessageMutation) ID() (id int, exists bool) {
  4617. if m.id == nil {
  4618. return
  4619. }
  4620. return *m.id, true
  4621. }
  4622. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4623. // That means, if the mutation is applied within a transaction with an isolation level such
  4624. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4625. // or updated by the mutation.
  4626. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  4627. switch {
  4628. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4629. id, exists := m.ID()
  4630. if exists {
  4631. return []int{id}, nil
  4632. }
  4633. fallthrough
  4634. case m.op.Is(OpUpdate | OpDelete):
  4635. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  4636. default:
  4637. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4638. }
  4639. }
  4640. // SetWxWxid sets the "wx_wxid" field.
  4641. func (m *MessageMutation) SetWxWxid(s string) {
  4642. m.wx_wxid = &s
  4643. }
  4644. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  4645. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  4646. v := m.wx_wxid
  4647. if v == nil {
  4648. return
  4649. }
  4650. return *v, true
  4651. }
  4652. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  4653. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  4654. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4655. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  4656. if !m.op.Is(OpUpdateOne) {
  4657. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  4658. }
  4659. if m.id == nil || m.oldValue == nil {
  4660. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  4661. }
  4662. oldValue, err := m.oldValue(ctx)
  4663. if err != nil {
  4664. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  4665. }
  4666. return oldValue.WxWxid, nil
  4667. }
  4668. // ClearWxWxid clears the value of the "wx_wxid" field.
  4669. func (m *MessageMutation) ClearWxWxid() {
  4670. m.wx_wxid = nil
  4671. m.clearedFields[message.FieldWxWxid] = struct{}{}
  4672. }
  4673. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  4674. func (m *MessageMutation) WxWxidCleared() bool {
  4675. _, ok := m.clearedFields[message.FieldWxWxid]
  4676. return ok
  4677. }
  4678. // ResetWxWxid resets all changes to the "wx_wxid" field.
  4679. func (m *MessageMutation) ResetWxWxid() {
  4680. m.wx_wxid = nil
  4681. delete(m.clearedFields, message.FieldWxWxid)
  4682. }
  4683. // SetWxid sets the "wxid" field.
  4684. func (m *MessageMutation) SetWxid(s string) {
  4685. m.wxid = &s
  4686. }
  4687. // Wxid returns the value of the "wxid" field in the mutation.
  4688. func (m *MessageMutation) Wxid() (r string, exists bool) {
  4689. v := m.wxid
  4690. if v == nil {
  4691. return
  4692. }
  4693. return *v, true
  4694. }
  4695. // OldWxid returns the old "wxid" field's value of the Message entity.
  4696. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  4697. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4698. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  4699. if !m.op.Is(OpUpdateOne) {
  4700. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  4701. }
  4702. if m.id == nil || m.oldValue == nil {
  4703. return v, errors.New("OldWxid requires an ID field in the mutation")
  4704. }
  4705. oldValue, err := m.oldValue(ctx)
  4706. if err != nil {
  4707. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  4708. }
  4709. return oldValue.Wxid, nil
  4710. }
  4711. // ResetWxid resets all changes to the "wxid" field.
  4712. func (m *MessageMutation) ResetWxid() {
  4713. m.wxid = nil
  4714. }
  4715. // SetContent sets the "content" field.
  4716. func (m *MessageMutation) SetContent(s string) {
  4717. m.content = &s
  4718. }
  4719. // Content returns the value of the "content" field in the mutation.
  4720. func (m *MessageMutation) Content() (r string, exists bool) {
  4721. v := m.content
  4722. if v == nil {
  4723. return
  4724. }
  4725. return *v, true
  4726. }
  4727. // OldContent returns the old "content" field's value of the Message entity.
  4728. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  4729. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4730. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  4731. if !m.op.Is(OpUpdateOne) {
  4732. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  4733. }
  4734. if m.id == nil || m.oldValue == nil {
  4735. return v, errors.New("OldContent requires an ID field in the mutation")
  4736. }
  4737. oldValue, err := m.oldValue(ctx)
  4738. if err != nil {
  4739. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  4740. }
  4741. return oldValue.Content, nil
  4742. }
  4743. // ResetContent resets all changes to the "content" field.
  4744. func (m *MessageMutation) ResetContent() {
  4745. m.content = nil
  4746. }
  4747. // Where appends a list predicates to the MessageMutation builder.
  4748. func (m *MessageMutation) Where(ps ...predicate.Message) {
  4749. m.predicates = append(m.predicates, ps...)
  4750. }
  4751. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  4752. // users can use type-assertion to append predicates that do not depend on any generated package.
  4753. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  4754. p := make([]predicate.Message, len(ps))
  4755. for i := range ps {
  4756. p[i] = ps[i]
  4757. }
  4758. m.Where(p...)
  4759. }
  4760. // Op returns the operation name.
  4761. func (m *MessageMutation) Op() Op {
  4762. return m.op
  4763. }
  4764. // SetOp allows setting the mutation operation.
  4765. func (m *MessageMutation) SetOp(op Op) {
  4766. m.op = op
  4767. }
  4768. // Type returns the node type of this mutation (Message).
  4769. func (m *MessageMutation) Type() string {
  4770. return m.typ
  4771. }
  4772. // Fields returns all fields that were changed during this mutation. Note that in
  4773. // order to get all numeric fields that were incremented/decremented, call
  4774. // AddedFields().
  4775. func (m *MessageMutation) Fields() []string {
  4776. fields := make([]string, 0, 3)
  4777. if m.wx_wxid != nil {
  4778. fields = append(fields, message.FieldWxWxid)
  4779. }
  4780. if m.wxid != nil {
  4781. fields = append(fields, message.FieldWxid)
  4782. }
  4783. if m.content != nil {
  4784. fields = append(fields, message.FieldContent)
  4785. }
  4786. return fields
  4787. }
  4788. // Field returns the value of a field with the given name. The second boolean
  4789. // return value indicates that this field was not set, or was not defined in the
  4790. // schema.
  4791. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  4792. switch name {
  4793. case message.FieldWxWxid:
  4794. return m.WxWxid()
  4795. case message.FieldWxid:
  4796. return m.Wxid()
  4797. case message.FieldContent:
  4798. return m.Content()
  4799. }
  4800. return nil, false
  4801. }
  4802. // OldField returns the old value of the field from the database. An error is
  4803. // returned if the mutation operation is not UpdateOne, or the query to the
  4804. // database failed.
  4805. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4806. switch name {
  4807. case message.FieldWxWxid:
  4808. return m.OldWxWxid(ctx)
  4809. case message.FieldWxid:
  4810. return m.OldWxid(ctx)
  4811. case message.FieldContent:
  4812. return m.OldContent(ctx)
  4813. }
  4814. return nil, fmt.Errorf("unknown Message field %s", name)
  4815. }
  4816. // SetField sets the value of a field with the given name. It returns an error if
  4817. // the field is not defined in the schema, or if the type mismatched the field
  4818. // type.
  4819. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  4820. switch name {
  4821. case message.FieldWxWxid:
  4822. v, ok := value.(string)
  4823. if !ok {
  4824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4825. }
  4826. m.SetWxWxid(v)
  4827. return nil
  4828. case message.FieldWxid:
  4829. v, ok := value.(string)
  4830. if !ok {
  4831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4832. }
  4833. m.SetWxid(v)
  4834. return nil
  4835. case message.FieldContent:
  4836. v, ok := value.(string)
  4837. if !ok {
  4838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4839. }
  4840. m.SetContent(v)
  4841. return nil
  4842. }
  4843. return fmt.Errorf("unknown Message field %s", name)
  4844. }
  4845. // AddedFields returns all numeric fields that were incremented/decremented during
  4846. // this mutation.
  4847. func (m *MessageMutation) AddedFields() []string {
  4848. return nil
  4849. }
  4850. // AddedField returns the numeric value that was incremented/decremented on a field
  4851. // with the given name. The second boolean return value indicates that this field
  4852. // was not set, or was not defined in the schema.
  4853. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  4854. return nil, false
  4855. }
  4856. // AddField adds the value to the field with the given name. It returns an error if
  4857. // the field is not defined in the schema, or if the type mismatched the field
  4858. // type.
  4859. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  4860. switch name {
  4861. }
  4862. return fmt.Errorf("unknown Message numeric field %s", name)
  4863. }
  4864. // ClearedFields returns all nullable fields that were cleared during this
  4865. // mutation.
  4866. func (m *MessageMutation) ClearedFields() []string {
  4867. var fields []string
  4868. if m.FieldCleared(message.FieldWxWxid) {
  4869. fields = append(fields, message.FieldWxWxid)
  4870. }
  4871. return fields
  4872. }
  4873. // FieldCleared returns a boolean indicating if a field with the given name was
  4874. // cleared in this mutation.
  4875. func (m *MessageMutation) FieldCleared(name string) bool {
  4876. _, ok := m.clearedFields[name]
  4877. return ok
  4878. }
  4879. // ClearField clears the value of the field with the given name. It returns an
  4880. // error if the field is not defined in the schema.
  4881. func (m *MessageMutation) ClearField(name string) error {
  4882. switch name {
  4883. case message.FieldWxWxid:
  4884. m.ClearWxWxid()
  4885. return nil
  4886. }
  4887. return fmt.Errorf("unknown Message nullable field %s", name)
  4888. }
  4889. // ResetField resets all changes in the mutation for the field with the given name.
  4890. // It returns an error if the field is not defined in the schema.
  4891. func (m *MessageMutation) ResetField(name string) error {
  4892. switch name {
  4893. case message.FieldWxWxid:
  4894. m.ResetWxWxid()
  4895. return nil
  4896. case message.FieldWxid:
  4897. m.ResetWxid()
  4898. return nil
  4899. case message.FieldContent:
  4900. m.ResetContent()
  4901. return nil
  4902. }
  4903. return fmt.Errorf("unknown Message field %s", name)
  4904. }
  4905. // AddedEdges returns all edge names that were set/added in this mutation.
  4906. func (m *MessageMutation) AddedEdges() []string {
  4907. edges := make([]string, 0, 0)
  4908. return edges
  4909. }
  4910. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4911. // name in this mutation.
  4912. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  4913. return nil
  4914. }
  4915. // RemovedEdges returns all edge names that were removed in this mutation.
  4916. func (m *MessageMutation) RemovedEdges() []string {
  4917. edges := make([]string, 0, 0)
  4918. return edges
  4919. }
  4920. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4921. // the given name in this mutation.
  4922. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  4923. return nil
  4924. }
  4925. // ClearedEdges returns all edge names that were cleared in this mutation.
  4926. func (m *MessageMutation) ClearedEdges() []string {
  4927. edges := make([]string, 0, 0)
  4928. return edges
  4929. }
  4930. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4931. // was cleared in this mutation.
  4932. func (m *MessageMutation) EdgeCleared(name string) bool {
  4933. return false
  4934. }
  4935. // ClearEdge clears the value of the edge with the given name. It returns an error
  4936. // if that edge is not defined in the schema.
  4937. func (m *MessageMutation) ClearEdge(name string) error {
  4938. return fmt.Errorf("unknown Message unique edge %s", name)
  4939. }
  4940. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4941. // It returns an error if the edge is not defined in the schema.
  4942. func (m *MessageMutation) ResetEdge(name string) error {
  4943. return fmt.Errorf("unknown Message edge %s", name)
  4944. }
  4945. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  4946. type MessageRecordsMutation struct {
  4947. config
  4948. op Op
  4949. typ string
  4950. id *uint64
  4951. created_at *time.Time
  4952. updated_at *time.Time
  4953. status *uint8
  4954. addstatus *int8
  4955. deleted_at *time.Time
  4956. bot_wxid *string
  4957. contact_type *int
  4958. addcontact_type *int
  4959. contact_wxid *string
  4960. content_type *int
  4961. addcontent_type *int
  4962. content *string
  4963. meta *custom_types.Meta
  4964. error_detail *string
  4965. send_time *time.Time
  4966. source_type *int
  4967. addsource_type *int
  4968. clearedFields map[string]struct{}
  4969. sop_stage *uint64
  4970. clearedsop_stage bool
  4971. sop_node *uint64
  4972. clearedsop_node bool
  4973. message_contact *uint64
  4974. clearedmessage_contact bool
  4975. done bool
  4976. oldValue func(context.Context) (*MessageRecords, error)
  4977. predicates []predicate.MessageRecords
  4978. }
  4979. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  4980. // messagerecordsOption allows management of the mutation configuration using functional options.
  4981. type messagerecordsOption func(*MessageRecordsMutation)
  4982. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  4983. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  4984. m := &MessageRecordsMutation{
  4985. config: c,
  4986. op: op,
  4987. typ: TypeMessageRecords,
  4988. clearedFields: make(map[string]struct{}),
  4989. }
  4990. for _, opt := range opts {
  4991. opt(m)
  4992. }
  4993. return m
  4994. }
  4995. // withMessageRecordsID sets the ID field of the mutation.
  4996. func withMessageRecordsID(id uint64) messagerecordsOption {
  4997. return func(m *MessageRecordsMutation) {
  4998. var (
  4999. err error
  5000. once sync.Once
  5001. value *MessageRecords
  5002. )
  5003. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  5004. once.Do(func() {
  5005. if m.done {
  5006. err = errors.New("querying old values post mutation is not allowed")
  5007. } else {
  5008. value, err = m.Client().MessageRecords.Get(ctx, id)
  5009. }
  5010. })
  5011. return value, err
  5012. }
  5013. m.id = &id
  5014. }
  5015. }
  5016. // withMessageRecords sets the old MessageRecords of the mutation.
  5017. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  5018. return func(m *MessageRecordsMutation) {
  5019. m.oldValue = func(context.Context) (*MessageRecords, error) {
  5020. return node, nil
  5021. }
  5022. m.id = &node.ID
  5023. }
  5024. }
  5025. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5026. // executed in a transaction (ent.Tx), a transactional client is returned.
  5027. func (m MessageRecordsMutation) Client() *Client {
  5028. client := &Client{config: m.config}
  5029. client.init()
  5030. return client
  5031. }
  5032. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5033. // it returns an error otherwise.
  5034. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  5035. if _, ok := m.driver.(*txDriver); !ok {
  5036. return nil, errors.New("ent: mutation is not running in a transaction")
  5037. }
  5038. tx := &Tx{config: m.config}
  5039. tx.init()
  5040. return tx, nil
  5041. }
  5042. // SetID sets the value of the id field. Note that this
  5043. // operation is only accepted on creation of MessageRecords entities.
  5044. func (m *MessageRecordsMutation) SetID(id uint64) {
  5045. m.id = &id
  5046. }
  5047. // ID returns the ID value in the mutation. Note that the ID is only available
  5048. // if it was provided to the builder or after it was returned from the database.
  5049. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  5050. if m.id == nil {
  5051. return
  5052. }
  5053. return *m.id, true
  5054. }
  5055. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5056. // That means, if the mutation is applied within a transaction with an isolation level such
  5057. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5058. // or updated by the mutation.
  5059. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  5060. switch {
  5061. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5062. id, exists := m.ID()
  5063. if exists {
  5064. return []uint64{id}, nil
  5065. }
  5066. fallthrough
  5067. case m.op.Is(OpUpdate | OpDelete):
  5068. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  5069. default:
  5070. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5071. }
  5072. }
  5073. // SetCreatedAt sets the "created_at" field.
  5074. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  5075. m.created_at = &t
  5076. }
  5077. // CreatedAt returns the value of the "created_at" field in the mutation.
  5078. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  5079. v := m.created_at
  5080. if v == nil {
  5081. return
  5082. }
  5083. return *v, true
  5084. }
  5085. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  5086. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5087. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5088. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5089. if !m.op.Is(OpUpdateOne) {
  5090. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5091. }
  5092. if m.id == nil || m.oldValue == nil {
  5093. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5094. }
  5095. oldValue, err := m.oldValue(ctx)
  5096. if err != nil {
  5097. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5098. }
  5099. return oldValue.CreatedAt, nil
  5100. }
  5101. // ResetCreatedAt resets all changes to the "created_at" field.
  5102. func (m *MessageRecordsMutation) ResetCreatedAt() {
  5103. m.created_at = nil
  5104. }
  5105. // SetUpdatedAt sets the "updated_at" field.
  5106. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  5107. m.updated_at = &t
  5108. }
  5109. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5110. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  5111. v := m.updated_at
  5112. if v == nil {
  5113. return
  5114. }
  5115. return *v, true
  5116. }
  5117. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  5118. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5119. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5120. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5121. if !m.op.Is(OpUpdateOne) {
  5122. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5123. }
  5124. if m.id == nil || m.oldValue == nil {
  5125. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5126. }
  5127. oldValue, err := m.oldValue(ctx)
  5128. if err != nil {
  5129. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5130. }
  5131. return oldValue.UpdatedAt, nil
  5132. }
  5133. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5134. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  5135. m.updated_at = nil
  5136. }
  5137. // SetStatus sets the "status" field.
  5138. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  5139. m.status = &u
  5140. m.addstatus = nil
  5141. }
  5142. // Status returns the value of the "status" field in the mutation.
  5143. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  5144. v := m.status
  5145. if v == nil {
  5146. return
  5147. }
  5148. return *v, true
  5149. }
  5150. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  5151. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5152. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5153. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  5154. if !m.op.Is(OpUpdateOne) {
  5155. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5156. }
  5157. if m.id == nil || m.oldValue == nil {
  5158. return v, errors.New("OldStatus requires an ID field in the mutation")
  5159. }
  5160. oldValue, err := m.oldValue(ctx)
  5161. if err != nil {
  5162. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5163. }
  5164. return oldValue.Status, nil
  5165. }
  5166. // AddStatus adds u to the "status" field.
  5167. func (m *MessageRecordsMutation) AddStatus(u int8) {
  5168. if m.addstatus != nil {
  5169. *m.addstatus += u
  5170. } else {
  5171. m.addstatus = &u
  5172. }
  5173. }
  5174. // AddedStatus returns the value that was added to the "status" field in this mutation.
  5175. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  5176. v := m.addstatus
  5177. if v == nil {
  5178. return
  5179. }
  5180. return *v, true
  5181. }
  5182. // ClearStatus clears the value of the "status" field.
  5183. func (m *MessageRecordsMutation) ClearStatus() {
  5184. m.status = nil
  5185. m.addstatus = nil
  5186. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  5187. }
  5188. // StatusCleared returns if the "status" field was cleared in this mutation.
  5189. func (m *MessageRecordsMutation) StatusCleared() bool {
  5190. _, ok := m.clearedFields[messagerecords.FieldStatus]
  5191. return ok
  5192. }
  5193. // ResetStatus resets all changes to the "status" field.
  5194. func (m *MessageRecordsMutation) ResetStatus() {
  5195. m.status = nil
  5196. m.addstatus = nil
  5197. delete(m.clearedFields, messagerecords.FieldStatus)
  5198. }
  5199. // SetDeletedAt sets the "deleted_at" field.
  5200. func (m *MessageRecordsMutation) SetDeletedAt(t time.Time) {
  5201. m.deleted_at = &t
  5202. }
  5203. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5204. func (m *MessageRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  5205. v := m.deleted_at
  5206. if v == nil {
  5207. return
  5208. }
  5209. return *v, true
  5210. }
  5211. // OldDeletedAt returns the old "deleted_at" field's value of the MessageRecords entity.
  5212. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5213. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5214. func (m *MessageRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5215. if !m.op.Is(OpUpdateOne) {
  5216. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5217. }
  5218. if m.id == nil || m.oldValue == nil {
  5219. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5220. }
  5221. oldValue, err := m.oldValue(ctx)
  5222. if err != nil {
  5223. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5224. }
  5225. return oldValue.DeletedAt, nil
  5226. }
  5227. // ClearDeletedAt clears the value of the "deleted_at" field.
  5228. func (m *MessageRecordsMutation) ClearDeletedAt() {
  5229. m.deleted_at = nil
  5230. m.clearedFields[messagerecords.FieldDeletedAt] = struct{}{}
  5231. }
  5232. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5233. func (m *MessageRecordsMutation) DeletedAtCleared() bool {
  5234. _, ok := m.clearedFields[messagerecords.FieldDeletedAt]
  5235. return ok
  5236. }
  5237. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5238. func (m *MessageRecordsMutation) ResetDeletedAt() {
  5239. m.deleted_at = nil
  5240. delete(m.clearedFields, messagerecords.FieldDeletedAt)
  5241. }
  5242. // SetBotWxid sets the "bot_wxid" field.
  5243. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  5244. m.bot_wxid = &s
  5245. }
  5246. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  5247. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  5248. v := m.bot_wxid
  5249. if v == nil {
  5250. return
  5251. }
  5252. return *v, true
  5253. }
  5254. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  5255. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5257. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  5258. if !m.op.Is(OpUpdateOne) {
  5259. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  5260. }
  5261. if m.id == nil || m.oldValue == nil {
  5262. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  5263. }
  5264. oldValue, err := m.oldValue(ctx)
  5265. if err != nil {
  5266. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  5267. }
  5268. return oldValue.BotWxid, nil
  5269. }
  5270. // ResetBotWxid resets all changes to the "bot_wxid" field.
  5271. func (m *MessageRecordsMutation) ResetBotWxid() {
  5272. m.bot_wxid = nil
  5273. }
  5274. // SetContactID sets the "contact_id" field.
  5275. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  5276. m.message_contact = &u
  5277. }
  5278. // ContactID returns the value of the "contact_id" field in the mutation.
  5279. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  5280. v := m.message_contact
  5281. if v == nil {
  5282. return
  5283. }
  5284. return *v, true
  5285. }
  5286. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  5287. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5289. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  5290. if !m.op.Is(OpUpdateOne) {
  5291. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  5292. }
  5293. if m.id == nil || m.oldValue == nil {
  5294. return v, errors.New("OldContactID requires an ID field in the mutation")
  5295. }
  5296. oldValue, err := m.oldValue(ctx)
  5297. if err != nil {
  5298. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  5299. }
  5300. return oldValue.ContactID, nil
  5301. }
  5302. // ClearContactID clears the value of the "contact_id" field.
  5303. func (m *MessageRecordsMutation) ClearContactID() {
  5304. m.message_contact = nil
  5305. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  5306. }
  5307. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  5308. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  5309. _, ok := m.clearedFields[messagerecords.FieldContactID]
  5310. return ok
  5311. }
  5312. // ResetContactID resets all changes to the "contact_id" field.
  5313. func (m *MessageRecordsMutation) ResetContactID() {
  5314. m.message_contact = nil
  5315. delete(m.clearedFields, messagerecords.FieldContactID)
  5316. }
  5317. // SetContactType sets the "contact_type" field.
  5318. func (m *MessageRecordsMutation) SetContactType(i int) {
  5319. m.contact_type = &i
  5320. m.addcontact_type = nil
  5321. }
  5322. // ContactType returns the value of the "contact_type" field in the mutation.
  5323. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  5324. v := m.contact_type
  5325. if v == nil {
  5326. return
  5327. }
  5328. return *v, true
  5329. }
  5330. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  5331. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5332. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5333. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  5334. if !m.op.Is(OpUpdateOne) {
  5335. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  5336. }
  5337. if m.id == nil || m.oldValue == nil {
  5338. return v, errors.New("OldContactType requires an ID field in the mutation")
  5339. }
  5340. oldValue, err := m.oldValue(ctx)
  5341. if err != nil {
  5342. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  5343. }
  5344. return oldValue.ContactType, nil
  5345. }
  5346. // AddContactType adds i to the "contact_type" field.
  5347. func (m *MessageRecordsMutation) AddContactType(i int) {
  5348. if m.addcontact_type != nil {
  5349. *m.addcontact_type += i
  5350. } else {
  5351. m.addcontact_type = &i
  5352. }
  5353. }
  5354. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  5355. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  5356. v := m.addcontact_type
  5357. if v == nil {
  5358. return
  5359. }
  5360. return *v, true
  5361. }
  5362. // ResetContactType resets all changes to the "contact_type" field.
  5363. func (m *MessageRecordsMutation) ResetContactType() {
  5364. m.contact_type = nil
  5365. m.addcontact_type = nil
  5366. }
  5367. // SetContactWxid sets the "contact_wxid" field.
  5368. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  5369. m.contact_wxid = &s
  5370. }
  5371. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  5372. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  5373. v := m.contact_wxid
  5374. if v == nil {
  5375. return
  5376. }
  5377. return *v, true
  5378. }
  5379. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  5380. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5381. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5382. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  5383. if !m.op.Is(OpUpdateOne) {
  5384. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  5385. }
  5386. if m.id == nil || m.oldValue == nil {
  5387. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  5388. }
  5389. oldValue, err := m.oldValue(ctx)
  5390. if err != nil {
  5391. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  5392. }
  5393. return oldValue.ContactWxid, nil
  5394. }
  5395. // ResetContactWxid resets all changes to the "contact_wxid" field.
  5396. func (m *MessageRecordsMutation) ResetContactWxid() {
  5397. m.contact_wxid = nil
  5398. }
  5399. // SetContentType sets the "content_type" field.
  5400. func (m *MessageRecordsMutation) SetContentType(i int) {
  5401. m.content_type = &i
  5402. m.addcontent_type = nil
  5403. }
  5404. // ContentType returns the value of the "content_type" field in the mutation.
  5405. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  5406. v := m.content_type
  5407. if v == nil {
  5408. return
  5409. }
  5410. return *v, true
  5411. }
  5412. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  5413. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5414. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5415. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  5416. if !m.op.Is(OpUpdateOne) {
  5417. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  5418. }
  5419. if m.id == nil || m.oldValue == nil {
  5420. return v, errors.New("OldContentType requires an ID field in the mutation")
  5421. }
  5422. oldValue, err := m.oldValue(ctx)
  5423. if err != nil {
  5424. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  5425. }
  5426. return oldValue.ContentType, nil
  5427. }
  5428. // AddContentType adds i to the "content_type" field.
  5429. func (m *MessageRecordsMutation) AddContentType(i int) {
  5430. if m.addcontent_type != nil {
  5431. *m.addcontent_type += i
  5432. } else {
  5433. m.addcontent_type = &i
  5434. }
  5435. }
  5436. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  5437. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  5438. v := m.addcontent_type
  5439. if v == nil {
  5440. return
  5441. }
  5442. return *v, true
  5443. }
  5444. // ResetContentType resets all changes to the "content_type" field.
  5445. func (m *MessageRecordsMutation) ResetContentType() {
  5446. m.content_type = nil
  5447. m.addcontent_type = nil
  5448. }
  5449. // SetContent sets the "content" field.
  5450. func (m *MessageRecordsMutation) SetContent(s string) {
  5451. m.content = &s
  5452. }
  5453. // Content returns the value of the "content" field in the mutation.
  5454. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  5455. v := m.content
  5456. if v == nil {
  5457. return
  5458. }
  5459. return *v, true
  5460. }
  5461. // OldContent returns the old "content" field's value of the MessageRecords entity.
  5462. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5463. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5464. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  5465. if !m.op.Is(OpUpdateOne) {
  5466. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  5467. }
  5468. if m.id == nil || m.oldValue == nil {
  5469. return v, errors.New("OldContent requires an ID field in the mutation")
  5470. }
  5471. oldValue, err := m.oldValue(ctx)
  5472. if err != nil {
  5473. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  5474. }
  5475. return oldValue.Content, nil
  5476. }
  5477. // ResetContent resets all changes to the "content" field.
  5478. func (m *MessageRecordsMutation) ResetContent() {
  5479. m.content = nil
  5480. }
  5481. // SetMeta sets the "meta" field.
  5482. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  5483. m.meta = &ct
  5484. }
  5485. // Meta returns the value of the "meta" field in the mutation.
  5486. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  5487. v := m.meta
  5488. if v == nil {
  5489. return
  5490. }
  5491. return *v, true
  5492. }
  5493. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  5494. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5496. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  5497. if !m.op.Is(OpUpdateOne) {
  5498. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  5499. }
  5500. if m.id == nil || m.oldValue == nil {
  5501. return v, errors.New("OldMeta requires an ID field in the mutation")
  5502. }
  5503. oldValue, err := m.oldValue(ctx)
  5504. if err != nil {
  5505. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  5506. }
  5507. return oldValue.Meta, nil
  5508. }
  5509. // ClearMeta clears the value of the "meta" field.
  5510. func (m *MessageRecordsMutation) ClearMeta() {
  5511. m.meta = nil
  5512. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  5513. }
  5514. // MetaCleared returns if the "meta" field was cleared in this mutation.
  5515. func (m *MessageRecordsMutation) MetaCleared() bool {
  5516. _, ok := m.clearedFields[messagerecords.FieldMeta]
  5517. return ok
  5518. }
  5519. // ResetMeta resets all changes to the "meta" field.
  5520. func (m *MessageRecordsMutation) ResetMeta() {
  5521. m.meta = nil
  5522. delete(m.clearedFields, messagerecords.FieldMeta)
  5523. }
  5524. // SetErrorDetail sets the "error_detail" field.
  5525. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  5526. m.error_detail = &s
  5527. }
  5528. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  5529. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  5530. v := m.error_detail
  5531. if v == nil {
  5532. return
  5533. }
  5534. return *v, true
  5535. }
  5536. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  5537. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5538. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5539. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  5540. if !m.op.Is(OpUpdateOne) {
  5541. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  5542. }
  5543. if m.id == nil || m.oldValue == nil {
  5544. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  5545. }
  5546. oldValue, err := m.oldValue(ctx)
  5547. if err != nil {
  5548. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  5549. }
  5550. return oldValue.ErrorDetail, nil
  5551. }
  5552. // ResetErrorDetail resets all changes to the "error_detail" field.
  5553. func (m *MessageRecordsMutation) ResetErrorDetail() {
  5554. m.error_detail = nil
  5555. }
  5556. // SetSendTime sets the "send_time" field.
  5557. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  5558. m.send_time = &t
  5559. }
  5560. // SendTime returns the value of the "send_time" field in the mutation.
  5561. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  5562. v := m.send_time
  5563. if v == nil {
  5564. return
  5565. }
  5566. return *v, true
  5567. }
  5568. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  5569. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5570. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5571. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  5572. if !m.op.Is(OpUpdateOne) {
  5573. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  5574. }
  5575. if m.id == nil || m.oldValue == nil {
  5576. return v, errors.New("OldSendTime requires an ID field in the mutation")
  5577. }
  5578. oldValue, err := m.oldValue(ctx)
  5579. if err != nil {
  5580. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  5581. }
  5582. return oldValue.SendTime, nil
  5583. }
  5584. // ClearSendTime clears the value of the "send_time" field.
  5585. func (m *MessageRecordsMutation) ClearSendTime() {
  5586. m.send_time = nil
  5587. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  5588. }
  5589. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  5590. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  5591. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  5592. return ok
  5593. }
  5594. // ResetSendTime resets all changes to the "send_time" field.
  5595. func (m *MessageRecordsMutation) ResetSendTime() {
  5596. m.send_time = nil
  5597. delete(m.clearedFields, messagerecords.FieldSendTime)
  5598. }
  5599. // SetSourceType sets the "source_type" field.
  5600. func (m *MessageRecordsMutation) SetSourceType(i int) {
  5601. m.source_type = &i
  5602. m.addsource_type = nil
  5603. }
  5604. // SourceType returns the value of the "source_type" field in the mutation.
  5605. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  5606. v := m.source_type
  5607. if v == nil {
  5608. return
  5609. }
  5610. return *v, true
  5611. }
  5612. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  5613. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5614. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5615. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  5616. if !m.op.Is(OpUpdateOne) {
  5617. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  5618. }
  5619. if m.id == nil || m.oldValue == nil {
  5620. return v, errors.New("OldSourceType requires an ID field in the mutation")
  5621. }
  5622. oldValue, err := m.oldValue(ctx)
  5623. if err != nil {
  5624. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  5625. }
  5626. return oldValue.SourceType, nil
  5627. }
  5628. // AddSourceType adds i to the "source_type" field.
  5629. func (m *MessageRecordsMutation) AddSourceType(i int) {
  5630. if m.addsource_type != nil {
  5631. *m.addsource_type += i
  5632. } else {
  5633. m.addsource_type = &i
  5634. }
  5635. }
  5636. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  5637. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  5638. v := m.addsource_type
  5639. if v == nil {
  5640. return
  5641. }
  5642. return *v, true
  5643. }
  5644. // ResetSourceType resets all changes to the "source_type" field.
  5645. func (m *MessageRecordsMutation) ResetSourceType() {
  5646. m.source_type = nil
  5647. m.addsource_type = nil
  5648. }
  5649. // SetSourceID sets the "source_id" field.
  5650. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  5651. m.sop_stage = &u
  5652. }
  5653. // SourceID returns the value of the "source_id" field in the mutation.
  5654. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  5655. v := m.sop_stage
  5656. if v == nil {
  5657. return
  5658. }
  5659. return *v, true
  5660. }
  5661. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  5662. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5663. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5664. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  5665. if !m.op.Is(OpUpdateOne) {
  5666. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  5667. }
  5668. if m.id == nil || m.oldValue == nil {
  5669. return v, errors.New("OldSourceID requires an ID field in the mutation")
  5670. }
  5671. oldValue, err := m.oldValue(ctx)
  5672. if err != nil {
  5673. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  5674. }
  5675. return oldValue.SourceID, nil
  5676. }
  5677. // ClearSourceID clears the value of the "source_id" field.
  5678. func (m *MessageRecordsMutation) ClearSourceID() {
  5679. m.sop_stage = nil
  5680. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  5681. }
  5682. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  5683. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  5684. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  5685. return ok
  5686. }
  5687. // ResetSourceID resets all changes to the "source_id" field.
  5688. func (m *MessageRecordsMutation) ResetSourceID() {
  5689. m.sop_stage = nil
  5690. delete(m.clearedFields, messagerecords.FieldSourceID)
  5691. }
  5692. // SetSubSourceID sets the "sub_source_id" field.
  5693. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  5694. m.sop_node = &u
  5695. }
  5696. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  5697. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  5698. v := m.sop_node
  5699. if v == nil {
  5700. return
  5701. }
  5702. return *v, true
  5703. }
  5704. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  5705. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  5706. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5707. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  5708. if !m.op.Is(OpUpdateOne) {
  5709. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  5710. }
  5711. if m.id == nil || m.oldValue == nil {
  5712. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  5713. }
  5714. oldValue, err := m.oldValue(ctx)
  5715. if err != nil {
  5716. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  5717. }
  5718. return oldValue.SubSourceID, nil
  5719. }
  5720. // ClearSubSourceID clears the value of the "sub_source_id" field.
  5721. func (m *MessageRecordsMutation) ClearSubSourceID() {
  5722. m.sop_node = nil
  5723. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  5724. }
  5725. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  5726. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  5727. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  5728. return ok
  5729. }
  5730. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  5731. func (m *MessageRecordsMutation) ResetSubSourceID() {
  5732. m.sop_node = nil
  5733. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  5734. }
  5735. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  5736. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  5737. m.sop_stage = &id
  5738. }
  5739. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  5740. func (m *MessageRecordsMutation) ClearSopStage() {
  5741. m.clearedsop_stage = true
  5742. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  5743. }
  5744. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  5745. func (m *MessageRecordsMutation) SopStageCleared() bool {
  5746. return m.SourceIDCleared() || m.clearedsop_stage
  5747. }
  5748. // SopStageID returns the "sop_stage" edge ID in the mutation.
  5749. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  5750. if m.sop_stage != nil {
  5751. return *m.sop_stage, true
  5752. }
  5753. return
  5754. }
  5755. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  5756. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  5757. // SopStageID instead. It exists only for internal usage by the builders.
  5758. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  5759. if id := m.sop_stage; id != nil {
  5760. ids = append(ids, *id)
  5761. }
  5762. return
  5763. }
  5764. // ResetSopStage resets all changes to the "sop_stage" edge.
  5765. func (m *MessageRecordsMutation) ResetSopStage() {
  5766. m.sop_stage = nil
  5767. m.clearedsop_stage = false
  5768. }
  5769. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  5770. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  5771. m.sop_node = &id
  5772. }
  5773. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  5774. func (m *MessageRecordsMutation) ClearSopNode() {
  5775. m.clearedsop_node = true
  5776. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  5777. }
  5778. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  5779. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  5780. return m.SubSourceIDCleared() || m.clearedsop_node
  5781. }
  5782. // SopNodeID returns the "sop_node" edge ID in the mutation.
  5783. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  5784. if m.sop_node != nil {
  5785. return *m.sop_node, true
  5786. }
  5787. return
  5788. }
  5789. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  5790. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  5791. // SopNodeID instead. It exists only for internal usage by the builders.
  5792. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  5793. if id := m.sop_node; id != nil {
  5794. ids = append(ids, *id)
  5795. }
  5796. return
  5797. }
  5798. // ResetSopNode resets all changes to the "sop_node" edge.
  5799. func (m *MessageRecordsMutation) ResetSopNode() {
  5800. m.sop_node = nil
  5801. m.clearedsop_node = false
  5802. }
  5803. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  5804. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  5805. m.message_contact = &id
  5806. }
  5807. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  5808. func (m *MessageRecordsMutation) ClearMessageContact() {
  5809. m.clearedmessage_contact = true
  5810. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  5811. }
  5812. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  5813. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  5814. return m.ContactIDCleared() || m.clearedmessage_contact
  5815. }
  5816. // MessageContactID returns the "message_contact" edge ID in the mutation.
  5817. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  5818. if m.message_contact != nil {
  5819. return *m.message_contact, true
  5820. }
  5821. return
  5822. }
  5823. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  5824. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  5825. // MessageContactID instead. It exists only for internal usage by the builders.
  5826. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  5827. if id := m.message_contact; id != nil {
  5828. ids = append(ids, *id)
  5829. }
  5830. return
  5831. }
  5832. // ResetMessageContact resets all changes to the "message_contact" edge.
  5833. func (m *MessageRecordsMutation) ResetMessageContact() {
  5834. m.message_contact = nil
  5835. m.clearedmessage_contact = false
  5836. }
  5837. // Where appends a list predicates to the MessageRecordsMutation builder.
  5838. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  5839. m.predicates = append(m.predicates, ps...)
  5840. }
  5841. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  5842. // users can use type-assertion to append predicates that do not depend on any generated package.
  5843. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  5844. p := make([]predicate.MessageRecords, len(ps))
  5845. for i := range ps {
  5846. p[i] = ps[i]
  5847. }
  5848. m.Where(p...)
  5849. }
  5850. // Op returns the operation name.
  5851. func (m *MessageRecordsMutation) Op() Op {
  5852. return m.op
  5853. }
  5854. // SetOp allows setting the mutation operation.
  5855. func (m *MessageRecordsMutation) SetOp(op Op) {
  5856. m.op = op
  5857. }
  5858. // Type returns the node type of this mutation (MessageRecords).
  5859. func (m *MessageRecordsMutation) Type() string {
  5860. return m.typ
  5861. }
  5862. // Fields returns all fields that were changed during this mutation. Note that in
  5863. // order to get all numeric fields that were incremented/decremented, call
  5864. // AddedFields().
  5865. func (m *MessageRecordsMutation) Fields() []string {
  5866. fields := make([]string, 0, 16)
  5867. if m.created_at != nil {
  5868. fields = append(fields, messagerecords.FieldCreatedAt)
  5869. }
  5870. if m.updated_at != nil {
  5871. fields = append(fields, messagerecords.FieldUpdatedAt)
  5872. }
  5873. if m.status != nil {
  5874. fields = append(fields, messagerecords.FieldStatus)
  5875. }
  5876. if m.deleted_at != nil {
  5877. fields = append(fields, messagerecords.FieldDeletedAt)
  5878. }
  5879. if m.bot_wxid != nil {
  5880. fields = append(fields, messagerecords.FieldBotWxid)
  5881. }
  5882. if m.message_contact != nil {
  5883. fields = append(fields, messagerecords.FieldContactID)
  5884. }
  5885. if m.contact_type != nil {
  5886. fields = append(fields, messagerecords.FieldContactType)
  5887. }
  5888. if m.contact_wxid != nil {
  5889. fields = append(fields, messagerecords.FieldContactWxid)
  5890. }
  5891. if m.content_type != nil {
  5892. fields = append(fields, messagerecords.FieldContentType)
  5893. }
  5894. if m.content != nil {
  5895. fields = append(fields, messagerecords.FieldContent)
  5896. }
  5897. if m.meta != nil {
  5898. fields = append(fields, messagerecords.FieldMeta)
  5899. }
  5900. if m.error_detail != nil {
  5901. fields = append(fields, messagerecords.FieldErrorDetail)
  5902. }
  5903. if m.send_time != nil {
  5904. fields = append(fields, messagerecords.FieldSendTime)
  5905. }
  5906. if m.source_type != nil {
  5907. fields = append(fields, messagerecords.FieldSourceType)
  5908. }
  5909. if m.sop_stage != nil {
  5910. fields = append(fields, messagerecords.FieldSourceID)
  5911. }
  5912. if m.sop_node != nil {
  5913. fields = append(fields, messagerecords.FieldSubSourceID)
  5914. }
  5915. return fields
  5916. }
  5917. // Field returns the value of a field with the given name. The second boolean
  5918. // return value indicates that this field was not set, or was not defined in the
  5919. // schema.
  5920. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  5921. switch name {
  5922. case messagerecords.FieldCreatedAt:
  5923. return m.CreatedAt()
  5924. case messagerecords.FieldUpdatedAt:
  5925. return m.UpdatedAt()
  5926. case messagerecords.FieldStatus:
  5927. return m.Status()
  5928. case messagerecords.FieldDeletedAt:
  5929. return m.DeletedAt()
  5930. case messagerecords.FieldBotWxid:
  5931. return m.BotWxid()
  5932. case messagerecords.FieldContactID:
  5933. return m.ContactID()
  5934. case messagerecords.FieldContactType:
  5935. return m.ContactType()
  5936. case messagerecords.FieldContactWxid:
  5937. return m.ContactWxid()
  5938. case messagerecords.FieldContentType:
  5939. return m.ContentType()
  5940. case messagerecords.FieldContent:
  5941. return m.Content()
  5942. case messagerecords.FieldMeta:
  5943. return m.Meta()
  5944. case messagerecords.FieldErrorDetail:
  5945. return m.ErrorDetail()
  5946. case messagerecords.FieldSendTime:
  5947. return m.SendTime()
  5948. case messagerecords.FieldSourceType:
  5949. return m.SourceType()
  5950. case messagerecords.FieldSourceID:
  5951. return m.SourceID()
  5952. case messagerecords.FieldSubSourceID:
  5953. return m.SubSourceID()
  5954. }
  5955. return nil, false
  5956. }
  5957. // OldField returns the old value of the field from the database. An error is
  5958. // returned if the mutation operation is not UpdateOne, or the query to the
  5959. // database failed.
  5960. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5961. switch name {
  5962. case messagerecords.FieldCreatedAt:
  5963. return m.OldCreatedAt(ctx)
  5964. case messagerecords.FieldUpdatedAt:
  5965. return m.OldUpdatedAt(ctx)
  5966. case messagerecords.FieldStatus:
  5967. return m.OldStatus(ctx)
  5968. case messagerecords.FieldDeletedAt:
  5969. return m.OldDeletedAt(ctx)
  5970. case messagerecords.FieldBotWxid:
  5971. return m.OldBotWxid(ctx)
  5972. case messagerecords.FieldContactID:
  5973. return m.OldContactID(ctx)
  5974. case messagerecords.FieldContactType:
  5975. return m.OldContactType(ctx)
  5976. case messagerecords.FieldContactWxid:
  5977. return m.OldContactWxid(ctx)
  5978. case messagerecords.FieldContentType:
  5979. return m.OldContentType(ctx)
  5980. case messagerecords.FieldContent:
  5981. return m.OldContent(ctx)
  5982. case messagerecords.FieldMeta:
  5983. return m.OldMeta(ctx)
  5984. case messagerecords.FieldErrorDetail:
  5985. return m.OldErrorDetail(ctx)
  5986. case messagerecords.FieldSendTime:
  5987. return m.OldSendTime(ctx)
  5988. case messagerecords.FieldSourceType:
  5989. return m.OldSourceType(ctx)
  5990. case messagerecords.FieldSourceID:
  5991. return m.OldSourceID(ctx)
  5992. case messagerecords.FieldSubSourceID:
  5993. return m.OldSubSourceID(ctx)
  5994. }
  5995. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  5996. }
  5997. // SetField sets the value of a field with the given name. It returns an error if
  5998. // the field is not defined in the schema, or if the type mismatched the field
  5999. // type.
  6000. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  6001. switch name {
  6002. case messagerecords.FieldCreatedAt:
  6003. v, ok := value.(time.Time)
  6004. if !ok {
  6005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6006. }
  6007. m.SetCreatedAt(v)
  6008. return nil
  6009. case messagerecords.FieldUpdatedAt:
  6010. v, ok := value.(time.Time)
  6011. if !ok {
  6012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6013. }
  6014. m.SetUpdatedAt(v)
  6015. return nil
  6016. case messagerecords.FieldStatus:
  6017. v, ok := value.(uint8)
  6018. if !ok {
  6019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6020. }
  6021. m.SetStatus(v)
  6022. return nil
  6023. case messagerecords.FieldDeletedAt:
  6024. v, ok := value.(time.Time)
  6025. if !ok {
  6026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6027. }
  6028. m.SetDeletedAt(v)
  6029. return nil
  6030. case messagerecords.FieldBotWxid:
  6031. v, ok := value.(string)
  6032. if !ok {
  6033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6034. }
  6035. m.SetBotWxid(v)
  6036. return nil
  6037. case messagerecords.FieldContactID:
  6038. v, ok := value.(uint64)
  6039. if !ok {
  6040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6041. }
  6042. m.SetContactID(v)
  6043. return nil
  6044. case messagerecords.FieldContactType:
  6045. v, ok := value.(int)
  6046. if !ok {
  6047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6048. }
  6049. m.SetContactType(v)
  6050. return nil
  6051. case messagerecords.FieldContactWxid:
  6052. v, ok := value.(string)
  6053. if !ok {
  6054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6055. }
  6056. m.SetContactWxid(v)
  6057. return nil
  6058. case messagerecords.FieldContentType:
  6059. v, ok := value.(int)
  6060. if !ok {
  6061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6062. }
  6063. m.SetContentType(v)
  6064. return nil
  6065. case messagerecords.FieldContent:
  6066. v, ok := value.(string)
  6067. if !ok {
  6068. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6069. }
  6070. m.SetContent(v)
  6071. return nil
  6072. case messagerecords.FieldMeta:
  6073. v, ok := value.(custom_types.Meta)
  6074. if !ok {
  6075. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6076. }
  6077. m.SetMeta(v)
  6078. return nil
  6079. case messagerecords.FieldErrorDetail:
  6080. v, ok := value.(string)
  6081. if !ok {
  6082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6083. }
  6084. m.SetErrorDetail(v)
  6085. return nil
  6086. case messagerecords.FieldSendTime:
  6087. v, ok := value.(time.Time)
  6088. if !ok {
  6089. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6090. }
  6091. m.SetSendTime(v)
  6092. return nil
  6093. case messagerecords.FieldSourceType:
  6094. v, ok := value.(int)
  6095. if !ok {
  6096. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6097. }
  6098. m.SetSourceType(v)
  6099. return nil
  6100. case messagerecords.FieldSourceID:
  6101. v, ok := value.(uint64)
  6102. if !ok {
  6103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6104. }
  6105. m.SetSourceID(v)
  6106. return nil
  6107. case messagerecords.FieldSubSourceID:
  6108. v, ok := value.(uint64)
  6109. if !ok {
  6110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6111. }
  6112. m.SetSubSourceID(v)
  6113. return nil
  6114. }
  6115. return fmt.Errorf("unknown MessageRecords field %s", name)
  6116. }
  6117. // AddedFields returns all numeric fields that were incremented/decremented during
  6118. // this mutation.
  6119. func (m *MessageRecordsMutation) AddedFields() []string {
  6120. var fields []string
  6121. if m.addstatus != nil {
  6122. fields = append(fields, messagerecords.FieldStatus)
  6123. }
  6124. if m.addcontact_type != nil {
  6125. fields = append(fields, messagerecords.FieldContactType)
  6126. }
  6127. if m.addcontent_type != nil {
  6128. fields = append(fields, messagerecords.FieldContentType)
  6129. }
  6130. if m.addsource_type != nil {
  6131. fields = append(fields, messagerecords.FieldSourceType)
  6132. }
  6133. return fields
  6134. }
  6135. // AddedField returns the numeric value that was incremented/decremented on a field
  6136. // with the given name. The second boolean return value indicates that this field
  6137. // was not set, or was not defined in the schema.
  6138. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  6139. switch name {
  6140. case messagerecords.FieldStatus:
  6141. return m.AddedStatus()
  6142. case messagerecords.FieldContactType:
  6143. return m.AddedContactType()
  6144. case messagerecords.FieldContentType:
  6145. return m.AddedContentType()
  6146. case messagerecords.FieldSourceType:
  6147. return m.AddedSourceType()
  6148. }
  6149. return nil, false
  6150. }
  6151. // AddField adds the value to the field with the given name. It returns an error if
  6152. // the field is not defined in the schema, or if the type mismatched the field
  6153. // type.
  6154. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  6155. switch name {
  6156. case messagerecords.FieldStatus:
  6157. v, ok := value.(int8)
  6158. if !ok {
  6159. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6160. }
  6161. m.AddStatus(v)
  6162. return nil
  6163. case messagerecords.FieldContactType:
  6164. v, ok := value.(int)
  6165. if !ok {
  6166. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6167. }
  6168. m.AddContactType(v)
  6169. return nil
  6170. case messagerecords.FieldContentType:
  6171. v, ok := value.(int)
  6172. if !ok {
  6173. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6174. }
  6175. m.AddContentType(v)
  6176. return nil
  6177. case messagerecords.FieldSourceType:
  6178. v, ok := value.(int)
  6179. if !ok {
  6180. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6181. }
  6182. m.AddSourceType(v)
  6183. return nil
  6184. }
  6185. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  6186. }
  6187. // ClearedFields returns all nullable fields that were cleared during this
  6188. // mutation.
  6189. func (m *MessageRecordsMutation) ClearedFields() []string {
  6190. var fields []string
  6191. if m.FieldCleared(messagerecords.FieldStatus) {
  6192. fields = append(fields, messagerecords.FieldStatus)
  6193. }
  6194. if m.FieldCleared(messagerecords.FieldDeletedAt) {
  6195. fields = append(fields, messagerecords.FieldDeletedAt)
  6196. }
  6197. if m.FieldCleared(messagerecords.FieldContactID) {
  6198. fields = append(fields, messagerecords.FieldContactID)
  6199. }
  6200. if m.FieldCleared(messagerecords.FieldMeta) {
  6201. fields = append(fields, messagerecords.FieldMeta)
  6202. }
  6203. if m.FieldCleared(messagerecords.FieldSendTime) {
  6204. fields = append(fields, messagerecords.FieldSendTime)
  6205. }
  6206. if m.FieldCleared(messagerecords.FieldSourceID) {
  6207. fields = append(fields, messagerecords.FieldSourceID)
  6208. }
  6209. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  6210. fields = append(fields, messagerecords.FieldSubSourceID)
  6211. }
  6212. return fields
  6213. }
  6214. // FieldCleared returns a boolean indicating if a field with the given name was
  6215. // cleared in this mutation.
  6216. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  6217. _, ok := m.clearedFields[name]
  6218. return ok
  6219. }
  6220. // ClearField clears the value of the field with the given name. It returns an
  6221. // error if the field is not defined in the schema.
  6222. func (m *MessageRecordsMutation) ClearField(name string) error {
  6223. switch name {
  6224. case messagerecords.FieldStatus:
  6225. m.ClearStatus()
  6226. return nil
  6227. case messagerecords.FieldDeletedAt:
  6228. m.ClearDeletedAt()
  6229. return nil
  6230. case messagerecords.FieldContactID:
  6231. m.ClearContactID()
  6232. return nil
  6233. case messagerecords.FieldMeta:
  6234. m.ClearMeta()
  6235. return nil
  6236. case messagerecords.FieldSendTime:
  6237. m.ClearSendTime()
  6238. return nil
  6239. case messagerecords.FieldSourceID:
  6240. m.ClearSourceID()
  6241. return nil
  6242. case messagerecords.FieldSubSourceID:
  6243. m.ClearSubSourceID()
  6244. return nil
  6245. }
  6246. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  6247. }
  6248. // ResetField resets all changes in the mutation for the field with the given name.
  6249. // It returns an error if the field is not defined in the schema.
  6250. func (m *MessageRecordsMutation) ResetField(name string) error {
  6251. switch name {
  6252. case messagerecords.FieldCreatedAt:
  6253. m.ResetCreatedAt()
  6254. return nil
  6255. case messagerecords.FieldUpdatedAt:
  6256. m.ResetUpdatedAt()
  6257. return nil
  6258. case messagerecords.FieldStatus:
  6259. m.ResetStatus()
  6260. return nil
  6261. case messagerecords.FieldDeletedAt:
  6262. m.ResetDeletedAt()
  6263. return nil
  6264. case messagerecords.FieldBotWxid:
  6265. m.ResetBotWxid()
  6266. return nil
  6267. case messagerecords.FieldContactID:
  6268. m.ResetContactID()
  6269. return nil
  6270. case messagerecords.FieldContactType:
  6271. m.ResetContactType()
  6272. return nil
  6273. case messagerecords.FieldContactWxid:
  6274. m.ResetContactWxid()
  6275. return nil
  6276. case messagerecords.FieldContentType:
  6277. m.ResetContentType()
  6278. return nil
  6279. case messagerecords.FieldContent:
  6280. m.ResetContent()
  6281. return nil
  6282. case messagerecords.FieldMeta:
  6283. m.ResetMeta()
  6284. return nil
  6285. case messagerecords.FieldErrorDetail:
  6286. m.ResetErrorDetail()
  6287. return nil
  6288. case messagerecords.FieldSendTime:
  6289. m.ResetSendTime()
  6290. return nil
  6291. case messagerecords.FieldSourceType:
  6292. m.ResetSourceType()
  6293. return nil
  6294. case messagerecords.FieldSourceID:
  6295. m.ResetSourceID()
  6296. return nil
  6297. case messagerecords.FieldSubSourceID:
  6298. m.ResetSubSourceID()
  6299. return nil
  6300. }
  6301. return fmt.Errorf("unknown MessageRecords field %s", name)
  6302. }
  6303. // AddedEdges returns all edge names that were set/added in this mutation.
  6304. func (m *MessageRecordsMutation) AddedEdges() []string {
  6305. edges := make([]string, 0, 3)
  6306. if m.sop_stage != nil {
  6307. edges = append(edges, messagerecords.EdgeSopStage)
  6308. }
  6309. if m.sop_node != nil {
  6310. edges = append(edges, messagerecords.EdgeSopNode)
  6311. }
  6312. if m.message_contact != nil {
  6313. edges = append(edges, messagerecords.EdgeMessageContact)
  6314. }
  6315. return edges
  6316. }
  6317. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6318. // name in this mutation.
  6319. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  6320. switch name {
  6321. case messagerecords.EdgeSopStage:
  6322. if id := m.sop_stage; id != nil {
  6323. return []ent.Value{*id}
  6324. }
  6325. case messagerecords.EdgeSopNode:
  6326. if id := m.sop_node; id != nil {
  6327. return []ent.Value{*id}
  6328. }
  6329. case messagerecords.EdgeMessageContact:
  6330. if id := m.message_contact; id != nil {
  6331. return []ent.Value{*id}
  6332. }
  6333. }
  6334. return nil
  6335. }
  6336. // RemovedEdges returns all edge names that were removed in this mutation.
  6337. func (m *MessageRecordsMutation) RemovedEdges() []string {
  6338. edges := make([]string, 0, 3)
  6339. return edges
  6340. }
  6341. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6342. // the given name in this mutation.
  6343. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  6344. return nil
  6345. }
  6346. // ClearedEdges returns all edge names that were cleared in this mutation.
  6347. func (m *MessageRecordsMutation) ClearedEdges() []string {
  6348. edges := make([]string, 0, 3)
  6349. if m.clearedsop_stage {
  6350. edges = append(edges, messagerecords.EdgeSopStage)
  6351. }
  6352. if m.clearedsop_node {
  6353. edges = append(edges, messagerecords.EdgeSopNode)
  6354. }
  6355. if m.clearedmessage_contact {
  6356. edges = append(edges, messagerecords.EdgeMessageContact)
  6357. }
  6358. return edges
  6359. }
  6360. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6361. // was cleared in this mutation.
  6362. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  6363. switch name {
  6364. case messagerecords.EdgeSopStage:
  6365. return m.clearedsop_stage
  6366. case messagerecords.EdgeSopNode:
  6367. return m.clearedsop_node
  6368. case messagerecords.EdgeMessageContact:
  6369. return m.clearedmessage_contact
  6370. }
  6371. return false
  6372. }
  6373. // ClearEdge clears the value of the edge with the given name. It returns an error
  6374. // if that edge is not defined in the schema.
  6375. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  6376. switch name {
  6377. case messagerecords.EdgeSopStage:
  6378. m.ClearSopStage()
  6379. return nil
  6380. case messagerecords.EdgeSopNode:
  6381. m.ClearSopNode()
  6382. return nil
  6383. case messagerecords.EdgeMessageContact:
  6384. m.ClearMessageContact()
  6385. return nil
  6386. }
  6387. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  6388. }
  6389. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6390. // It returns an error if the edge is not defined in the schema.
  6391. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  6392. switch name {
  6393. case messagerecords.EdgeSopStage:
  6394. m.ResetSopStage()
  6395. return nil
  6396. case messagerecords.EdgeSopNode:
  6397. m.ResetSopNode()
  6398. return nil
  6399. case messagerecords.EdgeMessageContact:
  6400. m.ResetMessageContact()
  6401. return nil
  6402. }
  6403. return fmt.Errorf("unknown MessageRecords edge %s", name)
  6404. }
  6405. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  6406. type MsgMutation struct {
  6407. config
  6408. op Op
  6409. typ string
  6410. id *int
  6411. created_at *time.Time
  6412. updated_at *time.Time
  6413. deleted_at *time.Time
  6414. status *uint8
  6415. addstatus *int8
  6416. fromwxid *string
  6417. toid *string
  6418. msgtype *int32
  6419. addmsgtype *int32
  6420. msg *string
  6421. batch_no *string
  6422. clearedFields map[string]struct{}
  6423. done bool
  6424. oldValue func(context.Context) (*Msg, error)
  6425. predicates []predicate.Msg
  6426. }
  6427. var _ ent.Mutation = (*MsgMutation)(nil)
  6428. // msgOption allows management of the mutation configuration using functional options.
  6429. type msgOption func(*MsgMutation)
  6430. // newMsgMutation creates new mutation for the Msg entity.
  6431. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  6432. m := &MsgMutation{
  6433. config: c,
  6434. op: op,
  6435. typ: TypeMsg,
  6436. clearedFields: make(map[string]struct{}),
  6437. }
  6438. for _, opt := range opts {
  6439. opt(m)
  6440. }
  6441. return m
  6442. }
  6443. // withMsgID sets the ID field of the mutation.
  6444. func withMsgID(id int) msgOption {
  6445. return func(m *MsgMutation) {
  6446. var (
  6447. err error
  6448. once sync.Once
  6449. value *Msg
  6450. )
  6451. m.oldValue = func(ctx context.Context) (*Msg, error) {
  6452. once.Do(func() {
  6453. if m.done {
  6454. err = errors.New("querying old values post mutation is not allowed")
  6455. } else {
  6456. value, err = m.Client().Msg.Get(ctx, id)
  6457. }
  6458. })
  6459. return value, err
  6460. }
  6461. m.id = &id
  6462. }
  6463. }
  6464. // withMsg sets the old Msg of the mutation.
  6465. func withMsg(node *Msg) msgOption {
  6466. return func(m *MsgMutation) {
  6467. m.oldValue = func(context.Context) (*Msg, error) {
  6468. return node, nil
  6469. }
  6470. m.id = &node.ID
  6471. }
  6472. }
  6473. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6474. // executed in a transaction (ent.Tx), a transactional client is returned.
  6475. func (m MsgMutation) Client() *Client {
  6476. client := &Client{config: m.config}
  6477. client.init()
  6478. return client
  6479. }
  6480. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6481. // it returns an error otherwise.
  6482. func (m MsgMutation) Tx() (*Tx, error) {
  6483. if _, ok := m.driver.(*txDriver); !ok {
  6484. return nil, errors.New("ent: mutation is not running in a transaction")
  6485. }
  6486. tx := &Tx{config: m.config}
  6487. tx.init()
  6488. return tx, nil
  6489. }
  6490. // SetID sets the value of the id field. Note that this
  6491. // operation is only accepted on creation of Msg entities.
  6492. func (m *MsgMutation) SetID(id int) {
  6493. m.id = &id
  6494. }
  6495. // ID returns the ID value in the mutation. Note that the ID is only available
  6496. // if it was provided to the builder or after it was returned from the database.
  6497. func (m *MsgMutation) ID() (id int, exists bool) {
  6498. if m.id == nil {
  6499. return
  6500. }
  6501. return *m.id, true
  6502. }
  6503. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6504. // That means, if the mutation is applied within a transaction with an isolation level such
  6505. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6506. // or updated by the mutation.
  6507. func (m *MsgMutation) IDs(ctx context.Context) ([]int, error) {
  6508. switch {
  6509. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6510. id, exists := m.ID()
  6511. if exists {
  6512. return []int{id}, nil
  6513. }
  6514. fallthrough
  6515. case m.op.Is(OpUpdate | OpDelete):
  6516. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  6517. default:
  6518. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6519. }
  6520. }
  6521. // SetCreatedAt sets the "created_at" field.
  6522. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  6523. m.created_at = &t
  6524. }
  6525. // CreatedAt returns the value of the "created_at" field in the mutation.
  6526. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  6527. v := m.created_at
  6528. if v == nil {
  6529. return
  6530. }
  6531. return *v, true
  6532. }
  6533. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  6534. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  6535. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6536. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6537. if !m.op.Is(OpUpdateOne) {
  6538. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6539. }
  6540. if m.id == nil || m.oldValue == nil {
  6541. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6542. }
  6543. oldValue, err := m.oldValue(ctx)
  6544. if err != nil {
  6545. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6546. }
  6547. return oldValue.CreatedAt, nil
  6548. }
  6549. // ResetCreatedAt resets all changes to the "created_at" field.
  6550. func (m *MsgMutation) ResetCreatedAt() {
  6551. m.created_at = nil
  6552. }
  6553. // SetUpdatedAt sets the "updated_at" field.
  6554. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  6555. m.updated_at = &t
  6556. }
  6557. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6558. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  6559. v := m.updated_at
  6560. if v == nil {
  6561. return
  6562. }
  6563. return *v, true
  6564. }
  6565. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  6566. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  6567. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6568. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6569. if !m.op.Is(OpUpdateOne) {
  6570. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6571. }
  6572. if m.id == nil || m.oldValue == nil {
  6573. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6574. }
  6575. oldValue, err := m.oldValue(ctx)
  6576. if err != nil {
  6577. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6578. }
  6579. return oldValue.UpdatedAt, nil
  6580. }
  6581. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6582. func (m *MsgMutation) ResetUpdatedAt() {
  6583. m.updated_at = nil
  6584. }
  6585. // SetDeletedAt sets the "deleted_at" field.
  6586. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  6587. m.deleted_at = &t
  6588. }
  6589. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6590. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  6591. v := m.deleted_at
  6592. if v == nil {
  6593. return
  6594. }
  6595. return *v, true
  6596. }
  6597. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  6598. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  6599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6600. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6601. if !m.op.Is(OpUpdateOne) {
  6602. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6603. }
  6604. if m.id == nil || m.oldValue == nil {
  6605. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6606. }
  6607. oldValue, err := m.oldValue(ctx)
  6608. if err != nil {
  6609. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6610. }
  6611. return oldValue.DeletedAt, nil
  6612. }
  6613. // ClearDeletedAt clears the value of the "deleted_at" field.
  6614. func (m *MsgMutation) ClearDeletedAt() {
  6615. m.deleted_at = nil
  6616. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  6617. }
  6618. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6619. func (m *MsgMutation) DeletedAtCleared() bool {
  6620. _, ok := m.clearedFields[msg.FieldDeletedAt]
  6621. return ok
  6622. }
  6623. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6624. func (m *MsgMutation) ResetDeletedAt() {
  6625. m.deleted_at = nil
  6626. delete(m.clearedFields, msg.FieldDeletedAt)
  6627. }
  6628. // SetStatus sets the "status" field.
  6629. func (m *MsgMutation) SetStatus(u uint8) {
  6630. m.status = &u
  6631. m.addstatus = nil
  6632. }
  6633. // Status returns the value of the "status" field in the mutation.
  6634. func (m *MsgMutation) Status() (r uint8, exists bool) {
  6635. v := m.status
  6636. if v == nil {
  6637. return
  6638. }
  6639. return *v, true
  6640. }
  6641. // OldStatus returns the old "status" field's value of the Msg entity.
  6642. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  6643. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6644. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  6645. if !m.op.Is(OpUpdateOne) {
  6646. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  6647. }
  6648. if m.id == nil || m.oldValue == nil {
  6649. return v, errors.New("OldStatus requires an ID field in the mutation")
  6650. }
  6651. oldValue, err := m.oldValue(ctx)
  6652. if err != nil {
  6653. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  6654. }
  6655. return oldValue.Status, nil
  6656. }
  6657. // AddStatus adds u to the "status" field.
  6658. func (m *MsgMutation) AddStatus(u int8) {
  6659. if m.addstatus != nil {
  6660. *m.addstatus += u
  6661. } else {
  6662. m.addstatus = &u
  6663. }
  6664. }
  6665. // AddedStatus returns the value that was added to the "status" field in this mutation.
  6666. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  6667. v := m.addstatus
  6668. if v == nil {
  6669. return
  6670. }
  6671. return *v, true
  6672. }
  6673. // ClearStatus clears the value of the "status" field.
  6674. func (m *MsgMutation) ClearStatus() {
  6675. m.status = nil
  6676. m.addstatus = nil
  6677. m.clearedFields[msg.FieldStatus] = struct{}{}
  6678. }
  6679. // StatusCleared returns if the "status" field was cleared in this mutation.
  6680. func (m *MsgMutation) StatusCleared() bool {
  6681. _, ok := m.clearedFields[msg.FieldStatus]
  6682. return ok
  6683. }
  6684. // ResetStatus resets all changes to the "status" field.
  6685. func (m *MsgMutation) ResetStatus() {
  6686. m.status = nil
  6687. m.addstatus = nil
  6688. delete(m.clearedFields, msg.FieldStatus)
  6689. }
  6690. // SetFromwxid sets the "fromwxid" field.
  6691. func (m *MsgMutation) SetFromwxid(s string) {
  6692. m.fromwxid = &s
  6693. }
  6694. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  6695. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  6696. v := m.fromwxid
  6697. if v == nil {
  6698. return
  6699. }
  6700. return *v, true
  6701. }
  6702. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  6703. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  6704. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6705. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  6706. if !m.op.Is(OpUpdateOne) {
  6707. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  6708. }
  6709. if m.id == nil || m.oldValue == nil {
  6710. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  6711. }
  6712. oldValue, err := m.oldValue(ctx)
  6713. if err != nil {
  6714. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  6715. }
  6716. return oldValue.Fromwxid, nil
  6717. }
  6718. // ClearFromwxid clears the value of the "fromwxid" field.
  6719. func (m *MsgMutation) ClearFromwxid() {
  6720. m.fromwxid = nil
  6721. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  6722. }
  6723. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  6724. func (m *MsgMutation) FromwxidCleared() bool {
  6725. _, ok := m.clearedFields[msg.FieldFromwxid]
  6726. return ok
  6727. }
  6728. // ResetFromwxid resets all changes to the "fromwxid" field.
  6729. func (m *MsgMutation) ResetFromwxid() {
  6730. m.fromwxid = nil
  6731. delete(m.clearedFields, msg.FieldFromwxid)
  6732. }
  6733. // SetToid sets the "toid" field.
  6734. func (m *MsgMutation) SetToid(s string) {
  6735. m.toid = &s
  6736. }
  6737. // Toid returns the value of the "toid" field in the mutation.
  6738. func (m *MsgMutation) Toid() (r string, exists bool) {
  6739. v := m.toid
  6740. if v == nil {
  6741. return
  6742. }
  6743. return *v, true
  6744. }
  6745. // OldToid returns the old "toid" field's value of the Msg entity.
  6746. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  6747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6748. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  6749. if !m.op.Is(OpUpdateOne) {
  6750. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  6751. }
  6752. if m.id == nil || m.oldValue == nil {
  6753. return v, errors.New("OldToid requires an ID field in the mutation")
  6754. }
  6755. oldValue, err := m.oldValue(ctx)
  6756. if err != nil {
  6757. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  6758. }
  6759. return oldValue.Toid, nil
  6760. }
  6761. // ClearToid clears the value of the "toid" field.
  6762. func (m *MsgMutation) ClearToid() {
  6763. m.toid = nil
  6764. m.clearedFields[msg.FieldToid] = struct{}{}
  6765. }
  6766. // ToidCleared returns if the "toid" field was cleared in this mutation.
  6767. func (m *MsgMutation) ToidCleared() bool {
  6768. _, ok := m.clearedFields[msg.FieldToid]
  6769. return ok
  6770. }
  6771. // ResetToid resets all changes to the "toid" field.
  6772. func (m *MsgMutation) ResetToid() {
  6773. m.toid = nil
  6774. delete(m.clearedFields, msg.FieldToid)
  6775. }
  6776. // SetMsgtype sets the "msgtype" field.
  6777. func (m *MsgMutation) SetMsgtype(i int32) {
  6778. m.msgtype = &i
  6779. m.addmsgtype = nil
  6780. }
  6781. // Msgtype returns the value of the "msgtype" field in the mutation.
  6782. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  6783. v := m.msgtype
  6784. if v == nil {
  6785. return
  6786. }
  6787. return *v, true
  6788. }
  6789. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  6790. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  6791. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6792. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  6793. if !m.op.Is(OpUpdateOne) {
  6794. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  6795. }
  6796. if m.id == nil || m.oldValue == nil {
  6797. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  6798. }
  6799. oldValue, err := m.oldValue(ctx)
  6800. if err != nil {
  6801. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  6802. }
  6803. return oldValue.Msgtype, nil
  6804. }
  6805. // AddMsgtype adds i to the "msgtype" field.
  6806. func (m *MsgMutation) AddMsgtype(i int32) {
  6807. if m.addmsgtype != nil {
  6808. *m.addmsgtype += i
  6809. } else {
  6810. m.addmsgtype = &i
  6811. }
  6812. }
  6813. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  6814. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  6815. v := m.addmsgtype
  6816. if v == nil {
  6817. return
  6818. }
  6819. return *v, true
  6820. }
  6821. // ClearMsgtype clears the value of the "msgtype" field.
  6822. func (m *MsgMutation) ClearMsgtype() {
  6823. m.msgtype = nil
  6824. m.addmsgtype = nil
  6825. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  6826. }
  6827. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  6828. func (m *MsgMutation) MsgtypeCleared() bool {
  6829. _, ok := m.clearedFields[msg.FieldMsgtype]
  6830. return ok
  6831. }
  6832. // ResetMsgtype resets all changes to the "msgtype" field.
  6833. func (m *MsgMutation) ResetMsgtype() {
  6834. m.msgtype = nil
  6835. m.addmsgtype = nil
  6836. delete(m.clearedFields, msg.FieldMsgtype)
  6837. }
  6838. // SetMsg sets the "msg" field.
  6839. func (m *MsgMutation) SetMsg(s string) {
  6840. m.msg = &s
  6841. }
  6842. // Msg returns the value of the "msg" field in the mutation.
  6843. func (m *MsgMutation) Msg() (r string, exists bool) {
  6844. v := m.msg
  6845. if v == nil {
  6846. return
  6847. }
  6848. return *v, true
  6849. }
  6850. // OldMsg returns the old "msg" field's value of the Msg entity.
  6851. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  6852. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6853. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  6854. if !m.op.Is(OpUpdateOne) {
  6855. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  6856. }
  6857. if m.id == nil || m.oldValue == nil {
  6858. return v, errors.New("OldMsg requires an ID field in the mutation")
  6859. }
  6860. oldValue, err := m.oldValue(ctx)
  6861. if err != nil {
  6862. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  6863. }
  6864. return oldValue.Msg, nil
  6865. }
  6866. // ClearMsg clears the value of the "msg" field.
  6867. func (m *MsgMutation) ClearMsg() {
  6868. m.msg = nil
  6869. m.clearedFields[msg.FieldMsg] = struct{}{}
  6870. }
  6871. // MsgCleared returns if the "msg" field was cleared in this mutation.
  6872. func (m *MsgMutation) MsgCleared() bool {
  6873. _, ok := m.clearedFields[msg.FieldMsg]
  6874. return ok
  6875. }
  6876. // ResetMsg resets all changes to the "msg" field.
  6877. func (m *MsgMutation) ResetMsg() {
  6878. m.msg = nil
  6879. delete(m.clearedFields, msg.FieldMsg)
  6880. }
  6881. // SetBatchNo sets the "batch_no" field.
  6882. func (m *MsgMutation) SetBatchNo(s string) {
  6883. m.batch_no = &s
  6884. }
  6885. // BatchNo returns the value of the "batch_no" field in the mutation.
  6886. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  6887. v := m.batch_no
  6888. if v == nil {
  6889. return
  6890. }
  6891. return *v, true
  6892. }
  6893. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  6894. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  6895. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6896. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  6897. if !m.op.Is(OpUpdateOne) {
  6898. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  6899. }
  6900. if m.id == nil || m.oldValue == nil {
  6901. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  6902. }
  6903. oldValue, err := m.oldValue(ctx)
  6904. if err != nil {
  6905. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  6906. }
  6907. return oldValue.BatchNo, nil
  6908. }
  6909. // ClearBatchNo clears the value of the "batch_no" field.
  6910. func (m *MsgMutation) ClearBatchNo() {
  6911. m.batch_no = nil
  6912. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  6913. }
  6914. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  6915. func (m *MsgMutation) BatchNoCleared() bool {
  6916. _, ok := m.clearedFields[msg.FieldBatchNo]
  6917. return ok
  6918. }
  6919. // ResetBatchNo resets all changes to the "batch_no" field.
  6920. func (m *MsgMutation) ResetBatchNo() {
  6921. m.batch_no = nil
  6922. delete(m.clearedFields, msg.FieldBatchNo)
  6923. }
  6924. // Where appends a list predicates to the MsgMutation builder.
  6925. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  6926. m.predicates = append(m.predicates, ps...)
  6927. }
  6928. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  6929. // users can use type-assertion to append predicates that do not depend on any generated package.
  6930. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  6931. p := make([]predicate.Msg, len(ps))
  6932. for i := range ps {
  6933. p[i] = ps[i]
  6934. }
  6935. m.Where(p...)
  6936. }
  6937. // Op returns the operation name.
  6938. func (m *MsgMutation) Op() Op {
  6939. return m.op
  6940. }
  6941. // SetOp allows setting the mutation operation.
  6942. func (m *MsgMutation) SetOp(op Op) {
  6943. m.op = op
  6944. }
  6945. // Type returns the node type of this mutation (Msg).
  6946. func (m *MsgMutation) Type() string {
  6947. return m.typ
  6948. }
  6949. // Fields returns all fields that were changed during this mutation. Note that in
  6950. // order to get all numeric fields that were incremented/decremented, call
  6951. // AddedFields().
  6952. func (m *MsgMutation) Fields() []string {
  6953. fields := make([]string, 0, 9)
  6954. if m.created_at != nil {
  6955. fields = append(fields, msg.FieldCreatedAt)
  6956. }
  6957. if m.updated_at != nil {
  6958. fields = append(fields, msg.FieldUpdatedAt)
  6959. }
  6960. if m.deleted_at != nil {
  6961. fields = append(fields, msg.FieldDeletedAt)
  6962. }
  6963. if m.status != nil {
  6964. fields = append(fields, msg.FieldStatus)
  6965. }
  6966. if m.fromwxid != nil {
  6967. fields = append(fields, msg.FieldFromwxid)
  6968. }
  6969. if m.toid != nil {
  6970. fields = append(fields, msg.FieldToid)
  6971. }
  6972. if m.msgtype != nil {
  6973. fields = append(fields, msg.FieldMsgtype)
  6974. }
  6975. if m.msg != nil {
  6976. fields = append(fields, msg.FieldMsg)
  6977. }
  6978. if m.batch_no != nil {
  6979. fields = append(fields, msg.FieldBatchNo)
  6980. }
  6981. return fields
  6982. }
  6983. // Field returns the value of a field with the given name. The second boolean
  6984. // return value indicates that this field was not set, or was not defined in the
  6985. // schema.
  6986. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  6987. switch name {
  6988. case msg.FieldCreatedAt:
  6989. return m.CreatedAt()
  6990. case msg.FieldUpdatedAt:
  6991. return m.UpdatedAt()
  6992. case msg.FieldDeletedAt:
  6993. return m.DeletedAt()
  6994. case msg.FieldStatus:
  6995. return m.Status()
  6996. case msg.FieldFromwxid:
  6997. return m.Fromwxid()
  6998. case msg.FieldToid:
  6999. return m.Toid()
  7000. case msg.FieldMsgtype:
  7001. return m.Msgtype()
  7002. case msg.FieldMsg:
  7003. return m.Msg()
  7004. case msg.FieldBatchNo:
  7005. return m.BatchNo()
  7006. }
  7007. return nil, false
  7008. }
  7009. // OldField returns the old value of the field from the database. An error is
  7010. // returned if the mutation operation is not UpdateOne, or the query to the
  7011. // database failed.
  7012. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7013. switch name {
  7014. case msg.FieldCreatedAt:
  7015. return m.OldCreatedAt(ctx)
  7016. case msg.FieldUpdatedAt:
  7017. return m.OldUpdatedAt(ctx)
  7018. case msg.FieldDeletedAt:
  7019. return m.OldDeletedAt(ctx)
  7020. case msg.FieldStatus:
  7021. return m.OldStatus(ctx)
  7022. case msg.FieldFromwxid:
  7023. return m.OldFromwxid(ctx)
  7024. case msg.FieldToid:
  7025. return m.OldToid(ctx)
  7026. case msg.FieldMsgtype:
  7027. return m.OldMsgtype(ctx)
  7028. case msg.FieldMsg:
  7029. return m.OldMsg(ctx)
  7030. case msg.FieldBatchNo:
  7031. return m.OldBatchNo(ctx)
  7032. }
  7033. return nil, fmt.Errorf("unknown Msg field %s", name)
  7034. }
  7035. // SetField sets the value of a field with the given name. It returns an error if
  7036. // the field is not defined in the schema, or if the type mismatched the field
  7037. // type.
  7038. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  7039. switch name {
  7040. case msg.FieldCreatedAt:
  7041. v, ok := value.(time.Time)
  7042. if !ok {
  7043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7044. }
  7045. m.SetCreatedAt(v)
  7046. return nil
  7047. case msg.FieldUpdatedAt:
  7048. v, ok := value.(time.Time)
  7049. if !ok {
  7050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7051. }
  7052. m.SetUpdatedAt(v)
  7053. return nil
  7054. case msg.FieldDeletedAt:
  7055. v, ok := value.(time.Time)
  7056. if !ok {
  7057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7058. }
  7059. m.SetDeletedAt(v)
  7060. return nil
  7061. case msg.FieldStatus:
  7062. v, ok := value.(uint8)
  7063. if !ok {
  7064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7065. }
  7066. m.SetStatus(v)
  7067. return nil
  7068. case msg.FieldFromwxid:
  7069. v, ok := value.(string)
  7070. if !ok {
  7071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7072. }
  7073. m.SetFromwxid(v)
  7074. return nil
  7075. case msg.FieldToid:
  7076. v, ok := value.(string)
  7077. if !ok {
  7078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7079. }
  7080. m.SetToid(v)
  7081. return nil
  7082. case msg.FieldMsgtype:
  7083. v, ok := value.(int32)
  7084. if !ok {
  7085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7086. }
  7087. m.SetMsgtype(v)
  7088. return nil
  7089. case msg.FieldMsg:
  7090. v, ok := value.(string)
  7091. if !ok {
  7092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7093. }
  7094. m.SetMsg(v)
  7095. return nil
  7096. case msg.FieldBatchNo:
  7097. v, ok := value.(string)
  7098. if !ok {
  7099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7100. }
  7101. m.SetBatchNo(v)
  7102. return nil
  7103. }
  7104. return fmt.Errorf("unknown Msg field %s", name)
  7105. }
  7106. // AddedFields returns all numeric fields that were incremented/decremented during
  7107. // this mutation.
  7108. func (m *MsgMutation) AddedFields() []string {
  7109. var fields []string
  7110. if m.addstatus != nil {
  7111. fields = append(fields, msg.FieldStatus)
  7112. }
  7113. if m.addmsgtype != nil {
  7114. fields = append(fields, msg.FieldMsgtype)
  7115. }
  7116. return fields
  7117. }
  7118. // AddedField returns the numeric value that was incremented/decremented on a field
  7119. // with the given name. The second boolean return value indicates that this field
  7120. // was not set, or was not defined in the schema.
  7121. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  7122. switch name {
  7123. case msg.FieldStatus:
  7124. return m.AddedStatus()
  7125. case msg.FieldMsgtype:
  7126. return m.AddedMsgtype()
  7127. }
  7128. return nil, false
  7129. }
  7130. // AddField adds the value to the field with the given name. It returns an error if
  7131. // the field is not defined in the schema, or if the type mismatched the field
  7132. // type.
  7133. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  7134. switch name {
  7135. case msg.FieldStatus:
  7136. v, ok := value.(int8)
  7137. if !ok {
  7138. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7139. }
  7140. m.AddStatus(v)
  7141. return nil
  7142. case msg.FieldMsgtype:
  7143. v, ok := value.(int32)
  7144. if !ok {
  7145. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7146. }
  7147. m.AddMsgtype(v)
  7148. return nil
  7149. }
  7150. return fmt.Errorf("unknown Msg numeric field %s", name)
  7151. }
  7152. // ClearedFields returns all nullable fields that were cleared during this
  7153. // mutation.
  7154. func (m *MsgMutation) ClearedFields() []string {
  7155. var fields []string
  7156. if m.FieldCleared(msg.FieldDeletedAt) {
  7157. fields = append(fields, msg.FieldDeletedAt)
  7158. }
  7159. if m.FieldCleared(msg.FieldStatus) {
  7160. fields = append(fields, msg.FieldStatus)
  7161. }
  7162. if m.FieldCleared(msg.FieldFromwxid) {
  7163. fields = append(fields, msg.FieldFromwxid)
  7164. }
  7165. if m.FieldCleared(msg.FieldToid) {
  7166. fields = append(fields, msg.FieldToid)
  7167. }
  7168. if m.FieldCleared(msg.FieldMsgtype) {
  7169. fields = append(fields, msg.FieldMsgtype)
  7170. }
  7171. if m.FieldCleared(msg.FieldMsg) {
  7172. fields = append(fields, msg.FieldMsg)
  7173. }
  7174. if m.FieldCleared(msg.FieldBatchNo) {
  7175. fields = append(fields, msg.FieldBatchNo)
  7176. }
  7177. return fields
  7178. }
  7179. // FieldCleared returns a boolean indicating if a field with the given name was
  7180. // cleared in this mutation.
  7181. func (m *MsgMutation) FieldCleared(name string) bool {
  7182. _, ok := m.clearedFields[name]
  7183. return ok
  7184. }
  7185. // ClearField clears the value of the field with the given name. It returns an
  7186. // error if the field is not defined in the schema.
  7187. func (m *MsgMutation) ClearField(name string) error {
  7188. switch name {
  7189. case msg.FieldDeletedAt:
  7190. m.ClearDeletedAt()
  7191. return nil
  7192. case msg.FieldStatus:
  7193. m.ClearStatus()
  7194. return nil
  7195. case msg.FieldFromwxid:
  7196. m.ClearFromwxid()
  7197. return nil
  7198. case msg.FieldToid:
  7199. m.ClearToid()
  7200. return nil
  7201. case msg.FieldMsgtype:
  7202. m.ClearMsgtype()
  7203. return nil
  7204. case msg.FieldMsg:
  7205. m.ClearMsg()
  7206. return nil
  7207. case msg.FieldBatchNo:
  7208. m.ClearBatchNo()
  7209. return nil
  7210. }
  7211. return fmt.Errorf("unknown Msg nullable field %s", name)
  7212. }
  7213. // ResetField resets all changes in the mutation for the field with the given name.
  7214. // It returns an error if the field is not defined in the schema.
  7215. func (m *MsgMutation) ResetField(name string) error {
  7216. switch name {
  7217. case msg.FieldCreatedAt:
  7218. m.ResetCreatedAt()
  7219. return nil
  7220. case msg.FieldUpdatedAt:
  7221. m.ResetUpdatedAt()
  7222. return nil
  7223. case msg.FieldDeletedAt:
  7224. m.ResetDeletedAt()
  7225. return nil
  7226. case msg.FieldStatus:
  7227. m.ResetStatus()
  7228. return nil
  7229. case msg.FieldFromwxid:
  7230. m.ResetFromwxid()
  7231. return nil
  7232. case msg.FieldToid:
  7233. m.ResetToid()
  7234. return nil
  7235. case msg.FieldMsgtype:
  7236. m.ResetMsgtype()
  7237. return nil
  7238. case msg.FieldMsg:
  7239. m.ResetMsg()
  7240. return nil
  7241. case msg.FieldBatchNo:
  7242. m.ResetBatchNo()
  7243. return nil
  7244. }
  7245. return fmt.Errorf("unknown Msg field %s", name)
  7246. }
  7247. // AddedEdges returns all edge names that were set/added in this mutation.
  7248. func (m *MsgMutation) AddedEdges() []string {
  7249. edges := make([]string, 0, 0)
  7250. return edges
  7251. }
  7252. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7253. // name in this mutation.
  7254. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  7255. return nil
  7256. }
  7257. // RemovedEdges returns all edge names that were removed in this mutation.
  7258. func (m *MsgMutation) RemovedEdges() []string {
  7259. edges := make([]string, 0, 0)
  7260. return edges
  7261. }
  7262. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7263. // the given name in this mutation.
  7264. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  7265. return nil
  7266. }
  7267. // ClearedEdges returns all edge names that were cleared in this mutation.
  7268. func (m *MsgMutation) ClearedEdges() []string {
  7269. edges := make([]string, 0, 0)
  7270. return edges
  7271. }
  7272. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7273. // was cleared in this mutation.
  7274. func (m *MsgMutation) EdgeCleared(name string) bool {
  7275. return false
  7276. }
  7277. // ClearEdge clears the value of the edge with the given name. It returns an error
  7278. // if that edge is not defined in the schema.
  7279. func (m *MsgMutation) ClearEdge(name string) error {
  7280. return fmt.Errorf("unknown Msg unique edge %s", name)
  7281. }
  7282. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7283. // It returns an error if the edge is not defined in the schema.
  7284. func (m *MsgMutation) ResetEdge(name string) error {
  7285. return fmt.Errorf("unknown Msg edge %s", name)
  7286. }
  7287. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  7288. type ServerMutation struct {
  7289. config
  7290. op Op
  7291. typ string
  7292. id *uint64
  7293. created_at *time.Time
  7294. updated_at *time.Time
  7295. status *uint8
  7296. addstatus *int8
  7297. deleted_at *time.Time
  7298. name *string
  7299. public_ip *string
  7300. private_ip *string
  7301. admin_port *string
  7302. clearedFields map[string]struct{}
  7303. wxs map[uint64]struct{}
  7304. removedwxs map[uint64]struct{}
  7305. clearedwxs bool
  7306. done bool
  7307. oldValue func(context.Context) (*Server, error)
  7308. predicates []predicate.Server
  7309. }
  7310. var _ ent.Mutation = (*ServerMutation)(nil)
  7311. // serverOption allows management of the mutation configuration using functional options.
  7312. type serverOption func(*ServerMutation)
  7313. // newServerMutation creates new mutation for the Server entity.
  7314. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  7315. m := &ServerMutation{
  7316. config: c,
  7317. op: op,
  7318. typ: TypeServer,
  7319. clearedFields: make(map[string]struct{}),
  7320. }
  7321. for _, opt := range opts {
  7322. opt(m)
  7323. }
  7324. return m
  7325. }
  7326. // withServerID sets the ID field of the mutation.
  7327. func withServerID(id uint64) serverOption {
  7328. return func(m *ServerMutation) {
  7329. var (
  7330. err error
  7331. once sync.Once
  7332. value *Server
  7333. )
  7334. m.oldValue = func(ctx context.Context) (*Server, error) {
  7335. once.Do(func() {
  7336. if m.done {
  7337. err = errors.New("querying old values post mutation is not allowed")
  7338. } else {
  7339. value, err = m.Client().Server.Get(ctx, id)
  7340. }
  7341. })
  7342. return value, err
  7343. }
  7344. m.id = &id
  7345. }
  7346. }
  7347. // withServer sets the old Server of the mutation.
  7348. func withServer(node *Server) serverOption {
  7349. return func(m *ServerMutation) {
  7350. m.oldValue = func(context.Context) (*Server, error) {
  7351. return node, nil
  7352. }
  7353. m.id = &node.ID
  7354. }
  7355. }
  7356. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7357. // executed in a transaction (ent.Tx), a transactional client is returned.
  7358. func (m ServerMutation) Client() *Client {
  7359. client := &Client{config: m.config}
  7360. client.init()
  7361. return client
  7362. }
  7363. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7364. // it returns an error otherwise.
  7365. func (m ServerMutation) Tx() (*Tx, error) {
  7366. if _, ok := m.driver.(*txDriver); !ok {
  7367. return nil, errors.New("ent: mutation is not running in a transaction")
  7368. }
  7369. tx := &Tx{config: m.config}
  7370. tx.init()
  7371. return tx, nil
  7372. }
  7373. // SetID sets the value of the id field. Note that this
  7374. // operation is only accepted on creation of Server entities.
  7375. func (m *ServerMutation) SetID(id uint64) {
  7376. m.id = &id
  7377. }
  7378. // ID returns the ID value in the mutation. Note that the ID is only available
  7379. // if it was provided to the builder or after it was returned from the database.
  7380. func (m *ServerMutation) ID() (id uint64, exists bool) {
  7381. if m.id == nil {
  7382. return
  7383. }
  7384. return *m.id, true
  7385. }
  7386. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7387. // That means, if the mutation is applied within a transaction with an isolation level such
  7388. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7389. // or updated by the mutation.
  7390. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  7391. switch {
  7392. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7393. id, exists := m.ID()
  7394. if exists {
  7395. return []uint64{id}, nil
  7396. }
  7397. fallthrough
  7398. case m.op.Is(OpUpdate | OpDelete):
  7399. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  7400. default:
  7401. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7402. }
  7403. }
  7404. // SetCreatedAt sets the "created_at" field.
  7405. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  7406. m.created_at = &t
  7407. }
  7408. // CreatedAt returns the value of the "created_at" field in the mutation.
  7409. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  7410. v := m.created_at
  7411. if v == nil {
  7412. return
  7413. }
  7414. return *v, true
  7415. }
  7416. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  7417. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  7418. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7419. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7420. if !m.op.Is(OpUpdateOne) {
  7421. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7422. }
  7423. if m.id == nil || m.oldValue == nil {
  7424. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7425. }
  7426. oldValue, err := m.oldValue(ctx)
  7427. if err != nil {
  7428. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7429. }
  7430. return oldValue.CreatedAt, nil
  7431. }
  7432. // ResetCreatedAt resets all changes to the "created_at" field.
  7433. func (m *ServerMutation) ResetCreatedAt() {
  7434. m.created_at = nil
  7435. }
  7436. // SetUpdatedAt sets the "updated_at" field.
  7437. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  7438. m.updated_at = &t
  7439. }
  7440. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7441. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  7442. v := m.updated_at
  7443. if v == nil {
  7444. return
  7445. }
  7446. return *v, true
  7447. }
  7448. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  7449. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  7450. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7451. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7452. if !m.op.Is(OpUpdateOne) {
  7453. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7454. }
  7455. if m.id == nil || m.oldValue == nil {
  7456. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7457. }
  7458. oldValue, err := m.oldValue(ctx)
  7459. if err != nil {
  7460. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7461. }
  7462. return oldValue.UpdatedAt, nil
  7463. }
  7464. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7465. func (m *ServerMutation) ResetUpdatedAt() {
  7466. m.updated_at = nil
  7467. }
  7468. // SetStatus sets the "status" field.
  7469. func (m *ServerMutation) SetStatus(u uint8) {
  7470. m.status = &u
  7471. m.addstatus = nil
  7472. }
  7473. // Status returns the value of the "status" field in the mutation.
  7474. func (m *ServerMutation) Status() (r uint8, exists bool) {
  7475. v := m.status
  7476. if v == nil {
  7477. return
  7478. }
  7479. return *v, true
  7480. }
  7481. // OldStatus returns the old "status" field's value of the Server entity.
  7482. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  7483. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7484. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7485. if !m.op.Is(OpUpdateOne) {
  7486. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7487. }
  7488. if m.id == nil || m.oldValue == nil {
  7489. return v, errors.New("OldStatus requires an ID field in the mutation")
  7490. }
  7491. oldValue, err := m.oldValue(ctx)
  7492. if err != nil {
  7493. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7494. }
  7495. return oldValue.Status, nil
  7496. }
  7497. // AddStatus adds u to the "status" field.
  7498. func (m *ServerMutation) AddStatus(u int8) {
  7499. if m.addstatus != nil {
  7500. *m.addstatus += u
  7501. } else {
  7502. m.addstatus = &u
  7503. }
  7504. }
  7505. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7506. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  7507. v := m.addstatus
  7508. if v == nil {
  7509. return
  7510. }
  7511. return *v, true
  7512. }
  7513. // ClearStatus clears the value of the "status" field.
  7514. func (m *ServerMutation) ClearStatus() {
  7515. m.status = nil
  7516. m.addstatus = nil
  7517. m.clearedFields[server.FieldStatus] = struct{}{}
  7518. }
  7519. // StatusCleared returns if the "status" field was cleared in this mutation.
  7520. func (m *ServerMutation) StatusCleared() bool {
  7521. _, ok := m.clearedFields[server.FieldStatus]
  7522. return ok
  7523. }
  7524. // ResetStatus resets all changes to the "status" field.
  7525. func (m *ServerMutation) ResetStatus() {
  7526. m.status = nil
  7527. m.addstatus = nil
  7528. delete(m.clearedFields, server.FieldStatus)
  7529. }
  7530. // SetDeletedAt sets the "deleted_at" field.
  7531. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  7532. m.deleted_at = &t
  7533. }
  7534. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7535. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  7536. v := m.deleted_at
  7537. if v == nil {
  7538. return
  7539. }
  7540. return *v, true
  7541. }
  7542. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  7543. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  7544. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7545. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7546. if !m.op.Is(OpUpdateOne) {
  7547. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7548. }
  7549. if m.id == nil || m.oldValue == nil {
  7550. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7551. }
  7552. oldValue, err := m.oldValue(ctx)
  7553. if err != nil {
  7554. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7555. }
  7556. return oldValue.DeletedAt, nil
  7557. }
  7558. // ClearDeletedAt clears the value of the "deleted_at" field.
  7559. func (m *ServerMutation) ClearDeletedAt() {
  7560. m.deleted_at = nil
  7561. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  7562. }
  7563. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7564. func (m *ServerMutation) DeletedAtCleared() bool {
  7565. _, ok := m.clearedFields[server.FieldDeletedAt]
  7566. return ok
  7567. }
  7568. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7569. func (m *ServerMutation) ResetDeletedAt() {
  7570. m.deleted_at = nil
  7571. delete(m.clearedFields, server.FieldDeletedAt)
  7572. }
  7573. // SetName sets the "name" field.
  7574. func (m *ServerMutation) SetName(s string) {
  7575. m.name = &s
  7576. }
  7577. // Name returns the value of the "name" field in the mutation.
  7578. func (m *ServerMutation) Name() (r string, exists bool) {
  7579. v := m.name
  7580. if v == nil {
  7581. return
  7582. }
  7583. return *v, true
  7584. }
  7585. // OldName returns the old "name" field's value of the Server entity.
  7586. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  7587. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7588. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  7589. if !m.op.Is(OpUpdateOne) {
  7590. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7591. }
  7592. if m.id == nil || m.oldValue == nil {
  7593. return v, errors.New("OldName requires an ID field in the mutation")
  7594. }
  7595. oldValue, err := m.oldValue(ctx)
  7596. if err != nil {
  7597. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7598. }
  7599. return oldValue.Name, nil
  7600. }
  7601. // ResetName resets all changes to the "name" field.
  7602. func (m *ServerMutation) ResetName() {
  7603. m.name = nil
  7604. }
  7605. // SetPublicIP sets the "public_ip" field.
  7606. func (m *ServerMutation) SetPublicIP(s string) {
  7607. m.public_ip = &s
  7608. }
  7609. // PublicIP returns the value of the "public_ip" field in the mutation.
  7610. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  7611. v := m.public_ip
  7612. if v == nil {
  7613. return
  7614. }
  7615. return *v, true
  7616. }
  7617. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  7618. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  7619. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7620. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  7621. if !m.op.Is(OpUpdateOne) {
  7622. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  7623. }
  7624. if m.id == nil || m.oldValue == nil {
  7625. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  7626. }
  7627. oldValue, err := m.oldValue(ctx)
  7628. if err != nil {
  7629. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  7630. }
  7631. return oldValue.PublicIP, nil
  7632. }
  7633. // ResetPublicIP resets all changes to the "public_ip" field.
  7634. func (m *ServerMutation) ResetPublicIP() {
  7635. m.public_ip = nil
  7636. }
  7637. // SetPrivateIP sets the "private_ip" field.
  7638. func (m *ServerMutation) SetPrivateIP(s string) {
  7639. m.private_ip = &s
  7640. }
  7641. // PrivateIP returns the value of the "private_ip" field in the mutation.
  7642. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  7643. v := m.private_ip
  7644. if v == nil {
  7645. return
  7646. }
  7647. return *v, true
  7648. }
  7649. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  7650. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  7651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7652. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  7653. if !m.op.Is(OpUpdateOne) {
  7654. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  7655. }
  7656. if m.id == nil || m.oldValue == nil {
  7657. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  7658. }
  7659. oldValue, err := m.oldValue(ctx)
  7660. if err != nil {
  7661. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  7662. }
  7663. return oldValue.PrivateIP, nil
  7664. }
  7665. // ResetPrivateIP resets all changes to the "private_ip" field.
  7666. func (m *ServerMutation) ResetPrivateIP() {
  7667. m.private_ip = nil
  7668. }
  7669. // SetAdminPort sets the "admin_port" field.
  7670. func (m *ServerMutation) SetAdminPort(s string) {
  7671. m.admin_port = &s
  7672. }
  7673. // AdminPort returns the value of the "admin_port" field in the mutation.
  7674. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  7675. v := m.admin_port
  7676. if v == nil {
  7677. return
  7678. }
  7679. return *v, true
  7680. }
  7681. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  7682. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  7683. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7684. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  7685. if !m.op.Is(OpUpdateOne) {
  7686. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  7687. }
  7688. if m.id == nil || m.oldValue == nil {
  7689. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  7690. }
  7691. oldValue, err := m.oldValue(ctx)
  7692. if err != nil {
  7693. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  7694. }
  7695. return oldValue.AdminPort, nil
  7696. }
  7697. // ResetAdminPort resets all changes to the "admin_port" field.
  7698. func (m *ServerMutation) ResetAdminPort() {
  7699. m.admin_port = nil
  7700. }
  7701. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  7702. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  7703. if m.wxs == nil {
  7704. m.wxs = make(map[uint64]struct{})
  7705. }
  7706. for i := range ids {
  7707. m.wxs[ids[i]] = struct{}{}
  7708. }
  7709. }
  7710. // ClearWxs clears the "wxs" edge to the Wx entity.
  7711. func (m *ServerMutation) ClearWxs() {
  7712. m.clearedwxs = true
  7713. }
  7714. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  7715. func (m *ServerMutation) WxsCleared() bool {
  7716. return m.clearedwxs
  7717. }
  7718. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  7719. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  7720. if m.removedwxs == nil {
  7721. m.removedwxs = make(map[uint64]struct{})
  7722. }
  7723. for i := range ids {
  7724. delete(m.wxs, ids[i])
  7725. m.removedwxs[ids[i]] = struct{}{}
  7726. }
  7727. }
  7728. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  7729. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  7730. for id := range m.removedwxs {
  7731. ids = append(ids, id)
  7732. }
  7733. return
  7734. }
  7735. // WxsIDs returns the "wxs" edge IDs in the mutation.
  7736. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  7737. for id := range m.wxs {
  7738. ids = append(ids, id)
  7739. }
  7740. return
  7741. }
  7742. // ResetWxs resets all changes to the "wxs" edge.
  7743. func (m *ServerMutation) ResetWxs() {
  7744. m.wxs = nil
  7745. m.clearedwxs = false
  7746. m.removedwxs = nil
  7747. }
  7748. // Where appends a list predicates to the ServerMutation builder.
  7749. func (m *ServerMutation) Where(ps ...predicate.Server) {
  7750. m.predicates = append(m.predicates, ps...)
  7751. }
  7752. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  7753. // users can use type-assertion to append predicates that do not depend on any generated package.
  7754. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  7755. p := make([]predicate.Server, len(ps))
  7756. for i := range ps {
  7757. p[i] = ps[i]
  7758. }
  7759. m.Where(p...)
  7760. }
  7761. // Op returns the operation name.
  7762. func (m *ServerMutation) Op() Op {
  7763. return m.op
  7764. }
  7765. // SetOp allows setting the mutation operation.
  7766. func (m *ServerMutation) SetOp(op Op) {
  7767. m.op = op
  7768. }
  7769. // Type returns the node type of this mutation (Server).
  7770. func (m *ServerMutation) Type() string {
  7771. return m.typ
  7772. }
  7773. // Fields returns all fields that were changed during this mutation. Note that in
  7774. // order to get all numeric fields that were incremented/decremented, call
  7775. // AddedFields().
  7776. func (m *ServerMutation) Fields() []string {
  7777. fields := make([]string, 0, 8)
  7778. if m.created_at != nil {
  7779. fields = append(fields, server.FieldCreatedAt)
  7780. }
  7781. if m.updated_at != nil {
  7782. fields = append(fields, server.FieldUpdatedAt)
  7783. }
  7784. if m.status != nil {
  7785. fields = append(fields, server.FieldStatus)
  7786. }
  7787. if m.deleted_at != nil {
  7788. fields = append(fields, server.FieldDeletedAt)
  7789. }
  7790. if m.name != nil {
  7791. fields = append(fields, server.FieldName)
  7792. }
  7793. if m.public_ip != nil {
  7794. fields = append(fields, server.FieldPublicIP)
  7795. }
  7796. if m.private_ip != nil {
  7797. fields = append(fields, server.FieldPrivateIP)
  7798. }
  7799. if m.admin_port != nil {
  7800. fields = append(fields, server.FieldAdminPort)
  7801. }
  7802. return fields
  7803. }
  7804. // Field returns the value of a field with the given name. The second boolean
  7805. // return value indicates that this field was not set, or was not defined in the
  7806. // schema.
  7807. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  7808. switch name {
  7809. case server.FieldCreatedAt:
  7810. return m.CreatedAt()
  7811. case server.FieldUpdatedAt:
  7812. return m.UpdatedAt()
  7813. case server.FieldStatus:
  7814. return m.Status()
  7815. case server.FieldDeletedAt:
  7816. return m.DeletedAt()
  7817. case server.FieldName:
  7818. return m.Name()
  7819. case server.FieldPublicIP:
  7820. return m.PublicIP()
  7821. case server.FieldPrivateIP:
  7822. return m.PrivateIP()
  7823. case server.FieldAdminPort:
  7824. return m.AdminPort()
  7825. }
  7826. return nil, false
  7827. }
  7828. // OldField returns the old value of the field from the database. An error is
  7829. // returned if the mutation operation is not UpdateOne, or the query to the
  7830. // database failed.
  7831. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7832. switch name {
  7833. case server.FieldCreatedAt:
  7834. return m.OldCreatedAt(ctx)
  7835. case server.FieldUpdatedAt:
  7836. return m.OldUpdatedAt(ctx)
  7837. case server.FieldStatus:
  7838. return m.OldStatus(ctx)
  7839. case server.FieldDeletedAt:
  7840. return m.OldDeletedAt(ctx)
  7841. case server.FieldName:
  7842. return m.OldName(ctx)
  7843. case server.FieldPublicIP:
  7844. return m.OldPublicIP(ctx)
  7845. case server.FieldPrivateIP:
  7846. return m.OldPrivateIP(ctx)
  7847. case server.FieldAdminPort:
  7848. return m.OldAdminPort(ctx)
  7849. }
  7850. return nil, fmt.Errorf("unknown Server field %s", name)
  7851. }
  7852. // SetField sets the value of a field with the given name. It returns an error if
  7853. // the field is not defined in the schema, or if the type mismatched the field
  7854. // type.
  7855. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  7856. switch name {
  7857. case server.FieldCreatedAt:
  7858. v, ok := value.(time.Time)
  7859. if !ok {
  7860. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7861. }
  7862. m.SetCreatedAt(v)
  7863. return nil
  7864. case server.FieldUpdatedAt:
  7865. v, ok := value.(time.Time)
  7866. if !ok {
  7867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7868. }
  7869. m.SetUpdatedAt(v)
  7870. return nil
  7871. case server.FieldStatus:
  7872. v, ok := value.(uint8)
  7873. if !ok {
  7874. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7875. }
  7876. m.SetStatus(v)
  7877. return nil
  7878. case server.FieldDeletedAt:
  7879. v, ok := value.(time.Time)
  7880. if !ok {
  7881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7882. }
  7883. m.SetDeletedAt(v)
  7884. return nil
  7885. case server.FieldName:
  7886. v, ok := value.(string)
  7887. if !ok {
  7888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7889. }
  7890. m.SetName(v)
  7891. return nil
  7892. case server.FieldPublicIP:
  7893. v, ok := value.(string)
  7894. if !ok {
  7895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7896. }
  7897. m.SetPublicIP(v)
  7898. return nil
  7899. case server.FieldPrivateIP:
  7900. v, ok := value.(string)
  7901. if !ok {
  7902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7903. }
  7904. m.SetPrivateIP(v)
  7905. return nil
  7906. case server.FieldAdminPort:
  7907. v, ok := value.(string)
  7908. if !ok {
  7909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7910. }
  7911. m.SetAdminPort(v)
  7912. return nil
  7913. }
  7914. return fmt.Errorf("unknown Server field %s", name)
  7915. }
  7916. // AddedFields returns all numeric fields that were incremented/decremented during
  7917. // this mutation.
  7918. func (m *ServerMutation) AddedFields() []string {
  7919. var fields []string
  7920. if m.addstatus != nil {
  7921. fields = append(fields, server.FieldStatus)
  7922. }
  7923. return fields
  7924. }
  7925. // AddedField returns the numeric value that was incremented/decremented on a field
  7926. // with the given name. The second boolean return value indicates that this field
  7927. // was not set, or was not defined in the schema.
  7928. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  7929. switch name {
  7930. case server.FieldStatus:
  7931. return m.AddedStatus()
  7932. }
  7933. return nil, false
  7934. }
  7935. // AddField adds the value to the field with the given name. It returns an error if
  7936. // the field is not defined in the schema, or if the type mismatched the field
  7937. // type.
  7938. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  7939. switch name {
  7940. case server.FieldStatus:
  7941. v, ok := value.(int8)
  7942. if !ok {
  7943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7944. }
  7945. m.AddStatus(v)
  7946. return nil
  7947. }
  7948. return fmt.Errorf("unknown Server numeric field %s", name)
  7949. }
  7950. // ClearedFields returns all nullable fields that were cleared during this
  7951. // mutation.
  7952. func (m *ServerMutation) ClearedFields() []string {
  7953. var fields []string
  7954. if m.FieldCleared(server.FieldStatus) {
  7955. fields = append(fields, server.FieldStatus)
  7956. }
  7957. if m.FieldCleared(server.FieldDeletedAt) {
  7958. fields = append(fields, server.FieldDeletedAt)
  7959. }
  7960. return fields
  7961. }
  7962. // FieldCleared returns a boolean indicating if a field with the given name was
  7963. // cleared in this mutation.
  7964. func (m *ServerMutation) FieldCleared(name string) bool {
  7965. _, ok := m.clearedFields[name]
  7966. return ok
  7967. }
  7968. // ClearField clears the value of the field with the given name. It returns an
  7969. // error if the field is not defined in the schema.
  7970. func (m *ServerMutation) ClearField(name string) error {
  7971. switch name {
  7972. case server.FieldStatus:
  7973. m.ClearStatus()
  7974. return nil
  7975. case server.FieldDeletedAt:
  7976. m.ClearDeletedAt()
  7977. return nil
  7978. }
  7979. return fmt.Errorf("unknown Server nullable field %s", name)
  7980. }
  7981. // ResetField resets all changes in the mutation for the field with the given name.
  7982. // It returns an error if the field is not defined in the schema.
  7983. func (m *ServerMutation) ResetField(name string) error {
  7984. switch name {
  7985. case server.FieldCreatedAt:
  7986. m.ResetCreatedAt()
  7987. return nil
  7988. case server.FieldUpdatedAt:
  7989. m.ResetUpdatedAt()
  7990. return nil
  7991. case server.FieldStatus:
  7992. m.ResetStatus()
  7993. return nil
  7994. case server.FieldDeletedAt:
  7995. m.ResetDeletedAt()
  7996. return nil
  7997. case server.FieldName:
  7998. m.ResetName()
  7999. return nil
  8000. case server.FieldPublicIP:
  8001. m.ResetPublicIP()
  8002. return nil
  8003. case server.FieldPrivateIP:
  8004. m.ResetPrivateIP()
  8005. return nil
  8006. case server.FieldAdminPort:
  8007. m.ResetAdminPort()
  8008. return nil
  8009. }
  8010. return fmt.Errorf("unknown Server field %s", name)
  8011. }
  8012. // AddedEdges returns all edge names that were set/added in this mutation.
  8013. func (m *ServerMutation) AddedEdges() []string {
  8014. edges := make([]string, 0, 1)
  8015. if m.wxs != nil {
  8016. edges = append(edges, server.EdgeWxs)
  8017. }
  8018. return edges
  8019. }
  8020. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8021. // name in this mutation.
  8022. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  8023. switch name {
  8024. case server.EdgeWxs:
  8025. ids := make([]ent.Value, 0, len(m.wxs))
  8026. for id := range m.wxs {
  8027. ids = append(ids, id)
  8028. }
  8029. return ids
  8030. }
  8031. return nil
  8032. }
  8033. // RemovedEdges returns all edge names that were removed in this mutation.
  8034. func (m *ServerMutation) RemovedEdges() []string {
  8035. edges := make([]string, 0, 1)
  8036. if m.removedwxs != nil {
  8037. edges = append(edges, server.EdgeWxs)
  8038. }
  8039. return edges
  8040. }
  8041. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8042. // the given name in this mutation.
  8043. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  8044. switch name {
  8045. case server.EdgeWxs:
  8046. ids := make([]ent.Value, 0, len(m.removedwxs))
  8047. for id := range m.removedwxs {
  8048. ids = append(ids, id)
  8049. }
  8050. return ids
  8051. }
  8052. return nil
  8053. }
  8054. // ClearedEdges returns all edge names that were cleared in this mutation.
  8055. func (m *ServerMutation) ClearedEdges() []string {
  8056. edges := make([]string, 0, 1)
  8057. if m.clearedwxs {
  8058. edges = append(edges, server.EdgeWxs)
  8059. }
  8060. return edges
  8061. }
  8062. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8063. // was cleared in this mutation.
  8064. func (m *ServerMutation) EdgeCleared(name string) bool {
  8065. switch name {
  8066. case server.EdgeWxs:
  8067. return m.clearedwxs
  8068. }
  8069. return false
  8070. }
  8071. // ClearEdge clears the value of the edge with the given name. It returns an error
  8072. // if that edge is not defined in the schema.
  8073. func (m *ServerMutation) ClearEdge(name string) error {
  8074. switch name {
  8075. }
  8076. return fmt.Errorf("unknown Server unique edge %s", name)
  8077. }
  8078. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8079. // It returns an error if the edge is not defined in the schema.
  8080. func (m *ServerMutation) ResetEdge(name string) error {
  8081. switch name {
  8082. case server.EdgeWxs:
  8083. m.ResetWxs()
  8084. return nil
  8085. }
  8086. return fmt.Errorf("unknown Server edge %s", name)
  8087. }
  8088. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  8089. type SopNodeMutation struct {
  8090. config
  8091. op Op
  8092. typ string
  8093. id *uint64
  8094. created_at *time.Time
  8095. updated_at *time.Time
  8096. status *uint8
  8097. addstatus *int8
  8098. deleted_at *time.Time
  8099. parent_id *uint64
  8100. addparent_id *int64
  8101. name *string
  8102. condition_type *int
  8103. addcondition_type *int
  8104. condition_list *[]string
  8105. appendcondition_list []string
  8106. no_reply_condition *uint64
  8107. addno_reply_condition *int64
  8108. action_message *[]custom_types.Action
  8109. appendaction_message []custom_types.Action
  8110. action_label *[]uint64
  8111. appendaction_label []uint64
  8112. clearedFields map[string]struct{}
  8113. sop_stage *uint64
  8114. clearedsop_stage bool
  8115. node_messages map[uint64]struct{}
  8116. removednode_messages map[uint64]struct{}
  8117. clearednode_messages bool
  8118. done bool
  8119. oldValue func(context.Context) (*SopNode, error)
  8120. predicates []predicate.SopNode
  8121. }
  8122. var _ ent.Mutation = (*SopNodeMutation)(nil)
  8123. // sopnodeOption allows management of the mutation configuration using functional options.
  8124. type sopnodeOption func(*SopNodeMutation)
  8125. // newSopNodeMutation creates new mutation for the SopNode entity.
  8126. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  8127. m := &SopNodeMutation{
  8128. config: c,
  8129. op: op,
  8130. typ: TypeSopNode,
  8131. clearedFields: make(map[string]struct{}),
  8132. }
  8133. for _, opt := range opts {
  8134. opt(m)
  8135. }
  8136. return m
  8137. }
  8138. // withSopNodeID sets the ID field of the mutation.
  8139. func withSopNodeID(id uint64) sopnodeOption {
  8140. return func(m *SopNodeMutation) {
  8141. var (
  8142. err error
  8143. once sync.Once
  8144. value *SopNode
  8145. )
  8146. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  8147. once.Do(func() {
  8148. if m.done {
  8149. err = errors.New("querying old values post mutation is not allowed")
  8150. } else {
  8151. value, err = m.Client().SopNode.Get(ctx, id)
  8152. }
  8153. })
  8154. return value, err
  8155. }
  8156. m.id = &id
  8157. }
  8158. }
  8159. // withSopNode sets the old SopNode of the mutation.
  8160. func withSopNode(node *SopNode) sopnodeOption {
  8161. return func(m *SopNodeMutation) {
  8162. m.oldValue = func(context.Context) (*SopNode, error) {
  8163. return node, nil
  8164. }
  8165. m.id = &node.ID
  8166. }
  8167. }
  8168. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8169. // executed in a transaction (ent.Tx), a transactional client is returned.
  8170. func (m SopNodeMutation) Client() *Client {
  8171. client := &Client{config: m.config}
  8172. client.init()
  8173. return client
  8174. }
  8175. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8176. // it returns an error otherwise.
  8177. func (m SopNodeMutation) Tx() (*Tx, error) {
  8178. if _, ok := m.driver.(*txDriver); !ok {
  8179. return nil, errors.New("ent: mutation is not running in a transaction")
  8180. }
  8181. tx := &Tx{config: m.config}
  8182. tx.init()
  8183. return tx, nil
  8184. }
  8185. // SetID sets the value of the id field. Note that this
  8186. // operation is only accepted on creation of SopNode entities.
  8187. func (m *SopNodeMutation) SetID(id uint64) {
  8188. m.id = &id
  8189. }
  8190. // ID returns the ID value in the mutation. Note that the ID is only available
  8191. // if it was provided to the builder or after it was returned from the database.
  8192. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  8193. if m.id == nil {
  8194. return
  8195. }
  8196. return *m.id, true
  8197. }
  8198. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8199. // That means, if the mutation is applied within a transaction with an isolation level such
  8200. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8201. // or updated by the mutation.
  8202. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  8203. switch {
  8204. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8205. id, exists := m.ID()
  8206. if exists {
  8207. return []uint64{id}, nil
  8208. }
  8209. fallthrough
  8210. case m.op.Is(OpUpdate | OpDelete):
  8211. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  8212. default:
  8213. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8214. }
  8215. }
  8216. // SetCreatedAt sets the "created_at" field.
  8217. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  8218. m.created_at = &t
  8219. }
  8220. // CreatedAt returns the value of the "created_at" field in the mutation.
  8221. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  8222. v := m.created_at
  8223. if v == nil {
  8224. return
  8225. }
  8226. return *v, true
  8227. }
  8228. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  8229. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  8230. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8231. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8232. if !m.op.Is(OpUpdateOne) {
  8233. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8234. }
  8235. if m.id == nil || m.oldValue == nil {
  8236. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8237. }
  8238. oldValue, err := m.oldValue(ctx)
  8239. if err != nil {
  8240. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8241. }
  8242. return oldValue.CreatedAt, nil
  8243. }
  8244. // ResetCreatedAt resets all changes to the "created_at" field.
  8245. func (m *SopNodeMutation) ResetCreatedAt() {
  8246. m.created_at = nil
  8247. }
  8248. // SetUpdatedAt sets the "updated_at" field.
  8249. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  8250. m.updated_at = &t
  8251. }
  8252. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8253. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  8254. v := m.updated_at
  8255. if v == nil {
  8256. return
  8257. }
  8258. return *v, true
  8259. }
  8260. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  8261. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  8262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8263. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8264. if !m.op.Is(OpUpdateOne) {
  8265. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8266. }
  8267. if m.id == nil || m.oldValue == nil {
  8268. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8269. }
  8270. oldValue, err := m.oldValue(ctx)
  8271. if err != nil {
  8272. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8273. }
  8274. return oldValue.UpdatedAt, nil
  8275. }
  8276. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8277. func (m *SopNodeMutation) ResetUpdatedAt() {
  8278. m.updated_at = nil
  8279. }
  8280. // SetStatus sets the "status" field.
  8281. func (m *SopNodeMutation) SetStatus(u uint8) {
  8282. m.status = &u
  8283. m.addstatus = nil
  8284. }
  8285. // Status returns the value of the "status" field in the mutation.
  8286. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  8287. v := m.status
  8288. if v == nil {
  8289. return
  8290. }
  8291. return *v, true
  8292. }
  8293. // OldStatus returns the old "status" field's value of the SopNode entity.
  8294. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  8295. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8296. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  8297. if !m.op.Is(OpUpdateOne) {
  8298. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  8299. }
  8300. if m.id == nil || m.oldValue == nil {
  8301. return v, errors.New("OldStatus requires an ID field in the mutation")
  8302. }
  8303. oldValue, err := m.oldValue(ctx)
  8304. if err != nil {
  8305. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  8306. }
  8307. return oldValue.Status, nil
  8308. }
  8309. // AddStatus adds u to the "status" field.
  8310. func (m *SopNodeMutation) AddStatus(u int8) {
  8311. if m.addstatus != nil {
  8312. *m.addstatus += u
  8313. } else {
  8314. m.addstatus = &u
  8315. }
  8316. }
  8317. // AddedStatus returns the value that was added to the "status" field in this mutation.
  8318. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  8319. v := m.addstatus
  8320. if v == nil {
  8321. return
  8322. }
  8323. return *v, true
  8324. }
  8325. // ClearStatus clears the value of the "status" field.
  8326. func (m *SopNodeMutation) ClearStatus() {
  8327. m.status = nil
  8328. m.addstatus = nil
  8329. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  8330. }
  8331. // StatusCleared returns if the "status" field was cleared in this mutation.
  8332. func (m *SopNodeMutation) StatusCleared() bool {
  8333. _, ok := m.clearedFields[sopnode.FieldStatus]
  8334. return ok
  8335. }
  8336. // ResetStatus resets all changes to the "status" field.
  8337. func (m *SopNodeMutation) ResetStatus() {
  8338. m.status = nil
  8339. m.addstatus = nil
  8340. delete(m.clearedFields, sopnode.FieldStatus)
  8341. }
  8342. // SetDeletedAt sets the "deleted_at" field.
  8343. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  8344. m.deleted_at = &t
  8345. }
  8346. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8347. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  8348. v := m.deleted_at
  8349. if v == nil {
  8350. return
  8351. }
  8352. return *v, true
  8353. }
  8354. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  8355. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  8356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8357. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8358. if !m.op.Is(OpUpdateOne) {
  8359. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8360. }
  8361. if m.id == nil || m.oldValue == nil {
  8362. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8363. }
  8364. oldValue, err := m.oldValue(ctx)
  8365. if err != nil {
  8366. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8367. }
  8368. return oldValue.DeletedAt, nil
  8369. }
  8370. // ClearDeletedAt clears the value of the "deleted_at" field.
  8371. func (m *SopNodeMutation) ClearDeletedAt() {
  8372. m.deleted_at = nil
  8373. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  8374. }
  8375. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8376. func (m *SopNodeMutation) DeletedAtCleared() bool {
  8377. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  8378. return ok
  8379. }
  8380. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8381. func (m *SopNodeMutation) ResetDeletedAt() {
  8382. m.deleted_at = nil
  8383. delete(m.clearedFields, sopnode.FieldDeletedAt)
  8384. }
  8385. // SetStageID sets the "stage_id" field.
  8386. func (m *SopNodeMutation) SetStageID(u uint64) {
  8387. m.sop_stage = &u
  8388. }
  8389. // StageID returns the value of the "stage_id" field in the mutation.
  8390. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  8391. v := m.sop_stage
  8392. if v == nil {
  8393. return
  8394. }
  8395. return *v, true
  8396. }
  8397. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  8398. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  8399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8400. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  8401. if !m.op.Is(OpUpdateOne) {
  8402. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  8403. }
  8404. if m.id == nil || m.oldValue == nil {
  8405. return v, errors.New("OldStageID requires an ID field in the mutation")
  8406. }
  8407. oldValue, err := m.oldValue(ctx)
  8408. if err != nil {
  8409. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  8410. }
  8411. return oldValue.StageID, nil
  8412. }
  8413. // ResetStageID resets all changes to the "stage_id" field.
  8414. func (m *SopNodeMutation) ResetStageID() {
  8415. m.sop_stage = nil
  8416. }
  8417. // SetParentID sets the "parent_id" field.
  8418. func (m *SopNodeMutation) SetParentID(u uint64) {
  8419. m.parent_id = &u
  8420. m.addparent_id = nil
  8421. }
  8422. // ParentID returns the value of the "parent_id" field in the mutation.
  8423. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  8424. v := m.parent_id
  8425. if v == nil {
  8426. return
  8427. }
  8428. return *v, true
  8429. }
  8430. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  8431. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  8432. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8433. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  8434. if !m.op.Is(OpUpdateOne) {
  8435. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  8436. }
  8437. if m.id == nil || m.oldValue == nil {
  8438. return v, errors.New("OldParentID requires an ID field in the mutation")
  8439. }
  8440. oldValue, err := m.oldValue(ctx)
  8441. if err != nil {
  8442. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  8443. }
  8444. return oldValue.ParentID, nil
  8445. }
  8446. // AddParentID adds u to the "parent_id" field.
  8447. func (m *SopNodeMutation) AddParentID(u int64) {
  8448. if m.addparent_id != nil {
  8449. *m.addparent_id += u
  8450. } else {
  8451. m.addparent_id = &u
  8452. }
  8453. }
  8454. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  8455. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  8456. v := m.addparent_id
  8457. if v == nil {
  8458. return
  8459. }
  8460. return *v, true
  8461. }
  8462. // ResetParentID resets all changes to the "parent_id" field.
  8463. func (m *SopNodeMutation) ResetParentID() {
  8464. m.parent_id = nil
  8465. m.addparent_id = nil
  8466. }
  8467. // SetName sets the "name" field.
  8468. func (m *SopNodeMutation) SetName(s string) {
  8469. m.name = &s
  8470. }
  8471. // Name returns the value of the "name" field in the mutation.
  8472. func (m *SopNodeMutation) Name() (r string, exists bool) {
  8473. v := m.name
  8474. if v == nil {
  8475. return
  8476. }
  8477. return *v, true
  8478. }
  8479. // OldName returns the old "name" field's value of the SopNode entity.
  8480. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  8481. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8482. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  8483. if !m.op.Is(OpUpdateOne) {
  8484. return v, errors.New("OldName is only allowed on UpdateOne operations")
  8485. }
  8486. if m.id == nil || m.oldValue == nil {
  8487. return v, errors.New("OldName requires an ID field in the mutation")
  8488. }
  8489. oldValue, err := m.oldValue(ctx)
  8490. if err != nil {
  8491. return v, fmt.Errorf("querying old value for OldName: %w", err)
  8492. }
  8493. return oldValue.Name, nil
  8494. }
  8495. // ResetName resets all changes to the "name" field.
  8496. func (m *SopNodeMutation) ResetName() {
  8497. m.name = nil
  8498. }
  8499. // SetConditionType sets the "condition_type" field.
  8500. func (m *SopNodeMutation) SetConditionType(i int) {
  8501. m.condition_type = &i
  8502. m.addcondition_type = nil
  8503. }
  8504. // ConditionType returns the value of the "condition_type" field in the mutation.
  8505. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  8506. v := m.condition_type
  8507. if v == nil {
  8508. return
  8509. }
  8510. return *v, true
  8511. }
  8512. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  8513. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  8514. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8515. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  8516. if !m.op.Is(OpUpdateOne) {
  8517. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  8518. }
  8519. if m.id == nil || m.oldValue == nil {
  8520. return v, errors.New("OldConditionType requires an ID field in the mutation")
  8521. }
  8522. oldValue, err := m.oldValue(ctx)
  8523. if err != nil {
  8524. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  8525. }
  8526. return oldValue.ConditionType, nil
  8527. }
  8528. // AddConditionType adds i to the "condition_type" field.
  8529. func (m *SopNodeMutation) AddConditionType(i int) {
  8530. if m.addcondition_type != nil {
  8531. *m.addcondition_type += i
  8532. } else {
  8533. m.addcondition_type = &i
  8534. }
  8535. }
  8536. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  8537. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  8538. v := m.addcondition_type
  8539. if v == nil {
  8540. return
  8541. }
  8542. return *v, true
  8543. }
  8544. // ResetConditionType resets all changes to the "condition_type" field.
  8545. func (m *SopNodeMutation) ResetConditionType() {
  8546. m.condition_type = nil
  8547. m.addcondition_type = nil
  8548. }
  8549. // SetConditionList sets the "condition_list" field.
  8550. func (m *SopNodeMutation) SetConditionList(s []string) {
  8551. m.condition_list = &s
  8552. m.appendcondition_list = nil
  8553. }
  8554. // ConditionList returns the value of the "condition_list" field in the mutation.
  8555. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  8556. v := m.condition_list
  8557. if v == nil {
  8558. return
  8559. }
  8560. return *v, true
  8561. }
  8562. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  8563. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  8564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8565. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  8566. if !m.op.Is(OpUpdateOne) {
  8567. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  8568. }
  8569. if m.id == nil || m.oldValue == nil {
  8570. return v, errors.New("OldConditionList requires an ID field in the mutation")
  8571. }
  8572. oldValue, err := m.oldValue(ctx)
  8573. if err != nil {
  8574. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  8575. }
  8576. return oldValue.ConditionList, nil
  8577. }
  8578. // AppendConditionList adds s to the "condition_list" field.
  8579. func (m *SopNodeMutation) AppendConditionList(s []string) {
  8580. m.appendcondition_list = append(m.appendcondition_list, s...)
  8581. }
  8582. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  8583. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  8584. if len(m.appendcondition_list) == 0 {
  8585. return nil, false
  8586. }
  8587. return m.appendcondition_list, true
  8588. }
  8589. // ClearConditionList clears the value of the "condition_list" field.
  8590. func (m *SopNodeMutation) ClearConditionList() {
  8591. m.condition_list = nil
  8592. m.appendcondition_list = nil
  8593. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  8594. }
  8595. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  8596. func (m *SopNodeMutation) ConditionListCleared() bool {
  8597. _, ok := m.clearedFields[sopnode.FieldConditionList]
  8598. return ok
  8599. }
  8600. // ResetConditionList resets all changes to the "condition_list" field.
  8601. func (m *SopNodeMutation) ResetConditionList() {
  8602. m.condition_list = nil
  8603. m.appendcondition_list = nil
  8604. delete(m.clearedFields, sopnode.FieldConditionList)
  8605. }
  8606. // SetNoReplyCondition sets the "no_reply_condition" field.
  8607. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  8608. m.no_reply_condition = &u
  8609. m.addno_reply_condition = nil
  8610. }
  8611. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  8612. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  8613. v := m.no_reply_condition
  8614. if v == nil {
  8615. return
  8616. }
  8617. return *v, true
  8618. }
  8619. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  8620. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  8621. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8622. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  8623. if !m.op.Is(OpUpdateOne) {
  8624. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  8625. }
  8626. if m.id == nil || m.oldValue == nil {
  8627. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  8628. }
  8629. oldValue, err := m.oldValue(ctx)
  8630. if err != nil {
  8631. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  8632. }
  8633. return oldValue.NoReplyCondition, nil
  8634. }
  8635. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  8636. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  8637. if m.addno_reply_condition != nil {
  8638. *m.addno_reply_condition += u
  8639. } else {
  8640. m.addno_reply_condition = &u
  8641. }
  8642. }
  8643. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  8644. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  8645. v := m.addno_reply_condition
  8646. if v == nil {
  8647. return
  8648. }
  8649. return *v, true
  8650. }
  8651. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  8652. func (m *SopNodeMutation) ResetNoReplyCondition() {
  8653. m.no_reply_condition = nil
  8654. m.addno_reply_condition = nil
  8655. }
  8656. // SetActionMessage sets the "action_message" field.
  8657. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  8658. m.action_message = &ct
  8659. m.appendaction_message = nil
  8660. }
  8661. // ActionMessage returns the value of the "action_message" field in the mutation.
  8662. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  8663. v := m.action_message
  8664. if v == nil {
  8665. return
  8666. }
  8667. return *v, true
  8668. }
  8669. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  8670. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  8671. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8672. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  8673. if !m.op.Is(OpUpdateOne) {
  8674. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  8675. }
  8676. if m.id == nil || m.oldValue == nil {
  8677. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  8678. }
  8679. oldValue, err := m.oldValue(ctx)
  8680. if err != nil {
  8681. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  8682. }
  8683. return oldValue.ActionMessage, nil
  8684. }
  8685. // AppendActionMessage adds ct to the "action_message" field.
  8686. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  8687. m.appendaction_message = append(m.appendaction_message, ct...)
  8688. }
  8689. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  8690. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  8691. if len(m.appendaction_message) == 0 {
  8692. return nil, false
  8693. }
  8694. return m.appendaction_message, true
  8695. }
  8696. // ClearActionMessage clears the value of the "action_message" field.
  8697. func (m *SopNodeMutation) ClearActionMessage() {
  8698. m.action_message = nil
  8699. m.appendaction_message = nil
  8700. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  8701. }
  8702. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  8703. func (m *SopNodeMutation) ActionMessageCleared() bool {
  8704. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  8705. return ok
  8706. }
  8707. // ResetActionMessage resets all changes to the "action_message" field.
  8708. func (m *SopNodeMutation) ResetActionMessage() {
  8709. m.action_message = nil
  8710. m.appendaction_message = nil
  8711. delete(m.clearedFields, sopnode.FieldActionMessage)
  8712. }
  8713. // SetActionLabel sets the "action_label" field.
  8714. func (m *SopNodeMutation) SetActionLabel(u []uint64) {
  8715. m.action_label = &u
  8716. m.appendaction_label = nil
  8717. }
  8718. // ActionLabel returns the value of the "action_label" field in the mutation.
  8719. func (m *SopNodeMutation) ActionLabel() (r []uint64, exists bool) {
  8720. v := m.action_label
  8721. if v == nil {
  8722. return
  8723. }
  8724. return *v, true
  8725. }
  8726. // OldActionLabel returns the old "action_label" field's value of the SopNode entity.
  8727. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  8728. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8729. func (m *SopNodeMutation) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  8730. if !m.op.Is(OpUpdateOne) {
  8731. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  8732. }
  8733. if m.id == nil || m.oldValue == nil {
  8734. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  8735. }
  8736. oldValue, err := m.oldValue(ctx)
  8737. if err != nil {
  8738. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  8739. }
  8740. return oldValue.ActionLabel, nil
  8741. }
  8742. // AppendActionLabel adds u to the "action_label" field.
  8743. func (m *SopNodeMutation) AppendActionLabel(u []uint64) {
  8744. m.appendaction_label = append(m.appendaction_label, u...)
  8745. }
  8746. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  8747. func (m *SopNodeMutation) AppendedActionLabel() ([]uint64, bool) {
  8748. if len(m.appendaction_label) == 0 {
  8749. return nil, false
  8750. }
  8751. return m.appendaction_label, true
  8752. }
  8753. // ClearActionLabel clears the value of the "action_label" field.
  8754. func (m *SopNodeMutation) ClearActionLabel() {
  8755. m.action_label = nil
  8756. m.appendaction_label = nil
  8757. m.clearedFields[sopnode.FieldActionLabel] = struct{}{}
  8758. }
  8759. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  8760. func (m *SopNodeMutation) ActionLabelCleared() bool {
  8761. _, ok := m.clearedFields[sopnode.FieldActionLabel]
  8762. return ok
  8763. }
  8764. // ResetActionLabel resets all changes to the "action_label" field.
  8765. func (m *SopNodeMutation) ResetActionLabel() {
  8766. m.action_label = nil
  8767. m.appendaction_label = nil
  8768. delete(m.clearedFields, sopnode.FieldActionLabel)
  8769. }
  8770. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  8771. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  8772. m.sop_stage = &id
  8773. }
  8774. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  8775. func (m *SopNodeMutation) ClearSopStage() {
  8776. m.clearedsop_stage = true
  8777. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  8778. }
  8779. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  8780. func (m *SopNodeMutation) SopStageCleared() bool {
  8781. return m.clearedsop_stage
  8782. }
  8783. // SopStageID returns the "sop_stage" edge ID in the mutation.
  8784. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  8785. if m.sop_stage != nil {
  8786. return *m.sop_stage, true
  8787. }
  8788. return
  8789. }
  8790. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  8791. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  8792. // SopStageID instead. It exists only for internal usage by the builders.
  8793. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  8794. if id := m.sop_stage; id != nil {
  8795. ids = append(ids, *id)
  8796. }
  8797. return
  8798. }
  8799. // ResetSopStage resets all changes to the "sop_stage" edge.
  8800. func (m *SopNodeMutation) ResetSopStage() {
  8801. m.sop_stage = nil
  8802. m.clearedsop_stage = false
  8803. }
  8804. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  8805. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  8806. if m.node_messages == nil {
  8807. m.node_messages = make(map[uint64]struct{})
  8808. }
  8809. for i := range ids {
  8810. m.node_messages[ids[i]] = struct{}{}
  8811. }
  8812. }
  8813. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  8814. func (m *SopNodeMutation) ClearNodeMessages() {
  8815. m.clearednode_messages = true
  8816. }
  8817. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  8818. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  8819. return m.clearednode_messages
  8820. }
  8821. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  8822. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  8823. if m.removednode_messages == nil {
  8824. m.removednode_messages = make(map[uint64]struct{})
  8825. }
  8826. for i := range ids {
  8827. delete(m.node_messages, ids[i])
  8828. m.removednode_messages[ids[i]] = struct{}{}
  8829. }
  8830. }
  8831. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  8832. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  8833. for id := range m.removednode_messages {
  8834. ids = append(ids, id)
  8835. }
  8836. return
  8837. }
  8838. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  8839. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  8840. for id := range m.node_messages {
  8841. ids = append(ids, id)
  8842. }
  8843. return
  8844. }
  8845. // ResetNodeMessages resets all changes to the "node_messages" edge.
  8846. func (m *SopNodeMutation) ResetNodeMessages() {
  8847. m.node_messages = nil
  8848. m.clearednode_messages = false
  8849. m.removednode_messages = nil
  8850. }
  8851. // Where appends a list predicates to the SopNodeMutation builder.
  8852. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  8853. m.predicates = append(m.predicates, ps...)
  8854. }
  8855. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  8856. // users can use type-assertion to append predicates that do not depend on any generated package.
  8857. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  8858. p := make([]predicate.SopNode, len(ps))
  8859. for i := range ps {
  8860. p[i] = ps[i]
  8861. }
  8862. m.Where(p...)
  8863. }
  8864. // Op returns the operation name.
  8865. func (m *SopNodeMutation) Op() Op {
  8866. return m.op
  8867. }
  8868. // SetOp allows setting the mutation operation.
  8869. func (m *SopNodeMutation) SetOp(op Op) {
  8870. m.op = op
  8871. }
  8872. // Type returns the node type of this mutation (SopNode).
  8873. func (m *SopNodeMutation) Type() string {
  8874. return m.typ
  8875. }
  8876. // Fields returns all fields that were changed during this mutation. Note that in
  8877. // order to get all numeric fields that were incremented/decremented, call
  8878. // AddedFields().
  8879. func (m *SopNodeMutation) Fields() []string {
  8880. fields := make([]string, 0, 12)
  8881. if m.created_at != nil {
  8882. fields = append(fields, sopnode.FieldCreatedAt)
  8883. }
  8884. if m.updated_at != nil {
  8885. fields = append(fields, sopnode.FieldUpdatedAt)
  8886. }
  8887. if m.status != nil {
  8888. fields = append(fields, sopnode.FieldStatus)
  8889. }
  8890. if m.deleted_at != nil {
  8891. fields = append(fields, sopnode.FieldDeletedAt)
  8892. }
  8893. if m.sop_stage != nil {
  8894. fields = append(fields, sopnode.FieldStageID)
  8895. }
  8896. if m.parent_id != nil {
  8897. fields = append(fields, sopnode.FieldParentID)
  8898. }
  8899. if m.name != nil {
  8900. fields = append(fields, sopnode.FieldName)
  8901. }
  8902. if m.condition_type != nil {
  8903. fields = append(fields, sopnode.FieldConditionType)
  8904. }
  8905. if m.condition_list != nil {
  8906. fields = append(fields, sopnode.FieldConditionList)
  8907. }
  8908. if m.no_reply_condition != nil {
  8909. fields = append(fields, sopnode.FieldNoReplyCondition)
  8910. }
  8911. if m.action_message != nil {
  8912. fields = append(fields, sopnode.FieldActionMessage)
  8913. }
  8914. if m.action_label != nil {
  8915. fields = append(fields, sopnode.FieldActionLabel)
  8916. }
  8917. return fields
  8918. }
  8919. // Field returns the value of a field with the given name. The second boolean
  8920. // return value indicates that this field was not set, or was not defined in the
  8921. // schema.
  8922. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  8923. switch name {
  8924. case sopnode.FieldCreatedAt:
  8925. return m.CreatedAt()
  8926. case sopnode.FieldUpdatedAt:
  8927. return m.UpdatedAt()
  8928. case sopnode.FieldStatus:
  8929. return m.Status()
  8930. case sopnode.FieldDeletedAt:
  8931. return m.DeletedAt()
  8932. case sopnode.FieldStageID:
  8933. return m.StageID()
  8934. case sopnode.FieldParentID:
  8935. return m.ParentID()
  8936. case sopnode.FieldName:
  8937. return m.Name()
  8938. case sopnode.FieldConditionType:
  8939. return m.ConditionType()
  8940. case sopnode.FieldConditionList:
  8941. return m.ConditionList()
  8942. case sopnode.FieldNoReplyCondition:
  8943. return m.NoReplyCondition()
  8944. case sopnode.FieldActionMessage:
  8945. return m.ActionMessage()
  8946. case sopnode.FieldActionLabel:
  8947. return m.ActionLabel()
  8948. }
  8949. return nil, false
  8950. }
  8951. // OldField returns the old value of the field from the database. An error is
  8952. // returned if the mutation operation is not UpdateOne, or the query to the
  8953. // database failed.
  8954. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8955. switch name {
  8956. case sopnode.FieldCreatedAt:
  8957. return m.OldCreatedAt(ctx)
  8958. case sopnode.FieldUpdatedAt:
  8959. return m.OldUpdatedAt(ctx)
  8960. case sopnode.FieldStatus:
  8961. return m.OldStatus(ctx)
  8962. case sopnode.FieldDeletedAt:
  8963. return m.OldDeletedAt(ctx)
  8964. case sopnode.FieldStageID:
  8965. return m.OldStageID(ctx)
  8966. case sopnode.FieldParentID:
  8967. return m.OldParentID(ctx)
  8968. case sopnode.FieldName:
  8969. return m.OldName(ctx)
  8970. case sopnode.FieldConditionType:
  8971. return m.OldConditionType(ctx)
  8972. case sopnode.FieldConditionList:
  8973. return m.OldConditionList(ctx)
  8974. case sopnode.FieldNoReplyCondition:
  8975. return m.OldNoReplyCondition(ctx)
  8976. case sopnode.FieldActionMessage:
  8977. return m.OldActionMessage(ctx)
  8978. case sopnode.FieldActionLabel:
  8979. return m.OldActionLabel(ctx)
  8980. }
  8981. return nil, fmt.Errorf("unknown SopNode field %s", name)
  8982. }
  8983. // SetField sets the value of a field with the given name. It returns an error if
  8984. // the field is not defined in the schema, or if the type mismatched the field
  8985. // type.
  8986. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  8987. switch name {
  8988. case sopnode.FieldCreatedAt:
  8989. v, ok := value.(time.Time)
  8990. if !ok {
  8991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8992. }
  8993. m.SetCreatedAt(v)
  8994. return nil
  8995. case sopnode.FieldUpdatedAt:
  8996. v, ok := value.(time.Time)
  8997. if !ok {
  8998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8999. }
  9000. m.SetUpdatedAt(v)
  9001. return nil
  9002. case sopnode.FieldStatus:
  9003. v, ok := value.(uint8)
  9004. if !ok {
  9005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9006. }
  9007. m.SetStatus(v)
  9008. return nil
  9009. case sopnode.FieldDeletedAt:
  9010. v, ok := value.(time.Time)
  9011. if !ok {
  9012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9013. }
  9014. m.SetDeletedAt(v)
  9015. return nil
  9016. case sopnode.FieldStageID:
  9017. v, ok := value.(uint64)
  9018. if !ok {
  9019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9020. }
  9021. m.SetStageID(v)
  9022. return nil
  9023. case sopnode.FieldParentID:
  9024. v, ok := value.(uint64)
  9025. if !ok {
  9026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9027. }
  9028. m.SetParentID(v)
  9029. return nil
  9030. case sopnode.FieldName:
  9031. v, ok := value.(string)
  9032. if !ok {
  9033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9034. }
  9035. m.SetName(v)
  9036. return nil
  9037. case sopnode.FieldConditionType:
  9038. v, ok := value.(int)
  9039. if !ok {
  9040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9041. }
  9042. m.SetConditionType(v)
  9043. return nil
  9044. case sopnode.FieldConditionList:
  9045. v, ok := value.([]string)
  9046. if !ok {
  9047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9048. }
  9049. m.SetConditionList(v)
  9050. return nil
  9051. case sopnode.FieldNoReplyCondition:
  9052. v, ok := value.(uint64)
  9053. if !ok {
  9054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9055. }
  9056. m.SetNoReplyCondition(v)
  9057. return nil
  9058. case sopnode.FieldActionMessage:
  9059. v, ok := value.([]custom_types.Action)
  9060. if !ok {
  9061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9062. }
  9063. m.SetActionMessage(v)
  9064. return nil
  9065. case sopnode.FieldActionLabel:
  9066. v, ok := value.([]uint64)
  9067. if !ok {
  9068. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9069. }
  9070. m.SetActionLabel(v)
  9071. return nil
  9072. }
  9073. return fmt.Errorf("unknown SopNode field %s", name)
  9074. }
  9075. // AddedFields returns all numeric fields that were incremented/decremented during
  9076. // this mutation.
  9077. func (m *SopNodeMutation) AddedFields() []string {
  9078. var fields []string
  9079. if m.addstatus != nil {
  9080. fields = append(fields, sopnode.FieldStatus)
  9081. }
  9082. if m.addparent_id != nil {
  9083. fields = append(fields, sopnode.FieldParentID)
  9084. }
  9085. if m.addcondition_type != nil {
  9086. fields = append(fields, sopnode.FieldConditionType)
  9087. }
  9088. if m.addno_reply_condition != nil {
  9089. fields = append(fields, sopnode.FieldNoReplyCondition)
  9090. }
  9091. return fields
  9092. }
  9093. // AddedField returns the numeric value that was incremented/decremented on a field
  9094. // with the given name. The second boolean return value indicates that this field
  9095. // was not set, or was not defined in the schema.
  9096. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  9097. switch name {
  9098. case sopnode.FieldStatus:
  9099. return m.AddedStatus()
  9100. case sopnode.FieldParentID:
  9101. return m.AddedParentID()
  9102. case sopnode.FieldConditionType:
  9103. return m.AddedConditionType()
  9104. case sopnode.FieldNoReplyCondition:
  9105. return m.AddedNoReplyCondition()
  9106. }
  9107. return nil, false
  9108. }
  9109. // AddField adds the value to the field with the given name. It returns an error if
  9110. // the field is not defined in the schema, or if the type mismatched the field
  9111. // type.
  9112. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  9113. switch name {
  9114. case sopnode.FieldStatus:
  9115. v, ok := value.(int8)
  9116. if !ok {
  9117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9118. }
  9119. m.AddStatus(v)
  9120. return nil
  9121. case sopnode.FieldParentID:
  9122. v, ok := value.(int64)
  9123. if !ok {
  9124. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9125. }
  9126. m.AddParentID(v)
  9127. return nil
  9128. case sopnode.FieldConditionType:
  9129. v, ok := value.(int)
  9130. if !ok {
  9131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9132. }
  9133. m.AddConditionType(v)
  9134. return nil
  9135. case sopnode.FieldNoReplyCondition:
  9136. v, ok := value.(int64)
  9137. if !ok {
  9138. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9139. }
  9140. m.AddNoReplyCondition(v)
  9141. return nil
  9142. }
  9143. return fmt.Errorf("unknown SopNode numeric field %s", name)
  9144. }
  9145. // ClearedFields returns all nullable fields that were cleared during this
  9146. // mutation.
  9147. func (m *SopNodeMutation) ClearedFields() []string {
  9148. var fields []string
  9149. if m.FieldCleared(sopnode.FieldStatus) {
  9150. fields = append(fields, sopnode.FieldStatus)
  9151. }
  9152. if m.FieldCleared(sopnode.FieldDeletedAt) {
  9153. fields = append(fields, sopnode.FieldDeletedAt)
  9154. }
  9155. if m.FieldCleared(sopnode.FieldConditionList) {
  9156. fields = append(fields, sopnode.FieldConditionList)
  9157. }
  9158. if m.FieldCleared(sopnode.FieldActionMessage) {
  9159. fields = append(fields, sopnode.FieldActionMessage)
  9160. }
  9161. if m.FieldCleared(sopnode.FieldActionLabel) {
  9162. fields = append(fields, sopnode.FieldActionLabel)
  9163. }
  9164. return fields
  9165. }
  9166. // FieldCleared returns a boolean indicating if a field with the given name was
  9167. // cleared in this mutation.
  9168. func (m *SopNodeMutation) FieldCleared(name string) bool {
  9169. _, ok := m.clearedFields[name]
  9170. return ok
  9171. }
  9172. // ClearField clears the value of the field with the given name. It returns an
  9173. // error if the field is not defined in the schema.
  9174. func (m *SopNodeMutation) ClearField(name string) error {
  9175. switch name {
  9176. case sopnode.FieldStatus:
  9177. m.ClearStatus()
  9178. return nil
  9179. case sopnode.FieldDeletedAt:
  9180. m.ClearDeletedAt()
  9181. return nil
  9182. case sopnode.FieldConditionList:
  9183. m.ClearConditionList()
  9184. return nil
  9185. case sopnode.FieldActionMessage:
  9186. m.ClearActionMessage()
  9187. return nil
  9188. case sopnode.FieldActionLabel:
  9189. m.ClearActionLabel()
  9190. return nil
  9191. }
  9192. return fmt.Errorf("unknown SopNode nullable field %s", name)
  9193. }
  9194. // ResetField resets all changes in the mutation for the field with the given name.
  9195. // It returns an error if the field is not defined in the schema.
  9196. func (m *SopNodeMutation) ResetField(name string) error {
  9197. switch name {
  9198. case sopnode.FieldCreatedAt:
  9199. m.ResetCreatedAt()
  9200. return nil
  9201. case sopnode.FieldUpdatedAt:
  9202. m.ResetUpdatedAt()
  9203. return nil
  9204. case sopnode.FieldStatus:
  9205. m.ResetStatus()
  9206. return nil
  9207. case sopnode.FieldDeletedAt:
  9208. m.ResetDeletedAt()
  9209. return nil
  9210. case sopnode.FieldStageID:
  9211. m.ResetStageID()
  9212. return nil
  9213. case sopnode.FieldParentID:
  9214. m.ResetParentID()
  9215. return nil
  9216. case sopnode.FieldName:
  9217. m.ResetName()
  9218. return nil
  9219. case sopnode.FieldConditionType:
  9220. m.ResetConditionType()
  9221. return nil
  9222. case sopnode.FieldConditionList:
  9223. m.ResetConditionList()
  9224. return nil
  9225. case sopnode.FieldNoReplyCondition:
  9226. m.ResetNoReplyCondition()
  9227. return nil
  9228. case sopnode.FieldActionMessage:
  9229. m.ResetActionMessage()
  9230. return nil
  9231. case sopnode.FieldActionLabel:
  9232. m.ResetActionLabel()
  9233. return nil
  9234. }
  9235. return fmt.Errorf("unknown SopNode field %s", name)
  9236. }
  9237. // AddedEdges returns all edge names that were set/added in this mutation.
  9238. func (m *SopNodeMutation) AddedEdges() []string {
  9239. edges := make([]string, 0, 2)
  9240. if m.sop_stage != nil {
  9241. edges = append(edges, sopnode.EdgeSopStage)
  9242. }
  9243. if m.node_messages != nil {
  9244. edges = append(edges, sopnode.EdgeNodeMessages)
  9245. }
  9246. return edges
  9247. }
  9248. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9249. // name in this mutation.
  9250. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  9251. switch name {
  9252. case sopnode.EdgeSopStage:
  9253. if id := m.sop_stage; id != nil {
  9254. return []ent.Value{*id}
  9255. }
  9256. case sopnode.EdgeNodeMessages:
  9257. ids := make([]ent.Value, 0, len(m.node_messages))
  9258. for id := range m.node_messages {
  9259. ids = append(ids, id)
  9260. }
  9261. return ids
  9262. }
  9263. return nil
  9264. }
  9265. // RemovedEdges returns all edge names that were removed in this mutation.
  9266. func (m *SopNodeMutation) RemovedEdges() []string {
  9267. edges := make([]string, 0, 2)
  9268. if m.removednode_messages != nil {
  9269. edges = append(edges, sopnode.EdgeNodeMessages)
  9270. }
  9271. return edges
  9272. }
  9273. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9274. // the given name in this mutation.
  9275. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  9276. switch name {
  9277. case sopnode.EdgeNodeMessages:
  9278. ids := make([]ent.Value, 0, len(m.removednode_messages))
  9279. for id := range m.removednode_messages {
  9280. ids = append(ids, id)
  9281. }
  9282. return ids
  9283. }
  9284. return nil
  9285. }
  9286. // ClearedEdges returns all edge names that were cleared in this mutation.
  9287. func (m *SopNodeMutation) ClearedEdges() []string {
  9288. edges := make([]string, 0, 2)
  9289. if m.clearedsop_stage {
  9290. edges = append(edges, sopnode.EdgeSopStage)
  9291. }
  9292. if m.clearednode_messages {
  9293. edges = append(edges, sopnode.EdgeNodeMessages)
  9294. }
  9295. return edges
  9296. }
  9297. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9298. // was cleared in this mutation.
  9299. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  9300. switch name {
  9301. case sopnode.EdgeSopStage:
  9302. return m.clearedsop_stage
  9303. case sopnode.EdgeNodeMessages:
  9304. return m.clearednode_messages
  9305. }
  9306. return false
  9307. }
  9308. // ClearEdge clears the value of the edge with the given name. It returns an error
  9309. // if that edge is not defined in the schema.
  9310. func (m *SopNodeMutation) ClearEdge(name string) error {
  9311. switch name {
  9312. case sopnode.EdgeSopStage:
  9313. m.ClearSopStage()
  9314. return nil
  9315. }
  9316. return fmt.Errorf("unknown SopNode unique edge %s", name)
  9317. }
  9318. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9319. // It returns an error if the edge is not defined in the schema.
  9320. func (m *SopNodeMutation) ResetEdge(name string) error {
  9321. switch name {
  9322. case sopnode.EdgeSopStage:
  9323. m.ResetSopStage()
  9324. return nil
  9325. case sopnode.EdgeNodeMessages:
  9326. m.ResetNodeMessages()
  9327. return nil
  9328. }
  9329. return fmt.Errorf("unknown SopNode edge %s", name)
  9330. }
  9331. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  9332. type SopStageMutation struct {
  9333. config
  9334. op Op
  9335. typ string
  9336. id *uint64
  9337. created_at *time.Time
  9338. updated_at *time.Time
  9339. status *uint8
  9340. addstatus *int8
  9341. deleted_at *time.Time
  9342. name *string
  9343. condition_type *int
  9344. addcondition_type *int
  9345. condition_operator *int
  9346. addcondition_operator *int
  9347. condition_list *[]custom_types.Condition
  9348. appendcondition_list []custom_types.Condition
  9349. action_message *[]custom_types.Action
  9350. appendaction_message []custom_types.Action
  9351. action_label *[]uint64
  9352. appendaction_label []uint64
  9353. index_sort *int
  9354. addindex_sort *int
  9355. clearedFields map[string]struct{}
  9356. sop_task *uint64
  9357. clearedsop_task bool
  9358. stage_nodes map[uint64]struct{}
  9359. removedstage_nodes map[uint64]struct{}
  9360. clearedstage_nodes bool
  9361. stage_messages map[uint64]struct{}
  9362. removedstage_messages map[uint64]struct{}
  9363. clearedstage_messages bool
  9364. done bool
  9365. oldValue func(context.Context) (*SopStage, error)
  9366. predicates []predicate.SopStage
  9367. }
  9368. var _ ent.Mutation = (*SopStageMutation)(nil)
  9369. // sopstageOption allows management of the mutation configuration using functional options.
  9370. type sopstageOption func(*SopStageMutation)
  9371. // newSopStageMutation creates new mutation for the SopStage entity.
  9372. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  9373. m := &SopStageMutation{
  9374. config: c,
  9375. op: op,
  9376. typ: TypeSopStage,
  9377. clearedFields: make(map[string]struct{}),
  9378. }
  9379. for _, opt := range opts {
  9380. opt(m)
  9381. }
  9382. return m
  9383. }
  9384. // withSopStageID sets the ID field of the mutation.
  9385. func withSopStageID(id uint64) sopstageOption {
  9386. return func(m *SopStageMutation) {
  9387. var (
  9388. err error
  9389. once sync.Once
  9390. value *SopStage
  9391. )
  9392. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  9393. once.Do(func() {
  9394. if m.done {
  9395. err = errors.New("querying old values post mutation is not allowed")
  9396. } else {
  9397. value, err = m.Client().SopStage.Get(ctx, id)
  9398. }
  9399. })
  9400. return value, err
  9401. }
  9402. m.id = &id
  9403. }
  9404. }
  9405. // withSopStage sets the old SopStage of the mutation.
  9406. func withSopStage(node *SopStage) sopstageOption {
  9407. return func(m *SopStageMutation) {
  9408. m.oldValue = func(context.Context) (*SopStage, error) {
  9409. return node, nil
  9410. }
  9411. m.id = &node.ID
  9412. }
  9413. }
  9414. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9415. // executed in a transaction (ent.Tx), a transactional client is returned.
  9416. func (m SopStageMutation) Client() *Client {
  9417. client := &Client{config: m.config}
  9418. client.init()
  9419. return client
  9420. }
  9421. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9422. // it returns an error otherwise.
  9423. func (m SopStageMutation) Tx() (*Tx, error) {
  9424. if _, ok := m.driver.(*txDriver); !ok {
  9425. return nil, errors.New("ent: mutation is not running in a transaction")
  9426. }
  9427. tx := &Tx{config: m.config}
  9428. tx.init()
  9429. return tx, nil
  9430. }
  9431. // SetID sets the value of the id field. Note that this
  9432. // operation is only accepted on creation of SopStage entities.
  9433. func (m *SopStageMutation) SetID(id uint64) {
  9434. m.id = &id
  9435. }
  9436. // ID returns the ID value in the mutation. Note that the ID is only available
  9437. // if it was provided to the builder or after it was returned from the database.
  9438. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  9439. if m.id == nil {
  9440. return
  9441. }
  9442. return *m.id, true
  9443. }
  9444. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9445. // That means, if the mutation is applied within a transaction with an isolation level such
  9446. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9447. // or updated by the mutation.
  9448. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  9449. switch {
  9450. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9451. id, exists := m.ID()
  9452. if exists {
  9453. return []uint64{id}, nil
  9454. }
  9455. fallthrough
  9456. case m.op.Is(OpUpdate | OpDelete):
  9457. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  9458. default:
  9459. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9460. }
  9461. }
  9462. // SetCreatedAt sets the "created_at" field.
  9463. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  9464. m.created_at = &t
  9465. }
  9466. // CreatedAt returns the value of the "created_at" field in the mutation.
  9467. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  9468. v := m.created_at
  9469. if v == nil {
  9470. return
  9471. }
  9472. return *v, true
  9473. }
  9474. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  9475. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  9476. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9477. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9478. if !m.op.Is(OpUpdateOne) {
  9479. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9480. }
  9481. if m.id == nil || m.oldValue == nil {
  9482. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9483. }
  9484. oldValue, err := m.oldValue(ctx)
  9485. if err != nil {
  9486. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9487. }
  9488. return oldValue.CreatedAt, nil
  9489. }
  9490. // ResetCreatedAt resets all changes to the "created_at" field.
  9491. func (m *SopStageMutation) ResetCreatedAt() {
  9492. m.created_at = nil
  9493. }
  9494. // SetUpdatedAt sets the "updated_at" field.
  9495. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  9496. m.updated_at = &t
  9497. }
  9498. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9499. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  9500. v := m.updated_at
  9501. if v == nil {
  9502. return
  9503. }
  9504. return *v, true
  9505. }
  9506. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  9507. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  9508. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9509. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9510. if !m.op.Is(OpUpdateOne) {
  9511. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9512. }
  9513. if m.id == nil || m.oldValue == nil {
  9514. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9515. }
  9516. oldValue, err := m.oldValue(ctx)
  9517. if err != nil {
  9518. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9519. }
  9520. return oldValue.UpdatedAt, nil
  9521. }
  9522. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9523. func (m *SopStageMutation) ResetUpdatedAt() {
  9524. m.updated_at = nil
  9525. }
  9526. // SetStatus sets the "status" field.
  9527. func (m *SopStageMutation) SetStatus(u uint8) {
  9528. m.status = &u
  9529. m.addstatus = nil
  9530. }
  9531. // Status returns the value of the "status" field in the mutation.
  9532. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  9533. v := m.status
  9534. if v == nil {
  9535. return
  9536. }
  9537. return *v, true
  9538. }
  9539. // OldStatus returns the old "status" field's value of the SopStage entity.
  9540. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  9541. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9542. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  9543. if !m.op.Is(OpUpdateOne) {
  9544. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9545. }
  9546. if m.id == nil || m.oldValue == nil {
  9547. return v, errors.New("OldStatus requires an ID field in the mutation")
  9548. }
  9549. oldValue, err := m.oldValue(ctx)
  9550. if err != nil {
  9551. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9552. }
  9553. return oldValue.Status, nil
  9554. }
  9555. // AddStatus adds u to the "status" field.
  9556. func (m *SopStageMutation) AddStatus(u int8) {
  9557. if m.addstatus != nil {
  9558. *m.addstatus += u
  9559. } else {
  9560. m.addstatus = &u
  9561. }
  9562. }
  9563. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9564. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  9565. v := m.addstatus
  9566. if v == nil {
  9567. return
  9568. }
  9569. return *v, true
  9570. }
  9571. // ClearStatus clears the value of the "status" field.
  9572. func (m *SopStageMutation) ClearStatus() {
  9573. m.status = nil
  9574. m.addstatus = nil
  9575. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  9576. }
  9577. // StatusCleared returns if the "status" field was cleared in this mutation.
  9578. func (m *SopStageMutation) StatusCleared() bool {
  9579. _, ok := m.clearedFields[sopstage.FieldStatus]
  9580. return ok
  9581. }
  9582. // ResetStatus resets all changes to the "status" field.
  9583. func (m *SopStageMutation) ResetStatus() {
  9584. m.status = nil
  9585. m.addstatus = nil
  9586. delete(m.clearedFields, sopstage.FieldStatus)
  9587. }
  9588. // SetDeletedAt sets the "deleted_at" field.
  9589. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  9590. m.deleted_at = &t
  9591. }
  9592. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9593. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  9594. v := m.deleted_at
  9595. if v == nil {
  9596. return
  9597. }
  9598. return *v, true
  9599. }
  9600. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  9601. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  9602. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9603. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9604. if !m.op.Is(OpUpdateOne) {
  9605. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9606. }
  9607. if m.id == nil || m.oldValue == nil {
  9608. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9609. }
  9610. oldValue, err := m.oldValue(ctx)
  9611. if err != nil {
  9612. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9613. }
  9614. return oldValue.DeletedAt, nil
  9615. }
  9616. // ClearDeletedAt clears the value of the "deleted_at" field.
  9617. func (m *SopStageMutation) ClearDeletedAt() {
  9618. m.deleted_at = nil
  9619. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  9620. }
  9621. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9622. func (m *SopStageMutation) DeletedAtCleared() bool {
  9623. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  9624. return ok
  9625. }
  9626. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9627. func (m *SopStageMutation) ResetDeletedAt() {
  9628. m.deleted_at = nil
  9629. delete(m.clearedFields, sopstage.FieldDeletedAt)
  9630. }
  9631. // SetTaskID sets the "task_id" field.
  9632. func (m *SopStageMutation) SetTaskID(u uint64) {
  9633. m.sop_task = &u
  9634. }
  9635. // TaskID returns the value of the "task_id" field in the mutation.
  9636. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  9637. v := m.sop_task
  9638. if v == nil {
  9639. return
  9640. }
  9641. return *v, true
  9642. }
  9643. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  9644. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  9645. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9646. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  9647. if !m.op.Is(OpUpdateOne) {
  9648. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  9649. }
  9650. if m.id == nil || m.oldValue == nil {
  9651. return v, errors.New("OldTaskID requires an ID field in the mutation")
  9652. }
  9653. oldValue, err := m.oldValue(ctx)
  9654. if err != nil {
  9655. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  9656. }
  9657. return oldValue.TaskID, nil
  9658. }
  9659. // ResetTaskID resets all changes to the "task_id" field.
  9660. func (m *SopStageMutation) ResetTaskID() {
  9661. m.sop_task = nil
  9662. }
  9663. // SetName sets the "name" field.
  9664. func (m *SopStageMutation) SetName(s string) {
  9665. m.name = &s
  9666. }
  9667. // Name returns the value of the "name" field in the mutation.
  9668. func (m *SopStageMutation) Name() (r string, exists bool) {
  9669. v := m.name
  9670. if v == nil {
  9671. return
  9672. }
  9673. return *v, true
  9674. }
  9675. // OldName returns the old "name" field's value of the SopStage entity.
  9676. // If the SopStage 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 *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  9679. if !m.op.Is(OpUpdateOne) {
  9680. return v, errors.New("OldName is only allowed on UpdateOne operations")
  9681. }
  9682. if m.id == nil || m.oldValue == nil {
  9683. return v, errors.New("OldName 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 OldName: %w", err)
  9688. }
  9689. return oldValue.Name, nil
  9690. }
  9691. // ResetName resets all changes to the "name" field.
  9692. func (m *SopStageMutation) ResetName() {
  9693. m.name = nil
  9694. }
  9695. // SetConditionType sets the "condition_type" field.
  9696. func (m *SopStageMutation) SetConditionType(i int) {
  9697. m.condition_type = &i
  9698. m.addcondition_type = nil
  9699. }
  9700. // ConditionType returns the value of the "condition_type" field in the mutation.
  9701. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  9702. v := m.condition_type
  9703. if v == nil {
  9704. return
  9705. }
  9706. return *v, true
  9707. }
  9708. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  9709. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  9710. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9711. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  9712. if !m.op.Is(OpUpdateOne) {
  9713. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  9714. }
  9715. if m.id == nil || m.oldValue == nil {
  9716. return v, errors.New("OldConditionType requires an ID field in the mutation")
  9717. }
  9718. oldValue, err := m.oldValue(ctx)
  9719. if err != nil {
  9720. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  9721. }
  9722. return oldValue.ConditionType, nil
  9723. }
  9724. // AddConditionType adds i to the "condition_type" field.
  9725. func (m *SopStageMutation) AddConditionType(i int) {
  9726. if m.addcondition_type != nil {
  9727. *m.addcondition_type += i
  9728. } else {
  9729. m.addcondition_type = &i
  9730. }
  9731. }
  9732. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  9733. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  9734. v := m.addcondition_type
  9735. if v == nil {
  9736. return
  9737. }
  9738. return *v, true
  9739. }
  9740. // ResetConditionType resets all changes to the "condition_type" field.
  9741. func (m *SopStageMutation) ResetConditionType() {
  9742. m.condition_type = nil
  9743. m.addcondition_type = nil
  9744. }
  9745. // SetConditionOperator sets the "condition_operator" field.
  9746. func (m *SopStageMutation) SetConditionOperator(i int) {
  9747. m.condition_operator = &i
  9748. m.addcondition_operator = nil
  9749. }
  9750. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  9751. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  9752. v := m.condition_operator
  9753. if v == nil {
  9754. return
  9755. }
  9756. return *v, true
  9757. }
  9758. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  9759. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  9760. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9761. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  9762. if !m.op.Is(OpUpdateOne) {
  9763. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  9764. }
  9765. if m.id == nil || m.oldValue == nil {
  9766. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  9767. }
  9768. oldValue, err := m.oldValue(ctx)
  9769. if err != nil {
  9770. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  9771. }
  9772. return oldValue.ConditionOperator, nil
  9773. }
  9774. // AddConditionOperator adds i to the "condition_operator" field.
  9775. func (m *SopStageMutation) AddConditionOperator(i int) {
  9776. if m.addcondition_operator != nil {
  9777. *m.addcondition_operator += i
  9778. } else {
  9779. m.addcondition_operator = &i
  9780. }
  9781. }
  9782. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  9783. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  9784. v := m.addcondition_operator
  9785. if v == nil {
  9786. return
  9787. }
  9788. return *v, true
  9789. }
  9790. // ResetConditionOperator resets all changes to the "condition_operator" field.
  9791. func (m *SopStageMutation) ResetConditionOperator() {
  9792. m.condition_operator = nil
  9793. m.addcondition_operator = nil
  9794. }
  9795. // SetConditionList sets the "condition_list" field.
  9796. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  9797. m.condition_list = &ct
  9798. m.appendcondition_list = nil
  9799. }
  9800. // ConditionList returns the value of the "condition_list" field in the mutation.
  9801. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  9802. v := m.condition_list
  9803. if v == nil {
  9804. return
  9805. }
  9806. return *v, true
  9807. }
  9808. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  9809. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  9810. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9811. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  9812. if !m.op.Is(OpUpdateOne) {
  9813. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  9814. }
  9815. if m.id == nil || m.oldValue == nil {
  9816. return v, errors.New("OldConditionList requires an ID field in the mutation")
  9817. }
  9818. oldValue, err := m.oldValue(ctx)
  9819. if err != nil {
  9820. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  9821. }
  9822. return oldValue.ConditionList, nil
  9823. }
  9824. // AppendConditionList adds ct to the "condition_list" field.
  9825. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  9826. m.appendcondition_list = append(m.appendcondition_list, ct...)
  9827. }
  9828. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  9829. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  9830. if len(m.appendcondition_list) == 0 {
  9831. return nil, false
  9832. }
  9833. return m.appendcondition_list, true
  9834. }
  9835. // ResetConditionList resets all changes to the "condition_list" field.
  9836. func (m *SopStageMutation) ResetConditionList() {
  9837. m.condition_list = nil
  9838. m.appendcondition_list = nil
  9839. }
  9840. // SetActionMessage sets the "action_message" field.
  9841. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  9842. m.action_message = &ct
  9843. m.appendaction_message = nil
  9844. }
  9845. // ActionMessage returns the value of the "action_message" field in the mutation.
  9846. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  9847. v := m.action_message
  9848. if v == nil {
  9849. return
  9850. }
  9851. return *v, true
  9852. }
  9853. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  9854. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  9855. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9856. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  9857. if !m.op.Is(OpUpdateOne) {
  9858. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  9859. }
  9860. if m.id == nil || m.oldValue == nil {
  9861. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  9862. }
  9863. oldValue, err := m.oldValue(ctx)
  9864. if err != nil {
  9865. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  9866. }
  9867. return oldValue.ActionMessage, nil
  9868. }
  9869. // AppendActionMessage adds ct to the "action_message" field.
  9870. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  9871. m.appendaction_message = append(m.appendaction_message, ct...)
  9872. }
  9873. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  9874. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  9875. if len(m.appendaction_message) == 0 {
  9876. return nil, false
  9877. }
  9878. return m.appendaction_message, true
  9879. }
  9880. // ClearActionMessage clears the value of the "action_message" field.
  9881. func (m *SopStageMutation) ClearActionMessage() {
  9882. m.action_message = nil
  9883. m.appendaction_message = nil
  9884. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  9885. }
  9886. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  9887. func (m *SopStageMutation) ActionMessageCleared() bool {
  9888. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  9889. return ok
  9890. }
  9891. // ResetActionMessage resets all changes to the "action_message" field.
  9892. func (m *SopStageMutation) ResetActionMessage() {
  9893. m.action_message = nil
  9894. m.appendaction_message = nil
  9895. delete(m.clearedFields, sopstage.FieldActionMessage)
  9896. }
  9897. // SetActionLabel sets the "action_label" field.
  9898. func (m *SopStageMutation) SetActionLabel(u []uint64) {
  9899. m.action_label = &u
  9900. m.appendaction_label = nil
  9901. }
  9902. // ActionLabel returns the value of the "action_label" field in the mutation.
  9903. func (m *SopStageMutation) ActionLabel() (r []uint64, exists bool) {
  9904. v := m.action_label
  9905. if v == nil {
  9906. return
  9907. }
  9908. return *v, true
  9909. }
  9910. // OldActionLabel returns the old "action_label" field's value of the SopStage entity.
  9911. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  9912. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9913. func (m *SopStageMutation) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  9914. if !m.op.Is(OpUpdateOne) {
  9915. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  9916. }
  9917. if m.id == nil || m.oldValue == nil {
  9918. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  9919. }
  9920. oldValue, err := m.oldValue(ctx)
  9921. if err != nil {
  9922. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  9923. }
  9924. return oldValue.ActionLabel, nil
  9925. }
  9926. // AppendActionLabel adds u to the "action_label" field.
  9927. func (m *SopStageMutation) AppendActionLabel(u []uint64) {
  9928. m.appendaction_label = append(m.appendaction_label, u...)
  9929. }
  9930. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  9931. func (m *SopStageMutation) AppendedActionLabel() ([]uint64, bool) {
  9932. if len(m.appendaction_label) == 0 {
  9933. return nil, false
  9934. }
  9935. return m.appendaction_label, true
  9936. }
  9937. // ClearActionLabel clears the value of the "action_label" field.
  9938. func (m *SopStageMutation) ClearActionLabel() {
  9939. m.action_label = nil
  9940. m.appendaction_label = nil
  9941. m.clearedFields[sopstage.FieldActionLabel] = struct{}{}
  9942. }
  9943. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  9944. func (m *SopStageMutation) ActionLabelCleared() bool {
  9945. _, ok := m.clearedFields[sopstage.FieldActionLabel]
  9946. return ok
  9947. }
  9948. // ResetActionLabel resets all changes to the "action_label" field.
  9949. func (m *SopStageMutation) ResetActionLabel() {
  9950. m.action_label = nil
  9951. m.appendaction_label = nil
  9952. delete(m.clearedFields, sopstage.FieldActionLabel)
  9953. }
  9954. // SetIndexSort sets the "index_sort" field.
  9955. func (m *SopStageMutation) SetIndexSort(i int) {
  9956. m.index_sort = &i
  9957. m.addindex_sort = nil
  9958. }
  9959. // IndexSort returns the value of the "index_sort" field in the mutation.
  9960. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  9961. v := m.index_sort
  9962. if v == nil {
  9963. return
  9964. }
  9965. return *v, true
  9966. }
  9967. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  9968. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  9969. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9970. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  9971. if !m.op.Is(OpUpdateOne) {
  9972. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  9973. }
  9974. if m.id == nil || m.oldValue == nil {
  9975. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  9976. }
  9977. oldValue, err := m.oldValue(ctx)
  9978. if err != nil {
  9979. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  9980. }
  9981. return oldValue.IndexSort, nil
  9982. }
  9983. // AddIndexSort adds i to the "index_sort" field.
  9984. func (m *SopStageMutation) AddIndexSort(i int) {
  9985. if m.addindex_sort != nil {
  9986. *m.addindex_sort += i
  9987. } else {
  9988. m.addindex_sort = &i
  9989. }
  9990. }
  9991. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  9992. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  9993. v := m.addindex_sort
  9994. if v == nil {
  9995. return
  9996. }
  9997. return *v, true
  9998. }
  9999. // ClearIndexSort clears the value of the "index_sort" field.
  10000. func (m *SopStageMutation) ClearIndexSort() {
  10001. m.index_sort = nil
  10002. m.addindex_sort = nil
  10003. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  10004. }
  10005. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  10006. func (m *SopStageMutation) IndexSortCleared() bool {
  10007. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  10008. return ok
  10009. }
  10010. // ResetIndexSort resets all changes to the "index_sort" field.
  10011. func (m *SopStageMutation) ResetIndexSort() {
  10012. m.index_sort = nil
  10013. m.addindex_sort = nil
  10014. delete(m.clearedFields, sopstage.FieldIndexSort)
  10015. }
  10016. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  10017. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  10018. m.sop_task = &id
  10019. }
  10020. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  10021. func (m *SopStageMutation) ClearSopTask() {
  10022. m.clearedsop_task = true
  10023. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  10024. }
  10025. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  10026. func (m *SopStageMutation) SopTaskCleared() bool {
  10027. return m.clearedsop_task
  10028. }
  10029. // SopTaskID returns the "sop_task" edge ID in the mutation.
  10030. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  10031. if m.sop_task != nil {
  10032. return *m.sop_task, true
  10033. }
  10034. return
  10035. }
  10036. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  10037. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  10038. // SopTaskID instead. It exists only for internal usage by the builders.
  10039. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  10040. if id := m.sop_task; id != nil {
  10041. ids = append(ids, *id)
  10042. }
  10043. return
  10044. }
  10045. // ResetSopTask resets all changes to the "sop_task" edge.
  10046. func (m *SopStageMutation) ResetSopTask() {
  10047. m.sop_task = nil
  10048. m.clearedsop_task = false
  10049. }
  10050. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  10051. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  10052. if m.stage_nodes == nil {
  10053. m.stage_nodes = make(map[uint64]struct{})
  10054. }
  10055. for i := range ids {
  10056. m.stage_nodes[ids[i]] = struct{}{}
  10057. }
  10058. }
  10059. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  10060. func (m *SopStageMutation) ClearStageNodes() {
  10061. m.clearedstage_nodes = true
  10062. }
  10063. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  10064. func (m *SopStageMutation) StageNodesCleared() bool {
  10065. return m.clearedstage_nodes
  10066. }
  10067. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  10068. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  10069. if m.removedstage_nodes == nil {
  10070. m.removedstage_nodes = make(map[uint64]struct{})
  10071. }
  10072. for i := range ids {
  10073. delete(m.stage_nodes, ids[i])
  10074. m.removedstage_nodes[ids[i]] = struct{}{}
  10075. }
  10076. }
  10077. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  10078. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  10079. for id := range m.removedstage_nodes {
  10080. ids = append(ids, id)
  10081. }
  10082. return
  10083. }
  10084. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  10085. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  10086. for id := range m.stage_nodes {
  10087. ids = append(ids, id)
  10088. }
  10089. return
  10090. }
  10091. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  10092. func (m *SopStageMutation) ResetStageNodes() {
  10093. m.stage_nodes = nil
  10094. m.clearedstage_nodes = false
  10095. m.removedstage_nodes = nil
  10096. }
  10097. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  10098. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  10099. if m.stage_messages == nil {
  10100. m.stage_messages = make(map[uint64]struct{})
  10101. }
  10102. for i := range ids {
  10103. m.stage_messages[ids[i]] = struct{}{}
  10104. }
  10105. }
  10106. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  10107. func (m *SopStageMutation) ClearStageMessages() {
  10108. m.clearedstage_messages = true
  10109. }
  10110. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  10111. func (m *SopStageMutation) StageMessagesCleared() bool {
  10112. return m.clearedstage_messages
  10113. }
  10114. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  10115. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  10116. if m.removedstage_messages == nil {
  10117. m.removedstage_messages = make(map[uint64]struct{})
  10118. }
  10119. for i := range ids {
  10120. delete(m.stage_messages, ids[i])
  10121. m.removedstage_messages[ids[i]] = struct{}{}
  10122. }
  10123. }
  10124. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  10125. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  10126. for id := range m.removedstage_messages {
  10127. ids = append(ids, id)
  10128. }
  10129. return
  10130. }
  10131. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  10132. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  10133. for id := range m.stage_messages {
  10134. ids = append(ids, id)
  10135. }
  10136. return
  10137. }
  10138. // ResetStageMessages resets all changes to the "stage_messages" edge.
  10139. func (m *SopStageMutation) ResetStageMessages() {
  10140. m.stage_messages = nil
  10141. m.clearedstage_messages = false
  10142. m.removedstage_messages = nil
  10143. }
  10144. // Where appends a list predicates to the SopStageMutation builder.
  10145. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  10146. m.predicates = append(m.predicates, ps...)
  10147. }
  10148. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  10149. // users can use type-assertion to append predicates that do not depend on any generated package.
  10150. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  10151. p := make([]predicate.SopStage, len(ps))
  10152. for i := range ps {
  10153. p[i] = ps[i]
  10154. }
  10155. m.Where(p...)
  10156. }
  10157. // Op returns the operation name.
  10158. func (m *SopStageMutation) Op() Op {
  10159. return m.op
  10160. }
  10161. // SetOp allows setting the mutation operation.
  10162. func (m *SopStageMutation) SetOp(op Op) {
  10163. m.op = op
  10164. }
  10165. // Type returns the node type of this mutation (SopStage).
  10166. func (m *SopStageMutation) Type() string {
  10167. return m.typ
  10168. }
  10169. // Fields returns all fields that were changed during this mutation. Note that in
  10170. // order to get all numeric fields that were incremented/decremented, call
  10171. // AddedFields().
  10172. func (m *SopStageMutation) Fields() []string {
  10173. fields := make([]string, 0, 12)
  10174. if m.created_at != nil {
  10175. fields = append(fields, sopstage.FieldCreatedAt)
  10176. }
  10177. if m.updated_at != nil {
  10178. fields = append(fields, sopstage.FieldUpdatedAt)
  10179. }
  10180. if m.status != nil {
  10181. fields = append(fields, sopstage.FieldStatus)
  10182. }
  10183. if m.deleted_at != nil {
  10184. fields = append(fields, sopstage.FieldDeletedAt)
  10185. }
  10186. if m.sop_task != nil {
  10187. fields = append(fields, sopstage.FieldTaskID)
  10188. }
  10189. if m.name != nil {
  10190. fields = append(fields, sopstage.FieldName)
  10191. }
  10192. if m.condition_type != nil {
  10193. fields = append(fields, sopstage.FieldConditionType)
  10194. }
  10195. if m.condition_operator != nil {
  10196. fields = append(fields, sopstage.FieldConditionOperator)
  10197. }
  10198. if m.condition_list != nil {
  10199. fields = append(fields, sopstage.FieldConditionList)
  10200. }
  10201. if m.action_message != nil {
  10202. fields = append(fields, sopstage.FieldActionMessage)
  10203. }
  10204. if m.action_label != nil {
  10205. fields = append(fields, sopstage.FieldActionLabel)
  10206. }
  10207. if m.index_sort != nil {
  10208. fields = append(fields, sopstage.FieldIndexSort)
  10209. }
  10210. return fields
  10211. }
  10212. // Field returns the value of a field with the given name. The second boolean
  10213. // return value indicates that this field was not set, or was not defined in the
  10214. // schema.
  10215. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  10216. switch name {
  10217. case sopstage.FieldCreatedAt:
  10218. return m.CreatedAt()
  10219. case sopstage.FieldUpdatedAt:
  10220. return m.UpdatedAt()
  10221. case sopstage.FieldStatus:
  10222. return m.Status()
  10223. case sopstage.FieldDeletedAt:
  10224. return m.DeletedAt()
  10225. case sopstage.FieldTaskID:
  10226. return m.TaskID()
  10227. case sopstage.FieldName:
  10228. return m.Name()
  10229. case sopstage.FieldConditionType:
  10230. return m.ConditionType()
  10231. case sopstage.FieldConditionOperator:
  10232. return m.ConditionOperator()
  10233. case sopstage.FieldConditionList:
  10234. return m.ConditionList()
  10235. case sopstage.FieldActionMessage:
  10236. return m.ActionMessage()
  10237. case sopstage.FieldActionLabel:
  10238. return m.ActionLabel()
  10239. case sopstage.FieldIndexSort:
  10240. return m.IndexSort()
  10241. }
  10242. return nil, false
  10243. }
  10244. // OldField returns the old value of the field from the database. An error is
  10245. // returned if the mutation operation is not UpdateOne, or the query to the
  10246. // database failed.
  10247. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10248. switch name {
  10249. case sopstage.FieldCreatedAt:
  10250. return m.OldCreatedAt(ctx)
  10251. case sopstage.FieldUpdatedAt:
  10252. return m.OldUpdatedAt(ctx)
  10253. case sopstage.FieldStatus:
  10254. return m.OldStatus(ctx)
  10255. case sopstage.FieldDeletedAt:
  10256. return m.OldDeletedAt(ctx)
  10257. case sopstage.FieldTaskID:
  10258. return m.OldTaskID(ctx)
  10259. case sopstage.FieldName:
  10260. return m.OldName(ctx)
  10261. case sopstage.FieldConditionType:
  10262. return m.OldConditionType(ctx)
  10263. case sopstage.FieldConditionOperator:
  10264. return m.OldConditionOperator(ctx)
  10265. case sopstage.FieldConditionList:
  10266. return m.OldConditionList(ctx)
  10267. case sopstage.FieldActionMessage:
  10268. return m.OldActionMessage(ctx)
  10269. case sopstage.FieldActionLabel:
  10270. return m.OldActionLabel(ctx)
  10271. case sopstage.FieldIndexSort:
  10272. return m.OldIndexSort(ctx)
  10273. }
  10274. return nil, fmt.Errorf("unknown SopStage field %s", name)
  10275. }
  10276. // SetField sets the value of a field with the given name. It returns an error if
  10277. // the field is not defined in the schema, or if the type mismatched the field
  10278. // type.
  10279. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  10280. switch name {
  10281. case sopstage.FieldCreatedAt:
  10282. v, ok := value.(time.Time)
  10283. if !ok {
  10284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10285. }
  10286. m.SetCreatedAt(v)
  10287. return nil
  10288. case sopstage.FieldUpdatedAt:
  10289. v, ok := value.(time.Time)
  10290. if !ok {
  10291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10292. }
  10293. m.SetUpdatedAt(v)
  10294. return nil
  10295. case sopstage.FieldStatus:
  10296. v, ok := value.(uint8)
  10297. if !ok {
  10298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10299. }
  10300. m.SetStatus(v)
  10301. return nil
  10302. case sopstage.FieldDeletedAt:
  10303. v, ok := value.(time.Time)
  10304. if !ok {
  10305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10306. }
  10307. m.SetDeletedAt(v)
  10308. return nil
  10309. case sopstage.FieldTaskID:
  10310. v, ok := value.(uint64)
  10311. if !ok {
  10312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10313. }
  10314. m.SetTaskID(v)
  10315. return nil
  10316. case sopstage.FieldName:
  10317. v, ok := value.(string)
  10318. if !ok {
  10319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10320. }
  10321. m.SetName(v)
  10322. return nil
  10323. case sopstage.FieldConditionType:
  10324. v, ok := value.(int)
  10325. if !ok {
  10326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10327. }
  10328. m.SetConditionType(v)
  10329. return nil
  10330. case sopstage.FieldConditionOperator:
  10331. v, ok := value.(int)
  10332. if !ok {
  10333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10334. }
  10335. m.SetConditionOperator(v)
  10336. return nil
  10337. case sopstage.FieldConditionList:
  10338. v, ok := value.([]custom_types.Condition)
  10339. if !ok {
  10340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10341. }
  10342. m.SetConditionList(v)
  10343. return nil
  10344. case sopstage.FieldActionMessage:
  10345. v, ok := value.([]custom_types.Action)
  10346. if !ok {
  10347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10348. }
  10349. m.SetActionMessage(v)
  10350. return nil
  10351. case sopstage.FieldActionLabel:
  10352. v, ok := value.([]uint64)
  10353. if !ok {
  10354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10355. }
  10356. m.SetActionLabel(v)
  10357. return nil
  10358. case sopstage.FieldIndexSort:
  10359. v, ok := value.(int)
  10360. if !ok {
  10361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10362. }
  10363. m.SetIndexSort(v)
  10364. return nil
  10365. }
  10366. return fmt.Errorf("unknown SopStage field %s", name)
  10367. }
  10368. // AddedFields returns all numeric fields that were incremented/decremented during
  10369. // this mutation.
  10370. func (m *SopStageMutation) AddedFields() []string {
  10371. var fields []string
  10372. if m.addstatus != nil {
  10373. fields = append(fields, sopstage.FieldStatus)
  10374. }
  10375. if m.addcondition_type != nil {
  10376. fields = append(fields, sopstage.FieldConditionType)
  10377. }
  10378. if m.addcondition_operator != nil {
  10379. fields = append(fields, sopstage.FieldConditionOperator)
  10380. }
  10381. if m.addindex_sort != nil {
  10382. fields = append(fields, sopstage.FieldIndexSort)
  10383. }
  10384. return fields
  10385. }
  10386. // AddedField returns the numeric value that was incremented/decremented on a field
  10387. // with the given name. The second boolean return value indicates that this field
  10388. // was not set, or was not defined in the schema.
  10389. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  10390. switch name {
  10391. case sopstage.FieldStatus:
  10392. return m.AddedStatus()
  10393. case sopstage.FieldConditionType:
  10394. return m.AddedConditionType()
  10395. case sopstage.FieldConditionOperator:
  10396. return m.AddedConditionOperator()
  10397. case sopstage.FieldIndexSort:
  10398. return m.AddedIndexSort()
  10399. }
  10400. return nil, false
  10401. }
  10402. // AddField adds the value to the field with the given name. It returns an error if
  10403. // the field is not defined in the schema, or if the type mismatched the field
  10404. // type.
  10405. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  10406. switch name {
  10407. case sopstage.FieldStatus:
  10408. v, ok := value.(int8)
  10409. if !ok {
  10410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10411. }
  10412. m.AddStatus(v)
  10413. return nil
  10414. case sopstage.FieldConditionType:
  10415. v, ok := value.(int)
  10416. if !ok {
  10417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10418. }
  10419. m.AddConditionType(v)
  10420. return nil
  10421. case sopstage.FieldConditionOperator:
  10422. v, ok := value.(int)
  10423. if !ok {
  10424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10425. }
  10426. m.AddConditionOperator(v)
  10427. return nil
  10428. case sopstage.FieldIndexSort:
  10429. v, ok := value.(int)
  10430. if !ok {
  10431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10432. }
  10433. m.AddIndexSort(v)
  10434. return nil
  10435. }
  10436. return fmt.Errorf("unknown SopStage numeric field %s", name)
  10437. }
  10438. // ClearedFields returns all nullable fields that were cleared during this
  10439. // mutation.
  10440. func (m *SopStageMutation) ClearedFields() []string {
  10441. var fields []string
  10442. if m.FieldCleared(sopstage.FieldStatus) {
  10443. fields = append(fields, sopstage.FieldStatus)
  10444. }
  10445. if m.FieldCleared(sopstage.FieldDeletedAt) {
  10446. fields = append(fields, sopstage.FieldDeletedAt)
  10447. }
  10448. if m.FieldCleared(sopstage.FieldActionMessage) {
  10449. fields = append(fields, sopstage.FieldActionMessage)
  10450. }
  10451. if m.FieldCleared(sopstage.FieldActionLabel) {
  10452. fields = append(fields, sopstage.FieldActionLabel)
  10453. }
  10454. if m.FieldCleared(sopstage.FieldIndexSort) {
  10455. fields = append(fields, sopstage.FieldIndexSort)
  10456. }
  10457. return fields
  10458. }
  10459. // FieldCleared returns a boolean indicating if a field with the given name was
  10460. // cleared in this mutation.
  10461. func (m *SopStageMutation) FieldCleared(name string) bool {
  10462. _, ok := m.clearedFields[name]
  10463. return ok
  10464. }
  10465. // ClearField clears the value of the field with the given name. It returns an
  10466. // error if the field is not defined in the schema.
  10467. func (m *SopStageMutation) ClearField(name string) error {
  10468. switch name {
  10469. case sopstage.FieldStatus:
  10470. m.ClearStatus()
  10471. return nil
  10472. case sopstage.FieldDeletedAt:
  10473. m.ClearDeletedAt()
  10474. return nil
  10475. case sopstage.FieldActionMessage:
  10476. m.ClearActionMessage()
  10477. return nil
  10478. case sopstage.FieldActionLabel:
  10479. m.ClearActionLabel()
  10480. return nil
  10481. case sopstage.FieldIndexSort:
  10482. m.ClearIndexSort()
  10483. return nil
  10484. }
  10485. return fmt.Errorf("unknown SopStage nullable field %s", name)
  10486. }
  10487. // ResetField resets all changes in the mutation for the field with the given name.
  10488. // It returns an error if the field is not defined in the schema.
  10489. func (m *SopStageMutation) ResetField(name string) error {
  10490. switch name {
  10491. case sopstage.FieldCreatedAt:
  10492. m.ResetCreatedAt()
  10493. return nil
  10494. case sopstage.FieldUpdatedAt:
  10495. m.ResetUpdatedAt()
  10496. return nil
  10497. case sopstage.FieldStatus:
  10498. m.ResetStatus()
  10499. return nil
  10500. case sopstage.FieldDeletedAt:
  10501. m.ResetDeletedAt()
  10502. return nil
  10503. case sopstage.FieldTaskID:
  10504. m.ResetTaskID()
  10505. return nil
  10506. case sopstage.FieldName:
  10507. m.ResetName()
  10508. return nil
  10509. case sopstage.FieldConditionType:
  10510. m.ResetConditionType()
  10511. return nil
  10512. case sopstage.FieldConditionOperator:
  10513. m.ResetConditionOperator()
  10514. return nil
  10515. case sopstage.FieldConditionList:
  10516. m.ResetConditionList()
  10517. return nil
  10518. case sopstage.FieldActionMessage:
  10519. m.ResetActionMessage()
  10520. return nil
  10521. case sopstage.FieldActionLabel:
  10522. m.ResetActionLabel()
  10523. return nil
  10524. case sopstage.FieldIndexSort:
  10525. m.ResetIndexSort()
  10526. return nil
  10527. }
  10528. return fmt.Errorf("unknown SopStage field %s", name)
  10529. }
  10530. // AddedEdges returns all edge names that were set/added in this mutation.
  10531. func (m *SopStageMutation) AddedEdges() []string {
  10532. edges := make([]string, 0, 3)
  10533. if m.sop_task != nil {
  10534. edges = append(edges, sopstage.EdgeSopTask)
  10535. }
  10536. if m.stage_nodes != nil {
  10537. edges = append(edges, sopstage.EdgeStageNodes)
  10538. }
  10539. if m.stage_messages != nil {
  10540. edges = append(edges, sopstage.EdgeStageMessages)
  10541. }
  10542. return edges
  10543. }
  10544. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10545. // name in this mutation.
  10546. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  10547. switch name {
  10548. case sopstage.EdgeSopTask:
  10549. if id := m.sop_task; id != nil {
  10550. return []ent.Value{*id}
  10551. }
  10552. case sopstage.EdgeStageNodes:
  10553. ids := make([]ent.Value, 0, len(m.stage_nodes))
  10554. for id := range m.stage_nodes {
  10555. ids = append(ids, id)
  10556. }
  10557. return ids
  10558. case sopstage.EdgeStageMessages:
  10559. ids := make([]ent.Value, 0, len(m.stage_messages))
  10560. for id := range m.stage_messages {
  10561. ids = append(ids, id)
  10562. }
  10563. return ids
  10564. }
  10565. return nil
  10566. }
  10567. // RemovedEdges returns all edge names that were removed in this mutation.
  10568. func (m *SopStageMutation) RemovedEdges() []string {
  10569. edges := make([]string, 0, 3)
  10570. if m.removedstage_nodes != nil {
  10571. edges = append(edges, sopstage.EdgeStageNodes)
  10572. }
  10573. if m.removedstage_messages != nil {
  10574. edges = append(edges, sopstage.EdgeStageMessages)
  10575. }
  10576. return edges
  10577. }
  10578. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10579. // the given name in this mutation.
  10580. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  10581. switch name {
  10582. case sopstage.EdgeStageNodes:
  10583. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  10584. for id := range m.removedstage_nodes {
  10585. ids = append(ids, id)
  10586. }
  10587. return ids
  10588. case sopstage.EdgeStageMessages:
  10589. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  10590. for id := range m.removedstage_messages {
  10591. ids = append(ids, id)
  10592. }
  10593. return ids
  10594. }
  10595. return nil
  10596. }
  10597. // ClearedEdges returns all edge names that were cleared in this mutation.
  10598. func (m *SopStageMutation) ClearedEdges() []string {
  10599. edges := make([]string, 0, 3)
  10600. if m.clearedsop_task {
  10601. edges = append(edges, sopstage.EdgeSopTask)
  10602. }
  10603. if m.clearedstage_nodes {
  10604. edges = append(edges, sopstage.EdgeStageNodes)
  10605. }
  10606. if m.clearedstage_messages {
  10607. edges = append(edges, sopstage.EdgeStageMessages)
  10608. }
  10609. return edges
  10610. }
  10611. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10612. // was cleared in this mutation.
  10613. func (m *SopStageMutation) EdgeCleared(name string) bool {
  10614. switch name {
  10615. case sopstage.EdgeSopTask:
  10616. return m.clearedsop_task
  10617. case sopstage.EdgeStageNodes:
  10618. return m.clearedstage_nodes
  10619. case sopstage.EdgeStageMessages:
  10620. return m.clearedstage_messages
  10621. }
  10622. return false
  10623. }
  10624. // ClearEdge clears the value of the edge with the given name. It returns an error
  10625. // if that edge is not defined in the schema.
  10626. func (m *SopStageMutation) ClearEdge(name string) error {
  10627. switch name {
  10628. case sopstage.EdgeSopTask:
  10629. m.ClearSopTask()
  10630. return nil
  10631. }
  10632. return fmt.Errorf("unknown SopStage unique edge %s", name)
  10633. }
  10634. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10635. // It returns an error if the edge is not defined in the schema.
  10636. func (m *SopStageMutation) ResetEdge(name string) error {
  10637. switch name {
  10638. case sopstage.EdgeSopTask:
  10639. m.ResetSopTask()
  10640. return nil
  10641. case sopstage.EdgeStageNodes:
  10642. m.ResetStageNodes()
  10643. return nil
  10644. case sopstage.EdgeStageMessages:
  10645. m.ResetStageMessages()
  10646. return nil
  10647. }
  10648. return fmt.Errorf("unknown SopStage edge %s", name)
  10649. }
  10650. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  10651. type SopTaskMutation struct {
  10652. config
  10653. op Op
  10654. typ string
  10655. id *uint64
  10656. created_at *time.Time
  10657. updated_at *time.Time
  10658. status *uint8
  10659. addstatus *int8
  10660. deleted_at *time.Time
  10661. name *string
  10662. bot_wxid_list *[]string
  10663. appendbot_wxid_list []string
  10664. _type *int
  10665. add_type *int
  10666. plan_start_time *time.Time
  10667. plan_end_time *time.Time
  10668. creator_id *string
  10669. clearedFields map[string]struct{}
  10670. task_stages map[uint64]struct{}
  10671. removedtask_stages map[uint64]struct{}
  10672. clearedtask_stages bool
  10673. done bool
  10674. oldValue func(context.Context) (*SopTask, error)
  10675. predicates []predicate.SopTask
  10676. }
  10677. var _ ent.Mutation = (*SopTaskMutation)(nil)
  10678. // soptaskOption allows management of the mutation configuration using functional options.
  10679. type soptaskOption func(*SopTaskMutation)
  10680. // newSopTaskMutation creates new mutation for the SopTask entity.
  10681. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  10682. m := &SopTaskMutation{
  10683. config: c,
  10684. op: op,
  10685. typ: TypeSopTask,
  10686. clearedFields: make(map[string]struct{}),
  10687. }
  10688. for _, opt := range opts {
  10689. opt(m)
  10690. }
  10691. return m
  10692. }
  10693. // withSopTaskID sets the ID field of the mutation.
  10694. func withSopTaskID(id uint64) soptaskOption {
  10695. return func(m *SopTaskMutation) {
  10696. var (
  10697. err error
  10698. once sync.Once
  10699. value *SopTask
  10700. )
  10701. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  10702. once.Do(func() {
  10703. if m.done {
  10704. err = errors.New("querying old values post mutation is not allowed")
  10705. } else {
  10706. value, err = m.Client().SopTask.Get(ctx, id)
  10707. }
  10708. })
  10709. return value, err
  10710. }
  10711. m.id = &id
  10712. }
  10713. }
  10714. // withSopTask sets the old SopTask of the mutation.
  10715. func withSopTask(node *SopTask) soptaskOption {
  10716. return func(m *SopTaskMutation) {
  10717. m.oldValue = func(context.Context) (*SopTask, error) {
  10718. return node, nil
  10719. }
  10720. m.id = &node.ID
  10721. }
  10722. }
  10723. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10724. // executed in a transaction (ent.Tx), a transactional client is returned.
  10725. func (m SopTaskMutation) Client() *Client {
  10726. client := &Client{config: m.config}
  10727. client.init()
  10728. return client
  10729. }
  10730. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10731. // it returns an error otherwise.
  10732. func (m SopTaskMutation) Tx() (*Tx, error) {
  10733. if _, ok := m.driver.(*txDriver); !ok {
  10734. return nil, errors.New("ent: mutation is not running in a transaction")
  10735. }
  10736. tx := &Tx{config: m.config}
  10737. tx.init()
  10738. return tx, nil
  10739. }
  10740. // SetID sets the value of the id field. Note that this
  10741. // operation is only accepted on creation of SopTask entities.
  10742. func (m *SopTaskMutation) SetID(id uint64) {
  10743. m.id = &id
  10744. }
  10745. // ID returns the ID value in the mutation. Note that the ID is only available
  10746. // if it was provided to the builder or after it was returned from the database.
  10747. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  10748. if m.id == nil {
  10749. return
  10750. }
  10751. return *m.id, true
  10752. }
  10753. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10754. // That means, if the mutation is applied within a transaction with an isolation level such
  10755. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10756. // or updated by the mutation.
  10757. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  10758. switch {
  10759. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10760. id, exists := m.ID()
  10761. if exists {
  10762. return []uint64{id}, nil
  10763. }
  10764. fallthrough
  10765. case m.op.Is(OpUpdate | OpDelete):
  10766. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  10767. default:
  10768. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10769. }
  10770. }
  10771. // SetCreatedAt sets the "created_at" field.
  10772. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  10773. m.created_at = &t
  10774. }
  10775. // CreatedAt returns the value of the "created_at" field in the mutation.
  10776. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  10777. v := m.created_at
  10778. if v == nil {
  10779. return
  10780. }
  10781. return *v, true
  10782. }
  10783. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  10784. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  10785. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10786. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10787. if !m.op.Is(OpUpdateOne) {
  10788. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10789. }
  10790. if m.id == nil || m.oldValue == nil {
  10791. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10792. }
  10793. oldValue, err := m.oldValue(ctx)
  10794. if err != nil {
  10795. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10796. }
  10797. return oldValue.CreatedAt, nil
  10798. }
  10799. // ResetCreatedAt resets all changes to the "created_at" field.
  10800. func (m *SopTaskMutation) ResetCreatedAt() {
  10801. m.created_at = nil
  10802. }
  10803. // SetUpdatedAt sets the "updated_at" field.
  10804. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  10805. m.updated_at = &t
  10806. }
  10807. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10808. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  10809. v := m.updated_at
  10810. if v == nil {
  10811. return
  10812. }
  10813. return *v, true
  10814. }
  10815. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  10816. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  10817. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10818. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10819. if !m.op.Is(OpUpdateOne) {
  10820. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10821. }
  10822. if m.id == nil || m.oldValue == nil {
  10823. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10824. }
  10825. oldValue, err := m.oldValue(ctx)
  10826. if err != nil {
  10827. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10828. }
  10829. return oldValue.UpdatedAt, nil
  10830. }
  10831. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10832. func (m *SopTaskMutation) ResetUpdatedAt() {
  10833. m.updated_at = nil
  10834. }
  10835. // SetStatus sets the "status" field.
  10836. func (m *SopTaskMutation) SetStatus(u uint8) {
  10837. m.status = &u
  10838. m.addstatus = nil
  10839. }
  10840. // Status returns the value of the "status" field in the mutation.
  10841. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  10842. v := m.status
  10843. if v == nil {
  10844. return
  10845. }
  10846. return *v, true
  10847. }
  10848. // OldStatus returns the old "status" field's value of the SopTask entity.
  10849. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  10850. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10851. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  10852. if !m.op.Is(OpUpdateOne) {
  10853. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  10854. }
  10855. if m.id == nil || m.oldValue == nil {
  10856. return v, errors.New("OldStatus requires an ID field in the mutation")
  10857. }
  10858. oldValue, err := m.oldValue(ctx)
  10859. if err != nil {
  10860. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  10861. }
  10862. return oldValue.Status, nil
  10863. }
  10864. // AddStatus adds u to the "status" field.
  10865. func (m *SopTaskMutation) AddStatus(u int8) {
  10866. if m.addstatus != nil {
  10867. *m.addstatus += u
  10868. } else {
  10869. m.addstatus = &u
  10870. }
  10871. }
  10872. // AddedStatus returns the value that was added to the "status" field in this mutation.
  10873. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  10874. v := m.addstatus
  10875. if v == nil {
  10876. return
  10877. }
  10878. return *v, true
  10879. }
  10880. // ClearStatus clears the value of the "status" field.
  10881. func (m *SopTaskMutation) ClearStatus() {
  10882. m.status = nil
  10883. m.addstatus = nil
  10884. m.clearedFields[soptask.FieldStatus] = struct{}{}
  10885. }
  10886. // StatusCleared returns if the "status" field was cleared in this mutation.
  10887. func (m *SopTaskMutation) StatusCleared() bool {
  10888. _, ok := m.clearedFields[soptask.FieldStatus]
  10889. return ok
  10890. }
  10891. // ResetStatus resets all changes to the "status" field.
  10892. func (m *SopTaskMutation) ResetStatus() {
  10893. m.status = nil
  10894. m.addstatus = nil
  10895. delete(m.clearedFields, soptask.FieldStatus)
  10896. }
  10897. // SetDeletedAt sets the "deleted_at" field.
  10898. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  10899. m.deleted_at = &t
  10900. }
  10901. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10902. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  10903. v := m.deleted_at
  10904. if v == nil {
  10905. return
  10906. }
  10907. return *v, true
  10908. }
  10909. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  10910. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  10911. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10912. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10913. if !m.op.Is(OpUpdateOne) {
  10914. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10915. }
  10916. if m.id == nil || m.oldValue == nil {
  10917. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10918. }
  10919. oldValue, err := m.oldValue(ctx)
  10920. if err != nil {
  10921. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10922. }
  10923. return oldValue.DeletedAt, nil
  10924. }
  10925. // ClearDeletedAt clears the value of the "deleted_at" field.
  10926. func (m *SopTaskMutation) ClearDeletedAt() {
  10927. m.deleted_at = nil
  10928. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  10929. }
  10930. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10931. func (m *SopTaskMutation) DeletedAtCleared() bool {
  10932. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  10933. return ok
  10934. }
  10935. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10936. func (m *SopTaskMutation) ResetDeletedAt() {
  10937. m.deleted_at = nil
  10938. delete(m.clearedFields, soptask.FieldDeletedAt)
  10939. }
  10940. // SetName sets the "name" field.
  10941. func (m *SopTaskMutation) SetName(s string) {
  10942. m.name = &s
  10943. }
  10944. // Name returns the value of the "name" field in the mutation.
  10945. func (m *SopTaskMutation) Name() (r string, exists bool) {
  10946. v := m.name
  10947. if v == nil {
  10948. return
  10949. }
  10950. return *v, true
  10951. }
  10952. // OldName returns the old "name" field's value of the SopTask entity.
  10953. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  10954. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10955. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  10956. if !m.op.Is(OpUpdateOne) {
  10957. return v, errors.New("OldName is only allowed on UpdateOne operations")
  10958. }
  10959. if m.id == nil || m.oldValue == nil {
  10960. return v, errors.New("OldName requires an ID field in the mutation")
  10961. }
  10962. oldValue, err := m.oldValue(ctx)
  10963. if err != nil {
  10964. return v, fmt.Errorf("querying old value for OldName: %w", err)
  10965. }
  10966. return oldValue.Name, nil
  10967. }
  10968. // ResetName resets all changes to the "name" field.
  10969. func (m *SopTaskMutation) ResetName() {
  10970. m.name = nil
  10971. }
  10972. // SetBotWxidList sets the "bot_wxid_list" field.
  10973. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  10974. m.bot_wxid_list = &s
  10975. m.appendbot_wxid_list = nil
  10976. }
  10977. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  10978. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  10979. v := m.bot_wxid_list
  10980. if v == nil {
  10981. return
  10982. }
  10983. return *v, true
  10984. }
  10985. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  10986. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  10987. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10988. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  10989. if !m.op.Is(OpUpdateOne) {
  10990. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  10991. }
  10992. if m.id == nil || m.oldValue == nil {
  10993. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  10994. }
  10995. oldValue, err := m.oldValue(ctx)
  10996. if err != nil {
  10997. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  10998. }
  10999. return oldValue.BotWxidList, nil
  11000. }
  11001. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  11002. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  11003. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  11004. }
  11005. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  11006. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  11007. if len(m.appendbot_wxid_list) == 0 {
  11008. return nil, false
  11009. }
  11010. return m.appendbot_wxid_list, true
  11011. }
  11012. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  11013. func (m *SopTaskMutation) ClearBotWxidList() {
  11014. m.bot_wxid_list = nil
  11015. m.appendbot_wxid_list = nil
  11016. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  11017. }
  11018. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  11019. func (m *SopTaskMutation) BotWxidListCleared() bool {
  11020. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  11021. return ok
  11022. }
  11023. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  11024. func (m *SopTaskMutation) ResetBotWxidList() {
  11025. m.bot_wxid_list = nil
  11026. m.appendbot_wxid_list = nil
  11027. delete(m.clearedFields, soptask.FieldBotWxidList)
  11028. }
  11029. // SetType sets the "type" field.
  11030. func (m *SopTaskMutation) SetType(i int) {
  11031. m._type = &i
  11032. m.add_type = nil
  11033. }
  11034. // GetType returns the value of the "type" field in the mutation.
  11035. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  11036. v := m._type
  11037. if v == nil {
  11038. return
  11039. }
  11040. return *v, true
  11041. }
  11042. // OldType returns the old "type" field's value of the SopTask entity.
  11043. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  11044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11045. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  11046. if !m.op.Is(OpUpdateOne) {
  11047. return v, errors.New("OldType is only allowed on UpdateOne operations")
  11048. }
  11049. if m.id == nil || m.oldValue == nil {
  11050. return v, errors.New("OldType requires an ID field in the mutation")
  11051. }
  11052. oldValue, err := m.oldValue(ctx)
  11053. if err != nil {
  11054. return v, fmt.Errorf("querying old value for OldType: %w", err)
  11055. }
  11056. return oldValue.Type, nil
  11057. }
  11058. // AddType adds i to the "type" field.
  11059. func (m *SopTaskMutation) AddType(i int) {
  11060. if m.add_type != nil {
  11061. *m.add_type += i
  11062. } else {
  11063. m.add_type = &i
  11064. }
  11065. }
  11066. // AddedType returns the value that was added to the "type" field in this mutation.
  11067. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  11068. v := m.add_type
  11069. if v == nil {
  11070. return
  11071. }
  11072. return *v, true
  11073. }
  11074. // ResetType resets all changes to the "type" field.
  11075. func (m *SopTaskMutation) ResetType() {
  11076. m._type = nil
  11077. m.add_type = nil
  11078. }
  11079. // SetPlanStartTime sets the "plan_start_time" field.
  11080. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  11081. m.plan_start_time = &t
  11082. }
  11083. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  11084. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  11085. v := m.plan_start_time
  11086. if v == nil {
  11087. return
  11088. }
  11089. return *v, true
  11090. }
  11091. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  11092. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  11093. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11094. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  11095. if !m.op.Is(OpUpdateOne) {
  11096. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  11097. }
  11098. if m.id == nil || m.oldValue == nil {
  11099. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  11100. }
  11101. oldValue, err := m.oldValue(ctx)
  11102. if err != nil {
  11103. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  11104. }
  11105. return oldValue.PlanStartTime, nil
  11106. }
  11107. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  11108. func (m *SopTaskMutation) ClearPlanStartTime() {
  11109. m.plan_start_time = nil
  11110. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  11111. }
  11112. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  11113. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  11114. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  11115. return ok
  11116. }
  11117. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  11118. func (m *SopTaskMutation) ResetPlanStartTime() {
  11119. m.plan_start_time = nil
  11120. delete(m.clearedFields, soptask.FieldPlanStartTime)
  11121. }
  11122. // SetPlanEndTime sets the "plan_end_time" field.
  11123. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  11124. m.plan_end_time = &t
  11125. }
  11126. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  11127. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  11128. v := m.plan_end_time
  11129. if v == nil {
  11130. return
  11131. }
  11132. return *v, true
  11133. }
  11134. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  11135. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  11136. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11137. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  11138. if !m.op.Is(OpUpdateOne) {
  11139. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  11140. }
  11141. if m.id == nil || m.oldValue == nil {
  11142. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  11143. }
  11144. oldValue, err := m.oldValue(ctx)
  11145. if err != nil {
  11146. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  11147. }
  11148. return oldValue.PlanEndTime, nil
  11149. }
  11150. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  11151. func (m *SopTaskMutation) ClearPlanEndTime() {
  11152. m.plan_end_time = nil
  11153. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  11154. }
  11155. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  11156. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  11157. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  11158. return ok
  11159. }
  11160. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  11161. func (m *SopTaskMutation) ResetPlanEndTime() {
  11162. m.plan_end_time = nil
  11163. delete(m.clearedFields, soptask.FieldPlanEndTime)
  11164. }
  11165. // SetCreatorID sets the "creator_id" field.
  11166. func (m *SopTaskMutation) SetCreatorID(s string) {
  11167. m.creator_id = &s
  11168. }
  11169. // CreatorID returns the value of the "creator_id" field in the mutation.
  11170. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  11171. v := m.creator_id
  11172. if v == nil {
  11173. return
  11174. }
  11175. return *v, true
  11176. }
  11177. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  11178. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  11179. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11180. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  11181. if !m.op.Is(OpUpdateOne) {
  11182. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  11183. }
  11184. if m.id == nil || m.oldValue == nil {
  11185. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  11186. }
  11187. oldValue, err := m.oldValue(ctx)
  11188. if err != nil {
  11189. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  11190. }
  11191. return oldValue.CreatorID, nil
  11192. }
  11193. // ClearCreatorID clears the value of the "creator_id" field.
  11194. func (m *SopTaskMutation) ClearCreatorID() {
  11195. m.creator_id = nil
  11196. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  11197. }
  11198. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  11199. func (m *SopTaskMutation) CreatorIDCleared() bool {
  11200. _, ok := m.clearedFields[soptask.FieldCreatorID]
  11201. return ok
  11202. }
  11203. // ResetCreatorID resets all changes to the "creator_id" field.
  11204. func (m *SopTaskMutation) ResetCreatorID() {
  11205. m.creator_id = nil
  11206. delete(m.clearedFields, soptask.FieldCreatorID)
  11207. }
  11208. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  11209. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  11210. if m.task_stages == nil {
  11211. m.task_stages = make(map[uint64]struct{})
  11212. }
  11213. for i := range ids {
  11214. m.task_stages[ids[i]] = struct{}{}
  11215. }
  11216. }
  11217. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  11218. func (m *SopTaskMutation) ClearTaskStages() {
  11219. m.clearedtask_stages = true
  11220. }
  11221. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  11222. func (m *SopTaskMutation) TaskStagesCleared() bool {
  11223. return m.clearedtask_stages
  11224. }
  11225. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  11226. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  11227. if m.removedtask_stages == nil {
  11228. m.removedtask_stages = make(map[uint64]struct{})
  11229. }
  11230. for i := range ids {
  11231. delete(m.task_stages, ids[i])
  11232. m.removedtask_stages[ids[i]] = struct{}{}
  11233. }
  11234. }
  11235. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  11236. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  11237. for id := range m.removedtask_stages {
  11238. ids = append(ids, id)
  11239. }
  11240. return
  11241. }
  11242. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  11243. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  11244. for id := range m.task_stages {
  11245. ids = append(ids, id)
  11246. }
  11247. return
  11248. }
  11249. // ResetTaskStages resets all changes to the "task_stages" edge.
  11250. func (m *SopTaskMutation) ResetTaskStages() {
  11251. m.task_stages = nil
  11252. m.clearedtask_stages = false
  11253. m.removedtask_stages = nil
  11254. }
  11255. // Where appends a list predicates to the SopTaskMutation builder.
  11256. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  11257. m.predicates = append(m.predicates, ps...)
  11258. }
  11259. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  11260. // users can use type-assertion to append predicates that do not depend on any generated package.
  11261. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  11262. p := make([]predicate.SopTask, len(ps))
  11263. for i := range ps {
  11264. p[i] = ps[i]
  11265. }
  11266. m.Where(p...)
  11267. }
  11268. // Op returns the operation name.
  11269. func (m *SopTaskMutation) Op() Op {
  11270. return m.op
  11271. }
  11272. // SetOp allows setting the mutation operation.
  11273. func (m *SopTaskMutation) SetOp(op Op) {
  11274. m.op = op
  11275. }
  11276. // Type returns the node type of this mutation (SopTask).
  11277. func (m *SopTaskMutation) Type() string {
  11278. return m.typ
  11279. }
  11280. // Fields returns all fields that were changed during this mutation. Note that in
  11281. // order to get all numeric fields that were incremented/decremented, call
  11282. // AddedFields().
  11283. func (m *SopTaskMutation) Fields() []string {
  11284. fields := make([]string, 0, 10)
  11285. if m.created_at != nil {
  11286. fields = append(fields, soptask.FieldCreatedAt)
  11287. }
  11288. if m.updated_at != nil {
  11289. fields = append(fields, soptask.FieldUpdatedAt)
  11290. }
  11291. if m.status != nil {
  11292. fields = append(fields, soptask.FieldStatus)
  11293. }
  11294. if m.deleted_at != nil {
  11295. fields = append(fields, soptask.FieldDeletedAt)
  11296. }
  11297. if m.name != nil {
  11298. fields = append(fields, soptask.FieldName)
  11299. }
  11300. if m.bot_wxid_list != nil {
  11301. fields = append(fields, soptask.FieldBotWxidList)
  11302. }
  11303. if m._type != nil {
  11304. fields = append(fields, soptask.FieldType)
  11305. }
  11306. if m.plan_start_time != nil {
  11307. fields = append(fields, soptask.FieldPlanStartTime)
  11308. }
  11309. if m.plan_end_time != nil {
  11310. fields = append(fields, soptask.FieldPlanEndTime)
  11311. }
  11312. if m.creator_id != nil {
  11313. fields = append(fields, soptask.FieldCreatorID)
  11314. }
  11315. return fields
  11316. }
  11317. // Field returns the value of a field with the given name. The second boolean
  11318. // return value indicates that this field was not set, or was not defined in the
  11319. // schema.
  11320. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  11321. switch name {
  11322. case soptask.FieldCreatedAt:
  11323. return m.CreatedAt()
  11324. case soptask.FieldUpdatedAt:
  11325. return m.UpdatedAt()
  11326. case soptask.FieldStatus:
  11327. return m.Status()
  11328. case soptask.FieldDeletedAt:
  11329. return m.DeletedAt()
  11330. case soptask.FieldName:
  11331. return m.Name()
  11332. case soptask.FieldBotWxidList:
  11333. return m.BotWxidList()
  11334. case soptask.FieldType:
  11335. return m.GetType()
  11336. case soptask.FieldPlanStartTime:
  11337. return m.PlanStartTime()
  11338. case soptask.FieldPlanEndTime:
  11339. return m.PlanEndTime()
  11340. case soptask.FieldCreatorID:
  11341. return m.CreatorID()
  11342. }
  11343. return nil, false
  11344. }
  11345. // OldField returns the old value of the field from the database. An error is
  11346. // returned if the mutation operation is not UpdateOne, or the query to the
  11347. // database failed.
  11348. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11349. switch name {
  11350. case soptask.FieldCreatedAt:
  11351. return m.OldCreatedAt(ctx)
  11352. case soptask.FieldUpdatedAt:
  11353. return m.OldUpdatedAt(ctx)
  11354. case soptask.FieldStatus:
  11355. return m.OldStatus(ctx)
  11356. case soptask.FieldDeletedAt:
  11357. return m.OldDeletedAt(ctx)
  11358. case soptask.FieldName:
  11359. return m.OldName(ctx)
  11360. case soptask.FieldBotWxidList:
  11361. return m.OldBotWxidList(ctx)
  11362. case soptask.FieldType:
  11363. return m.OldType(ctx)
  11364. case soptask.FieldPlanStartTime:
  11365. return m.OldPlanStartTime(ctx)
  11366. case soptask.FieldPlanEndTime:
  11367. return m.OldPlanEndTime(ctx)
  11368. case soptask.FieldCreatorID:
  11369. return m.OldCreatorID(ctx)
  11370. }
  11371. return nil, fmt.Errorf("unknown SopTask field %s", name)
  11372. }
  11373. // SetField sets the value of a field with the given name. It returns an error if
  11374. // the field is not defined in the schema, or if the type mismatched the field
  11375. // type.
  11376. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  11377. switch name {
  11378. case soptask.FieldCreatedAt:
  11379. v, ok := value.(time.Time)
  11380. if !ok {
  11381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11382. }
  11383. m.SetCreatedAt(v)
  11384. return nil
  11385. case soptask.FieldUpdatedAt:
  11386. v, ok := value.(time.Time)
  11387. if !ok {
  11388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11389. }
  11390. m.SetUpdatedAt(v)
  11391. return nil
  11392. case soptask.FieldStatus:
  11393. v, ok := value.(uint8)
  11394. if !ok {
  11395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11396. }
  11397. m.SetStatus(v)
  11398. return nil
  11399. case soptask.FieldDeletedAt:
  11400. v, ok := value.(time.Time)
  11401. if !ok {
  11402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11403. }
  11404. m.SetDeletedAt(v)
  11405. return nil
  11406. case soptask.FieldName:
  11407. v, ok := value.(string)
  11408. if !ok {
  11409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11410. }
  11411. m.SetName(v)
  11412. return nil
  11413. case soptask.FieldBotWxidList:
  11414. v, ok := value.([]string)
  11415. if !ok {
  11416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11417. }
  11418. m.SetBotWxidList(v)
  11419. return nil
  11420. case soptask.FieldType:
  11421. v, ok := value.(int)
  11422. if !ok {
  11423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11424. }
  11425. m.SetType(v)
  11426. return nil
  11427. case soptask.FieldPlanStartTime:
  11428. v, ok := value.(time.Time)
  11429. if !ok {
  11430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11431. }
  11432. m.SetPlanStartTime(v)
  11433. return nil
  11434. case soptask.FieldPlanEndTime:
  11435. v, ok := value.(time.Time)
  11436. if !ok {
  11437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11438. }
  11439. m.SetPlanEndTime(v)
  11440. return nil
  11441. case soptask.FieldCreatorID:
  11442. v, ok := value.(string)
  11443. if !ok {
  11444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11445. }
  11446. m.SetCreatorID(v)
  11447. return nil
  11448. }
  11449. return fmt.Errorf("unknown SopTask field %s", name)
  11450. }
  11451. // AddedFields returns all numeric fields that were incremented/decremented during
  11452. // this mutation.
  11453. func (m *SopTaskMutation) AddedFields() []string {
  11454. var fields []string
  11455. if m.addstatus != nil {
  11456. fields = append(fields, soptask.FieldStatus)
  11457. }
  11458. if m.add_type != nil {
  11459. fields = append(fields, soptask.FieldType)
  11460. }
  11461. return fields
  11462. }
  11463. // AddedField returns the numeric value that was incremented/decremented on a field
  11464. // with the given name. The second boolean return value indicates that this field
  11465. // was not set, or was not defined in the schema.
  11466. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  11467. switch name {
  11468. case soptask.FieldStatus:
  11469. return m.AddedStatus()
  11470. case soptask.FieldType:
  11471. return m.AddedType()
  11472. }
  11473. return nil, false
  11474. }
  11475. // AddField adds the value to the field with the given name. It returns an error if
  11476. // the field is not defined in the schema, or if the type mismatched the field
  11477. // type.
  11478. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  11479. switch name {
  11480. case soptask.FieldStatus:
  11481. v, ok := value.(int8)
  11482. if !ok {
  11483. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11484. }
  11485. m.AddStatus(v)
  11486. return nil
  11487. case soptask.FieldType:
  11488. v, ok := value.(int)
  11489. if !ok {
  11490. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11491. }
  11492. m.AddType(v)
  11493. return nil
  11494. }
  11495. return fmt.Errorf("unknown SopTask numeric field %s", name)
  11496. }
  11497. // ClearedFields returns all nullable fields that were cleared during this
  11498. // mutation.
  11499. func (m *SopTaskMutation) ClearedFields() []string {
  11500. var fields []string
  11501. if m.FieldCleared(soptask.FieldStatus) {
  11502. fields = append(fields, soptask.FieldStatus)
  11503. }
  11504. if m.FieldCleared(soptask.FieldDeletedAt) {
  11505. fields = append(fields, soptask.FieldDeletedAt)
  11506. }
  11507. if m.FieldCleared(soptask.FieldBotWxidList) {
  11508. fields = append(fields, soptask.FieldBotWxidList)
  11509. }
  11510. if m.FieldCleared(soptask.FieldPlanStartTime) {
  11511. fields = append(fields, soptask.FieldPlanStartTime)
  11512. }
  11513. if m.FieldCleared(soptask.FieldPlanEndTime) {
  11514. fields = append(fields, soptask.FieldPlanEndTime)
  11515. }
  11516. if m.FieldCleared(soptask.FieldCreatorID) {
  11517. fields = append(fields, soptask.FieldCreatorID)
  11518. }
  11519. return fields
  11520. }
  11521. // FieldCleared returns a boolean indicating if a field with the given name was
  11522. // cleared in this mutation.
  11523. func (m *SopTaskMutation) FieldCleared(name string) bool {
  11524. _, ok := m.clearedFields[name]
  11525. return ok
  11526. }
  11527. // ClearField clears the value of the field with the given name. It returns an
  11528. // error if the field is not defined in the schema.
  11529. func (m *SopTaskMutation) ClearField(name string) error {
  11530. switch name {
  11531. case soptask.FieldStatus:
  11532. m.ClearStatus()
  11533. return nil
  11534. case soptask.FieldDeletedAt:
  11535. m.ClearDeletedAt()
  11536. return nil
  11537. case soptask.FieldBotWxidList:
  11538. m.ClearBotWxidList()
  11539. return nil
  11540. case soptask.FieldPlanStartTime:
  11541. m.ClearPlanStartTime()
  11542. return nil
  11543. case soptask.FieldPlanEndTime:
  11544. m.ClearPlanEndTime()
  11545. return nil
  11546. case soptask.FieldCreatorID:
  11547. m.ClearCreatorID()
  11548. return nil
  11549. }
  11550. return fmt.Errorf("unknown SopTask nullable field %s", name)
  11551. }
  11552. // ResetField resets all changes in the mutation for the field with the given name.
  11553. // It returns an error if the field is not defined in the schema.
  11554. func (m *SopTaskMutation) ResetField(name string) error {
  11555. switch name {
  11556. case soptask.FieldCreatedAt:
  11557. m.ResetCreatedAt()
  11558. return nil
  11559. case soptask.FieldUpdatedAt:
  11560. m.ResetUpdatedAt()
  11561. return nil
  11562. case soptask.FieldStatus:
  11563. m.ResetStatus()
  11564. return nil
  11565. case soptask.FieldDeletedAt:
  11566. m.ResetDeletedAt()
  11567. return nil
  11568. case soptask.FieldName:
  11569. m.ResetName()
  11570. return nil
  11571. case soptask.FieldBotWxidList:
  11572. m.ResetBotWxidList()
  11573. return nil
  11574. case soptask.FieldType:
  11575. m.ResetType()
  11576. return nil
  11577. case soptask.FieldPlanStartTime:
  11578. m.ResetPlanStartTime()
  11579. return nil
  11580. case soptask.FieldPlanEndTime:
  11581. m.ResetPlanEndTime()
  11582. return nil
  11583. case soptask.FieldCreatorID:
  11584. m.ResetCreatorID()
  11585. return nil
  11586. }
  11587. return fmt.Errorf("unknown SopTask field %s", name)
  11588. }
  11589. // AddedEdges returns all edge names that were set/added in this mutation.
  11590. func (m *SopTaskMutation) AddedEdges() []string {
  11591. edges := make([]string, 0, 1)
  11592. if m.task_stages != nil {
  11593. edges = append(edges, soptask.EdgeTaskStages)
  11594. }
  11595. return edges
  11596. }
  11597. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11598. // name in this mutation.
  11599. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  11600. switch name {
  11601. case soptask.EdgeTaskStages:
  11602. ids := make([]ent.Value, 0, len(m.task_stages))
  11603. for id := range m.task_stages {
  11604. ids = append(ids, id)
  11605. }
  11606. return ids
  11607. }
  11608. return nil
  11609. }
  11610. // RemovedEdges returns all edge names that were removed in this mutation.
  11611. func (m *SopTaskMutation) RemovedEdges() []string {
  11612. edges := make([]string, 0, 1)
  11613. if m.removedtask_stages != nil {
  11614. edges = append(edges, soptask.EdgeTaskStages)
  11615. }
  11616. return edges
  11617. }
  11618. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11619. // the given name in this mutation.
  11620. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  11621. switch name {
  11622. case soptask.EdgeTaskStages:
  11623. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  11624. for id := range m.removedtask_stages {
  11625. ids = append(ids, id)
  11626. }
  11627. return ids
  11628. }
  11629. return nil
  11630. }
  11631. // ClearedEdges returns all edge names that were cleared in this mutation.
  11632. func (m *SopTaskMutation) ClearedEdges() []string {
  11633. edges := make([]string, 0, 1)
  11634. if m.clearedtask_stages {
  11635. edges = append(edges, soptask.EdgeTaskStages)
  11636. }
  11637. return edges
  11638. }
  11639. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11640. // was cleared in this mutation.
  11641. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  11642. switch name {
  11643. case soptask.EdgeTaskStages:
  11644. return m.clearedtask_stages
  11645. }
  11646. return false
  11647. }
  11648. // ClearEdge clears the value of the edge with the given name. It returns an error
  11649. // if that edge is not defined in the schema.
  11650. func (m *SopTaskMutation) ClearEdge(name string) error {
  11651. switch name {
  11652. }
  11653. return fmt.Errorf("unknown SopTask unique edge %s", name)
  11654. }
  11655. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11656. // It returns an error if the edge is not defined in the schema.
  11657. func (m *SopTaskMutation) ResetEdge(name string) error {
  11658. switch name {
  11659. case soptask.EdgeTaskStages:
  11660. m.ResetTaskStages()
  11661. return nil
  11662. }
  11663. return fmt.Errorf("unknown SopTask edge %s", name)
  11664. }
  11665. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  11666. type WxMutation struct {
  11667. config
  11668. op Op
  11669. typ string
  11670. id *uint64
  11671. created_at *time.Time
  11672. updated_at *time.Time
  11673. status *uint8
  11674. addstatus *int8
  11675. deleted_at *time.Time
  11676. port *string
  11677. process_id *string
  11678. callback *string
  11679. wxid *string
  11680. account *string
  11681. nickname *string
  11682. tel *string
  11683. head_big *string
  11684. clearedFields map[string]struct{}
  11685. server *uint64
  11686. clearedserver bool
  11687. done bool
  11688. oldValue func(context.Context) (*Wx, error)
  11689. predicates []predicate.Wx
  11690. }
  11691. var _ ent.Mutation = (*WxMutation)(nil)
  11692. // wxOption allows management of the mutation configuration using functional options.
  11693. type wxOption func(*WxMutation)
  11694. // newWxMutation creates new mutation for the Wx entity.
  11695. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  11696. m := &WxMutation{
  11697. config: c,
  11698. op: op,
  11699. typ: TypeWx,
  11700. clearedFields: make(map[string]struct{}),
  11701. }
  11702. for _, opt := range opts {
  11703. opt(m)
  11704. }
  11705. return m
  11706. }
  11707. // withWxID sets the ID field of the mutation.
  11708. func withWxID(id uint64) wxOption {
  11709. return func(m *WxMutation) {
  11710. var (
  11711. err error
  11712. once sync.Once
  11713. value *Wx
  11714. )
  11715. m.oldValue = func(ctx context.Context) (*Wx, error) {
  11716. once.Do(func() {
  11717. if m.done {
  11718. err = errors.New("querying old values post mutation is not allowed")
  11719. } else {
  11720. value, err = m.Client().Wx.Get(ctx, id)
  11721. }
  11722. })
  11723. return value, err
  11724. }
  11725. m.id = &id
  11726. }
  11727. }
  11728. // withWx sets the old Wx of the mutation.
  11729. func withWx(node *Wx) wxOption {
  11730. return func(m *WxMutation) {
  11731. m.oldValue = func(context.Context) (*Wx, error) {
  11732. return node, nil
  11733. }
  11734. m.id = &node.ID
  11735. }
  11736. }
  11737. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11738. // executed in a transaction (ent.Tx), a transactional client is returned.
  11739. func (m WxMutation) Client() *Client {
  11740. client := &Client{config: m.config}
  11741. client.init()
  11742. return client
  11743. }
  11744. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11745. // it returns an error otherwise.
  11746. func (m WxMutation) Tx() (*Tx, error) {
  11747. if _, ok := m.driver.(*txDriver); !ok {
  11748. return nil, errors.New("ent: mutation is not running in a transaction")
  11749. }
  11750. tx := &Tx{config: m.config}
  11751. tx.init()
  11752. return tx, nil
  11753. }
  11754. // SetID sets the value of the id field. Note that this
  11755. // operation is only accepted on creation of Wx entities.
  11756. func (m *WxMutation) SetID(id uint64) {
  11757. m.id = &id
  11758. }
  11759. // ID returns the ID value in the mutation. Note that the ID is only available
  11760. // if it was provided to the builder or after it was returned from the database.
  11761. func (m *WxMutation) ID() (id uint64, exists bool) {
  11762. if m.id == nil {
  11763. return
  11764. }
  11765. return *m.id, true
  11766. }
  11767. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11768. // That means, if the mutation is applied within a transaction with an isolation level such
  11769. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11770. // or updated by the mutation.
  11771. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  11772. switch {
  11773. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11774. id, exists := m.ID()
  11775. if exists {
  11776. return []uint64{id}, nil
  11777. }
  11778. fallthrough
  11779. case m.op.Is(OpUpdate | OpDelete):
  11780. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  11781. default:
  11782. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11783. }
  11784. }
  11785. // SetCreatedAt sets the "created_at" field.
  11786. func (m *WxMutation) SetCreatedAt(t time.Time) {
  11787. m.created_at = &t
  11788. }
  11789. // CreatedAt returns the value of the "created_at" field in the mutation.
  11790. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  11791. v := m.created_at
  11792. if v == nil {
  11793. return
  11794. }
  11795. return *v, true
  11796. }
  11797. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  11798. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  11799. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11800. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11801. if !m.op.Is(OpUpdateOne) {
  11802. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11803. }
  11804. if m.id == nil || m.oldValue == nil {
  11805. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11806. }
  11807. oldValue, err := m.oldValue(ctx)
  11808. if err != nil {
  11809. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11810. }
  11811. return oldValue.CreatedAt, nil
  11812. }
  11813. // ResetCreatedAt resets all changes to the "created_at" field.
  11814. func (m *WxMutation) ResetCreatedAt() {
  11815. m.created_at = nil
  11816. }
  11817. // SetUpdatedAt sets the "updated_at" field.
  11818. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  11819. m.updated_at = &t
  11820. }
  11821. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11822. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  11823. v := m.updated_at
  11824. if v == nil {
  11825. return
  11826. }
  11827. return *v, true
  11828. }
  11829. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  11830. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  11831. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11832. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11833. if !m.op.Is(OpUpdateOne) {
  11834. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11835. }
  11836. if m.id == nil || m.oldValue == nil {
  11837. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11838. }
  11839. oldValue, err := m.oldValue(ctx)
  11840. if err != nil {
  11841. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11842. }
  11843. return oldValue.UpdatedAt, nil
  11844. }
  11845. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11846. func (m *WxMutation) ResetUpdatedAt() {
  11847. m.updated_at = nil
  11848. }
  11849. // SetStatus sets the "status" field.
  11850. func (m *WxMutation) SetStatus(u uint8) {
  11851. m.status = &u
  11852. m.addstatus = nil
  11853. }
  11854. // Status returns the value of the "status" field in the mutation.
  11855. func (m *WxMutation) Status() (r uint8, exists bool) {
  11856. v := m.status
  11857. if v == nil {
  11858. return
  11859. }
  11860. return *v, true
  11861. }
  11862. // OldStatus returns the old "status" field's value of the Wx entity.
  11863. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  11864. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11865. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11866. if !m.op.Is(OpUpdateOne) {
  11867. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11868. }
  11869. if m.id == nil || m.oldValue == nil {
  11870. return v, errors.New("OldStatus requires an ID field in the mutation")
  11871. }
  11872. oldValue, err := m.oldValue(ctx)
  11873. if err != nil {
  11874. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11875. }
  11876. return oldValue.Status, nil
  11877. }
  11878. // AddStatus adds u to the "status" field.
  11879. func (m *WxMutation) AddStatus(u int8) {
  11880. if m.addstatus != nil {
  11881. *m.addstatus += u
  11882. } else {
  11883. m.addstatus = &u
  11884. }
  11885. }
  11886. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11887. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  11888. v := m.addstatus
  11889. if v == nil {
  11890. return
  11891. }
  11892. return *v, true
  11893. }
  11894. // ClearStatus clears the value of the "status" field.
  11895. func (m *WxMutation) ClearStatus() {
  11896. m.status = nil
  11897. m.addstatus = nil
  11898. m.clearedFields[wx.FieldStatus] = struct{}{}
  11899. }
  11900. // StatusCleared returns if the "status" field was cleared in this mutation.
  11901. func (m *WxMutation) StatusCleared() bool {
  11902. _, ok := m.clearedFields[wx.FieldStatus]
  11903. return ok
  11904. }
  11905. // ResetStatus resets all changes to the "status" field.
  11906. func (m *WxMutation) ResetStatus() {
  11907. m.status = nil
  11908. m.addstatus = nil
  11909. delete(m.clearedFields, wx.FieldStatus)
  11910. }
  11911. // SetDeletedAt sets the "deleted_at" field.
  11912. func (m *WxMutation) SetDeletedAt(t time.Time) {
  11913. m.deleted_at = &t
  11914. }
  11915. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11916. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  11917. v := m.deleted_at
  11918. if v == nil {
  11919. return
  11920. }
  11921. return *v, true
  11922. }
  11923. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  11924. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  11925. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11926. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11927. if !m.op.Is(OpUpdateOne) {
  11928. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11929. }
  11930. if m.id == nil || m.oldValue == nil {
  11931. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11932. }
  11933. oldValue, err := m.oldValue(ctx)
  11934. if err != nil {
  11935. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11936. }
  11937. return oldValue.DeletedAt, nil
  11938. }
  11939. // ClearDeletedAt clears the value of the "deleted_at" field.
  11940. func (m *WxMutation) ClearDeletedAt() {
  11941. m.deleted_at = nil
  11942. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  11943. }
  11944. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11945. func (m *WxMutation) DeletedAtCleared() bool {
  11946. _, ok := m.clearedFields[wx.FieldDeletedAt]
  11947. return ok
  11948. }
  11949. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11950. func (m *WxMutation) ResetDeletedAt() {
  11951. m.deleted_at = nil
  11952. delete(m.clearedFields, wx.FieldDeletedAt)
  11953. }
  11954. // SetServerID sets the "server_id" field.
  11955. func (m *WxMutation) SetServerID(u uint64) {
  11956. m.server = &u
  11957. }
  11958. // ServerID returns the value of the "server_id" field in the mutation.
  11959. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  11960. v := m.server
  11961. if v == nil {
  11962. return
  11963. }
  11964. return *v, true
  11965. }
  11966. // OldServerID returns the old "server_id" field's value of the Wx entity.
  11967. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  11968. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11969. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  11970. if !m.op.Is(OpUpdateOne) {
  11971. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  11972. }
  11973. if m.id == nil || m.oldValue == nil {
  11974. return v, errors.New("OldServerID requires an ID field in the mutation")
  11975. }
  11976. oldValue, err := m.oldValue(ctx)
  11977. if err != nil {
  11978. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  11979. }
  11980. return oldValue.ServerID, nil
  11981. }
  11982. // ClearServerID clears the value of the "server_id" field.
  11983. func (m *WxMutation) ClearServerID() {
  11984. m.server = nil
  11985. m.clearedFields[wx.FieldServerID] = struct{}{}
  11986. }
  11987. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  11988. func (m *WxMutation) ServerIDCleared() bool {
  11989. _, ok := m.clearedFields[wx.FieldServerID]
  11990. return ok
  11991. }
  11992. // ResetServerID resets all changes to the "server_id" field.
  11993. func (m *WxMutation) ResetServerID() {
  11994. m.server = nil
  11995. delete(m.clearedFields, wx.FieldServerID)
  11996. }
  11997. // SetPort sets the "port" field.
  11998. func (m *WxMutation) SetPort(s string) {
  11999. m.port = &s
  12000. }
  12001. // Port returns the value of the "port" field in the mutation.
  12002. func (m *WxMutation) Port() (r string, exists bool) {
  12003. v := m.port
  12004. if v == nil {
  12005. return
  12006. }
  12007. return *v, true
  12008. }
  12009. // OldPort returns the old "port" field's value of the Wx entity.
  12010. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  12011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12012. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  12013. if !m.op.Is(OpUpdateOne) {
  12014. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  12015. }
  12016. if m.id == nil || m.oldValue == nil {
  12017. return v, errors.New("OldPort requires an ID field in the mutation")
  12018. }
  12019. oldValue, err := m.oldValue(ctx)
  12020. if err != nil {
  12021. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  12022. }
  12023. return oldValue.Port, nil
  12024. }
  12025. // ResetPort resets all changes to the "port" field.
  12026. func (m *WxMutation) ResetPort() {
  12027. m.port = nil
  12028. }
  12029. // SetProcessID sets the "process_id" field.
  12030. func (m *WxMutation) SetProcessID(s string) {
  12031. m.process_id = &s
  12032. }
  12033. // ProcessID returns the value of the "process_id" field in the mutation.
  12034. func (m *WxMutation) ProcessID() (r string, exists bool) {
  12035. v := m.process_id
  12036. if v == nil {
  12037. return
  12038. }
  12039. return *v, true
  12040. }
  12041. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  12042. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  12043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12044. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  12045. if !m.op.Is(OpUpdateOne) {
  12046. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  12047. }
  12048. if m.id == nil || m.oldValue == nil {
  12049. return v, errors.New("OldProcessID requires an ID field in the mutation")
  12050. }
  12051. oldValue, err := m.oldValue(ctx)
  12052. if err != nil {
  12053. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  12054. }
  12055. return oldValue.ProcessID, nil
  12056. }
  12057. // ResetProcessID resets all changes to the "process_id" field.
  12058. func (m *WxMutation) ResetProcessID() {
  12059. m.process_id = nil
  12060. }
  12061. // SetCallback sets the "callback" field.
  12062. func (m *WxMutation) SetCallback(s string) {
  12063. m.callback = &s
  12064. }
  12065. // Callback returns the value of the "callback" field in the mutation.
  12066. func (m *WxMutation) Callback() (r string, exists bool) {
  12067. v := m.callback
  12068. if v == nil {
  12069. return
  12070. }
  12071. return *v, true
  12072. }
  12073. // OldCallback returns the old "callback" field's value of the Wx entity.
  12074. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  12075. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12076. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  12077. if !m.op.Is(OpUpdateOne) {
  12078. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  12079. }
  12080. if m.id == nil || m.oldValue == nil {
  12081. return v, errors.New("OldCallback requires an ID field in the mutation")
  12082. }
  12083. oldValue, err := m.oldValue(ctx)
  12084. if err != nil {
  12085. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  12086. }
  12087. return oldValue.Callback, nil
  12088. }
  12089. // ResetCallback resets all changes to the "callback" field.
  12090. func (m *WxMutation) ResetCallback() {
  12091. m.callback = nil
  12092. }
  12093. // SetWxid sets the "wxid" field.
  12094. func (m *WxMutation) SetWxid(s string) {
  12095. m.wxid = &s
  12096. }
  12097. // Wxid returns the value of the "wxid" field in the mutation.
  12098. func (m *WxMutation) Wxid() (r string, exists bool) {
  12099. v := m.wxid
  12100. if v == nil {
  12101. return
  12102. }
  12103. return *v, true
  12104. }
  12105. // OldWxid returns the old "wxid" field's value of the Wx entity.
  12106. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  12107. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12108. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  12109. if !m.op.Is(OpUpdateOne) {
  12110. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  12111. }
  12112. if m.id == nil || m.oldValue == nil {
  12113. return v, errors.New("OldWxid requires an ID field in the mutation")
  12114. }
  12115. oldValue, err := m.oldValue(ctx)
  12116. if err != nil {
  12117. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  12118. }
  12119. return oldValue.Wxid, nil
  12120. }
  12121. // ResetWxid resets all changes to the "wxid" field.
  12122. func (m *WxMutation) ResetWxid() {
  12123. m.wxid = nil
  12124. }
  12125. // SetAccount sets the "account" field.
  12126. func (m *WxMutation) SetAccount(s string) {
  12127. m.account = &s
  12128. }
  12129. // Account returns the value of the "account" field in the mutation.
  12130. func (m *WxMutation) Account() (r string, exists bool) {
  12131. v := m.account
  12132. if v == nil {
  12133. return
  12134. }
  12135. return *v, true
  12136. }
  12137. // OldAccount returns the old "account" field's value of the Wx entity.
  12138. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  12139. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12140. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  12141. if !m.op.Is(OpUpdateOne) {
  12142. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  12143. }
  12144. if m.id == nil || m.oldValue == nil {
  12145. return v, errors.New("OldAccount requires an ID field in the mutation")
  12146. }
  12147. oldValue, err := m.oldValue(ctx)
  12148. if err != nil {
  12149. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  12150. }
  12151. return oldValue.Account, nil
  12152. }
  12153. // ResetAccount resets all changes to the "account" field.
  12154. func (m *WxMutation) ResetAccount() {
  12155. m.account = nil
  12156. }
  12157. // SetNickname sets the "nickname" field.
  12158. func (m *WxMutation) SetNickname(s string) {
  12159. m.nickname = &s
  12160. }
  12161. // Nickname returns the value of the "nickname" field in the mutation.
  12162. func (m *WxMutation) Nickname() (r string, exists bool) {
  12163. v := m.nickname
  12164. if v == nil {
  12165. return
  12166. }
  12167. return *v, true
  12168. }
  12169. // OldNickname returns the old "nickname" field's value of the Wx entity.
  12170. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  12171. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12172. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  12173. if !m.op.Is(OpUpdateOne) {
  12174. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  12175. }
  12176. if m.id == nil || m.oldValue == nil {
  12177. return v, errors.New("OldNickname requires an ID field in the mutation")
  12178. }
  12179. oldValue, err := m.oldValue(ctx)
  12180. if err != nil {
  12181. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  12182. }
  12183. return oldValue.Nickname, nil
  12184. }
  12185. // ResetNickname resets all changes to the "nickname" field.
  12186. func (m *WxMutation) ResetNickname() {
  12187. m.nickname = nil
  12188. }
  12189. // SetTel sets the "tel" field.
  12190. func (m *WxMutation) SetTel(s string) {
  12191. m.tel = &s
  12192. }
  12193. // Tel returns the value of the "tel" field in the mutation.
  12194. func (m *WxMutation) Tel() (r string, exists bool) {
  12195. v := m.tel
  12196. if v == nil {
  12197. return
  12198. }
  12199. return *v, true
  12200. }
  12201. // OldTel returns the old "tel" field's value of the Wx entity.
  12202. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  12203. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12204. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  12205. if !m.op.Is(OpUpdateOne) {
  12206. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  12207. }
  12208. if m.id == nil || m.oldValue == nil {
  12209. return v, errors.New("OldTel requires an ID field in the mutation")
  12210. }
  12211. oldValue, err := m.oldValue(ctx)
  12212. if err != nil {
  12213. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  12214. }
  12215. return oldValue.Tel, nil
  12216. }
  12217. // ResetTel resets all changes to the "tel" field.
  12218. func (m *WxMutation) ResetTel() {
  12219. m.tel = nil
  12220. }
  12221. // SetHeadBig sets the "head_big" field.
  12222. func (m *WxMutation) SetHeadBig(s string) {
  12223. m.head_big = &s
  12224. }
  12225. // HeadBig returns the value of the "head_big" field in the mutation.
  12226. func (m *WxMutation) HeadBig() (r string, exists bool) {
  12227. v := m.head_big
  12228. if v == nil {
  12229. return
  12230. }
  12231. return *v, true
  12232. }
  12233. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  12234. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  12235. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12236. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  12237. if !m.op.Is(OpUpdateOne) {
  12238. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  12239. }
  12240. if m.id == nil || m.oldValue == nil {
  12241. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  12242. }
  12243. oldValue, err := m.oldValue(ctx)
  12244. if err != nil {
  12245. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  12246. }
  12247. return oldValue.HeadBig, nil
  12248. }
  12249. // ResetHeadBig resets all changes to the "head_big" field.
  12250. func (m *WxMutation) ResetHeadBig() {
  12251. m.head_big = nil
  12252. }
  12253. // ClearServer clears the "server" edge to the Server entity.
  12254. func (m *WxMutation) ClearServer() {
  12255. m.clearedserver = true
  12256. m.clearedFields[wx.FieldServerID] = struct{}{}
  12257. }
  12258. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  12259. func (m *WxMutation) ServerCleared() bool {
  12260. return m.ServerIDCleared() || m.clearedserver
  12261. }
  12262. // ServerIDs returns the "server" edge IDs in the mutation.
  12263. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  12264. // ServerID instead. It exists only for internal usage by the builders.
  12265. func (m *WxMutation) ServerIDs() (ids []uint64) {
  12266. if id := m.server; id != nil {
  12267. ids = append(ids, *id)
  12268. }
  12269. return
  12270. }
  12271. // ResetServer resets all changes to the "server" edge.
  12272. func (m *WxMutation) ResetServer() {
  12273. m.server = nil
  12274. m.clearedserver = false
  12275. }
  12276. // Where appends a list predicates to the WxMutation builder.
  12277. func (m *WxMutation) Where(ps ...predicate.Wx) {
  12278. m.predicates = append(m.predicates, ps...)
  12279. }
  12280. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  12281. // users can use type-assertion to append predicates that do not depend on any generated package.
  12282. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  12283. p := make([]predicate.Wx, len(ps))
  12284. for i := range ps {
  12285. p[i] = ps[i]
  12286. }
  12287. m.Where(p...)
  12288. }
  12289. // Op returns the operation name.
  12290. func (m *WxMutation) Op() Op {
  12291. return m.op
  12292. }
  12293. // SetOp allows setting the mutation operation.
  12294. func (m *WxMutation) SetOp(op Op) {
  12295. m.op = op
  12296. }
  12297. // Type returns the node type of this mutation (Wx).
  12298. func (m *WxMutation) Type() string {
  12299. return m.typ
  12300. }
  12301. // Fields returns all fields that were changed during this mutation. Note that in
  12302. // order to get all numeric fields that were incremented/decremented, call
  12303. // AddedFields().
  12304. func (m *WxMutation) Fields() []string {
  12305. fields := make([]string, 0, 13)
  12306. if m.created_at != nil {
  12307. fields = append(fields, wx.FieldCreatedAt)
  12308. }
  12309. if m.updated_at != nil {
  12310. fields = append(fields, wx.FieldUpdatedAt)
  12311. }
  12312. if m.status != nil {
  12313. fields = append(fields, wx.FieldStatus)
  12314. }
  12315. if m.deleted_at != nil {
  12316. fields = append(fields, wx.FieldDeletedAt)
  12317. }
  12318. if m.server != nil {
  12319. fields = append(fields, wx.FieldServerID)
  12320. }
  12321. if m.port != nil {
  12322. fields = append(fields, wx.FieldPort)
  12323. }
  12324. if m.process_id != nil {
  12325. fields = append(fields, wx.FieldProcessID)
  12326. }
  12327. if m.callback != nil {
  12328. fields = append(fields, wx.FieldCallback)
  12329. }
  12330. if m.wxid != nil {
  12331. fields = append(fields, wx.FieldWxid)
  12332. }
  12333. if m.account != nil {
  12334. fields = append(fields, wx.FieldAccount)
  12335. }
  12336. if m.nickname != nil {
  12337. fields = append(fields, wx.FieldNickname)
  12338. }
  12339. if m.tel != nil {
  12340. fields = append(fields, wx.FieldTel)
  12341. }
  12342. if m.head_big != nil {
  12343. fields = append(fields, wx.FieldHeadBig)
  12344. }
  12345. return fields
  12346. }
  12347. // Field returns the value of a field with the given name. The second boolean
  12348. // return value indicates that this field was not set, or was not defined in the
  12349. // schema.
  12350. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  12351. switch name {
  12352. case wx.FieldCreatedAt:
  12353. return m.CreatedAt()
  12354. case wx.FieldUpdatedAt:
  12355. return m.UpdatedAt()
  12356. case wx.FieldStatus:
  12357. return m.Status()
  12358. case wx.FieldDeletedAt:
  12359. return m.DeletedAt()
  12360. case wx.FieldServerID:
  12361. return m.ServerID()
  12362. case wx.FieldPort:
  12363. return m.Port()
  12364. case wx.FieldProcessID:
  12365. return m.ProcessID()
  12366. case wx.FieldCallback:
  12367. return m.Callback()
  12368. case wx.FieldWxid:
  12369. return m.Wxid()
  12370. case wx.FieldAccount:
  12371. return m.Account()
  12372. case wx.FieldNickname:
  12373. return m.Nickname()
  12374. case wx.FieldTel:
  12375. return m.Tel()
  12376. case wx.FieldHeadBig:
  12377. return m.HeadBig()
  12378. }
  12379. return nil, false
  12380. }
  12381. // OldField returns the old value of the field from the database. An error is
  12382. // returned if the mutation operation is not UpdateOne, or the query to the
  12383. // database failed.
  12384. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12385. switch name {
  12386. case wx.FieldCreatedAt:
  12387. return m.OldCreatedAt(ctx)
  12388. case wx.FieldUpdatedAt:
  12389. return m.OldUpdatedAt(ctx)
  12390. case wx.FieldStatus:
  12391. return m.OldStatus(ctx)
  12392. case wx.FieldDeletedAt:
  12393. return m.OldDeletedAt(ctx)
  12394. case wx.FieldServerID:
  12395. return m.OldServerID(ctx)
  12396. case wx.FieldPort:
  12397. return m.OldPort(ctx)
  12398. case wx.FieldProcessID:
  12399. return m.OldProcessID(ctx)
  12400. case wx.FieldCallback:
  12401. return m.OldCallback(ctx)
  12402. case wx.FieldWxid:
  12403. return m.OldWxid(ctx)
  12404. case wx.FieldAccount:
  12405. return m.OldAccount(ctx)
  12406. case wx.FieldNickname:
  12407. return m.OldNickname(ctx)
  12408. case wx.FieldTel:
  12409. return m.OldTel(ctx)
  12410. case wx.FieldHeadBig:
  12411. return m.OldHeadBig(ctx)
  12412. }
  12413. return nil, fmt.Errorf("unknown Wx field %s", name)
  12414. }
  12415. // SetField sets the value of a field with the given name. It returns an error if
  12416. // the field is not defined in the schema, or if the type mismatched the field
  12417. // type.
  12418. func (m *WxMutation) SetField(name string, value ent.Value) error {
  12419. switch name {
  12420. case wx.FieldCreatedAt:
  12421. v, ok := value.(time.Time)
  12422. if !ok {
  12423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12424. }
  12425. m.SetCreatedAt(v)
  12426. return nil
  12427. case wx.FieldUpdatedAt:
  12428. v, ok := value.(time.Time)
  12429. if !ok {
  12430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12431. }
  12432. m.SetUpdatedAt(v)
  12433. return nil
  12434. case wx.FieldStatus:
  12435. v, ok := value.(uint8)
  12436. if !ok {
  12437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12438. }
  12439. m.SetStatus(v)
  12440. return nil
  12441. case wx.FieldDeletedAt:
  12442. v, ok := value.(time.Time)
  12443. if !ok {
  12444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12445. }
  12446. m.SetDeletedAt(v)
  12447. return nil
  12448. case wx.FieldServerID:
  12449. v, ok := value.(uint64)
  12450. if !ok {
  12451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12452. }
  12453. m.SetServerID(v)
  12454. return nil
  12455. case wx.FieldPort:
  12456. v, ok := value.(string)
  12457. if !ok {
  12458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12459. }
  12460. m.SetPort(v)
  12461. return nil
  12462. case wx.FieldProcessID:
  12463. v, ok := value.(string)
  12464. if !ok {
  12465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12466. }
  12467. m.SetProcessID(v)
  12468. return nil
  12469. case wx.FieldCallback:
  12470. v, ok := value.(string)
  12471. if !ok {
  12472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12473. }
  12474. m.SetCallback(v)
  12475. return nil
  12476. case wx.FieldWxid:
  12477. v, ok := value.(string)
  12478. if !ok {
  12479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12480. }
  12481. m.SetWxid(v)
  12482. return nil
  12483. case wx.FieldAccount:
  12484. v, ok := value.(string)
  12485. if !ok {
  12486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12487. }
  12488. m.SetAccount(v)
  12489. return nil
  12490. case wx.FieldNickname:
  12491. v, ok := value.(string)
  12492. if !ok {
  12493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12494. }
  12495. m.SetNickname(v)
  12496. return nil
  12497. case wx.FieldTel:
  12498. v, ok := value.(string)
  12499. if !ok {
  12500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12501. }
  12502. m.SetTel(v)
  12503. return nil
  12504. case wx.FieldHeadBig:
  12505. v, ok := value.(string)
  12506. if !ok {
  12507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12508. }
  12509. m.SetHeadBig(v)
  12510. return nil
  12511. }
  12512. return fmt.Errorf("unknown Wx field %s", name)
  12513. }
  12514. // AddedFields returns all numeric fields that were incremented/decremented during
  12515. // this mutation.
  12516. func (m *WxMutation) AddedFields() []string {
  12517. var fields []string
  12518. if m.addstatus != nil {
  12519. fields = append(fields, wx.FieldStatus)
  12520. }
  12521. return fields
  12522. }
  12523. // AddedField returns the numeric value that was incremented/decremented on a field
  12524. // with the given name. The second boolean return value indicates that this field
  12525. // was not set, or was not defined in the schema.
  12526. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  12527. switch name {
  12528. case wx.FieldStatus:
  12529. return m.AddedStatus()
  12530. }
  12531. return nil, false
  12532. }
  12533. // AddField adds the value to the field with the given name. It returns an error if
  12534. // the field is not defined in the schema, or if the type mismatched the field
  12535. // type.
  12536. func (m *WxMutation) AddField(name string, value ent.Value) error {
  12537. switch name {
  12538. case wx.FieldStatus:
  12539. v, ok := value.(int8)
  12540. if !ok {
  12541. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12542. }
  12543. m.AddStatus(v)
  12544. return nil
  12545. }
  12546. return fmt.Errorf("unknown Wx numeric field %s", name)
  12547. }
  12548. // ClearedFields returns all nullable fields that were cleared during this
  12549. // mutation.
  12550. func (m *WxMutation) ClearedFields() []string {
  12551. var fields []string
  12552. if m.FieldCleared(wx.FieldStatus) {
  12553. fields = append(fields, wx.FieldStatus)
  12554. }
  12555. if m.FieldCleared(wx.FieldDeletedAt) {
  12556. fields = append(fields, wx.FieldDeletedAt)
  12557. }
  12558. if m.FieldCleared(wx.FieldServerID) {
  12559. fields = append(fields, wx.FieldServerID)
  12560. }
  12561. return fields
  12562. }
  12563. // FieldCleared returns a boolean indicating if a field with the given name was
  12564. // cleared in this mutation.
  12565. func (m *WxMutation) FieldCleared(name string) bool {
  12566. _, ok := m.clearedFields[name]
  12567. return ok
  12568. }
  12569. // ClearField clears the value of the field with the given name. It returns an
  12570. // error if the field is not defined in the schema.
  12571. func (m *WxMutation) ClearField(name string) error {
  12572. switch name {
  12573. case wx.FieldStatus:
  12574. m.ClearStatus()
  12575. return nil
  12576. case wx.FieldDeletedAt:
  12577. m.ClearDeletedAt()
  12578. return nil
  12579. case wx.FieldServerID:
  12580. m.ClearServerID()
  12581. return nil
  12582. }
  12583. return fmt.Errorf("unknown Wx nullable field %s", name)
  12584. }
  12585. // ResetField resets all changes in the mutation for the field with the given name.
  12586. // It returns an error if the field is not defined in the schema.
  12587. func (m *WxMutation) ResetField(name string) error {
  12588. switch name {
  12589. case wx.FieldCreatedAt:
  12590. m.ResetCreatedAt()
  12591. return nil
  12592. case wx.FieldUpdatedAt:
  12593. m.ResetUpdatedAt()
  12594. return nil
  12595. case wx.FieldStatus:
  12596. m.ResetStatus()
  12597. return nil
  12598. case wx.FieldDeletedAt:
  12599. m.ResetDeletedAt()
  12600. return nil
  12601. case wx.FieldServerID:
  12602. m.ResetServerID()
  12603. return nil
  12604. case wx.FieldPort:
  12605. m.ResetPort()
  12606. return nil
  12607. case wx.FieldProcessID:
  12608. m.ResetProcessID()
  12609. return nil
  12610. case wx.FieldCallback:
  12611. m.ResetCallback()
  12612. return nil
  12613. case wx.FieldWxid:
  12614. m.ResetWxid()
  12615. return nil
  12616. case wx.FieldAccount:
  12617. m.ResetAccount()
  12618. return nil
  12619. case wx.FieldNickname:
  12620. m.ResetNickname()
  12621. return nil
  12622. case wx.FieldTel:
  12623. m.ResetTel()
  12624. return nil
  12625. case wx.FieldHeadBig:
  12626. m.ResetHeadBig()
  12627. return nil
  12628. }
  12629. return fmt.Errorf("unknown Wx field %s", name)
  12630. }
  12631. // AddedEdges returns all edge names that were set/added in this mutation.
  12632. func (m *WxMutation) AddedEdges() []string {
  12633. edges := make([]string, 0, 1)
  12634. if m.server != nil {
  12635. edges = append(edges, wx.EdgeServer)
  12636. }
  12637. return edges
  12638. }
  12639. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12640. // name in this mutation.
  12641. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  12642. switch name {
  12643. case wx.EdgeServer:
  12644. if id := m.server; id != nil {
  12645. return []ent.Value{*id}
  12646. }
  12647. }
  12648. return nil
  12649. }
  12650. // RemovedEdges returns all edge names that were removed in this mutation.
  12651. func (m *WxMutation) RemovedEdges() []string {
  12652. edges := make([]string, 0, 1)
  12653. return edges
  12654. }
  12655. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12656. // the given name in this mutation.
  12657. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  12658. return nil
  12659. }
  12660. // ClearedEdges returns all edge names that were cleared in this mutation.
  12661. func (m *WxMutation) ClearedEdges() []string {
  12662. edges := make([]string, 0, 1)
  12663. if m.clearedserver {
  12664. edges = append(edges, wx.EdgeServer)
  12665. }
  12666. return edges
  12667. }
  12668. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12669. // was cleared in this mutation.
  12670. func (m *WxMutation) EdgeCleared(name string) bool {
  12671. switch name {
  12672. case wx.EdgeServer:
  12673. return m.clearedserver
  12674. }
  12675. return false
  12676. }
  12677. // ClearEdge clears the value of the edge with the given name. It returns an error
  12678. // if that edge is not defined in the schema.
  12679. func (m *WxMutation) ClearEdge(name string) error {
  12680. switch name {
  12681. case wx.EdgeServer:
  12682. m.ClearServer()
  12683. return nil
  12684. }
  12685. return fmt.Errorf("unknown Wx unique edge %s", name)
  12686. }
  12687. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12688. // It returns an error if the edge is not defined in the schema.
  12689. func (m *WxMutation) ResetEdge(name string) error {
  12690. switch name {
  12691. case wx.EdgeServer:
  12692. m.ResetServer()
  12693. return nil
  12694. }
  12695. return fmt.Errorf("unknown Wx edge %s", name)
  12696. }