mutation.go 460 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755
  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/agent"
  10. "wechat-api/ent/batchmsg"
  11. "wechat-api/ent/contact"
  12. "wechat-api/ent/custom_types"
  13. "wechat-api/ent/label"
  14. "wechat-api/ent/labelrelationship"
  15. "wechat-api/ent/message"
  16. "wechat-api/ent/messagerecords"
  17. "wechat-api/ent/msg"
  18. "wechat-api/ent/predicate"
  19. "wechat-api/ent/server"
  20. "wechat-api/ent/sopnode"
  21. "wechat-api/ent/sopstage"
  22. "wechat-api/ent/soptask"
  23. "wechat-api/ent/wx"
  24. "entgo.io/ent"
  25. "entgo.io/ent/dialect/sql"
  26. )
  27. const (
  28. // Operation types.
  29. OpCreate = ent.OpCreate
  30. OpDelete = ent.OpDelete
  31. OpDeleteOne = ent.OpDeleteOne
  32. OpUpdate = ent.OpUpdate
  33. OpUpdateOne = ent.OpUpdateOne
  34. // Node types.
  35. TypeAgent = "Agent"
  36. TypeBatchMsg = "BatchMsg"
  37. TypeContact = "Contact"
  38. TypeLabel = "Label"
  39. TypeLabelRelationship = "LabelRelationship"
  40. TypeMessage = "Message"
  41. TypeMessageRecords = "MessageRecords"
  42. TypeMsg = "Msg"
  43. TypeServer = "Server"
  44. TypeSopNode = "SopNode"
  45. TypeSopStage = "SopStage"
  46. TypeSopTask = "SopTask"
  47. TypeWx = "Wx"
  48. )
  49. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  50. type AgentMutation struct {
  51. config
  52. op Op
  53. typ string
  54. id *uint64
  55. created_at *time.Time
  56. updated_at *time.Time
  57. deleted_at *time.Time
  58. name *string
  59. role *string
  60. status *int
  61. addstatus *int
  62. background *string
  63. examples *string
  64. organization_id *uint64
  65. addorganization_id *int64
  66. clearedFields map[string]struct{}
  67. wx_agent map[uint64]struct{}
  68. removedwx_agent map[uint64]struct{}
  69. clearedwx_agent bool
  70. done bool
  71. oldValue func(context.Context) (*Agent, error)
  72. predicates []predicate.Agent
  73. }
  74. var _ ent.Mutation = (*AgentMutation)(nil)
  75. // agentOption allows management of the mutation configuration using functional options.
  76. type agentOption func(*AgentMutation)
  77. // newAgentMutation creates new mutation for the Agent entity.
  78. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  79. m := &AgentMutation{
  80. config: c,
  81. op: op,
  82. typ: TypeAgent,
  83. clearedFields: make(map[string]struct{}),
  84. }
  85. for _, opt := range opts {
  86. opt(m)
  87. }
  88. return m
  89. }
  90. // withAgentID sets the ID field of the mutation.
  91. func withAgentID(id uint64) agentOption {
  92. return func(m *AgentMutation) {
  93. var (
  94. err error
  95. once sync.Once
  96. value *Agent
  97. )
  98. m.oldValue = func(ctx context.Context) (*Agent, error) {
  99. once.Do(func() {
  100. if m.done {
  101. err = errors.New("querying old values post mutation is not allowed")
  102. } else {
  103. value, err = m.Client().Agent.Get(ctx, id)
  104. }
  105. })
  106. return value, err
  107. }
  108. m.id = &id
  109. }
  110. }
  111. // withAgent sets the old Agent of the mutation.
  112. func withAgent(node *Agent) agentOption {
  113. return func(m *AgentMutation) {
  114. m.oldValue = func(context.Context) (*Agent, error) {
  115. return node, nil
  116. }
  117. m.id = &node.ID
  118. }
  119. }
  120. // Client returns a new `ent.Client` from the mutation. If the mutation was
  121. // executed in a transaction (ent.Tx), a transactional client is returned.
  122. func (m AgentMutation) Client() *Client {
  123. client := &Client{config: m.config}
  124. client.init()
  125. return client
  126. }
  127. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  128. // it returns an error otherwise.
  129. func (m AgentMutation) Tx() (*Tx, error) {
  130. if _, ok := m.driver.(*txDriver); !ok {
  131. return nil, errors.New("ent: mutation is not running in a transaction")
  132. }
  133. tx := &Tx{config: m.config}
  134. tx.init()
  135. return tx, nil
  136. }
  137. // SetID sets the value of the id field. Note that this
  138. // operation is only accepted on creation of Agent entities.
  139. func (m *AgentMutation) SetID(id uint64) {
  140. m.id = &id
  141. }
  142. // ID returns the ID value in the mutation. Note that the ID is only available
  143. // if it was provided to the builder or after it was returned from the database.
  144. func (m *AgentMutation) ID() (id uint64, exists bool) {
  145. if m.id == nil {
  146. return
  147. }
  148. return *m.id, true
  149. }
  150. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  151. // That means, if the mutation is applied within a transaction with an isolation level such
  152. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  153. // or updated by the mutation.
  154. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  155. switch {
  156. case m.op.Is(OpUpdateOne | OpDeleteOne):
  157. id, exists := m.ID()
  158. if exists {
  159. return []uint64{id}, nil
  160. }
  161. fallthrough
  162. case m.op.Is(OpUpdate | OpDelete):
  163. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  164. default:
  165. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  166. }
  167. }
  168. // SetCreatedAt sets the "created_at" field.
  169. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  170. m.created_at = &t
  171. }
  172. // CreatedAt returns the value of the "created_at" field in the mutation.
  173. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  174. v := m.created_at
  175. if v == nil {
  176. return
  177. }
  178. return *v, true
  179. }
  180. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  181. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  182. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  183. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  184. if !m.op.Is(OpUpdateOne) {
  185. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  186. }
  187. if m.id == nil || m.oldValue == nil {
  188. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  189. }
  190. oldValue, err := m.oldValue(ctx)
  191. if err != nil {
  192. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  193. }
  194. return oldValue.CreatedAt, nil
  195. }
  196. // ResetCreatedAt resets all changes to the "created_at" field.
  197. func (m *AgentMutation) ResetCreatedAt() {
  198. m.created_at = nil
  199. }
  200. // SetUpdatedAt sets the "updated_at" field.
  201. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  202. m.updated_at = &t
  203. }
  204. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  205. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  206. v := m.updated_at
  207. if v == nil {
  208. return
  209. }
  210. return *v, true
  211. }
  212. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  213. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  214. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  215. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  216. if !m.op.Is(OpUpdateOne) {
  217. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  218. }
  219. if m.id == nil || m.oldValue == nil {
  220. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  221. }
  222. oldValue, err := m.oldValue(ctx)
  223. if err != nil {
  224. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  225. }
  226. return oldValue.UpdatedAt, nil
  227. }
  228. // ResetUpdatedAt resets all changes to the "updated_at" field.
  229. func (m *AgentMutation) ResetUpdatedAt() {
  230. m.updated_at = nil
  231. }
  232. // SetDeletedAt sets the "deleted_at" field.
  233. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  234. m.deleted_at = &t
  235. }
  236. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  237. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  238. v := m.deleted_at
  239. if v == nil {
  240. return
  241. }
  242. return *v, true
  243. }
  244. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  245. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  246. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  247. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  248. if !m.op.Is(OpUpdateOne) {
  249. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  250. }
  251. if m.id == nil || m.oldValue == nil {
  252. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  253. }
  254. oldValue, err := m.oldValue(ctx)
  255. if err != nil {
  256. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  257. }
  258. return oldValue.DeletedAt, nil
  259. }
  260. // ClearDeletedAt clears the value of the "deleted_at" field.
  261. func (m *AgentMutation) ClearDeletedAt() {
  262. m.deleted_at = nil
  263. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  264. }
  265. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  266. func (m *AgentMutation) DeletedAtCleared() bool {
  267. _, ok := m.clearedFields[agent.FieldDeletedAt]
  268. return ok
  269. }
  270. // ResetDeletedAt resets all changes to the "deleted_at" field.
  271. func (m *AgentMutation) ResetDeletedAt() {
  272. m.deleted_at = nil
  273. delete(m.clearedFields, agent.FieldDeletedAt)
  274. }
  275. // SetName sets the "name" field.
  276. func (m *AgentMutation) SetName(s string) {
  277. m.name = &s
  278. }
  279. // Name returns the value of the "name" field in the mutation.
  280. func (m *AgentMutation) Name() (r string, exists bool) {
  281. v := m.name
  282. if v == nil {
  283. return
  284. }
  285. return *v, true
  286. }
  287. // OldName returns the old "name" field's value of the Agent entity.
  288. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  289. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  290. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  291. if !m.op.Is(OpUpdateOne) {
  292. return v, errors.New("OldName is only allowed on UpdateOne operations")
  293. }
  294. if m.id == nil || m.oldValue == nil {
  295. return v, errors.New("OldName requires an ID field in the mutation")
  296. }
  297. oldValue, err := m.oldValue(ctx)
  298. if err != nil {
  299. return v, fmt.Errorf("querying old value for OldName: %w", err)
  300. }
  301. return oldValue.Name, nil
  302. }
  303. // ResetName resets all changes to the "name" field.
  304. func (m *AgentMutation) ResetName() {
  305. m.name = nil
  306. }
  307. // SetRole sets the "role" field.
  308. func (m *AgentMutation) SetRole(s string) {
  309. m.role = &s
  310. }
  311. // Role returns the value of the "role" field in the mutation.
  312. func (m *AgentMutation) Role() (r string, exists bool) {
  313. v := m.role
  314. if v == nil {
  315. return
  316. }
  317. return *v, true
  318. }
  319. // OldRole returns the old "role" field's value of the Agent entity.
  320. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  321. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  322. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  323. if !m.op.Is(OpUpdateOne) {
  324. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  325. }
  326. if m.id == nil || m.oldValue == nil {
  327. return v, errors.New("OldRole requires an ID field in the mutation")
  328. }
  329. oldValue, err := m.oldValue(ctx)
  330. if err != nil {
  331. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  332. }
  333. return oldValue.Role, nil
  334. }
  335. // ResetRole resets all changes to the "role" field.
  336. func (m *AgentMutation) ResetRole() {
  337. m.role = nil
  338. }
  339. // SetStatus sets the "status" field.
  340. func (m *AgentMutation) SetStatus(i int) {
  341. m.status = &i
  342. m.addstatus = nil
  343. }
  344. // Status returns the value of the "status" field in the mutation.
  345. func (m *AgentMutation) Status() (r int, exists bool) {
  346. v := m.status
  347. if v == nil {
  348. return
  349. }
  350. return *v, true
  351. }
  352. // OldStatus returns the old "status" field's value of the Agent entity.
  353. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  355. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  356. if !m.op.Is(OpUpdateOne) {
  357. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  358. }
  359. if m.id == nil || m.oldValue == nil {
  360. return v, errors.New("OldStatus requires an ID field in the mutation")
  361. }
  362. oldValue, err := m.oldValue(ctx)
  363. if err != nil {
  364. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  365. }
  366. return oldValue.Status, nil
  367. }
  368. // AddStatus adds i to the "status" field.
  369. func (m *AgentMutation) AddStatus(i int) {
  370. if m.addstatus != nil {
  371. *m.addstatus += i
  372. } else {
  373. m.addstatus = &i
  374. }
  375. }
  376. // AddedStatus returns the value that was added to the "status" field in this mutation.
  377. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  378. v := m.addstatus
  379. if v == nil {
  380. return
  381. }
  382. return *v, true
  383. }
  384. // ClearStatus clears the value of the "status" field.
  385. func (m *AgentMutation) ClearStatus() {
  386. m.status = nil
  387. m.addstatus = nil
  388. m.clearedFields[agent.FieldStatus] = struct{}{}
  389. }
  390. // StatusCleared returns if the "status" field was cleared in this mutation.
  391. func (m *AgentMutation) StatusCleared() bool {
  392. _, ok := m.clearedFields[agent.FieldStatus]
  393. return ok
  394. }
  395. // ResetStatus resets all changes to the "status" field.
  396. func (m *AgentMutation) ResetStatus() {
  397. m.status = nil
  398. m.addstatus = nil
  399. delete(m.clearedFields, agent.FieldStatus)
  400. }
  401. // SetBackground sets the "background" field.
  402. func (m *AgentMutation) SetBackground(s string) {
  403. m.background = &s
  404. }
  405. // Background returns the value of the "background" field in the mutation.
  406. func (m *AgentMutation) Background() (r string, exists bool) {
  407. v := m.background
  408. if v == nil {
  409. return
  410. }
  411. return *v, true
  412. }
  413. // OldBackground returns the old "background" field's value of the Agent entity.
  414. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  415. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  416. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  417. if !m.op.Is(OpUpdateOne) {
  418. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  419. }
  420. if m.id == nil || m.oldValue == nil {
  421. return v, errors.New("OldBackground requires an ID field in the mutation")
  422. }
  423. oldValue, err := m.oldValue(ctx)
  424. if err != nil {
  425. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  426. }
  427. return oldValue.Background, nil
  428. }
  429. // ClearBackground clears the value of the "background" field.
  430. func (m *AgentMutation) ClearBackground() {
  431. m.background = nil
  432. m.clearedFields[agent.FieldBackground] = struct{}{}
  433. }
  434. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  435. func (m *AgentMutation) BackgroundCleared() bool {
  436. _, ok := m.clearedFields[agent.FieldBackground]
  437. return ok
  438. }
  439. // ResetBackground resets all changes to the "background" field.
  440. func (m *AgentMutation) ResetBackground() {
  441. m.background = nil
  442. delete(m.clearedFields, agent.FieldBackground)
  443. }
  444. // SetExamples sets the "examples" field.
  445. func (m *AgentMutation) SetExamples(s string) {
  446. m.examples = &s
  447. }
  448. // Examples returns the value of the "examples" field in the mutation.
  449. func (m *AgentMutation) Examples() (r string, exists bool) {
  450. v := m.examples
  451. if v == nil {
  452. return
  453. }
  454. return *v, true
  455. }
  456. // OldExamples returns the old "examples" field's value of the Agent entity.
  457. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  458. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  459. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  460. if !m.op.Is(OpUpdateOne) {
  461. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  462. }
  463. if m.id == nil || m.oldValue == nil {
  464. return v, errors.New("OldExamples requires an ID field in the mutation")
  465. }
  466. oldValue, err := m.oldValue(ctx)
  467. if err != nil {
  468. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  469. }
  470. return oldValue.Examples, nil
  471. }
  472. // ClearExamples clears the value of the "examples" field.
  473. func (m *AgentMutation) ClearExamples() {
  474. m.examples = nil
  475. m.clearedFields[agent.FieldExamples] = struct{}{}
  476. }
  477. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  478. func (m *AgentMutation) ExamplesCleared() bool {
  479. _, ok := m.clearedFields[agent.FieldExamples]
  480. return ok
  481. }
  482. // ResetExamples resets all changes to the "examples" field.
  483. func (m *AgentMutation) ResetExamples() {
  484. m.examples = nil
  485. delete(m.clearedFields, agent.FieldExamples)
  486. }
  487. // SetOrganizationID sets the "organization_id" field.
  488. func (m *AgentMutation) SetOrganizationID(u uint64) {
  489. m.organization_id = &u
  490. m.addorganization_id = nil
  491. }
  492. // OrganizationID returns the value of the "organization_id" field in the mutation.
  493. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  494. v := m.organization_id
  495. if v == nil {
  496. return
  497. }
  498. return *v, true
  499. }
  500. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  501. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  502. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  503. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  504. if !m.op.Is(OpUpdateOne) {
  505. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  506. }
  507. if m.id == nil || m.oldValue == nil {
  508. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  509. }
  510. oldValue, err := m.oldValue(ctx)
  511. if err != nil {
  512. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  513. }
  514. return oldValue.OrganizationID, nil
  515. }
  516. // AddOrganizationID adds u to the "organization_id" field.
  517. func (m *AgentMutation) AddOrganizationID(u int64) {
  518. if m.addorganization_id != nil {
  519. *m.addorganization_id += u
  520. } else {
  521. m.addorganization_id = &u
  522. }
  523. }
  524. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  525. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  526. v := m.addorganization_id
  527. if v == nil {
  528. return
  529. }
  530. return *v, true
  531. }
  532. // ResetOrganizationID resets all changes to the "organization_id" field.
  533. func (m *AgentMutation) ResetOrganizationID() {
  534. m.organization_id = nil
  535. m.addorganization_id = nil
  536. }
  537. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  538. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  539. if m.wx_agent == nil {
  540. m.wx_agent = make(map[uint64]struct{})
  541. }
  542. for i := range ids {
  543. m.wx_agent[ids[i]] = struct{}{}
  544. }
  545. }
  546. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  547. func (m *AgentMutation) ClearWxAgent() {
  548. m.clearedwx_agent = true
  549. }
  550. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  551. func (m *AgentMutation) WxAgentCleared() bool {
  552. return m.clearedwx_agent
  553. }
  554. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  555. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  556. if m.removedwx_agent == nil {
  557. m.removedwx_agent = make(map[uint64]struct{})
  558. }
  559. for i := range ids {
  560. delete(m.wx_agent, ids[i])
  561. m.removedwx_agent[ids[i]] = struct{}{}
  562. }
  563. }
  564. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  565. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  566. for id := range m.removedwx_agent {
  567. ids = append(ids, id)
  568. }
  569. return
  570. }
  571. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  572. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  573. for id := range m.wx_agent {
  574. ids = append(ids, id)
  575. }
  576. return
  577. }
  578. // ResetWxAgent resets all changes to the "wx_agent" edge.
  579. func (m *AgentMutation) ResetWxAgent() {
  580. m.wx_agent = nil
  581. m.clearedwx_agent = false
  582. m.removedwx_agent = nil
  583. }
  584. // Where appends a list predicates to the AgentMutation builder.
  585. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  586. m.predicates = append(m.predicates, ps...)
  587. }
  588. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  589. // users can use type-assertion to append predicates that do not depend on any generated package.
  590. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  591. p := make([]predicate.Agent, len(ps))
  592. for i := range ps {
  593. p[i] = ps[i]
  594. }
  595. m.Where(p...)
  596. }
  597. // Op returns the operation name.
  598. func (m *AgentMutation) Op() Op {
  599. return m.op
  600. }
  601. // SetOp allows setting the mutation operation.
  602. func (m *AgentMutation) SetOp(op Op) {
  603. m.op = op
  604. }
  605. // Type returns the node type of this mutation (Agent).
  606. func (m *AgentMutation) Type() string {
  607. return m.typ
  608. }
  609. // Fields returns all fields that were changed during this mutation. Note that in
  610. // order to get all numeric fields that were incremented/decremented, call
  611. // AddedFields().
  612. func (m *AgentMutation) Fields() []string {
  613. fields := make([]string, 0, 9)
  614. if m.created_at != nil {
  615. fields = append(fields, agent.FieldCreatedAt)
  616. }
  617. if m.updated_at != nil {
  618. fields = append(fields, agent.FieldUpdatedAt)
  619. }
  620. if m.deleted_at != nil {
  621. fields = append(fields, agent.FieldDeletedAt)
  622. }
  623. if m.name != nil {
  624. fields = append(fields, agent.FieldName)
  625. }
  626. if m.role != nil {
  627. fields = append(fields, agent.FieldRole)
  628. }
  629. if m.status != nil {
  630. fields = append(fields, agent.FieldStatus)
  631. }
  632. if m.background != nil {
  633. fields = append(fields, agent.FieldBackground)
  634. }
  635. if m.examples != nil {
  636. fields = append(fields, agent.FieldExamples)
  637. }
  638. if m.organization_id != nil {
  639. fields = append(fields, agent.FieldOrganizationID)
  640. }
  641. return fields
  642. }
  643. // Field returns the value of a field with the given name. The second boolean
  644. // return value indicates that this field was not set, or was not defined in the
  645. // schema.
  646. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  647. switch name {
  648. case agent.FieldCreatedAt:
  649. return m.CreatedAt()
  650. case agent.FieldUpdatedAt:
  651. return m.UpdatedAt()
  652. case agent.FieldDeletedAt:
  653. return m.DeletedAt()
  654. case agent.FieldName:
  655. return m.Name()
  656. case agent.FieldRole:
  657. return m.Role()
  658. case agent.FieldStatus:
  659. return m.Status()
  660. case agent.FieldBackground:
  661. return m.Background()
  662. case agent.FieldExamples:
  663. return m.Examples()
  664. case agent.FieldOrganizationID:
  665. return m.OrganizationID()
  666. }
  667. return nil, false
  668. }
  669. // OldField returns the old value of the field from the database. An error is
  670. // returned if the mutation operation is not UpdateOne, or the query to the
  671. // database failed.
  672. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  673. switch name {
  674. case agent.FieldCreatedAt:
  675. return m.OldCreatedAt(ctx)
  676. case agent.FieldUpdatedAt:
  677. return m.OldUpdatedAt(ctx)
  678. case agent.FieldDeletedAt:
  679. return m.OldDeletedAt(ctx)
  680. case agent.FieldName:
  681. return m.OldName(ctx)
  682. case agent.FieldRole:
  683. return m.OldRole(ctx)
  684. case agent.FieldStatus:
  685. return m.OldStatus(ctx)
  686. case agent.FieldBackground:
  687. return m.OldBackground(ctx)
  688. case agent.FieldExamples:
  689. return m.OldExamples(ctx)
  690. case agent.FieldOrganizationID:
  691. return m.OldOrganizationID(ctx)
  692. }
  693. return nil, fmt.Errorf("unknown Agent field %s", name)
  694. }
  695. // SetField sets the value of a field with the given name. It returns an error if
  696. // the field is not defined in the schema, or if the type mismatched the field
  697. // type.
  698. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  699. switch name {
  700. case agent.FieldCreatedAt:
  701. v, ok := value.(time.Time)
  702. if !ok {
  703. return fmt.Errorf("unexpected type %T for field %s", value, name)
  704. }
  705. m.SetCreatedAt(v)
  706. return nil
  707. case agent.FieldUpdatedAt:
  708. v, ok := value.(time.Time)
  709. if !ok {
  710. return fmt.Errorf("unexpected type %T for field %s", value, name)
  711. }
  712. m.SetUpdatedAt(v)
  713. return nil
  714. case agent.FieldDeletedAt:
  715. v, ok := value.(time.Time)
  716. if !ok {
  717. return fmt.Errorf("unexpected type %T for field %s", value, name)
  718. }
  719. m.SetDeletedAt(v)
  720. return nil
  721. case agent.FieldName:
  722. v, ok := value.(string)
  723. if !ok {
  724. return fmt.Errorf("unexpected type %T for field %s", value, name)
  725. }
  726. m.SetName(v)
  727. return nil
  728. case agent.FieldRole:
  729. v, ok := value.(string)
  730. if !ok {
  731. return fmt.Errorf("unexpected type %T for field %s", value, name)
  732. }
  733. m.SetRole(v)
  734. return nil
  735. case agent.FieldStatus:
  736. v, ok := value.(int)
  737. if !ok {
  738. return fmt.Errorf("unexpected type %T for field %s", value, name)
  739. }
  740. m.SetStatus(v)
  741. return nil
  742. case agent.FieldBackground:
  743. v, ok := value.(string)
  744. if !ok {
  745. return fmt.Errorf("unexpected type %T for field %s", value, name)
  746. }
  747. m.SetBackground(v)
  748. return nil
  749. case agent.FieldExamples:
  750. v, ok := value.(string)
  751. if !ok {
  752. return fmt.Errorf("unexpected type %T for field %s", value, name)
  753. }
  754. m.SetExamples(v)
  755. return nil
  756. case agent.FieldOrganizationID:
  757. v, ok := value.(uint64)
  758. if !ok {
  759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  760. }
  761. m.SetOrganizationID(v)
  762. return nil
  763. }
  764. return fmt.Errorf("unknown Agent field %s", name)
  765. }
  766. // AddedFields returns all numeric fields that were incremented/decremented during
  767. // this mutation.
  768. func (m *AgentMutation) AddedFields() []string {
  769. var fields []string
  770. if m.addstatus != nil {
  771. fields = append(fields, agent.FieldStatus)
  772. }
  773. if m.addorganization_id != nil {
  774. fields = append(fields, agent.FieldOrganizationID)
  775. }
  776. return fields
  777. }
  778. // AddedField returns the numeric value that was incremented/decremented on a field
  779. // with the given name. The second boolean return value indicates that this field
  780. // was not set, or was not defined in the schema.
  781. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  782. switch name {
  783. case agent.FieldStatus:
  784. return m.AddedStatus()
  785. case agent.FieldOrganizationID:
  786. return m.AddedOrganizationID()
  787. }
  788. return nil, false
  789. }
  790. // AddField adds the value to the field with the given name. It returns an error if
  791. // the field is not defined in the schema, or if the type mismatched the field
  792. // type.
  793. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  794. switch name {
  795. case agent.FieldStatus:
  796. v, ok := value.(int)
  797. if !ok {
  798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  799. }
  800. m.AddStatus(v)
  801. return nil
  802. case agent.FieldOrganizationID:
  803. v, ok := value.(int64)
  804. if !ok {
  805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  806. }
  807. m.AddOrganizationID(v)
  808. return nil
  809. }
  810. return fmt.Errorf("unknown Agent numeric field %s", name)
  811. }
  812. // ClearedFields returns all nullable fields that were cleared during this
  813. // mutation.
  814. func (m *AgentMutation) ClearedFields() []string {
  815. var fields []string
  816. if m.FieldCleared(agent.FieldDeletedAt) {
  817. fields = append(fields, agent.FieldDeletedAt)
  818. }
  819. if m.FieldCleared(agent.FieldStatus) {
  820. fields = append(fields, agent.FieldStatus)
  821. }
  822. if m.FieldCleared(agent.FieldBackground) {
  823. fields = append(fields, agent.FieldBackground)
  824. }
  825. if m.FieldCleared(agent.FieldExamples) {
  826. fields = append(fields, agent.FieldExamples)
  827. }
  828. return fields
  829. }
  830. // FieldCleared returns a boolean indicating if a field with the given name was
  831. // cleared in this mutation.
  832. func (m *AgentMutation) FieldCleared(name string) bool {
  833. _, ok := m.clearedFields[name]
  834. return ok
  835. }
  836. // ClearField clears the value of the field with the given name. It returns an
  837. // error if the field is not defined in the schema.
  838. func (m *AgentMutation) ClearField(name string) error {
  839. switch name {
  840. case agent.FieldDeletedAt:
  841. m.ClearDeletedAt()
  842. return nil
  843. case agent.FieldStatus:
  844. m.ClearStatus()
  845. return nil
  846. case agent.FieldBackground:
  847. m.ClearBackground()
  848. return nil
  849. case agent.FieldExamples:
  850. m.ClearExamples()
  851. return nil
  852. }
  853. return fmt.Errorf("unknown Agent nullable field %s", name)
  854. }
  855. // ResetField resets all changes in the mutation for the field with the given name.
  856. // It returns an error if the field is not defined in the schema.
  857. func (m *AgentMutation) ResetField(name string) error {
  858. switch name {
  859. case agent.FieldCreatedAt:
  860. m.ResetCreatedAt()
  861. return nil
  862. case agent.FieldUpdatedAt:
  863. m.ResetUpdatedAt()
  864. return nil
  865. case agent.FieldDeletedAt:
  866. m.ResetDeletedAt()
  867. return nil
  868. case agent.FieldName:
  869. m.ResetName()
  870. return nil
  871. case agent.FieldRole:
  872. m.ResetRole()
  873. return nil
  874. case agent.FieldStatus:
  875. m.ResetStatus()
  876. return nil
  877. case agent.FieldBackground:
  878. m.ResetBackground()
  879. return nil
  880. case agent.FieldExamples:
  881. m.ResetExamples()
  882. return nil
  883. case agent.FieldOrganizationID:
  884. m.ResetOrganizationID()
  885. return nil
  886. }
  887. return fmt.Errorf("unknown Agent field %s", name)
  888. }
  889. // AddedEdges returns all edge names that were set/added in this mutation.
  890. func (m *AgentMutation) AddedEdges() []string {
  891. edges := make([]string, 0, 1)
  892. if m.wx_agent != nil {
  893. edges = append(edges, agent.EdgeWxAgent)
  894. }
  895. return edges
  896. }
  897. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  898. // name in this mutation.
  899. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  900. switch name {
  901. case agent.EdgeWxAgent:
  902. ids := make([]ent.Value, 0, len(m.wx_agent))
  903. for id := range m.wx_agent {
  904. ids = append(ids, id)
  905. }
  906. return ids
  907. }
  908. return nil
  909. }
  910. // RemovedEdges returns all edge names that were removed in this mutation.
  911. func (m *AgentMutation) RemovedEdges() []string {
  912. edges := make([]string, 0, 1)
  913. if m.removedwx_agent != nil {
  914. edges = append(edges, agent.EdgeWxAgent)
  915. }
  916. return edges
  917. }
  918. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  919. // the given name in this mutation.
  920. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  921. switch name {
  922. case agent.EdgeWxAgent:
  923. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  924. for id := range m.removedwx_agent {
  925. ids = append(ids, id)
  926. }
  927. return ids
  928. }
  929. return nil
  930. }
  931. // ClearedEdges returns all edge names that were cleared in this mutation.
  932. func (m *AgentMutation) ClearedEdges() []string {
  933. edges := make([]string, 0, 1)
  934. if m.clearedwx_agent {
  935. edges = append(edges, agent.EdgeWxAgent)
  936. }
  937. return edges
  938. }
  939. // EdgeCleared returns a boolean which indicates if the edge with the given name
  940. // was cleared in this mutation.
  941. func (m *AgentMutation) EdgeCleared(name string) bool {
  942. switch name {
  943. case agent.EdgeWxAgent:
  944. return m.clearedwx_agent
  945. }
  946. return false
  947. }
  948. // ClearEdge clears the value of the edge with the given name. It returns an error
  949. // if that edge is not defined in the schema.
  950. func (m *AgentMutation) ClearEdge(name string) error {
  951. switch name {
  952. }
  953. return fmt.Errorf("unknown Agent unique edge %s", name)
  954. }
  955. // ResetEdge resets all changes to the edge with the given name in this mutation.
  956. // It returns an error if the edge is not defined in the schema.
  957. func (m *AgentMutation) ResetEdge(name string) error {
  958. switch name {
  959. case agent.EdgeWxAgent:
  960. m.ResetWxAgent()
  961. return nil
  962. }
  963. return fmt.Errorf("unknown Agent edge %s", name)
  964. }
  965. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  966. type BatchMsgMutation struct {
  967. config
  968. op Op
  969. typ string
  970. id *uint64
  971. created_at *time.Time
  972. updated_at *time.Time
  973. deleted_at *time.Time
  974. status *uint8
  975. addstatus *int8
  976. batch_no *string
  977. task_name *string
  978. fromwxid *string
  979. msg *string
  980. tag *string
  981. total *int32
  982. addtotal *int32
  983. success *int32
  984. addsuccess *int32
  985. fail *int32
  986. addfail *int32
  987. start_time *time.Time
  988. stop_time *time.Time
  989. send_time *time.Time
  990. clearedFields map[string]struct{}
  991. done bool
  992. oldValue func(context.Context) (*BatchMsg, error)
  993. predicates []predicate.BatchMsg
  994. }
  995. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  996. // batchmsgOption allows management of the mutation configuration using functional options.
  997. type batchmsgOption func(*BatchMsgMutation)
  998. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  999. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  1000. m := &BatchMsgMutation{
  1001. config: c,
  1002. op: op,
  1003. typ: TypeBatchMsg,
  1004. clearedFields: make(map[string]struct{}),
  1005. }
  1006. for _, opt := range opts {
  1007. opt(m)
  1008. }
  1009. return m
  1010. }
  1011. // withBatchMsgID sets the ID field of the mutation.
  1012. func withBatchMsgID(id uint64) batchmsgOption {
  1013. return func(m *BatchMsgMutation) {
  1014. var (
  1015. err error
  1016. once sync.Once
  1017. value *BatchMsg
  1018. )
  1019. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  1020. once.Do(func() {
  1021. if m.done {
  1022. err = errors.New("querying old values post mutation is not allowed")
  1023. } else {
  1024. value, err = m.Client().BatchMsg.Get(ctx, id)
  1025. }
  1026. })
  1027. return value, err
  1028. }
  1029. m.id = &id
  1030. }
  1031. }
  1032. // withBatchMsg sets the old BatchMsg of the mutation.
  1033. func withBatchMsg(node *BatchMsg) batchmsgOption {
  1034. return func(m *BatchMsgMutation) {
  1035. m.oldValue = func(context.Context) (*BatchMsg, error) {
  1036. return node, nil
  1037. }
  1038. m.id = &node.ID
  1039. }
  1040. }
  1041. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1042. // executed in a transaction (ent.Tx), a transactional client is returned.
  1043. func (m BatchMsgMutation) Client() *Client {
  1044. client := &Client{config: m.config}
  1045. client.init()
  1046. return client
  1047. }
  1048. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1049. // it returns an error otherwise.
  1050. func (m BatchMsgMutation) Tx() (*Tx, error) {
  1051. if _, ok := m.driver.(*txDriver); !ok {
  1052. return nil, errors.New("ent: mutation is not running in a transaction")
  1053. }
  1054. tx := &Tx{config: m.config}
  1055. tx.init()
  1056. return tx, nil
  1057. }
  1058. // SetID sets the value of the id field. Note that this
  1059. // operation is only accepted on creation of BatchMsg entities.
  1060. func (m *BatchMsgMutation) SetID(id uint64) {
  1061. m.id = &id
  1062. }
  1063. // ID returns the ID value in the mutation. Note that the ID is only available
  1064. // if it was provided to the builder or after it was returned from the database.
  1065. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  1066. if m.id == nil {
  1067. return
  1068. }
  1069. return *m.id, true
  1070. }
  1071. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1072. // That means, if the mutation is applied within a transaction with an isolation level such
  1073. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1074. // or updated by the mutation.
  1075. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  1076. switch {
  1077. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1078. id, exists := m.ID()
  1079. if exists {
  1080. return []uint64{id}, nil
  1081. }
  1082. fallthrough
  1083. case m.op.Is(OpUpdate | OpDelete):
  1084. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  1085. default:
  1086. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1087. }
  1088. }
  1089. // SetCreatedAt sets the "created_at" field.
  1090. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  1091. m.created_at = &t
  1092. }
  1093. // CreatedAt returns the value of the "created_at" field in the mutation.
  1094. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  1095. v := m.created_at
  1096. if v == nil {
  1097. return
  1098. }
  1099. return *v, true
  1100. }
  1101. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  1102. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1103. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1104. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  1105. if !m.op.Is(OpUpdateOne) {
  1106. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  1107. }
  1108. if m.id == nil || m.oldValue == nil {
  1109. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  1110. }
  1111. oldValue, err := m.oldValue(ctx)
  1112. if err != nil {
  1113. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  1114. }
  1115. return oldValue.CreatedAt, nil
  1116. }
  1117. // ResetCreatedAt resets all changes to the "created_at" field.
  1118. func (m *BatchMsgMutation) ResetCreatedAt() {
  1119. m.created_at = nil
  1120. }
  1121. // SetUpdatedAt sets the "updated_at" field.
  1122. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  1123. m.updated_at = &t
  1124. }
  1125. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  1126. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  1127. v := m.updated_at
  1128. if v == nil {
  1129. return
  1130. }
  1131. return *v, true
  1132. }
  1133. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  1134. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1135. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1136. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  1137. if !m.op.Is(OpUpdateOne) {
  1138. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  1139. }
  1140. if m.id == nil || m.oldValue == nil {
  1141. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  1142. }
  1143. oldValue, err := m.oldValue(ctx)
  1144. if err != nil {
  1145. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  1146. }
  1147. return oldValue.UpdatedAt, nil
  1148. }
  1149. // ResetUpdatedAt resets all changes to the "updated_at" field.
  1150. func (m *BatchMsgMutation) ResetUpdatedAt() {
  1151. m.updated_at = nil
  1152. }
  1153. // SetDeletedAt sets the "deleted_at" field.
  1154. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  1155. m.deleted_at = &t
  1156. }
  1157. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  1158. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  1159. v := m.deleted_at
  1160. if v == nil {
  1161. return
  1162. }
  1163. return *v, true
  1164. }
  1165. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  1166. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1167. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1168. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  1169. if !m.op.Is(OpUpdateOne) {
  1170. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  1171. }
  1172. if m.id == nil || m.oldValue == nil {
  1173. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  1174. }
  1175. oldValue, err := m.oldValue(ctx)
  1176. if err != nil {
  1177. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  1178. }
  1179. return oldValue.DeletedAt, nil
  1180. }
  1181. // ClearDeletedAt clears the value of the "deleted_at" field.
  1182. func (m *BatchMsgMutation) ClearDeletedAt() {
  1183. m.deleted_at = nil
  1184. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  1185. }
  1186. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  1187. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  1188. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  1189. return ok
  1190. }
  1191. // ResetDeletedAt resets all changes to the "deleted_at" field.
  1192. func (m *BatchMsgMutation) ResetDeletedAt() {
  1193. m.deleted_at = nil
  1194. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  1195. }
  1196. // SetStatus sets the "status" field.
  1197. func (m *BatchMsgMutation) SetStatus(u uint8) {
  1198. m.status = &u
  1199. m.addstatus = nil
  1200. }
  1201. // Status returns the value of the "status" field in the mutation.
  1202. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  1203. v := m.status
  1204. if v == nil {
  1205. return
  1206. }
  1207. return *v, true
  1208. }
  1209. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  1210. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1211. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1212. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  1213. if !m.op.Is(OpUpdateOne) {
  1214. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  1215. }
  1216. if m.id == nil || m.oldValue == nil {
  1217. return v, errors.New("OldStatus requires an ID field in the mutation")
  1218. }
  1219. oldValue, err := m.oldValue(ctx)
  1220. if err != nil {
  1221. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  1222. }
  1223. return oldValue.Status, nil
  1224. }
  1225. // AddStatus adds u to the "status" field.
  1226. func (m *BatchMsgMutation) AddStatus(u int8) {
  1227. if m.addstatus != nil {
  1228. *m.addstatus += u
  1229. } else {
  1230. m.addstatus = &u
  1231. }
  1232. }
  1233. // AddedStatus returns the value that was added to the "status" field in this mutation.
  1234. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  1235. v := m.addstatus
  1236. if v == nil {
  1237. return
  1238. }
  1239. return *v, true
  1240. }
  1241. // ClearStatus clears the value of the "status" field.
  1242. func (m *BatchMsgMutation) ClearStatus() {
  1243. m.status = nil
  1244. m.addstatus = nil
  1245. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  1246. }
  1247. // StatusCleared returns if the "status" field was cleared in this mutation.
  1248. func (m *BatchMsgMutation) StatusCleared() bool {
  1249. _, ok := m.clearedFields[batchmsg.FieldStatus]
  1250. return ok
  1251. }
  1252. // ResetStatus resets all changes to the "status" field.
  1253. func (m *BatchMsgMutation) ResetStatus() {
  1254. m.status = nil
  1255. m.addstatus = nil
  1256. delete(m.clearedFields, batchmsg.FieldStatus)
  1257. }
  1258. // SetBatchNo sets the "batch_no" field.
  1259. func (m *BatchMsgMutation) SetBatchNo(s string) {
  1260. m.batch_no = &s
  1261. }
  1262. // BatchNo returns the value of the "batch_no" field in the mutation.
  1263. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  1264. v := m.batch_no
  1265. if v == nil {
  1266. return
  1267. }
  1268. return *v, true
  1269. }
  1270. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  1271. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1272. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1273. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  1274. if !m.op.Is(OpUpdateOne) {
  1275. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  1276. }
  1277. if m.id == nil || m.oldValue == nil {
  1278. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  1279. }
  1280. oldValue, err := m.oldValue(ctx)
  1281. if err != nil {
  1282. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  1283. }
  1284. return oldValue.BatchNo, nil
  1285. }
  1286. // ClearBatchNo clears the value of the "batch_no" field.
  1287. func (m *BatchMsgMutation) ClearBatchNo() {
  1288. m.batch_no = nil
  1289. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  1290. }
  1291. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  1292. func (m *BatchMsgMutation) BatchNoCleared() bool {
  1293. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  1294. return ok
  1295. }
  1296. // ResetBatchNo resets all changes to the "batch_no" field.
  1297. func (m *BatchMsgMutation) ResetBatchNo() {
  1298. m.batch_no = nil
  1299. delete(m.clearedFields, batchmsg.FieldBatchNo)
  1300. }
  1301. // SetTaskName sets the "task_name" field.
  1302. func (m *BatchMsgMutation) SetTaskName(s string) {
  1303. m.task_name = &s
  1304. }
  1305. // TaskName returns the value of the "task_name" field in the mutation.
  1306. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  1307. v := m.task_name
  1308. if v == nil {
  1309. return
  1310. }
  1311. return *v, true
  1312. }
  1313. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  1314. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1316. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  1317. if !m.op.Is(OpUpdateOne) {
  1318. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  1319. }
  1320. if m.id == nil || m.oldValue == nil {
  1321. return v, errors.New("OldTaskName requires an ID field in the mutation")
  1322. }
  1323. oldValue, err := m.oldValue(ctx)
  1324. if err != nil {
  1325. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  1326. }
  1327. return oldValue.TaskName, nil
  1328. }
  1329. // ClearTaskName clears the value of the "task_name" field.
  1330. func (m *BatchMsgMutation) ClearTaskName() {
  1331. m.task_name = nil
  1332. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  1333. }
  1334. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  1335. func (m *BatchMsgMutation) TaskNameCleared() bool {
  1336. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  1337. return ok
  1338. }
  1339. // ResetTaskName resets all changes to the "task_name" field.
  1340. func (m *BatchMsgMutation) ResetTaskName() {
  1341. m.task_name = nil
  1342. delete(m.clearedFields, batchmsg.FieldTaskName)
  1343. }
  1344. // SetFromwxid sets the "fromwxid" field.
  1345. func (m *BatchMsgMutation) SetFromwxid(s string) {
  1346. m.fromwxid = &s
  1347. }
  1348. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  1349. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  1350. v := m.fromwxid
  1351. if v == nil {
  1352. return
  1353. }
  1354. return *v, true
  1355. }
  1356. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  1357. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1359. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  1360. if !m.op.Is(OpUpdateOne) {
  1361. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  1362. }
  1363. if m.id == nil || m.oldValue == nil {
  1364. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  1365. }
  1366. oldValue, err := m.oldValue(ctx)
  1367. if err != nil {
  1368. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  1369. }
  1370. return oldValue.Fromwxid, nil
  1371. }
  1372. // ClearFromwxid clears the value of the "fromwxid" field.
  1373. func (m *BatchMsgMutation) ClearFromwxid() {
  1374. m.fromwxid = nil
  1375. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  1376. }
  1377. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  1378. func (m *BatchMsgMutation) FromwxidCleared() bool {
  1379. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  1380. return ok
  1381. }
  1382. // ResetFromwxid resets all changes to the "fromwxid" field.
  1383. func (m *BatchMsgMutation) ResetFromwxid() {
  1384. m.fromwxid = nil
  1385. delete(m.clearedFields, batchmsg.FieldFromwxid)
  1386. }
  1387. // SetMsg sets the "msg" field.
  1388. func (m *BatchMsgMutation) SetMsg(s string) {
  1389. m.msg = &s
  1390. }
  1391. // Msg returns the value of the "msg" field in the mutation.
  1392. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  1393. v := m.msg
  1394. if v == nil {
  1395. return
  1396. }
  1397. return *v, true
  1398. }
  1399. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  1400. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1402. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  1403. if !m.op.Is(OpUpdateOne) {
  1404. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  1405. }
  1406. if m.id == nil || m.oldValue == nil {
  1407. return v, errors.New("OldMsg requires an ID field in the mutation")
  1408. }
  1409. oldValue, err := m.oldValue(ctx)
  1410. if err != nil {
  1411. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  1412. }
  1413. return oldValue.Msg, nil
  1414. }
  1415. // ClearMsg clears the value of the "msg" field.
  1416. func (m *BatchMsgMutation) ClearMsg() {
  1417. m.msg = nil
  1418. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  1419. }
  1420. // MsgCleared returns if the "msg" field was cleared in this mutation.
  1421. func (m *BatchMsgMutation) MsgCleared() bool {
  1422. _, ok := m.clearedFields[batchmsg.FieldMsg]
  1423. return ok
  1424. }
  1425. // ResetMsg resets all changes to the "msg" field.
  1426. func (m *BatchMsgMutation) ResetMsg() {
  1427. m.msg = nil
  1428. delete(m.clearedFields, batchmsg.FieldMsg)
  1429. }
  1430. // SetTag sets the "tag" field.
  1431. func (m *BatchMsgMutation) SetTag(s string) {
  1432. m.tag = &s
  1433. }
  1434. // Tag returns the value of the "tag" field in the mutation.
  1435. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  1436. v := m.tag
  1437. if v == nil {
  1438. return
  1439. }
  1440. return *v, true
  1441. }
  1442. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  1443. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1445. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  1446. if !m.op.Is(OpUpdateOne) {
  1447. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  1448. }
  1449. if m.id == nil || m.oldValue == nil {
  1450. return v, errors.New("OldTag requires an ID field in the mutation")
  1451. }
  1452. oldValue, err := m.oldValue(ctx)
  1453. if err != nil {
  1454. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  1455. }
  1456. return oldValue.Tag, nil
  1457. }
  1458. // ClearTag clears the value of the "tag" field.
  1459. func (m *BatchMsgMutation) ClearTag() {
  1460. m.tag = nil
  1461. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  1462. }
  1463. // TagCleared returns if the "tag" field was cleared in this mutation.
  1464. func (m *BatchMsgMutation) TagCleared() bool {
  1465. _, ok := m.clearedFields[batchmsg.FieldTag]
  1466. return ok
  1467. }
  1468. // ResetTag resets all changes to the "tag" field.
  1469. func (m *BatchMsgMutation) ResetTag() {
  1470. m.tag = nil
  1471. delete(m.clearedFields, batchmsg.FieldTag)
  1472. }
  1473. // SetTotal sets the "total" field.
  1474. func (m *BatchMsgMutation) SetTotal(i int32) {
  1475. m.total = &i
  1476. m.addtotal = nil
  1477. }
  1478. // Total returns the value of the "total" field in the mutation.
  1479. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  1480. v := m.total
  1481. if v == nil {
  1482. return
  1483. }
  1484. return *v, true
  1485. }
  1486. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  1487. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1489. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  1490. if !m.op.Is(OpUpdateOne) {
  1491. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  1492. }
  1493. if m.id == nil || m.oldValue == nil {
  1494. return v, errors.New("OldTotal requires an ID field in the mutation")
  1495. }
  1496. oldValue, err := m.oldValue(ctx)
  1497. if err != nil {
  1498. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  1499. }
  1500. return oldValue.Total, nil
  1501. }
  1502. // AddTotal adds i to the "total" field.
  1503. func (m *BatchMsgMutation) AddTotal(i int32) {
  1504. if m.addtotal != nil {
  1505. *m.addtotal += i
  1506. } else {
  1507. m.addtotal = &i
  1508. }
  1509. }
  1510. // AddedTotal returns the value that was added to the "total" field in this mutation.
  1511. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  1512. v := m.addtotal
  1513. if v == nil {
  1514. return
  1515. }
  1516. return *v, true
  1517. }
  1518. // ClearTotal clears the value of the "total" field.
  1519. func (m *BatchMsgMutation) ClearTotal() {
  1520. m.total = nil
  1521. m.addtotal = nil
  1522. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  1523. }
  1524. // TotalCleared returns if the "total" field was cleared in this mutation.
  1525. func (m *BatchMsgMutation) TotalCleared() bool {
  1526. _, ok := m.clearedFields[batchmsg.FieldTotal]
  1527. return ok
  1528. }
  1529. // ResetTotal resets all changes to the "total" field.
  1530. func (m *BatchMsgMutation) ResetTotal() {
  1531. m.total = nil
  1532. m.addtotal = nil
  1533. delete(m.clearedFields, batchmsg.FieldTotal)
  1534. }
  1535. // SetSuccess sets the "success" field.
  1536. func (m *BatchMsgMutation) SetSuccess(i int32) {
  1537. m.success = &i
  1538. m.addsuccess = nil
  1539. }
  1540. // Success returns the value of the "success" field in the mutation.
  1541. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  1542. v := m.success
  1543. if v == nil {
  1544. return
  1545. }
  1546. return *v, true
  1547. }
  1548. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  1549. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1550. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1551. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  1552. if !m.op.Is(OpUpdateOne) {
  1553. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  1554. }
  1555. if m.id == nil || m.oldValue == nil {
  1556. return v, errors.New("OldSuccess requires an ID field in the mutation")
  1557. }
  1558. oldValue, err := m.oldValue(ctx)
  1559. if err != nil {
  1560. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  1561. }
  1562. return oldValue.Success, nil
  1563. }
  1564. // AddSuccess adds i to the "success" field.
  1565. func (m *BatchMsgMutation) AddSuccess(i int32) {
  1566. if m.addsuccess != nil {
  1567. *m.addsuccess += i
  1568. } else {
  1569. m.addsuccess = &i
  1570. }
  1571. }
  1572. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  1573. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  1574. v := m.addsuccess
  1575. if v == nil {
  1576. return
  1577. }
  1578. return *v, true
  1579. }
  1580. // ClearSuccess clears the value of the "success" field.
  1581. func (m *BatchMsgMutation) ClearSuccess() {
  1582. m.success = nil
  1583. m.addsuccess = nil
  1584. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  1585. }
  1586. // SuccessCleared returns if the "success" field was cleared in this mutation.
  1587. func (m *BatchMsgMutation) SuccessCleared() bool {
  1588. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  1589. return ok
  1590. }
  1591. // ResetSuccess resets all changes to the "success" field.
  1592. func (m *BatchMsgMutation) ResetSuccess() {
  1593. m.success = nil
  1594. m.addsuccess = nil
  1595. delete(m.clearedFields, batchmsg.FieldSuccess)
  1596. }
  1597. // SetFail sets the "fail" field.
  1598. func (m *BatchMsgMutation) SetFail(i int32) {
  1599. m.fail = &i
  1600. m.addfail = nil
  1601. }
  1602. // Fail returns the value of the "fail" field in the mutation.
  1603. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  1604. v := m.fail
  1605. if v == nil {
  1606. return
  1607. }
  1608. return *v, true
  1609. }
  1610. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  1611. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1612. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1613. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  1614. if !m.op.Is(OpUpdateOne) {
  1615. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  1616. }
  1617. if m.id == nil || m.oldValue == nil {
  1618. return v, errors.New("OldFail requires an ID field in the mutation")
  1619. }
  1620. oldValue, err := m.oldValue(ctx)
  1621. if err != nil {
  1622. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  1623. }
  1624. return oldValue.Fail, nil
  1625. }
  1626. // AddFail adds i to the "fail" field.
  1627. func (m *BatchMsgMutation) AddFail(i int32) {
  1628. if m.addfail != nil {
  1629. *m.addfail += i
  1630. } else {
  1631. m.addfail = &i
  1632. }
  1633. }
  1634. // AddedFail returns the value that was added to the "fail" field in this mutation.
  1635. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  1636. v := m.addfail
  1637. if v == nil {
  1638. return
  1639. }
  1640. return *v, true
  1641. }
  1642. // ClearFail clears the value of the "fail" field.
  1643. func (m *BatchMsgMutation) ClearFail() {
  1644. m.fail = nil
  1645. m.addfail = nil
  1646. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  1647. }
  1648. // FailCleared returns if the "fail" field was cleared in this mutation.
  1649. func (m *BatchMsgMutation) FailCleared() bool {
  1650. _, ok := m.clearedFields[batchmsg.FieldFail]
  1651. return ok
  1652. }
  1653. // ResetFail resets all changes to the "fail" field.
  1654. func (m *BatchMsgMutation) ResetFail() {
  1655. m.fail = nil
  1656. m.addfail = nil
  1657. delete(m.clearedFields, batchmsg.FieldFail)
  1658. }
  1659. // SetStartTime sets the "start_time" field.
  1660. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  1661. m.start_time = &t
  1662. }
  1663. // StartTime returns the value of the "start_time" field in the mutation.
  1664. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  1665. v := m.start_time
  1666. if v == nil {
  1667. return
  1668. }
  1669. return *v, true
  1670. }
  1671. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  1672. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1673. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1674. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  1675. if !m.op.Is(OpUpdateOne) {
  1676. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  1677. }
  1678. if m.id == nil || m.oldValue == nil {
  1679. return v, errors.New("OldStartTime requires an ID field in the mutation")
  1680. }
  1681. oldValue, err := m.oldValue(ctx)
  1682. if err != nil {
  1683. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  1684. }
  1685. return oldValue.StartTime, nil
  1686. }
  1687. // ClearStartTime clears the value of the "start_time" field.
  1688. func (m *BatchMsgMutation) ClearStartTime() {
  1689. m.start_time = nil
  1690. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  1691. }
  1692. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  1693. func (m *BatchMsgMutation) StartTimeCleared() bool {
  1694. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  1695. return ok
  1696. }
  1697. // ResetStartTime resets all changes to the "start_time" field.
  1698. func (m *BatchMsgMutation) ResetStartTime() {
  1699. m.start_time = nil
  1700. delete(m.clearedFields, batchmsg.FieldStartTime)
  1701. }
  1702. // SetStopTime sets the "stop_time" field.
  1703. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  1704. m.stop_time = &t
  1705. }
  1706. // StopTime returns the value of the "stop_time" field in the mutation.
  1707. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  1708. v := m.stop_time
  1709. if v == nil {
  1710. return
  1711. }
  1712. return *v, true
  1713. }
  1714. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  1715. // If the BatchMsg 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 *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  1718. if !m.op.Is(OpUpdateOne) {
  1719. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  1720. }
  1721. if m.id == nil || m.oldValue == nil {
  1722. return v, errors.New("OldStopTime 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 OldStopTime: %w", err)
  1727. }
  1728. return oldValue.StopTime, nil
  1729. }
  1730. // ClearStopTime clears the value of the "stop_time" field.
  1731. func (m *BatchMsgMutation) ClearStopTime() {
  1732. m.stop_time = nil
  1733. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  1734. }
  1735. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  1736. func (m *BatchMsgMutation) StopTimeCleared() bool {
  1737. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  1738. return ok
  1739. }
  1740. // ResetStopTime resets all changes to the "stop_time" field.
  1741. func (m *BatchMsgMutation) ResetStopTime() {
  1742. m.stop_time = nil
  1743. delete(m.clearedFields, batchmsg.FieldStopTime)
  1744. }
  1745. // SetSendTime sets the "send_time" field.
  1746. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  1747. m.send_time = &t
  1748. }
  1749. // SendTime returns the value of the "send_time" field in the mutation.
  1750. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  1751. v := m.send_time
  1752. if v == nil {
  1753. return
  1754. }
  1755. return *v, true
  1756. }
  1757. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  1758. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1759. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1760. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  1761. if !m.op.Is(OpUpdateOne) {
  1762. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  1763. }
  1764. if m.id == nil || m.oldValue == nil {
  1765. return v, errors.New("OldSendTime requires an ID field in the mutation")
  1766. }
  1767. oldValue, err := m.oldValue(ctx)
  1768. if err != nil {
  1769. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  1770. }
  1771. return oldValue.SendTime, nil
  1772. }
  1773. // ClearSendTime clears the value of the "send_time" field.
  1774. func (m *BatchMsgMutation) ClearSendTime() {
  1775. m.send_time = nil
  1776. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  1777. }
  1778. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  1779. func (m *BatchMsgMutation) SendTimeCleared() bool {
  1780. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  1781. return ok
  1782. }
  1783. // ResetSendTime resets all changes to the "send_time" field.
  1784. func (m *BatchMsgMutation) ResetSendTime() {
  1785. m.send_time = nil
  1786. delete(m.clearedFields, batchmsg.FieldSendTime)
  1787. }
  1788. // Where appends a list predicates to the BatchMsgMutation builder.
  1789. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  1790. m.predicates = append(m.predicates, ps...)
  1791. }
  1792. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  1793. // users can use type-assertion to append predicates that do not depend on any generated package.
  1794. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  1795. p := make([]predicate.BatchMsg, len(ps))
  1796. for i := range ps {
  1797. p[i] = ps[i]
  1798. }
  1799. m.Where(p...)
  1800. }
  1801. // Op returns the operation name.
  1802. func (m *BatchMsgMutation) Op() Op {
  1803. return m.op
  1804. }
  1805. // SetOp allows setting the mutation operation.
  1806. func (m *BatchMsgMutation) SetOp(op Op) {
  1807. m.op = op
  1808. }
  1809. // Type returns the node type of this mutation (BatchMsg).
  1810. func (m *BatchMsgMutation) Type() string {
  1811. return m.typ
  1812. }
  1813. // Fields returns all fields that were changed during this mutation. Note that in
  1814. // order to get all numeric fields that were incremented/decremented, call
  1815. // AddedFields().
  1816. func (m *BatchMsgMutation) Fields() []string {
  1817. fields := make([]string, 0, 15)
  1818. if m.created_at != nil {
  1819. fields = append(fields, batchmsg.FieldCreatedAt)
  1820. }
  1821. if m.updated_at != nil {
  1822. fields = append(fields, batchmsg.FieldUpdatedAt)
  1823. }
  1824. if m.deleted_at != nil {
  1825. fields = append(fields, batchmsg.FieldDeletedAt)
  1826. }
  1827. if m.status != nil {
  1828. fields = append(fields, batchmsg.FieldStatus)
  1829. }
  1830. if m.batch_no != nil {
  1831. fields = append(fields, batchmsg.FieldBatchNo)
  1832. }
  1833. if m.task_name != nil {
  1834. fields = append(fields, batchmsg.FieldTaskName)
  1835. }
  1836. if m.fromwxid != nil {
  1837. fields = append(fields, batchmsg.FieldFromwxid)
  1838. }
  1839. if m.msg != nil {
  1840. fields = append(fields, batchmsg.FieldMsg)
  1841. }
  1842. if m.tag != nil {
  1843. fields = append(fields, batchmsg.FieldTag)
  1844. }
  1845. if m.total != nil {
  1846. fields = append(fields, batchmsg.FieldTotal)
  1847. }
  1848. if m.success != nil {
  1849. fields = append(fields, batchmsg.FieldSuccess)
  1850. }
  1851. if m.fail != nil {
  1852. fields = append(fields, batchmsg.FieldFail)
  1853. }
  1854. if m.start_time != nil {
  1855. fields = append(fields, batchmsg.FieldStartTime)
  1856. }
  1857. if m.stop_time != nil {
  1858. fields = append(fields, batchmsg.FieldStopTime)
  1859. }
  1860. if m.send_time != nil {
  1861. fields = append(fields, batchmsg.FieldSendTime)
  1862. }
  1863. return fields
  1864. }
  1865. // Field returns the value of a field with the given name. The second boolean
  1866. // return value indicates that this field was not set, or was not defined in the
  1867. // schema.
  1868. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  1869. switch name {
  1870. case batchmsg.FieldCreatedAt:
  1871. return m.CreatedAt()
  1872. case batchmsg.FieldUpdatedAt:
  1873. return m.UpdatedAt()
  1874. case batchmsg.FieldDeletedAt:
  1875. return m.DeletedAt()
  1876. case batchmsg.FieldStatus:
  1877. return m.Status()
  1878. case batchmsg.FieldBatchNo:
  1879. return m.BatchNo()
  1880. case batchmsg.FieldTaskName:
  1881. return m.TaskName()
  1882. case batchmsg.FieldFromwxid:
  1883. return m.Fromwxid()
  1884. case batchmsg.FieldMsg:
  1885. return m.Msg()
  1886. case batchmsg.FieldTag:
  1887. return m.Tag()
  1888. case batchmsg.FieldTotal:
  1889. return m.Total()
  1890. case batchmsg.FieldSuccess:
  1891. return m.Success()
  1892. case batchmsg.FieldFail:
  1893. return m.Fail()
  1894. case batchmsg.FieldStartTime:
  1895. return m.StartTime()
  1896. case batchmsg.FieldStopTime:
  1897. return m.StopTime()
  1898. case batchmsg.FieldSendTime:
  1899. return m.SendTime()
  1900. }
  1901. return nil, false
  1902. }
  1903. // OldField returns the old value of the field from the database. An error is
  1904. // returned if the mutation operation is not UpdateOne, or the query to the
  1905. // database failed.
  1906. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1907. switch name {
  1908. case batchmsg.FieldCreatedAt:
  1909. return m.OldCreatedAt(ctx)
  1910. case batchmsg.FieldUpdatedAt:
  1911. return m.OldUpdatedAt(ctx)
  1912. case batchmsg.FieldDeletedAt:
  1913. return m.OldDeletedAt(ctx)
  1914. case batchmsg.FieldStatus:
  1915. return m.OldStatus(ctx)
  1916. case batchmsg.FieldBatchNo:
  1917. return m.OldBatchNo(ctx)
  1918. case batchmsg.FieldTaskName:
  1919. return m.OldTaskName(ctx)
  1920. case batchmsg.FieldFromwxid:
  1921. return m.OldFromwxid(ctx)
  1922. case batchmsg.FieldMsg:
  1923. return m.OldMsg(ctx)
  1924. case batchmsg.FieldTag:
  1925. return m.OldTag(ctx)
  1926. case batchmsg.FieldTotal:
  1927. return m.OldTotal(ctx)
  1928. case batchmsg.FieldSuccess:
  1929. return m.OldSuccess(ctx)
  1930. case batchmsg.FieldFail:
  1931. return m.OldFail(ctx)
  1932. case batchmsg.FieldStartTime:
  1933. return m.OldStartTime(ctx)
  1934. case batchmsg.FieldStopTime:
  1935. return m.OldStopTime(ctx)
  1936. case batchmsg.FieldSendTime:
  1937. return m.OldSendTime(ctx)
  1938. }
  1939. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  1940. }
  1941. // SetField sets the value of a field with the given name. It returns an error if
  1942. // the field is not defined in the schema, or if the type mismatched the field
  1943. // type.
  1944. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  1945. switch name {
  1946. case batchmsg.FieldCreatedAt:
  1947. v, ok := value.(time.Time)
  1948. if !ok {
  1949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1950. }
  1951. m.SetCreatedAt(v)
  1952. return nil
  1953. case batchmsg.FieldUpdatedAt:
  1954. v, ok := value.(time.Time)
  1955. if !ok {
  1956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1957. }
  1958. m.SetUpdatedAt(v)
  1959. return nil
  1960. case batchmsg.FieldDeletedAt:
  1961. v, ok := value.(time.Time)
  1962. if !ok {
  1963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1964. }
  1965. m.SetDeletedAt(v)
  1966. return nil
  1967. case batchmsg.FieldStatus:
  1968. v, ok := value.(uint8)
  1969. if !ok {
  1970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1971. }
  1972. m.SetStatus(v)
  1973. return nil
  1974. case batchmsg.FieldBatchNo:
  1975. v, ok := value.(string)
  1976. if !ok {
  1977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1978. }
  1979. m.SetBatchNo(v)
  1980. return nil
  1981. case batchmsg.FieldTaskName:
  1982. v, ok := value.(string)
  1983. if !ok {
  1984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1985. }
  1986. m.SetTaskName(v)
  1987. return nil
  1988. case batchmsg.FieldFromwxid:
  1989. v, ok := value.(string)
  1990. if !ok {
  1991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1992. }
  1993. m.SetFromwxid(v)
  1994. return nil
  1995. case batchmsg.FieldMsg:
  1996. v, ok := value.(string)
  1997. if !ok {
  1998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1999. }
  2000. m.SetMsg(v)
  2001. return nil
  2002. case batchmsg.FieldTag:
  2003. v, ok := value.(string)
  2004. if !ok {
  2005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2006. }
  2007. m.SetTag(v)
  2008. return nil
  2009. case batchmsg.FieldTotal:
  2010. v, ok := value.(int32)
  2011. if !ok {
  2012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2013. }
  2014. m.SetTotal(v)
  2015. return nil
  2016. case batchmsg.FieldSuccess:
  2017. v, ok := value.(int32)
  2018. if !ok {
  2019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2020. }
  2021. m.SetSuccess(v)
  2022. return nil
  2023. case batchmsg.FieldFail:
  2024. v, ok := value.(int32)
  2025. if !ok {
  2026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2027. }
  2028. m.SetFail(v)
  2029. return nil
  2030. case batchmsg.FieldStartTime:
  2031. v, ok := value.(time.Time)
  2032. if !ok {
  2033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2034. }
  2035. m.SetStartTime(v)
  2036. return nil
  2037. case batchmsg.FieldStopTime:
  2038. v, ok := value.(time.Time)
  2039. if !ok {
  2040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2041. }
  2042. m.SetStopTime(v)
  2043. return nil
  2044. case batchmsg.FieldSendTime:
  2045. v, ok := value.(time.Time)
  2046. if !ok {
  2047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2048. }
  2049. m.SetSendTime(v)
  2050. return nil
  2051. }
  2052. return fmt.Errorf("unknown BatchMsg field %s", name)
  2053. }
  2054. // AddedFields returns all numeric fields that were incremented/decremented during
  2055. // this mutation.
  2056. func (m *BatchMsgMutation) AddedFields() []string {
  2057. var fields []string
  2058. if m.addstatus != nil {
  2059. fields = append(fields, batchmsg.FieldStatus)
  2060. }
  2061. if m.addtotal != nil {
  2062. fields = append(fields, batchmsg.FieldTotal)
  2063. }
  2064. if m.addsuccess != nil {
  2065. fields = append(fields, batchmsg.FieldSuccess)
  2066. }
  2067. if m.addfail != nil {
  2068. fields = append(fields, batchmsg.FieldFail)
  2069. }
  2070. return fields
  2071. }
  2072. // AddedField returns the numeric value that was incremented/decremented on a field
  2073. // with the given name. The second boolean return value indicates that this field
  2074. // was not set, or was not defined in the schema.
  2075. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  2076. switch name {
  2077. case batchmsg.FieldStatus:
  2078. return m.AddedStatus()
  2079. case batchmsg.FieldTotal:
  2080. return m.AddedTotal()
  2081. case batchmsg.FieldSuccess:
  2082. return m.AddedSuccess()
  2083. case batchmsg.FieldFail:
  2084. return m.AddedFail()
  2085. }
  2086. return nil, false
  2087. }
  2088. // AddField adds the value to the field with the given name. It returns an error if
  2089. // the field is not defined in the schema, or if the type mismatched the field
  2090. // type.
  2091. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  2092. switch name {
  2093. case batchmsg.FieldStatus:
  2094. v, ok := value.(int8)
  2095. if !ok {
  2096. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2097. }
  2098. m.AddStatus(v)
  2099. return nil
  2100. case batchmsg.FieldTotal:
  2101. v, ok := value.(int32)
  2102. if !ok {
  2103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2104. }
  2105. m.AddTotal(v)
  2106. return nil
  2107. case batchmsg.FieldSuccess:
  2108. v, ok := value.(int32)
  2109. if !ok {
  2110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2111. }
  2112. m.AddSuccess(v)
  2113. return nil
  2114. case batchmsg.FieldFail:
  2115. v, ok := value.(int32)
  2116. if !ok {
  2117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2118. }
  2119. m.AddFail(v)
  2120. return nil
  2121. }
  2122. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  2123. }
  2124. // ClearedFields returns all nullable fields that were cleared during this
  2125. // mutation.
  2126. func (m *BatchMsgMutation) ClearedFields() []string {
  2127. var fields []string
  2128. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  2129. fields = append(fields, batchmsg.FieldDeletedAt)
  2130. }
  2131. if m.FieldCleared(batchmsg.FieldStatus) {
  2132. fields = append(fields, batchmsg.FieldStatus)
  2133. }
  2134. if m.FieldCleared(batchmsg.FieldBatchNo) {
  2135. fields = append(fields, batchmsg.FieldBatchNo)
  2136. }
  2137. if m.FieldCleared(batchmsg.FieldTaskName) {
  2138. fields = append(fields, batchmsg.FieldTaskName)
  2139. }
  2140. if m.FieldCleared(batchmsg.FieldFromwxid) {
  2141. fields = append(fields, batchmsg.FieldFromwxid)
  2142. }
  2143. if m.FieldCleared(batchmsg.FieldMsg) {
  2144. fields = append(fields, batchmsg.FieldMsg)
  2145. }
  2146. if m.FieldCleared(batchmsg.FieldTag) {
  2147. fields = append(fields, batchmsg.FieldTag)
  2148. }
  2149. if m.FieldCleared(batchmsg.FieldTotal) {
  2150. fields = append(fields, batchmsg.FieldTotal)
  2151. }
  2152. if m.FieldCleared(batchmsg.FieldSuccess) {
  2153. fields = append(fields, batchmsg.FieldSuccess)
  2154. }
  2155. if m.FieldCleared(batchmsg.FieldFail) {
  2156. fields = append(fields, batchmsg.FieldFail)
  2157. }
  2158. if m.FieldCleared(batchmsg.FieldStartTime) {
  2159. fields = append(fields, batchmsg.FieldStartTime)
  2160. }
  2161. if m.FieldCleared(batchmsg.FieldStopTime) {
  2162. fields = append(fields, batchmsg.FieldStopTime)
  2163. }
  2164. if m.FieldCleared(batchmsg.FieldSendTime) {
  2165. fields = append(fields, batchmsg.FieldSendTime)
  2166. }
  2167. return fields
  2168. }
  2169. // FieldCleared returns a boolean indicating if a field with the given name was
  2170. // cleared in this mutation.
  2171. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  2172. _, ok := m.clearedFields[name]
  2173. return ok
  2174. }
  2175. // ClearField clears the value of the field with the given name. It returns an
  2176. // error if the field is not defined in the schema.
  2177. func (m *BatchMsgMutation) ClearField(name string) error {
  2178. switch name {
  2179. case batchmsg.FieldDeletedAt:
  2180. m.ClearDeletedAt()
  2181. return nil
  2182. case batchmsg.FieldStatus:
  2183. m.ClearStatus()
  2184. return nil
  2185. case batchmsg.FieldBatchNo:
  2186. m.ClearBatchNo()
  2187. return nil
  2188. case batchmsg.FieldTaskName:
  2189. m.ClearTaskName()
  2190. return nil
  2191. case batchmsg.FieldFromwxid:
  2192. m.ClearFromwxid()
  2193. return nil
  2194. case batchmsg.FieldMsg:
  2195. m.ClearMsg()
  2196. return nil
  2197. case batchmsg.FieldTag:
  2198. m.ClearTag()
  2199. return nil
  2200. case batchmsg.FieldTotal:
  2201. m.ClearTotal()
  2202. return nil
  2203. case batchmsg.FieldSuccess:
  2204. m.ClearSuccess()
  2205. return nil
  2206. case batchmsg.FieldFail:
  2207. m.ClearFail()
  2208. return nil
  2209. case batchmsg.FieldStartTime:
  2210. m.ClearStartTime()
  2211. return nil
  2212. case batchmsg.FieldStopTime:
  2213. m.ClearStopTime()
  2214. return nil
  2215. case batchmsg.FieldSendTime:
  2216. m.ClearSendTime()
  2217. return nil
  2218. }
  2219. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  2220. }
  2221. // ResetField resets all changes in the mutation for the field with the given name.
  2222. // It returns an error if the field is not defined in the schema.
  2223. func (m *BatchMsgMutation) ResetField(name string) error {
  2224. switch name {
  2225. case batchmsg.FieldCreatedAt:
  2226. m.ResetCreatedAt()
  2227. return nil
  2228. case batchmsg.FieldUpdatedAt:
  2229. m.ResetUpdatedAt()
  2230. return nil
  2231. case batchmsg.FieldDeletedAt:
  2232. m.ResetDeletedAt()
  2233. return nil
  2234. case batchmsg.FieldStatus:
  2235. m.ResetStatus()
  2236. return nil
  2237. case batchmsg.FieldBatchNo:
  2238. m.ResetBatchNo()
  2239. return nil
  2240. case batchmsg.FieldTaskName:
  2241. m.ResetTaskName()
  2242. return nil
  2243. case batchmsg.FieldFromwxid:
  2244. m.ResetFromwxid()
  2245. return nil
  2246. case batchmsg.FieldMsg:
  2247. m.ResetMsg()
  2248. return nil
  2249. case batchmsg.FieldTag:
  2250. m.ResetTag()
  2251. return nil
  2252. case batchmsg.FieldTotal:
  2253. m.ResetTotal()
  2254. return nil
  2255. case batchmsg.FieldSuccess:
  2256. m.ResetSuccess()
  2257. return nil
  2258. case batchmsg.FieldFail:
  2259. m.ResetFail()
  2260. return nil
  2261. case batchmsg.FieldStartTime:
  2262. m.ResetStartTime()
  2263. return nil
  2264. case batchmsg.FieldStopTime:
  2265. m.ResetStopTime()
  2266. return nil
  2267. case batchmsg.FieldSendTime:
  2268. m.ResetSendTime()
  2269. return nil
  2270. }
  2271. return fmt.Errorf("unknown BatchMsg field %s", name)
  2272. }
  2273. // AddedEdges returns all edge names that were set/added in this mutation.
  2274. func (m *BatchMsgMutation) AddedEdges() []string {
  2275. edges := make([]string, 0, 0)
  2276. return edges
  2277. }
  2278. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2279. // name in this mutation.
  2280. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  2281. return nil
  2282. }
  2283. // RemovedEdges returns all edge names that were removed in this mutation.
  2284. func (m *BatchMsgMutation) RemovedEdges() []string {
  2285. edges := make([]string, 0, 0)
  2286. return edges
  2287. }
  2288. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2289. // the given name in this mutation.
  2290. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  2291. return nil
  2292. }
  2293. // ClearedEdges returns all edge names that were cleared in this mutation.
  2294. func (m *BatchMsgMutation) ClearedEdges() []string {
  2295. edges := make([]string, 0, 0)
  2296. return edges
  2297. }
  2298. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2299. // was cleared in this mutation.
  2300. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  2301. return false
  2302. }
  2303. // ClearEdge clears the value of the edge with the given name. It returns an error
  2304. // if that edge is not defined in the schema.
  2305. func (m *BatchMsgMutation) ClearEdge(name string) error {
  2306. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  2307. }
  2308. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2309. // It returns an error if the edge is not defined in the schema.
  2310. func (m *BatchMsgMutation) ResetEdge(name string) error {
  2311. return fmt.Errorf("unknown BatchMsg edge %s", name)
  2312. }
  2313. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  2314. type ContactMutation struct {
  2315. config
  2316. op Op
  2317. typ string
  2318. id *uint64
  2319. created_at *time.Time
  2320. updated_at *time.Time
  2321. status *uint8
  2322. addstatus *int8
  2323. deleted_at *time.Time
  2324. wx_wxid *string
  2325. _type *int
  2326. add_type *int
  2327. wxid *string
  2328. account *string
  2329. nickname *string
  2330. markname *string
  2331. headimg *string
  2332. sex *int
  2333. addsex *int
  2334. starrole *string
  2335. dontseeit *int
  2336. adddontseeit *int
  2337. dontseeme *int
  2338. adddontseeme *int
  2339. lag *string
  2340. gid *string
  2341. gname *string
  2342. v3 *string
  2343. organization_id *uint64
  2344. addorganization_id *int64
  2345. clearedFields map[string]struct{}
  2346. contact_relationships map[uint64]struct{}
  2347. removedcontact_relationships map[uint64]struct{}
  2348. clearedcontact_relationships bool
  2349. contact_messages map[uint64]struct{}
  2350. removedcontact_messages map[uint64]struct{}
  2351. clearedcontact_messages bool
  2352. done bool
  2353. oldValue func(context.Context) (*Contact, error)
  2354. predicates []predicate.Contact
  2355. }
  2356. var _ ent.Mutation = (*ContactMutation)(nil)
  2357. // contactOption allows management of the mutation configuration using functional options.
  2358. type contactOption func(*ContactMutation)
  2359. // newContactMutation creates new mutation for the Contact entity.
  2360. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  2361. m := &ContactMutation{
  2362. config: c,
  2363. op: op,
  2364. typ: TypeContact,
  2365. clearedFields: make(map[string]struct{}),
  2366. }
  2367. for _, opt := range opts {
  2368. opt(m)
  2369. }
  2370. return m
  2371. }
  2372. // withContactID sets the ID field of the mutation.
  2373. func withContactID(id uint64) contactOption {
  2374. return func(m *ContactMutation) {
  2375. var (
  2376. err error
  2377. once sync.Once
  2378. value *Contact
  2379. )
  2380. m.oldValue = func(ctx context.Context) (*Contact, error) {
  2381. once.Do(func() {
  2382. if m.done {
  2383. err = errors.New("querying old values post mutation is not allowed")
  2384. } else {
  2385. value, err = m.Client().Contact.Get(ctx, id)
  2386. }
  2387. })
  2388. return value, err
  2389. }
  2390. m.id = &id
  2391. }
  2392. }
  2393. // withContact sets the old Contact of the mutation.
  2394. func withContact(node *Contact) contactOption {
  2395. return func(m *ContactMutation) {
  2396. m.oldValue = func(context.Context) (*Contact, error) {
  2397. return node, nil
  2398. }
  2399. m.id = &node.ID
  2400. }
  2401. }
  2402. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2403. // executed in a transaction (ent.Tx), a transactional client is returned.
  2404. func (m ContactMutation) Client() *Client {
  2405. client := &Client{config: m.config}
  2406. client.init()
  2407. return client
  2408. }
  2409. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2410. // it returns an error otherwise.
  2411. func (m ContactMutation) Tx() (*Tx, error) {
  2412. if _, ok := m.driver.(*txDriver); !ok {
  2413. return nil, errors.New("ent: mutation is not running in a transaction")
  2414. }
  2415. tx := &Tx{config: m.config}
  2416. tx.init()
  2417. return tx, nil
  2418. }
  2419. // SetID sets the value of the id field. Note that this
  2420. // operation is only accepted on creation of Contact entities.
  2421. func (m *ContactMutation) SetID(id uint64) {
  2422. m.id = &id
  2423. }
  2424. // ID returns the ID value in the mutation. Note that the ID is only available
  2425. // if it was provided to the builder or after it was returned from the database.
  2426. func (m *ContactMutation) ID() (id uint64, exists bool) {
  2427. if m.id == nil {
  2428. return
  2429. }
  2430. return *m.id, true
  2431. }
  2432. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2433. // That means, if the mutation is applied within a transaction with an isolation level such
  2434. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2435. // or updated by the mutation.
  2436. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  2437. switch {
  2438. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2439. id, exists := m.ID()
  2440. if exists {
  2441. return []uint64{id}, nil
  2442. }
  2443. fallthrough
  2444. case m.op.Is(OpUpdate | OpDelete):
  2445. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  2446. default:
  2447. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2448. }
  2449. }
  2450. // SetCreatedAt sets the "created_at" field.
  2451. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  2452. m.created_at = &t
  2453. }
  2454. // CreatedAt returns the value of the "created_at" field in the mutation.
  2455. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  2456. v := m.created_at
  2457. if v == nil {
  2458. return
  2459. }
  2460. return *v, true
  2461. }
  2462. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  2463. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2464. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2465. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2466. if !m.op.Is(OpUpdateOne) {
  2467. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2468. }
  2469. if m.id == nil || m.oldValue == nil {
  2470. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2471. }
  2472. oldValue, err := m.oldValue(ctx)
  2473. if err != nil {
  2474. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2475. }
  2476. return oldValue.CreatedAt, nil
  2477. }
  2478. // ResetCreatedAt resets all changes to the "created_at" field.
  2479. func (m *ContactMutation) ResetCreatedAt() {
  2480. m.created_at = nil
  2481. }
  2482. // SetUpdatedAt sets the "updated_at" field.
  2483. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  2484. m.updated_at = &t
  2485. }
  2486. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2487. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  2488. v := m.updated_at
  2489. if v == nil {
  2490. return
  2491. }
  2492. return *v, true
  2493. }
  2494. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  2495. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2496. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2497. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2498. if !m.op.Is(OpUpdateOne) {
  2499. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2500. }
  2501. if m.id == nil || m.oldValue == nil {
  2502. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2503. }
  2504. oldValue, err := m.oldValue(ctx)
  2505. if err != nil {
  2506. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2507. }
  2508. return oldValue.UpdatedAt, nil
  2509. }
  2510. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2511. func (m *ContactMutation) ResetUpdatedAt() {
  2512. m.updated_at = nil
  2513. }
  2514. // SetStatus sets the "status" field.
  2515. func (m *ContactMutation) SetStatus(u uint8) {
  2516. m.status = &u
  2517. m.addstatus = nil
  2518. }
  2519. // Status returns the value of the "status" field in the mutation.
  2520. func (m *ContactMutation) Status() (r uint8, exists bool) {
  2521. v := m.status
  2522. if v == nil {
  2523. return
  2524. }
  2525. return *v, true
  2526. }
  2527. // OldStatus returns the old "status" field's value of the Contact entity.
  2528. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2529. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2530. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  2531. if !m.op.Is(OpUpdateOne) {
  2532. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  2533. }
  2534. if m.id == nil || m.oldValue == nil {
  2535. return v, errors.New("OldStatus requires an ID field in the mutation")
  2536. }
  2537. oldValue, err := m.oldValue(ctx)
  2538. if err != nil {
  2539. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  2540. }
  2541. return oldValue.Status, nil
  2542. }
  2543. // AddStatus adds u to the "status" field.
  2544. func (m *ContactMutation) AddStatus(u int8) {
  2545. if m.addstatus != nil {
  2546. *m.addstatus += u
  2547. } else {
  2548. m.addstatus = &u
  2549. }
  2550. }
  2551. // AddedStatus returns the value that was added to the "status" field in this mutation.
  2552. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  2553. v := m.addstatus
  2554. if v == nil {
  2555. return
  2556. }
  2557. return *v, true
  2558. }
  2559. // ClearStatus clears the value of the "status" field.
  2560. func (m *ContactMutation) ClearStatus() {
  2561. m.status = nil
  2562. m.addstatus = nil
  2563. m.clearedFields[contact.FieldStatus] = struct{}{}
  2564. }
  2565. // StatusCleared returns if the "status" field was cleared in this mutation.
  2566. func (m *ContactMutation) StatusCleared() bool {
  2567. _, ok := m.clearedFields[contact.FieldStatus]
  2568. return ok
  2569. }
  2570. // ResetStatus resets all changes to the "status" field.
  2571. func (m *ContactMutation) ResetStatus() {
  2572. m.status = nil
  2573. m.addstatus = nil
  2574. delete(m.clearedFields, contact.FieldStatus)
  2575. }
  2576. // SetDeletedAt sets the "deleted_at" field.
  2577. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  2578. m.deleted_at = &t
  2579. }
  2580. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2581. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  2582. v := m.deleted_at
  2583. if v == nil {
  2584. return
  2585. }
  2586. return *v, true
  2587. }
  2588. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  2589. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2590. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2591. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2592. if !m.op.Is(OpUpdateOne) {
  2593. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2594. }
  2595. if m.id == nil || m.oldValue == nil {
  2596. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2597. }
  2598. oldValue, err := m.oldValue(ctx)
  2599. if err != nil {
  2600. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2601. }
  2602. return oldValue.DeletedAt, nil
  2603. }
  2604. // ClearDeletedAt clears the value of the "deleted_at" field.
  2605. func (m *ContactMutation) ClearDeletedAt() {
  2606. m.deleted_at = nil
  2607. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  2608. }
  2609. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2610. func (m *ContactMutation) DeletedAtCleared() bool {
  2611. _, ok := m.clearedFields[contact.FieldDeletedAt]
  2612. return ok
  2613. }
  2614. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2615. func (m *ContactMutation) ResetDeletedAt() {
  2616. m.deleted_at = nil
  2617. delete(m.clearedFields, contact.FieldDeletedAt)
  2618. }
  2619. // SetWxWxid sets the "wx_wxid" field.
  2620. func (m *ContactMutation) SetWxWxid(s string) {
  2621. m.wx_wxid = &s
  2622. }
  2623. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  2624. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  2625. v := m.wx_wxid
  2626. if v == nil {
  2627. return
  2628. }
  2629. return *v, true
  2630. }
  2631. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  2632. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2633. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2634. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  2635. if !m.op.Is(OpUpdateOne) {
  2636. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  2637. }
  2638. if m.id == nil || m.oldValue == nil {
  2639. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  2640. }
  2641. oldValue, err := m.oldValue(ctx)
  2642. if err != nil {
  2643. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  2644. }
  2645. return oldValue.WxWxid, nil
  2646. }
  2647. // ClearWxWxid clears the value of the "wx_wxid" field.
  2648. func (m *ContactMutation) ClearWxWxid() {
  2649. m.wx_wxid = nil
  2650. m.clearedFields[contact.FieldWxWxid] = struct{}{}
  2651. }
  2652. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  2653. func (m *ContactMutation) WxWxidCleared() bool {
  2654. _, ok := m.clearedFields[contact.FieldWxWxid]
  2655. return ok
  2656. }
  2657. // ResetWxWxid resets all changes to the "wx_wxid" field.
  2658. func (m *ContactMutation) ResetWxWxid() {
  2659. m.wx_wxid = nil
  2660. delete(m.clearedFields, contact.FieldWxWxid)
  2661. }
  2662. // SetType sets the "type" field.
  2663. func (m *ContactMutation) SetType(i int) {
  2664. m._type = &i
  2665. m.add_type = nil
  2666. }
  2667. // GetType returns the value of the "type" field in the mutation.
  2668. func (m *ContactMutation) GetType() (r int, exists bool) {
  2669. v := m._type
  2670. if v == nil {
  2671. return
  2672. }
  2673. return *v, true
  2674. }
  2675. // OldType returns the old "type" field's value of the Contact entity.
  2676. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2678. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  2679. if !m.op.Is(OpUpdateOne) {
  2680. return v, errors.New("OldType is only allowed on UpdateOne operations")
  2681. }
  2682. if m.id == nil || m.oldValue == nil {
  2683. return v, errors.New("OldType requires an ID field in the mutation")
  2684. }
  2685. oldValue, err := m.oldValue(ctx)
  2686. if err != nil {
  2687. return v, fmt.Errorf("querying old value for OldType: %w", err)
  2688. }
  2689. return oldValue.Type, nil
  2690. }
  2691. // AddType adds i to the "type" field.
  2692. func (m *ContactMutation) AddType(i int) {
  2693. if m.add_type != nil {
  2694. *m.add_type += i
  2695. } else {
  2696. m.add_type = &i
  2697. }
  2698. }
  2699. // AddedType returns the value that was added to the "type" field in this mutation.
  2700. func (m *ContactMutation) AddedType() (r int, exists bool) {
  2701. v := m.add_type
  2702. if v == nil {
  2703. return
  2704. }
  2705. return *v, true
  2706. }
  2707. // ClearType clears the value of the "type" field.
  2708. func (m *ContactMutation) ClearType() {
  2709. m._type = nil
  2710. m.add_type = nil
  2711. m.clearedFields[contact.FieldType] = struct{}{}
  2712. }
  2713. // TypeCleared returns if the "type" field was cleared in this mutation.
  2714. func (m *ContactMutation) TypeCleared() bool {
  2715. _, ok := m.clearedFields[contact.FieldType]
  2716. return ok
  2717. }
  2718. // ResetType resets all changes to the "type" field.
  2719. func (m *ContactMutation) ResetType() {
  2720. m._type = nil
  2721. m.add_type = nil
  2722. delete(m.clearedFields, contact.FieldType)
  2723. }
  2724. // SetWxid sets the "wxid" field.
  2725. func (m *ContactMutation) SetWxid(s string) {
  2726. m.wxid = &s
  2727. }
  2728. // Wxid returns the value of the "wxid" field in the mutation.
  2729. func (m *ContactMutation) Wxid() (r string, exists bool) {
  2730. v := m.wxid
  2731. if v == nil {
  2732. return
  2733. }
  2734. return *v, true
  2735. }
  2736. // OldWxid returns the old "wxid" field's value of the Contact entity.
  2737. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2738. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2739. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  2740. if !m.op.Is(OpUpdateOne) {
  2741. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  2742. }
  2743. if m.id == nil || m.oldValue == nil {
  2744. return v, errors.New("OldWxid requires an ID field in the mutation")
  2745. }
  2746. oldValue, err := m.oldValue(ctx)
  2747. if err != nil {
  2748. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  2749. }
  2750. return oldValue.Wxid, nil
  2751. }
  2752. // ResetWxid resets all changes to the "wxid" field.
  2753. func (m *ContactMutation) ResetWxid() {
  2754. m.wxid = nil
  2755. }
  2756. // SetAccount sets the "account" field.
  2757. func (m *ContactMutation) SetAccount(s string) {
  2758. m.account = &s
  2759. }
  2760. // Account returns the value of the "account" field in the mutation.
  2761. func (m *ContactMutation) Account() (r string, exists bool) {
  2762. v := m.account
  2763. if v == nil {
  2764. return
  2765. }
  2766. return *v, true
  2767. }
  2768. // OldAccount returns the old "account" field's value of the Contact entity.
  2769. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2770. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2771. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  2772. if !m.op.Is(OpUpdateOne) {
  2773. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  2774. }
  2775. if m.id == nil || m.oldValue == nil {
  2776. return v, errors.New("OldAccount requires an ID field in the mutation")
  2777. }
  2778. oldValue, err := m.oldValue(ctx)
  2779. if err != nil {
  2780. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  2781. }
  2782. return oldValue.Account, nil
  2783. }
  2784. // ResetAccount resets all changes to the "account" field.
  2785. func (m *ContactMutation) ResetAccount() {
  2786. m.account = nil
  2787. }
  2788. // SetNickname sets the "nickname" field.
  2789. func (m *ContactMutation) SetNickname(s string) {
  2790. m.nickname = &s
  2791. }
  2792. // Nickname returns the value of the "nickname" field in the mutation.
  2793. func (m *ContactMutation) Nickname() (r string, exists bool) {
  2794. v := m.nickname
  2795. if v == nil {
  2796. return
  2797. }
  2798. return *v, true
  2799. }
  2800. // OldNickname returns the old "nickname" field's value of the Contact entity.
  2801. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2802. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2803. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  2804. if !m.op.Is(OpUpdateOne) {
  2805. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  2806. }
  2807. if m.id == nil || m.oldValue == nil {
  2808. return v, errors.New("OldNickname requires an ID field in the mutation")
  2809. }
  2810. oldValue, err := m.oldValue(ctx)
  2811. if err != nil {
  2812. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  2813. }
  2814. return oldValue.Nickname, nil
  2815. }
  2816. // ResetNickname resets all changes to the "nickname" field.
  2817. func (m *ContactMutation) ResetNickname() {
  2818. m.nickname = nil
  2819. }
  2820. // SetMarkname sets the "markname" field.
  2821. func (m *ContactMutation) SetMarkname(s string) {
  2822. m.markname = &s
  2823. }
  2824. // Markname returns the value of the "markname" field in the mutation.
  2825. func (m *ContactMutation) Markname() (r string, exists bool) {
  2826. v := m.markname
  2827. if v == nil {
  2828. return
  2829. }
  2830. return *v, true
  2831. }
  2832. // OldMarkname returns the old "markname" field's value of the Contact entity.
  2833. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2834. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2835. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  2836. if !m.op.Is(OpUpdateOne) {
  2837. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  2838. }
  2839. if m.id == nil || m.oldValue == nil {
  2840. return v, errors.New("OldMarkname requires an ID field in the mutation")
  2841. }
  2842. oldValue, err := m.oldValue(ctx)
  2843. if err != nil {
  2844. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  2845. }
  2846. return oldValue.Markname, nil
  2847. }
  2848. // ResetMarkname resets all changes to the "markname" field.
  2849. func (m *ContactMutation) ResetMarkname() {
  2850. m.markname = nil
  2851. }
  2852. // SetHeadimg sets the "headimg" field.
  2853. func (m *ContactMutation) SetHeadimg(s string) {
  2854. m.headimg = &s
  2855. }
  2856. // Headimg returns the value of the "headimg" field in the mutation.
  2857. func (m *ContactMutation) Headimg() (r string, exists bool) {
  2858. v := m.headimg
  2859. if v == nil {
  2860. return
  2861. }
  2862. return *v, true
  2863. }
  2864. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  2865. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2866. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2867. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  2868. if !m.op.Is(OpUpdateOne) {
  2869. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  2870. }
  2871. if m.id == nil || m.oldValue == nil {
  2872. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  2873. }
  2874. oldValue, err := m.oldValue(ctx)
  2875. if err != nil {
  2876. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  2877. }
  2878. return oldValue.Headimg, nil
  2879. }
  2880. // ResetHeadimg resets all changes to the "headimg" field.
  2881. func (m *ContactMutation) ResetHeadimg() {
  2882. m.headimg = nil
  2883. }
  2884. // SetSex sets the "sex" field.
  2885. func (m *ContactMutation) SetSex(i int) {
  2886. m.sex = &i
  2887. m.addsex = nil
  2888. }
  2889. // Sex returns the value of the "sex" field in the mutation.
  2890. func (m *ContactMutation) Sex() (r int, exists bool) {
  2891. v := m.sex
  2892. if v == nil {
  2893. return
  2894. }
  2895. return *v, true
  2896. }
  2897. // OldSex returns the old "sex" field's value of the Contact entity.
  2898. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2900. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  2901. if !m.op.Is(OpUpdateOne) {
  2902. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  2903. }
  2904. if m.id == nil || m.oldValue == nil {
  2905. return v, errors.New("OldSex requires an ID field in the mutation")
  2906. }
  2907. oldValue, err := m.oldValue(ctx)
  2908. if err != nil {
  2909. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  2910. }
  2911. return oldValue.Sex, nil
  2912. }
  2913. // AddSex adds i to the "sex" field.
  2914. func (m *ContactMutation) AddSex(i int) {
  2915. if m.addsex != nil {
  2916. *m.addsex += i
  2917. } else {
  2918. m.addsex = &i
  2919. }
  2920. }
  2921. // AddedSex returns the value that was added to the "sex" field in this mutation.
  2922. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  2923. v := m.addsex
  2924. if v == nil {
  2925. return
  2926. }
  2927. return *v, true
  2928. }
  2929. // ResetSex resets all changes to the "sex" field.
  2930. func (m *ContactMutation) ResetSex() {
  2931. m.sex = nil
  2932. m.addsex = nil
  2933. }
  2934. // SetStarrole sets the "starrole" field.
  2935. func (m *ContactMutation) SetStarrole(s string) {
  2936. m.starrole = &s
  2937. }
  2938. // Starrole returns the value of the "starrole" field in the mutation.
  2939. func (m *ContactMutation) Starrole() (r string, exists bool) {
  2940. v := m.starrole
  2941. if v == nil {
  2942. return
  2943. }
  2944. return *v, true
  2945. }
  2946. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  2947. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2948. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2949. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  2950. if !m.op.Is(OpUpdateOne) {
  2951. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  2952. }
  2953. if m.id == nil || m.oldValue == nil {
  2954. return v, errors.New("OldStarrole requires an ID field in the mutation")
  2955. }
  2956. oldValue, err := m.oldValue(ctx)
  2957. if err != nil {
  2958. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  2959. }
  2960. return oldValue.Starrole, nil
  2961. }
  2962. // ResetStarrole resets all changes to the "starrole" field.
  2963. func (m *ContactMutation) ResetStarrole() {
  2964. m.starrole = nil
  2965. }
  2966. // SetDontseeit sets the "dontseeit" field.
  2967. func (m *ContactMutation) SetDontseeit(i int) {
  2968. m.dontseeit = &i
  2969. m.adddontseeit = nil
  2970. }
  2971. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  2972. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  2973. v := m.dontseeit
  2974. if v == nil {
  2975. return
  2976. }
  2977. return *v, true
  2978. }
  2979. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  2980. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2981. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2982. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  2983. if !m.op.Is(OpUpdateOne) {
  2984. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  2985. }
  2986. if m.id == nil || m.oldValue == nil {
  2987. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  2988. }
  2989. oldValue, err := m.oldValue(ctx)
  2990. if err != nil {
  2991. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  2992. }
  2993. return oldValue.Dontseeit, nil
  2994. }
  2995. // AddDontseeit adds i to the "dontseeit" field.
  2996. func (m *ContactMutation) AddDontseeit(i int) {
  2997. if m.adddontseeit != nil {
  2998. *m.adddontseeit += i
  2999. } else {
  3000. m.adddontseeit = &i
  3001. }
  3002. }
  3003. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  3004. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  3005. v := m.adddontseeit
  3006. if v == nil {
  3007. return
  3008. }
  3009. return *v, true
  3010. }
  3011. // ResetDontseeit resets all changes to the "dontseeit" field.
  3012. func (m *ContactMutation) ResetDontseeit() {
  3013. m.dontseeit = nil
  3014. m.adddontseeit = nil
  3015. }
  3016. // SetDontseeme sets the "dontseeme" field.
  3017. func (m *ContactMutation) SetDontseeme(i int) {
  3018. m.dontseeme = &i
  3019. m.adddontseeme = nil
  3020. }
  3021. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  3022. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  3023. v := m.dontseeme
  3024. if v == nil {
  3025. return
  3026. }
  3027. return *v, true
  3028. }
  3029. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  3030. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3031. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3032. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  3033. if !m.op.Is(OpUpdateOne) {
  3034. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  3035. }
  3036. if m.id == nil || m.oldValue == nil {
  3037. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  3038. }
  3039. oldValue, err := m.oldValue(ctx)
  3040. if err != nil {
  3041. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  3042. }
  3043. return oldValue.Dontseeme, nil
  3044. }
  3045. // AddDontseeme adds i to the "dontseeme" field.
  3046. func (m *ContactMutation) AddDontseeme(i int) {
  3047. if m.adddontseeme != nil {
  3048. *m.adddontseeme += i
  3049. } else {
  3050. m.adddontseeme = &i
  3051. }
  3052. }
  3053. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  3054. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  3055. v := m.adddontseeme
  3056. if v == nil {
  3057. return
  3058. }
  3059. return *v, true
  3060. }
  3061. // ResetDontseeme resets all changes to the "dontseeme" field.
  3062. func (m *ContactMutation) ResetDontseeme() {
  3063. m.dontseeme = nil
  3064. m.adddontseeme = nil
  3065. }
  3066. // SetLag sets the "lag" field.
  3067. func (m *ContactMutation) SetLag(s string) {
  3068. m.lag = &s
  3069. }
  3070. // Lag returns the value of the "lag" field in the mutation.
  3071. func (m *ContactMutation) Lag() (r string, exists bool) {
  3072. v := m.lag
  3073. if v == nil {
  3074. return
  3075. }
  3076. return *v, true
  3077. }
  3078. // OldLag returns the old "lag" field's value of the Contact entity.
  3079. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3081. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  3082. if !m.op.Is(OpUpdateOne) {
  3083. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  3084. }
  3085. if m.id == nil || m.oldValue == nil {
  3086. return v, errors.New("OldLag requires an ID field in the mutation")
  3087. }
  3088. oldValue, err := m.oldValue(ctx)
  3089. if err != nil {
  3090. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  3091. }
  3092. return oldValue.Lag, nil
  3093. }
  3094. // ResetLag resets all changes to the "lag" field.
  3095. func (m *ContactMutation) ResetLag() {
  3096. m.lag = nil
  3097. }
  3098. // SetGid sets the "gid" field.
  3099. func (m *ContactMutation) SetGid(s string) {
  3100. m.gid = &s
  3101. }
  3102. // Gid returns the value of the "gid" field in the mutation.
  3103. func (m *ContactMutation) Gid() (r string, exists bool) {
  3104. v := m.gid
  3105. if v == nil {
  3106. return
  3107. }
  3108. return *v, true
  3109. }
  3110. // OldGid returns the old "gid" field's value of the Contact entity.
  3111. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3112. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3113. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  3114. if !m.op.Is(OpUpdateOne) {
  3115. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  3116. }
  3117. if m.id == nil || m.oldValue == nil {
  3118. return v, errors.New("OldGid requires an ID field in the mutation")
  3119. }
  3120. oldValue, err := m.oldValue(ctx)
  3121. if err != nil {
  3122. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  3123. }
  3124. return oldValue.Gid, nil
  3125. }
  3126. // ResetGid resets all changes to the "gid" field.
  3127. func (m *ContactMutation) ResetGid() {
  3128. m.gid = nil
  3129. }
  3130. // SetGname sets the "gname" field.
  3131. func (m *ContactMutation) SetGname(s string) {
  3132. m.gname = &s
  3133. }
  3134. // Gname returns the value of the "gname" field in the mutation.
  3135. func (m *ContactMutation) Gname() (r string, exists bool) {
  3136. v := m.gname
  3137. if v == nil {
  3138. return
  3139. }
  3140. return *v, true
  3141. }
  3142. // OldGname returns the old "gname" field's value of the Contact entity.
  3143. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3144. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3145. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  3146. if !m.op.Is(OpUpdateOne) {
  3147. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  3148. }
  3149. if m.id == nil || m.oldValue == nil {
  3150. return v, errors.New("OldGname requires an ID field in the mutation")
  3151. }
  3152. oldValue, err := m.oldValue(ctx)
  3153. if err != nil {
  3154. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  3155. }
  3156. return oldValue.Gname, nil
  3157. }
  3158. // ResetGname resets all changes to the "gname" field.
  3159. func (m *ContactMutation) ResetGname() {
  3160. m.gname = nil
  3161. }
  3162. // SetV3 sets the "v3" field.
  3163. func (m *ContactMutation) SetV3(s string) {
  3164. m.v3 = &s
  3165. }
  3166. // V3 returns the value of the "v3" field in the mutation.
  3167. func (m *ContactMutation) V3() (r string, exists bool) {
  3168. v := m.v3
  3169. if v == nil {
  3170. return
  3171. }
  3172. return *v, true
  3173. }
  3174. // OldV3 returns the old "v3" field's value of the Contact entity.
  3175. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3176. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3177. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  3178. if !m.op.Is(OpUpdateOne) {
  3179. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  3180. }
  3181. if m.id == nil || m.oldValue == nil {
  3182. return v, errors.New("OldV3 requires an ID field in the mutation")
  3183. }
  3184. oldValue, err := m.oldValue(ctx)
  3185. if err != nil {
  3186. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  3187. }
  3188. return oldValue.V3, nil
  3189. }
  3190. // ResetV3 resets all changes to the "v3" field.
  3191. func (m *ContactMutation) ResetV3() {
  3192. m.v3 = nil
  3193. }
  3194. // SetOrganizationID sets the "organization_id" field.
  3195. func (m *ContactMutation) SetOrganizationID(u uint64) {
  3196. m.organization_id = &u
  3197. m.addorganization_id = nil
  3198. }
  3199. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3200. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  3201. v := m.organization_id
  3202. if v == nil {
  3203. return
  3204. }
  3205. return *v, true
  3206. }
  3207. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  3208. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  3209. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3210. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3211. if !m.op.Is(OpUpdateOne) {
  3212. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3213. }
  3214. if m.id == nil || m.oldValue == nil {
  3215. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3216. }
  3217. oldValue, err := m.oldValue(ctx)
  3218. if err != nil {
  3219. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3220. }
  3221. return oldValue.OrganizationID, nil
  3222. }
  3223. // AddOrganizationID adds u to the "organization_id" field.
  3224. func (m *ContactMutation) AddOrganizationID(u int64) {
  3225. if m.addorganization_id != nil {
  3226. *m.addorganization_id += u
  3227. } else {
  3228. m.addorganization_id = &u
  3229. }
  3230. }
  3231. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3232. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  3233. v := m.addorganization_id
  3234. if v == nil {
  3235. return
  3236. }
  3237. return *v, true
  3238. }
  3239. // ClearOrganizationID clears the value of the "organization_id" field.
  3240. func (m *ContactMutation) ClearOrganizationID() {
  3241. m.organization_id = nil
  3242. m.addorganization_id = nil
  3243. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  3244. }
  3245. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3246. func (m *ContactMutation) OrganizationIDCleared() bool {
  3247. _, ok := m.clearedFields[contact.FieldOrganizationID]
  3248. return ok
  3249. }
  3250. // ResetOrganizationID resets all changes to the "organization_id" field.
  3251. func (m *ContactMutation) ResetOrganizationID() {
  3252. m.organization_id = nil
  3253. m.addorganization_id = nil
  3254. delete(m.clearedFields, contact.FieldOrganizationID)
  3255. }
  3256. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  3257. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  3258. if m.contact_relationships == nil {
  3259. m.contact_relationships = make(map[uint64]struct{})
  3260. }
  3261. for i := range ids {
  3262. m.contact_relationships[ids[i]] = struct{}{}
  3263. }
  3264. }
  3265. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  3266. func (m *ContactMutation) ClearContactRelationships() {
  3267. m.clearedcontact_relationships = true
  3268. }
  3269. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  3270. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  3271. return m.clearedcontact_relationships
  3272. }
  3273. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  3274. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  3275. if m.removedcontact_relationships == nil {
  3276. m.removedcontact_relationships = make(map[uint64]struct{})
  3277. }
  3278. for i := range ids {
  3279. delete(m.contact_relationships, ids[i])
  3280. m.removedcontact_relationships[ids[i]] = struct{}{}
  3281. }
  3282. }
  3283. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  3284. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  3285. for id := range m.removedcontact_relationships {
  3286. ids = append(ids, id)
  3287. }
  3288. return
  3289. }
  3290. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  3291. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  3292. for id := range m.contact_relationships {
  3293. ids = append(ids, id)
  3294. }
  3295. return
  3296. }
  3297. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  3298. func (m *ContactMutation) ResetContactRelationships() {
  3299. m.contact_relationships = nil
  3300. m.clearedcontact_relationships = false
  3301. m.removedcontact_relationships = nil
  3302. }
  3303. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  3304. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  3305. if m.contact_messages == nil {
  3306. m.contact_messages = make(map[uint64]struct{})
  3307. }
  3308. for i := range ids {
  3309. m.contact_messages[ids[i]] = struct{}{}
  3310. }
  3311. }
  3312. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  3313. func (m *ContactMutation) ClearContactMessages() {
  3314. m.clearedcontact_messages = true
  3315. }
  3316. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  3317. func (m *ContactMutation) ContactMessagesCleared() bool {
  3318. return m.clearedcontact_messages
  3319. }
  3320. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  3321. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  3322. if m.removedcontact_messages == nil {
  3323. m.removedcontact_messages = make(map[uint64]struct{})
  3324. }
  3325. for i := range ids {
  3326. delete(m.contact_messages, ids[i])
  3327. m.removedcontact_messages[ids[i]] = struct{}{}
  3328. }
  3329. }
  3330. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  3331. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  3332. for id := range m.removedcontact_messages {
  3333. ids = append(ids, id)
  3334. }
  3335. return
  3336. }
  3337. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  3338. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  3339. for id := range m.contact_messages {
  3340. ids = append(ids, id)
  3341. }
  3342. return
  3343. }
  3344. // ResetContactMessages resets all changes to the "contact_messages" edge.
  3345. func (m *ContactMutation) ResetContactMessages() {
  3346. m.contact_messages = nil
  3347. m.clearedcontact_messages = false
  3348. m.removedcontact_messages = nil
  3349. }
  3350. // Where appends a list predicates to the ContactMutation builder.
  3351. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  3352. m.predicates = append(m.predicates, ps...)
  3353. }
  3354. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  3355. // users can use type-assertion to append predicates that do not depend on any generated package.
  3356. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  3357. p := make([]predicate.Contact, len(ps))
  3358. for i := range ps {
  3359. p[i] = ps[i]
  3360. }
  3361. m.Where(p...)
  3362. }
  3363. // Op returns the operation name.
  3364. func (m *ContactMutation) Op() Op {
  3365. return m.op
  3366. }
  3367. // SetOp allows setting the mutation operation.
  3368. func (m *ContactMutation) SetOp(op Op) {
  3369. m.op = op
  3370. }
  3371. // Type returns the node type of this mutation (Contact).
  3372. func (m *ContactMutation) Type() string {
  3373. return m.typ
  3374. }
  3375. // Fields returns all fields that were changed during this mutation. Note that in
  3376. // order to get all numeric fields that were incremented/decremented, call
  3377. // AddedFields().
  3378. func (m *ContactMutation) Fields() []string {
  3379. fields := make([]string, 0, 20)
  3380. if m.created_at != nil {
  3381. fields = append(fields, contact.FieldCreatedAt)
  3382. }
  3383. if m.updated_at != nil {
  3384. fields = append(fields, contact.FieldUpdatedAt)
  3385. }
  3386. if m.status != nil {
  3387. fields = append(fields, contact.FieldStatus)
  3388. }
  3389. if m.deleted_at != nil {
  3390. fields = append(fields, contact.FieldDeletedAt)
  3391. }
  3392. if m.wx_wxid != nil {
  3393. fields = append(fields, contact.FieldWxWxid)
  3394. }
  3395. if m._type != nil {
  3396. fields = append(fields, contact.FieldType)
  3397. }
  3398. if m.wxid != nil {
  3399. fields = append(fields, contact.FieldWxid)
  3400. }
  3401. if m.account != nil {
  3402. fields = append(fields, contact.FieldAccount)
  3403. }
  3404. if m.nickname != nil {
  3405. fields = append(fields, contact.FieldNickname)
  3406. }
  3407. if m.markname != nil {
  3408. fields = append(fields, contact.FieldMarkname)
  3409. }
  3410. if m.headimg != nil {
  3411. fields = append(fields, contact.FieldHeadimg)
  3412. }
  3413. if m.sex != nil {
  3414. fields = append(fields, contact.FieldSex)
  3415. }
  3416. if m.starrole != nil {
  3417. fields = append(fields, contact.FieldStarrole)
  3418. }
  3419. if m.dontseeit != nil {
  3420. fields = append(fields, contact.FieldDontseeit)
  3421. }
  3422. if m.dontseeme != nil {
  3423. fields = append(fields, contact.FieldDontseeme)
  3424. }
  3425. if m.lag != nil {
  3426. fields = append(fields, contact.FieldLag)
  3427. }
  3428. if m.gid != nil {
  3429. fields = append(fields, contact.FieldGid)
  3430. }
  3431. if m.gname != nil {
  3432. fields = append(fields, contact.FieldGname)
  3433. }
  3434. if m.v3 != nil {
  3435. fields = append(fields, contact.FieldV3)
  3436. }
  3437. if m.organization_id != nil {
  3438. fields = append(fields, contact.FieldOrganizationID)
  3439. }
  3440. return fields
  3441. }
  3442. // Field returns the value of a field with the given name. The second boolean
  3443. // return value indicates that this field was not set, or was not defined in the
  3444. // schema.
  3445. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  3446. switch name {
  3447. case contact.FieldCreatedAt:
  3448. return m.CreatedAt()
  3449. case contact.FieldUpdatedAt:
  3450. return m.UpdatedAt()
  3451. case contact.FieldStatus:
  3452. return m.Status()
  3453. case contact.FieldDeletedAt:
  3454. return m.DeletedAt()
  3455. case contact.FieldWxWxid:
  3456. return m.WxWxid()
  3457. case contact.FieldType:
  3458. return m.GetType()
  3459. case contact.FieldWxid:
  3460. return m.Wxid()
  3461. case contact.FieldAccount:
  3462. return m.Account()
  3463. case contact.FieldNickname:
  3464. return m.Nickname()
  3465. case contact.FieldMarkname:
  3466. return m.Markname()
  3467. case contact.FieldHeadimg:
  3468. return m.Headimg()
  3469. case contact.FieldSex:
  3470. return m.Sex()
  3471. case contact.FieldStarrole:
  3472. return m.Starrole()
  3473. case contact.FieldDontseeit:
  3474. return m.Dontseeit()
  3475. case contact.FieldDontseeme:
  3476. return m.Dontseeme()
  3477. case contact.FieldLag:
  3478. return m.Lag()
  3479. case contact.FieldGid:
  3480. return m.Gid()
  3481. case contact.FieldGname:
  3482. return m.Gname()
  3483. case contact.FieldV3:
  3484. return m.V3()
  3485. case contact.FieldOrganizationID:
  3486. return m.OrganizationID()
  3487. }
  3488. return nil, false
  3489. }
  3490. // OldField returns the old value of the field from the database. An error is
  3491. // returned if the mutation operation is not UpdateOne, or the query to the
  3492. // database failed.
  3493. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3494. switch name {
  3495. case contact.FieldCreatedAt:
  3496. return m.OldCreatedAt(ctx)
  3497. case contact.FieldUpdatedAt:
  3498. return m.OldUpdatedAt(ctx)
  3499. case contact.FieldStatus:
  3500. return m.OldStatus(ctx)
  3501. case contact.FieldDeletedAt:
  3502. return m.OldDeletedAt(ctx)
  3503. case contact.FieldWxWxid:
  3504. return m.OldWxWxid(ctx)
  3505. case contact.FieldType:
  3506. return m.OldType(ctx)
  3507. case contact.FieldWxid:
  3508. return m.OldWxid(ctx)
  3509. case contact.FieldAccount:
  3510. return m.OldAccount(ctx)
  3511. case contact.FieldNickname:
  3512. return m.OldNickname(ctx)
  3513. case contact.FieldMarkname:
  3514. return m.OldMarkname(ctx)
  3515. case contact.FieldHeadimg:
  3516. return m.OldHeadimg(ctx)
  3517. case contact.FieldSex:
  3518. return m.OldSex(ctx)
  3519. case contact.FieldStarrole:
  3520. return m.OldStarrole(ctx)
  3521. case contact.FieldDontseeit:
  3522. return m.OldDontseeit(ctx)
  3523. case contact.FieldDontseeme:
  3524. return m.OldDontseeme(ctx)
  3525. case contact.FieldLag:
  3526. return m.OldLag(ctx)
  3527. case contact.FieldGid:
  3528. return m.OldGid(ctx)
  3529. case contact.FieldGname:
  3530. return m.OldGname(ctx)
  3531. case contact.FieldV3:
  3532. return m.OldV3(ctx)
  3533. case contact.FieldOrganizationID:
  3534. return m.OldOrganizationID(ctx)
  3535. }
  3536. return nil, fmt.Errorf("unknown Contact field %s", name)
  3537. }
  3538. // SetField sets the value of a field with the given name. It returns an error if
  3539. // the field is not defined in the schema, or if the type mismatched the field
  3540. // type.
  3541. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  3542. switch name {
  3543. case contact.FieldCreatedAt:
  3544. v, ok := value.(time.Time)
  3545. if !ok {
  3546. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3547. }
  3548. m.SetCreatedAt(v)
  3549. return nil
  3550. case contact.FieldUpdatedAt:
  3551. v, ok := value.(time.Time)
  3552. if !ok {
  3553. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3554. }
  3555. m.SetUpdatedAt(v)
  3556. return nil
  3557. case contact.FieldStatus:
  3558. v, ok := value.(uint8)
  3559. if !ok {
  3560. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3561. }
  3562. m.SetStatus(v)
  3563. return nil
  3564. case contact.FieldDeletedAt:
  3565. v, ok := value.(time.Time)
  3566. if !ok {
  3567. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3568. }
  3569. m.SetDeletedAt(v)
  3570. return nil
  3571. case contact.FieldWxWxid:
  3572. v, ok := value.(string)
  3573. if !ok {
  3574. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3575. }
  3576. m.SetWxWxid(v)
  3577. return nil
  3578. case contact.FieldType:
  3579. v, ok := value.(int)
  3580. if !ok {
  3581. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3582. }
  3583. m.SetType(v)
  3584. return nil
  3585. case contact.FieldWxid:
  3586. v, ok := value.(string)
  3587. if !ok {
  3588. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3589. }
  3590. m.SetWxid(v)
  3591. return nil
  3592. case contact.FieldAccount:
  3593. v, ok := value.(string)
  3594. if !ok {
  3595. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3596. }
  3597. m.SetAccount(v)
  3598. return nil
  3599. case contact.FieldNickname:
  3600. v, ok := value.(string)
  3601. if !ok {
  3602. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3603. }
  3604. m.SetNickname(v)
  3605. return nil
  3606. case contact.FieldMarkname:
  3607. v, ok := value.(string)
  3608. if !ok {
  3609. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3610. }
  3611. m.SetMarkname(v)
  3612. return nil
  3613. case contact.FieldHeadimg:
  3614. v, ok := value.(string)
  3615. if !ok {
  3616. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3617. }
  3618. m.SetHeadimg(v)
  3619. return nil
  3620. case contact.FieldSex:
  3621. v, ok := value.(int)
  3622. if !ok {
  3623. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3624. }
  3625. m.SetSex(v)
  3626. return nil
  3627. case contact.FieldStarrole:
  3628. v, ok := value.(string)
  3629. if !ok {
  3630. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3631. }
  3632. m.SetStarrole(v)
  3633. return nil
  3634. case contact.FieldDontseeit:
  3635. v, ok := value.(int)
  3636. if !ok {
  3637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3638. }
  3639. m.SetDontseeit(v)
  3640. return nil
  3641. case contact.FieldDontseeme:
  3642. v, ok := value.(int)
  3643. if !ok {
  3644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3645. }
  3646. m.SetDontseeme(v)
  3647. return nil
  3648. case contact.FieldLag:
  3649. v, ok := value.(string)
  3650. if !ok {
  3651. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3652. }
  3653. m.SetLag(v)
  3654. return nil
  3655. case contact.FieldGid:
  3656. v, ok := value.(string)
  3657. if !ok {
  3658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3659. }
  3660. m.SetGid(v)
  3661. return nil
  3662. case contact.FieldGname:
  3663. v, ok := value.(string)
  3664. if !ok {
  3665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3666. }
  3667. m.SetGname(v)
  3668. return nil
  3669. case contact.FieldV3:
  3670. v, ok := value.(string)
  3671. if !ok {
  3672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3673. }
  3674. m.SetV3(v)
  3675. return nil
  3676. case contact.FieldOrganizationID:
  3677. v, ok := value.(uint64)
  3678. if !ok {
  3679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3680. }
  3681. m.SetOrganizationID(v)
  3682. return nil
  3683. }
  3684. return fmt.Errorf("unknown Contact field %s", name)
  3685. }
  3686. // AddedFields returns all numeric fields that were incremented/decremented during
  3687. // this mutation.
  3688. func (m *ContactMutation) AddedFields() []string {
  3689. var fields []string
  3690. if m.addstatus != nil {
  3691. fields = append(fields, contact.FieldStatus)
  3692. }
  3693. if m.add_type != nil {
  3694. fields = append(fields, contact.FieldType)
  3695. }
  3696. if m.addsex != nil {
  3697. fields = append(fields, contact.FieldSex)
  3698. }
  3699. if m.adddontseeit != nil {
  3700. fields = append(fields, contact.FieldDontseeit)
  3701. }
  3702. if m.adddontseeme != nil {
  3703. fields = append(fields, contact.FieldDontseeme)
  3704. }
  3705. if m.addorganization_id != nil {
  3706. fields = append(fields, contact.FieldOrganizationID)
  3707. }
  3708. return fields
  3709. }
  3710. // AddedField returns the numeric value that was incremented/decremented on a field
  3711. // with the given name. The second boolean return value indicates that this field
  3712. // was not set, or was not defined in the schema.
  3713. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  3714. switch name {
  3715. case contact.FieldStatus:
  3716. return m.AddedStatus()
  3717. case contact.FieldType:
  3718. return m.AddedType()
  3719. case contact.FieldSex:
  3720. return m.AddedSex()
  3721. case contact.FieldDontseeit:
  3722. return m.AddedDontseeit()
  3723. case contact.FieldDontseeme:
  3724. return m.AddedDontseeme()
  3725. case contact.FieldOrganizationID:
  3726. return m.AddedOrganizationID()
  3727. }
  3728. return nil, false
  3729. }
  3730. // AddField adds the value to the field with the given name. It returns an error if
  3731. // the field is not defined in the schema, or if the type mismatched the field
  3732. // type.
  3733. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  3734. switch name {
  3735. case contact.FieldStatus:
  3736. v, ok := value.(int8)
  3737. if !ok {
  3738. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3739. }
  3740. m.AddStatus(v)
  3741. return nil
  3742. case contact.FieldType:
  3743. v, ok := value.(int)
  3744. if !ok {
  3745. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3746. }
  3747. m.AddType(v)
  3748. return nil
  3749. case contact.FieldSex:
  3750. v, ok := value.(int)
  3751. if !ok {
  3752. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3753. }
  3754. m.AddSex(v)
  3755. return nil
  3756. case contact.FieldDontseeit:
  3757. v, ok := value.(int)
  3758. if !ok {
  3759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3760. }
  3761. m.AddDontseeit(v)
  3762. return nil
  3763. case contact.FieldDontseeme:
  3764. v, ok := value.(int)
  3765. if !ok {
  3766. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3767. }
  3768. m.AddDontseeme(v)
  3769. return nil
  3770. case contact.FieldOrganizationID:
  3771. v, ok := value.(int64)
  3772. if !ok {
  3773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3774. }
  3775. m.AddOrganizationID(v)
  3776. return nil
  3777. }
  3778. return fmt.Errorf("unknown Contact numeric field %s", name)
  3779. }
  3780. // ClearedFields returns all nullable fields that were cleared during this
  3781. // mutation.
  3782. func (m *ContactMutation) ClearedFields() []string {
  3783. var fields []string
  3784. if m.FieldCleared(contact.FieldStatus) {
  3785. fields = append(fields, contact.FieldStatus)
  3786. }
  3787. if m.FieldCleared(contact.FieldDeletedAt) {
  3788. fields = append(fields, contact.FieldDeletedAt)
  3789. }
  3790. if m.FieldCleared(contact.FieldWxWxid) {
  3791. fields = append(fields, contact.FieldWxWxid)
  3792. }
  3793. if m.FieldCleared(contact.FieldType) {
  3794. fields = append(fields, contact.FieldType)
  3795. }
  3796. if m.FieldCleared(contact.FieldOrganizationID) {
  3797. fields = append(fields, contact.FieldOrganizationID)
  3798. }
  3799. return fields
  3800. }
  3801. // FieldCleared returns a boolean indicating if a field with the given name was
  3802. // cleared in this mutation.
  3803. func (m *ContactMutation) FieldCleared(name string) bool {
  3804. _, ok := m.clearedFields[name]
  3805. return ok
  3806. }
  3807. // ClearField clears the value of the field with the given name. It returns an
  3808. // error if the field is not defined in the schema.
  3809. func (m *ContactMutation) ClearField(name string) error {
  3810. switch name {
  3811. case contact.FieldStatus:
  3812. m.ClearStatus()
  3813. return nil
  3814. case contact.FieldDeletedAt:
  3815. m.ClearDeletedAt()
  3816. return nil
  3817. case contact.FieldWxWxid:
  3818. m.ClearWxWxid()
  3819. return nil
  3820. case contact.FieldType:
  3821. m.ClearType()
  3822. return nil
  3823. case contact.FieldOrganizationID:
  3824. m.ClearOrganizationID()
  3825. return nil
  3826. }
  3827. return fmt.Errorf("unknown Contact nullable field %s", name)
  3828. }
  3829. // ResetField resets all changes in the mutation for the field with the given name.
  3830. // It returns an error if the field is not defined in the schema.
  3831. func (m *ContactMutation) ResetField(name string) error {
  3832. switch name {
  3833. case contact.FieldCreatedAt:
  3834. m.ResetCreatedAt()
  3835. return nil
  3836. case contact.FieldUpdatedAt:
  3837. m.ResetUpdatedAt()
  3838. return nil
  3839. case contact.FieldStatus:
  3840. m.ResetStatus()
  3841. return nil
  3842. case contact.FieldDeletedAt:
  3843. m.ResetDeletedAt()
  3844. return nil
  3845. case contact.FieldWxWxid:
  3846. m.ResetWxWxid()
  3847. return nil
  3848. case contact.FieldType:
  3849. m.ResetType()
  3850. return nil
  3851. case contact.FieldWxid:
  3852. m.ResetWxid()
  3853. return nil
  3854. case contact.FieldAccount:
  3855. m.ResetAccount()
  3856. return nil
  3857. case contact.FieldNickname:
  3858. m.ResetNickname()
  3859. return nil
  3860. case contact.FieldMarkname:
  3861. m.ResetMarkname()
  3862. return nil
  3863. case contact.FieldHeadimg:
  3864. m.ResetHeadimg()
  3865. return nil
  3866. case contact.FieldSex:
  3867. m.ResetSex()
  3868. return nil
  3869. case contact.FieldStarrole:
  3870. m.ResetStarrole()
  3871. return nil
  3872. case contact.FieldDontseeit:
  3873. m.ResetDontseeit()
  3874. return nil
  3875. case contact.FieldDontseeme:
  3876. m.ResetDontseeme()
  3877. return nil
  3878. case contact.FieldLag:
  3879. m.ResetLag()
  3880. return nil
  3881. case contact.FieldGid:
  3882. m.ResetGid()
  3883. return nil
  3884. case contact.FieldGname:
  3885. m.ResetGname()
  3886. return nil
  3887. case contact.FieldV3:
  3888. m.ResetV3()
  3889. return nil
  3890. case contact.FieldOrganizationID:
  3891. m.ResetOrganizationID()
  3892. return nil
  3893. }
  3894. return fmt.Errorf("unknown Contact field %s", name)
  3895. }
  3896. // AddedEdges returns all edge names that were set/added in this mutation.
  3897. func (m *ContactMutation) AddedEdges() []string {
  3898. edges := make([]string, 0, 2)
  3899. if m.contact_relationships != nil {
  3900. edges = append(edges, contact.EdgeContactRelationships)
  3901. }
  3902. if m.contact_messages != nil {
  3903. edges = append(edges, contact.EdgeContactMessages)
  3904. }
  3905. return edges
  3906. }
  3907. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3908. // name in this mutation.
  3909. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  3910. switch name {
  3911. case contact.EdgeContactRelationships:
  3912. ids := make([]ent.Value, 0, len(m.contact_relationships))
  3913. for id := range m.contact_relationships {
  3914. ids = append(ids, id)
  3915. }
  3916. return ids
  3917. case contact.EdgeContactMessages:
  3918. ids := make([]ent.Value, 0, len(m.contact_messages))
  3919. for id := range m.contact_messages {
  3920. ids = append(ids, id)
  3921. }
  3922. return ids
  3923. }
  3924. return nil
  3925. }
  3926. // RemovedEdges returns all edge names that were removed in this mutation.
  3927. func (m *ContactMutation) RemovedEdges() []string {
  3928. edges := make([]string, 0, 2)
  3929. if m.removedcontact_relationships != nil {
  3930. edges = append(edges, contact.EdgeContactRelationships)
  3931. }
  3932. if m.removedcontact_messages != nil {
  3933. edges = append(edges, contact.EdgeContactMessages)
  3934. }
  3935. return edges
  3936. }
  3937. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3938. // the given name in this mutation.
  3939. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  3940. switch name {
  3941. case contact.EdgeContactRelationships:
  3942. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  3943. for id := range m.removedcontact_relationships {
  3944. ids = append(ids, id)
  3945. }
  3946. return ids
  3947. case contact.EdgeContactMessages:
  3948. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  3949. for id := range m.removedcontact_messages {
  3950. ids = append(ids, id)
  3951. }
  3952. return ids
  3953. }
  3954. return nil
  3955. }
  3956. // ClearedEdges returns all edge names that were cleared in this mutation.
  3957. func (m *ContactMutation) ClearedEdges() []string {
  3958. edges := make([]string, 0, 2)
  3959. if m.clearedcontact_relationships {
  3960. edges = append(edges, contact.EdgeContactRelationships)
  3961. }
  3962. if m.clearedcontact_messages {
  3963. edges = append(edges, contact.EdgeContactMessages)
  3964. }
  3965. return edges
  3966. }
  3967. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3968. // was cleared in this mutation.
  3969. func (m *ContactMutation) EdgeCleared(name string) bool {
  3970. switch name {
  3971. case contact.EdgeContactRelationships:
  3972. return m.clearedcontact_relationships
  3973. case contact.EdgeContactMessages:
  3974. return m.clearedcontact_messages
  3975. }
  3976. return false
  3977. }
  3978. // ClearEdge clears the value of the edge with the given name. It returns an error
  3979. // if that edge is not defined in the schema.
  3980. func (m *ContactMutation) ClearEdge(name string) error {
  3981. switch name {
  3982. }
  3983. return fmt.Errorf("unknown Contact unique edge %s", name)
  3984. }
  3985. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3986. // It returns an error if the edge is not defined in the schema.
  3987. func (m *ContactMutation) ResetEdge(name string) error {
  3988. switch name {
  3989. case contact.EdgeContactRelationships:
  3990. m.ResetContactRelationships()
  3991. return nil
  3992. case contact.EdgeContactMessages:
  3993. m.ResetContactMessages()
  3994. return nil
  3995. }
  3996. return fmt.Errorf("unknown Contact edge %s", name)
  3997. }
  3998. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  3999. type LabelMutation struct {
  4000. config
  4001. op Op
  4002. typ string
  4003. id *uint64
  4004. created_at *time.Time
  4005. updated_at *time.Time
  4006. status *uint8
  4007. addstatus *int8
  4008. _type *int
  4009. add_type *int
  4010. name *string
  4011. from *int
  4012. addfrom *int
  4013. mode *int
  4014. addmode *int
  4015. conditions *string
  4016. organization_id *uint64
  4017. addorganization_id *int64
  4018. clearedFields map[string]struct{}
  4019. label_relationships map[uint64]struct{}
  4020. removedlabel_relationships map[uint64]struct{}
  4021. clearedlabel_relationships bool
  4022. done bool
  4023. oldValue func(context.Context) (*Label, error)
  4024. predicates []predicate.Label
  4025. }
  4026. var _ ent.Mutation = (*LabelMutation)(nil)
  4027. // labelOption allows management of the mutation configuration using functional options.
  4028. type labelOption func(*LabelMutation)
  4029. // newLabelMutation creates new mutation for the Label entity.
  4030. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  4031. m := &LabelMutation{
  4032. config: c,
  4033. op: op,
  4034. typ: TypeLabel,
  4035. clearedFields: make(map[string]struct{}),
  4036. }
  4037. for _, opt := range opts {
  4038. opt(m)
  4039. }
  4040. return m
  4041. }
  4042. // withLabelID sets the ID field of the mutation.
  4043. func withLabelID(id uint64) labelOption {
  4044. return func(m *LabelMutation) {
  4045. var (
  4046. err error
  4047. once sync.Once
  4048. value *Label
  4049. )
  4050. m.oldValue = func(ctx context.Context) (*Label, error) {
  4051. once.Do(func() {
  4052. if m.done {
  4053. err = errors.New("querying old values post mutation is not allowed")
  4054. } else {
  4055. value, err = m.Client().Label.Get(ctx, id)
  4056. }
  4057. })
  4058. return value, err
  4059. }
  4060. m.id = &id
  4061. }
  4062. }
  4063. // withLabel sets the old Label of the mutation.
  4064. func withLabel(node *Label) labelOption {
  4065. return func(m *LabelMutation) {
  4066. m.oldValue = func(context.Context) (*Label, error) {
  4067. return node, nil
  4068. }
  4069. m.id = &node.ID
  4070. }
  4071. }
  4072. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4073. // executed in a transaction (ent.Tx), a transactional client is returned.
  4074. func (m LabelMutation) Client() *Client {
  4075. client := &Client{config: m.config}
  4076. client.init()
  4077. return client
  4078. }
  4079. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4080. // it returns an error otherwise.
  4081. func (m LabelMutation) Tx() (*Tx, error) {
  4082. if _, ok := m.driver.(*txDriver); !ok {
  4083. return nil, errors.New("ent: mutation is not running in a transaction")
  4084. }
  4085. tx := &Tx{config: m.config}
  4086. tx.init()
  4087. return tx, nil
  4088. }
  4089. // SetID sets the value of the id field. Note that this
  4090. // operation is only accepted on creation of Label entities.
  4091. func (m *LabelMutation) SetID(id uint64) {
  4092. m.id = &id
  4093. }
  4094. // ID returns the ID value in the mutation. Note that the ID is only available
  4095. // if it was provided to the builder or after it was returned from the database.
  4096. func (m *LabelMutation) ID() (id uint64, exists bool) {
  4097. if m.id == nil {
  4098. return
  4099. }
  4100. return *m.id, true
  4101. }
  4102. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4103. // That means, if the mutation is applied within a transaction with an isolation level such
  4104. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4105. // or updated by the mutation.
  4106. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  4107. switch {
  4108. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4109. id, exists := m.ID()
  4110. if exists {
  4111. return []uint64{id}, nil
  4112. }
  4113. fallthrough
  4114. case m.op.Is(OpUpdate | OpDelete):
  4115. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  4116. default:
  4117. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4118. }
  4119. }
  4120. // SetCreatedAt sets the "created_at" field.
  4121. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  4122. m.created_at = &t
  4123. }
  4124. // CreatedAt returns the value of the "created_at" field in the mutation.
  4125. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  4126. v := m.created_at
  4127. if v == nil {
  4128. return
  4129. }
  4130. return *v, true
  4131. }
  4132. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  4133. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  4134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4135. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4136. if !m.op.Is(OpUpdateOne) {
  4137. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4138. }
  4139. if m.id == nil || m.oldValue == nil {
  4140. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4141. }
  4142. oldValue, err := m.oldValue(ctx)
  4143. if err != nil {
  4144. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4145. }
  4146. return oldValue.CreatedAt, nil
  4147. }
  4148. // ResetCreatedAt resets all changes to the "created_at" field.
  4149. func (m *LabelMutation) ResetCreatedAt() {
  4150. m.created_at = nil
  4151. }
  4152. // SetUpdatedAt sets the "updated_at" field.
  4153. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  4154. m.updated_at = &t
  4155. }
  4156. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4157. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  4158. v := m.updated_at
  4159. if v == nil {
  4160. return
  4161. }
  4162. return *v, true
  4163. }
  4164. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  4165. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  4166. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4167. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4168. if !m.op.Is(OpUpdateOne) {
  4169. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4170. }
  4171. if m.id == nil || m.oldValue == nil {
  4172. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4173. }
  4174. oldValue, err := m.oldValue(ctx)
  4175. if err != nil {
  4176. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4177. }
  4178. return oldValue.UpdatedAt, nil
  4179. }
  4180. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4181. func (m *LabelMutation) ResetUpdatedAt() {
  4182. m.updated_at = nil
  4183. }
  4184. // SetStatus sets the "status" field.
  4185. func (m *LabelMutation) SetStatus(u uint8) {
  4186. m.status = &u
  4187. m.addstatus = nil
  4188. }
  4189. // Status returns the value of the "status" field in the mutation.
  4190. func (m *LabelMutation) Status() (r uint8, exists bool) {
  4191. v := m.status
  4192. if v == nil {
  4193. return
  4194. }
  4195. return *v, true
  4196. }
  4197. // OldStatus returns the old "status" field's value of the Label entity.
  4198. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  4199. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4200. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  4201. if !m.op.Is(OpUpdateOne) {
  4202. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  4203. }
  4204. if m.id == nil || m.oldValue == nil {
  4205. return v, errors.New("OldStatus requires an ID field in the mutation")
  4206. }
  4207. oldValue, err := m.oldValue(ctx)
  4208. if err != nil {
  4209. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  4210. }
  4211. return oldValue.Status, nil
  4212. }
  4213. // AddStatus adds u to the "status" field.
  4214. func (m *LabelMutation) AddStatus(u int8) {
  4215. if m.addstatus != nil {
  4216. *m.addstatus += u
  4217. } else {
  4218. m.addstatus = &u
  4219. }
  4220. }
  4221. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4222. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  4223. v := m.addstatus
  4224. if v == nil {
  4225. return
  4226. }
  4227. return *v, true
  4228. }
  4229. // ClearStatus clears the value of the "status" field.
  4230. func (m *LabelMutation) ClearStatus() {
  4231. m.status = nil
  4232. m.addstatus = nil
  4233. m.clearedFields[label.FieldStatus] = struct{}{}
  4234. }
  4235. // StatusCleared returns if the "status" field was cleared in this mutation.
  4236. func (m *LabelMutation) StatusCleared() bool {
  4237. _, ok := m.clearedFields[label.FieldStatus]
  4238. return ok
  4239. }
  4240. // ResetStatus resets all changes to the "status" field.
  4241. func (m *LabelMutation) ResetStatus() {
  4242. m.status = nil
  4243. m.addstatus = nil
  4244. delete(m.clearedFields, label.FieldStatus)
  4245. }
  4246. // SetType sets the "type" field.
  4247. func (m *LabelMutation) SetType(i int) {
  4248. m._type = &i
  4249. m.add_type = nil
  4250. }
  4251. // GetType returns the value of the "type" field in the mutation.
  4252. func (m *LabelMutation) GetType() (r int, exists bool) {
  4253. v := m._type
  4254. if v == nil {
  4255. return
  4256. }
  4257. return *v, true
  4258. }
  4259. // OldType returns the old "type" field's value of the Label entity.
  4260. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  4261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4262. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  4263. if !m.op.Is(OpUpdateOne) {
  4264. return v, errors.New("OldType is only allowed on UpdateOne operations")
  4265. }
  4266. if m.id == nil || m.oldValue == nil {
  4267. return v, errors.New("OldType requires an ID field in the mutation")
  4268. }
  4269. oldValue, err := m.oldValue(ctx)
  4270. if err != nil {
  4271. return v, fmt.Errorf("querying old value for OldType: %w", err)
  4272. }
  4273. return oldValue.Type, nil
  4274. }
  4275. // AddType adds i to the "type" field.
  4276. func (m *LabelMutation) AddType(i int) {
  4277. if m.add_type != nil {
  4278. *m.add_type += i
  4279. } else {
  4280. m.add_type = &i
  4281. }
  4282. }
  4283. // AddedType returns the value that was added to the "type" field in this mutation.
  4284. func (m *LabelMutation) AddedType() (r int, exists bool) {
  4285. v := m.add_type
  4286. if v == nil {
  4287. return
  4288. }
  4289. return *v, true
  4290. }
  4291. // ResetType resets all changes to the "type" field.
  4292. func (m *LabelMutation) ResetType() {
  4293. m._type = nil
  4294. m.add_type = nil
  4295. }
  4296. // SetName sets the "name" field.
  4297. func (m *LabelMutation) SetName(s string) {
  4298. m.name = &s
  4299. }
  4300. // Name returns the value of the "name" field in the mutation.
  4301. func (m *LabelMutation) Name() (r string, exists bool) {
  4302. v := m.name
  4303. if v == nil {
  4304. return
  4305. }
  4306. return *v, true
  4307. }
  4308. // OldName returns the old "name" field's value of the Label entity.
  4309. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  4310. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4311. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  4312. if !m.op.Is(OpUpdateOne) {
  4313. return v, errors.New("OldName is only allowed on UpdateOne operations")
  4314. }
  4315. if m.id == nil || m.oldValue == nil {
  4316. return v, errors.New("OldName requires an ID field in the mutation")
  4317. }
  4318. oldValue, err := m.oldValue(ctx)
  4319. if err != nil {
  4320. return v, fmt.Errorf("querying old value for OldName: %w", err)
  4321. }
  4322. return oldValue.Name, nil
  4323. }
  4324. // ResetName resets all changes to the "name" field.
  4325. func (m *LabelMutation) ResetName() {
  4326. m.name = nil
  4327. }
  4328. // SetFrom sets the "from" field.
  4329. func (m *LabelMutation) SetFrom(i int) {
  4330. m.from = &i
  4331. m.addfrom = nil
  4332. }
  4333. // From returns the value of the "from" field in the mutation.
  4334. func (m *LabelMutation) From() (r int, exists bool) {
  4335. v := m.from
  4336. if v == nil {
  4337. return
  4338. }
  4339. return *v, true
  4340. }
  4341. // OldFrom returns the old "from" field's value of the Label entity.
  4342. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  4343. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4344. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  4345. if !m.op.Is(OpUpdateOne) {
  4346. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  4347. }
  4348. if m.id == nil || m.oldValue == nil {
  4349. return v, errors.New("OldFrom requires an ID field in the mutation")
  4350. }
  4351. oldValue, err := m.oldValue(ctx)
  4352. if err != nil {
  4353. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  4354. }
  4355. return oldValue.From, nil
  4356. }
  4357. // AddFrom adds i to the "from" field.
  4358. func (m *LabelMutation) AddFrom(i int) {
  4359. if m.addfrom != nil {
  4360. *m.addfrom += i
  4361. } else {
  4362. m.addfrom = &i
  4363. }
  4364. }
  4365. // AddedFrom returns the value that was added to the "from" field in this mutation.
  4366. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  4367. v := m.addfrom
  4368. if v == nil {
  4369. return
  4370. }
  4371. return *v, true
  4372. }
  4373. // ResetFrom resets all changes to the "from" field.
  4374. func (m *LabelMutation) ResetFrom() {
  4375. m.from = nil
  4376. m.addfrom = nil
  4377. }
  4378. // SetMode sets the "mode" field.
  4379. func (m *LabelMutation) SetMode(i int) {
  4380. m.mode = &i
  4381. m.addmode = nil
  4382. }
  4383. // Mode returns the value of the "mode" field in the mutation.
  4384. func (m *LabelMutation) Mode() (r int, exists bool) {
  4385. v := m.mode
  4386. if v == nil {
  4387. return
  4388. }
  4389. return *v, true
  4390. }
  4391. // OldMode returns the old "mode" field's value of the Label entity.
  4392. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  4393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4394. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  4395. if !m.op.Is(OpUpdateOne) {
  4396. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  4397. }
  4398. if m.id == nil || m.oldValue == nil {
  4399. return v, errors.New("OldMode requires an ID field in the mutation")
  4400. }
  4401. oldValue, err := m.oldValue(ctx)
  4402. if err != nil {
  4403. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  4404. }
  4405. return oldValue.Mode, nil
  4406. }
  4407. // AddMode adds i to the "mode" field.
  4408. func (m *LabelMutation) AddMode(i int) {
  4409. if m.addmode != nil {
  4410. *m.addmode += i
  4411. } else {
  4412. m.addmode = &i
  4413. }
  4414. }
  4415. // AddedMode returns the value that was added to the "mode" field in this mutation.
  4416. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  4417. v := m.addmode
  4418. if v == nil {
  4419. return
  4420. }
  4421. return *v, true
  4422. }
  4423. // ResetMode resets all changes to the "mode" field.
  4424. func (m *LabelMutation) ResetMode() {
  4425. m.mode = nil
  4426. m.addmode = nil
  4427. }
  4428. // SetConditions sets the "conditions" field.
  4429. func (m *LabelMutation) SetConditions(s string) {
  4430. m.conditions = &s
  4431. }
  4432. // Conditions returns the value of the "conditions" field in the mutation.
  4433. func (m *LabelMutation) Conditions() (r string, exists bool) {
  4434. v := m.conditions
  4435. if v == nil {
  4436. return
  4437. }
  4438. return *v, true
  4439. }
  4440. // OldConditions returns the old "conditions" field's value of the Label entity.
  4441. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  4442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4443. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  4444. if !m.op.Is(OpUpdateOne) {
  4445. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  4446. }
  4447. if m.id == nil || m.oldValue == nil {
  4448. return v, errors.New("OldConditions requires an ID field in the mutation")
  4449. }
  4450. oldValue, err := m.oldValue(ctx)
  4451. if err != nil {
  4452. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  4453. }
  4454. return oldValue.Conditions, nil
  4455. }
  4456. // ClearConditions clears the value of the "conditions" field.
  4457. func (m *LabelMutation) ClearConditions() {
  4458. m.conditions = nil
  4459. m.clearedFields[label.FieldConditions] = struct{}{}
  4460. }
  4461. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  4462. func (m *LabelMutation) ConditionsCleared() bool {
  4463. _, ok := m.clearedFields[label.FieldConditions]
  4464. return ok
  4465. }
  4466. // ResetConditions resets all changes to the "conditions" field.
  4467. func (m *LabelMutation) ResetConditions() {
  4468. m.conditions = nil
  4469. delete(m.clearedFields, label.FieldConditions)
  4470. }
  4471. // SetOrganizationID sets the "organization_id" field.
  4472. func (m *LabelMutation) SetOrganizationID(u uint64) {
  4473. m.organization_id = &u
  4474. m.addorganization_id = nil
  4475. }
  4476. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4477. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  4478. v := m.organization_id
  4479. if v == nil {
  4480. return
  4481. }
  4482. return *v, true
  4483. }
  4484. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  4485. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  4486. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4487. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4488. if !m.op.Is(OpUpdateOne) {
  4489. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4490. }
  4491. if m.id == nil || m.oldValue == nil {
  4492. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4493. }
  4494. oldValue, err := m.oldValue(ctx)
  4495. if err != nil {
  4496. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4497. }
  4498. return oldValue.OrganizationID, nil
  4499. }
  4500. // AddOrganizationID adds u to the "organization_id" field.
  4501. func (m *LabelMutation) AddOrganizationID(u int64) {
  4502. if m.addorganization_id != nil {
  4503. *m.addorganization_id += u
  4504. } else {
  4505. m.addorganization_id = &u
  4506. }
  4507. }
  4508. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4509. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  4510. v := m.addorganization_id
  4511. if v == nil {
  4512. return
  4513. }
  4514. return *v, true
  4515. }
  4516. // ClearOrganizationID clears the value of the "organization_id" field.
  4517. func (m *LabelMutation) ClearOrganizationID() {
  4518. m.organization_id = nil
  4519. m.addorganization_id = nil
  4520. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  4521. }
  4522. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  4523. func (m *LabelMutation) OrganizationIDCleared() bool {
  4524. _, ok := m.clearedFields[label.FieldOrganizationID]
  4525. return ok
  4526. }
  4527. // ResetOrganizationID resets all changes to the "organization_id" field.
  4528. func (m *LabelMutation) ResetOrganizationID() {
  4529. m.organization_id = nil
  4530. m.addorganization_id = nil
  4531. delete(m.clearedFields, label.FieldOrganizationID)
  4532. }
  4533. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  4534. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  4535. if m.label_relationships == nil {
  4536. m.label_relationships = make(map[uint64]struct{})
  4537. }
  4538. for i := range ids {
  4539. m.label_relationships[ids[i]] = struct{}{}
  4540. }
  4541. }
  4542. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  4543. func (m *LabelMutation) ClearLabelRelationships() {
  4544. m.clearedlabel_relationships = true
  4545. }
  4546. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  4547. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  4548. return m.clearedlabel_relationships
  4549. }
  4550. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  4551. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  4552. if m.removedlabel_relationships == nil {
  4553. m.removedlabel_relationships = make(map[uint64]struct{})
  4554. }
  4555. for i := range ids {
  4556. delete(m.label_relationships, ids[i])
  4557. m.removedlabel_relationships[ids[i]] = struct{}{}
  4558. }
  4559. }
  4560. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  4561. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  4562. for id := range m.removedlabel_relationships {
  4563. ids = append(ids, id)
  4564. }
  4565. return
  4566. }
  4567. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  4568. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  4569. for id := range m.label_relationships {
  4570. ids = append(ids, id)
  4571. }
  4572. return
  4573. }
  4574. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  4575. func (m *LabelMutation) ResetLabelRelationships() {
  4576. m.label_relationships = nil
  4577. m.clearedlabel_relationships = false
  4578. m.removedlabel_relationships = nil
  4579. }
  4580. // Where appends a list predicates to the LabelMutation builder.
  4581. func (m *LabelMutation) Where(ps ...predicate.Label) {
  4582. m.predicates = append(m.predicates, ps...)
  4583. }
  4584. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  4585. // users can use type-assertion to append predicates that do not depend on any generated package.
  4586. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  4587. p := make([]predicate.Label, len(ps))
  4588. for i := range ps {
  4589. p[i] = ps[i]
  4590. }
  4591. m.Where(p...)
  4592. }
  4593. // Op returns the operation name.
  4594. func (m *LabelMutation) Op() Op {
  4595. return m.op
  4596. }
  4597. // SetOp allows setting the mutation operation.
  4598. func (m *LabelMutation) SetOp(op Op) {
  4599. m.op = op
  4600. }
  4601. // Type returns the node type of this mutation (Label).
  4602. func (m *LabelMutation) Type() string {
  4603. return m.typ
  4604. }
  4605. // Fields returns all fields that were changed during this mutation. Note that in
  4606. // order to get all numeric fields that were incremented/decremented, call
  4607. // AddedFields().
  4608. func (m *LabelMutation) Fields() []string {
  4609. fields := make([]string, 0, 9)
  4610. if m.created_at != nil {
  4611. fields = append(fields, label.FieldCreatedAt)
  4612. }
  4613. if m.updated_at != nil {
  4614. fields = append(fields, label.FieldUpdatedAt)
  4615. }
  4616. if m.status != nil {
  4617. fields = append(fields, label.FieldStatus)
  4618. }
  4619. if m._type != nil {
  4620. fields = append(fields, label.FieldType)
  4621. }
  4622. if m.name != nil {
  4623. fields = append(fields, label.FieldName)
  4624. }
  4625. if m.from != nil {
  4626. fields = append(fields, label.FieldFrom)
  4627. }
  4628. if m.mode != nil {
  4629. fields = append(fields, label.FieldMode)
  4630. }
  4631. if m.conditions != nil {
  4632. fields = append(fields, label.FieldConditions)
  4633. }
  4634. if m.organization_id != nil {
  4635. fields = append(fields, label.FieldOrganizationID)
  4636. }
  4637. return fields
  4638. }
  4639. // Field returns the value of a field with the given name. The second boolean
  4640. // return value indicates that this field was not set, or was not defined in the
  4641. // schema.
  4642. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  4643. switch name {
  4644. case label.FieldCreatedAt:
  4645. return m.CreatedAt()
  4646. case label.FieldUpdatedAt:
  4647. return m.UpdatedAt()
  4648. case label.FieldStatus:
  4649. return m.Status()
  4650. case label.FieldType:
  4651. return m.GetType()
  4652. case label.FieldName:
  4653. return m.Name()
  4654. case label.FieldFrom:
  4655. return m.From()
  4656. case label.FieldMode:
  4657. return m.Mode()
  4658. case label.FieldConditions:
  4659. return m.Conditions()
  4660. case label.FieldOrganizationID:
  4661. return m.OrganizationID()
  4662. }
  4663. return nil, false
  4664. }
  4665. // OldField returns the old value of the field from the database. An error is
  4666. // returned if the mutation operation is not UpdateOne, or the query to the
  4667. // database failed.
  4668. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4669. switch name {
  4670. case label.FieldCreatedAt:
  4671. return m.OldCreatedAt(ctx)
  4672. case label.FieldUpdatedAt:
  4673. return m.OldUpdatedAt(ctx)
  4674. case label.FieldStatus:
  4675. return m.OldStatus(ctx)
  4676. case label.FieldType:
  4677. return m.OldType(ctx)
  4678. case label.FieldName:
  4679. return m.OldName(ctx)
  4680. case label.FieldFrom:
  4681. return m.OldFrom(ctx)
  4682. case label.FieldMode:
  4683. return m.OldMode(ctx)
  4684. case label.FieldConditions:
  4685. return m.OldConditions(ctx)
  4686. case label.FieldOrganizationID:
  4687. return m.OldOrganizationID(ctx)
  4688. }
  4689. return nil, fmt.Errorf("unknown Label field %s", name)
  4690. }
  4691. // SetField sets the value of a field with the given name. It returns an error if
  4692. // the field is not defined in the schema, or if the type mismatched the field
  4693. // type.
  4694. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  4695. switch name {
  4696. case label.FieldCreatedAt:
  4697. v, ok := value.(time.Time)
  4698. if !ok {
  4699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4700. }
  4701. m.SetCreatedAt(v)
  4702. return nil
  4703. case label.FieldUpdatedAt:
  4704. v, ok := value.(time.Time)
  4705. if !ok {
  4706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4707. }
  4708. m.SetUpdatedAt(v)
  4709. return nil
  4710. case label.FieldStatus:
  4711. v, ok := value.(uint8)
  4712. if !ok {
  4713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4714. }
  4715. m.SetStatus(v)
  4716. return nil
  4717. case label.FieldType:
  4718. v, ok := value.(int)
  4719. if !ok {
  4720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4721. }
  4722. m.SetType(v)
  4723. return nil
  4724. case label.FieldName:
  4725. v, ok := value.(string)
  4726. if !ok {
  4727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4728. }
  4729. m.SetName(v)
  4730. return nil
  4731. case label.FieldFrom:
  4732. v, ok := value.(int)
  4733. if !ok {
  4734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4735. }
  4736. m.SetFrom(v)
  4737. return nil
  4738. case label.FieldMode:
  4739. v, ok := value.(int)
  4740. if !ok {
  4741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4742. }
  4743. m.SetMode(v)
  4744. return nil
  4745. case label.FieldConditions:
  4746. v, ok := value.(string)
  4747. if !ok {
  4748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4749. }
  4750. m.SetConditions(v)
  4751. return nil
  4752. case label.FieldOrganizationID:
  4753. v, ok := value.(uint64)
  4754. if !ok {
  4755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4756. }
  4757. m.SetOrganizationID(v)
  4758. return nil
  4759. }
  4760. return fmt.Errorf("unknown Label field %s", name)
  4761. }
  4762. // AddedFields returns all numeric fields that were incremented/decremented during
  4763. // this mutation.
  4764. func (m *LabelMutation) AddedFields() []string {
  4765. var fields []string
  4766. if m.addstatus != nil {
  4767. fields = append(fields, label.FieldStatus)
  4768. }
  4769. if m.add_type != nil {
  4770. fields = append(fields, label.FieldType)
  4771. }
  4772. if m.addfrom != nil {
  4773. fields = append(fields, label.FieldFrom)
  4774. }
  4775. if m.addmode != nil {
  4776. fields = append(fields, label.FieldMode)
  4777. }
  4778. if m.addorganization_id != nil {
  4779. fields = append(fields, label.FieldOrganizationID)
  4780. }
  4781. return fields
  4782. }
  4783. // AddedField returns the numeric value that was incremented/decremented on a field
  4784. // with the given name. The second boolean return value indicates that this field
  4785. // was not set, or was not defined in the schema.
  4786. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  4787. switch name {
  4788. case label.FieldStatus:
  4789. return m.AddedStatus()
  4790. case label.FieldType:
  4791. return m.AddedType()
  4792. case label.FieldFrom:
  4793. return m.AddedFrom()
  4794. case label.FieldMode:
  4795. return m.AddedMode()
  4796. case label.FieldOrganizationID:
  4797. return m.AddedOrganizationID()
  4798. }
  4799. return nil, false
  4800. }
  4801. // AddField adds the value to the field with the given name. It returns an error if
  4802. // the field is not defined in the schema, or if the type mismatched the field
  4803. // type.
  4804. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  4805. switch name {
  4806. case label.FieldStatus:
  4807. v, ok := value.(int8)
  4808. if !ok {
  4809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4810. }
  4811. m.AddStatus(v)
  4812. return nil
  4813. case label.FieldType:
  4814. v, ok := value.(int)
  4815. if !ok {
  4816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4817. }
  4818. m.AddType(v)
  4819. return nil
  4820. case label.FieldFrom:
  4821. v, ok := value.(int)
  4822. if !ok {
  4823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4824. }
  4825. m.AddFrom(v)
  4826. return nil
  4827. case label.FieldMode:
  4828. v, ok := value.(int)
  4829. if !ok {
  4830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4831. }
  4832. m.AddMode(v)
  4833. return nil
  4834. case label.FieldOrganizationID:
  4835. v, ok := value.(int64)
  4836. if !ok {
  4837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4838. }
  4839. m.AddOrganizationID(v)
  4840. return nil
  4841. }
  4842. return fmt.Errorf("unknown Label numeric field %s", name)
  4843. }
  4844. // ClearedFields returns all nullable fields that were cleared during this
  4845. // mutation.
  4846. func (m *LabelMutation) ClearedFields() []string {
  4847. var fields []string
  4848. if m.FieldCleared(label.FieldStatus) {
  4849. fields = append(fields, label.FieldStatus)
  4850. }
  4851. if m.FieldCleared(label.FieldConditions) {
  4852. fields = append(fields, label.FieldConditions)
  4853. }
  4854. if m.FieldCleared(label.FieldOrganizationID) {
  4855. fields = append(fields, label.FieldOrganizationID)
  4856. }
  4857. return fields
  4858. }
  4859. // FieldCleared returns a boolean indicating if a field with the given name was
  4860. // cleared in this mutation.
  4861. func (m *LabelMutation) FieldCleared(name string) bool {
  4862. _, ok := m.clearedFields[name]
  4863. return ok
  4864. }
  4865. // ClearField clears the value of the field with the given name. It returns an
  4866. // error if the field is not defined in the schema.
  4867. func (m *LabelMutation) ClearField(name string) error {
  4868. switch name {
  4869. case label.FieldStatus:
  4870. m.ClearStatus()
  4871. return nil
  4872. case label.FieldConditions:
  4873. m.ClearConditions()
  4874. return nil
  4875. case label.FieldOrganizationID:
  4876. m.ClearOrganizationID()
  4877. return nil
  4878. }
  4879. return fmt.Errorf("unknown Label nullable field %s", name)
  4880. }
  4881. // ResetField resets all changes in the mutation for the field with the given name.
  4882. // It returns an error if the field is not defined in the schema.
  4883. func (m *LabelMutation) ResetField(name string) error {
  4884. switch name {
  4885. case label.FieldCreatedAt:
  4886. m.ResetCreatedAt()
  4887. return nil
  4888. case label.FieldUpdatedAt:
  4889. m.ResetUpdatedAt()
  4890. return nil
  4891. case label.FieldStatus:
  4892. m.ResetStatus()
  4893. return nil
  4894. case label.FieldType:
  4895. m.ResetType()
  4896. return nil
  4897. case label.FieldName:
  4898. m.ResetName()
  4899. return nil
  4900. case label.FieldFrom:
  4901. m.ResetFrom()
  4902. return nil
  4903. case label.FieldMode:
  4904. m.ResetMode()
  4905. return nil
  4906. case label.FieldConditions:
  4907. m.ResetConditions()
  4908. return nil
  4909. case label.FieldOrganizationID:
  4910. m.ResetOrganizationID()
  4911. return nil
  4912. }
  4913. return fmt.Errorf("unknown Label field %s", name)
  4914. }
  4915. // AddedEdges returns all edge names that were set/added in this mutation.
  4916. func (m *LabelMutation) AddedEdges() []string {
  4917. edges := make([]string, 0, 1)
  4918. if m.label_relationships != nil {
  4919. edges = append(edges, label.EdgeLabelRelationships)
  4920. }
  4921. return edges
  4922. }
  4923. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4924. // name in this mutation.
  4925. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  4926. switch name {
  4927. case label.EdgeLabelRelationships:
  4928. ids := make([]ent.Value, 0, len(m.label_relationships))
  4929. for id := range m.label_relationships {
  4930. ids = append(ids, id)
  4931. }
  4932. return ids
  4933. }
  4934. return nil
  4935. }
  4936. // RemovedEdges returns all edge names that were removed in this mutation.
  4937. func (m *LabelMutation) RemovedEdges() []string {
  4938. edges := make([]string, 0, 1)
  4939. if m.removedlabel_relationships != nil {
  4940. edges = append(edges, label.EdgeLabelRelationships)
  4941. }
  4942. return edges
  4943. }
  4944. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4945. // the given name in this mutation.
  4946. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  4947. switch name {
  4948. case label.EdgeLabelRelationships:
  4949. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  4950. for id := range m.removedlabel_relationships {
  4951. ids = append(ids, id)
  4952. }
  4953. return ids
  4954. }
  4955. return nil
  4956. }
  4957. // ClearedEdges returns all edge names that were cleared in this mutation.
  4958. func (m *LabelMutation) ClearedEdges() []string {
  4959. edges := make([]string, 0, 1)
  4960. if m.clearedlabel_relationships {
  4961. edges = append(edges, label.EdgeLabelRelationships)
  4962. }
  4963. return edges
  4964. }
  4965. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4966. // was cleared in this mutation.
  4967. func (m *LabelMutation) EdgeCleared(name string) bool {
  4968. switch name {
  4969. case label.EdgeLabelRelationships:
  4970. return m.clearedlabel_relationships
  4971. }
  4972. return false
  4973. }
  4974. // ClearEdge clears the value of the edge with the given name. It returns an error
  4975. // if that edge is not defined in the schema.
  4976. func (m *LabelMutation) ClearEdge(name string) error {
  4977. switch name {
  4978. }
  4979. return fmt.Errorf("unknown Label unique edge %s", name)
  4980. }
  4981. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4982. // It returns an error if the edge is not defined in the schema.
  4983. func (m *LabelMutation) ResetEdge(name string) error {
  4984. switch name {
  4985. case label.EdgeLabelRelationships:
  4986. m.ResetLabelRelationships()
  4987. return nil
  4988. }
  4989. return fmt.Errorf("unknown Label edge %s", name)
  4990. }
  4991. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  4992. type LabelRelationshipMutation struct {
  4993. config
  4994. op Op
  4995. typ string
  4996. id *uint64
  4997. created_at *time.Time
  4998. updated_at *time.Time
  4999. status *uint8
  5000. addstatus *int8
  5001. deleted_at *time.Time
  5002. organization_id *uint64
  5003. addorganization_id *int64
  5004. clearedFields map[string]struct{}
  5005. contacts *uint64
  5006. clearedcontacts bool
  5007. labels *uint64
  5008. clearedlabels bool
  5009. done bool
  5010. oldValue func(context.Context) (*LabelRelationship, error)
  5011. predicates []predicate.LabelRelationship
  5012. }
  5013. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  5014. // labelrelationshipOption allows management of the mutation configuration using functional options.
  5015. type labelrelationshipOption func(*LabelRelationshipMutation)
  5016. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  5017. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  5018. m := &LabelRelationshipMutation{
  5019. config: c,
  5020. op: op,
  5021. typ: TypeLabelRelationship,
  5022. clearedFields: make(map[string]struct{}),
  5023. }
  5024. for _, opt := range opts {
  5025. opt(m)
  5026. }
  5027. return m
  5028. }
  5029. // withLabelRelationshipID sets the ID field of the mutation.
  5030. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  5031. return func(m *LabelRelationshipMutation) {
  5032. var (
  5033. err error
  5034. once sync.Once
  5035. value *LabelRelationship
  5036. )
  5037. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  5038. once.Do(func() {
  5039. if m.done {
  5040. err = errors.New("querying old values post mutation is not allowed")
  5041. } else {
  5042. value, err = m.Client().LabelRelationship.Get(ctx, id)
  5043. }
  5044. })
  5045. return value, err
  5046. }
  5047. m.id = &id
  5048. }
  5049. }
  5050. // withLabelRelationship sets the old LabelRelationship of the mutation.
  5051. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  5052. return func(m *LabelRelationshipMutation) {
  5053. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  5054. return node, nil
  5055. }
  5056. m.id = &node.ID
  5057. }
  5058. }
  5059. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5060. // executed in a transaction (ent.Tx), a transactional client is returned.
  5061. func (m LabelRelationshipMutation) Client() *Client {
  5062. client := &Client{config: m.config}
  5063. client.init()
  5064. return client
  5065. }
  5066. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5067. // it returns an error otherwise.
  5068. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  5069. if _, ok := m.driver.(*txDriver); !ok {
  5070. return nil, errors.New("ent: mutation is not running in a transaction")
  5071. }
  5072. tx := &Tx{config: m.config}
  5073. tx.init()
  5074. return tx, nil
  5075. }
  5076. // SetID sets the value of the id field. Note that this
  5077. // operation is only accepted on creation of LabelRelationship entities.
  5078. func (m *LabelRelationshipMutation) SetID(id uint64) {
  5079. m.id = &id
  5080. }
  5081. // ID returns the ID value in the mutation. Note that the ID is only available
  5082. // if it was provided to the builder or after it was returned from the database.
  5083. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  5084. if m.id == nil {
  5085. return
  5086. }
  5087. return *m.id, true
  5088. }
  5089. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5090. // That means, if the mutation is applied within a transaction with an isolation level such
  5091. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5092. // or updated by the mutation.
  5093. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  5094. switch {
  5095. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5096. id, exists := m.ID()
  5097. if exists {
  5098. return []uint64{id}, nil
  5099. }
  5100. fallthrough
  5101. case m.op.Is(OpUpdate | OpDelete):
  5102. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  5103. default:
  5104. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5105. }
  5106. }
  5107. // SetCreatedAt sets the "created_at" field.
  5108. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  5109. m.created_at = &t
  5110. }
  5111. // CreatedAt returns the value of the "created_at" field in the mutation.
  5112. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  5113. v := m.created_at
  5114. if v == nil {
  5115. return
  5116. }
  5117. return *v, true
  5118. }
  5119. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  5120. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  5121. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5122. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5123. if !m.op.Is(OpUpdateOne) {
  5124. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5125. }
  5126. if m.id == nil || m.oldValue == nil {
  5127. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5128. }
  5129. oldValue, err := m.oldValue(ctx)
  5130. if err != nil {
  5131. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5132. }
  5133. return oldValue.CreatedAt, nil
  5134. }
  5135. // ResetCreatedAt resets all changes to the "created_at" field.
  5136. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  5137. m.created_at = nil
  5138. }
  5139. // SetUpdatedAt sets the "updated_at" field.
  5140. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  5141. m.updated_at = &t
  5142. }
  5143. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5144. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  5145. v := m.updated_at
  5146. if v == nil {
  5147. return
  5148. }
  5149. return *v, true
  5150. }
  5151. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  5152. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  5153. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5154. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5155. if !m.op.Is(OpUpdateOne) {
  5156. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5157. }
  5158. if m.id == nil || m.oldValue == nil {
  5159. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5160. }
  5161. oldValue, err := m.oldValue(ctx)
  5162. if err != nil {
  5163. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5164. }
  5165. return oldValue.UpdatedAt, nil
  5166. }
  5167. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5168. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  5169. m.updated_at = nil
  5170. }
  5171. // SetStatus sets the "status" field.
  5172. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  5173. m.status = &u
  5174. m.addstatus = nil
  5175. }
  5176. // Status returns the value of the "status" field in the mutation.
  5177. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  5178. v := m.status
  5179. if v == nil {
  5180. return
  5181. }
  5182. return *v, true
  5183. }
  5184. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  5185. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  5186. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5187. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  5188. if !m.op.Is(OpUpdateOne) {
  5189. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5190. }
  5191. if m.id == nil || m.oldValue == nil {
  5192. return v, errors.New("OldStatus requires an ID field in the mutation")
  5193. }
  5194. oldValue, err := m.oldValue(ctx)
  5195. if err != nil {
  5196. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5197. }
  5198. return oldValue.Status, nil
  5199. }
  5200. // AddStatus adds u to the "status" field.
  5201. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  5202. if m.addstatus != nil {
  5203. *m.addstatus += u
  5204. } else {
  5205. m.addstatus = &u
  5206. }
  5207. }
  5208. // AddedStatus returns the value that was added to the "status" field in this mutation.
  5209. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  5210. v := m.addstatus
  5211. if v == nil {
  5212. return
  5213. }
  5214. return *v, true
  5215. }
  5216. // ClearStatus clears the value of the "status" field.
  5217. func (m *LabelRelationshipMutation) ClearStatus() {
  5218. m.status = nil
  5219. m.addstatus = nil
  5220. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  5221. }
  5222. // StatusCleared returns if the "status" field was cleared in this mutation.
  5223. func (m *LabelRelationshipMutation) StatusCleared() bool {
  5224. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  5225. return ok
  5226. }
  5227. // ResetStatus resets all changes to the "status" field.
  5228. func (m *LabelRelationshipMutation) ResetStatus() {
  5229. m.status = nil
  5230. m.addstatus = nil
  5231. delete(m.clearedFields, labelrelationship.FieldStatus)
  5232. }
  5233. // SetDeletedAt sets the "deleted_at" field.
  5234. func (m *LabelRelationshipMutation) SetDeletedAt(t time.Time) {
  5235. m.deleted_at = &t
  5236. }
  5237. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5238. func (m *LabelRelationshipMutation) DeletedAt() (r time.Time, exists bool) {
  5239. v := m.deleted_at
  5240. if v == nil {
  5241. return
  5242. }
  5243. return *v, true
  5244. }
  5245. // OldDeletedAt returns the old "deleted_at" field's value of the LabelRelationship entity.
  5246. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  5247. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5248. func (m *LabelRelationshipMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5249. if !m.op.Is(OpUpdateOne) {
  5250. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5251. }
  5252. if m.id == nil || m.oldValue == nil {
  5253. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5254. }
  5255. oldValue, err := m.oldValue(ctx)
  5256. if err != nil {
  5257. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5258. }
  5259. return oldValue.DeletedAt, nil
  5260. }
  5261. // ClearDeletedAt clears the value of the "deleted_at" field.
  5262. func (m *LabelRelationshipMutation) ClearDeletedAt() {
  5263. m.deleted_at = nil
  5264. m.clearedFields[labelrelationship.FieldDeletedAt] = struct{}{}
  5265. }
  5266. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5267. func (m *LabelRelationshipMutation) DeletedAtCleared() bool {
  5268. _, ok := m.clearedFields[labelrelationship.FieldDeletedAt]
  5269. return ok
  5270. }
  5271. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5272. func (m *LabelRelationshipMutation) ResetDeletedAt() {
  5273. m.deleted_at = nil
  5274. delete(m.clearedFields, labelrelationship.FieldDeletedAt)
  5275. }
  5276. // SetLabelID sets the "label_id" field.
  5277. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  5278. m.labels = &u
  5279. }
  5280. // LabelID returns the value of the "label_id" field in the mutation.
  5281. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  5282. v := m.labels
  5283. if v == nil {
  5284. return
  5285. }
  5286. return *v, true
  5287. }
  5288. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  5289. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  5290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5291. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  5292. if !m.op.Is(OpUpdateOne) {
  5293. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  5294. }
  5295. if m.id == nil || m.oldValue == nil {
  5296. return v, errors.New("OldLabelID requires an ID field in the mutation")
  5297. }
  5298. oldValue, err := m.oldValue(ctx)
  5299. if err != nil {
  5300. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  5301. }
  5302. return oldValue.LabelID, nil
  5303. }
  5304. // ResetLabelID resets all changes to the "label_id" field.
  5305. func (m *LabelRelationshipMutation) ResetLabelID() {
  5306. m.labels = nil
  5307. }
  5308. // SetContactID sets the "contact_id" field.
  5309. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  5310. m.contacts = &u
  5311. }
  5312. // ContactID returns the value of the "contact_id" field in the mutation.
  5313. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  5314. v := m.contacts
  5315. if v == nil {
  5316. return
  5317. }
  5318. return *v, true
  5319. }
  5320. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  5321. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  5322. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5323. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  5324. if !m.op.Is(OpUpdateOne) {
  5325. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  5326. }
  5327. if m.id == nil || m.oldValue == nil {
  5328. return v, errors.New("OldContactID requires an ID field in the mutation")
  5329. }
  5330. oldValue, err := m.oldValue(ctx)
  5331. if err != nil {
  5332. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  5333. }
  5334. return oldValue.ContactID, nil
  5335. }
  5336. // ResetContactID resets all changes to the "contact_id" field.
  5337. func (m *LabelRelationshipMutation) ResetContactID() {
  5338. m.contacts = nil
  5339. }
  5340. // SetOrganizationID sets the "organization_id" field.
  5341. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  5342. m.organization_id = &u
  5343. m.addorganization_id = nil
  5344. }
  5345. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5346. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  5347. v := m.organization_id
  5348. if v == nil {
  5349. return
  5350. }
  5351. return *v, true
  5352. }
  5353. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  5354. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  5355. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5356. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5357. if !m.op.Is(OpUpdateOne) {
  5358. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5359. }
  5360. if m.id == nil || m.oldValue == nil {
  5361. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5362. }
  5363. oldValue, err := m.oldValue(ctx)
  5364. if err != nil {
  5365. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  5366. }
  5367. return oldValue.OrganizationID, nil
  5368. }
  5369. // AddOrganizationID adds u to the "organization_id" field.
  5370. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  5371. if m.addorganization_id != nil {
  5372. *m.addorganization_id += u
  5373. } else {
  5374. m.addorganization_id = &u
  5375. }
  5376. }
  5377. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5378. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  5379. v := m.addorganization_id
  5380. if v == nil {
  5381. return
  5382. }
  5383. return *v, true
  5384. }
  5385. // ClearOrganizationID clears the value of the "organization_id" field.
  5386. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  5387. m.organization_id = nil
  5388. m.addorganization_id = nil
  5389. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  5390. }
  5391. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  5392. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  5393. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  5394. return ok
  5395. }
  5396. // ResetOrganizationID resets all changes to the "organization_id" field.
  5397. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  5398. m.organization_id = nil
  5399. m.addorganization_id = nil
  5400. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  5401. }
  5402. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  5403. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  5404. m.contacts = &id
  5405. }
  5406. // ClearContacts clears the "contacts" edge to the Contact entity.
  5407. func (m *LabelRelationshipMutation) ClearContacts() {
  5408. m.clearedcontacts = true
  5409. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  5410. }
  5411. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  5412. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  5413. return m.clearedcontacts
  5414. }
  5415. // ContactsID returns the "contacts" edge ID in the mutation.
  5416. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  5417. if m.contacts != nil {
  5418. return *m.contacts, true
  5419. }
  5420. return
  5421. }
  5422. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  5423. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  5424. // ContactsID instead. It exists only for internal usage by the builders.
  5425. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  5426. if id := m.contacts; id != nil {
  5427. ids = append(ids, *id)
  5428. }
  5429. return
  5430. }
  5431. // ResetContacts resets all changes to the "contacts" edge.
  5432. func (m *LabelRelationshipMutation) ResetContacts() {
  5433. m.contacts = nil
  5434. m.clearedcontacts = false
  5435. }
  5436. // SetLabelsID sets the "labels" edge to the Label entity by id.
  5437. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  5438. m.labels = &id
  5439. }
  5440. // ClearLabels clears the "labels" edge to the Label entity.
  5441. func (m *LabelRelationshipMutation) ClearLabels() {
  5442. m.clearedlabels = true
  5443. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  5444. }
  5445. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  5446. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  5447. return m.clearedlabels
  5448. }
  5449. // LabelsID returns the "labels" edge ID in the mutation.
  5450. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  5451. if m.labels != nil {
  5452. return *m.labels, true
  5453. }
  5454. return
  5455. }
  5456. // LabelsIDs returns the "labels" edge IDs in the mutation.
  5457. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  5458. // LabelsID instead. It exists only for internal usage by the builders.
  5459. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  5460. if id := m.labels; id != nil {
  5461. ids = append(ids, *id)
  5462. }
  5463. return
  5464. }
  5465. // ResetLabels resets all changes to the "labels" edge.
  5466. func (m *LabelRelationshipMutation) ResetLabels() {
  5467. m.labels = nil
  5468. m.clearedlabels = false
  5469. }
  5470. // Where appends a list predicates to the LabelRelationshipMutation builder.
  5471. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  5472. m.predicates = append(m.predicates, ps...)
  5473. }
  5474. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  5475. // users can use type-assertion to append predicates that do not depend on any generated package.
  5476. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  5477. p := make([]predicate.LabelRelationship, len(ps))
  5478. for i := range ps {
  5479. p[i] = ps[i]
  5480. }
  5481. m.Where(p...)
  5482. }
  5483. // Op returns the operation name.
  5484. func (m *LabelRelationshipMutation) Op() Op {
  5485. return m.op
  5486. }
  5487. // SetOp allows setting the mutation operation.
  5488. func (m *LabelRelationshipMutation) SetOp(op Op) {
  5489. m.op = op
  5490. }
  5491. // Type returns the node type of this mutation (LabelRelationship).
  5492. func (m *LabelRelationshipMutation) Type() string {
  5493. return m.typ
  5494. }
  5495. // Fields returns all fields that were changed during this mutation. Note that in
  5496. // order to get all numeric fields that were incremented/decremented, call
  5497. // AddedFields().
  5498. func (m *LabelRelationshipMutation) Fields() []string {
  5499. fields := make([]string, 0, 7)
  5500. if m.created_at != nil {
  5501. fields = append(fields, labelrelationship.FieldCreatedAt)
  5502. }
  5503. if m.updated_at != nil {
  5504. fields = append(fields, labelrelationship.FieldUpdatedAt)
  5505. }
  5506. if m.status != nil {
  5507. fields = append(fields, labelrelationship.FieldStatus)
  5508. }
  5509. if m.deleted_at != nil {
  5510. fields = append(fields, labelrelationship.FieldDeletedAt)
  5511. }
  5512. if m.labels != nil {
  5513. fields = append(fields, labelrelationship.FieldLabelID)
  5514. }
  5515. if m.contacts != nil {
  5516. fields = append(fields, labelrelationship.FieldContactID)
  5517. }
  5518. if m.organization_id != nil {
  5519. fields = append(fields, labelrelationship.FieldOrganizationID)
  5520. }
  5521. return fields
  5522. }
  5523. // Field returns the value of a field with the given name. The second boolean
  5524. // return value indicates that this field was not set, or was not defined in the
  5525. // schema.
  5526. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  5527. switch name {
  5528. case labelrelationship.FieldCreatedAt:
  5529. return m.CreatedAt()
  5530. case labelrelationship.FieldUpdatedAt:
  5531. return m.UpdatedAt()
  5532. case labelrelationship.FieldStatus:
  5533. return m.Status()
  5534. case labelrelationship.FieldDeletedAt:
  5535. return m.DeletedAt()
  5536. case labelrelationship.FieldLabelID:
  5537. return m.LabelID()
  5538. case labelrelationship.FieldContactID:
  5539. return m.ContactID()
  5540. case labelrelationship.FieldOrganizationID:
  5541. return m.OrganizationID()
  5542. }
  5543. return nil, false
  5544. }
  5545. // OldField returns the old value of the field from the database. An error is
  5546. // returned if the mutation operation is not UpdateOne, or the query to the
  5547. // database failed.
  5548. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5549. switch name {
  5550. case labelrelationship.FieldCreatedAt:
  5551. return m.OldCreatedAt(ctx)
  5552. case labelrelationship.FieldUpdatedAt:
  5553. return m.OldUpdatedAt(ctx)
  5554. case labelrelationship.FieldStatus:
  5555. return m.OldStatus(ctx)
  5556. case labelrelationship.FieldDeletedAt:
  5557. return m.OldDeletedAt(ctx)
  5558. case labelrelationship.FieldLabelID:
  5559. return m.OldLabelID(ctx)
  5560. case labelrelationship.FieldContactID:
  5561. return m.OldContactID(ctx)
  5562. case labelrelationship.FieldOrganizationID:
  5563. return m.OldOrganizationID(ctx)
  5564. }
  5565. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  5566. }
  5567. // SetField sets the value of a field with the given name. It returns an error if
  5568. // the field is not defined in the schema, or if the type mismatched the field
  5569. // type.
  5570. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  5571. switch name {
  5572. case labelrelationship.FieldCreatedAt:
  5573. v, ok := value.(time.Time)
  5574. if !ok {
  5575. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5576. }
  5577. m.SetCreatedAt(v)
  5578. return nil
  5579. case labelrelationship.FieldUpdatedAt:
  5580. v, ok := value.(time.Time)
  5581. if !ok {
  5582. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5583. }
  5584. m.SetUpdatedAt(v)
  5585. return nil
  5586. case labelrelationship.FieldStatus:
  5587. v, ok := value.(uint8)
  5588. if !ok {
  5589. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5590. }
  5591. m.SetStatus(v)
  5592. return nil
  5593. case labelrelationship.FieldDeletedAt:
  5594. v, ok := value.(time.Time)
  5595. if !ok {
  5596. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5597. }
  5598. m.SetDeletedAt(v)
  5599. return nil
  5600. case labelrelationship.FieldLabelID:
  5601. v, ok := value.(uint64)
  5602. if !ok {
  5603. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5604. }
  5605. m.SetLabelID(v)
  5606. return nil
  5607. case labelrelationship.FieldContactID:
  5608. v, ok := value.(uint64)
  5609. if !ok {
  5610. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5611. }
  5612. m.SetContactID(v)
  5613. return nil
  5614. case labelrelationship.FieldOrganizationID:
  5615. v, ok := value.(uint64)
  5616. if !ok {
  5617. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5618. }
  5619. m.SetOrganizationID(v)
  5620. return nil
  5621. }
  5622. return fmt.Errorf("unknown LabelRelationship field %s", name)
  5623. }
  5624. // AddedFields returns all numeric fields that were incremented/decremented during
  5625. // this mutation.
  5626. func (m *LabelRelationshipMutation) AddedFields() []string {
  5627. var fields []string
  5628. if m.addstatus != nil {
  5629. fields = append(fields, labelrelationship.FieldStatus)
  5630. }
  5631. if m.addorganization_id != nil {
  5632. fields = append(fields, labelrelationship.FieldOrganizationID)
  5633. }
  5634. return fields
  5635. }
  5636. // AddedField returns the numeric value that was incremented/decremented on a field
  5637. // with the given name. The second boolean return value indicates that this field
  5638. // was not set, or was not defined in the schema.
  5639. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  5640. switch name {
  5641. case labelrelationship.FieldStatus:
  5642. return m.AddedStatus()
  5643. case labelrelationship.FieldOrganizationID:
  5644. return m.AddedOrganizationID()
  5645. }
  5646. return nil, false
  5647. }
  5648. // AddField adds the value to the field with the given name. It returns an error if
  5649. // the field is not defined in the schema, or if the type mismatched the field
  5650. // type.
  5651. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  5652. switch name {
  5653. case labelrelationship.FieldStatus:
  5654. v, ok := value.(int8)
  5655. if !ok {
  5656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5657. }
  5658. m.AddStatus(v)
  5659. return nil
  5660. case labelrelationship.FieldOrganizationID:
  5661. v, ok := value.(int64)
  5662. if !ok {
  5663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5664. }
  5665. m.AddOrganizationID(v)
  5666. return nil
  5667. }
  5668. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  5669. }
  5670. // ClearedFields returns all nullable fields that were cleared during this
  5671. // mutation.
  5672. func (m *LabelRelationshipMutation) ClearedFields() []string {
  5673. var fields []string
  5674. if m.FieldCleared(labelrelationship.FieldStatus) {
  5675. fields = append(fields, labelrelationship.FieldStatus)
  5676. }
  5677. if m.FieldCleared(labelrelationship.FieldDeletedAt) {
  5678. fields = append(fields, labelrelationship.FieldDeletedAt)
  5679. }
  5680. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  5681. fields = append(fields, labelrelationship.FieldOrganizationID)
  5682. }
  5683. return fields
  5684. }
  5685. // FieldCleared returns a boolean indicating if a field with the given name was
  5686. // cleared in this mutation.
  5687. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  5688. _, ok := m.clearedFields[name]
  5689. return ok
  5690. }
  5691. // ClearField clears the value of the field with the given name. It returns an
  5692. // error if the field is not defined in the schema.
  5693. func (m *LabelRelationshipMutation) ClearField(name string) error {
  5694. switch name {
  5695. case labelrelationship.FieldStatus:
  5696. m.ClearStatus()
  5697. return nil
  5698. case labelrelationship.FieldDeletedAt:
  5699. m.ClearDeletedAt()
  5700. return nil
  5701. case labelrelationship.FieldOrganizationID:
  5702. m.ClearOrganizationID()
  5703. return nil
  5704. }
  5705. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  5706. }
  5707. // ResetField resets all changes in the mutation for the field with the given name.
  5708. // It returns an error if the field is not defined in the schema.
  5709. func (m *LabelRelationshipMutation) ResetField(name string) error {
  5710. switch name {
  5711. case labelrelationship.FieldCreatedAt:
  5712. m.ResetCreatedAt()
  5713. return nil
  5714. case labelrelationship.FieldUpdatedAt:
  5715. m.ResetUpdatedAt()
  5716. return nil
  5717. case labelrelationship.FieldStatus:
  5718. m.ResetStatus()
  5719. return nil
  5720. case labelrelationship.FieldDeletedAt:
  5721. m.ResetDeletedAt()
  5722. return nil
  5723. case labelrelationship.FieldLabelID:
  5724. m.ResetLabelID()
  5725. return nil
  5726. case labelrelationship.FieldContactID:
  5727. m.ResetContactID()
  5728. return nil
  5729. case labelrelationship.FieldOrganizationID:
  5730. m.ResetOrganizationID()
  5731. return nil
  5732. }
  5733. return fmt.Errorf("unknown LabelRelationship field %s", name)
  5734. }
  5735. // AddedEdges returns all edge names that were set/added in this mutation.
  5736. func (m *LabelRelationshipMutation) AddedEdges() []string {
  5737. edges := make([]string, 0, 2)
  5738. if m.contacts != nil {
  5739. edges = append(edges, labelrelationship.EdgeContacts)
  5740. }
  5741. if m.labels != nil {
  5742. edges = append(edges, labelrelationship.EdgeLabels)
  5743. }
  5744. return edges
  5745. }
  5746. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5747. // name in this mutation.
  5748. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  5749. switch name {
  5750. case labelrelationship.EdgeContacts:
  5751. if id := m.contacts; id != nil {
  5752. return []ent.Value{*id}
  5753. }
  5754. case labelrelationship.EdgeLabels:
  5755. if id := m.labels; id != nil {
  5756. return []ent.Value{*id}
  5757. }
  5758. }
  5759. return nil
  5760. }
  5761. // RemovedEdges returns all edge names that were removed in this mutation.
  5762. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  5763. edges := make([]string, 0, 2)
  5764. return edges
  5765. }
  5766. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5767. // the given name in this mutation.
  5768. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  5769. return nil
  5770. }
  5771. // ClearedEdges returns all edge names that were cleared in this mutation.
  5772. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  5773. edges := make([]string, 0, 2)
  5774. if m.clearedcontacts {
  5775. edges = append(edges, labelrelationship.EdgeContacts)
  5776. }
  5777. if m.clearedlabels {
  5778. edges = append(edges, labelrelationship.EdgeLabels)
  5779. }
  5780. return edges
  5781. }
  5782. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5783. // was cleared in this mutation.
  5784. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  5785. switch name {
  5786. case labelrelationship.EdgeContacts:
  5787. return m.clearedcontacts
  5788. case labelrelationship.EdgeLabels:
  5789. return m.clearedlabels
  5790. }
  5791. return false
  5792. }
  5793. // ClearEdge clears the value of the edge with the given name. It returns an error
  5794. // if that edge is not defined in the schema.
  5795. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  5796. switch name {
  5797. case labelrelationship.EdgeContacts:
  5798. m.ClearContacts()
  5799. return nil
  5800. case labelrelationship.EdgeLabels:
  5801. m.ClearLabels()
  5802. return nil
  5803. }
  5804. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  5805. }
  5806. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5807. // It returns an error if the edge is not defined in the schema.
  5808. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  5809. switch name {
  5810. case labelrelationship.EdgeContacts:
  5811. m.ResetContacts()
  5812. return nil
  5813. case labelrelationship.EdgeLabels:
  5814. m.ResetLabels()
  5815. return nil
  5816. }
  5817. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  5818. }
  5819. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  5820. type MessageMutation struct {
  5821. config
  5822. op Op
  5823. typ string
  5824. id *int
  5825. wx_wxid *string
  5826. wxid *string
  5827. content *string
  5828. clearedFields map[string]struct{}
  5829. done bool
  5830. oldValue func(context.Context) (*Message, error)
  5831. predicates []predicate.Message
  5832. }
  5833. var _ ent.Mutation = (*MessageMutation)(nil)
  5834. // messageOption allows management of the mutation configuration using functional options.
  5835. type messageOption func(*MessageMutation)
  5836. // newMessageMutation creates new mutation for the Message entity.
  5837. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  5838. m := &MessageMutation{
  5839. config: c,
  5840. op: op,
  5841. typ: TypeMessage,
  5842. clearedFields: make(map[string]struct{}),
  5843. }
  5844. for _, opt := range opts {
  5845. opt(m)
  5846. }
  5847. return m
  5848. }
  5849. // withMessageID sets the ID field of the mutation.
  5850. func withMessageID(id int) messageOption {
  5851. return func(m *MessageMutation) {
  5852. var (
  5853. err error
  5854. once sync.Once
  5855. value *Message
  5856. )
  5857. m.oldValue = func(ctx context.Context) (*Message, error) {
  5858. once.Do(func() {
  5859. if m.done {
  5860. err = errors.New("querying old values post mutation is not allowed")
  5861. } else {
  5862. value, err = m.Client().Message.Get(ctx, id)
  5863. }
  5864. })
  5865. return value, err
  5866. }
  5867. m.id = &id
  5868. }
  5869. }
  5870. // withMessage sets the old Message of the mutation.
  5871. func withMessage(node *Message) messageOption {
  5872. return func(m *MessageMutation) {
  5873. m.oldValue = func(context.Context) (*Message, error) {
  5874. return node, nil
  5875. }
  5876. m.id = &node.ID
  5877. }
  5878. }
  5879. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5880. // executed in a transaction (ent.Tx), a transactional client is returned.
  5881. func (m MessageMutation) Client() *Client {
  5882. client := &Client{config: m.config}
  5883. client.init()
  5884. return client
  5885. }
  5886. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5887. // it returns an error otherwise.
  5888. func (m MessageMutation) Tx() (*Tx, error) {
  5889. if _, ok := m.driver.(*txDriver); !ok {
  5890. return nil, errors.New("ent: mutation is not running in a transaction")
  5891. }
  5892. tx := &Tx{config: m.config}
  5893. tx.init()
  5894. return tx, nil
  5895. }
  5896. // ID returns the ID value in the mutation. Note that the ID is only available
  5897. // if it was provided to the builder or after it was returned from the database.
  5898. func (m *MessageMutation) ID() (id int, exists bool) {
  5899. if m.id == nil {
  5900. return
  5901. }
  5902. return *m.id, true
  5903. }
  5904. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5905. // That means, if the mutation is applied within a transaction with an isolation level such
  5906. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5907. // or updated by the mutation.
  5908. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  5909. switch {
  5910. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5911. id, exists := m.ID()
  5912. if exists {
  5913. return []int{id}, nil
  5914. }
  5915. fallthrough
  5916. case m.op.Is(OpUpdate | OpDelete):
  5917. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  5918. default:
  5919. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5920. }
  5921. }
  5922. // SetWxWxid sets the "wx_wxid" field.
  5923. func (m *MessageMutation) SetWxWxid(s string) {
  5924. m.wx_wxid = &s
  5925. }
  5926. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  5927. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  5928. v := m.wx_wxid
  5929. if v == nil {
  5930. return
  5931. }
  5932. return *v, true
  5933. }
  5934. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  5935. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  5936. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5937. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  5938. if !m.op.Is(OpUpdateOne) {
  5939. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  5940. }
  5941. if m.id == nil || m.oldValue == nil {
  5942. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  5943. }
  5944. oldValue, err := m.oldValue(ctx)
  5945. if err != nil {
  5946. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  5947. }
  5948. return oldValue.WxWxid, nil
  5949. }
  5950. // ClearWxWxid clears the value of the "wx_wxid" field.
  5951. func (m *MessageMutation) ClearWxWxid() {
  5952. m.wx_wxid = nil
  5953. m.clearedFields[message.FieldWxWxid] = struct{}{}
  5954. }
  5955. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  5956. func (m *MessageMutation) WxWxidCleared() bool {
  5957. _, ok := m.clearedFields[message.FieldWxWxid]
  5958. return ok
  5959. }
  5960. // ResetWxWxid resets all changes to the "wx_wxid" field.
  5961. func (m *MessageMutation) ResetWxWxid() {
  5962. m.wx_wxid = nil
  5963. delete(m.clearedFields, message.FieldWxWxid)
  5964. }
  5965. // SetWxid sets the "wxid" field.
  5966. func (m *MessageMutation) SetWxid(s string) {
  5967. m.wxid = &s
  5968. }
  5969. // Wxid returns the value of the "wxid" field in the mutation.
  5970. func (m *MessageMutation) Wxid() (r string, exists bool) {
  5971. v := m.wxid
  5972. if v == nil {
  5973. return
  5974. }
  5975. return *v, true
  5976. }
  5977. // OldWxid returns the old "wxid" field's value of the Message entity.
  5978. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  5979. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5980. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  5981. if !m.op.Is(OpUpdateOne) {
  5982. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  5983. }
  5984. if m.id == nil || m.oldValue == nil {
  5985. return v, errors.New("OldWxid requires an ID field in the mutation")
  5986. }
  5987. oldValue, err := m.oldValue(ctx)
  5988. if err != nil {
  5989. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  5990. }
  5991. return oldValue.Wxid, nil
  5992. }
  5993. // ResetWxid resets all changes to the "wxid" field.
  5994. func (m *MessageMutation) ResetWxid() {
  5995. m.wxid = nil
  5996. }
  5997. // SetContent sets the "content" field.
  5998. func (m *MessageMutation) SetContent(s string) {
  5999. m.content = &s
  6000. }
  6001. // Content returns the value of the "content" field in the mutation.
  6002. func (m *MessageMutation) Content() (r string, exists bool) {
  6003. v := m.content
  6004. if v == nil {
  6005. return
  6006. }
  6007. return *v, true
  6008. }
  6009. // OldContent returns the old "content" field's value of the Message entity.
  6010. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  6011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6012. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  6013. if !m.op.Is(OpUpdateOne) {
  6014. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  6015. }
  6016. if m.id == nil || m.oldValue == nil {
  6017. return v, errors.New("OldContent requires an ID field in the mutation")
  6018. }
  6019. oldValue, err := m.oldValue(ctx)
  6020. if err != nil {
  6021. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  6022. }
  6023. return oldValue.Content, nil
  6024. }
  6025. // ResetContent resets all changes to the "content" field.
  6026. func (m *MessageMutation) ResetContent() {
  6027. m.content = nil
  6028. }
  6029. // Where appends a list predicates to the MessageMutation builder.
  6030. func (m *MessageMutation) Where(ps ...predicate.Message) {
  6031. m.predicates = append(m.predicates, ps...)
  6032. }
  6033. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  6034. // users can use type-assertion to append predicates that do not depend on any generated package.
  6035. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  6036. p := make([]predicate.Message, len(ps))
  6037. for i := range ps {
  6038. p[i] = ps[i]
  6039. }
  6040. m.Where(p...)
  6041. }
  6042. // Op returns the operation name.
  6043. func (m *MessageMutation) Op() Op {
  6044. return m.op
  6045. }
  6046. // SetOp allows setting the mutation operation.
  6047. func (m *MessageMutation) SetOp(op Op) {
  6048. m.op = op
  6049. }
  6050. // Type returns the node type of this mutation (Message).
  6051. func (m *MessageMutation) Type() string {
  6052. return m.typ
  6053. }
  6054. // Fields returns all fields that were changed during this mutation. Note that in
  6055. // order to get all numeric fields that were incremented/decremented, call
  6056. // AddedFields().
  6057. func (m *MessageMutation) Fields() []string {
  6058. fields := make([]string, 0, 3)
  6059. if m.wx_wxid != nil {
  6060. fields = append(fields, message.FieldWxWxid)
  6061. }
  6062. if m.wxid != nil {
  6063. fields = append(fields, message.FieldWxid)
  6064. }
  6065. if m.content != nil {
  6066. fields = append(fields, message.FieldContent)
  6067. }
  6068. return fields
  6069. }
  6070. // Field returns the value of a field with the given name. The second boolean
  6071. // return value indicates that this field was not set, or was not defined in the
  6072. // schema.
  6073. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  6074. switch name {
  6075. case message.FieldWxWxid:
  6076. return m.WxWxid()
  6077. case message.FieldWxid:
  6078. return m.Wxid()
  6079. case message.FieldContent:
  6080. return m.Content()
  6081. }
  6082. return nil, false
  6083. }
  6084. // OldField returns the old value of the field from the database. An error is
  6085. // returned if the mutation operation is not UpdateOne, or the query to the
  6086. // database failed.
  6087. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6088. switch name {
  6089. case message.FieldWxWxid:
  6090. return m.OldWxWxid(ctx)
  6091. case message.FieldWxid:
  6092. return m.OldWxid(ctx)
  6093. case message.FieldContent:
  6094. return m.OldContent(ctx)
  6095. }
  6096. return nil, fmt.Errorf("unknown Message field %s", name)
  6097. }
  6098. // SetField sets the value of a field with the given name. It returns an error if
  6099. // the field is not defined in the schema, or if the type mismatched the field
  6100. // type.
  6101. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  6102. switch name {
  6103. case message.FieldWxWxid:
  6104. v, ok := value.(string)
  6105. if !ok {
  6106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6107. }
  6108. m.SetWxWxid(v)
  6109. return nil
  6110. case message.FieldWxid:
  6111. v, ok := value.(string)
  6112. if !ok {
  6113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6114. }
  6115. m.SetWxid(v)
  6116. return nil
  6117. case message.FieldContent:
  6118. v, ok := value.(string)
  6119. if !ok {
  6120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6121. }
  6122. m.SetContent(v)
  6123. return nil
  6124. }
  6125. return fmt.Errorf("unknown Message field %s", name)
  6126. }
  6127. // AddedFields returns all numeric fields that were incremented/decremented during
  6128. // this mutation.
  6129. func (m *MessageMutation) AddedFields() []string {
  6130. return nil
  6131. }
  6132. // AddedField returns the numeric value that was incremented/decremented on a field
  6133. // with the given name. The second boolean return value indicates that this field
  6134. // was not set, or was not defined in the schema.
  6135. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  6136. return nil, false
  6137. }
  6138. // AddField adds the value to the field with the given name. It returns an error if
  6139. // the field is not defined in the schema, or if the type mismatched the field
  6140. // type.
  6141. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  6142. switch name {
  6143. }
  6144. return fmt.Errorf("unknown Message numeric field %s", name)
  6145. }
  6146. // ClearedFields returns all nullable fields that were cleared during this
  6147. // mutation.
  6148. func (m *MessageMutation) ClearedFields() []string {
  6149. var fields []string
  6150. if m.FieldCleared(message.FieldWxWxid) {
  6151. fields = append(fields, message.FieldWxWxid)
  6152. }
  6153. return fields
  6154. }
  6155. // FieldCleared returns a boolean indicating if a field with the given name was
  6156. // cleared in this mutation.
  6157. func (m *MessageMutation) FieldCleared(name string) bool {
  6158. _, ok := m.clearedFields[name]
  6159. return ok
  6160. }
  6161. // ClearField clears the value of the field with the given name. It returns an
  6162. // error if the field is not defined in the schema.
  6163. func (m *MessageMutation) ClearField(name string) error {
  6164. switch name {
  6165. case message.FieldWxWxid:
  6166. m.ClearWxWxid()
  6167. return nil
  6168. }
  6169. return fmt.Errorf("unknown Message nullable field %s", name)
  6170. }
  6171. // ResetField resets all changes in the mutation for the field with the given name.
  6172. // It returns an error if the field is not defined in the schema.
  6173. func (m *MessageMutation) ResetField(name string) error {
  6174. switch name {
  6175. case message.FieldWxWxid:
  6176. m.ResetWxWxid()
  6177. return nil
  6178. case message.FieldWxid:
  6179. m.ResetWxid()
  6180. return nil
  6181. case message.FieldContent:
  6182. m.ResetContent()
  6183. return nil
  6184. }
  6185. return fmt.Errorf("unknown Message field %s", name)
  6186. }
  6187. // AddedEdges returns all edge names that were set/added in this mutation.
  6188. func (m *MessageMutation) AddedEdges() []string {
  6189. edges := make([]string, 0, 0)
  6190. return edges
  6191. }
  6192. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6193. // name in this mutation.
  6194. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  6195. return nil
  6196. }
  6197. // RemovedEdges returns all edge names that were removed in this mutation.
  6198. func (m *MessageMutation) RemovedEdges() []string {
  6199. edges := make([]string, 0, 0)
  6200. return edges
  6201. }
  6202. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6203. // the given name in this mutation.
  6204. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  6205. return nil
  6206. }
  6207. // ClearedEdges returns all edge names that were cleared in this mutation.
  6208. func (m *MessageMutation) ClearedEdges() []string {
  6209. edges := make([]string, 0, 0)
  6210. return edges
  6211. }
  6212. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6213. // was cleared in this mutation.
  6214. func (m *MessageMutation) EdgeCleared(name string) bool {
  6215. return false
  6216. }
  6217. // ClearEdge clears the value of the edge with the given name. It returns an error
  6218. // if that edge is not defined in the schema.
  6219. func (m *MessageMutation) ClearEdge(name string) error {
  6220. return fmt.Errorf("unknown Message unique edge %s", name)
  6221. }
  6222. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6223. // It returns an error if the edge is not defined in the schema.
  6224. func (m *MessageMutation) ResetEdge(name string) error {
  6225. return fmt.Errorf("unknown Message edge %s", name)
  6226. }
  6227. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  6228. type MessageRecordsMutation struct {
  6229. config
  6230. op Op
  6231. typ string
  6232. id *uint64
  6233. created_at *time.Time
  6234. updated_at *time.Time
  6235. status *uint8
  6236. addstatus *int8
  6237. deleted_at *time.Time
  6238. bot_wxid *string
  6239. contact_type *int
  6240. addcontact_type *int
  6241. contact_wxid *string
  6242. content_type *int
  6243. addcontent_type *int
  6244. content *string
  6245. meta *custom_types.Meta
  6246. error_detail *string
  6247. send_time *time.Time
  6248. source_type *int
  6249. addsource_type *int
  6250. organization_id *uint64
  6251. addorganization_id *int64
  6252. clearedFields map[string]struct{}
  6253. sop_stage *uint64
  6254. clearedsop_stage bool
  6255. sop_node *uint64
  6256. clearedsop_node bool
  6257. message_contact *uint64
  6258. clearedmessage_contact bool
  6259. done bool
  6260. oldValue func(context.Context) (*MessageRecords, error)
  6261. predicates []predicate.MessageRecords
  6262. }
  6263. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  6264. // messagerecordsOption allows management of the mutation configuration using functional options.
  6265. type messagerecordsOption func(*MessageRecordsMutation)
  6266. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  6267. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  6268. m := &MessageRecordsMutation{
  6269. config: c,
  6270. op: op,
  6271. typ: TypeMessageRecords,
  6272. clearedFields: make(map[string]struct{}),
  6273. }
  6274. for _, opt := range opts {
  6275. opt(m)
  6276. }
  6277. return m
  6278. }
  6279. // withMessageRecordsID sets the ID field of the mutation.
  6280. func withMessageRecordsID(id uint64) messagerecordsOption {
  6281. return func(m *MessageRecordsMutation) {
  6282. var (
  6283. err error
  6284. once sync.Once
  6285. value *MessageRecords
  6286. )
  6287. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  6288. once.Do(func() {
  6289. if m.done {
  6290. err = errors.New("querying old values post mutation is not allowed")
  6291. } else {
  6292. value, err = m.Client().MessageRecords.Get(ctx, id)
  6293. }
  6294. })
  6295. return value, err
  6296. }
  6297. m.id = &id
  6298. }
  6299. }
  6300. // withMessageRecords sets the old MessageRecords of the mutation.
  6301. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  6302. return func(m *MessageRecordsMutation) {
  6303. m.oldValue = func(context.Context) (*MessageRecords, error) {
  6304. return node, nil
  6305. }
  6306. m.id = &node.ID
  6307. }
  6308. }
  6309. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6310. // executed in a transaction (ent.Tx), a transactional client is returned.
  6311. func (m MessageRecordsMutation) Client() *Client {
  6312. client := &Client{config: m.config}
  6313. client.init()
  6314. return client
  6315. }
  6316. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6317. // it returns an error otherwise.
  6318. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  6319. if _, ok := m.driver.(*txDriver); !ok {
  6320. return nil, errors.New("ent: mutation is not running in a transaction")
  6321. }
  6322. tx := &Tx{config: m.config}
  6323. tx.init()
  6324. return tx, nil
  6325. }
  6326. // SetID sets the value of the id field. Note that this
  6327. // operation is only accepted on creation of MessageRecords entities.
  6328. func (m *MessageRecordsMutation) SetID(id uint64) {
  6329. m.id = &id
  6330. }
  6331. // ID returns the ID value in the mutation. Note that the ID is only available
  6332. // if it was provided to the builder or after it was returned from the database.
  6333. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  6334. if m.id == nil {
  6335. return
  6336. }
  6337. return *m.id, true
  6338. }
  6339. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6340. // That means, if the mutation is applied within a transaction with an isolation level such
  6341. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6342. // or updated by the mutation.
  6343. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  6344. switch {
  6345. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6346. id, exists := m.ID()
  6347. if exists {
  6348. return []uint64{id}, nil
  6349. }
  6350. fallthrough
  6351. case m.op.Is(OpUpdate | OpDelete):
  6352. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  6353. default:
  6354. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6355. }
  6356. }
  6357. // SetCreatedAt sets the "created_at" field.
  6358. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  6359. m.created_at = &t
  6360. }
  6361. // CreatedAt returns the value of the "created_at" field in the mutation.
  6362. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  6363. v := m.created_at
  6364. if v == nil {
  6365. return
  6366. }
  6367. return *v, true
  6368. }
  6369. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  6370. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6372. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6373. if !m.op.Is(OpUpdateOne) {
  6374. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6375. }
  6376. if m.id == nil || m.oldValue == nil {
  6377. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6378. }
  6379. oldValue, err := m.oldValue(ctx)
  6380. if err != nil {
  6381. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6382. }
  6383. return oldValue.CreatedAt, nil
  6384. }
  6385. // ResetCreatedAt resets all changes to the "created_at" field.
  6386. func (m *MessageRecordsMutation) ResetCreatedAt() {
  6387. m.created_at = nil
  6388. }
  6389. // SetUpdatedAt sets the "updated_at" field.
  6390. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  6391. m.updated_at = &t
  6392. }
  6393. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6394. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  6395. v := m.updated_at
  6396. if v == nil {
  6397. return
  6398. }
  6399. return *v, true
  6400. }
  6401. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  6402. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6403. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6404. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6405. if !m.op.Is(OpUpdateOne) {
  6406. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6407. }
  6408. if m.id == nil || m.oldValue == nil {
  6409. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6410. }
  6411. oldValue, err := m.oldValue(ctx)
  6412. if err != nil {
  6413. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6414. }
  6415. return oldValue.UpdatedAt, nil
  6416. }
  6417. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6418. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  6419. m.updated_at = nil
  6420. }
  6421. // SetStatus sets the "status" field.
  6422. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  6423. m.status = &u
  6424. m.addstatus = nil
  6425. }
  6426. // Status returns the value of the "status" field in the mutation.
  6427. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  6428. v := m.status
  6429. if v == nil {
  6430. return
  6431. }
  6432. return *v, true
  6433. }
  6434. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  6435. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6436. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6437. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  6438. if !m.op.Is(OpUpdateOne) {
  6439. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  6440. }
  6441. if m.id == nil || m.oldValue == nil {
  6442. return v, errors.New("OldStatus requires an ID field in the mutation")
  6443. }
  6444. oldValue, err := m.oldValue(ctx)
  6445. if err != nil {
  6446. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  6447. }
  6448. return oldValue.Status, nil
  6449. }
  6450. // AddStatus adds u to the "status" field.
  6451. func (m *MessageRecordsMutation) AddStatus(u int8) {
  6452. if m.addstatus != nil {
  6453. *m.addstatus += u
  6454. } else {
  6455. m.addstatus = &u
  6456. }
  6457. }
  6458. // AddedStatus returns the value that was added to the "status" field in this mutation.
  6459. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  6460. v := m.addstatus
  6461. if v == nil {
  6462. return
  6463. }
  6464. return *v, true
  6465. }
  6466. // ClearStatus clears the value of the "status" field.
  6467. func (m *MessageRecordsMutation) ClearStatus() {
  6468. m.status = nil
  6469. m.addstatus = nil
  6470. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  6471. }
  6472. // StatusCleared returns if the "status" field was cleared in this mutation.
  6473. func (m *MessageRecordsMutation) StatusCleared() bool {
  6474. _, ok := m.clearedFields[messagerecords.FieldStatus]
  6475. return ok
  6476. }
  6477. // ResetStatus resets all changes to the "status" field.
  6478. func (m *MessageRecordsMutation) ResetStatus() {
  6479. m.status = nil
  6480. m.addstatus = nil
  6481. delete(m.clearedFields, messagerecords.FieldStatus)
  6482. }
  6483. // SetDeletedAt sets the "deleted_at" field.
  6484. func (m *MessageRecordsMutation) SetDeletedAt(t time.Time) {
  6485. m.deleted_at = &t
  6486. }
  6487. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6488. func (m *MessageRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  6489. v := m.deleted_at
  6490. if v == nil {
  6491. return
  6492. }
  6493. return *v, true
  6494. }
  6495. // OldDeletedAt returns the old "deleted_at" field's value of the MessageRecords entity.
  6496. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6497. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6498. func (m *MessageRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6499. if !m.op.Is(OpUpdateOne) {
  6500. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6501. }
  6502. if m.id == nil || m.oldValue == nil {
  6503. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6504. }
  6505. oldValue, err := m.oldValue(ctx)
  6506. if err != nil {
  6507. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6508. }
  6509. return oldValue.DeletedAt, nil
  6510. }
  6511. // ClearDeletedAt clears the value of the "deleted_at" field.
  6512. func (m *MessageRecordsMutation) ClearDeletedAt() {
  6513. m.deleted_at = nil
  6514. m.clearedFields[messagerecords.FieldDeletedAt] = struct{}{}
  6515. }
  6516. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6517. func (m *MessageRecordsMutation) DeletedAtCleared() bool {
  6518. _, ok := m.clearedFields[messagerecords.FieldDeletedAt]
  6519. return ok
  6520. }
  6521. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6522. func (m *MessageRecordsMutation) ResetDeletedAt() {
  6523. m.deleted_at = nil
  6524. delete(m.clearedFields, messagerecords.FieldDeletedAt)
  6525. }
  6526. // SetBotWxid sets the "bot_wxid" field.
  6527. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  6528. m.bot_wxid = &s
  6529. }
  6530. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  6531. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  6532. v := m.bot_wxid
  6533. if v == nil {
  6534. return
  6535. }
  6536. return *v, true
  6537. }
  6538. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  6539. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6540. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6541. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  6542. if !m.op.Is(OpUpdateOne) {
  6543. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  6544. }
  6545. if m.id == nil || m.oldValue == nil {
  6546. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  6547. }
  6548. oldValue, err := m.oldValue(ctx)
  6549. if err != nil {
  6550. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  6551. }
  6552. return oldValue.BotWxid, nil
  6553. }
  6554. // ResetBotWxid resets all changes to the "bot_wxid" field.
  6555. func (m *MessageRecordsMutation) ResetBotWxid() {
  6556. m.bot_wxid = nil
  6557. }
  6558. // SetContactID sets the "contact_id" field.
  6559. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  6560. m.message_contact = &u
  6561. }
  6562. // ContactID returns the value of the "contact_id" field in the mutation.
  6563. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  6564. v := m.message_contact
  6565. if v == nil {
  6566. return
  6567. }
  6568. return *v, true
  6569. }
  6570. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  6571. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6572. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6573. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  6574. if !m.op.Is(OpUpdateOne) {
  6575. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  6576. }
  6577. if m.id == nil || m.oldValue == nil {
  6578. return v, errors.New("OldContactID requires an ID field in the mutation")
  6579. }
  6580. oldValue, err := m.oldValue(ctx)
  6581. if err != nil {
  6582. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  6583. }
  6584. return oldValue.ContactID, nil
  6585. }
  6586. // ClearContactID clears the value of the "contact_id" field.
  6587. func (m *MessageRecordsMutation) ClearContactID() {
  6588. m.message_contact = nil
  6589. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  6590. }
  6591. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  6592. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  6593. _, ok := m.clearedFields[messagerecords.FieldContactID]
  6594. return ok
  6595. }
  6596. // ResetContactID resets all changes to the "contact_id" field.
  6597. func (m *MessageRecordsMutation) ResetContactID() {
  6598. m.message_contact = nil
  6599. delete(m.clearedFields, messagerecords.FieldContactID)
  6600. }
  6601. // SetContactType sets the "contact_type" field.
  6602. func (m *MessageRecordsMutation) SetContactType(i int) {
  6603. m.contact_type = &i
  6604. m.addcontact_type = nil
  6605. }
  6606. // ContactType returns the value of the "contact_type" field in the mutation.
  6607. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  6608. v := m.contact_type
  6609. if v == nil {
  6610. return
  6611. }
  6612. return *v, true
  6613. }
  6614. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  6615. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6616. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6617. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  6618. if !m.op.Is(OpUpdateOne) {
  6619. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  6620. }
  6621. if m.id == nil || m.oldValue == nil {
  6622. return v, errors.New("OldContactType requires an ID field in the mutation")
  6623. }
  6624. oldValue, err := m.oldValue(ctx)
  6625. if err != nil {
  6626. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  6627. }
  6628. return oldValue.ContactType, nil
  6629. }
  6630. // AddContactType adds i to the "contact_type" field.
  6631. func (m *MessageRecordsMutation) AddContactType(i int) {
  6632. if m.addcontact_type != nil {
  6633. *m.addcontact_type += i
  6634. } else {
  6635. m.addcontact_type = &i
  6636. }
  6637. }
  6638. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  6639. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  6640. v := m.addcontact_type
  6641. if v == nil {
  6642. return
  6643. }
  6644. return *v, true
  6645. }
  6646. // ResetContactType resets all changes to the "contact_type" field.
  6647. func (m *MessageRecordsMutation) ResetContactType() {
  6648. m.contact_type = nil
  6649. m.addcontact_type = nil
  6650. }
  6651. // SetContactWxid sets the "contact_wxid" field.
  6652. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  6653. m.contact_wxid = &s
  6654. }
  6655. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  6656. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  6657. v := m.contact_wxid
  6658. if v == nil {
  6659. return
  6660. }
  6661. return *v, true
  6662. }
  6663. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  6664. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6665. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6666. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  6667. if !m.op.Is(OpUpdateOne) {
  6668. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  6669. }
  6670. if m.id == nil || m.oldValue == nil {
  6671. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  6672. }
  6673. oldValue, err := m.oldValue(ctx)
  6674. if err != nil {
  6675. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  6676. }
  6677. return oldValue.ContactWxid, nil
  6678. }
  6679. // ResetContactWxid resets all changes to the "contact_wxid" field.
  6680. func (m *MessageRecordsMutation) ResetContactWxid() {
  6681. m.contact_wxid = nil
  6682. }
  6683. // SetContentType sets the "content_type" field.
  6684. func (m *MessageRecordsMutation) SetContentType(i int) {
  6685. m.content_type = &i
  6686. m.addcontent_type = nil
  6687. }
  6688. // ContentType returns the value of the "content_type" field in the mutation.
  6689. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  6690. v := m.content_type
  6691. if v == nil {
  6692. return
  6693. }
  6694. return *v, true
  6695. }
  6696. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  6697. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6699. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  6700. if !m.op.Is(OpUpdateOne) {
  6701. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  6702. }
  6703. if m.id == nil || m.oldValue == nil {
  6704. return v, errors.New("OldContentType requires an ID field in the mutation")
  6705. }
  6706. oldValue, err := m.oldValue(ctx)
  6707. if err != nil {
  6708. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  6709. }
  6710. return oldValue.ContentType, nil
  6711. }
  6712. // AddContentType adds i to the "content_type" field.
  6713. func (m *MessageRecordsMutation) AddContentType(i int) {
  6714. if m.addcontent_type != nil {
  6715. *m.addcontent_type += i
  6716. } else {
  6717. m.addcontent_type = &i
  6718. }
  6719. }
  6720. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  6721. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  6722. v := m.addcontent_type
  6723. if v == nil {
  6724. return
  6725. }
  6726. return *v, true
  6727. }
  6728. // ResetContentType resets all changes to the "content_type" field.
  6729. func (m *MessageRecordsMutation) ResetContentType() {
  6730. m.content_type = nil
  6731. m.addcontent_type = nil
  6732. }
  6733. // SetContent sets the "content" field.
  6734. func (m *MessageRecordsMutation) SetContent(s string) {
  6735. m.content = &s
  6736. }
  6737. // Content returns the value of the "content" field in the mutation.
  6738. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  6739. v := m.content
  6740. if v == nil {
  6741. return
  6742. }
  6743. return *v, true
  6744. }
  6745. // OldContent returns the old "content" field's value of the MessageRecords entity.
  6746. // If the MessageRecords 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 *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  6749. if !m.op.Is(OpUpdateOne) {
  6750. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  6751. }
  6752. if m.id == nil || m.oldValue == nil {
  6753. return v, errors.New("OldContent 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 OldContent: %w", err)
  6758. }
  6759. return oldValue.Content, nil
  6760. }
  6761. // ResetContent resets all changes to the "content" field.
  6762. func (m *MessageRecordsMutation) ResetContent() {
  6763. m.content = nil
  6764. }
  6765. // SetMeta sets the "meta" field.
  6766. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  6767. m.meta = &ct
  6768. }
  6769. // Meta returns the value of the "meta" field in the mutation.
  6770. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  6771. v := m.meta
  6772. if v == nil {
  6773. return
  6774. }
  6775. return *v, true
  6776. }
  6777. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  6778. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6780. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  6781. if !m.op.Is(OpUpdateOne) {
  6782. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  6783. }
  6784. if m.id == nil || m.oldValue == nil {
  6785. return v, errors.New("OldMeta requires an ID field in the mutation")
  6786. }
  6787. oldValue, err := m.oldValue(ctx)
  6788. if err != nil {
  6789. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  6790. }
  6791. return oldValue.Meta, nil
  6792. }
  6793. // ClearMeta clears the value of the "meta" field.
  6794. func (m *MessageRecordsMutation) ClearMeta() {
  6795. m.meta = nil
  6796. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  6797. }
  6798. // MetaCleared returns if the "meta" field was cleared in this mutation.
  6799. func (m *MessageRecordsMutation) MetaCleared() bool {
  6800. _, ok := m.clearedFields[messagerecords.FieldMeta]
  6801. return ok
  6802. }
  6803. // ResetMeta resets all changes to the "meta" field.
  6804. func (m *MessageRecordsMutation) ResetMeta() {
  6805. m.meta = nil
  6806. delete(m.clearedFields, messagerecords.FieldMeta)
  6807. }
  6808. // SetErrorDetail sets the "error_detail" field.
  6809. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  6810. m.error_detail = &s
  6811. }
  6812. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  6813. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  6814. v := m.error_detail
  6815. if v == nil {
  6816. return
  6817. }
  6818. return *v, true
  6819. }
  6820. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  6821. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6822. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6823. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  6824. if !m.op.Is(OpUpdateOne) {
  6825. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  6826. }
  6827. if m.id == nil || m.oldValue == nil {
  6828. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  6829. }
  6830. oldValue, err := m.oldValue(ctx)
  6831. if err != nil {
  6832. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  6833. }
  6834. return oldValue.ErrorDetail, nil
  6835. }
  6836. // ResetErrorDetail resets all changes to the "error_detail" field.
  6837. func (m *MessageRecordsMutation) ResetErrorDetail() {
  6838. m.error_detail = nil
  6839. }
  6840. // SetSendTime sets the "send_time" field.
  6841. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  6842. m.send_time = &t
  6843. }
  6844. // SendTime returns the value of the "send_time" field in the mutation.
  6845. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  6846. v := m.send_time
  6847. if v == nil {
  6848. return
  6849. }
  6850. return *v, true
  6851. }
  6852. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  6853. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6854. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6855. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  6856. if !m.op.Is(OpUpdateOne) {
  6857. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  6858. }
  6859. if m.id == nil || m.oldValue == nil {
  6860. return v, errors.New("OldSendTime requires an ID field in the mutation")
  6861. }
  6862. oldValue, err := m.oldValue(ctx)
  6863. if err != nil {
  6864. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  6865. }
  6866. return oldValue.SendTime, nil
  6867. }
  6868. // ClearSendTime clears the value of the "send_time" field.
  6869. func (m *MessageRecordsMutation) ClearSendTime() {
  6870. m.send_time = nil
  6871. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  6872. }
  6873. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  6874. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  6875. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  6876. return ok
  6877. }
  6878. // ResetSendTime resets all changes to the "send_time" field.
  6879. func (m *MessageRecordsMutation) ResetSendTime() {
  6880. m.send_time = nil
  6881. delete(m.clearedFields, messagerecords.FieldSendTime)
  6882. }
  6883. // SetSourceType sets the "source_type" field.
  6884. func (m *MessageRecordsMutation) SetSourceType(i int) {
  6885. m.source_type = &i
  6886. m.addsource_type = nil
  6887. }
  6888. // SourceType returns the value of the "source_type" field in the mutation.
  6889. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  6890. v := m.source_type
  6891. if v == nil {
  6892. return
  6893. }
  6894. return *v, true
  6895. }
  6896. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  6897. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6898. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6899. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  6900. if !m.op.Is(OpUpdateOne) {
  6901. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  6902. }
  6903. if m.id == nil || m.oldValue == nil {
  6904. return v, errors.New("OldSourceType requires an ID field in the mutation")
  6905. }
  6906. oldValue, err := m.oldValue(ctx)
  6907. if err != nil {
  6908. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  6909. }
  6910. return oldValue.SourceType, nil
  6911. }
  6912. // AddSourceType adds i to the "source_type" field.
  6913. func (m *MessageRecordsMutation) AddSourceType(i int) {
  6914. if m.addsource_type != nil {
  6915. *m.addsource_type += i
  6916. } else {
  6917. m.addsource_type = &i
  6918. }
  6919. }
  6920. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  6921. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  6922. v := m.addsource_type
  6923. if v == nil {
  6924. return
  6925. }
  6926. return *v, true
  6927. }
  6928. // ResetSourceType resets all changes to the "source_type" field.
  6929. func (m *MessageRecordsMutation) ResetSourceType() {
  6930. m.source_type = nil
  6931. m.addsource_type = nil
  6932. }
  6933. // SetSourceID sets the "source_id" field.
  6934. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  6935. m.sop_stage = &u
  6936. }
  6937. // SourceID returns the value of the "source_id" field in the mutation.
  6938. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  6939. v := m.sop_stage
  6940. if v == nil {
  6941. return
  6942. }
  6943. return *v, true
  6944. }
  6945. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  6946. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6947. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6948. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  6949. if !m.op.Is(OpUpdateOne) {
  6950. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  6951. }
  6952. if m.id == nil || m.oldValue == nil {
  6953. return v, errors.New("OldSourceID requires an ID field in the mutation")
  6954. }
  6955. oldValue, err := m.oldValue(ctx)
  6956. if err != nil {
  6957. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  6958. }
  6959. return oldValue.SourceID, nil
  6960. }
  6961. // ClearSourceID clears the value of the "source_id" field.
  6962. func (m *MessageRecordsMutation) ClearSourceID() {
  6963. m.sop_stage = nil
  6964. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  6965. }
  6966. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  6967. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  6968. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  6969. return ok
  6970. }
  6971. // ResetSourceID resets all changes to the "source_id" field.
  6972. func (m *MessageRecordsMutation) ResetSourceID() {
  6973. m.sop_stage = nil
  6974. delete(m.clearedFields, messagerecords.FieldSourceID)
  6975. }
  6976. // SetSubSourceID sets the "sub_source_id" field.
  6977. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  6978. m.sop_node = &u
  6979. }
  6980. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  6981. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  6982. v := m.sop_node
  6983. if v == nil {
  6984. return
  6985. }
  6986. return *v, true
  6987. }
  6988. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  6989. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6990. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6991. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  6992. if !m.op.Is(OpUpdateOne) {
  6993. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  6994. }
  6995. if m.id == nil || m.oldValue == nil {
  6996. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  6997. }
  6998. oldValue, err := m.oldValue(ctx)
  6999. if err != nil {
  7000. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  7001. }
  7002. return oldValue.SubSourceID, nil
  7003. }
  7004. // ClearSubSourceID clears the value of the "sub_source_id" field.
  7005. func (m *MessageRecordsMutation) ClearSubSourceID() {
  7006. m.sop_node = nil
  7007. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  7008. }
  7009. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  7010. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  7011. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  7012. return ok
  7013. }
  7014. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  7015. func (m *MessageRecordsMutation) ResetSubSourceID() {
  7016. m.sop_node = nil
  7017. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  7018. }
  7019. // SetOrganizationID sets the "organization_id" field.
  7020. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  7021. m.organization_id = &u
  7022. m.addorganization_id = nil
  7023. }
  7024. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7025. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  7026. v := m.organization_id
  7027. if v == nil {
  7028. return
  7029. }
  7030. return *v, true
  7031. }
  7032. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  7033. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  7034. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7035. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7036. if !m.op.Is(OpUpdateOne) {
  7037. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7038. }
  7039. if m.id == nil || m.oldValue == nil {
  7040. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7041. }
  7042. oldValue, err := m.oldValue(ctx)
  7043. if err != nil {
  7044. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7045. }
  7046. return oldValue.OrganizationID, nil
  7047. }
  7048. // AddOrganizationID adds u to the "organization_id" field.
  7049. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  7050. if m.addorganization_id != nil {
  7051. *m.addorganization_id += u
  7052. } else {
  7053. m.addorganization_id = &u
  7054. }
  7055. }
  7056. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7057. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  7058. v := m.addorganization_id
  7059. if v == nil {
  7060. return
  7061. }
  7062. return *v, true
  7063. }
  7064. // ClearOrganizationID clears the value of the "organization_id" field.
  7065. func (m *MessageRecordsMutation) ClearOrganizationID() {
  7066. m.organization_id = nil
  7067. m.addorganization_id = nil
  7068. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  7069. }
  7070. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  7071. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  7072. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  7073. return ok
  7074. }
  7075. // ResetOrganizationID resets all changes to the "organization_id" field.
  7076. func (m *MessageRecordsMutation) ResetOrganizationID() {
  7077. m.organization_id = nil
  7078. m.addorganization_id = nil
  7079. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  7080. }
  7081. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  7082. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  7083. m.sop_stage = &id
  7084. }
  7085. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  7086. func (m *MessageRecordsMutation) ClearSopStage() {
  7087. m.clearedsop_stage = true
  7088. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  7089. }
  7090. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  7091. func (m *MessageRecordsMutation) SopStageCleared() bool {
  7092. return m.SourceIDCleared() || m.clearedsop_stage
  7093. }
  7094. // SopStageID returns the "sop_stage" edge ID in the mutation.
  7095. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  7096. if m.sop_stage != nil {
  7097. return *m.sop_stage, true
  7098. }
  7099. return
  7100. }
  7101. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  7102. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  7103. // SopStageID instead. It exists only for internal usage by the builders.
  7104. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  7105. if id := m.sop_stage; id != nil {
  7106. ids = append(ids, *id)
  7107. }
  7108. return
  7109. }
  7110. // ResetSopStage resets all changes to the "sop_stage" edge.
  7111. func (m *MessageRecordsMutation) ResetSopStage() {
  7112. m.sop_stage = nil
  7113. m.clearedsop_stage = false
  7114. }
  7115. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  7116. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  7117. m.sop_node = &id
  7118. }
  7119. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  7120. func (m *MessageRecordsMutation) ClearSopNode() {
  7121. m.clearedsop_node = true
  7122. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  7123. }
  7124. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  7125. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  7126. return m.SubSourceIDCleared() || m.clearedsop_node
  7127. }
  7128. // SopNodeID returns the "sop_node" edge ID in the mutation.
  7129. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  7130. if m.sop_node != nil {
  7131. return *m.sop_node, true
  7132. }
  7133. return
  7134. }
  7135. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  7136. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  7137. // SopNodeID instead. It exists only for internal usage by the builders.
  7138. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  7139. if id := m.sop_node; id != nil {
  7140. ids = append(ids, *id)
  7141. }
  7142. return
  7143. }
  7144. // ResetSopNode resets all changes to the "sop_node" edge.
  7145. func (m *MessageRecordsMutation) ResetSopNode() {
  7146. m.sop_node = nil
  7147. m.clearedsop_node = false
  7148. }
  7149. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  7150. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  7151. m.message_contact = &id
  7152. }
  7153. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  7154. func (m *MessageRecordsMutation) ClearMessageContact() {
  7155. m.clearedmessage_contact = true
  7156. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  7157. }
  7158. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  7159. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  7160. return m.ContactIDCleared() || m.clearedmessage_contact
  7161. }
  7162. // MessageContactID returns the "message_contact" edge ID in the mutation.
  7163. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  7164. if m.message_contact != nil {
  7165. return *m.message_contact, true
  7166. }
  7167. return
  7168. }
  7169. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  7170. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  7171. // MessageContactID instead. It exists only for internal usage by the builders.
  7172. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  7173. if id := m.message_contact; id != nil {
  7174. ids = append(ids, *id)
  7175. }
  7176. return
  7177. }
  7178. // ResetMessageContact resets all changes to the "message_contact" edge.
  7179. func (m *MessageRecordsMutation) ResetMessageContact() {
  7180. m.message_contact = nil
  7181. m.clearedmessage_contact = false
  7182. }
  7183. // Where appends a list predicates to the MessageRecordsMutation builder.
  7184. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  7185. m.predicates = append(m.predicates, ps...)
  7186. }
  7187. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  7188. // users can use type-assertion to append predicates that do not depend on any generated package.
  7189. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  7190. p := make([]predicate.MessageRecords, len(ps))
  7191. for i := range ps {
  7192. p[i] = ps[i]
  7193. }
  7194. m.Where(p...)
  7195. }
  7196. // Op returns the operation name.
  7197. func (m *MessageRecordsMutation) Op() Op {
  7198. return m.op
  7199. }
  7200. // SetOp allows setting the mutation operation.
  7201. func (m *MessageRecordsMutation) SetOp(op Op) {
  7202. m.op = op
  7203. }
  7204. // Type returns the node type of this mutation (MessageRecords).
  7205. func (m *MessageRecordsMutation) Type() string {
  7206. return m.typ
  7207. }
  7208. // Fields returns all fields that were changed during this mutation. Note that in
  7209. // order to get all numeric fields that were incremented/decremented, call
  7210. // AddedFields().
  7211. func (m *MessageRecordsMutation) Fields() []string {
  7212. fields := make([]string, 0, 17)
  7213. if m.created_at != nil {
  7214. fields = append(fields, messagerecords.FieldCreatedAt)
  7215. }
  7216. if m.updated_at != nil {
  7217. fields = append(fields, messagerecords.FieldUpdatedAt)
  7218. }
  7219. if m.status != nil {
  7220. fields = append(fields, messagerecords.FieldStatus)
  7221. }
  7222. if m.deleted_at != nil {
  7223. fields = append(fields, messagerecords.FieldDeletedAt)
  7224. }
  7225. if m.bot_wxid != nil {
  7226. fields = append(fields, messagerecords.FieldBotWxid)
  7227. }
  7228. if m.message_contact != nil {
  7229. fields = append(fields, messagerecords.FieldContactID)
  7230. }
  7231. if m.contact_type != nil {
  7232. fields = append(fields, messagerecords.FieldContactType)
  7233. }
  7234. if m.contact_wxid != nil {
  7235. fields = append(fields, messagerecords.FieldContactWxid)
  7236. }
  7237. if m.content_type != nil {
  7238. fields = append(fields, messagerecords.FieldContentType)
  7239. }
  7240. if m.content != nil {
  7241. fields = append(fields, messagerecords.FieldContent)
  7242. }
  7243. if m.meta != nil {
  7244. fields = append(fields, messagerecords.FieldMeta)
  7245. }
  7246. if m.error_detail != nil {
  7247. fields = append(fields, messagerecords.FieldErrorDetail)
  7248. }
  7249. if m.send_time != nil {
  7250. fields = append(fields, messagerecords.FieldSendTime)
  7251. }
  7252. if m.source_type != nil {
  7253. fields = append(fields, messagerecords.FieldSourceType)
  7254. }
  7255. if m.sop_stage != nil {
  7256. fields = append(fields, messagerecords.FieldSourceID)
  7257. }
  7258. if m.sop_node != nil {
  7259. fields = append(fields, messagerecords.FieldSubSourceID)
  7260. }
  7261. if m.organization_id != nil {
  7262. fields = append(fields, messagerecords.FieldOrganizationID)
  7263. }
  7264. return fields
  7265. }
  7266. // Field returns the value of a field with the given name. The second boolean
  7267. // return value indicates that this field was not set, or was not defined in the
  7268. // schema.
  7269. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  7270. switch name {
  7271. case messagerecords.FieldCreatedAt:
  7272. return m.CreatedAt()
  7273. case messagerecords.FieldUpdatedAt:
  7274. return m.UpdatedAt()
  7275. case messagerecords.FieldStatus:
  7276. return m.Status()
  7277. case messagerecords.FieldDeletedAt:
  7278. return m.DeletedAt()
  7279. case messagerecords.FieldBotWxid:
  7280. return m.BotWxid()
  7281. case messagerecords.FieldContactID:
  7282. return m.ContactID()
  7283. case messagerecords.FieldContactType:
  7284. return m.ContactType()
  7285. case messagerecords.FieldContactWxid:
  7286. return m.ContactWxid()
  7287. case messagerecords.FieldContentType:
  7288. return m.ContentType()
  7289. case messagerecords.FieldContent:
  7290. return m.Content()
  7291. case messagerecords.FieldMeta:
  7292. return m.Meta()
  7293. case messagerecords.FieldErrorDetail:
  7294. return m.ErrorDetail()
  7295. case messagerecords.FieldSendTime:
  7296. return m.SendTime()
  7297. case messagerecords.FieldSourceType:
  7298. return m.SourceType()
  7299. case messagerecords.FieldSourceID:
  7300. return m.SourceID()
  7301. case messagerecords.FieldSubSourceID:
  7302. return m.SubSourceID()
  7303. case messagerecords.FieldOrganizationID:
  7304. return m.OrganizationID()
  7305. }
  7306. return nil, false
  7307. }
  7308. // OldField returns the old value of the field from the database. An error is
  7309. // returned if the mutation operation is not UpdateOne, or the query to the
  7310. // database failed.
  7311. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7312. switch name {
  7313. case messagerecords.FieldCreatedAt:
  7314. return m.OldCreatedAt(ctx)
  7315. case messagerecords.FieldUpdatedAt:
  7316. return m.OldUpdatedAt(ctx)
  7317. case messagerecords.FieldStatus:
  7318. return m.OldStatus(ctx)
  7319. case messagerecords.FieldDeletedAt:
  7320. return m.OldDeletedAt(ctx)
  7321. case messagerecords.FieldBotWxid:
  7322. return m.OldBotWxid(ctx)
  7323. case messagerecords.FieldContactID:
  7324. return m.OldContactID(ctx)
  7325. case messagerecords.FieldContactType:
  7326. return m.OldContactType(ctx)
  7327. case messagerecords.FieldContactWxid:
  7328. return m.OldContactWxid(ctx)
  7329. case messagerecords.FieldContentType:
  7330. return m.OldContentType(ctx)
  7331. case messagerecords.FieldContent:
  7332. return m.OldContent(ctx)
  7333. case messagerecords.FieldMeta:
  7334. return m.OldMeta(ctx)
  7335. case messagerecords.FieldErrorDetail:
  7336. return m.OldErrorDetail(ctx)
  7337. case messagerecords.FieldSendTime:
  7338. return m.OldSendTime(ctx)
  7339. case messagerecords.FieldSourceType:
  7340. return m.OldSourceType(ctx)
  7341. case messagerecords.FieldSourceID:
  7342. return m.OldSourceID(ctx)
  7343. case messagerecords.FieldSubSourceID:
  7344. return m.OldSubSourceID(ctx)
  7345. case messagerecords.FieldOrganizationID:
  7346. return m.OldOrganizationID(ctx)
  7347. }
  7348. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  7349. }
  7350. // SetField sets the value of a field with the given name. It returns an error if
  7351. // the field is not defined in the schema, or if the type mismatched the field
  7352. // type.
  7353. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  7354. switch name {
  7355. case messagerecords.FieldCreatedAt:
  7356. v, ok := value.(time.Time)
  7357. if !ok {
  7358. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7359. }
  7360. m.SetCreatedAt(v)
  7361. return nil
  7362. case messagerecords.FieldUpdatedAt:
  7363. v, ok := value.(time.Time)
  7364. if !ok {
  7365. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7366. }
  7367. m.SetUpdatedAt(v)
  7368. return nil
  7369. case messagerecords.FieldStatus:
  7370. v, ok := value.(uint8)
  7371. if !ok {
  7372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7373. }
  7374. m.SetStatus(v)
  7375. return nil
  7376. case messagerecords.FieldDeletedAt:
  7377. v, ok := value.(time.Time)
  7378. if !ok {
  7379. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7380. }
  7381. m.SetDeletedAt(v)
  7382. return nil
  7383. case messagerecords.FieldBotWxid:
  7384. v, ok := value.(string)
  7385. if !ok {
  7386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7387. }
  7388. m.SetBotWxid(v)
  7389. return nil
  7390. case messagerecords.FieldContactID:
  7391. v, ok := value.(uint64)
  7392. if !ok {
  7393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7394. }
  7395. m.SetContactID(v)
  7396. return nil
  7397. case messagerecords.FieldContactType:
  7398. v, ok := value.(int)
  7399. if !ok {
  7400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7401. }
  7402. m.SetContactType(v)
  7403. return nil
  7404. case messagerecords.FieldContactWxid:
  7405. v, ok := value.(string)
  7406. if !ok {
  7407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7408. }
  7409. m.SetContactWxid(v)
  7410. return nil
  7411. case messagerecords.FieldContentType:
  7412. v, ok := value.(int)
  7413. if !ok {
  7414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7415. }
  7416. m.SetContentType(v)
  7417. return nil
  7418. case messagerecords.FieldContent:
  7419. v, ok := value.(string)
  7420. if !ok {
  7421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7422. }
  7423. m.SetContent(v)
  7424. return nil
  7425. case messagerecords.FieldMeta:
  7426. v, ok := value.(custom_types.Meta)
  7427. if !ok {
  7428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7429. }
  7430. m.SetMeta(v)
  7431. return nil
  7432. case messagerecords.FieldErrorDetail:
  7433. v, ok := value.(string)
  7434. if !ok {
  7435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7436. }
  7437. m.SetErrorDetail(v)
  7438. return nil
  7439. case messagerecords.FieldSendTime:
  7440. v, ok := value.(time.Time)
  7441. if !ok {
  7442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7443. }
  7444. m.SetSendTime(v)
  7445. return nil
  7446. case messagerecords.FieldSourceType:
  7447. v, ok := value.(int)
  7448. if !ok {
  7449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7450. }
  7451. m.SetSourceType(v)
  7452. return nil
  7453. case messagerecords.FieldSourceID:
  7454. v, ok := value.(uint64)
  7455. if !ok {
  7456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7457. }
  7458. m.SetSourceID(v)
  7459. return nil
  7460. case messagerecords.FieldSubSourceID:
  7461. v, ok := value.(uint64)
  7462. if !ok {
  7463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7464. }
  7465. m.SetSubSourceID(v)
  7466. return nil
  7467. case messagerecords.FieldOrganizationID:
  7468. v, ok := value.(uint64)
  7469. if !ok {
  7470. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7471. }
  7472. m.SetOrganizationID(v)
  7473. return nil
  7474. }
  7475. return fmt.Errorf("unknown MessageRecords field %s", name)
  7476. }
  7477. // AddedFields returns all numeric fields that were incremented/decremented during
  7478. // this mutation.
  7479. func (m *MessageRecordsMutation) AddedFields() []string {
  7480. var fields []string
  7481. if m.addstatus != nil {
  7482. fields = append(fields, messagerecords.FieldStatus)
  7483. }
  7484. if m.addcontact_type != nil {
  7485. fields = append(fields, messagerecords.FieldContactType)
  7486. }
  7487. if m.addcontent_type != nil {
  7488. fields = append(fields, messagerecords.FieldContentType)
  7489. }
  7490. if m.addsource_type != nil {
  7491. fields = append(fields, messagerecords.FieldSourceType)
  7492. }
  7493. if m.addorganization_id != nil {
  7494. fields = append(fields, messagerecords.FieldOrganizationID)
  7495. }
  7496. return fields
  7497. }
  7498. // AddedField returns the numeric value that was incremented/decremented on a field
  7499. // with the given name. The second boolean return value indicates that this field
  7500. // was not set, or was not defined in the schema.
  7501. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  7502. switch name {
  7503. case messagerecords.FieldStatus:
  7504. return m.AddedStatus()
  7505. case messagerecords.FieldContactType:
  7506. return m.AddedContactType()
  7507. case messagerecords.FieldContentType:
  7508. return m.AddedContentType()
  7509. case messagerecords.FieldSourceType:
  7510. return m.AddedSourceType()
  7511. case messagerecords.FieldOrganizationID:
  7512. return m.AddedOrganizationID()
  7513. }
  7514. return nil, false
  7515. }
  7516. // AddField adds the value to the field with the given name. It returns an error if
  7517. // the field is not defined in the schema, or if the type mismatched the field
  7518. // type.
  7519. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  7520. switch name {
  7521. case messagerecords.FieldStatus:
  7522. v, ok := value.(int8)
  7523. if !ok {
  7524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7525. }
  7526. m.AddStatus(v)
  7527. return nil
  7528. case messagerecords.FieldContactType:
  7529. v, ok := value.(int)
  7530. if !ok {
  7531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7532. }
  7533. m.AddContactType(v)
  7534. return nil
  7535. case messagerecords.FieldContentType:
  7536. v, ok := value.(int)
  7537. if !ok {
  7538. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7539. }
  7540. m.AddContentType(v)
  7541. return nil
  7542. case messagerecords.FieldSourceType:
  7543. v, ok := value.(int)
  7544. if !ok {
  7545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7546. }
  7547. m.AddSourceType(v)
  7548. return nil
  7549. case messagerecords.FieldOrganizationID:
  7550. v, ok := value.(int64)
  7551. if !ok {
  7552. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7553. }
  7554. m.AddOrganizationID(v)
  7555. return nil
  7556. }
  7557. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  7558. }
  7559. // ClearedFields returns all nullable fields that were cleared during this
  7560. // mutation.
  7561. func (m *MessageRecordsMutation) ClearedFields() []string {
  7562. var fields []string
  7563. if m.FieldCleared(messagerecords.FieldStatus) {
  7564. fields = append(fields, messagerecords.FieldStatus)
  7565. }
  7566. if m.FieldCleared(messagerecords.FieldDeletedAt) {
  7567. fields = append(fields, messagerecords.FieldDeletedAt)
  7568. }
  7569. if m.FieldCleared(messagerecords.FieldContactID) {
  7570. fields = append(fields, messagerecords.FieldContactID)
  7571. }
  7572. if m.FieldCleared(messagerecords.FieldMeta) {
  7573. fields = append(fields, messagerecords.FieldMeta)
  7574. }
  7575. if m.FieldCleared(messagerecords.FieldSendTime) {
  7576. fields = append(fields, messagerecords.FieldSendTime)
  7577. }
  7578. if m.FieldCleared(messagerecords.FieldSourceID) {
  7579. fields = append(fields, messagerecords.FieldSourceID)
  7580. }
  7581. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  7582. fields = append(fields, messagerecords.FieldSubSourceID)
  7583. }
  7584. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  7585. fields = append(fields, messagerecords.FieldOrganizationID)
  7586. }
  7587. return fields
  7588. }
  7589. // FieldCleared returns a boolean indicating if a field with the given name was
  7590. // cleared in this mutation.
  7591. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  7592. _, ok := m.clearedFields[name]
  7593. return ok
  7594. }
  7595. // ClearField clears the value of the field with the given name. It returns an
  7596. // error if the field is not defined in the schema.
  7597. func (m *MessageRecordsMutation) ClearField(name string) error {
  7598. switch name {
  7599. case messagerecords.FieldStatus:
  7600. m.ClearStatus()
  7601. return nil
  7602. case messagerecords.FieldDeletedAt:
  7603. m.ClearDeletedAt()
  7604. return nil
  7605. case messagerecords.FieldContactID:
  7606. m.ClearContactID()
  7607. return nil
  7608. case messagerecords.FieldMeta:
  7609. m.ClearMeta()
  7610. return nil
  7611. case messagerecords.FieldSendTime:
  7612. m.ClearSendTime()
  7613. return nil
  7614. case messagerecords.FieldSourceID:
  7615. m.ClearSourceID()
  7616. return nil
  7617. case messagerecords.FieldSubSourceID:
  7618. m.ClearSubSourceID()
  7619. return nil
  7620. case messagerecords.FieldOrganizationID:
  7621. m.ClearOrganizationID()
  7622. return nil
  7623. }
  7624. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  7625. }
  7626. // ResetField resets all changes in the mutation for the field with the given name.
  7627. // It returns an error if the field is not defined in the schema.
  7628. func (m *MessageRecordsMutation) ResetField(name string) error {
  7629. switch name {
  7630. case messagerecords.FieldCreatedAt:
  7631. m.ResetCreatedAt()
  7632. return nil
  7633. case messagerecords.FieldUpdatedAt:
  7634. m.ResetUpdatedAt()
  7635. return nil
  7636. case messagerecords.FieldStatus:
  7637. m.ResetStatus()
  7638. return nil
  7639. case messagerecords.FieldDeletedAt:
  7640. m.ResetDeletedAt()
  7641. return nil
  7642. case messagerecords.FieldBotWxid:
  7643. m.ResetBotWxid()
  7644. return nil
  7645. case messagerecords.FieldContactID:
  7646. m.ResetContactID()
  7647. return nil
  7648. case messagerecords.FieldContactType:
  7649. m.ResetContactType()
  7650. return nil
  7651. case messagerecords.FieldContactWxid:
  7652. m.ResetContactWxid()
  7653. return nil
  7654. case messagerecords.FieldContentType:
  7655. m.ResetContentType()
  7656. return nil
  7657. case messagerecords.FieldContent:
  7658. m.ResetContent()
  7659. return nil
  7660. case messagerecords.FieldMeta:
  7661. m.ResetMeta()
  7662. return nil
  7663. case messagerecords.FieldErrorDetail:
  7664. m.ResetErrorDetail()
  7665. return nil
  7666. case messagerecords.FieldSendTime:
  7667. m.ResetSendTime()
  7668. return nil
  7669. case messagerecords.FieldSourceType:
  7670. m.ResetSourceType()
  7671. return nil
  7672. case messagerecords.FieldSourceID:
  7673. m.ResetSourceID()
  7674. return nil
  7675. case messagerecords.FieldSubSourceID:
  7676. m.ResetSubSourceID()
  7677. return nil
  7678. case messagerecords.FieldOrganizationID:
  7679. m.ResetOrganizationID()
  7680. return nil
  7681. }
  7682. return fmt.Errorf("unknown MessageRecords field %s", name)
  7683. }
  7684. // AddedEdges returns all edge names that were set/added in this mutation.
  7685. func (m *MessageRecordsMutation) AddedEdges() []string {
  7686. edges := make([]string, 0, 3)
  7687. if m.sop_stage != nil {
  7688. edges = append(edges, messagerecords.EdgeSopStage)
  7689. }
  7690. if m.sop_node != nil {
  7691. edges = append(edges, messagerecords.EdgeSopNode)
  7692. }
  7693. if m.message_contact != nil {
  7694. edges = append(edges, messagerecords.EdgeMessageContact)
  7695. }
  7696. return edges
  7697. }
  7698. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7699. // name in this mutation.
  7700. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  7701. switch name {
  7702. case messagerecords.EdgeSopStage:
  7703. if id := m.sop_stage; id != nil {
  7704. return []ent.Value{*id}
  7705. }
  7706. case messagerecords.EdgeSopNode:
  7707. if id := m.sop_node; id != nil {
  7708. return []ent.Value{*id}
  7709. }
  7710. case messagerecords.EdgeMessageContact:
  7711. if id := m.message_contact; id != nil {
  7712. return []ent.Value{*id}
  7713. }
  7714. }
  7715. return nil
  7716. }
  7717. // RemovedEdges returns all edge names that were removed in this mutation.
  7718. func (m *MessageRecordsMutation) RemovedEdges() []string {
  7719. edges := make([]string, 0, 3)
  7720. return edges
  7721. }
  7722. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7723. // the given name in this mutation.
  7724. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  7725. return nil
  7726. }
  7727. // ClearedEdges returns all edge names that were cleared in this mutation.
  7728. func (m *MessageRecordsMutation) ClearedEdges() []string {
  7729. edges := make([]string, 0, 3)
  7730. if m.clearedsop_stage {
  7731. edges = append(edges, messagerecords.EdgeSopStage)
  7732. }
  7733. if m.clearedsop_node {
  7734. edges = append(edges, messagerecords.EdgeSopNode)
  7735. }
  7736. if m.clearedmessage_contact {
  7737. edges = append(edges, messagerecords.EdgeMessageContact)
  7738. }
  7739. return edges
  7740. }
  7741. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7742. // was cleared in this mutation.
  7743. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  7744. switch name {
  7745. case messagerecords.EdgeSopStage:
  7746. return m.clearedsop_stage
  7747. case messagerecords.EdgeSopNode:
  7748. return m.clearedsop_node
  7749. case messagerecords.EdgeMessageContact:
  7750. return m.clearedmessage_contact
  7751. }
  7752. return false
  7753. }
  7754. // ClearEdge clears the value of the edge with the given name. It returns an error
  7755. // if that edge is not defined in the schema.
  7756. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  7757. switch name {
  7758. case messagerecords.EdgeSopStage:
  7759. m.ClearSopStage()
  7760. return nil
  7761. case messagerecords.EdgeSopNode:
  7762. m.ClearSopNode()
  7763. return nil
  7764. case messagerecords.EdgeMessageContact:
  7765. m.ClearMessageContact()
  7766. return nil
  7767. }
  7768. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  7769. }
  7770. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7771. // It returns an error if the edge is not defined in the schema.
  7772. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  7773. switch name {
  7774. case messagerecords.EdgeSopStage:
  7775. m.ResetSopStage()
  7776. return nil
  7777. case messagerecords.EdgeSopNode:
  7778. m.ResetSopNode()
  7779. return nil
  7780. case messagerecords.EdgeMessageContact:
  7781. m.ResetMessageContact()
  7782. return nil
  7783. }
  7784. return fmt.Errorf("unknown MessageRecords edge %s", name)
  7785. }
  7786. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  7787. type MsgMutation struct {
  7788. config
  7789. op Op
  7790. typ string
  7791. id *uint64
  7792. created_at *time.Time
  7793. updated_at *time.Time
  7794. deleted_at *time.Time
  7795. status *uint8
  7796. addstatus *int8
  7797. fromwxid *string
  7798. toid *string
  7799. msgtype *int32
  7800. addmsgtype *int32
  7801. msg *string
  7802. batch_no *string
  7803. clearedFields map[string]struct{}
  7804. done bool
  7805. oldValue func(context.Context) (*Msg, error)
  7806. predicates []predicate.Msg
  7807. }
  7808. var _ ent.Mutation = (*MsgMutation)(nil)
  7809. // msgOption allows management of the mutation configuration using functional options.
  7810. type msgOption func(*MsgMutation)
  7811. // newMsgMutation creates new mutation for the Msg entity.
  7812. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  7813. m := &MsgMutation{
  7814. config: c,
  7815. op: op,
  7816. typ: TypeMsg,
  7817. clearedFields: make(map[string]struct{}),
  7818. }
  7819. for _, opt := range opts {
  7820. opt(m)
  7821. }
  7822. return m
  7823. }
  7824. // withMsgID sets the ID field of the mutation.
  7825. func withMsgID(id uint64) msgOption {
  7826. return func(m *MsgMutation) {
  7827. var (
  7828. err error
  7829. once sync.Once
  7830. value *Msg
  7831. )
  7832. m.oldValue = func(ctx context.Context) (*Msg, error) {
  7833. once.Do(func() {
  7834. if m.done {
  7835. err = errors.New("querying old values post mutation is not allowed")
  7836. } else {
  7837. value, err = m.Client().Msg.Get(ctx, id)
  7838. }
  7839. })
  7840. return value, err
  7841. }
  7842. m.id = &id
  7843. }
  7844. }
  7845. // withMsg sets the old Msg of the mutation.
  7846. func withMsg(node *Msg) msgOption {
  7847. return func(m *MsgMutation) {
  7848. m.oldValue = func(context.Context) (*Msg, error) {
  7849. return node, nil
  7850. }
  7851. m.id = &node.ID
  7852. }
  7853. }
  7854. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7855. // executed in a transaction (ent.Tx), a transactional client is returned.
  7856. func (m MsgMutation) Client() *Client {
  7857. client := &Client{config: m.config}
  7858. client.init()
  7859. return client
  7860. }
  7861. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7862. // it returns an error otherwise.
  7863. func (m MsgMutation) Tx() (*Tx, error) {
  7864. if _, ok := m.driver.(*txDriver); !ok {
  7865. return nil, errors.New("ent: mutation is not running in a transaction")
  7866. }
  7867. tx := &Tx{config: m.config}
  7868. tx.init()
  7869. return tx, nil
  7870. }
  7871. // SetID sets the value of the id field. Note that this
  7872. // operation is only accepted on creation of Msg entities.
  7873. func (m *MsgMutation) SetID(id uint64) {
  7874. m.id = &id
  7875. }
  7876. // ID returns the ID value in the mutation. Note that the ID is only available
  7877. // if it was provided to the builder or after it was returned from the database.
  7878. func (m *MsgMutation) ID() (id uint64, exists bool) {
  7879. if m.id == nil {
  7880. return
  7881. }
  7882. return *m.id, true
  7883. }
  7884. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7885. // That means, if the mutation is applied within a transaction with an isolation level such
  7886. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7887. // or updated by the mutation.
  7888. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  7889. switch {
  7890. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7891. id, exists := m.ID()
  7892. if exists {
  7893. return []uint64{id}, nil
  7894. }
  7895. fallthrough
  7896. case m.op.Is(OpUpdate | OpDelete):
  7897. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  7898. default:
  7899. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7900. }
  7901. }
  7902. // SetCreatedAt sets the "created_at" field.
  7903. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  7904. m.created_at = &t
  7905. }
  7906. // CreatedAt returns the value of the "created_at" field in the mutation.
  7907. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  7908. v := m.created_at
  7909. if v == nil {
  7910. return
  7911. }
  7912. return *v, true
  7913. }
  7914. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  7915. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  7916. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7917. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7918. if !m.op.Is(OpUpdateOne) {
  7919. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7920. }
  7921. if m.id == nil || m.oldValue == nil {
  7922. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7923. }
  7924. oldValue, err := m.oldValue(ctx)
  7925. if err != nil {
  7926. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7927. }
  7928. return oldValue.CreatedAt, nil
  7929. }
  7930. // ResetCreatedAt resets all changes to the "created_at" field.
  7931. func (m *MsgMutation) ResetCreatedAt() {
  7932. m.created_at = nil
  7933. }
  7934. // SetUpdatedAt sets the "updated_at" field.
  7935. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  7936. m.updated_at = &t
  7937. }
  7938. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7939. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  7940. v := m.updated_at
  7941. if v == nil {
  7942. return
  7943. }
  7944. return *v, true
  7945. }
  7946. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  7947. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  7948. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7949. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7950. if !m.op.Is(OpUpdateOne) {
  7951. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7952. }
  7953. if m.id == nil || m.oldValue == nil {
  7954. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7955. }
  7956. oldValue, err := m.oldValue(ctx)
  7957. if err != nil {
  7958. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7959. }
  7960. return oldValue.UpdatedAt, nil
  7961. }
  7962. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7963. func (m *MsgMutation) ResetUpdatedAt() {
  7964. m.updated_at = nil
  7965. }
  7966. // SetDeletedAt sets the "deleted_at" field.
  7967. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  7968. m.deleted_at = &t
  7969. }
  7970. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7971. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  7972. v := m.deleted_at
  7973. if v == nil {
  7974. return
  7975. }
  7976. return *v, true
  7977. }
  7978. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  7979. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  7980. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7981. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7982. if !m.op.Is(OpUpdateOne) {
  7983. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7984. }
  7985. if m.id == nil || m.oldValue == nil {
  7986. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7987. }
  7988. oldValue, err := m.oldValue(ctx)
  7989. if err != nil {
  7990. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7991. }
  7992. return oldValue.DeletedAt, nil
  7993. }
  7994. // ClearDeletedAt clears the value of the "deleted_at" field.
  7995. func (m *MsgMutation) ClearDeletedAt() {
  7996. m.deleted_at = nil
  7997. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  7998. }
  7999. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8000. func (m *MsgMutation) DeletedAtCleared() bool {
  8001. _, ok := m.clearedFields[msg.FieldDeletedAt]
  8002. return ok
  8003. }
  8004. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8005. func (m *MsgMutation) ResetDeletedAt() {
  8006. m.deleted_at = nil
  8007. delete(m.clearedFields, msg.FieldDeletedAt)
  8008. }
  8009. // SetStatus sets the "status" field.
  8010. func (m *MsgMutation) SetStatus(u uint8) {
  8011. m.status = &u
  8012. m.addstatus = nil
  8013. }
  8014. // Status returns the value of the "status" field in the mutation.
  8015. func (m *MsgMutation) Status() (r uint8, exists bool) {
  8016. v := m.status
  8017. if v == nil {
  8018. return
  8019. }
  8020. return *v, true
  8021. }
  8022. // OldStatus returns the old "status" field's value of the Msg entity.
  8023. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  8024. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8025. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  8026. if !m.op.Is(OpUpdateOne) {
  8027. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  8028. }
  8029. if m.id == nil || m.oldValue == nil {
  8030. return v, errors.New("OldStatus requires an ID field in the mutation")
  8031. }
  8032. oldValue, err := m.oldValue(ctx)
  8033. if err != nil {
  8034. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  8035. }
  8036. return oldValue.Status, nil
  8037. }
  8038. // AddStatus adds u to the "status" field.
  8039. func (m *MsgMutation) AddStatus(u int8) {
  8040. if m.addstatus != nil {
  8041. *m.addstatus += u
  8042. } else {
  8043. m.addstatus = &u
  8044. }
  8045. }
  8046. // AddedStatus returns the value that was added to the "status" field in this mutation.
  8047. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  8048. v := m.addstatus
  8049. if v == nil {
  8050. return
  8051. }
  8052. return *v, true
  8053. }
  8054. // ClearStatus clears the value of the "status" field.
  8055. func (m *MsgMutation) ClearStatus() {
  8056. m.status = nil
  8057. m.addstatus = nil
  8058. m.clearedFields[msg.FieldStatus] = struct{}{}
  8059. }
  8060. // StatusCleared returns if the "status" field was cleared in this mutation.
  8061. func (m *MsgMutation) StatusCleared() bool {
  8062. _, ok := m.clearedFields[msg.FieldStatus]
  8063. return ok
  8064. }
  8065. // ResetStatus resets all changes to the "status" field.
  8066. func (m *MsgMutation) ResetStatus() {
  8067. m.status = nil
  8068. m.addstatus = nil
  8069. delete(m.clearedFields, msg.FieldStatus)
  8070. }
  8071. // SetFromwxid sets the "fromwxid" field.
  8072. func (m *MsgMutation) SetFromwxid(s string) {
  8073. m.fromwxid = &s
  8074. }
  8075. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  8076. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  8077. v := m.fromwxid
  8078. if v == nil {
  8079. return
  8080. }
  8081. return *v, true
  8082. }
  8083. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  8084. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  8085. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8086. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  8087. if !m.op.Is(OpUpdateOne) {
  8088. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  8089. }
  8090. if m.id == nil || m.oldValue == nil {
  8091. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  8092. }
  8093. oldValue, err := m.oldValue(ctx)
  8094. if err != nil {
  8095. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  8096. }
  8097. return oldValue.Fromwxid, nil
  8098. }
  8099. // ClearFromwxid clears the value of the "fromwxid" field.
  8100. func (m *MsgMutation) ClearFromwxid() {
  8101. m.fromwxid = nil
  8102. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  8103. }
  8104. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  8105. func (m *MsgMutation) FromwxidCleared() bool {
  8106. _, ok := m.clearedFields[msg.FieldFromwxid]
  8107. return ok
  8108. }
  8109. // ResetFromwxid resets all changes to the "fromwxid" field.
  8110. func (m *MsgMutation) ResetFromwxid() {
  8111. m.fromwxid = nil
  8112. delete(m.clearedFields, msg.FieldFromwxid)
  8113. }
  8114. // SetToid sets the "toid" field.
  8115. func (m *MsgMutation) SetToid(s string) {
  8116. m.toid = &s
  8117. }
  8118. // Toid returns the value of the "toid" field in the mutation.
  8119. func (m *MsgMutation) Toid() (r string, exists bool) {
  8120. v := m.toid
  8121. if v == nil {
  8122. return
  8123. }
  8124. return *v, true
  8125. }
  8126. // OldToid returns the old "toid" field's value of the Msg entity.
  8127. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  8128. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8129. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  8130. if !m.op.Is(OpUpdateOne) {
  8131. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  8132. }
  8133. if m.id == nil || m.oldValue == nil {
  8134. return v, errors.New("OldToid requires an ID field in the mutation")
  8135. }
  8136. oldValue, err := m.oldValue(ctx)
  8137. if err != nil {
  8138. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  8139. }
  8140. return oldValue.Toid, nil
  8141. }
  8142. // ClearToid clears the value of the "toid" field.
  8143. func (m *MsgMutation) ClearToid() {
  8144. m.toid = nil
  8145. m.clearedFields[msg.FieldToid] = struct{}{}
  8146. }
  8147. // ToidCleared returns if the "toid" field was cleared in this mutation.
  8148. func (m *MsgMutation) ToidCleared() bool {
  8149. _, ok := m.clearedFields[msg.FieldToid]
  8150. return ok
  8151. }
  8152. // ResetToid resets all changes to the "toid" field.
  8153. func (m *MsgMutation) ResetToid() {
  8154. m.toid = nil
  8155. delete(m.clearedFields, msg.FieldToid)
  8156. }
  8157. // SetMsgtype sets the "msgtype" field.
  8158. func (m *MsgMutation) SetMsgtype(i int32) {
  8159. m.msgtype = &i
  8160. m.addmsgtype = nil
  8161. }
  8162. // Msgtype returns the value of the "msgtype" field in the mutation.
  8163. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  8164. v := m.msgtype
  8165. if v == nil {
  8166. return
  8167. }
  8168. return *v, true
  8169. }
  8170. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  8171. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  8172. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8173. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  8174. if !m.op.Is(OpUpdateOne) {
  8175. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  8176. }
  8177. if m.id == nil || m.oldValue == nil {
  8178. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  8179. }
  8180. oldValue, err := m.oldValue(ctx)
  8181. if err != nil {
  8182. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  8183. }
  8184. return oldValue.Msgtype, nil
  8185. }
  8186. // AddMsgtype adds i to the "msgtype" field.
  8187. func (m *MsgMutation) AddMsgtype(i int32) {
  8188. if m.addmsgtype != nil {
  8189. *m.addmsgtype += i
  8190. } else {
  8191. m.addmsgtype = &i
  8192. }
  8193. }
  8194. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  8195. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  8196. v := m.addmsgtype
  8197. if v == nil {
  8198. return
  8199. }
  8200. return *v, true
  8201. }
  8202. // ClearMsgtype clears the value of the "msgtype" field.
  8203. func (m *MsgMutation) ClearMsgtype() {
  8204. m.msgtype = nil
  8205. m.addmsgtype = nil
  8206. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  8207. }
  8208. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  8209. func (m *MsgMutation) MsgtypeCleared() bool {
  8210. _, ok := m.clearedFields[msg.FieldMsgtype]
  8211. return ok
  8212. }
  8213. // ResetMsgtype resets all changes to the "msgtype" field.
  8214. func (m *MsgMutation) ResetMsgtype() {
  8215. m.msgtype = nil
  8216. m.addmsgtype = nil
  8217. delete(m.clearedFields, msg.FieldMsgtype)
  8218. }
  8219. // SetMsg sets the "msg" field.
  8220. func (m *MsgMutation) SetMsg(s string) {
  8221. m.msg = &s
  8222. }
  8223. // Msg returns the value of the "msg" field in the mutation.
  8224. func (m *MsgMutation) Msg() (r string, exists bool) {
  8225. v := m.msg
  8226. if v == nil {
  8227. return
  8228. }
  8229. return *v, true
  8230. }
  8231. // OldMsg returns the old "msg" field's value of the Msg entity.
  8232. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  8233. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8234. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  8235. if !m.op.Is(OpUpdateOne) {
  8236. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  8237. }
  8238. if m.id == nil || m.oldValue == nil {
  8239. return v, errors.New("OldMsg requires an ID field in the mutation")
  8240. }
  8241. oldValue, err := m.oldValue(ctx)
  8242. if err != nil {
  8243. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  8244. }
  8245. return oldValue.Msg, nil
  8246. }
  8247. // ClearMsg clears the value of the "msg" field.
  8248. func (m *MsgMutation) ClearMsg() {
  8249. m.msg = nil
  8250. m.clearedFields[msg.FieldMsg] = struct{}{}
  8251. }
  8252. // MsgCleared returns if the "msg" field was cleared in this mutation.
  8253. func (m *MsgMutation) MsgCleared() bool {
  8254. _, ok := m.clearedFields[msg.FieldMsg]
  8255. return ok
  8256. }
  8257. // ResetMsg resets all changes to the "msg" field.
  8258. func (m *MsgMutation) ResetMsg() {
  8259. m.msg = nil
  8260. delete(m.clearedFields, msg.FieldMsg)
  8261. }
  8262. // SetBatchNo sets the "batch_no" field.
  8263. func (m *MsgMutation) SetBatchNo(s string) {
  8264. m.batch_no = &s
  8265. }
  8266. // BatchNo returns the value of the "batch_no" field in the mutation.
  8267. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  8268. v := m.batch_no
  8269. if v == nil {
  8270. return
  8271. }
  8272. return *v, true
  8273. }
  8274. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  8275. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  8276. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8277. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  8278. if !m.op.Is(OpUpdateOne) {
  8279. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  8280. }
  8281. if m.id == nil || m.oldValue == nil {
  8282. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  8283. }
  8284. oldValue, err := m.oldValue(ctx)
  8285. if err != nil {
  8286. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  8287. }
  8288. return oldValue.BatchNo, nil
  8289. }
  8290. // ClearBatchNo clears the value of the "batch_no" field.
  8291. func (m *MsgMutation) ClearBatchNo() {
  8292. m.batch_no = nil
  8293. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  8294. }
  8295. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  8296. func (m *MsgMutation) BatchNoCleared() bool {
  8297. _, ok := m.clearedFields[msg.FieldBatchNo]
  8298. return ok
  8299. }
  8300. // ResetBatchNo resets all changes to the "batch_no" field.
  8301. func (m *MsgMutation) ResetBatchNo() {
  8302. m.batch_no = nil
  8303. delete(m.clearedFields, msg.FieldBatchNo)
  8304. }
  8305. // Where appends a list predicates to the MsgMutation builder.
  8306. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  8307. m.predicates = append(m.predicates, ps...)
  8308. }
  8309. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  8310. // users can use type-assertion to append predicates that do not depend on any generated package.
  8311. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  8312. p := make([]predicate.Msg, len(ps))
  8313. for i := range ps {
  8314. p[i] = ps[i]
  8315. }
  8316. m.Where(p...)
  8317. }
  8318. // Op returns the operation name.
  8319. func (m *MsgMutation) Op() Op {
  8320. return m.op
  8321. }
  8322. // SetOp allows setting the mutation operation.
  8323. func (m *MsgMutation) SetOp(op Op) {
  8324. m.op = op
  8325. }
  8326. // Type returns the node type of this mutation (Msg).
  8327. func (m *MsgMutation) Type() string {
  8328. return m.typ
  8329. }
  8330. // Fields returns all fields that were changed during this mutation. Note that in
  8331. // order to get all numeric fields that were incremented/decremented, call
  8332. // AddedFields().
  8333. func (m *MsgMutation) Fields() []string {
  8334. fields := make([]string, 0, 9)
  8335. if m.created_at != nil {
  8336. fields = append(fields, msg.FieldCreatedAt)
  8337. }
  8338. if m.updated_at != nil {
  8339. fields = append(fields, msg.FieldUpdatedAt)
  8340. }
  8341. if m.deleted_at != nil {
  8342. fields = append(fields, msg.FieldDeletedAt)
  8343. }
  8344. if m.status != nil {
  8345. fields = append(fields, msg.FieldStatus)
  8346. }
  8347. if m.fromwxid != nil {
  8348. fields = append(fields, msg.FieldFromwxid)
  8349. }
  8350. if m.toid != nil {
  8351. fields = append(fields, msg.FieldToid)
  8352. }
  8353. if m.msgtype != nil {
  8354. fields = append(fields, msg.FieldMsgtype)
  8355. }
  8356. if m.msg != nil {
  8357. fields = append(fields, msg.FieldMsg)
  8358. }
  8359. if m.batch_no != nil {
  8360. fields = append(fields, msg.FieldBatchNo)
  8361. }
  8362. return fields
  8363. }
  8364. // Field returns the value of a field with the given name. The second boolean
  8365. // return value indicates that this field was not set, or was not defined in the
  8366. // schema.
  8367. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  8368. switch name {
  8369. case msg.FieldCreatedAt:
  8370. return m.CreatedAt()
  8371. case msg.FieldUpdatedAt:
  8372. return m.UpdatedAt()
  8373. case msg.FieldDeletedAt:
  8374. return m.DeletedAt()
  8375. case msg.FieldStatus:
  8376. return m.Status()
  8377. case msg.FieldFromwxid:
  8378. return m.Fromwxid()
  8379. case msg.FieldToid:
  8380. return m.Toid()
  8381. case msg.FieldMsgtype:
  8382. return m.Msgtype()
  8383. case msg.FieldMsg:
  8384. return m.Msg()
  8385. case msg.FieldBatchNo:
  8386. return m.BatchNo()
  8387. }
  8388. return nil, false
  8389. }
  8390. // OldField returns the old value of the field from the database. An error is
  8391. // returned if the mutation operation is not UpdateOne, or the query to the
  8392. // database failed.
  8393. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8394. switch name {
  8395. case msg.FieldCreatedAt:
  8396. return m.OldCreatedAt(ctx)
  8397. case msg.FieldUpdatedAt:
  8398. return m.OldUpdatedAt(ctx)
  8399. case msg.FieldDeletedAt:
  8400. return m.OldDeletedAt(ctx)
  8401. case msg.FieldStatus:
  8402. return m.OldStatus(ctx)
  8403. case msg.FieldFromwxid:
  8404. return m.OldFromwxid(ctx)
  8405. case msg.FieldToid:
  8406. return m.OldToid(ctx)
  8407. case msg.FieldMsgtype:
  8408. return m.OldMsgtype(ctx)
  8409. case msg.FieldMsg:
  8410. return m.OldMsg(ctx)
  8411. case msg.FieldBatchNo:
  8412. return m.OldBatchNo(ctx)
  8413. }
  8414. return nil, fmt.Errorf("unknown Msg field %s", name)
  8415. }
  8416. // SetField sets the value of a field with the given name. It returns an error if
  8417. // the field is not defined in the schema, or if the type mismatched the field
  8418. // type.
  8419. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  8420. switch name {
  8421. case msg.FieldCreatedAt:
  8422. v, ok := value.(time.Time)
  8423. if !ok {
  8424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8425. }
  8426. m.SetCreatedAt(v)
  8427. return nil
  8428. case msg.FieldUpdatedAt:
  8429. v, ok := value.(time.Time)
  8430. if !ok {
  8431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8432. }
  8433. m.SetUpdatedAt(v)
  8434. return nil
  8435. case msg.FieldDeletedAt:
  8436. v, ok := value.(time.Time)
  8437. if !ok {
  8438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8439. }
  8440. m.SetDeletedAt(v)
  8441. return nil
  8442. case msg.FieldStatus:
  8443. v, ok := value.(uint8)
  8444. if !ok {
  8445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8446. }
  8447. m.SetStatus(v)
  8448. return nil
  8449. case msg.FieldFromwxid:
  8450. v, ok := value.(string)
  8451. if !ok {
  8452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8453. }
  8454. m.SetFromwxid(v)
  8455. return nil
  8456. case msg.FieldToid:
  8457. v, ok := value.(string)
  8458. if !ok {
  8459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8460. }
  8461. m.SetToid(v)
  8462. return nil
  8463. case msg.FieldMsgtype:
  8464. v, ok := value.(int32)
  8465. if !ok {
  8466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8467. }
  8468. m.SetMsgtype(v)
  8469. return nil
  8470. case msg.FieldMsg:
  8471. v, ok := value.(string)
  8472. if !ok {
  8473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8474. }
  8475. m.SetMsg(v)
  8476. return nil
  8477. case msg.FieldBatchNo:
  8478. v, ok := value.(string)
  8479. if !ok {
  8480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8481. }
  8482. m.SetBatchNo(v)
  8483. return nil
  8484. }
  8485. return fmt.Errorf("unknown Msg field %s", name)
  8486. }
  8487. // AddedFields returns all numeric fields that were incremented/decremented during
  8488. // this mutation.
  8489. func (m *MsgMutation) AddedFields() []string {
  8490. var fields []string
  8491. if m.addstatus != nil {
  8492. fields = append(fields, msg.FieldStatus)
  8493. }
  8494. if m.addmsgtype != nil {
  8495. fields = append(fields, msg.FieldMsgtype)
  8496. }
  8497. return fields
  8498. }
  8499. // AddedField returns the numeric value that was incremented/decremented on a field
  8500. // with the given name. The second boolean return value indicates that this field
  8501. // was not set, or was not defined in the schema.
  8502. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  8503. switch name {
  8504. case msg.FieldStatus:
  8505. return m.AddedStatus()
  8506. case msg.FieldMsgtype:
  8507. return m.AddedMsgtype()
  8508. }
  8509. return nil, false
  8510. }
  8511. // AddField adds the value to the field with the given name. It returns an error if
  8512. // the field is not defined in the schema, or if the type mismatched the field
  8513. // type.
  8514. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  8515. switch name {
  8516. case msg.FieldStatus:
  8517. v, ok := value.(int8)
  8518. if !ok {
  8519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8520. }
  8521. m.AddStatus(v)
  8522. return nil
  8523. case msg.FieldMsgtype:
  8524. v, ok := value.(int32)
  8525. if !ok {
  8526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8527. }
  8528. m.AddMsgtype(v)
  8529. return nil
  8530. }
  8531. return fmt.Errorf("unknown Msg numeric field %s", name)
  8532. }
  8533. // ClearedFields returns all nullable fields that were cleared during this
  8534. // mutation.
  8535. func (m *MsgMutation) ClearedFields() []string {
  8536. var fields []string
  8537. if m.FieldCleared(msg.FieldDeletedAt) {
  8538. fields = append(fields, msg.FieldDeletedAt)
  8539. }
  8540. if m.FieldCleared(msg.FieldStatus) {
  8541. fields = append(fields, msg.FieldStatus)
  8542. }
  8543. if m.FieldCleared(msg.FieldFromwxid) {
  8544. fields = append(fields, msg.FieldFromwxid)
  8545. }
  8546. if m.FieldCleared(msg.FieldToid) {
  8547. fields = append(fields, msg.FieldToid)
  8548. }
  8549. if m.FieldCleared(msg.FieldMsgtype) {
  8550. fields = append(fields, msg.FieldMsgtype)
  8551. }
  8552. if m.FieldCleared(msg.FieldMsg) {
  8553. fields = append(fields, msg.FieldMsg)
  8554. }
  8555. if m.FieldCleared(msg.FieldBatchNo) {
  8556. fields = append(fields, msg.FieldBatchNo)
  8557. }
  8558. return fields
  8559. }
  8560. // FieldCleared returns a boolean indicating if a field with the given name was
  8561. // cleared in this mutation.
  8562. func (m *MsgMutation) FieldCleared(name string) bool {
  8563. _, ok := m.clearedFields[name]
  8564. return ok
  8565. }
  8566. // ClearField clears the value of the field with the given name. It returns an
  8567. // error if the field is not defined in the schema.
  8568. func (m *MsgMutation) ClearField(name string) error {
  8569. switch name {
  8570. case msg.FieldDeletedAt:
  8571. m.ClearDeletedAt()
  8572. return nil
  8573. case msg.FieldStatus:
  8574. m.ClearStatus()
  8575. return nil
  8576. case msg.FieldFromwxid:
  8577. m.ClearFromwxid()
  8578. return nil
  8579. case msg.FieldToid:
  8580. m.ClearToid()
  8581. return nil
  8582. case msg.FieldMsgtype:
  8583. m.ClearMsgtype()
  8584. return nil
  8585. case msg.FieldMsg:
  8586. m.ClearMsg()
  8587. return nil
  8588. case msg.FieldBatchNo:
  8589. m.ClearBatchNo()
  8590. return nil
  8591. }
  8592. return fmt.Errorf("unknown Msg nullable field %s", name)
  8593. }
  8594. // ResetField resets all changes in the mutation for the field with the given name.
  8595. // It returns an error if the field is not defined in the schema.
  8596. func (m *MsgMutation) ResetField(name string) error {
  8597. switch name {
  8598. case msg.FieldCreatedAt:
  8599. m.ResetCreatedAt()
  8600. return nil
  8601. case msg.FieldUpdatedAt:
  8602. m.ResetUpdatedAt()
  8603. return nil
  8604. case msg.FieldDeletedAt:
  8605. m.ResetDeletedAt()
  8606. return nil
  8607. case msg.FieldStatus:
  8608. m.ResetStatus()
  8609. return nil
  8610. case msg.FieldFromwxid:
  8611. m.ResetFromwxid()
  8612. return nil
  8613. case msg.FieldToid:
  8614. m.ResetToid()
  8615. return nil
  8616. case msg.FieldMsgtype:
  8617. m.ResetMsgtype()
  8618. return nil
  8619. case msg.FieldMsg:
  8620. m.ResetMsg()
  8621. return nil
  8622. case msg.FieldBatchNo:
  8623. m.ResetBatchNo()
  8624. return nil
  8625. }
  8626. return fmt.Errorf("unknown Msg field %s", name)
  8627. }
  8628. // AddedEdges returns all edge names that were set/added in this mutation.
  8629. func (m *MsgMutation) AddedEdges() []string {
  8630. edges := make([]string, 0, 0)
  8631. return edges
  8632. }
  8633. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8634. // name in this mutation.
  8635. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  8636. return nil
  8637. }
  8638. // RemovedEdges returns all edge names that were removed in this mutation.
  8639. func (m *MsgMutation) RemovedEdges() []string {
  8640. edges := make([]string, 0, 0)
  8641. return edges
  8642. }
  8643. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8644. // the given name in this mutation.
  8645. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  8646. return nil
  8647. }
  8648. // ClearedEdges returns all edge names that were cleared in this mutation.
  8649. func (m *MsgMutation) ClearedEdges() []string {
  8650. edges := make([]string, 0, 0)
  8651. return edges
  8652. }
  8653. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8654. // was cleared in this mutation.
  8655. func (m *MsgMutation) EdgeCleared(name string) bool {
  8656. return false
  8657. }
  8658. // ClearEdge clears the value of the edge with the given name. It returns an error
  8659. // if that edge is not defined in the schema.
  8660. func (m *MsgMutation) ClearEdge(name string) error {
  8661. return fmt.Errorf("unknown Msg unique edge %s", name)
  8662. }
  8663. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8664. // It returns an error if the edge is not defined in the schema.
  8665. func (m *MsgMutation) ResetEdge(name string) error {
  8666. return fmt.Errorf("unknown Msg edge %s", name)
  8667. }
  8668. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  8669. type ServerMutation struct {
  8670. config
  8671. op Op
  8672. typ string
  8673. id *uint64
  8674. created_at *time.Time
  8675. updated_at *time.Time
  8676. status *uint8
  8677. addstatus *int8
  8678. deleted_at *time.Time
  8679. name *string
  8680. public_ip *string
  8681. private_ip *string
  8682. admin_port *string
  8683. clearedFields map[string]struct{}
  8684. wxs map[uint64]struct{}
  8685. removedwxs map[uint64]struct{}
  8686. clearedwxs bool
  8687. done bool
  8688. oldValue func(context.Context) (*Server, error)
  8689. predicates []predicate.Server
  8690. }
  8691. var _ ent.Mutation = (*ServerMutation)(nil)
  8692. // serverOption allows management of the mutation configuration using functional options.
  8693. type serverOption func(*ServerMutation)
  8694. // newServerMutation creates new mutation for the Server entity.
  8695. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  8696. m := &ServerMutation{
  8697. config: c,
  8698. op: op,
  8699. typ: TypeServer,
  8700. clearedFields: make(map[string]struct{}),
  8701. }
  8702. for _, opt := range opts {
  8703. opt(m)
  8704. }
  8705. return m
  8706. }
  8707. // withServerID sets the ID field of the mutation.
  8708. func withServerID(id uint64) serverOption {
  8709. return func(m *ServerMutation) {
  8710. var (
  8711. err error
  8712. once sync.Once
  8713. value *Server
  8714. )
  8715. m.oldValue = func(ctx context.Context) (*Server, error) {
  8716. once.Do(func() {
  8717. if m.done {
  8718. err = errors.New("querying old values post mutation is not allowed")
  8719. } else {
  8720. value, err = m.Client().Server.Get(ctx, id)
  8721. }
  8722. })
  8723. return value, err
  8724. }
  8725. m.id = &id
  8726. }
  8727. }
  8728. // withServer sets the old Server of the mutation.
  8729. func withServer(node *Server) serverOption {
  8730. return func(m *ServerMutation) {
  8731. m.oldValue = func(context.Context) (*Server, error) {
  8732. return node, nil
  8733. }
  8734. m.id = &node.ID
  8735. }
  8736. }
  8737. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8738. // executed in a transaction (ent.Tx), a transactional client is returned.
  8739. func (m ServerMutation) Client() *Client {
  8740. client := &Client{config: m.config}
  8741. client.init()
  8742. return client
  8743. }
  8744. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8745. // it returns an error otherwise.
  8746. func (m ServerMutation) Tx() (*Tx, error) {
  8747. if _, ok := m.driver.(*txDriver); !ok {
  8748. return nil, errors.New("ent: mutation is not running in a transaction")
  8749. }
  8750. tx := &Tx{config: m.config}
  8751. tx.init()
  8752. return tx, nil
  8753. }
  8754. // SetID sets the value of the id field. Note that this
  8755. // operation is only accepted on creation of Server entities.
  8756. func (m *ServerMutation) SetID(id uint64) {
  8757. m.id = &id
  8758. }
  8759. // ID returns the ID value in the mutation. Note that the ID is only available
  8760. // if it was provided to the builder or after it was returned from the database.
  8761. func (m *ServerMutation) ID() (id uint64, exists bool) {
  8762. if m.id == nil {
  8763. return
  8764. }
  8765. return *m.id, true
  8766. }
  8767. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8768. // That means, if the mutation is applied within a transaction with an isolation level such
  8769. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8770. // or updated by the mutation.
  8771. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  8772. switch {
  8773. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8774. id, exists := m.ID()
  8775. if exists {
  8776. return []uint64{id}, nil
  8777. }
  8778. fallthrough
  8779. case m.op.Is(OpUpdate | OpDelete):
  8780. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  8781. default:
  8782. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8783. }
  8784. }
  8785. // SetCreatedAt sets the "created_at" field.
  8786. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  8787. m.created_at = &t
  8788. }
  8789. // CreatedAt returns the value of the "created_at" field in the mutation.
  8790. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  8791. v := m.created_at
  8792. if v == nil {
  8793. return
  8794. }
  8795. return *v, true
  8796. }
  8797. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  8798. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  8799. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8800. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8801. if !m.op.Is(OpUpdateOne) {
  8802. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8803. }
  8804. if m.id == nil || m.oldValue == nil {
  8805. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8806. }
  8807. oldValue, err := m.oldValue(ctx)
  8808. if err != nil {
  8809. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8810. }
  8811. return oldValue.CreatedAt, nil
  8812. }
  8813. // ResetCreatedAt resets all changes to the "created_at" field.
  8814. func (m *ServerMutation) ResetCreatedAt() {
  8815. m.created_at = nil
  8816. }
  8817. // SetUpdatedAt sets the "updated_at" field.
  8818. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  8819. m.updated_at = &t
  8820. }
  8821. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8822. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  8823. v := m.updated_at
  8824. if v == nil {
  8825. return
  8826. }
  8827. return *v, true
  8828. }
  8829. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  8830. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  8831. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8832. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8833. if !m.op.Is(OpUpdateOne) {
  8834. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8835. }
  8836. if m.id == nil || m.oldValue == nil {
  8837. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8838. }
  8839. oldValue, err := m.oldValue(ctx)
  8840. if err != nil {
  8841. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8842. }
  8843. return oldValue.UpdatedAt, nil
  8844. }
  8845. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8846. func (m *ServerMutation) ResetUpdatedAt() {
  8847. m.updated_at = nil
  8848. }
  8849. // SetStatus sets the "status" field.
  8850. func (m *ServerMutation) SetStatus(u uint8) {
  8851. m.status = &u
  8852. m.addstatus = nil
  8853. }
  8854. // Status returns the value of the "status" field in the mutation.
  8855. func (m *ServerMutation) Status() (r uint8, exists bool) {
  8856. v := m.status
  8857. if v == nil {
  8858. return
  8859. }
  8860. return *v, true
  8861. }
  8862. // OldStatus returns the old "status" field's value of the Server entity.
  8863. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  8864. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8865. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  8866. if !m.op.Is(OpUpdateOne) {
  8867. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  8868. }
  8869. if m.id == nil || m.oldValue == nil {
  8870. return v, errors.New("OldStatus requires an ID field in the mutation")
  8871. }
  8872. oldValue, err := m.oldValue(ctx)
  8873. if err != nil {
  8874. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  8875. }
  8876. return oldValue.Status, nil
  8877. }
  8878. // AddStatus adds u to the "status" field.
  8879. func (m *ServerMutation) AddStatus(u int8) {
  8880. if m.addstatus != nil {
  8881. *m.addstatus += u
  8882. } else {
  8883. m.addstatus = &u
  8884. }
  8885. }
  8886. // AddedStatus returns the value that was added to the "status" field in this mutation.
  8887. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  8888. v := m.addstatus
  8889. if v == nil {
  8890. return
  8891. }
  8892. return *v, true
  8893. }
  8894. // ClearStatus clears the value of the "status" field.
  8895. func (m *ServerMutation) ClearStatus() {
  8896. m.status = nil
  8897. m.addstatus = nil
  8898. m.clearedFields[server.FieldStatus] = struct{}{}
  8899. }
  8900. // StatusCleared returns if the "status" field was cleared in this mutation.
  8901. func (m *ServerMutation) StatusCleared() bool {
  8902. _, ok := m.clearedFields[server.FieldStatus]
  8903. return ok
  8904. }
  8905. // ResetStatus resets all changes to the "status" field.
  8906. func (m *ServerMutation) ResetStatus() {
  8907. m.status = nil
  8908. m.addstatus = nil
  8909. delete(m.clearedFields, server.FieldStatus)
  8910. }
  8911. // SetDeletedAt sets the "deleted_at" field.
  8912. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  8913. m.deleted_at = &t
  8914. }
  8915. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8916. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  8917. v := m.deleted_at
  8918. if v == nil {
  8919. return
  8920. }
  8921. return *v, true
  8922. }
  8923. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  8924. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  8925. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8926. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8927. if !m.op.Is(OpUpdateOne) {
  8928. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8929. }
  8930. if m.id == nil || m.oldValue == nil {
  8931. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8932. }
  8933. oldValue, err := m.oldValue(ctx)
  8934. if err != nil {
  8935. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8936. }
  8937. return oldValue.DeletedAt, nil
  8938. }
  8939. // ClearDeletedAt clears the value of the "deleted_at" field.
  8940. func (m *ServerMutation) ClearDeletedAt() {
  8941. m.deleted_at = nil
  8942. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  8943. }
  8944. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8945. func (m *ServerMutation) DeletedAtCleared() bool {
  8946. _, ok := m.clearedFields[server.FieldDeletedAt]
  8947. return ok
  8948. }
  8949. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8950. func (m *ServerMutation) ResetDeletedAt() {
  8951. m.deleted_at = nil
  8952. delete(m.clearedFields, server.FieldDeletedAt)
  8953. }
  8954. // SetName sets the "name" field.
  8955. func (m *ServerMutation) SetName(s string) {
  8956. m.name = &s
  8957. }
  8958. // Name returns the value of the "name" field in the mutation.
  8959. func (m *ServerMutation) Name() (r string, exists bool) {
  8960. v := m.name
  8961. if v == nil {
  8962. return
  8963. }
  8964. return *v, true
  8965. }
  8966. // OldName returns the old "name" field's value of the Server entity.
  8967. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  8968. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8969. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  8970. if !m.op.Is(OpUpdateOne) {
  8971. return v, errors.New("OldName is only allowed on UpdateOne operations")
  8972. }
  8973. if m.id == nil || m.oldValue == nil {
  8974. return v, errors.New("OldName requires an ID field in the mutation")
  8975. }
  8976. oldValue, err := m.oldValue(ctx)
  8977. if err != nil {
  8978. return v, fmt.Errorf("querying old value for OldName: %w", err)
  8979. }
  8980. return oldValue.Name, nil
  8981. }
  8982. // ResetName resets all changes to the "name" field.
  8983. func (m *ServerMutation) ResetName() {
  8984. m.name = nil
  8985. }
  8986. // SetPublicIP sets the "public_ip" field.
  8987. func (m *ServerMutation) SetPublicIP(s string) {
  8988. m.public_ip = &s
  8989. }
  8990. // PublicIP returns the value of the "public_ip" field in the mutation.
  8991. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  8992. v := m.public_ip
  8993. if v == nil {
  8994. return
  8995. }
  8996. return *v, true
  8997. }
  8998. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  8999. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  9000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9001. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  9002. if !m.op.Is(OpUpdateOne) {
  9003. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  9004. }
  9005. if m.id == nil || m.oldValue == nil {
  9006. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  9007. }
  9008. oldValue, err := m.oldValue(ctx)
  9009. if err != nil {
  9010. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  9011. }
  9012. return oldValue.PublicIP, nil
  9013. }
  9014. // ResetPublicIP resets all changes to the "public_ip" field.
  9015. func (m *ServerMutation) ResetPublicIP() {
  9016. m.public_ip = nil
  9017. }
  9018. // SetPrivateIP sets the "private_ip" field.
  9019. func (m *ServerMutation) SetPrivateIP(s string) {
  9020. m.private_ip = &s
  9021. }
  9022. // PrivateIP returns the value of the "private_ip" field in the mutation.
  9023. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  9024. v := m.private_ip
  9025. if v == nil {
  9026. return
  9027. }
  9028. return *v, true
  9029. }
  9030. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  9031. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  9032. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9033. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  9034. if !m.op.Is(OpUpdateOne) {
  9035. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  9036. }
  9037. if m.id == nil || m.oldValue == nil {
  9038. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  9039. }
  9040. oldValue, err := m.oldValue(ctx)
  9041. if err != nil {
  9042. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  9043. }
  9044. return oldValue.PrivateIP, nil
  9045. }
  9046. // ResetPrivateIP resets all changes to the "private_ip" field.
  9047. func (m *ServerMutation) ResetPrivateIP() {
  9048. m.private_ip = nil
  9049. }
  9050. // SetAdminPort sets the "admin_port" field.
  9051. func (m *ServerMutation) SetAdminPort(s string) {
  9052. m.admin_port = &s
  9053. }
  9054. // AdminPort returns the value of the "admin_port" field in the mutation.
  9055. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  9056. v := m.admin_port
  9057. if v == nil {
  9058. return
  9059. }
  9060. return *v, true
  9061. }
  9062. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  9063. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  9064. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9065. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  9066. if !m.op.Is(OpUpdateOne) {
  9067. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  9068. }
  9069. if m.id == nil || m.oldValue == nil {
  9070. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  9071. }
  9072. oldValue, err := m.oldValue(ctx)
  9073. if err != nil {
  9074. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  9075. }
  9076. return oldValue.AdminPort, nil
  9077. }
  9078. // ResetAdminPort resets all changes to the "admin_port" field.
  9079. func (m *ServerMutation) ResetAdminPort() {
  9080. m.admin_port = nil
  9081. }
  9082. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  9083. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  9084. if m.wxs == nil {
  9085. m.wxs = make(map[uint64]struct{})
  9086. }
  9087. for i := range ids {
  9088. m.wxs[ids[i]] = struct{}{}
  9089. }
  9090. }
  9091. // ClearWxs clears the "wxs" edge to the Wx entity.
  9092. func (m *ServerMutation) ClearWxs() {
  9093. m.clearedwxs = true
  9094. }
  9095. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  9096. func (m *ServerMutation) WxsCleared() bool {
  9097. return m.clearedwxs
  9098. }
  9099. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  9100. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  9101. if m.removedwxs == nil {
  9102. m.removedwxs = make(map[uint64]struct{})
  9103. }
  9104. for i := range ids {
  9105. delete(m.wxs, ids[i])
  9106. m.removedwxs[ids[i]] = struct{}{}
  9107. }
  9108. }
  9109. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  9110. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  9111. for id := range m.removedwxs {
  9112. ids = append(ids, id)
  9113. }
  9114. return
  9115. }
  9116. // WxsIDs returns the "wxs" edge IDs in the mutation.
  9117. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  9118. for id := range m.wxs {
  9119. ids = append(ids, id)
  9120. }
  9121. return
  9122. }
  9123. // ResetWxs resets all changes to the "wxs" edge.
  9124. func (m *ServerMutation) ResetWxs() {
  9125. m.wxs = nil
  9126. m.clearedwxs = false
  9127. m.removedwxs = nil
  9128. }
  9129. // Where appends a list predicates to the ServerMutation builder.
  9130. func (m *ServerMutation) Where(ps ...predicate.Server) {
  9131. m.predicates = append(m.predicates, ps...)
  9132. }
  9133. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  9134. // users can use type-assertion to append predicates that do not depend on any generated package.
  9135. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  9136. p := make([]predicate.Server, len(ps))
  9137. for i := range ps {
  9138. p[i] = ps[i]
  9139. }
  9140. m.Where(p...)
  9141. }
  9142. // Op returns the operation name.
  9143. func (m *ServerMutation) Op() Op {
  9144. return m.op
  9145. }
  9146. // SetOp allows setting the mutation operation.
  9147. func (m *ServerMutation) SetOp(op Op) {
  9148. m.op = op
  9149. }
  9150. // Type returns the node type of this mutation (Server).
  9151. func (m *ServerMutation) Type() string {
  9152. return m.typ
  9153. }
  9154. // Fields returns all fields that were changed during this mutation. Note that in
  9155. // order to get all numeric fields that were incremented/decremented, call
  9156. // AddedFields().
  9157. func (m *ServerMutation) Fields() []string {
  9158. fields := make([]string, 0, 8)
  9159. if m.created_at != nil {
  9160. fields = append(fields, server.FieldCreatedAt)
  9161. }
  9162. if m.updated_at != nil {
  9163. fields = append(fields, server.FieldUpdatedAt)
  9164. }
  9165. if m.status != nil {
  9166. fields = append(fields, server.FieldStatus)
  9167. }
  9168. if m.deleted_at != nil {
  9169. fields = append(fields, server.FieldDeletedAt)
  9170. }
  9171. if m.name != nil {
  9172. fields = append(fields, server.FieldName)
  9173. }
  9174. if m.public_ip != nil {
  9175. fields = append(fields, server.FieldPublicIP)
  9176. }
  9177. if m.private_ip != nil {
  9178. fields = append(fields, server.FieldPrivateIP)
  9179. }
  9180. if m.admin_port != nil {
  9181. fields = append(fields, server.FieldAdminPort)
  9182. }
  9183. return fields
  9184. }
  9185. // Field returns the value of a field with the given name. The second boolean
  9186. // return value indicates that this field was not set, or was not defined in the
  9187. // schema.
  9188. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  9189. switch name {
  9190. case server.FieldCreatedAt:
  9191. return m.CreatedAt()
  9192. case server.FieldUpdatedAt:
  9193. return m.UpdatedAt()
  9194. case server.FieldStatus:
  9195. return m.Status()
  9196. case server.FieldDeletedAt:
  9197. return m.DeletedAt()
  9198. case server.FieldName:
  9199. return m.Name()
  9200. case server.FieldPublicIP:
  9201. return m.PublicIP()
  9202. case server.FieldPrivateIP:
  9203. return m.PrivateIP()
  9204. case server.FieldAdminPort:
  9205. return m.AdminPort()
  9206. }
  9207. return nil, false
  9208. }
  9209. // OldField returns the old value of the field from the database. An error is
  9210. // returned if the mutation operation is not UpdateOne, or the query to the
  9211. // database failed.
  9212. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9213. switch name {
  9214. case server.FieldCreatedAt:
  9215. return m.OldCreatedAt(ctx)
  9216. case server.FieldUpdatedAt:
  9217. return m.OldUpdatedAt(ctx)
  9218. case server.FieldStatus:
  9219. return m.OldStatus(ctx)
  9220. case server.FieldDeletedAt:
  9221. return m.OldDeletedAt(ctx)
  9222. case server.FieldName:
  9223. return m.OldName(ctx)
  9224. case server.FieldPublicIP:
  9225. return m.OldPublicIP(ctx)
  9226. case server.FieldPrivateIP:
  9227. return m.OldPrivateIP(ctx)
  9228. case server.FieldAdminPort:
  9229. return m.OldAdminPort(ctx)
  9230. }
  9231. return nil, fmt.Errorf("unknown Server field %s", name)
  9232. }
  9233. // SetField sets the value of a field with the given name. It returns an error if
  9234. // the field is not defined in the schema, or if the type mismatched the field
  9235. // type.
  9236. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  9237. switch name {
  9238. case server.FieldCreatedAt:
  9239. v, ok := value.(time.Time)
  9240. if !ok {
  9241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9242. }
  9243. m.SetCreatedAt(v)
  9244. return nil
  9245. case server.FieldUpdatedAt:
  9246. v, ok := value.(time.Time)
  9247. if !ok {
  9248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9249. }
  9250. m.SetUpdatedAt(v)
  9251. return nil
  9252. case server.FieldStatus:
  9253. v, ok := value.(uint8)
  9254. if !ok {
  9255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9256. }
  9257. m.SetStatus(v)
  9258. return nil
  9259. case server.FieldDeletedAt:
  9260. v, ok := value.(time.Time)
  9261. if !ok {
  9262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9263. }
  9264. m.SetDeletedAt(v)
  9265. return nil
  9266. case server.FieldName:
  9267. v, ok := value.(string)
  9268. if !ok {
  9269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9270. }
  9271. m.SetName(v)
  9272. return nil
  9273. case server.FieldPublicIP:
  9274. v, ok := value.(string)
  9275. if !ok {
  9276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9277. }
  9278. m.SetPublicIP(v)
  9279. return nil
  9280. case server.FieldPrivateIP:
  9281. v, ok := value.(string)
  9282. if !ok {
  9283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9284. }
  9285. m.SetPrivateIP(v)
  9286. return nil
  9287. case server.FieldAdminPort:
  9288. v, ok := value.(string)
  9289. if !ok {
  9290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9291. }
  9292. m.SetAdminPort(v)
  9293. return nil
  9294. }
  9295. return fmt.Errorf("unknown Server field %s", name)
  9296. }
  9297. // AddedFields returns all numeric fields that were incremented/decremented during
  9298. // this mutation.
  9299. func (m *ServerMutation) AddedFields() []string {
  9300. var fields []string
  9301. if m.addstatus != nil {
  9302. fields = append(fields, server.FieldStatus)
  9303. }
  9304. return fields
  9305. }
  9306. // AddedField returns the numeric value that was incremented/decremented on a field
  9307. // with the given name. The second boolean return value indicates that this field
  9308. // was not set, or was not defined in the schema.
  9309. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  9310. switch name {
  9311. case server.FieldStatus:
  9312. return m.AddedStatus()
  9313. }
  9314. return nil, false
  9315. }
  9316. // AddField adds the value to the field with the given name. It returns an error if
  9317. // the field is not defined in the schema, or if the type mismatched the field
  9318. // type.
  9319. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  9320. switch name {
  9321. case server.FieldStatus:
  9322. v, ok := value.(int8)
  9323. if !ok {
  9324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9325. }
  9326. m.AddStatus(v)
  9327. return nil
  9328. }
  9329. return fmt.Errorf("unknown Server numeric field %s", name)
  9330. }
  9331. // ClearedFields returns all nullable fields that were cleared during this
  9332. // mutation.
  9333. func (m *ServerMutation) ClearedFields() []string {
  9334. var fields []string
  9335. if m.FieldCleared(server.FieldStatus) {
  9336. fields = append(fields, server.FieldStatus)
  9337. }
  9338. if m.FieldCleared(server.FieldDeletedAt) {
  9339. fields = append(fields, server.FieldDeletedAt)
  9340. }
  9341. return fields
  9342. }
  9343. // FieldCleared returns a boolean indicating if a field with the given name was
  9344. // cleared in this mutation.
  9345. func (m *ServerMutation) FieldCleared(name string) bool {
  9346. _, ok := m.clearedFields[name]
  9347. return ok
  9348. }
  9349. // ClearField clears the value of the field with the given name. It returns an
  9350. // error if the field is not defined in the schema.
  9351. func (m *ServerMutation) ClearField(name string) error {
  9352. switch name {
  9353. case server.FieldStatus:
  9354. m.ClearStatus()
  9355. return nil
  9356. case server.FieldDeletedAt:
  9357. m.ClearDeletedAt()
  9358. return nil
  9359. }
  9360. return fmt.Errorf("unknown Server nullable field %s", name)
  9361. }
  9362. // ResetField resets all changes in the mutation for the field with the given name.
  9363. // It returns an error if the field is not defined in the schema.
  9364. func (m *ServerMutation) ResetField(name string) error {
  9365. switch name {
  9366. case server.FieldCreatedAt:
  9367. m.ResetCreatedAt()
  9368. return nil
  9369. case server.FieldUpdatedAt:
  9370. m.ResetUpdatedAt()
  9371. return nil
  9372. case server.FieldStatus:
  9373. m.ResetStatus()
  9374. return nil
  9375. case server.FieldDeletedAt:
  9376. m.ResetDeletedAt()
  9377. return nil
  9378. case server.FieldName:
  9379. m.ResetName()
  9380. return nil
  9381. case server.FieldPublicIP:
  9382. m.ResetPublicIP()
  9383. return nil
  9384. case server.FieldPrivateIP:
  9385. m.ResetPrivateIP()
  9386. return nil
  9387. case server.FieldAdminPort:
  9388. m.ResetAdminPort()
  9389. return nil
  9390. }
  9391. return fmt.Errorf("unknown Server field %s", name)
  9392. }
  9393. // AddedEdges returns all edge names that were set/added in this mutation.
  9394. func (m *ServerMutation) AddedEdges() []string {
  9395. edges := make([]string, 0, 1)
  9396. if m.wxs != nil {
  9397. edges = append(edges, server.EdgeWxs)
  9398. }
  9399. return edges
  9400. }
  9401. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9402. // name in this mutation.
  9403. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  9404. switch name {
  9405. case server.EdgeWxs:
  9406. ids := make([]ent.Value, 0, len(m.wxs))
  9407. for id := range m.wxs {
  9408. ids = append(ids, id)
  9409. }
  9410. return ids
  9411. }
  9412. return nil
  9413. }
  9414. // RemovedEdges returns all edge names that were removed in this mutation.
  9415. func (m *ServerMutation) RemovedEdges() []string {
  9416. edges := make([]string, 0, 1)
  9417. if m.removedwxs != nil {
  9418. edges = append(edges, server.EdgeWxs)
  9419. }
  9420. return edges
  9421. }
  9422. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9423. // the given name in this mutation.
  9424. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  9425. switch name {
  9426. case server.EdgeWxs:
  9427. ids := make([]ent.Value, 0, len(m.removedwxs))
  9428. for id := range m.removedwxs {
  9429. ids = append(ids, id)
  9430. }
  9431. return ids
  9432. }
  9433. return nil
  9434. }
  9435. // ClearedEdges returns all edge names that were cleared in this mutation.
  9436. func (m *ServerMutation) ClearedEdges() []string {
  9437. edges := make([]string, 0, 1)
  9438. if m.clearedwxs {
  9439. edges = append(edges, server.EdgeWxs)
  9440. }
  9441. return edges
  9442. }
  9443. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9444. // was cleared in this mutation.
  9445. func (m *ServerMutation) EdgeCleared(name string) bool {
  9446. switch name {
  9447. case server.EdgeWxs:
  9448. return m.clearedwxs
  9449. }
  9450. return false
  9451. }
  9452. // ClearEdge clears the value of the edge with the given name. It returns an error
  9453. // if that edge is not defined in the schema.
  9454. func (m *ServerMutation) ClearEdge(name string) error {
  9455. switch name {
  9456. }
  9457. return fmt.Errorf("unknown Server unique edge %s", name)
  9458. }
  9459. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9460. // It returns an error if the edge is not defined in the schema.
  9461. func (m *ServerMutation) ResetEdge(name string) error {
  9462. switch name {
  9463. case server.EdgeWxs:
  9464. m.ResetWxs()
  9465. return nil
  9466. }
  9467. return fmt.Errorf("unknown Server edge %s", name)
  9468. }
  9469. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  9470. type SopNodeMutation struct {
  9471. config
  9472. op Op
  9473. typ string
  9474. id *uint64
  9475. created_at *time.Time
  9476. updated_at *time.Time
  9477. status *uint8
  9478. addstatus *int8
  9479. deleted_at *time.Time
  9480. parent_id *uint64
  9481. addparent_id *int64
  9482. name *string
  9483. condition_type *int
  9484. addcondition_type *int
  9485. condition_list *[]string
  9486. appendcondition_list []string
  9487. no_reply_condition *uint64
  9488. addno_reply_condition *int64
  9489. action_message *[]custom_types.Action
  9490. appendaction_message []custom_types.Action
  9491. action_label *[]uint64
  9492. appendaction_label []uint64
  9493. clearedFields map[string]struct{}
  9494. sop_stage *uint64
  9495. clearedsop_stage bool
  9496. node_messages map[uint64]struct{}
  9497. removednode_messages map[uint64]struct{}
  9498. clearednode_messages bool
  9499. done bool
  9500. oldValue func(context.Context) (*SopNode, error)
  9501. predicates []predicate.SopNode
  9502. }
  9503. var _ ent.Mutation = (*SopNodeMutation)(nil)
  9504. // sopnodeOption allows management of the mutation configuration using functional options.
  9505. type sopnodeOption func(*SopNodeMutation)
  9506. // newSopNodeMutation creates new mutation for the SopNode entity.
  9507. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  9508. m := &SopNodeMutation{
  9509. config: c,
  9510. op: op,
  9511. typ: TypeSopNode,
  9512. clearedFields: make(map[string]struct{}),
  9513. }
  9514. for _, opt := range opts {
  9515. opt(m)
  9516. }
  9517. return m
  9518. }
  9519. // withSopNodeID sets the ID field of the mutation.
  9520. func withSopNodeID(id uint64) sopnodeOption {
  9521. return func(m *SopNodeMutation) {
  9522. var (
  9523. err error
  9524. once sync.Once
  9525. value *SopNode
  9526. )
  9527. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  9528. once.Do(func() {
  9529. if m.done {
  9530. err = errors.New("querying old values post mutation is not allowed")
  9531. } else {
  9532. value, err = m.Client().SopNode.Get(ctx, id)
  9533. }
  9534. })
  9535. return value, err
  9536. }
  9537. m.id = &id
  9538. }
  9539. }
  9540. // withSopNode sets the old SopNode of the mutation.
  9541. func withSopNode(node *SopNode) sopnodeOption {
  9542. return func(m *SopNodeMutation) {
  9543. m.oldValue = func(context.Context) (*SopNode, error) {
  9544. return node, nil
  9545. }
  9546. m.id = &node.ID
  9547. }
  9548. }
  9549. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9550. // executed in a transaction (ent.Tx), a transactional client is returned.
  9551. func (m SopNodeMutation) Client() *Client {
  9552. client := &Client{config: m.config}
  9553. client.init()
  9554. return client
  9555. }
  9556. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9557. // it returns an error otherwise.
  9558. func (m SopNodeMutation) Tx() (*Tx, error) {
  9559. if _, ok := m.driver.(*txDriver); !ok {
  9560. return nil, errors.New("ent: mutation is not running in a transaction")
  9561. }
  9562. tx := &Tx{config: m.config}
  9563. tx.init()
  9564. return tx, nil
  9565. }
  9566. // SetID sets the value of the id field. Note that this
  9567. // operation is only accepted on creation of SopNode entities.
  9568. func (m *SopNodeMutation) SetID(id uint64) {
  9569. m.id = &id
  9570. }
  9571. // ID returns the ID value in the mutation. Note that the ID is only available
  9572. // if it was provided to the builder or after it was returned from the database.
  9573. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  9574. if m.id == nil {
  9575. return
  9576. }
  9577. return *m.id, true
  9578. }
  9579. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9580. // That means, if the mutation is applied within a transaction with an isolation level such
  9581. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9582. // or updated by the mutation.
  9583. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  9584. switch {
  9585. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9586. id, exists := m.ID()
  9587. if exists {
  9588. return []uint64{id}, nil
  9589. }
  9590. fallthrough
  9591. case m.op.Is(OpUpdate | OpDelete):
  9592. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  9593. default:
  9594. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9595. }
  9596. }
  9597. // SetCreatedAt sets the "created_at" field.
  9598. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  9599. m.created_at = &t
  9600. }
  9601. // CreatedAt returns the value of the "created_at" field in the mutation.
  9602. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  9603. v := m.created_at
  9604. if v == nil {
  9605. return
  9606. }
  9607. return *v, true
  9608. }
  9609. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  9610. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9611. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9612. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9613. if !m.op.Is(OpUpdateOne) {
  9614. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9615. }
  9616. if m.id == nil || m.oldValue == nil {
  9617. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9618. }
  9619. oldValue, err := m.oldValue(ctx)
  9620. if err != nil {
  9621. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9622. }
  9623. return oldValue.CreatedAt, nil
  9624. }
  9625. // ResetCreatedAt resets all changes to the "created_at" field.
  9626. func (m *SopNodeMutation) ResetCreatedAt() {
  9627. m.created_at = nil
  9628. }
  9629. // SetUpdatedAt sets the "updated_at" field.
  9630. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  9631. m.updated_at = &t
  9632. }
  9633. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9634. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  9635. v := m.updated_at
  9636. if v == nil {
  9637. return
  9638. }
  9639. return *v, true
  9640. }
  9641. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  9642. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9643. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9644. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9645. if !m.op.Is(OpUpdateOne) {
  9646. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9647. }
  9648. if m.id == nil || m.oldValue == nil {
  9649. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9650. }
  9651. oldValue, err := m.oldValue(ctx)
  9652. if err != nil {
  9653. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9654. }
  9655. return oldValue.UpdatedAt, nil
  9656. }
  9657. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9658. func (m *SopNodeMutation) ResetUpdatedAt() {
  9659. m.updated_at = nil
  9660. }
  9661. // SetStatus sets the "status" field.
  9662. func (m *SopNodeMutation) SetStatus(u uint8) {
  9663. m.status = &u
  9664. m.addstatus = nil
  9665. }
  9666. // Status returns the value of the "status" field in the mutation.
  9667. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  9668. v := m.status
  9669. if v == nil {
  9670. return
  9671. }
  9672. return *v, true
  9673. }
  9674. // OldStatus returns the old "status" field's value of the SopNode entity.
  9675. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9677. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  9678. if !m.op.Is(OpUpdateOne) {
  9679. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9680. }
  9681. if m.id == nil || m.oldValue == nil {
  9682. return v, errors.New("OldStatus requires an ID field in the mutation")
  9683. }
  9684. oldValue, err := m.oldValue(ctx)
  9685. if err != nil {
  9686. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9687. }
  9688. return oldValue.Status, nil
  9689. }
  9690. // AddStatus adds u to the "status" field.
  9691. func (m *SopNodeMutation) AddStatus(u int8) {
  9692. if m.addstatus != nil {
  9693. *m.addstatus += u
  9694. } else {
  9695. m.addstatus = &u
  9696. }
  9697. }
  9698. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9699. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  9700. v := m.addstatus
  9701. if v == nil {
  9702. return
  9703. }
  9704. return *v, true
  9705. }
  9706. // ClearStatus clears the value of the "status" field.
  9707. func (m *SopNodeMutation) ClearStatus() {
  9708. m.status = nil
  9709. m.addstatus = nil
  9710. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  9711. }
  9712. // StatusCleared returns if the "status" field was cleared in this mutation.
  9713. func (m *SopNodeMutation) StatusCleared() bool {
  9714. _, ok := m.clearedFields[sopnode.FieldStatus]
  9715. return ok
  9716. }
  9717. // ResetStatus resets all changes to the "status" field.
  9718. func (m *SopNodeMutation) ResetStatus() {
  9719. m.status = nil
  9720. m.addstatus = nil
  9721. delete(m.clearedFields, sopnode.FieldStatus)
  9722. }
  9723. // SetDeletedAt sets the "deleted_at" field.
  9724. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  9725. m.deleted_at = &t
  9726. }
  9727. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9728. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  9729. v := m.deleted_at
  9730. if v == nil {
  9731. return
  9732. }
  9733. return *v, true
  9734. }
  9735. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  9736. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9737. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9738. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9739. if !m.op.Is(OpUpdateOne) {
  9740. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9741. }
  9742. if m.id == nil || m.oldValue == nil {
  9743. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9744. }
  9745. oldValue, err := m.oldValue(ctx)
  9746. if err != nil {
  9747. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9748. }
  9749. return oldValue.DeletedAt, nil
  9750. }
  9751. // ClearDeletedAt clears the value of the "deleted_at" field.
  9752. func (m *SopNodeMutation) ClearDeletedAt() {
  9753. m.deleted_at = nil
  9754. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  9755. }
  9756. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9757. func (m *SopNodeMutation) DeletedAtCleared() bool {
  9758. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  9759. return ok
  9760. }
  9761. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9762. func (m *SopNodeMutation) ResetDeletedAt() {
  9763. m.deleted_at = nil
  9764. delete(m.clearedFields, sopnode.FieldDeletedAt)
  9765. }
  9766. // SetStageID sets the "stage_id" field.
  9767. func (m *SopNodeMutation) SetStageID(u uint64) {
  9768. m.sop_stage = &u
  9769. }
  9770. // StageID returns the value of the "stage_id" field in the mutation.
  9771. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  9772. v := m.sop_stage
  9773. if v == nil {
  9774. return
  9775. }
  9776. return *v, true
  9777. }
  9778. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  9779. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9781. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  9782. if !m.op.Is(OpUpdateOne) {
  9783. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  9784. }
  9785. if m.id == nil || m.oldValue == nil {
  9786. return v, errors.New("OldStageID requires an ID field in the mutation")
  9787. }
  9788. oldValue, err := m.oldValue(ctx)
  9789. if err != nil {
  9790. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  9791. }
  9792. return oldValue.StageID, nil
  9793. }
  9794. // ResetStageID resets all changes to the "stage_id" field.
  9795. func (m *SopNodeMutation) ResetStageID() {
  9796. m.sop_stage = nil
  9797. }
  9798. // SetParentID sets the "parent_id" field.
  9799. func (m *SopNodeMutation) SetParentID(u uint64) {
  9800. m.parent_id = &u
  9801. m.addparent_id = nil
  9802. }
  9803. // ParentID returns the value of the "parent_id" field in the mutation.
  9804. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  9805. v := m.parent_id
  9806. if v == nil {
  9807. return
  9808. }
  9809. return *v, true
  9810. }
  9811. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  9812. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9814. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  9815. if !m.op.Is(OpUpdateOne) {
  9816. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  9817. }
  9818. if m.id == nil || m.oldValue == nil {
  9819. return v, errors.New("OldParentID requires an ID field in the mutation")
  9820. }
  9821. oldValue, err := m.oldValue(ctx)
  9822. if err != nil {
  9823. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  9824. }
  9825. return oldValue.ParentID, nil
  9826. }
  9827. // AddParentID adds u to the "parent_id" field.
  9828. func (m *SopNodeMutation) AddParentID(u int64) {
  9829. if m.addparent_id != nil {
  9830. *m.addparent_id += u
  9831. } else {
  9832. m.addparent_id = &u
  9833. }
  9834. }
  9835. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  9836. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  9837. v := m.addparent_id
  9838. if v == nil {
  9839. return
  9840. }
  9841. return *v, true
  9842. }
  9843. // ResetParentID resets all changes to the "parent_id" field.
  9844. func (m *SopNodeMutation) ResetParentID() {
  9845. m.parent_id = nil
  9846. m.addparent_id = nil
  9847. }
  9848. // SetName sets the "name" field.
  9849. func (m *SopNodeMutation) SetName(s string) {
  9850. m.name = &s
  9851. }
  9852. // Name returns the value of the "name" field in the mutation.
  9853. func (m *SopNodeMutation) Name() (r string, exists bool) {
  9854. v := m.name
  9855. if v == nil {
  9856. return
  9857. }
  9858. return *v, true
  9859. }
  9860. // OldName returns the old "name" field's value of the SopNode entity.
  9861. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9862. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9863. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  9864. if !m.op.Is(OpUpdateOne) {
  9865. return v, errors.New("OldName is only allowed on UpdateOne operations")
  9866. }
  9867. if m.id == nil || m.oldValue == nil {
  9868. return v, errors.New("OldName requires an ID field in the mutation")
  9869. }
  9870. oldValue, err := m.oldValue(ctx)
  9871. if err != nil {
  9872. return v, fmt.Errorf("querying old value for OldName: %w", err)
  9873. }
  9874. return oldValue.Name, nil
  9875. }
  9876. // ResetName resets all changes to the "name" field.
  9877. func (m *SopNodeMutation) ResetName() {
  9878. m.name = nil
  9879. }
  9880. // SetConditionType sets the "condition_type" field.
  9881. func (m *SopNodeMutation) SetConditionType(i int) {
  9882. m.condition_type = &i
  9883. m.addcondition_type = nil
  9884. }
  9885. // ConditionType returns the value of the "condition_type" field in the mutation.
  9886. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  9887. v := m.condition_type
  9888. if v == nil {
  9889. return
  9890. }
  9891. return *v, true
  9892. }
  9893. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  9894. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9895. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9896. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  9897. if !m.op.Is(OpUpdateOne) {
  9898. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  9899. }
  9900. if m.id == nil || m.oldValue == nil {
  9901. return v, errors.New("OldConditionType requires an ID field in the mutation")
  9902. }
  9903. oldValue, err := m.oldValue(ctx)
  9904. if err != nil {
  9905. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  9906. }
  9907. return oldValue.ConditionType, nil
  9908. }
  9909. // AddConditionType adds i to the "condition_type" field.
  9910. func (m *SopNodeMutation) AddConditionType(i int) {
  9911. if m.addcondition_type != nil {
  9912. *m.addcondition_type += i
  9913. } else {
  9914. m.addcondition_type = &i
  9915. }
  9916. }
  9917. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  9918. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  9919. v := m.addcondition_type
  9920. if v == nil {
  9921. return
  9922. }
  9923. return *v, true
  9924. }
  9925. // ResetConditionType resets all changes to the "condition_type" field.
  9926. func (m *SopNodeMutation) ResetConditionType() {
  9927. m.condition_type = nil
  9928. m.addcondition_type = nil
  9929. }
  9930. // SetConditionList sets the "condition_list" field.
  9931. func (m *SopNodeMutation) SetConditionList(s []string) {
  9932. m.condition_list = &s
  9933. m.appendcondition_list = nil
  9934. }
  9935. // ConditionList returns the value of the "condition_list" field in the mutation.
  9936. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  9937. v := m.condition_list
  9938. if v == nil {
  9939. return
  9940. }
  9941. return *v, true
  9942. }
  9943. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  9944. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9945. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9946. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  9947. if !m.op.Is(OpUpdateOne) {
  9948. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  9949. }
  9950. if m.id == nil || m.oldValue == nil {
  9951. return v, errors.New("OldConditionList requires an ID field in the mutation")
  9952. }
  9953. oldValue, err := m.oldValue(ctx)
  9954. if err != nil {
  9955. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  9956. }
  9957. return oldValue.ConditionList, nil
  9958. }
  9959. // AppendConditionList adds s to the "condition_list" field.
  9960. func (m *SopNodeMutation) AppendConditionList(s []string) {
  9961. m.appendcondition_list = append(m.appendcondition_list, s...)
  9962. }
  9963. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  9964. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  9965. if len(m.appendcondition_list) == 0 {
  9966. return nil, false
  9967. }
  9968. return m.appendcondition_list, true
  9969. }
  9970. // ClearConditionList clears the value of the "condition_list" field.
  9971. func (m *SopNodeMutation) ClearConditionList() {
  9972. m.condition_list = nil
  9973. m.appendcondition_list = nil
  9974. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  9975. }
  9976. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  9977. func (m *SopNodeMutation) ConditionListCleared() bool {
  9978. _, ok := m.clearedFields[sopnode.FieldConditionList]
  9979. return ok
  9980. }
  9981. // ResetConditionList resets all changes to the "condition_list" field.
  9982. func (m *SopNodeMutation) ResetConditionList() {
  9983. m.condition_list = nil
  9984. m.appendcondition_list = nil
  9985. delete(m.clearedFields, sopnode.FieldConditionList)
  9986. }
  9987. // SetNoReplyCondition sets the "no_reply_condition" field.
  9988. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  9989. m.no_reply_condition = &u
  9990. m.addno_reply_condition = nil
  9991. }
  9992. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  9993. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  9994. v := m.no_reply_condition
  9995. if v == nil {
  9996. return
  9997. }
  9998. return *v, true
  9999. }
  10000. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  10001. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  10002. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10003. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  10004. if !m.op.Is(OpUpdateOne) {
  10005. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  10006. }
  10007. if m.id == nil || m.oldValue == nil {
  10008. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  10009. }
  10010. oldValue, err := m.oldValue(ctx)
  10011. if err != nil {
  10012. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  10013. }
  10014. return oldValue.NoReplyCondition, nil
  10015. }
  10016. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  10017. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  10018. if m.addno_reply_condition != nil {
  10019. *m.addno_reply_condition += u
  10020. } else {
  10021. m.addno_reply_condition = &u
  10022. }
  10023. }
  10024. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  10025. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  10026. v := m.addno_reply_condition
  10027. if v == nil {
  10028. return
  10029. }
  10030. return *v, true
  10031. }
  10032. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  10033. func (m *SopNodeMutation) ResetNoReplyCondition() {
  10034. m.no_reply_condition = nil
  10035. m.addno_reply_condition = nil
  10036. }
  10037. // SetActionMessage sets the "action_message" field.
  10038. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  10039. m.action_message = &ct
  10040. m.appendaction_message = nil
  10041. }
  10042. // ActionMessage returns the value of the "action_message" field in the mutation.
  10043. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  10044. v := m.action_message
  10045. if v == nil {
  10046. return
  10047. }
  10048. return *v, true
  10049. }
  10050. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  10051. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  10052. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10053. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  10054. if !m.op.Is(OpUpdateOne) {
  10055. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  10056. }
  10057. if m.id == nil || m.oldValue == nil {
  10058. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  10059. }
  10060. oldValue, err := m.oldValue(ctx)
  10061. if err != nil {
  10062. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  10063. }
  10064. return oldValue.ActionMessage, nil
  10065. }
  10066. // AppendActionMessage adds ct to the "action_message" field.
  10067. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  10068. m.appendaction_message = append(m.appendaction_message, ct...)
  10069. }
  10070. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  10071. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  10072. if len(m.appendaction_message) == 0 {
  10073. return nil, false
  10074. }
  10075. return m.appendaction_message, true
  10076. }
  10077. // ClearActionMessage clears the value of the "action_message" field.
  10078. func (m *SopNodeMutation) ClearActionMessage() {
  10079. m.action_message = nil
  10080. m.appendaction_message = nil
  10081. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  10082. }
  10083. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  10084. func (m *SopNodeMutation) ActionMessageCleared() bool {
  10085. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  10086. return ok
  10087. }
  10088. // ResetActionMessage resets all changes to the "action_message" field.
  10089. func (m *SopNodeMutation) ResetActionMessage() {
  10090. m.action_message = nil
  10091. m.appendaction_message = nil
  10092. delete(m.clearedFields, sopnode.FieldActionMessage)
  10093. }
  10094. // SetActionLabel sets the "action_label" field.
  10095. func (m *SopNodeMutation) SetActionLabel(u []uint64) {
  10096. m.action_label = &u
  10097. m.appendaction_label = nil
  10098. }
  10099. // ActionLabel returns the value of the "action_label" field in the mutation.
  10100. func (m *SopNodeMutation) ActionLabel() (r []uint64, exists bool) {
  10101. v := m.action_label
  10102. if v == nil {
  10103. return
  10104. }
  10105. return *v, true
  10106. }
  10107. // OldActionLabel returns the old "action_label" field's value of the SopNode entity.
  10108. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  10109. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10110. func (m *SopNodeMutation) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  10111. if !m.op.Is(OpUpdateOne) {
  10112. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  10113. }
  10114. if m.id == nil || m.oldValue == nil {
  10115. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  10116. }
  10117. oldValue, err := m.oldValue(ctx)
  10118. if err != nil {
  10119. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  10120. }
  10121. return oldValue.ActionLabel, nil
  10122. }
  10123. // AppendActionLabel adds u to the "action_label" field.
  10124. func (m *SopNodeMutation) AppendActionLabel(u []uint64) {
  10125. m.appendaction_label = append(m.appendaction_label, u...)
  10126. }
  10127. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  10128. func (m *SopNodeMutation) AppendedActionLabel() ([]uint64, bool) {
  10129. if len(m.appendaction_label) == 0 {
  10130. return nil, false
  10131. }
  10132. return m.appendaction_label, true
  10133. }
  10134. // ClearActionLabel clears the value of the "action_label" field.
  10135. func (m *SopNodeMutation) ClearActionLabel() {
  10136. m.action_label = nil
  10137. m.appendaction_label = nil
  10138. m.clearedFields[sopnode.FieldActionLabel] = struct{}{}
  10139. }
  10140. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  10141. func (m *SopNodeMutation) ActionLabelCleared() bool {
  10142. _, ok := m.clearedFields[sopnode.FieldActionLabel]
  10143. return ok
  10144. }
  10145. // ResetActionLabel resets all changes to the "action_label" field.
  10146. func (m *SopNodeMutation) ResetActionLabel() {
  10147. m.action_label = nil
  10148. m.appendaction_label = nil
  10149. delete(m.clearedFields, sopnode.FieldActionLabel)
  10150. }
  10151. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  10152. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  10153. m.sop_stage = &id
  10154. }
  10155. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  10156. func (m *SopNodeMutation) ClearSopStage() {
  10157. m.clearedsop_stage = true
  10158. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  10159. }
  10160. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  10161. func (m *SopNodeMutation) SopStageCleared() bool {
  10162. return m.clearedsop_stage
  10163. }
  10164. // SopStageID returns the "sop_stage" edge ID in the mutation.
  10165. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  10166. if m.sop_stage != nil {
  10167. return *m.sop_stage, true
  10168. }
  10169. return
  10170. }
  10171. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  10172. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  10173. // SopStageID instead. It exists only for internal usage by the builders.
  10174. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  10175. if id := m.sop_stage; id != nil {
  10176. ids = append(ids, *id)
  10177. }
  10178. return
  10179. }
  10180. // ResetSopStage resets all changes to the "sop_stage" edge.
  10181. func (m *SopNodeMutation) ResetSopStage() {
  10182. m.sop_stage = nil
  10183. m.clearedsop_stage = false
  10184. }
  10185. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  10186. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  10187. if m.node_messages == nil {
  10188. m.node_messages = make(map[uint64]struct{})
  10189. }
  10190. for i := range ids {
  10191. m.node_messages[ids[i]] = struct{}{}
  10192. }
  10193. }
  10194. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  10195. func (m *SopNodeMutation) ClearNodeMessages() {
  10196. m.clearednode_messages = true
  10197. }
  10198. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  10199. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  10200. return m.clearednode_messages
  10201. }
  10202. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  10203. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  10204. if m.removednode_messages == nil {
  10205. m.removednode_messages = make(map[uint64]struct{})
  10206. }
  10207. for i := range ids {
  10208. delete(m.node_messages, ids[i])
  10209. m.removednode_messages[ids[i]] = struct{}{}
  10210. }
  10211. }
  10212. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  10213. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  10214. for id := range m.removednode_messages {
  10215. ids = append(ids, id)
  10216. }
  10217. return
  10218. }
  10219. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  10220. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  10221. for id := range m.node_messages {
  10222. ids = append(ids, id)
  10223. }
  10224. return
  10225. }
  10226. // ResetNodeMessages resets all changes to the "node_messages" edge.
  10227. func (m *SopNodeMutation) ResetNodeMessages() {
  10228. m.node_messages = nil
  10229. m.clearednode_messages = false
  10230. m.removednode_messages = nil
  10231. }
  10232. // Where appends a list predicates to the SopNodeMutation builder.
  10233. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  10234. m.predicates = append(m.predicates, ps...)
  10235. }
  10236. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  10237. // users can use type-assertion to append predicates that do not depend on any generated package.
  10238. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  10239. p := make([]predicate.SopNode, len(ps))
  10240. for i := range ps {
  10241. p[i] = ps[i]
  10242. }
  10243. m.Where(p...)
  10244. }
  10245. // Op returns the operation name.
  10246. func (m *SopNodeMutation) Op() Op {
  10247. return m.op
  10248. }
  10249. // SetOp allows setting the mutation operation.
  10250. func (m *SopNodeMutation) SetOp(op Op) {
  10251. m.op = op
  10252. }
  10253. // Type returns the node type of this mutation (SopNode).
  10254. func (m *SopNodeMutation) Type() string {
  10255. return m.typ
  10256. }
  10257. // Fields returns all fields that were changed during this mutation. Note that in
  10258. // order to get all numeric fields that were incremented/decremented, call
  10259. // AddedFields().
  10260. func (m *SopNodeMutation) Fields() []string {
  10261. fields := make([]string, 0, 12)
  10262. if m.created_at != nil {
  10263. fields = append(fields, sopnode.FieldCreatedAt)
  10264. }
  10265. if m.updated_at != nil {
  10266. fields = append(fields, sopnode.FieldUpdatedAt)
  10267. }
  10268. if m.status != nil {
  10269. fields = append(fields, sopnode.FieldStatus)
  10270. }
  10271. if m.deleted_at != nil {
  10272. fields = append(fields, sopnode.FieldDeletedAt)
  10273. }
  10274. if m.sop_stage != nil {
  10275. fields = append(fields, sopnode.FieldStageID)
  10276. }
  10277. if m.parent_id != nil {
  10278. fields = append(fields, sopnode.FieldParentID)
  10279. }
  10280. if m.name != nil {
  10281. fields = append(fields, sopnode.FieldName)
  10282. }
  10283. if m.condition_type != nil {
  10284. fields = append(fields, sopnode.FieldConditionType)
  10285. }
  10286. if m.condition_list != nil {
  10287. fields = append(fields, sopnode.FieldConditionList)
  10288. }
  10289. if m.no_reply_condition != nil {
  10290. fields = append(fields, sopnode.FieldNoReplyCondition)
  10291. }
  10292. if m.action_message != nil {
  10293. fields = append(fields, sopnode.FieldActionMessage)
  10294. }
  10295. if m.action_label != nil {
  10296. fields = append(fields, sopnode.FieldActionLabel)
  10297. }
  10298. return fields
  10299. }
  10300. // Field returns the value of a field with the given name. The second boolean
  10301. // return value indicates that this field was not set, or was not defined in the
  10302. // schema.
  10303. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  10304. switch name {
  10305. case sopnode.FieldCreatedAt:
  10306. return m.CreatedAt()
  10307. case sopnode.FieldUpdatedAt:
  10308. return m.UpdatedAt()
  10309. case sopnode.FieldStatus:
  10310. return m.Status()
  10311. case sopnode.FieldDeletedAt:
  10312. return m.DeletedAt()
  10313. case sopnode.FieldStageID:
  10314. return m.StageID()
  10315. case sopnode.FieldParentID:
  10316. return m.ParentID()
  10317. case sopnode.FieldName:
  10318. return m.Name()
  10319. case sopnode.FieldConditionType:
  10320. return m.ConditionType()
  10321. case sopnode.FieldConditionList:
  10322. return m.ConditionList()
  10323. case sopnode.FieldNoReplyCondition:
  10324. return m.NoReplyCondition()
  10325. case sopnode.FieldActionMessage:
  10326. return m.ActionMessage()
  10327. case sopnode.FieldActionLabel:
  10328. return m.ActionLabel()
  10329. }
  10330. return nil, false
  10331. }
  10332. // OldField returns the old value of the field from the database. An error is
  10333. // returned if the mutation operation is not UpdateOne, or the query to the
  10334. // database failed.
  10335. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10336. switch name {
  10337. case sopnode.FieldCreatedAt:
  10338. return m.OldCreatedAt(ctx)
  10339. case sopnode.FieldUpdatedAt:
  10340. return m.OldUpdatedAt(ctx)
  10341. case sopnode.FieldStatus:
  10342. return m.OldStatus(ctx)
  10343. case sopnode.FieldDeletedAt:
  10344. return m.OldDeletedAt(ctx)
  10345. case sopnode.FieldStageID:
  10346. return m.OldStageID(ctx)
  10347. case sopnode.FieldParentID:
  10348. return m.OldParentID(ctx)
  10349. case sopnode.FieldName:
  10350. return m.OldName(ctx)
  10351. case sopnode.FieldConditionType:
  10352. return m.OldConditionType(ctx)
  10353. case sopnode.FieldConditionList:
  10354. return m.OldConditionList(ctx)
  10355. case sopnode.FieldNoReplyCondition:
  10356. return m.OldNoReplyCondition(ctx)
  10357. case sopnode.FieldActionMessage:
  10358. return m.OldActionMessage(ctx)
  10359. case sopnode.FieldActionLabel:
  10360. return m.OldActionLabel(ctx)
  10361. }
  10362. return nil, fmt.Errorf("unknown SopNode field %s", name)
  10363. }
  10364. // SetField sets the value of a field with the given name. It returns an error if
  10365. // the field is not defined in the schema, or if the type mismatched the field
  10366. // type.
  10367. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  10368. switch name {
  10369. case sopnode.FieldCreatedAt:
  10370. v, ok := value.(time.Time)
  10371. if !ok {
  10372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10373. }
  10374. m.SetCreatedAt(v)
  10375. return nil
  10376. case sopnode.FieldUpdatedAt:
  10377. v, ok := value.(time.Time)
  10378. if !ok {
  10379. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10380. }
  10381. m.SetUpdatedAt(v)
  10382. return nil
  10383. case sopnode.FieldStatus:
  10384. v, ok := value.(uint8)
  10385. if !ok {
  10386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10387. }
  10388. m.SetStatus(v)
  10389. return nil
  10390. case sopnode.FieldDeletedAt:
  10391. v, ok := value.(time.Time)
  10392. if !ok {
  10393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10394. }
  10395. m.SetDeletedAt(v)
  10396. return nil
  10397. case sopnode.FieldStageID:
  10398. v, ok := value.(uint64)
  10399. if !ok {
  10400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10401. }
  10402. m.SetStageID(v)
  10403. return nil
  10404. case sopnode.FieldParentID:
  10405. v, ok := value.(uint64)
  10406. if !ok {
  10407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10408. }
  10409. m.SetParentID(v)
  10410. return nil
  10411. case sopnode.FieldName:
  10412. v, ok := value.(string)
  10413. if !ok {
  10414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10415. }
  10416. m.SetName(v)
  10417. return nil
  10418. case sopnode.FieldConditionType:
  10419. v, ok := value.(int)
  10420. if !ok {
  10421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10422. }
  10423. m.SetConditionType(v)
  10424. return nil
  10425. case sopnode.FieldConditionList:
  10426. v, ok := value.([]string)
  10427. if !ok {
  10428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10429. }
  10430. m.SetConditionList(v)
  10431. return nil
  10432. case sopnode.FieldNoReplyCondition:
  10433. v, ok := value.(uint64)
  10434. if !ok {
  10435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10436. }
  10437. m.SetNoReplyCondition(v)
  10438. return nil
  10439. case sopnode.FieldActionMessage:
  10440. v, ok := value.([]custom_types.Action)
  10441. if !ok {
  10442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10443. }
  10444. m.SetActionMessage(v)
  10445. return nil
  10446. case sopnode.FieldActionLabel:
  10447. v, ok := value.([]uint64)
  10448. if !ok {
  10449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10450. }
  10451. m.SetActionLabel(v)
  10452. return nil
  10453. }
  10454. return fmt.Errorf("unknown SopNode field %s", name)
  10455. }
  10456. // AddedFields returns all numeric fields that were incremented/decremented during
  10457. // this mutation.
  10458. func (m *SopNodeMutation) AddedFields() []string {
  10459. var fields []string
  10460. if m.addstatus != nil {
  10461. fields = append(fields, sopnode.FieldStatus)
  10462. }
  10463. if m.addparent_id != nil {
  10464. fields = append(fields, sopnode.FieldParentID)
  10465. }
  10466. if m.addcondition_type != nil {
  10467. fields = append(fields, sopnode.FieldConditionType)
  10468. }
  10469. if m.addno_reply_condition != nil {
  10470. fields = append(fields, sopnode.FieldNoReplyCondition)
  10471. }
  10472. return fields
  10473. }
  10474. // AddedField returns the numeric value that was incremented/decremented on a field
  10475. // with the given name. The second boolean return value indicates that this field
  10476. // was not set, or was not defined in the schema.
  10477. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  10478. switch name {
  10479. case sopnode.FieldStatus:
  10480. return m.AddedStatus()
  10481. case sopnode.FieldParentID:
  10482. return m.AddedParentID()
  10483. case sopnode.FieldConditionType:
  10484. return m.AddedConditionType()
  10485. case sopnode.FieldNoReplyCondition:
  10486. return m.AddedNoReplyCondition()
  10487. }
  10488. return nil, false
  10489. }
  10490. // AddField adds the value to the field with the given name. It returns an error if
  10491. // the field is not defined in the schema, or if the type mismatched the field
  10492. // type.
  10493. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  10494. switch name {
  10495. case sopnode.FieldStatus:
  10496. v, ok := value.(int8)
  10497. if !ok {
  10498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10499. }
  10500. m.AddStatus(v)
  10501. return nil
  10502. case sopnode.FieldParentID:
  10503. v, ok := value.(int64)
  10504. if !ok {
  10505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10506. }
  10507. m.AddParentID(v)
  10508. return nil
  10509. case sopnode.FieldConditionType:
  10510. v, ok := value.(int)
  10511. if !ok {
  10512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10513. }
  10514. m.AddConditionType(v)
  10515. return nil
  10516. case sopnode.FieldNoReplyCondition:
  10517. v, ok := value.(int64)
  10518. if !ok {
  10519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10520. }
  10521. m.AddNoReplyCondition(v)
  10522. return nil
  10523. }
  10524. return fmt.Errorf("unknown SopNode numeric field %s", name)
  10525. }
  10526. // ClearedFields returns all nullable fields that were cleared during this
  10527. // mutation.
  10528. func (m *SopNodeMutation) ClearedFields() []string {
  10529. var fields []string
  10530. if m.FieldCleared(sopnode.FieldStatus) {
  10531. fields = append(fields, sopnode.FieldStatus)
  10532. }
  10533. if m.FieldCleared(sopnode.FieldDeletedAt) {
  10534. fields = append(fields, sopnode.FieldDeletedAt)
  10535. }
  10536. if m.FieldCleared(sopnode.FieldConditionList) {
  10537. fields = append(fields, sopnode.FieldConditionList)
  10538. }
  10539. if m.FieldCleared(sopnode.FieldActionMessage) {
  10540. fields = append(fields, sopnode.FieldActionMessage)
  10541. }
  10542. if m.FieldCleared(sopnode.FieldActionLabel) {
  10543. fields = append(fields, sopnode.FieldActionLabel)
  10544. }
  10545. return fields
  10546. }
  10547. // FieldCleared returns a boolean indicating if a field with the given name was
  10548. // cleared in this mutation.
  10549. func (m *SopNodeMutation) FieldCleared(name string) bool {
  10550. _, ok := m.clearedFields[name]
  10551. return ok
  10552. }
  10553. // ClearField clears the value of the field with the given name. It returns an
  10554. // error if the field is not defined in the schema.
  10555. func (m *SopNodeMutation) ClearField(name string) error {
  10556. switch name {
  10557. case sopnode.FieldStatus:
  10558. m.ClearStatus()
  10559. return nil
  10560. case sopnode.FieldDeletedAt:
  10561. m.ClearDeletedAt()
  10562. return nil
  10563. case sopnode.FieldConditionList:
  10564. m.ClearConditionList()
  10565. return nil
  10566. case sopnode.FieldActionMessage:
  10567. m.ClearActionMessage()
  10568. return nil
  10569. case sopnode.FieldActionLabel:
  10570. m.ClearActionLabel()
  10571. return nil
  10572. }
  10573. return fmt.Errorf("unknown SopNode nullable field %s", name)
  10574. }
  10575. // ResetField resets all changes in the mutation for the field with the given name.
  10576. // It returns an error if the field is not defined in the schema.
  10577. func (m *SopNodeMutation) ResetField(name string) error {
  10578. switch name {
  10579. case sopnode.FieldCreatedAt:
  10580. m.ResetCreatedAt()
  10581. return nil
  10582. case sopnode.FieldUpdatedAt:
  10583. m.ResetUpdatedAt()
  10584. return nil
  10585. case sopnode.FieldStatus:
  10586. m.ResetStatus()
  10587. return nil
  10588. case sopnode.FieldDeletedAt:
  10589. m.ResetDeletedAt()
  10590. return nil
  10591. case sopnode.FieldStageID:
  10592. m.ResetStageID()
  10593. return nil
  10594. case sopnode.FieldParentID:
  10595. m.ResetParentID()
  10596. return nil
  10597. case sopnode.FieldName:
  10598. m.ResetName()
  10599. return nil
  10600. case sopnode.FieldConditionType:
  10601. m.ResetConditionType()
  10602. return nil
  10603. case sopnode.FieldConditionList:
  10604. m.ResetConditionList()
  10605. return nil
  10606. case sopnode.FieldNoReplyCondition:
  10607. m.ResetNoReplyCondition()
  10608. return nil
  10609. case sopnode.FieldActionMessage:
  10610. m.ResetActionMessage()
  10611. return nil
  10612. case sopnode.FieldActionLabel:
  10613. m.ResetActionLabel()
  10614. return nil
  10615. }
  10616. return fmt.Errorf("unknown SopNode field %s", name)
  10617. }
  10618. // AddedEdges returns all edge names that were set/added in this mutation.
  10619. func (m *SopNodeMutation) AddedEdges() []string {
  10620. edges := make([]string, 0, 2)
  10621. if m.sop_stage != nil {
  10622. edges = append(edges, sopnode.EdgeSopStage)
  10623. }
  10624. if m.node_messages != nil {
  10625. edges = append(edges, sopnode.EdgeNodeMessages)
  10626. }
  10627. return edges
  10628. }
  10629. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10630. // name in this mutation.
  10631. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  10632. switch name {
  10633. case sopnode.EdgeSopStage:
  10634. if id := m.sop_stage; id != nil {
  10635. return []ent.Value{*id}
  10636. }
  10637. case sopnode.EdgeNodeMessages:
  10638. ids := make([]ent.Value, 0, len(m.node_messages))
  10639. for id := range m.node_messages {
  10640. ids = append(ids, id)
  10641. }
  10642. return ids
  10643. }
  10644. return nil
  10645. }
  10646. // RemovedEdges returns all edge names that were removed in this mutation.
  10647. func (m *SopNodeMutation) RemovedEdges() []string {
  10648. edges := make([]string, 0, 2)
  10649. if m.removednode_messages != nil {
  10650. edges = append(edges, sopnode.EdgeNodeMessages)
  10651. }
  10652. return edges
  10653. }
  10654. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10655. // the given name in this mutation.
  10656. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  10657. switch name {
  10658. case sopnode.EdgeNodeMessages:
  10659. ids := make([]ent.Value, 0, len(m.removednode_messages))
  10660. for id := range m.removednode_messages {
  10661. ids = append(ids, id)
  10662. }
  10663. return ids
  10664. }
  10665. return nil
  10666. }
  10667. // ClearedEdges returns all edge names that were cleared in this mutation.
  10668. func (m *SopNodeMutation) ClearedEdges() []string {
  10669. edges := make([]string, 0, 2)
  10670. if m.clearedsop_stage {
  10671. edges = append(edges, sopnode.EdgeSopStage)
  10672. }
  10673. if m.clearednode_messages {
  10674. edges = append(edges, sopnode.EdgeNodeMessages)
  10675. }
  10676. return edges
  10677. }
  10678. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10679. // was cleared in this mutation.
  10680. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  10681. switch name {
  10682. case sopnode.EdgeSopStage:
  10683. return m.clearedsop_stage
  10684. case sopnode.EdgeNodeMessages:
  10685. return m.clearednode_messages
  10686. }
  10687. return false
  10688. }
  10689. // ClearEdge clears the value of the edge with the given name. It returns an error
  10690. // if that edge is not defined in the schema.
  10691. func (m *SopNodeMutation) ClearEdge(name string) error {
  10692. switch name {
  10693. case sopnode.EdgeSopStage:
  10694. m.ClearSopStage()
  10695. return nil
  10696. }
  10697. return fmt.Errorf("unknown SopNode unique edge %s", name)
  10698. }
  10699. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10700. // It returns an error if the edge is not defined in the schema.
  10701. func (m *SopNodeMutation) ResetEdge(name string) error {
  10702. switch name {
  10703. case sopnode.EdgeSopStage:
  10704. m.ResetSopStage()
  10705. return nil
  10706. case sopnode.EdgeNodeMessages:
  10707. m.ResetNodeMessages()
  10708. return nil
  10709. }
  10710. return fmt.Errorf("unknown SopNode edge %s", name)
  10711. }
  10712. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  10713. type SopStageMutation struct {
  10714. config
  10715. op Op
  10716. typ string
  10717. id *uint64
  10718. created_at *time.Time
  10719. updated_at *time.Time
  10720. status *uint8
  10721. addstatus *int8
  10722. deleted_at *time.Time
  10723. name *string
  10724. condition_type *int
  10725. addcondition_type *int
  10726. condition_operator *int
  10727. addcondition_operator *int
  10728. condition_list *[]custom_types.Condition
  10729. appendcondition_list []custom_types.Condition
  10730. action_message *[]custom_types.Action
  10731. appendaction_message []custom_types.Action
  10732. action_label *[]uint64
  10733. appendaction_label []uint64
  10734. index_sort *int
  10735. addindex_sort *int
  10736. clearedFields map[string]struct{}
  10737. sop_task *uint64
  10738. clearedsop_task bool
  10739. stage_nodes map[uint64]struct{}
  10740. removedstage_nodes map[uint64]struct{}
  10741. clearedstage_nodes bool
  10742. stage_messages map[uint64]struct{}
  10743. removedstage_messages map[uint64]struct{}
  10744. clearedstage_messages bool
  10745. done bool
  10746. oldValue func(context.Context) (*SopStage, error)
  10747. predicates []predicate.SopStage
  10748. }
  10749. var _ ent.Mutation = (*SopStageMutation)(nil)
  10750. // sopstageOption allows management of the mutation configuration using functional options.
  10751. type sopstageOption func(*SopStageMutation)
  10752. // newSopStageMutation creates new mutation for the SopStage entity.
  10753. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  10754. m := &SopStageMutation{
  10755. config: c,
  10756. op: op,
  10757. typ: TypeSopStage,
  10758. clearedFields: make(map[string]struct{}),
  10759. }
  10760. for _, opt := range opts {
  10761. opt(m)
  10762. }
  10763. return m
  10764. }
  10765. // withSopStageID sets the ID field of the mutation.
  10766. func withSopStageID(id uint64) sopstageOption {
  10767. return func(m *SopStageMutation) {
  10768. var (
  10769. err error
  10770. once sync.Once
  10771. value *SopStage
  10772. )
  10773. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  10774. once.Do(func() {
  10775. if m.done {
  10776. err = errors.New("querying old values post mutation is not allowed")
  10777. } else {
  10778. value, err = m.Client().SopStage.Get(ctx, id)
  10779. }
  10780. })
  10781. return value, err
  10782. }
  10783. m.id = &id
  10784. }
  10785. }
  10786. // withSopStage sets the old SopStage of the mutation.
  10787. func withSopStage(node *SopStage) sopstageOption {
  10788. return func(m *SopStageMutation) {
  10789. m.oldValue = func(context.Context) (*SopStage, error) {
  10790. return node, nil
  10791. }
  10792. m.id = &node.ID
  10793. }
  10794. }
  10795. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10796. // executed in a transaction (ent.Tx), a transactional client is returned.
  10797. func (m SopStageMutation) Client() *Client {
  10798. client := &Client{config: m.config}
  10799. client.init()
  10800. return client
  10801. }
  10802. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10803. // it returns an error otherwise.
  10804. func (m SopStageMutation) Tx() (*Tx, error) {
  10805. if _, ok := m.driver.(*txDriver); !ok {
  10806. return nil, errors.New("ent: mutation is not running in a transaction")
  10807. }
  10808. tx := &Tx{config: m.config}
  10809. tx.init()
  10810. return tx, nil
  10811. }
  10812. // SetID sets the value of the id field. Note that this
  10813. // operation is only accepted on creation of SopStage entities.
  10814. func (m *SopStageMutation) SetID(id uint64) {
  10815. m.id = &id
  10816. }
  10817. // ID returns the ID value in the mutation. Note that the ID is only available
  10818. // if it was provided to the builder or after it was returned from the database.
  10819. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  10820. if m.id == nil {
  10821. return
  10822. }
  10823. return *m.id, true
  10824. }
  10825. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10826. // That means, if the mutation is applied within a transaction with an isolation level such
  10827. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10828. // or updated by the mutation.
  10829. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  10830. switch {
  10831. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10832. id, exists := m.ID()
  10833. if exists {
  10834. return []uint64{id}, nil
  10835. }
  10836. fallthrough
  10837. case m.op.Is(OpUpdate | OpDelete):
  10838. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  10839. default:
  10840. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10841. }
  10842. }
  10843. // SetCreatedAt sets the "created_at" field.
  10844. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  10845. m.created_at = &t
  10846. }
  10847. // CreatedAt returns the value of the "created_at" field in the mutation.
  10848. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  10849. v := m.created_at
  10850. if v == nil {
  10851. return
  10852. }
  10853. return *v, true
  10854. }
  10855. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  10856. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  10857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10858. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10859. if !m.op.Is(OpUpdateOne) {
  10860. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10861. }
  10862. if m.id == nil || m.oldValue == nil {
  10863. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10864. }
  10865. oldValue, err := m.oldValue(ctx)
  10866. if err != nil {
  10867. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10868. }
  10869. return oldValue.CreatedAt, nil
  10870. }
  10871. // ResetCreatedAt resets all changes to the "created_at" field.
  10872. func (m *SopStageMutation) ResetCreatedAt() {
  10873. m.created_at = nil
  10874. }
  10875. // SetUpdatedAt sets the "updated_at" field.
  10876. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  10877. m.updated_at = &t
  10878. }
  10879. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10880. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  10881. v := m.updated_at
  10882. if v == nil {
  10883. return
  10884. }
  10885. return *v, true
  10886. }
  10887. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  10888. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  10889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10890. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10891. if !m.op.Is(OpUpdateOne) {
  10892. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10893. }
  10894. if m.id == nil || m.oldValue == nil {
  10895. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10896. }
  10897. oldValue, err := m.oldValue(ctx)
  10898. if err != nil {
  10899. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10900. }
  10901. return oldValue.UpdatedAt, nil
  10902. }
  10903. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10904. func (m *SopStageMutation) ResetUpdatedAt() {
  10905. m.updated_at = nil
  10906. }
  10907. // SetStatus sets the "status" field.
  10908. func (m *SopStageMutation) SetStatus(u uint8) {
  10909. m.status = &u
  10910. m.addstatus = nil
  10911. }
  10912. // Status returns the value of the "status" field in the mutation.
  10913. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  10914. v := m.status
  10915. if v == nil {
  10916. return
  10917. }
  10918. return *v, true
  10919. }
  10920. // OldStatus returns the old "status" field's value of the SopStage entity.
  10921. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  10922. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10923. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  10924. if !m.op.Is(OpUpdateOne) {
  10925. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  10926. }
  10927. if m.id == nil || m.oldValue == nil {
  10928. return v, errors.New("OldStatus requires an ID field in the mutation")
  10929. }
  10930. oldValue, err := m.oldValue(ctx)
  10931. if err != nil {
  10932. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  10933. }
  10934. return oldValue.Status, nil
  10935. }
  10936. // AddStatus adds u to the "status" field.
  10937. func (m *SopStageMutation) AddStatus(u int8) {
  10938. if m.addstatus != nil {
  10939. *m.addstatus += u
  10940. } else {
  10941. m.addstatus = &u
  10942. }
  10943. }
  10944. // AddedStatus returns the value that was added to the "status" field in this mutation.
  10945. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  10946. v := m.addstatus
  10947. if v == nil {
  10948. return
  10949. }
  10950. return *v, true
  10951. }
  10952. // ClearStatus clears the value of the "status" field.
  10953. func (m *SopStageMutation) ClearStatus() {
  10954. m.status = nil
  10955. m.addstatus = nil
  10956. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  10957. }
  10958. // StatusCleared returns if the "status" field was cleared in this mutation.
  10959. func (m *SopStageMutation) StatusCleared() bool {
  10960. _, ok := m.clearedFields[sopstage.FieldStatus]
  10961. return ok
  10962. }
  10963. // ResetStatus resets all changes to the "status" field.
  10964. func (m *SopStageMutation) ResetStatus() {
  10965. m.status = nil
  10966. m.addstatus = nil
  10967. delete(m.clearedFields, sopstage.FieldStatus)
  10968. }
  10969. // SetDeletedAt sets the "deleted_at" field.
  10970. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  10971. m.deleted_at = &t
  10972. }
  10973. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10974. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  10975. v := m.deleted_at
  10976. if v == nil {
  10977. return
  10978. }
  10979. return *v, true
  10980. }
  10981. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  10982. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  10983. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10984. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10985. if !m.op.Is(OpUpdateOne) {
  10986. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10987. }
  10988. if m.id == nil || m.oldValue == nil {
  10989. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10990. }
  10991. oldValue, err := m.oldValue(ctx)
  10992. if err != nil {
  10993. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10994. }
  10995. return oldValue.DeletedAt, nil
  10996. }
  10997. // ClearDeletedAt clears the value of the "deleted_at" field.
  10998. func (m *SopStageMutation) ClearDeletedAt() {
  10999. m.deleted_at = nil
  11000. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  11001. }
  11002. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11003. func (m *SopStageMutation) DeletedAtCleared() bool {
  11004. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  11005. return ok
  11006. }
  11007. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11008. func (m *SopStageMutation) ResetDeletedAt() {
  11009. m.deleted_at = nil
  11010. delete(m.clearedFields, sopstage.FieldDeletedAt)
  11011. }
  11012. // SetTaskID sets the "task_id" field.
  11013. func (m *SopStageMutation) SetTaskID(u uint64) {
  11014. m.sop_task = &u
  11015. }
  11016. // TaskID returns the value of the "task_id" field in the mutation.
  11017. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  11018. v := m.sop_task
  11019. if v == nil {
  11020. return
  11021. }
  11022. return *v, true
  11023. }
  11024. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  11025. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  11026. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11027. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  11028. if !m.op.Is(OpUpdateOne) {
  11029. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  11030. }
  11031. if m.id == nil || m.oldValue == nil {
  11032. return v, errors.New("OldTaskID requires an ID field in the mutation")
  11033. }
  11034. oldValue, err := m.oldValue(ctx)
  11035. if err != nil {
  11036. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  11037. }
  11038. return oldValue.TaskID, nil
  11039. }
  11040. // ResetTaskID resets all changes to the "task_id" field.
  11041. func (m *SopStageMutation) ResetTaskID() {
  11042. m.sop_task = nil
  11043. }
  11044. // SetName sets the "name" field.
  11045. func (m *SopStageMutation) SetName(s string) {
  11046. m.name = &s
  11047. }
  11048. // Name returns the value of the "name" field in the mutation.
  11049. func (m *SopStageMutation) Name() (r string, exists bool) {
  11050. v := m.name
  11051. if v == nil {
  11052. return
  11053. }
  11054. return *v, true
  11055. }
  11056. // OldName returns the old "name" field's value of the SopStage entity.
  11057. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  11058. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11059. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  11060. if !m.op.Is(OpUpdateOne) {
  11061. return v, errors.New("OldName is only allowed on UpdateOne operations")
  11062. }
  11063. if m.id == nil || m.oldValue == nil {
  11064. return v, errors.New("OldName requires an ID field in the mutation")
  11065. }
  11066. oldValue, err := m.oldValue(ctx)
  11067. if err != nil {
  11068. return v, fmt.Errorf("querying old value for OldName: %w", err)
  11069. }
  11070. return oldValue.Name, nil
  11071. }
  11072. // ResetName resets all changes to the "name" field.
  11073. func (m *SopStageMutation) ResetName() {
  11074. m.name = nil
  11075. }
  11076. // SetConditionType sets the "condition_type" field.
  11077. func (m *SopStageMutation) SetConditionType(i int) {
  11078. m.condition_type = &i
  11079. m.addcondition_type = nil
  11080. }
  11081. // ConditionType returns the value of the "condition_type" field in the mutation.
  11082. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  11083. v := m.condition_type
  11084. if v == nil {
  11085. return
  11086. }
  11087. return *v, true
  11088. }
  11089. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  11090. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  11091. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11092. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  11093. if !m.op.Is(OpUpdateOne) {
  11094. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  11095. }
  11096. if m.id == nil || m.oldValue == nil {
  11097. return v, errors.New("OldConditionType requires an ID field in the mutation")
  11098. }
  11099. oldValue, err := m.oldValue(ctx)
  11100. if err != nil {
  11101. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  11102. }
  11103. return oldValue.ConditionType, nil
  11104. }
  11105. // AddConditionType adds i to the "condition_type" field.
  11106. func (m *SopStageMutation) AddConditionType(i int) {
  11107. if m.addcondition_type != nil {
  11108. *m.addcondition_type += i
  11109. } else {
  11110. m.addcondition_type = &i
  11111. }
  11112. }
  11113. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  11114. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  11115. v := m.addcondition_type
  11116. if v == nil {
  11117. return
  11118. }
  11119. return *v, true
  11120. }
  11121. // ResetConditionType resets all changes to the "condition_type" field.
  11122. func (m *SopStageMutation) ResetConditionType() {
  11123. m.condition_type = nil
  11124. m.addcondition_type = nil
  11125. }
  11126. // SetConditionOperator sets the "condition_operator" field.
  11127. func (m *SopStageMutation) SetConditionOperator(i int) {
  11128. m.condition_operator = &i
  11129. m.addcondition_operator = nil
  11130. }
  11131. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  11132. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  11133. v := m.condition_operator
  11134. if v == nil {
  11135. return
  11136. }
  11137. return *v, true
  11138. }
  11139. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  11140. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  11141. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11142. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  11143. if !m.op.Is(OpUpdateOne) {
  11144. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  11145. }
  11146. if m.id == nil || m.oldValue == nil {
  11147. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  11148. }
  11149. oldValue, err := m.oldValue(ctx)
  11150. if err != nil {
  11151. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  11152. }
  11153. return oldValue.ConditionOperator, nil
  11154. }
  11155. // AddConditionOperator adds i to the "condition_operator" field.
  11156. func (m *SopStageMutation) AddConditionOperator(i int) {
  11157. if m.addcondition_operator != nil {
  11158. *m.addcondition_operator += i
  11159. } else {
  11160. m.addcondition_operator = &i
  11161. }
  11162. }
  11163. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  11164. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  11165. v := m.addcondition_operator
  11166. if v == nil {
  11167. return
  11168. }
  11169. return *v, true
  11170. }
  11171. // ResetConditionOperator resets all changes to the "condition_operator" field.
  11172. func (m *SopStageMutation) ResetConditionOperator() {
  11173. m.condition_operator = nil
  11174. m.addcondition_operator = nil
  11175. }
  11176. // SetConditionList sets the "condition_list" field.
  11177. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  11178. m.condition_list = &ct
  11179. m.appendcondition_list = nil
  11180. }
  11181. // ConditionList returns the value of the "condition_list" field in the mutation.
  11182. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  11183. v := m.condition_list
  11184. if v == nil {
  11185. return
  11186. }
  11187. return *v, true
  11188. }
  11189. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  11190. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  11191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11192. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  11193. if !m.op.Is(OpUpdateOne) {
  11194. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  11195. }
  11196. if m.id == nil || m.oldValue == nil {
  11197. return v, errors.New("OldConditionList requires an ID field in the mutation")
  11198. }
  11199. oldValue, err := m.oldValue(ctx)
  11200. if err != nil {
  11201. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  11202. }
  11203. return oldValue.ConditionList, nil
  11204. }
  11205. // AppendConditionList adds ct to the "condition_list" field.
  11206. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  11207. m.appendcondition_list = append(m.appendcondition_list, ct...)
  11208. }
  11209. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  11210. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  11211. if len(m.appendcondition_list) == 0 {
  11212. return nil, false
  11213. }
  11214. return m.appendcondition_list, true
  11215. }
  11216. // ResetConditionList resets all changes to the "condition_list" field.
  11217. func (m *SopStageMutation) ResetConditionList() {
  11218. m.condition_list = nil
  11219. m.appendcondition_list = nil
  11220. }
  11221. // SetActionMessage sets the "action_message" field.
  11222. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  11223. m.action_message = &ct
  11224. m.appendaction_message = nil
  11225. }
  11226. // ActionMessage returns the value of the "action_message" field in the mutation.
  11227. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  11228. v := m.action_message
  11229. if v == nil {
  11230. return
  11231. }
  11232. return *v, true
  11233. }
  11234. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  11235. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  11236. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11237. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  11238. if !m.op.Is(OpUpdateOne) {
  11239. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  11240. }
  11241. if m.id == nil || m.oldValue == nil {
  11242. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  11243. }
  11244. oldValue, err := m.oldValue(ctx)
  11245. if err != nil {
  11246. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  11247. }
  11248. return oldValue.ActionMessage, nil
  11249. }
  11250. // AppendActionMessage adds ct to the "action_message" field.
  11251. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  11252. m.appendaction_message = append(m.appendaction_message, ct...)
  11253. }
  11254. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  11255. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  11256. if len(m.appendaction_message) == 0 {
  11257. return nil, false
  11258. }
  11259. return m.appendaction_message, true
  11260. }
  11261. // ClearActionMessage clears the value of the "action_message" field.
  11262. func (m *SopStageMutation) ClearActionMessage() {
  11263. m.action_message = nil
  11264. m.appendaction_message = nil
  11265. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  11266. }
  11267. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  11268. func (m *SopStageMutation) ActionMessageCleared() bool {
  11269. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  11270. return ok
  11271. }
  11272. // ResetActionMessage resets all changes to the "action_message" field.
  11273. func (m *SopStageMutation) ResetActionMessage() {
  11274. m.action_message = nil
  11275. m.appendaction_message = nil
  11276. delete(m.clearedFields, sopstage.FieldActionMessage)
  11277. }
  11278. // SetActionLabel sets the "action_label" field.
  11279. func (m *SopStageMutation) SetActionLabel(u []uint64) {
  11280. m.action_label = &u
  11281. m.appendaction_label = nil
  11282. }
  11283. // ActionLabel returns the value of the "action_label" field in the mutation.
  11284. func (m *SopStageMutation) ActionLabel() (r []uint64, exists bool) {
  11285. v := m.action_label
  11286. if v == nil {
  11287. return
  11288. }
  11289. return *v, true
  11290. }
  11291. // OldActionLabel returns the old "action_label" field's value of the SopStage entity.
  11292. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  11293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11294. func (m *SopStageMutation) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  11295. if !m.op.Is(OpUpdateOne) {
  11296. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  11297. }
  11298. if m.id == nil || m.oldValue == nil {
  11299. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  11300. }
  11301. oldValue, err := m.oldValue(ctx)
  11302. if err != nil {
  11303. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  11304. }
  11305. return oldValue.ActionLabel, nil
  11306. }
  11307. // AppendActionLabel adds u to the "action_label" field.
  11308. func (m *SopStageMutation) AppendActionLabel(u []uint64) {
  11309. m.appendaction_label = append(m.appendaction_label, u...)
  11310. }
  11311. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  11312. func (m *SopStageMutation) AppendedActionLabel() ([]uint64, bool) {
  11313. if len(m.appendaction_label) == 0 {
  11314. return nil, false
  11315. }
  11316. return m.appendaction_label, true
  11317. }
  11318. // ClearActionLabel clears the value of the "action_label" field.
  11319. func (m *SopStageMutation) ClearActionLabel() {
  11320. m.action_label = nil
  11321. m.appendaction_label = nil
  11322. m.clearedFields[sopstage.FieldActionLabel] = struct{}{}
  11323. }
  11324. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  11325. func (m *SopStageMutation) ActionLabelCleared() bool {
  11326. _, ok := m.clearedFields[sopstage.FieldActionLabel]
  11327. return ok
  11328. }
  11329. // ResetActionLabel resets all changes to the "action_label" field.
  11330. func (m *SopStageMutation) ResetActionLabel() {
  11331. m.action_label = nil
  11332. m.appendaction_label = nil
  11333. delete(m.clearedFields, sopstage.FieldActionLabel)
  11334. }
  11335. // SetIndexSort sets the "index_sort" field.
  11336. func (m *SopStageMutation) SetIndexSort(i int) {
  11337. m.index_sort = &i
  11338. m.addindex_sort = nil
  11339. }
  11340. // IndexSort returns the value of the "index_sort" field in the mutation.
  11341. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  11342. v := m.index_sort
  11343. if v == nil {
  11344. return
  11345. }
  11346. return *v, true
  11347. }
  11348. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  11349. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  11350. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11351. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  11352. if !m.op.Is(OpUpdateOne) {
  11353. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  11354. }
  11355. if m.id == nil || m.oldValue == nil {
  11356. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  11357. }
  11358. oldValue, err := m.oldValue(ctx)
  11359. if err != nil {
  11360. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  11361. }
  11362. return oldValue.IndexSort, nil
  11363. }
  11364. // AddIndexSort adds i to the "index_sort" field.
  11365. func (m *SopStageMutation) AddIndexSort(i int) {
  11366. if m.addindex_sort != nil {
  11367. *m.addindex_sort += i
  11368. } else {
  11369. m.addindex_sort = &i
  11370. }
  11371. }
  11372. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  11373. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  11374. v := m.addindex_sort
  11375. if v == nil {
  11376. return
  11377. }
  11378. return *v, true
  11379. }
  11380. // ClearIndexSort clears the value of the "index_sort" field.
  11381. func (m *SopStageMutation) ClearIndexSort() {
  11382. m.index_sort = nil
  11383. m.addindex_sort = nil
  11384. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  11385. }
  11386. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  11387. func (m *SopStageMutation) IndexSortCleared() bool {
  11388. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  11389. return ok
  11390. }
  11391. // ResetIndexSort resets all changes to the "index_sort" field.
  11392. func (m *SopStageMutation) ResetIndexSort() {
  11393. m.index_sort = nil
  11394. m.addindex_sort = nil
  11395. delete(m.clearedFields, sopstage.FieldIndexSort)
  11396. }
  11397. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  11398. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  11399. m.sop_task = &id
  11400. }
  11401. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  11402. func (m *SopStageMutation) ClearSopTask() {
  11403. m.clearedsop_task = true
  11404. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  11405. }
  11406. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  11407. func (m *SopStageMutation) SopTaskCleared() bool {
  11408. return m.clearedsop_task
  11409. }
  11410. // SopTaskID returns the "sop_task" edge ID in the mutation.
  11411. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  11412. if m.sop_task != nil {
  11413. return *m.sop_task, true
  11414. }
  11415. return
  11416. }
  11417. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  11418. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  11419. // SopTaskID instead. It exists only for internal usage by the builders.
  11420. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  11421. if id := m.sop_task; id != nil {
  11422. ids = append(ids, *id)
  11423. }
  11424. return
  11425. }
  11426. // ResetSopTask resets all changes to the "sop_task" edge.
  11427. func (m *SopStageMutation) ResetSopTask() {
  11428. m.sop_task = nil
  11429. m.clearedsop_task = false
  11430. }
  11431. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  11432. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  11433. if m.stage_nodes == nil {
  11434. m.stage_nodes = make(map[uint64]struct{})
  11435. }
  11436. for i := range ids {
  11437. m.stage_nodes[ids[i]] = struct{}{}
  11438. }
  11439. }
  11440. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  11441. func (m *SopStageMutation) ClearStageNodes() {
  11442. m.clearedstage_nodes = true
  11443. }
  11444. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  11445. func (m *SopStageMutation) StageNodesCleared() bool {
  11446. return m.clearedstage_nodes
  11447. }
  11448. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  11449. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  11450. if m.removedstage_nodes == nil {
  11451. m.removedstage_nodes = make(map[uint64]struct{})
  11452. }
  11453. for i := range ids {
  11454. delete(m.stage_nodes, ids[i])
  11455. m.removedstage_nodes[ids[i]] = struct{}{}
  11456. }
  11457. }
  11458. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  11459. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  11460. for id := range m.removedstage_nodes {
  11461. ids = append(ids, id)
  11462. }
  11463. return
  11464. }
  11465. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  11466. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  11467. for id := range m.stage_nodes {
  11468. ids = append(ids, id)
  11469. }
  11470. return
  11471. }
  11472. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  11473. func (m *SopStageMutation) ResetStageNodes() {
  11474. m.stage_nodes = nil
  11475. m.clearedstage_nodes = false
  11476. m.removedstage_nodes = nil
  11477. }
  11478. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  11479. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  11480. if m.stage_messages == nil {
  11481. m.stage_messages = make(map[uint64]struct{})
  11482. }
  11483. for i := range ids {
  11484. m.stage_messages[ids[i]] = struct{}{}
  11485. }
  11486. }
  11487. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  11488. func (m *SopStageMutation) ClearStageMessages() {
  11489. m.clearedstage_messages = true
  11490. }
  11491. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  11492. func (m *SopStageMutation) StageMessagesCleared() bool {
  11493. return m.clearedstage_messages
  11494. }
  11495. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  11496. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  11497. if m.removedstage_messages == nil {
  11498. m.removedstage_messages = make(map[uint64]struct{})
  11499. }
  11500. for i := range ids {
  11501. delete(m.stage_messages, ids[i])
  11502. m.removedstage_messages[ids[i]] = struct{}{}
  11503. }
  11504. }
  11505. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  11506. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  11507. for id := range m.removedstage_messages {
  11508. ids = append(ids, id)
  11509. }
  11510. return
  11511. }
  11512. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  11513. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  11514. for id := range m.stage_messages {
  11515. ids = append(ids, id)
  11516. }
  11517. return
  11518. }
  11519. // ResetStageMessages resets all changes to the "stage_messages" edge.
  11520. func (m *SopStageMutation) ResetStageMessages() {
  11521. m.stage_messages = nil
  11522. m.clearedstage_messages = false
  11523. m.removedstage_messages = nil
  11524. }
  11525. // Where appends a list predicates to the SopStageMutation builder.
  11526. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  11527. m.predicates = append(m.predicates, ps...)
  11528. }
  11529. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  11530. // users can use type-assertion to append predicates that do not depend on any generated package.
  11531. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  11532. p := make([]predicate.SopStage, len(ps))
  11533. for i := range ps {
  11534. p[i] = ps[i]
  11535. }
  11536. m.Where(p...)
  11537. }
  11538. // Op returns the operation name.
  11539. func (m *SopStageMutation) Op() Op {
  11540. return m.op
  11541. }
  11542. // SetOp allows setting the mutation operation.
  11543. func (m *SopStageMutation) SetOp(op Op) {
  11544. m.op = op
  11545. }
  11546. // Type returns the node type of this mutation (SopStage).
  11547. func (m *SopStageMutation) Type() string {
  11548. return m.typ
  11549. }
  11550. // Fields returns all fields that were changed during this mutation. Note that in
  11551. // order to get all numeric fields that were incremented/decremented, call
  11552. // AddedFields().
  11553. func (m *SopStageMutation) Fields() []string {
  11554. fields := make([]string, 0, 12)
  11555. if m.created_at != nil {
  11556. fields = append(fields, sopstage.FieldCreatedAt)
  11557. }
  11558. if m.updated_at != nil {
  11559. fields = append(fields, sopstage.FieldUpdatedAt)
  11560. }
  11561. if m.status != nil {
  11562. fields = append(fields, sopstage.FieldStatus)
  11563. }
  11564. if m.deleted_at != nil {
  11565. fields = append(fields, sopstage.FieldDeletedAt)
  11566. }
  11567. if m.sop_task != nil {
  11568. fields = append(fields, sopstage.FieldTaskID)
  11569. }
  11570. if m.name != nil {
  11571. fields = append(fields, sopstage.FieldName)
  11572. }
  11573. if m.condition_type != nil {
  11574. fields = append(fields, sopstage.FieldConditionType)
  11575. }
  11576. if m.condition_operator != nil {
  11577. fields = append(fields, sopstage.FieldConditionOperator)
  11578. }
  11579. if m.condition_list != nil {
  11580. fields = append(fields, sopstage.FieldConditionList)
  11581. }
  11582. if m.action_message != nil {
  11583. fields = append(fields, sopstage.FieldActionMessage)
  11584. }
  11585. if m.action_label != nil {
  11586. fields = append(fields, sopstage.FieldActionLabel)
  11587. }
  11588. if m.index_sort != nil {
  11589. fields = append(fields, sopstage.FieldIndexSort)
  11590. }
  11591. return fields
  11592. }
  11593. // Field returns the value of a field with the given name. The second boolean
  11594. // return value indicates that this field was not set, or was not defined in the
  11595. // schema.
  11596. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  11597. switch name {
  11598. case sopstage.FieldCreatedAt:
  11599. return m.CreatedAt()
  11600. case sopstage.FieldUpdatedAt:
  11601. return m.UpdatedAt()
  11602. case sopstage.FieldStatus:
  11603. return m.Status()
  11604. case sopstage.FieldDeletedAt:
  11605. return m.DeletedAt()
  11606. case sopstage.FieldTaskID:
  11607. return m.TaskID()
  11608. case sopstage.FieldName:
  11609. return m.Name()
  11610. case sopstage.FieldConditionType:
  11611. return m.ConditionType()
  11612. case sopstage.FieldConditionOperator:
  11613. return m.ConditionOperator()
  11614. case sopstage.FieldConditionList:
  11615. return m.ConditionList()
  11616. case sopstage.FieldActionMessage:
  11617. return m.ActionMessage()
  11618. case sopstage.FieldActionLabel:
  11619. return m.ActionLabel()
  11620. case sopstage.FieldIndexSort:
  11621. return m.IndexSort()
  11622. }
  11623. return nil, false
  11624. }
  11625. // OldField returns the old value of the field from the database. An error is
  11626. // returned if the mutation operation is not UpdateOne, or the query to the
  11627. // database failed.
  11628. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11629. switch name {
  11630. case sopstage.FieldCreatedAt:
  11631. return m.OldCreatedAt(ctx)
  11632. case sopstage.FieldUpdatedAt:
  11633. return m.OldUpdatedAt(ctx)
  11634. case sopstage.FieldStatus:
  11635. return m.OldStatus(ctx)
  11636. case sopstage.FieldDeletedAt:
  11637. return m.OldDeletedAt(ctx)
  11638. case sopstage.FieldTaskID:
  11639. return m.OldTaskID(ctx)
  11640. case sopstage.FieldName:
  11641. return m.OldName(ctx)
  11642. case sopstage.FieldConditionType:
  11643. return m.OldConditionType(ctx)
  11644. case sopstage.FieldConditionOperator:
  11645. return m.OldConditionOperator(ctx)
  11646. case sopstage.FieldConditionList:
  11647. return m.OldConditionList(ctx)
  11648. case sopstage.FieldActionMessage:
  11649. return m.OldActionMessage(ctx)
  11650. case sopstage.FieldActionLabel:
  11651. return m.OldActionLabel(ctx)
  11652. case sopstage.FieldIndexSort:
  11653. return m.OldIndexSort(ctx)
  11654. }
  11655. return nil, fmt.Errorf("unknown SopStage field %s", name)
  11656. }
  11657. // SetField sets the value of a field with the given name. It returns an error if
  11658. // the field is not defined in the schema, or if the type mismatched the field
  11659. // type.
  11660. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  11661. switch name {
  11662. case sopstage.FieldCreatedAt:
  11663. v, ok := value.(time.Time)
  11664. if !ok {
  11665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11666. }
  11667. m.SetCreatedAt(v)
  11668. return nil
  11669. case sopstage.FieldUpdatedAt:
  11670. v, ok := value.(time.Time)
  11671. if !ok {
  11672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11673. }
  11674. m.SetUpdatedAt(v)
  11675. return nil
  11676. case sopstage.FieldStatus:
  11677. v, ok := value.(uint8)
  11678. if !ok {
  11679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11680. }
  11681. m.SetStatus(v)
  11682. return nil
  11683. case sopstage.FieldDeletedAt:
  11684. v, ok := value.(time.Time)
  11685. if !ok {
  11686. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11687. }
  11688. m.SetDeletedAt(v)
  11689. return nil
  11690. case sopstage.FieldTaskID:
  11691. v, ok := value.(uint64)
  11692. if !ok {
  11693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11694. }
  11695. m.SetTaskID(v)
  11696. return nil
  11697. case sopstage.FieldName:
  11698. v, ok := value.(string)
  11699. if !ok {
  11700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11701. }
  11702. m.SetName(v)
  11703. return nil
  11704. case sopstage.FieldConditionType:
  11705. v, ok := value.(int)
  11706. if !ok {
  11707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11708. }
  11709. m.SetConditionType(v)
  11710. return nil
  11711. case sopstage.FieldConditionOperator:
  11712. v, ok := value.(int)
  11713. if !ok {
  11714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11715. }
  11716. m.SetConditionOperator(v)
  11717. return nil
  11718. case sopstage.FieldConditionList:
  11719. v, ok := value.([]custom_types.Condition)
  11720. if !ok {
  11721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11722. }
  11723. m.SetConditionList(v)
  11724. return nil
  11725. case sopstage.FieldActionMessage:
  11726. v, ok := value.([]custom_types.Action)
  11727. if !ok {
  11728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11729. }
  11730. m.SetActionMessage(v)
  11731. return nil
  11732. case sopstage.FieldActionLabel:
  11733. v, ok := value.([]uint64)
  11734. if !ok {
  11735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11736. }
  11737. m.SetActionLabel(v)
  11738. return nil
  11739. case sopstage.FieldIndexSort:
  11740. v, ok := value.(int)
  11741. if !ok {
  11742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11743. }
  11744. m.SetIndexSort(v)
  11745. return nil
  11746. }
  11747. return fmt.Errorf("unknown SopStage field %s", name)
  11748. }
  11749. // AddedFields returns all numeric fields that were incremented/decremented during
  11750. // this mutation.
  11751. func (m *SopStageMutation) AddedFields() []string {
  11752. var fields []string
  11753. if m.addstatus != nil {
  11754. fields = append(fields, sopstage.FieldStatus)
  11755. }
  11756. if m.addcondition_type != nil {
  11757. fields = append(fields, sopstage.FieldConditionType)
  11758. }
  11759. if m.addcondition_operator != nil {
  11760. fields = append(fields, sopstage.FieldConditionOperator)
  11761. }
  11762. if m.addindex_sort != nil {
  11763. fields = append(fields, sopstage.FieldIndexSort)
  11764. }
  11765. return fields
  11766. }
  11767. // AddedField returns the numeric value that was incremented/decremented on a field
  11768. // with the given name. The second boolean return value indicates that this field
  11769. // was not set, or was not defined in the schema.
  11770. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  11771. switch name {
  11772. case sopstage.FieldStatus:
  11773. return m.AddedStatus()
  11774. case sopstage.FieldConditionType:
  11775. return m.AddedConditionType()
  11776. case sopstage.FieldConditionOperator:
  11777. return m.AddedConditionOperator()
  11778. case sopstage.FieldIndexSort:
  11779. return m.AddedIndexSort()
  11780. }
  11781. return nil, false
  11782. }
  11783. // AddField adds the value to the field with the given name. It returns an error if
  11784. // the field is not defined in the schema, or if the type mismatched the field
  11785. // type.
  11786. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  11787. switch name {
  11788. case sopstage.FieldStatus:
  11789. v, ok := value.(int8)
  11790. if !ok {
  11791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11792. }
  11793. m.AddStatus(v)
  11794. return nil
  11795. case sopstage.FieldConditionType:
  11796. v, ok := value.(int)
  11797. if !ok {
  11798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11799. }
  11800. m.AddConditionType(v)
  11801. return nil
  11802. case sopstage.FieldConditionOperator:
  11803. v, ok := value.(int)
  11804. if !ok {
  11805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11806. }
  11807. m.AddConditionOperator(v)
  11808. return nil
  11809. case sopstage.FieldIndexSort:
  11810. v, ok := value.(int)
  11811. if !ok {
  11812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11813. }
  11814. m.AddIndexSort(v)
  11815. return nil
  11816. }
  11817. return fmt.Errorf("unknown SopStage numeric field %s", name)
  11818. }
  11819. // ClearedFields returns all nullable fields that were cleared during this
  11820. // mutation.
  11821. func (m *SopStageMutation) ClearedFields() []string {
  11822. var fields []string
  11823. if m.FieldCleared(sopstage.FieldStatus) {
  11824. fields = append(fields, sopstage.FieldStatus)
  11825. }
  11826. if m.FieldCleared(sopstage.FieldDeletedAt) {
  11827. fields = append(fields, sopstage.FieldDeletedAt)
  11828. }
  11829. if m.FieldCleared(sopstage.FieldActionMessage) {
  11830. fields = append(fields, sopstage.FieldActionMessage)
  11831. }
  11832. if m.FieldCleared(sopstage.FieldActionLabel) {
  11833. fields = append(fields, sopstage.FieldActionLabel)
  11834. }
  11835. if m.FieldCleared(sopstage.FieldIndexSort) {
  11836. fields = append(fields, sopstage.FieldIndexSort)
  11837. }
  11838. return fields
  11839. }
  11840. // FieldCleared returns a boolean indicating if a field with the given name was
  11841. // cleared in this mutation.
  11842. func (m *SopStageMutation) FieldCleared(name string) bool {
  11843. _, ok := m.clearedFields[name]
  11844. return ok
  11845. }
  11846. // ClearField clears the value of the field with the given name. It returns an
  11847. // error if the field is not defined in the schema.
  11848. func (m *SopStageMutation) ClearField(name string) error {
  11849. switch name {
  11850. case sopstage.FieldStatus:
  11851. m.ClearStatus()
  11852. return nil
  11853. case sopstage.FieldDeletedAt:
  11854. m.ClearDeletedAt()
  11855. return nil
  11856. case sopstage.FieldActionMessage:
  11857. m.ClearActionMessage()
  11858. return nil
  11859. case sopstage.FieldActionLabel:
  11860. m.ClearActionLabel()
  11861. return nil
  11862. case sopstage.FieldIndexSort:
  11863. m.ClearIndexSort()
  11864. return nil
  11865. }
  11866. return fmt.Errorf("unknown SopStage nullable field %s", name)
  11867. }
  11868. // ResetField resets all changes in the mutation for the field with the given name.
  11869. // It returns an error if the field is not defined in the schema.
  11870. func (m *SopStageMutation) ResetField(name string) error {
  11871. switch name {
  11872. case sopstage.FieldCreatedAt:
  11873. m.ResetCreatedAt()
  11874. return nil
  11875. case sopstage.FieldUpdatedAt:
  11876. m.ResetUpdatedAt()
  11877. return nil
  11878. case sopstage.FieldStatus:
  11879. m.ResetStatus()
  11880. return nil
  11881. case sopstage.FieldDeletedAt:
  11882. m.ResetDeletedAt()
  11883. return nil
  11884. case sopstage.FieldTaskID:
  11885. m.ResetTaskID()
  11886. return nil
  11887. case sopstage.FieldName:
  11888. m.ResetName()
  11889. return nil
  11890. case sopstage.FieldConditionType:
  11891. m.ResetConditionType()
  11892. return nil
  11893. case sopstage.FieldConditionOperator:
  11894. m.ResetConditionOperator()
  11895. return nil
  11896. case sopstage.FieldConditionList:
  11897. m.ResetConditionList()
  11898. return nil
  11899. case sopstage.FieldActionMessage:
  11900. m.ResetActionMessage()
  11901. return nil
  11902. case sopstage.FieldActionLabel:
  11903. m.ResetActionLabel()
  11904. return nil
  11905. case sopstage.FieldIndexSort:
  11906. m.ResetIndexSort()
  11907. return nil
  11908. }
  11909. return fmt.Errorf("unknown SopStage field %s", name)
  11910. }
  11911. // AddedEdges returns all edge names that were set/added in this mutation.
  11912. func (m *SopStageMutation) AddedEdges() []string {
  11913. edges := make([]string, 0, 3)
  11914. if m.sop_task != nil {
  11915. edges = append(edges, sopstage.EdgeSopTask)
  11916. }
  11917. if m.stage_nodes != nil {
  11918. edges = append(edges, sopstage.EdgeStageNodes)
  11919. }
  11920. if m.stage_messages != nil {
  11921. edges = append(edges, sopstage.EdgeStageMessages)
  11922. }
  11923. return edges
  11924. }
  11925. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11926. // name in this mutation.
  11927. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  11928. switch name {
  11929. case sopstage.EdgeSopTask:
  11930. if id := m.sop_task; id != nil {
  11931. return []ent.Value{*id}
  11932. }
  11933. case sopstage.EdgeStageNodes:
  11934. ids := make([]ent.Value, 0, len(m.stage_nodes))
  11935. for id := range m.stage_nodes {
  11936. ids = append(ids, id)
  11937. }
  11938. return ids
  11939. case sopstage.EdgeStageMessages:
  11940. ids := make([]ent.Value, 0, len(m.stage_messages))
  11941. for id := range m.stage_messages {
  11942. ids = append(ids, id)
  11943. }
  11944. return ids
  11945. }
  11946. return nil
  11947. }
  11948. // RemovedEdges returns all edge names that were removed in this mutation.
  11949. func (m *SopStageMutation) RemovedEdges() []string {
  11950. edges := make([]string, 0, 3)
  11951. if m.removedstage_nodes != nil {
  11952. edges = append(edges, sopstage.EdgeStageNodes)
  11953. }
  11954. if m.removedstage_messages != nil {
  11955. edges = append(edges, sopstage.EdgeStageMessages)
  11956. }
  11957. return edges
  11958. }
  11959. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11960. // the given name in this mutation.
  11961. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  11962. switch name {
  11963. case sopstage.EdgeStageNodes:
  11964. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  11965. for id := range m.removedstage_nodes {
  11966. ids = append(ids, id)
  11967. }
  11968. return ids
  11969. case sopstage.EdgeStageMessages:
  11970. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  11971. for id := range m.removedstage_messages {
  11972. ids = append(ids, id)
  11973. }
  11974. return ids
  11975. }
  11976. return nil
  11977. }
  11978. // ClearedEdges returns all edge names that were cleared in this mutation.
  11979. func (m *SopStageMutation) ClearedEdges() []string {
  11980. edges := make([]string, 0, 3)
  11981. if m.clearedsop_task {
  11982. edges = append(edges, sopstage.EdgeSopTask)
  11983. }
  11984. if m.clearedstage_nodes {
  11985. edges = append(edges, sopstage.EdgeStageNodes)
  11986. }
  11987. if m.clearedstage_messages {
  11988. edges = append(edges, sopstage.EdgeStageMessages)
  11989. }
  11990. return edges
  11991. }
  11992. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11993. // was cleared in this mutation.
  11994. func (m *SopStageMutation) EdgeCleared(name string) bool {
  11995. switch name {
  11996. case sopstage.EdgeSopTask:
  11997. return m.clearedsop_task
  11998. case sopstage.EdgeStageNodes:
  11999. return m.clearedstage_nodes
  12000. case sopstage.EdgeStageMessages:
  12001. return m.clearedstage_messages
  12002. }
  12003. return false
  12004. }
  12005. // ClearEdge clears the value of the edge with the given name. It returns an error
  12006. // if that edge is not defined in the schema.
  12007. func (m *SopStageMutation) ClearEdge(name string) error {
  12008. switch name {
  12009. case sopstage.EdgeSopTask:
  12010. m.ClearSopTask()
  12011. return nil
  12012. }
  12013. return fmt.Errorf("unknown SopStage unique edge %s", name)
  12014. }
  12015. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12016. // It returns an error if the edge is not defined in the schema.
  12017. func (m *SopStageMutation) ResetEdge(name string) error {
  12018. switch name {
  12019. case sopstage.EdgeSopTask:
  12020. m.ResetSopTask()
  12021. return nil
  12022. case sopstage.EdgeStageNodes:
  12023. m.ResetStageNodes()
  12024. return nil
  12025. case sopstage.EdgeStageMessages:
  12026. m.ResetStageMessages()
  12027. return nil
  12028. }
  12029. return fmt.Errorf("unknown SopStage edge %s", name)
  12030. }
  12031. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  12032. type SopTaskMutation struct {
  12033. config
  12034. op Op
  12035. typ string
  12036. id *uint64
  12037. created_at *time.Time
  12038. updated_at *time.Time
  12039. status *uint8
  12040. addstatus *int8
  12041. deleted_at *time.Time
  12042. name *string
  12043. bot_wxid_list *[]string
  12044. appendbot_wxid_list []string
  12045. _type *int
  12046. add_type *int
  12047. plan_start_time *time.Time
  12048. plan_end_time *time.Time
  12049. creator_id *string
  12050. organization_id *uint64
  12051. addorganization_id *int64
  12052. clearedFields map[string]struct{}
  12053. task_stages map[uint64]struct{}
  12054. removedtask_stages map[uint64]struct{}
  12055. clearedtask_stages bool
  12056. done bool
  12057. oldValue func(context.Context) (*SopTask, error)
  12058. predicates []predicate.SopTask
  12059. }
  12060. var _ ent.Mutation = (*SopTaskMutation)(nil)
  12061. // soptaskOption allows management of the mutation configuration using functional options.
  12062. type soptaskOption func(*SopTaskMutation)
  12063. // newSopTaskMutation creates new mutation for the SopTask entity.
  12064. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  12065. m := &SopTaskMutation{
  12066. config: c,
  12067. op: op,
  12068. typ: TypeSopTask,
  12069. clearedFields: make(map[string]struct{}),
  12070. }
  12071. for _, opt := range opts {
  12072. opt(m)
  12073. }
  12074. return m
  12075. }
  12076. // withSopTaskID sets the ID field of the mutation.
  12077. func withSopTaskID(id uint64) soptaskOption {
  12078. return func(m *SopTaskMutation) {
  12079. var (
  12080. err error
  12081. once sync.Once
  12082. value *SopTask
  12083. )
  12084. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  12085. once.Do(func() {
  12086. if m.done {
  12087. err = errors.New("querying old values post mutation is not allowed")
  12088. } else {
  12089. value, err = m.Client().SopTask.Get(ctx, id)
  12090. }
  12091. })
  12092. return value, err
  12093. }
  12094. m.id = &id
  12095. }
  12096. }
  12097. // withSopTask sets the old SopTask of the mutation.
  12098. func withSopTask(node *SopTask) soptaskOption {
  12099. return func(m *SopTaskMutation) {
  12100. m.oldValue = func(context.Context) (*SopTask, error) {
  12101. return node, nil
  12102. }
  12103. m.id = &node.ID
  12104. }
  12105. }
  12106. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12107. // executed in a transaction (ent.Tx), a transactional client is returned.
  12108. func (m SopTaskMutation) Client() *Client {
  12109. client := &Client{config: m.config}
  12110. client.init()
  12111. return client
  12112. }
  12113. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12114. // it returns an error otherwise.
  12115. func (m SopTaskMutation) Tx() (*Tx, error) {
  12116. if _, ok := m.driver.(*txDriver); !ok {
  12117. return nil, errors.New("ent: mutation is not running in a transaction")
  12118. }
  12119. tx := &Tx{config: m.config}
  12120. tx.init()
  12121. return tx, nil
  12122. }
  12123. // SetID sets the value of the id field. Note that this
  12124. // operation is only accepted on creation of SopTask entities.
  12125. func (m *SopTaskMutation) SetID(id uint64) {
  12126. m.id = &id
  12127. }
  12128. // ID returns the ID value in the mutation. Note that the ID is only available
  12129. // if it was provided to the builder or after it was returned from the database.
  12130. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  12131. if m.id == nil {
  12132. return
  12133. }
  12134. return *m.id, true
  12135. }
  12136. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12137. // That means, if the mutation is applied within a transaction with an isolation level such
  12138. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12139. // or updated by the mutation.
  12140. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  12141. switch {
  12142. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12143. id, exists := m.ID()
  12144. if exists {
  12145. return []uint64{id}, nil
  12146. }
  12147. fallthrough
  12148. case m.op.Is(OpUpdate | OpDelete):
  12149. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  12150. default:
  12151. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12152. }
  12153. }
  12154. // SetCreatedAt sets the "created_at" field.
  12155. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  12156. m.created_at = &t
  12157. }
  12158. // CreatedAt returns the value of the "created_at" field in the mutation.
  12159. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  12160. v := m.created_at
  12161. if v == nil {
  12162. return
  12163. }
  12164. return *v, true
  12165. }
  12166. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  12167. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12168. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12169. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12170. if !m.op.Is(OpUpdateOne) {
  12171. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12172. }
  12173. if m.id == nil || m.oldValue == nil {
  12174. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12175. }
  12176. oldValue, err := m.oldValue(ctx)
  12177. if err != nil {
  12178. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12179. }
  12180. return oldValue.CreatedAt, nil
  12181. }
  12182. // ResetCreatedAt resets all changes to the "created_at" field.
  12183. func (m *SopTaskMutation) ResetCreatedAt() {
  12184. m.created_at = nil
  12185. }
  12186. // SetUpdatedAt sets the "updated_at" field.
  12187. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  12188. m.updated_at = &t
  12189. }
  12190. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12191. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  12192. v := m.updated_at
  12193. if v == nil {
  12194. return
  12195. }
  12196. return *v, true
  12197. }
  12198. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  12199. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12200. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12201. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12202. if !m.op.Is(OpUpdateOne) {
  12203. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12204. }
  12205. if m.id == nil || m.oldValue == nil {
  12206. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12207. }
  12208. oldValue, err := m.oldValue(ctx)
  12209. if err != nil {
  12210. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12211. }
  12212. return oldValue.UpdatedAt, nil
  12213. }
  12214. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12215. func (m *SopTaskMutation) ResetUpdatedAt() {
  12216. m.updated_at = nil
  12217. }
  12218. // SetStatus sets the "status" field.
  12219. func (m *SopTaskMutation) SetStatus(u uint8) {
  12220. m.status = &u
  12221. m.addstatus = nil
  12222. }
  12223. // Status returns the value of the "status" field in the mutation.
  12224. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  12225. v := m.status
  12226. if v == nil {
  12227. return
  12228. }
  12229. return *v, true
  12230. }
  12231. // OldStatus returns the old "status" field's value of the SopTask entity.
  12232. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12233. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12234. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12235. if !m.op.Is(OpUpdateOne) {
  12236. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12237. }
  12238. if m.id == nil || m.oldValue == nil {
  12239. return v, errors.New("OldStatus requires an ID field in the mutation")
  12240. }
  12241. oldValue, err := m.oldValue(ctx)
  12242. if err != nil {
  12243. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12244. }
  12245. return oldValue.Status, nil
  12246. }
  12247. // AddStatus adds u to the "status" field.
  12248. func (m *SopTaskMutation) AddStatus(u int8) {
  12249. if m.addstatus != nil {
  12250. *m.addstatus += u
  12251. } else {
  12252. m.addstatus = &u
  12253. }
  12254. }
  12255. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12256. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  12257. v := m.addstatus
  12258. if v == nil {
  12259. return
  12260. }
  12261. return *v, true
  12262. }
  12263. // ClearStatus clears the value of the "status" field.
  12264. func (m *SopTaskMutation) ClearStatus() {
  12265. m.status = nil
  12266. m.addstatus = nil
  12267. m.clearedFields[soptask.FieldStatus] = struct{}{}
  12268. }
  12269. // StatusCleared returns if the "status" field was cleared in this mutation.
  12270. func (m *SopTaskMutation) StatusCleared() bool {
  12271. _, ok := m.clearedFields[soptask.FieldStatus]
  12272. return ok
  12273. }
  12274. // ResetStatus resets all changes to the "status" field.
  12275. func (m *SopTaskMutation) ResetStatus() {
  12276. m.status = nil
  12277. m.addstatus = nil
  12278. delete(m.clearedFields, soptask.FieldStatus)
  12279. }
  12280. // SetDeletedAt sets the "deleted_at" field.
  12281. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  12282. m.deleted_at = &t
  12283. }
  12284. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12285. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  12286. v := m.deleted_at
  12287. if v == nil {
  12288. return
  12289. }
  12290. return *v, true
  12291. }
  12292. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  12293. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12294. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12295. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12296. if !m.op.Is(OpUpdateOne) {
  12297. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12298. }
  12299. if m.id == nil || m.oldValue == nil {
  12300. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12301. }
  12302. oldValue, err := m.oldValue(ctx)
  12303. if err != nil {
  12304. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12305. }
  12306. return oldValue.DeletedAt, nil
  12307. }
  12308. // ClearDeletedAt clears the value of the "deleted_at" field.
  12309. func (m *SopTaskMutation) ClearDeletedAt() {
  12310. m.deleted_at = nil
  12311. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  12312. }
  12313. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12314. func (m *SopTaskMutation) DeletedAtCleared() bool {
  12315. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  12316. return ok
  12317. }
  12318. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12319. func (m *SopTaskMutation) ResetDeletedAt() {
  12320. m.deleted_at = nil
  12321. delete(m.clearedFields, soptask.FieldDeletedAt)
  12322. }
  12323. // SetName sets the "name" field.
  12324. func (m *SopTaskMutation) SetName(s string) {
  12325. m.name = &s
  12326. }
  12327. // Name returns the value of the "name" field in the mutation.
  12328. func (m *SopTaskMutation) Name() (r string, exists bool) {
  12329. v := m.name
  12330. if v == nil {
  12331. return
  12332. }
  12333. return *v, true
  12334. }
  12335. // OldName returns the old "name" field's value of the SopTask entity.
  12336. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12337. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12338. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  12339. if !m.op.Is(OpUpdateOne) {
  12340. return v, errors.New("OldName is only allowed on UpdateOne operations")
  12341. }
  12342. if m.id == nil || m.oldValue == nil {
  12343. return v, errors.New("OldName requires an ID field in the mutation")
  12344. }
  12345. oldValue, err := m.oldValue(ctx)
  12346. if err != nil {
  12347. return v, fmt.Errorf("querying old value for OldName: %w", err)
  12348. }
  12349. return oldValue.Name, nil
  12350. }
  12351. // ResetName resets all changes to the "name" field.
  12352. func (m *SopTaskMutation) ResetName() {
  12353. m.name = nil
  12354. }
  12355. // SetBotWxidList sets the "bot_wxid_list" field.
  12356. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  12357. m.bot_wxid_list = &s
  12358. m.appendbot_wxid_list = nil
  12359. }
  12360. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  12361. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  12362. v := m.bot_wxid_list
  12363. if v == nil {
  12364. return
  12365. }
  12366. return *v, true
  12367. }
  12368. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  12369. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12370. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12371. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  12372. if !m.op.Is(OpUpdateOne) {
  12373. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  12374. }
  12375. if m.id == nil || m.oldValue == nil {
  12376. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  12377. }
  12378. oldValue, err := m.oldValue(ctx)
  12379. if err != nil {
  12380. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  12381. }
  12382. return oldValue.BotWxidList, nil
  12383. }
  12384. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  12385. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  12386. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  12387. }
  12388. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  12389. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  12390. if len(m.appendbot_wxid_list) == 0 {
  12391. return nil, false
  12392. }
  12393. return m.appendbot_wxid_list, true
  12394. }
  12395. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  12396. func (m *SopTaskMutation) ClearBotWxidList() {
  12397. m.bot_wxid_list = nil
  12398. m.appendbot_wxid_list = nil
  12399. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  12400. }
  12401. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  12402. func (m *SopTaskMutation) BotWxidListCleared() bool {
  12403. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  12404. return ok
  12405. }
  12406. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  12407. func (m *SopTaskMutation) ResetBotWxidList() {
  12408. m.bot_wxid_list = nil
  12409. m.appendbot_wxid_list = nil
  12410. delete(m.clearedFields, soptask.FieldBotWxidList)
  12411. }
  12412. // SetType sets the "type" field.
  12413. func (m *SopTaskMutation) SetType(i int) {
  12414. m._type = &i
  12415. m.add_type = nil
  12416. }
  12417. // GetType returns the value of the "type" field in the mutation.
  12418. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  12419. v := m._type
  12420. if v == nil {
  12421. return
  12422. }
  12423. return *v, true
  12424. }
  12425. // OldType returns the old "type" field's value of the SopTask entity.
  12426. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12427. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12428. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  12429. if !m.op.Is(OpUpdateOne) {
  12430. return v, errors.New("OldType is only allowed on UpdateOne operations")
  12431. }
  12432. if m.id == nil || m.oldValue == nil {
  12433. return v, errors.New("OldType requires an ID field in the mutation")
  12434. }
  12435. oldValue, err := m.oldValue(ctx)
  12436. if err != nil {
  12437. return v, fmt.Errorf("querying old value for OldType: %w", err)
  12438. }
  12439. return oldValue.Type, nil
  12440. }
  12441. // AddType adds i to the "type" field.
  12442. func (m *SopTaskMutation) AddType(i int) {
  12443. if m.add_type != nil {
  12444. *m.add_type += i
  12445. } else {
  12446. m.add_type = &i
  12447. }
  12448. }
  12449. // AddedType returns the value that was added to the "type" field in this mutation.
  12450. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  12451. v := m.add_type
  12452. if v == nil {
  12453. return
  12454. }
  12455. return *v, true
  12456. }
  12457. // ResetType resets all changes to the "type" field.
  12458. func (m *SopTaskMutation) ResetType() {
  12459. m._type = nil
  12460. m.add_type = nil
  12461. }
  12462. // SetPlanStartTime sets the "plan_start_time" field.
  12463. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  12464. m.plan_start_time = &t
  12465. }
  12466. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  12467. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  12468. v := m.plan_start_time
  12469. if v == nil {
  12470. return
  12471. }
  12472. return *v, true
  12473. }
  12474. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  12475. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12476. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12477. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  12478. if !m.op.Is(OpUpdateOne) {
  12479. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  12480. }
  12481. if m.id == nil || m.oldValue == nil {
  12482. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  12483. }
  12484. oldValue, err := m.oldValue(ctx)
  12485. if err != nil {
  12486. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  12487. }
  12488. return oldValue.PlanStartTime, nil
  12489. }
  12490. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  12491. func (m *SopTaskMutation) ClearPlanStartTime() {
  12492. m.plan_start_time = nil
  12493. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  12494. }
  12495. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  12496. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  12497. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  12498. return ok
  12499. }
  12500. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  12501. func (m *SopTaskMutation) ResetPlanStartTime() {
  12502. m.plan_start_time = nil
  12503. delete(m.clearedFields, soptask.FieldPlanStartTime)
  12504. }
  12505. // SetPlanEndTime sets the "plan_end_time" field.
  12506. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  12507. m.plan_end_time = &t
  12508. }
  12509. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  12510. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  12511. v := m.plan_end_time
  12512. if v == nil {
  12513. return
  12514. }
  12515. return *v, true
  12516. }
  12517. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  12518. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12519. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12520. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  12521. if !m.op.Is(OpUpdateOne) {
  12522. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  12523. }
  12524. if m.id == nil || m.oldValue == nil {
  12525. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  12526. }
  12527. oldValue, err := m.oldValue(ctx)
  12528. if err != nil {
  12529. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  12530. }
  12531. return oldValue.PlanEndTime, nil
  12532. }
  12533. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  12534. func (m *SopTaskMutation) ClearPlanEndTime() {
  12535. m.plan_end_time = nil
  12536. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  12537. }
  12538. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  12539. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  12540. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  12541. return ok
  12542. }
  12543. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  12544. func (m *SopTaskMutation) ResetPlanEndTime() {
  12545. m.plan_end_time = nil
  12546. delete(m.clearedFields, soptask.FieldPlanEndTime)
  12547. }
  12548. // SetCreatorID sets the "creator_id" field.
  12549. func (m *SopTaskMutation) SetCreatorID(s string) {
  12550. m.creator_id = &s
  12551. }
  12552. // CreatorID returns the value of the "creator_id" field in the mutation.
  12553. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  12554. v := m.creator_id
  12555. if v == nil {
  12556. return
  12557. }
  12558. return *v, true
  12559. }
  12560. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  12561. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12562. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12563. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  12564. if !m.op.Is(OpUpdateOne) {
  12565. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  12566. }
  12567. if m.id == nil || m.oldValue == nil {
  12568. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  12569. }
  12570. oldValue, err := m.oldValue(ctx)
  12571. if err != nil {
  12572. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  12573. }
  12574. return oldValue.CreatorID, nil
  12575. }
  12576. // ClearCreatorID clears the value of the "creator_id" field.
  12577. func (m *SopTaskMutation) ClearCreatorID() {
  12578. m.creator_id = nil
  12579. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  12580. }
  12581. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  12582. func (m *SopTaskMutation) CreatorIDCleared() bool {
  12583. _, ok := m.clearedFields[soptask.FieldCreatorID]
  12584. return ok
  12585. }
  12586. // ResetCreatorID resets all changes to the "creator_id" field.
  12587. func (m *SopTaskMutation) ResetCreatorID() {
  12588. m.creator_id = nil
  12589. delete(m.clearedFields, soptask.FieldCreatorID)
  12590. }
  12591. // SetOrganizationID sets the "organization_id" field.
  12592. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  12593. m.organization_id = &u
  12594. m.addorganization_id = nil
  12595. }
  12596. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12597. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  12598. v := m.organization_id
  12599. if v == nil {
  12600. return
  12601. }
  12602. return *v, true
  12603. }
  12604. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  12605. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12606. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12607. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12608. if !m.op.Is(OpUpdateOne) {
  12609. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12610. }
  12611. if m.id == nil || m.oldValue == nil {
  12612. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12613. }
  12614. oldValue, err := m.oldValue(ctx)
  12615. if err != nil {
  12616. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12617. }
  12618. return oldValue.OrganizationID, nil
  12619. }
  12620. // AddOrganizationID adds u to the "organization_id" field.
  12621. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  12622. if m.addorganization_id != nil {
  12623. *m.addorganization_id += u
  12624. } else {
  12625. m.addorganization_id = &u
  12626. }
  12627. }
  12628. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12629. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  12630. v := m.addorganization_id
  12631. if v == nil {
  12632. return
  12633. }
  12634. return *v, true
  12635. }
  12636. // ClearOrganizationID clears the value of the "organization_id" field.
  12637. func (m *SopTaskMutation) ClearOrganizationID() {
  12638. m.organization_id = nil
  12639. m.addorganization_id = nil
  12640. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  12641. }
  12642. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  12643. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  12644. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  12645. return ok
  12646. }
  12647. // ResetOrganizationID resets all changes to the "organization_id" field.
  12648. func (m *SopTaskMutation) ResetOrganizationID() {
  12649. m.organization_id = nil
  12650. m.addorganization_id = nil
  12651. delete(m.clearedFields, soptask.FieldOrganizationID)
  12652. }
  12653. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  12654. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  12655. if m.task_stages == nil {
  12656. m.task_stages = make(map[uint64]struct{})
  12657. }
  12658. for i := range ids {
  12659. m.task_stages[ids[i]] = struct{}{}
  12660. }
  12661. }
  12662. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  12663. func (m *SopTaskMutation) ClearTaskStages() {
  12664. m.clearedtask_stages = true
  12665. }
  12666. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  12667. func (m *SopTaskMutation) TaskStagesCleared() bool {
  12668. return m.clearedtask_stages
  12669. }
  12670. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  12671. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  12672. if m.removedtask_stages == nil {
  12673. m.removedtask_stages = make(map[uint64]struct{})
  12674. }
  12675. for i := range ids {
  12676. delete(m.task_stages, ids[i])
  12677. m.removedtask_stages[ids[i]] = struct{}{}
  12678. }
  12679. }
  12680. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  12681. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  12682. for id := range m.removedtask_stages {
  12683. ids = append(ids, id)
  12684. }
  12685. return
  12686. }
  12687. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  12688. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  12689. for id := range m.task_stages {
  12690. ids = append(ids, id)
  12691. }
  12692. return
  12693. }
  12694. // ResetTaskStages resets all changes to the "task_stages" edge.
  12695. func (m *SopTaskMutation) ResetTaskStages() {
  12696. m.task_stages = nil
  12697. m.clearedtask_stages = false
  12698. m.removedtask_stages = nil
  12699. }
  12700. // Where appends a list predicates to the SopTaskMutation builder.
  12701. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  12702. m.predicates = append(m.predicates, ps...)
  12703. }
  12704. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  12705. // users can use type-assertion to append predicates that do not depend on any generated package.
  12706. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  12707. p := make([]predicate.SopTask, len(ps))
  12708. for i := range ps {
  12709. p[i] = ps[i]
  12710. }
  12711. m.Where(p...)
  12712. }
  12713. // Op returns the operation name.
  12714. func (m *SopTaskMutation) Op() Op {
  12715. return m.op
  12716. }
  12717. // SetOp allows setting the mutation operation.
  12718. func (m *SopTaskMutation) SetOp(op Op) {
  12719. m.op = op
  12720. }
  12721. // Type returns the node type of this mutation (SopTask).
  12722. func (m *SopTaskMutation) Type() string {
  12723. return m.typ
  12724. }
  12725. // Fields returns all fields that were changed during this mutation. Note that in
  12726. // order to get all numeric fields that were incremented/decremented, call
  12727. // AddedFields().
  12728. func (m *SopTaskMutation) Fields() []string {
  12729. fields := make([]string, 0, 11)
  12730. if m.created_at != nil {
  12731. fields = append(fields, soptask.FieldCreatedAt)
  12732. }
  12733. if m.updated_at != nil {
  12734. fields = append(fields, soptask.FieldUpdatedAt)
  12735. }
  12736. if m.status != nil {
  12737. fields = append(fields, soptask.FieldStatus)
  12738. }
  12739. if m.deleted_at != nil {
  12740. fields = append(fields, soptask.FieldDeletedAt)
  12741. }
  12742. if m.name != nil {
  12743. fields = append(fields, soptask.FieldName)
  12744. }
  12745. if m.bot_wxid_list != nil {
  12746. fields = append(fields, soptask.FieldBotWxidList)
  12747. }
  12748. if m._type != nil {
  12749. fields = append(fields, soptask.FieldType)
  12750. }
  12751. if m.plan_start_time != nil {
  12752. fields = append(fields, soptask.FieldPlanStartTime)
  12753. }
  12754. if m.plan_end_time != nil {
  12755. fields = append(fields, soptask.FieldPlanEndTime)
  12756. }
  12757. if m.creator_id != nil {
  12758. fields = append(fields, soptask.FieldCreatorID)
  12759. }
  12760. if m.organization_id != nil {
  12761. fields = append(fields, soptask.FieldOrganizationID)
  12762. }
  12763. return fields
  12764. }
  12765. // Field returns the value of a field with the given name. The second boolean
  12766. // return value indicates that this field was not set, or was not defined in the
  12767. // schema.
  12768. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  12769. switch name {
  12770. case soptask.FieldCreatedAt:
  12771. return m.CreatedAt()
  12772. case soptask.FieldUpdatedAt:
  12773. return m.UpdatedAt()
  12774. case soptask.FieldStatus:
  12775. return m.Status()
  12776. case soptask.FieldDeletedAt:
  12777. return m.DeletedAt()
  12778. case soptask.FieldName:
  12779. return m.Name()
  12780. case soptask.FieldBotWxidList:
  12781. return m.BotWxidList()
  12782. case soptask.FieldType:
  12783. return m.GetType()
  12784. case soptask.FieldPlanStartTime:
  12785. return m.PlanStartTime()
  12786. case soptask.FieldPlanEndTime:
  12787. return m.PlanEndTime()
  12788. case soptask.FieldCreatorID:
  12789. return m.CreatorID()
  12790. case soptask.FieldOrganizationID:
  12791. return m.OrganizationID()
  12792. }
  12793. return nil, false
  12794. }
  12795. // OldField returns the old value of the field from the database. An error is
  12796. // returned if the mutation operation is not UpdateOne, or the query to the
  12797. // database failed.
  12798. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12799. switch name {
  12800. case soptask.FieldCreatedAt:
  12801. return m.OldCreatedAt(ctx)
  12802. case soptask.FieldUpdatedAt:
  12803. return m.OldUpdatedAt(ctx)
  12804. case soptask.FieldStatus:
  12805. return m.OldStatus(ctx)
  12806. case soptask.FieldDeletedAt:
  12807. return m.OldDeletedAt(ctx)
  12808. case soptask.FieldName:
  12809. return m.OldName(ctx)
  12810. case soptask.FieldBotWxidList:
  12811. return m.OldBotWxidList(ctx)
  12812. case soptask.FieldType:
  12813. return m.OldType(ctx)
  12814. case soptask.FieldPlanStartTime:
  12815. return m.OldPlanStartTime(ctx)
  12816. case soptask.FieldPlanEndTime:
  12817. return m.OldPlanEndTime(ctx)
  12818. case soptask.FieldCreatorID:
  12819. return m.OldCreatorID(ctx)
  12820. case soptask.FieldOrganizationID:
  12821. return m.OldOrganizationID(ctx)
  12822. }
  12823. return nil, fmt.Errorf("unknown SopTask field %s", name)
  12824. }
  12825. // SetField sets the value of a field with the given name. It returns an error if
  12826. // the field is not defined in the schema, or if the type mismatched the field
  12827. // type.
  12828. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  12829. switch name {
  12830. case soptask.FieldCreatedAt:
  12831. v, ok := value.(time.Time)
  12832. if !ok {
  12833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12834. }
  12835. m.SetCreatedAt(v)
  12836. return nil
  12837. case soptask.FieldUpdatedAt:
  12838. v, ok := value.(time.Time)
  12839. if !ok {
  12840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12841. }
  12842. m.SetUpdatedAt(v)
  12843. return nil
  12844. case soptask.FieldStatus:
  12845. v, ok := value.(uint8)
  12846. if !ok {
  12847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12848. }
  12849. m.SetStatus(v)
  12850. return nil
  12851. case soptask.FieldDeletedAt:
  12852. v, ok := value.(time.Time)
  12853. if !ok {
  12854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12855. }
  12856. m.SetDeletedAt(v)
  12857. return nil
  12858. case soptask.FieldName:
  12859. v, ok := value.(string)
  12860. if !ok {
  12861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12862. }
  12863. m.SetName(v)
  12864. return nil
  12865. case soptask.FieldBotWxidList:
  12866. v, ok := value.([]string)
  12867. if !ok {
  12868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12869. }
  12870. m.SetBotWxidList(v)
  12871. return nil
  12872. case soptask.FieldType:
  12873. v, ok := value.(int)
  12874. if !ok {
  12875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12876. }
  12877. m.SetType(v)
  12878. return nil
  12879. case soptask.FieldPlanStartTime:
  12880. v, ok := value.(time.Time)
  12881. if !ok {
  12882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12883. }
  12884. m.SetPlanStartTime(v)
  12885. return nil
  12886. case soptask.FieldPlanEndTime:
  12887. v, ok := value.(time.Time)
  12888. if !ok {
  12889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12890. }
  12891. m.SetPlanEndTime(v)
  12892. return nil
  12893. case soptask.FieldCreatorID:
  12894. v, ok := value.(string)
  12895. if !ok {
  12896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12897. }
  12898. m.SetCreatorID(v)
  12899. return nil
  12900. case soptask.FieldOrganizationID:
  12901. v, ok := value.(uint64)
  12902. if !ok {
  12903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12904. }
  12905. m.SetOrganizationID(v)
  12906. return nil
  12907. }
  12908. return fmt.Errorf("unknown SopTask field %s", name)
  12909. }
  12910. // AddedFields returns all numeric fields that were incremented/decremented during
  12911. // this mutation.
  12912. func (m *SopTaskMutation) AddedFields() []string {
  12913. var fields []string
  12914. if m.addstatus != nil {
  12915. fields = append(fields, soptask.FieldStatus)
  12916. }
  12917. if m.add_type != nil {
  12918. fields = append(fields, soptask.FieldType)
  12919. }
  12920. if m.addorganization_id != nil {
  12921. fields = append(fields, soptask.FieldOrganizationID)
  12922. }
  12923. return fields
  12924. }
  12925. // AddedField returns the numeric value that was incremented/decremented on a field
  12926. // with the given name. The second boolean return value indicates that this field
  12927. // was not set, or was not defined in the schema.
  12928. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  12929. switch name {
  12930. case soptask.FieldStatus:
  12931. return m.AddedStatus()
  12932. case soptask.FieldType:
  12933. return m.AddedType()
  12934. case soptask.FieldOrganizationID:
  12935. return m.AddedOrganizationID()
  12936. }
  12937. return nil, false
  12938. }
  12939. // AddField adds the value to the field with the given name. It returns an error if
  12940. // the field is not defined in the schema, or if the type mismatched the field
  12941. // type.
  12942. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  12943. switch name {
  12944. case soptask.FieldStatus:
  12945. v, ok := value.(int8)
  12946. if !ok {
  12947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12948. }
  12949. m.AddStatus(v)
  12950. return nil
  12951. case soptask.FieldType:
  12952. v, ok := value.(int)
  12953. if !ok {
  12954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12955. }
  12956. m.AddType(v)
  12957. return nil
  12958. case soptask.FieldOrganizationID:
  12959. v, ok := value.(int64)
  12960. if !ok {
  12961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12962. }
  12963. m.AddOrganizationID(v)
  12964. return nil
  12965. }
  12966. return fmt.Errorf("unknown SopTask numeric field %s", name)
  12967. }
  12968. // ClearedFields returns all nullable fields that were cleared during this
  12969. // mutation.
  12970. func (m *SopTaskMutation) ClearedFields() []string {
  12971. var fields []string
  12972. if m.FieldCleared(soptask.FieldStatus) {
  12973. fields = append(fields, soptask.FieldStatus)
  12974. }
  12975. if m.FieldCleared(soptask.FieldDeletedAt) {
  12976. fields = append(fields, soptask.FieldDeletedAt)
  12977. }
  12978. if m.FieldCleared(soptask.FieldBotWxidList) {
  12979. fields = append(fields, soptask.FieldBotWxidList)
  12980. }
  12981. if m.FieldCleared(soptask.FieldPlanStartTime) {
  12982. fields = append(fields, soptask.FieldPlanStartTime)
  12983. }
  12984. if m.FieldCleared(soptask.FieldPlanEndTime) {
  12985. fields = append(fields, soptask.FieldPlanEndTime)
  12986. }
  12987. if m.FieldCleared(soptask.FieldCreatorID) {
  12988. fields = append(fields, soptask.FieldCreatorID)
  12989. }
  12990. if m.FieldCleared(soptask.FieldOrganizationID) {
  12991. fields = append(fields, soptask.FieldOrganizationID)
  12992. }
  12993. return fields
  12994. }
  12995. // FieldCleared returns a boolean indicating if a field with the given name was
  12996. // cleared in this mutation.
  12997. func (m *SopTaskMutation) FieldCleared(name string) bool {
  12998. _, ok := m.clearedFields[name]
  12999. return ok
  13000. }
  13001. // ClearField clears the value of the field with the given name. It returns an
  13002. // error if the field is not defined in the schema.
  13003. func (m *SopTaskMutation) ClearField(name string) error {
  13004. switch name {
  13005. case soptask.FieldStatus:
  13006. m.ClearStatus()
  13007. return nil
  13008. case soptask.FieldDeletedAt:
  13009. m.ClearDeletedAt()
  13010. return nil
  13011. case soptask.FieldBotWxidList:
  13012. m.ClearBotWxidList()
  13013. return nil
  13014. case soptask.FieldPlanStartTime:
  13015. m.ClearPlanStartTime()
  13016. return nil
  13017. case soptask.FieldPlanEndTime:
  13018. m.ClearPlanEndTime()
  13019. return nil
  13020. case soptask.FieldCreatorID:
  13021. m.ClearCreatorID()
  13022. return nil
  13023. case soptask.FieldOrganizationID:
  13024. m.ClearOrganizationID()
  13025. return nil
  13026. }
  13027. return fmt.Errorf("unknown SopTask nullable field %s", name)
  13028. }
  13029. // ResetField resets all changes in the mutation for the field with the given name.
  13030. // It returns an error if the field is not defined in the schema.
  13031. func (m *SopTaskMutation) ResetField(name string) error {
  13032. switch name {
  13033. case soptask.FieldCreatedAt:
  13034. m.ResetCreatedAt()
  13035. return nil
  13036. case soptask.FieldUpdatedAt:
  13037. m.ResetUpdatedAt()
  13038. return nil
  13039. case soptask.FieldStatus:
  13040. m.ResetStatus()
  13041. return nil
  13042. case soptask.FieldDeletedAt:
  13043. m.ResetDeletedAt()
  13044. return nil
  13045. case soptask.FieldName:
  13046. m.ResetName()
  13047. return nil
  13048. case soptask.FieldBotWxidList:
  13049. m.ResetBotWxidList()
  13050. return nil
  13051. case soptask.FieldType:
  13052. m.ResetType()
  13053. return nil
  13054. case soptask.FieldPlanStartTime:
  13055. m.ResetPlanStartTime()
  13056. return nil
  13057. case soptask.FieldPlanEndTime:
  13058. m.ResetPlanEndTime()
  13059. return nil
  13060. case soptask.FieldCreatorID:
  13061. m.ResetCreatorID()
  13062. return nil
  13063. case soptask.FieldOrganizationID:
  13064. m.ResetOrganizationID()
  13065. return nil
  13066. }
  13067. return fmt.Errorf("unknown SopTask field %s", name)
  13068. }
  13069. // AddedEdges returns all edge names that were set/added in this mutation.
  13070. func (m *SopTaskMutation) AddedEdges() []string {
  13071. edges := make([]string, 0, 1)
  13072. if m.task_stages != nil {
  13073. edges = append(edges, soptask.EdgeTaskStages)
  13074. }
  13075. return edges
  13076. }
  13077. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13078. // name in this mutation.
  13079. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  13080. switch name {
  13081. case soptask.EdgeTaskStages:
  13082. ids := make([]ent.Value, 0, len(m.task_stages))
  13083. for id := range m.task_stages {
  13084. ids = append(ids, id)
  13085. }
  13086. return ids
  13087. }
  13088. return nil
  13089. }
  13090. // RemovedEdges returns all edge names that were removed in this mutation.
  13091. func (m *SopTaskMutation) RemovedEdges() []string {
  13092. edges := make([]string, 0, 1)
  13093. if m.removedtask_stages != nil {
  13094. edges = append(edges, soptask.EdgeTaskStages)
  13095. }
  13096. return edges
  13097. }
  13098. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13099. // the given name in this mutation.
  13100. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  13101. switch name {
  13102. case soptask.EdgeTaskStages:
  13103. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  13104. for id := range m.removedtask_stages {
  13105. ids = append(ids, id)
  13106. }
  13107. return ids
  13108. }
  13109. return nil
  13110. }
  13111. // ClearedEdges returns all edge names that were cleared in this mutation.
  13112. func (m *SopTaskMutation) ClearedEdges() []string {
  13113. edges := make([]string, 0, 1)
  13114. if m.clearedtask_stages {
  13115. edges = append(edges, soptask.EdgeTaskStages)
  13116. }
  13117. return edges
  13118. }
  13119. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13120. // was cleared in this mutation.
  13121. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  13122. switch name {
  13123. case soptask.EdgeTaskStages:
  13124. return m.clearedtask_stages
  13125. }
  13126. return false
  13127. }
  13128. // ClearEdge clears the value of the edge with the given name. It returns an error
  13129. // if that edge is not defined in the schema.
  13130. func (m *SopTaskMutation) ClearEdge(name string) error {
  13131. switch name {
  13132. }
  13133. return fmt.Errorf("unknown SopTask unique edge %s", name)
  13134. }
  13135. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13136. // It returns an error if the edge is not defined in the schema.
  13137. func (m *SopTaskMutation) ResetEdge(name string) error {
  13138. switch name {
  13139. case soptask.EdgeTaskStages:
  13140. m.ResetTaskStages()
  13141. return nil
  13142. }
  13143. return fmt.Errorf("unknown SopTask edge %s", name)
  13144. }
  13145. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  13146. type WxMutation struct {
  13147. config
  13148. op Op
  13149. typ string
  13150. id *uint64
  13151. created_at *time.Time
  13152. updated_at *time.Time
  13153. status *uint8
  13154. addstatus *int8
  13155. deleted_at *time.Time
  13156. port *string
  13157. process_id *string
  13158. callback *string
  13159. wxid *string
  13160. account *string
  13161. nickname *string
  13162. tel *string
  13163. head_big *string
  13164. organization_id *uint64
  13165. addorganization_id *int64
  13166. clearedFields map[string]struct{}
  13167. server *uint64
  13168. clearedserver bool
  13169. agent *uint64
  13170. clearedagent bool
  13171. done bool
  13172. oldValue func(context.Context) (*Wx, error)
  13173. predicates []predicate.Wx
  13174. }
  13175. var _ ent.Mutation = (*WxMutation)(nil)
  13176. // wxOption allows management of the mutation configuration using functional options.
  13177. type wxOption func(*WxMutation)
  13178. // newWxMutation creates new mutation for the Wx entity.
  13179. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  13180. m := &WxMutation{
  13181. config: c,
  13182. op: op,
  13183. typ: TypeWx,
  13184. clearedFields: make(map[string]struct{}),
  13185. }
  13186. for _, opt := range opts {
  13187. opt(m)
  13188. }
  13189. return m
  13190. }
  13191. // withWxID sets the ID field of the mutation.
  13192. func withWxID(id uint64) wxOption {
  13193. return func(m *WxMutation) {
  13194. var (
  13195. err error
  13196. once sync.Once
  13197. value *Wx
  13198. )
  13199. m.oldValue = func(ctx context.Context) (*Wx, error) {
  13200. once.Do(func() {
  13201. if m.done {
  13202. err = errors.New("querying old values post mutation is not allowed")
  13203. } else {
  13204. value, err = m.Client().Wx.Get(ctx, id)
  13205. }
  13206. })
  13207. return value, err
  13208. }
  13209. m.id = &id
  13210. }
  13211. }
  13212. // withWx sets the old Wx of the mutation.
  13213. func withWx(node *Wx) wxOption {
  13214. return func(m *WxMutation) {
  13215. m.oldValue = func(context.Context) (*Wx, error) {
  13216. return node, nil
  13217. }
  13218. m.id = &node.ID
  13219. }
  13220. }
  13221. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13222. // executed in a transaction (ent.Tx), a transactional client is returned.
  13223. func (m WxMutation) Client() *Client {
  13224. client := &Client{config: m.config}
  13225. client.init()
  13226. return client
  13227. }
  13228. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13229. // it returns an error otherwise.
  13230. func (m WxMutation) Tx() (*Tx, error) {
  13231. if _, ok := m.driver.(*txDriver); !ok {
  13232. return nil, errors.New("ent: mutation is not running in a transaction")
  13233. }
  13234. tx := &Tx{config: m.config}
  13235. tx.init()
  13236. return tx, nil
  13237. }
  13238. // SetID sets the value of the id field. Note that this
  13239. // operation is only accepted on creation of Wx entities.
  13240. func (m *WxMutation) SetID(id uint64) {
  13241. m.id = &id
  13242. }
  13243. // ID returns the ID value in the mutation. Note that the ID is only available
  13244. // if it was provided to the builder or after it was returned from the database.
  13245. func (m *WxMutation) ID() (id uint64, exists bool) {
  13246. if m.id == nil {
  13247. return
  13248. }
  13249. return *m.id, true
  13250. }
  13251. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13252. // That means, if the mutation is applied within a transaction with an isolation level such
  13253. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13254. // or updated by the mutation.
  13255. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  13256. switch {
  13257. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13258. id, exists := m.ID()
  13259. if exists {
  13260. return []uint64{id}, nil
  13261. }
  13262. fallthrough
  13263. case m.op.Is(OpUpdate | OpDelete):
  13264. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  13265. default:
  13266. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13267. }
  13268. }
  13269. // SetCreatedAt sets the "created_at" field.
  13270. func (m *WxMutation) SetCreatedAt(t time.Time) {
  13271. m.created_at = &t
  13272. }
  13273. // CreatedAt returns the value of the "created_at" field in the mutation.
  13274. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  13275. v := m.created_at
  13276. if v == nil {
  13277. return
  13278. }
  13279. return *v, true
  13280. }
  13281. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  13282. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13283. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13284. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13285. if !m.op.Is(OpUpdateOne) {
  13286. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13287. }
  13288. if m.id == nil || m.oldValue == nil {
  13289. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13290. }
  13291. oldValue, err := m.oldValue(ctx)
  13292. if err != nil {
  13293. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13294. }
  13295. return oldValue.CreatedAt, nil
  13296. }
  13297. // ResetCreatedAt resets all changes to the "created_at" field.
  13298. func (m *WxMutation) ResetCreatedAt() {
  13299. m.created_at = nil
  13300. }
  13301. // SetUpdatedAt sets the "updated_at" field.
  13302. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  13303. m.updated_at = &t
  13304. }
  13305. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13306. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  13307. v := m.updated_at
  13308. if v == nil {
  13309. return
  13310. }
  13311. return *v, true
  13312. }
  13313. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  13314. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13316. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13317. if !m.op.Is(OpUpdateOne) {
  13318. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13319. }
  13320. if m.id == nil || m.oldValue == nil {
  13321. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13322. }
  13323. oldValue, err := m.oldValue(ctx)
  13324. if err != nil {
  13325. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13326. }
  13327. return oldValue.UpdatedAt, nil
  13328. }
  13329. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13330. func (m *WxMutation) ResetUpdatedAt() {
  13331. m.updated_at = nil
  13332. }
  13333. // SetStatus sets the "status" field.
  13334. func (m *WxMutation) SetStatus(u uint8) {
  13335. m.status = &u
  13336. m.addstatus = nil
  13337. }
  13338. // Status returns the value of the "status" field in the mutation.
  13339. func (m *WxMutation) Status() (r uint8, exists bool) {
  13340. v := m.status
  13341. if v == nil {
  13342. return
  13343. }
  13344. return *v, true
  13345. }
  13346. // OldStatus returns the old "status" field's value of the Wx entity.
  13347. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13348. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13349. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13350. if !m.op.Is(OpUpdateOne) {
  13351. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13352. }
  13353. if m.id == nil || m.oldValue == nil {
  13354. return v, errors.New("OldStatus requires an ID field in the mutation")
  13355. }
  13356. oldValue, err := m.oldValue(ctx)
  13357. if err != nil {
  13358. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13359. }
  13360. return oldValue.Status, nil
  13361. }
  13362. // AddStatus adds u to the "status" field.
  13363. func (m *WxMutation) AddStatus(u int8) {
  13364. if m.addstatus != nil {
  13365. *m.addstatus += u
  13366. } else {
  13367. m.addstatus = &u
  13368. }
  13369. }
  13370. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13371. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  13372. v := m.addstatus
  13373. if v == nil {
  13374. return
  13375. }
  13376. return *v, true
  13377. }
  13378. // ClearStatus clears the value of the "status" field.
  13379. func (m *WxMutation) ClearStatus() {
  13380. m.status = nil
  13381. m.addstatus = nil
  13382. m.clearedFields[wx.FieldStatus] = struct{}{}
  13383. }
  13384. // StatusCleared returns if the "status" field was cleared in this mutation.
  13385. func (m *WxMutation) StatusCleared() bool {
  13386. _, ok := m.clearedFields[wx.FieldStatus]
  13387. return ok
  13388. }
  13389. // ResetStatus resets all changes to the "status" field.
  13390. func (m *WxMutation) ResetStatus() {
  13391. m.status = nil
  13392. m.addstatus = nil
  13393. delete(m.clearedFields, wx.FieldStatus)
  13394. }
  13395. // SetDeletedAt sets the "deleted_at" field.
  13396. func (m *WxMutation) SetDeletedAt(t time.Time) {
  13397. m.deleted_at = &t
  13398. }
  13399. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13400. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  13401. v := m.deleted_at
  13402. if v == nil {
  13403. return
  13404. }
  13405. return *v, true
  13406. }
  13407. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  13408. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13409. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13410. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13411. if !m.op.Is(OpUpdateOne) {
  13412. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13413. }
  13414. if m.id == nil || m.oldValue == nil {
  13415. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13416. }
  13417. oldValue, err := m.oldValue(ctx)
  13418. if err != nil {
  13419. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13420. }
  13421. return oldValue.DeletedAt, nil
  13422. }
  13423. // ClearDeletedAt clears the value of the "deleted_at" field.
  13424. func (m *WxMutation) ClearDeletedAt() {
  13425. m.deleted_at = nil
  13426. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  13427. }
  13428. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13429. func (m *WxMutation) DeletedAtCleared() bool {
  13430. _, ok := m.clearedFields[wx.FieldDeletedAt]
  13431. return ok
  13432. }
  13433. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13434. func (m *WxMutation) ResetDeletedAt() {
  13435. m.deleted_at = nil
  13436. delete(m.clearedFields, wx.FieldDeletedAt)
  13437. }
  13438. // SetServerID sets the "server_id" field.
  13439. func (m *WxMutation) SetServerID(u uint64) {
  13440. m.server = &u
  13441. }
  13442. // ServerID returns the value of the "server_id" field in the mutation.
  13443. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  13444. v := m.server
  13445. if v == nil {
  13446. return
  13447. }
  13448. return *v, true
  13449. }
  13450. // OldServerID returns the old "server_id" field's value of the Wx entity.
  13451. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13453. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  13454. if !m.op.Is(OpUpdateOne) {
  13455. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  13456. }
  13457. if m.id == nil || m.oldValue == nil {
  13458. return v, errors.New("OldServerID requires an ID field in the mutation")
  13459. }
  13460. oldValue, err := m.oldValue(ctx)
  13461. if err != nil {
  13462. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  13463. }
  13464. return oldValue.ServerID, nil
  13465. }
  13466. // ClearServerID clears the value of the "server_id" field.
  13467. func (m *WxMutation) ClearServerID() {
  13468. m.server = nil
  13469. m.clearedFields[wx.FieldServerID] = struct{}{}
  13470. }
  13471. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  13472. func (m *WxMutation) ServerIDCleared() bool {
  13473. _, ok := m.clearedFields[wx.FieldServerID]
  13474. return ok
  13475. }
  13476. // ResetServerID resets all changes to the "server_id" field.
  13477. func (m *WxMutation) ResetServerID() {
  13478. m.server = nil
  13479. delete(m.clearedFields, wx.FieldServerID)
  13480. }
  13481. // SetPort sets the "port" field.
  13482. func (m *WxMutation) SetPort(s string) {
  13483. m.port = &s
  13484. }
  13485. // Port returns the value of the "port" field in the mutation.
  13486. func (m *WxMutation) Port() (r string, exists bool) {
  13487. v := m.port
  13488. if v == nil {
  13489. return
  13490. }
  13491. return *v, true
  13492. }
  13493. // OldPort returns the old "port" field's value of the Wx entity.
  13494. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13496. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  13497. if !m.op.Is(OpUpdateOne) {
  13498. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  13499. }
  13500. if m.id == nil || m.oldValue == nil {
  13501. return v, errors.New("OldPort requires an ID field in the mutation")
  13502. }
  13503. oldValue, err := m.oldValue(ctx)
  13504. if err != nil {
  13505. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  13506. }
  13507. return oldValue.Port, nil
  13508. }
  13509. // ResetPort resets all changes to the "port" field.
  13510. func (m *WxMutation) ResetPort() {
  13511. m.port = nil
  13512. }
  13513. // SetProcessID sets the "process_id" field.
  13514. func (m *WxMutation) SetProcessID(s string) {
  13515. m.process_id = &s
  13516. }
  13517. // ProcessID returns the value of the "process_id" field in the mutation.
  13518. func (m *WxMutation) ProcessID() (r string, exists bool) {
  13519. v := m.process_id
  13520. if v == nil {
  13521. return
  13522. }
  13523. return *v, true
  13524. }
  13525. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  13526. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13527. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13528. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  13529. if !m.op.Is(OpUpdateOne) {
  13530. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  13531. }
  13532. if m.id == nil || m.oldValue == nil {
  13533. return v, errors.New("OldProcessID requires an ID field in the mutation")
  13534. }
  13535. oldValue, err := m.oldValue(ctx)
  13536. if err != nil {
  13537. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  13538. }
  13539. return oldValue.ProcessID, nil
  13540. }
  13541. // ResetProcessID resets all changes to the "process_id" field.
  13542. func (m *WxMutation) ResetProcessID() {
  13543. m.process_id = nil
  13544. }
  13545. // SetCallback sets the "callback" field.
  13546. func (m *WxMutation) SetCallback(s string) {
  13547. m.callback = &s
  13548. }
  13549. // Callback returns the value of the "callback" field in the mutation.
  13550. func (m *WxMutation) Callback() (r string, exists bool) {
  13551. v := m.callback
  13552. if v == nil {
  13553. return
  13554. }
  13555. return *v, true
  13556. }
  13557. // OldCallback returns the old "callback" field's value of the Wx entity.
  13558. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13559. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13560. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  13561. if !m.op.Is(OpUpdateOne) {
  13562. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  13563. }
  13564. if m.id == nil || m.oldValue == nil {
  13565. return v, errors.New("OldCallback requires an ID field in the mutation")
  13566. }
  13567. oldValue, err := m.oldValue(ctx)
  13568. if err != nil {
  13569. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  13570. }
  13571. return oldValue.Callback, nil
  13572. }
  13573. // ResetCallback resets all changes to the "callback" field.
  13574. func (m *WxMutation) ResetCallback() {
  13575. m.callback = nil
  13576. }
  13577. // SetWxid sets the "wxid" field.
  13578. func (m *WxMutation) SetWxid(s string) {
  13579. m.wxid = &s
  13580. }
  13581. // Wxid returns the value of the "wxid" field in the mutation.
  13582. func (m *WxMutation) Wxid() (r string, exists bool) {
  13583. v := m.wxid
  13584. if v == nil {
  13585. return
  13586. }
  13587. return *v, true
  13588. }
  13589. // OldWxid returns the old "wxid" field's value of the Wx entity.
  13590. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13591. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13592. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  13593. if !m.op.Is(OpUpdateOne) {
  13594. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  13595. }
  13596. if m.id == nil || m.oldValue == nil {
  13597. return v, errors.New("OldWxid requires an ID field in the mutation")
  13598. }
  13599. oldValue, err := m.oldValue(ctx)
  13600. if err != nil {
  13601. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  13602. }
  13603. return oldValue.Wxid, nil
  13604. }
  13605. // ResetWxid resets all changes to the "wxid" field.
  13606. func (m *WxMutation) ResetWxid() {
  13607. m.wxid = nil
  13608. }
  13609. // SetAccount sets the "account" field.
  13610. func (m *WxMutation) SetAccount(s string) {
  13611. m.account = &s
  13612. }
  13613. // Account returns the value of the "account" field in the mutation.
  13614. func (m *WxMutation) Account() (r string, exists bool) {
  13615. v := m.account
  13616. if v == nil {
  13617. return
  13618. }
  13619. return *v, true
  13620. }
  13621. // OldAccount returns the old "account" field's value of the Wx entity.
  13622. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13623. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13624. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  13625. if !m.op.Is(OpUpdateOne) {
  13626. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  13627. }
  13628. if m.id == nil || m.oldValue == nil {
  13629. return v, errors.New("OldAccount requires an ID field in the mutation")
  13630. }
  13631. oldValue, err := m.oldValue(ctx)
  13632. if err != nil {
  13633. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  13634. }
  13635. return oldValue.Account, nil
  13636. }
  13637. // ResetAccount resets all changes to the "account" field.
  13638. func (m *WxMutation) ResetAccount() {
  13639. m.account = nil
  13640. }
  13641. // SetNickname sets the "nickname" field.
  13642. func (m *WxMutation) SetNickname(s string) {
  13643. m.nickname = &s
  13644. }
  13645. // Nickname returns the value of the "nickname" field in the mutation.
  13646. func (m *WxMutation) Nickname() (r string, exists bool) {
  13647. v := m.nickname
  13648. if v == nil {
  13649. return
  13650. }
  13651. return *v, true
  13652. }
  13653. // OldNickname returns the old "nickname" field's value of the Wx entity.
  13654. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13655. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13656. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  13657. if !m.op.Is(OpUpdateOne) {
  13658. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  13659. }
  13660. if m.id == nil || m.oldValue == nil {
  13661. return v, errors.New("OldNickname requires an ID field in the mutation")
  13662. }
  13663. oldValue, err := m.oldValue(ctx)
  13664. if err != nil {
  13665. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  13666. }
  13667. return oldValue.Nickname, nil
  13668. }
  13669. // ResetNickname resets all changes to the "nickname" field.
  13670. func (m *WxMutation) ResetNickname() {
  13671. m.nickname = nil
  13672. }
  13673. // SetTel sets the "tel" field.
  13674. func (m *WxMutation) SetTel(s string) {
  13675. m.tel = &s
  13676. }
  13677. // Tel returns the value of the "tel" field in the mutation.
  13678. func (m *WxMutation) Tel() (r string, exists bool) {
  13679. v := m.tel
  13680. if v == nil {
  13681. return
  13682. }
  13683. return *v, true
  13684. }
  13685. // OldTel returns the old "tel" field's value of the Wx entity.
  13686. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13687. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13688. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  13689. if !m.op.Is(OpUpdateOne) {
  13690. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  13691. }
  13692. if m.id == nil || m.oldValue == nil {
  13693. return v, errors.New("OldTel requires an ID field in the mutation")
  13694. }
  13695. oldValue, err := m.oldValue(ctx)
  13696. if err != nil {
  13697. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  13698. }
  13699. return oldValue.Tel, nil
  13700. }
  13701. // ResetTel resets all changes to the "tel" field.
  13702. func (m *WxMutation) ResetTel() {
  13703. m.tel = nil
  13704. }
  13705. // SetHeadBig sets the "head_big" field.
  13706. func (m *WxMutation) SetHeadBig(s string) {
  13707. m.head_big = &s
  13708. }
  13709. // HeadBig returns the value of the "head_big" field in the mutation.
  13710. func (m *WxMutation) HeadBig() (r string, exists bool) {
  13711. v := m.head_big
  13712. if v == nil {
  13713. return
  13714. }
  13715. return *v, true
  13716. }
  13717. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  13718. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13719. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13720. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  13721. if !m.op.Is(OpUpdateOne) {
  13722. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  13723. }
  13724. if m.id == nil || m.oldValue == nil {
  13725. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  13726. }
  13727. oldValue, err := m.oldValue(ctx)
  13728. if err != nil {
  13729. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  13730. }
  13731. return oldValue.HeadBig, nil
  13732. }
  13733. // ResetHeadBig resets all changes to the "head_big" field.
  13734. func (m *WxMutation) ResetHeadBig() {
  13735. m.head_big = nil
  13736. }
  13737. // SetOrganizationID sets the "organization_id" field.
  13738. func (m *WxMutation) SetOrganizationID(u uint64) {
  13739. m.organization_id = &u
  13740. m.addorganization_id = nil
  13741. }
  13742. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13743. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  13744. v := m.organization_id
  13745. if v == nil {
  13746. return
  13747. }
  13748. return *v, true
  13749. }
  13750. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  13751. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13752. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13753. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13754. if !m.op.Is(OpUpdateOne) {
  13755. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13756. }
  13757. if m.id == nil || m.oldValue == nil {
  13758. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13759. }
  13760. oldValue, err := m.oldValue(ctx)
  13761. if err != nil {
  13762. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13763. }
  13764. return oldValue.OrganizationID, nil
  13765. }
  13766. // AddOrganizationID adds u to the "organization_id" field.
  13767. func (m *WxMutation) AddOrganizationID(u int64) {
  13768. if m.addorganization_id != nil {
  13769. *m.addorganization_id += u
  13770. } else {
  13771. m.addorganization_id = &u
  13772. }
  13773. }
  13774. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13775. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  13776. v := m.addorganization_id
  13777. if v == nil {
  13778. return
  13779. }
  13780. return *v, true
  13781. }
  13782. // ClearOrganizationID clears the value of the "organization_id" field.
  13783. func (m *WxMutation) ClearOrganizationID() {
  13784. m.organization_id = nil
  13785. m.addorganization_id = nil
  13786. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  13787. }
  13788. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13789. func (m *WxMutation) OrganizationIDCleared() bool {
  13790. _, ok := m.clearedFields[wx.FieldOrganizationID]
  13791. return ok
  13792. }
  13793. // ResetOrganizationID resets all changes to the "organization_id" field.
  13794. func (m *WxMutation) ResetOrganizationID() {
  13795. m.organization_id = nil
  13796. m.addorganization_id = nil
  13797. delete(m.clearedFields, wx.FieldOrganizationID)
  13798. }
  13799. // SetAgentID sets the "agent_id" field.
  13800. func (m *WxMutation) SetAgentID(u uint64) {
  13801. m.agent = &u
  13802. }
  13803. // AgentID returns the value of the "agent_id" field in the mutation.
  13804. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  13805. v := m.agent
  13806. if v == nil {
  13807. return
  13808. }
  13809. return *v, true
  13810. }
  13811. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  13812. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13814. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  13815. if !m.op.Is(OpUpdateOne) {
  13816. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  13817. }
  13818. if m.id == nil || m.oldValue == nil {
  13819. return v, errors.New("OldAgentID requires an ID field in the mutation")
  13820. }
  13821. oldValue, err := m.oldValue(ctx)
  13822. if err != nil {
  13823. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  13824. }
  13825. return oldValue.AgentID, nil
  13826. }
  13827. // ResetAgentID resets all changes to the "agent_id" field.
  13828. func (m *WxMutation) ResetAgentID() {
  13829. m.agent = nil
  13830. }
  13831. // ClearServer clears the "server" edge to the Server entity.
  13832. func (m *WxMutation) ClearServer() {
  13833. m.clearedserver = true
  13834. m.clearedFields[wx.FieldServerID] = struct{}{}
  13835. }
  13836. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  13837. func (m *WxMutation) ServerCleared() bool {
  13838. return m.ServerIDCleared() || m.clearedserver
  13839. }
  13840. // ServerIDs returns the "server" edge IDs in the mutation.
  13841. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  13842. // ServerID instead. It exists only for internal usage by the builders.
  13843. func (m *WxMutation) ServerIDs() (ids []uint64) {
  13844. if id := m.server; id != nil {
  13845. ids = append(ids, *id)
  13846. }
  13847. return
  13848. }
  13849. // ResetServer resets all changes to the "server" edge.
  13850. func (m *WxMutation) ResetServer() {
  13851. m.server = nil
  13852. m.clearedserver = false
  13853. }
  13854. // ClearAgent clears the "agent" edge to the Agent entity.
  13855. func (m *WxMutation) ClearAgent() {
  13856. m.clearedagent = true
  13857. m.clearedFields[wx.FieldAgentID] = struct{}{}
  13858. }
  13859. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  13860. func (m *WxMutation) AgentCleared() bool {
  13861. return m.clearedagent
  13862. }
  13863. // AgentIDs returns the "agent" edge IDs in the mutation.
  13864. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  13865. // AgentID instead. It exists only for internal usage by the builders.
  13866. func (m *WxMutation) AgentIDs() (ids []uint64) {
  13867. if id := m.agent; id != nil {
  13868. ids = append(ids, *id)
  13869. }
  13870. return
  13871. }
  13872. // ResetAgent resets all changes to the "agent" edge.
  13873. func (m *WxMutation) ResetAgent() {
  13874. m.agent = nil
  13875. m.clearedagent = false
  13876. }
  13877. // Where appends a list predicates to the WxMutation builder.
  13878. func (m *WxMutation) Where(ps ...predicate.Wx) {
  13879. m.predicates = append(m.predicates, ps...)
  13880. }
  13881. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  13882. // users can use type-assertion to append predicates that do not depend on any generated package.
  13883. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  13884. p := make([]predicate.Wx, len(ps))
  13885. for i := range ps {
  13886. p[i] = ps[i]
  13887. }
  13888. m.Where(p...)
  13889. }
  13890. // Op returns the operation name.
  13891. func (m *WxMutation) Op() Op {
  13892. return m.op
  13893. }
  13894. // SetOp allows setting the mutation operation.
  13895. func (m *WxMutation) SetOp(op Op) {
  13896. m.op = op
  13897. }
  13898. // Type returns the node type of this mutation (Wx).
  13899. func (m *WxMutation) Type() string {
  13900. return m.typ
  13901. }
  13902. // Fields returns all fields that were changed during this mutation. Note that in
  13903. // order to get all numeric fields that were incremented/decremented, call
  13904. // AddedFields().
  13905. func (m *WxMutation) Fields() []string {
  13906. fields := make([]string, 0, 15)
  13907. if m.created_at != nil {
  13908. fields = append(fields, wx.FieldCreatedAt)
  13909. }
  13910. if m.updated_at != nil {
  13911. fields = append(fields, wx.FieldUpdatedAt)
  13912. }
  13913. if m.status != nil {
  13914. fields = append(fields, wx.FieldStatus)
  13915. }
  13916. if m.deleted_at != nil {
  13917. fields = append(fields, wx.FieldDeletedAt)
  13918. }
  13919. if m.server != nil {
  13920. fields = append(fields, wx.FieldServerID)
  13921. }
  13922. if m.port != nil {
  13923. fields = append(fields, wx.FieldPort)
  13924. }
  13925. if m.process_id != nil {
  13926. fields = append(fields, wx.FieldProcessID)
  13927. }
  13928. if m.callback != nil {
  13929. fields = append(fields, wx.FieldCallback)
  13930. }
  13931. if m.wxid != nil {
  13932. fields = append(fields, wx.FieldWxid)
  13933. }
  13934. if m.account != nil {
  13935. fields = append(fields, wx.FieldAccount)
  13936. }
  13937. if m.nickname != nil {
  13938. fields = append(fields, wx.FieldNickname)
  13939. }
  13940. if m.tel != nil {
  13941. fields = append(fields, wx.FieldTel)
  13942. }
  13943. if m.head_big != nil {
  13944. fields = append(fields, wx.FieldHeadBig)
  13945. }
  13946. if m.organization_id != nil {
  13947. fields = append(fields, wx.FieldOrganizationID)
  13948. }
  13949. if m.agent != nil {
  13950. fields = append(fields, wx.FieldAgentID)
  13951. }
  13952. return fields
  13953. }
  13954. // Field returns the value of a field with the given name. The second boolean
  13955. // return value indicates that this field was not set, or was not defined in the
  13956. // schema.
  13957. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  13958. switch name {
  13959. case wx.FieldCreatedAt:
  13960. return m.CreatedAt()
  13961. case wx.FieldUpdatedAt:
  13962. return m.UpdatedAt()
  13963. case wx.FieldStatus:
  13964. return m.Status()
  13965. case wx.FieldDeletedAt:
  13966. return m.DeletedAt()
  13967. case wx.FieldServerID:
  13968. return m.ServerID()
  13969. case wx.FieldPort:
  13970. return m.Port()
  13971. case wx.FieldProcessID:
  13972. return m.ProcessID()
  13973. case wx.FieldCallback:
  13974. return m.Callback()
  13975. case wx.FieldWxid:
  13976. return m.Wxid()
  13977. case wx.FieldAccount:
  13978. return m.Account()
  13979. case wx.FieldNickname:
  13980. return m.Nickname()
  13981. case wx.FieldTel:
  13982. return m.Tel()
  13983. case wx.FieldHeadBig:
  13984. return m.HeadBig()
  13985. case wx.FieldOrganizationID:
  13986. return m.OrganizationID()
  13987. case wx.FieldAgentID:
  13988. return m.AgentID()
  13989. }
  13990. return nil, false
  13991. }
  13992. // OldField returns the old value of the field from the database. An error is
  13993. // returned if the mutation operation is not UpdateOne, or the query to the
  13994. // database failed.
  13995. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13996. switch name {
  13997. case wx.FieldCreatedAt:
  13998. return m.OldCreatedAt(ctx)
  13999. case wx.FieldUpdatedAt:
  14000. return m.OldUpdatedAt(ctx)
  14001. case wx.FieldStatus:
  14002. return m.OldStatus(ctx)
  14003. case wx.FieldDeletedAt:
  14004. return m.OldDeletedAt(ctx)
  14005. case wx.FieldServerID:
  14006. return m.OldServerID(ctx)
  14007. case wx.FieldPort:
  14008. return m.OldPort(ctx)
  14009. case wx.FieldProcessID:
  14010. return m.OldProcessID(ctx)
  14011. case wx.FieldCallback:
  14012. return m.OldCallback(ctx)
  14013. case wx.FieldWxid:
  14014. return m.OldWxid(ctx)
  14015. case wx.FieldAccount:
  14016. return m.OldAccount(ctx)
  14017. case wx.FieldNickname:
  14018. return m.OldNickname(ctx)
  14019. case wx.FieldTel:
  14020. return m.OldTel(ctx)
  14021. case wx.FieldHeadBig:
  14022. return m.OldHeadBig(ctx)
  14023. case wx.FieldOrganizationID:
  14024. return m.OldOrganizationID(ctx)
  14025. case wx.FieldAgentID:
  14026. return m.OldAgentID(ctx)
  14027. }
  14028. return nil, fmt.Errorf("unknown Wx field %s", name)
  14029. }
  14030. // SetField sets the value of a field with the given name. It returns an error if
  14031. // the field is not defined in the schema, or if the type mismatched the field
  14032. // type.
  14033. func (m *WxMutation) SetField(name string, value ent.Value) error {
  14034. switch name {
  14035. case wx.FieldCreatedAt:
  14036. v, ok := value.(time.Time)
  14037. if !ok {
  14038. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14039. }
  14040. m.SetCreatedAt(v)
  14041. return nil
  14042. case wx.FieldUpdatedAt:
  14043. v, ok := value.(time.Time)
  14044. if !ok {
  14045. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14046. }
  14047. m.SetUpdatedAt(v)
  14048. return nil
  14049. case wx.FieldStatus:
  14050. v, ok := value.(uint8)
  14051. if !ok {
  14052. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14053. }
  14054. m.SetStatus(v)
  14055. return nil
  14056. case wx.FieldDeletedAt:
  14057. v, ok := value.(time.Time)
  14058. if !ok {
  14059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14060. }
  14061. m.SetDeletedAt(v)
  14062. return nil
  14063. case wx.FieldServerID:
  14064. v, ok := value.(uint64)
  14065. if !ok {
  14066. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14067. }
  14068. m.SetServerID(v)
  14069. return nil
  14070. case wx.FieldPort:
  14071. v, ok := value.(string)
  14072. if !ok {
  14073. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14074. }
  14075. m.SetPort(v)
  14076. return nil
  14077. case wx.FieldProcessID:
  14078. v, ok := value.(string)
  14079. if !ok {
  14080. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14081. }
  14082. m.SetProcessID(v)
  14083. return nil
  14084. case wx.FieldCallback:
  14085. v, ok := value.(string)
  14086. if !ok {
  14087. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14088. }
  14089. m.SetCallback(v)
  14090. return nil
  14091. case wx.FieldWxid:
  14092. v, ok := value.(string)
  14093. if !ok {
  14094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14095. }
  14096. m.SetWxid(v)
  14097. return nil
  14098. case wx.FieldAccount:
  14099. v, ok := value.(string)
  14100. if !ok {
  14101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14102. }
  14103. m.SetAccount(v)
  14104. return nil
  14105. case wx.FieldNickname:
  14106. v, ok := value.(string)
  14107. if !ok {
  14108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14109. }
  14110. m.SetNickname(v)
  14111. return nil
  14112. case wx.FieldTel:
  14113. v, ok := value.(string)
  14114. if !ok {
  14115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14116. }
  14117. m.SetTel(v)
  14118. return nil
  14119. case wx.FieldHeadBig:
  14120. v, ok := value.(string)
  14121. if !ok {
  14122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14123. }
  14124. m.SetHeadBig(v)
  14125. return nil
  14126. case wx.FieldOrganizationID:
  14127. v, ok := value.(uint64)
  14128. if !ok {
  14129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14130. }
  14131. m.SetOrganizationID(v)
  14132. return nil
  14133. case wx.FieldAgentID:
  14134. v, ok := value.(uint64)
  14135. if !ok {
  14136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14137. }
  14138. m.SetAgentID(v)
  14139. return nil
  14140. }
  14141. return fmt.Errorf("unknown Wx field %s", name)
  14142. }
  14143. // AddedFields returns all numeric fields that were incremented/decremented during
  14144. // this mutation.
  14145. func (m *WxMutation) AddedFields() []string {
  14146. var fields []string
  14147. if m.addstatus != nil {
  14148. fields = append(fields, wx.FieldStatus)
  14149. }
  14150. if m.addorganization_id != nil {
  14151. fields = append(fields, wx.FieldOrganizationID)
  14152. }
  14153. return fields
  14154. }
  14155. // AddedField returns the numeric value that was incremented/decremented on a field
  14156. // with the given name. The second boolean return value indicates that this field
  14157. // was not set, or was not defined in the schema.
  14158. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  14159. switch name {
  14160. case wx.FieldStatus:
  14161. return m.AddedStatus()
  14162. case wx.FieldOrganizationID:
  14163. return m.AddedOrganizationID()
  14164. }
  14165. return nil, false
  14166. }
  14167. // AddField adds the value to the field with the given name. It returns an error if
  14168. // the field is not defined in the schema, or if the type mismatched the field
  14169. // type.
  14170. func (m *WxMutation) AddField(name string, value ent.Value) error {
  14171. switch name {
  14172. case wx.FieldStatus:
  14173. v, ok := value.(int8)
  14174. if !ok {
  14175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14176. }
  14177. m.AddStatus(v)
  14178. return nil
  14179. case wx.FieldOrganizationID:
  14180. v, ok := value.(int64)
  14181. if !ok {
  14182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14183. }
  14184. m.AddOrganizationID(v)
  14185. return nil
  14186. }
  14187. return fmt.Errorf("unknown Wx numeric field %s", name)
  14188. }
  14189. // ClearedFields returns all nullable fields that were cleared during this
  14190. // mutation.
  14191. func (m *WxMutation) ClearedFields() []string {
  14192. var fields []string
  14193. if m.FieldCleared(wx.FieldStatus) {
  14194. fields = append(fields, wx.FieldStatus)
  14195. }
  14196. if m.FieldCleared(wx.FieldDeletedAt) {
  14197. fields = append(fields, wx.FieldDeletedAt)
  14198. }
  14199. if m.FieldCleared(wx.FieldServerID) {
  14200. fields = append(fields, wx.FieldServerID)
  14201. }
  14202. if m.FieldCleared(wx.FieldOrganizationID) {
  14203. fields = append(fields, wx.FieldOrganizationID)
  14204. }
  14205. return fields
  14206. }
  14207. // FieldCleared returns a boolean indicating if a field with the given name was
  14208. // cleared in this mutation.
  14209. func (m *WxMutation) FieldCleared(name string) bool {
  14210. _, ok := m.clearedFields[name]
  14211. return ok
  14212. }
  14213. // ClearField clears the value of the field with the given name. It returns an
  14214. // error if the field is not defined in the schema.
  14215. func (m *WxMutation) ClearField(name string) error {
  14216. switch name {
  14217. case wx.FieldStatus:
  14218. m.ClearStatus()
  14219. return nil
  14220. case wx.FieldDeletedAt:
  14221. m.ClearDeletedAt()
  14222. return nil
  14223. case wx.FieldServerID:
  14224. m.ClearServerID()
  14225. return nil
  14226. case wx.FieldOrganizationID:
  14227. m.ClearOrganizationID()
  14228. return nil
  14229. }
  14230. return fmt.Errorf("unknown Wx nullable field %s", name)
  14231. }
  14232. // ResetField resets all changes in the mutation for the field with the given name.
  14233. // It returns an error if the field is not defined in the schema.
  14234. func (m *WxMutation) ResetField(name string) error {
  14235. switch name {
  14236. case wx.FieldCreatedAt:
  14237. m.ResetCreatedAt()
  14238. return nil
  14239. case wx.FieldUpdatedAt:
  14240. m.ResetUpdatedAt()
  14241. return nil
  14242. case wx.FieldStatus:
  14243. m.ResetStatus()
  14244. return nil
  14245. case wx.FieldDeletedAt:
  14246. m.ResetDeletedAt()
  14247. return nil
  14248. case wx.FieldServerID:
  14249. m.ResetServerID()
  14250. return nil
  14251. case wx.FieldPort:
  14252. m.ResetPort()
  14253. return nil
  14254. case wx.FieldProcessID:
  14255. m.ResetProcessID()
  14256. return nil
  14257. case wx.FieldCallback:
  14258. m.ResetCallback()
  14259. return nil
  14260. case wx.FieldWxid:
  14261. m.ResetWxid()
  14262. return nil
  14263. case wx.FieldAccount:
  14264. m.ResetAccount()
  14265. return nil
  14266. case wx.FieldNickname:
  14267. m.ResetNickname()
  14268. return nil
  14269. case wx.FieldTel:
  14270. m.ResetTel()
  14271. return nil
  14272. case wx.FieldHeadBig:
  14273. m.ResetHeadBig()
  14274. return nil
  14275. case wx.FieldOrganizationID:
  14276. m.ResetOrganizationID()
  14277. return nil
  14278. case wx.FieldAgentID:
  14279. m.ResetAgentID()
  14280. return nil
  14281. }
  14282. return fmt.Errorf("unknown Wx field %s", name)
  14283. }
  14284. // AddedEdges returns all edge names that were set/added in this mutation.
  14285. func (m *WxMutation) AddedEdges() []string {
  14286. edges := make([]string, 0, 2)
  14287. if m.server != nil {
  14288. edges = append(edges, wx.EdgeServer)
  14289. }
  14290. if m.agent != nil {
  14291. edges = append(edges, wx.EdgeAgent)
  14292. }
  14293. return edges
  14294. }
  14295. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14296. // name in this mutation.
  14297. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  14298. switch name {
  14299. case wx.EdgeServer:
  14300. if id := m.server; id != nil {
  14301. return []ent.Value{*id}
  14302. }
  14303. case wx.EdgeAgent:
  14304. if id := m.agent; id != nil {
  14305. return []ent.Value{*id}
  14306. }
  14307. }
  14308. return nil
  14309. }
  14310. // RemovedEdges returns all edge names that were removed in this mutation.
  14311. func (m *WxMutation) RemovedEdges() []string {
  14312. edges := make([]string, 0, 2)
  14313. return edges
  14314. }
  14315. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14316. // the given name in this mutation.
  14317. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  14318. return nil
  14319. }
  14320. // ClearedEdges returns all edge names that were cleared in this mutation.
  14321. func (m *WxMutation) ClearedEdges() []string {
  14322. edges := make([]string, 0, 2)
  14323. if m.clearedserver {
  14324. edges = append(edges, wx.EdgeServer)
  14325. }
  14326. if m.clearedagent {
  14327. edges = append(edges, wx.EdgeAgent)
  14328. }
  14329. return edges
  14330. }
  14331. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14332. // was cleared in this mutation.
  14333. func (m *WxMutation) EdgeCleared(name string) bool {
  14334. switch name {
  14335. case wx.EdgeServer:
  14336. return m.clearedserver
  14337. case wx.EdgeAgent:
  14338. return m.clearedagent
  14339. }
  14340. return false
  14341. }
  14342. // ClearEdge clears the value of the edge with the given name. It returns an error
  14343. // if that edge is not defined in the schema.
  14344. func (m *WxMutation) ClearEdge(name string) error {
  14345. switch name {
  14346. case wx.EdgeServer:
  14347. m.ClearServer()
  14348. return nil
  14349. case wx.EdgeAgent:
  14350. m.ClearAgent()
  14351. return nil
  14352. }
  14353. return fmt.Errorf("unknown Wx unique edge %s", name)
  14354. }
  14355. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14356. // It returns an error if the edge is not defined in the schema.
  14357. func (m *WxMutation) ResetEdge(name string) error {
  14358. switch name {
  14359. case wx.EdgeServer:
  14360. m.ResetServer()
  14361. return nil
  14362. case wx.EdgeAgent:
  14363. m.ResetAgent()
  14364. return nil
  14365. }
  14366. return fmt.Errorf("unknown Wx edge %s", name)
  14367. }