mutation.go 449 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378
  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. done bool
  68. oldValue func(context.Context) (*Agent, error)
  69. predicates []predicate.Agent
  70. }
  71. var _ ent.Mutation = (*AgentMutation)(nil)
  72. // agentOption allows management of the mutation configuration using functional options.
  73. type agentOption func(*AgentMutation)
  74. // newAgentMutation creates new mutation for the Agent entity.
  75. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  76. m := &AgentMutation{
  77. config: c,
  78. op: op,
  79. typ: TypeAgent,
  80. clearedFields: make(map[string]struct{}),
  81. }
  82. for _, opt := range opts {
  83. opt(m)
  84. }
  85. return m
  86. }
  87. // withAgentID sets the ID field of the mutation.
  88. func withAgentID(id uint64) agentOption {
  89. return func(m *AgentMutation) {
  90. var (
  91. err error
  92. once sync.Once
  93. value *Agent
  94. )
  95. m.oldValue = func(ctx context.Context) (*Agent, error) {
  96. once.Do(func() {
  97. if m.done {
  98. err = errors.New("querying old values post mutation is not allowed")
  99. } else {
  100. value, err = m.Client().Agent.Get(ctx, id)
  101. }
  102. })
  103. return value, err
  104. }
  105. m.id = &id
  106. }
  107. }
  108. // withAgent sets the old Agent of the mutation.
  109. func withAgent(node *Agent) agentOption {
  110. return func(m *AgentMutation) {
  111. m.oldValue = func(context.Context) (*Agent, error) {
  112. return node, nil
  113. }
  114. m.id = &node.ID
  115. }
  116. }
  117. // Client returns a new `ent.Client` from the mutation. If the mutation was
  118. // executed in a transaction (ent.Tx), a transactional client is returned.
  119. func (m AgentMutation) Client() *Client {
  120. client := &Client{config: m.config}
  121. client.init()
  122. return client
  123. }
  124. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  125. // it returns an error otherwise.
  126. func (m AgentMutation) Tx() (*Tx, error) {
  127. if _, ok := m.driver.(*txDriver); !ok {
  128. return nil, errors.New("ent: mutation is not running in a transaction")
  129. }
  130. tx := &Tx{config: m.config}
  131. tx.init()
  132. return tx, nil
  133. }
  134. // SetID sets the value of the id field. Note that this
  135. // operation is only accepted on creation of Agent entities.
  136. func (m *AgentMutation) SetID(id uint64) {
  137. m.id = &id
  138. }
  139. // ID returns the ID value in the mutation. Note that the ID is only available
  140. // if it was provided to the builder or after it was returned from the database.
  141. func (m *AgentMutation) ID() (id uint64, exists bool) {
  142. if m.id == nil {
  143. return
  144. }
  145. return *m.id, true
  146. }
  147. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  148. // That means, if the mutation is applied within a transaction with an isolation level such
  149. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  150. // or updated by the mutation.
  151. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  152. switch {
  153. case m.op.Is(OpUpdateOne | OpDeleteOne):
  154. id, exists := m.ID()
  155. if exists {
  156. return []uint64{id}, nil
  157. }
  158. fallthrough
  159. case m.op.Is(OpUpdate | OpDelete):
  160. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  161. default:
  162. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  163. }
  164. }
  165. // SetCreatedAt sets the "created_at" field.
  166. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  167. m.created_at = &t
  168. }
  169. // CreatedAt returns the value of the "created_at" field in the mutation.
  170. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  171. v := m.created_at
  172. if v == nil {
  173. return
  174. }
  175. return *v, true
  176. }
  177. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  178. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  179. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  180. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  181. if !m.op.Is(OpUpdateOne) {
  182. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  183. }
  184. if m.id == nil || m.oldValue == nil {
  185. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  186. }
  187. oldValue, err := m.oldValue(ctx)
  188. if err != nil {
  189. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  190. }
  191. return oldValue.CreatedAt, nil
  192. }
  193. // ResetCreatedAt resets all changes to the "created_at" field.
  194. func (m *AgentMutation) ResetCreatedAt() {
  195. m.created_at = nil
  196. }
  197. // SetUpdatedAt sets the "updated_at" field.
  198. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  199. m.updated_at = &t
  200. }
  201. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  202. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  203. v := m.updated_at
  204. if v == nil {
  205. return
  206. }
  207. return *v, true
  208. }
  209. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  210. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  211. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  212. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  213. if !m.op.Is(OpUpdateOne) {
  214. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  215. }
  216. if m.id == nil || m.oldValue == nil {
  217. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  218. }
  219. oldValue, err := m.oldValue(ctx)
  220. if err != nil {
  221. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  222. }
  223. return oldValue.UpdatedAt, nil
  224. }
  225. // ResetUpdatedAt resets all changes to the "updated_at" field.
  226. func (m *AgentMutation) ResetUpdatedAt() {
  227. m.updated_at = nil
  228. }
  229. // SetDeletedAt sets the "deleted_at" field.
  230. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  231. m.deleted_at = &t
  232. }
  233. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  234. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  235. v := m.deleted_at
  236. if v == nil {
  237. return
  238. }
  239. return *v, true
  240. }
  241. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  242. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  243. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  244. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  245. if !m.op.Is(OpUpdateOne) {
  246. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  247. }
  248. if m.id == nil || m.oldValue == nil {
  249. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  250. }
  251. oldValue, err := m.oldValue(ctx)
  252. if err != nil {
  253. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  254. }
  255. return oldValue.DeletedAt, nil
  256. }
  257. // ClearDeletedAt clears the value of the "deleted_at" field.
  258. func (m *AgentMutation) ClearDeletedAt() {
  259. m.deleted_at = nil
  260. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  261. }
  262. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  263. func (m *AgentMutation) DeletedAtCleared() bool {
  264. _, ok := m.clearedFields[agent.FieldDeletedAt]
  265. return ok
  266. }
  267. // ResetDeletedAt resets all changes to the "deleted_at" field.
  268. func (m *AgentMutation) ResetDeletedAt() {
  269. m.deleted_at = nil
  270. delete(m.clearedFields, agent.FieldDeletedAt)
  271. }
  272. // SetName sets the "name" field.
  273. func (m *AgentMutation) SetName(s string) {
  274. m.name = &s
  275. }
  276. // Name returns the value of the "name" field in the mutation.
  277. func (m *AgentMutation) Name() (r string, exists bool) {
  278. v := m.name
  279. if v == nil {
  280. return
  281. }
  282. return *v, true
  283. }
  284. // OldName returns the old "name" field's value of the Agent entity.
  285. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  286. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  287. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  288. if !m.op.Is(OpUpdateOne) {
  289. return v, errors.New("OldName is only allowed on UpdateOne operations")
  290. }
  291. if m.id == nil || m.oldValue == nil {
  292. return v, errors.New("OldName requires an ID field in the mutation")
  293. }
  294. oldValue, err := m.oldValue(ctx)
  295. if err != nil {
  296. return v, fmt.Errorf("querying old value for OldName: %w", err)
  297. }
  298. return oldValue.Name, nil
  299. }
  300. // ResetName resets all changes to the "name" field.
  301. func (m *AgentMutation) ResetName() {
  302. m.name = nil
  303. }
  304. // SetRole sets the "role" field.
  305. func (m *AgentMutation) SetRole(s string) {
  306. m.role = &s
  307. }
  308. // Role returns the value of the "role" field in the mutation.
  309. func (m *AgentMutation) Role() (r string, exists bool) {
  310. v := m.role
  311. if v == nil {
  312. return
  313. }
  314. return *v, true
  315. }
  316. // OldRole returns the old "role" field's value of the Agent entity.
  317. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  319. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  320. if !m.op.Is(OpUpdateOne) {
  321. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  322. }
  323. if m.id == nil || m.oldValue == nil {
  324. return v, errors.New("OldRole requires an ID field in the mutation")
  325. }
  326. oldValue, err := m.oldValue(ctx)
  327. if err != nil {
  328. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  329. }
  330. return oldValue.Role, nil
  331. }
  332. // ResetRole resets all changes to the "role" field.
  333. func (m *AgentMutation) ResetRole() {
  334. m.role = nil
  335. }
  336. // SetStatus sets the "status" field.
  337. func (m *AgentMutation) SetStatus(i int) {
  338. m.status = &i
  339. m.addstatus = nil
  340. }
  341. // Status returns the value of the "status" field in the mutation.
  342. func (m *AgentMutation) Status() (r int, exists bool) {
  343. v := m.status
  344. if v == nil {
  345. return
  346. }
  347. return *v, true
  348. }
  349. // OldStatus returns the old "status" field's value of the Agent entity.
  350. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  352. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  353. if !m.op.Is(OpUpdateOne) {
  354. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  355. }
  356. if m.id == nil || m.oldValue == nil {
  357. return v, errors.New("OldStatus requires an ID field in the mutation")
  358. }
  359. oldValue, err := m.oldValue(ctx)
  360. if err != nil {
  361. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  362. }
  363. return oldValue.Status, nil
  364. }
  365. // AddStatus adds i to the "status" field.
  366. func (m *AgentMutation) AddStatus(i int) {
  367. if m.addstatus != nil {
  368. *m.addstatus += i
  369. } else {
  370. m.addstatus = &i
  371. }
  372. }
  373. // AddedStatus returns the value that was added to the "status" field in this mutation.
  374. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  375. v := m.addstatus
  376. if v == nil {
  377. return
  378. }
  379. return *v, true
  380. }
  381. // ClearStatus clears the value of the "status" field.
  382. func (m *AgentMutation) ClearStatus() {
  383. m.status = nil
  384. m.addstatus = nil
  385. m.clearedFields[agent.FieldStatus] = struct{}{}
  386. }
  387. // StatusCleared returns if the "status" field was cleared in this mutation.
  388. func (m *AgentMutation) StatusCleared() bool {
  389. _, ok := m.clearedFields[agent.FieldStatus]
  390. return ok
  391. }
  392. // ResetStatus resets all changes to the "status" field.
  393. func (m *AgentMutation) ResetStatus() {
  394. m.status = nil
  395. m.addstatus = nil
  396. delete(m.clearedFields, agent.FieldStatus)
  397. }
  398. // SetBackground sets the "background" field.
  399. func (m *AgentMutation) SetBackground(s string) {
  400. m.background = &s
  401. }
  402. // Background returns the value of the "background" field in the mutation.
  403. func (m *AgentMutation) Background() (r string, exists bool) {
  404. v := m.background
  405. if v == nil {
  406. return
  407. }
  408. return *v, true
  409. }
  410. // OldBackground returns the old "background" field's value of the Agent entity.
  411. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  412. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  413. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  414. if !m.op.Is(OpUpdateOne) {
  415. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  416. }
  417. if m.id == nil || m.oldValue == nil {
  418. return v, errors.New("OldBackground requires an ID field in the mutation")
  419. }
  420. oldValue, err := m.oldValue(ctx)
  421. if err != nil {
  422. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  423. }
  424. return oldValue.Background, nil
  425. }
  426. // ResetBackground resets all changes to the "background" field.
  427. func (m *AgentMutation) ResetBackground() {
  428. m.background = nil
  429. }
  430. // SetExamples sets the "examples" field.
  431. func (m *AgentMutation) SetExamples(s string) {
  432. m.examples = &s
  433. }
  434. // Examples returns the value of the "examples" field in the mutation.
  435. func (m *AgentMutation) Examples() (r string, exists bool) {
  436. v := m.examples
  437. if v == nil {
  438. return
  439. }
  440. return *v, true
  441. }
  442. // OldExamples returns the old "examples" field's value of the Agent entity.
  443. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  445. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  446. if !m.op.Is(OpUpdateOne) {
  447. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  448. }
  449. if m.id == nil || m.oldValue == nil {
  450. return v, errors.New("OldExamples requires an ID field in the mutation")
  451. }
  452. oldValue, err := m.oldValue(ctx)
  453. if err != nil {
  454. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  455. }
  456. return oldValue.Examples, nil
  457. }
  458. // ResetExamples resets all changes to the "examples" field.
  459. func (m *AgentMutation) ResetExamples() {
  460. m.examples = nil
  461. }
  462. // SetOrganizationID sets the "organization_id" field.
  463. func (m *AgentMutation) SetOrganizationID(u uint64) {
  464. m.organization_id = &u
  465. m.addorganization_id = nil
  466. }
  467. // OrganizationID returns the value of the "organization_id" field in the mutation.
  468. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  469. v := m.organization_id
  470. if v == nil {
  471. return
  472. }
  473. return *v, true
  474. }
  475. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  476. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  477. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  478. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  479. if !m.op.Is(OpUpdateOne) {
  480. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  481. }
  482. if m.id == nil || m.oldValue == nil {
  483. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  484. }
  485. oldValue, err := m.oldValue(ctx)
  486. if err != nil {
  487. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  488. }
  489. return oldValue.OrganizationID, nil
  490. }
  491. // AddOrganizationID adds u to the "organization_id" field.
  492. func (m *AgentMutation) AddOrganizationID(u int64) {
  493. if m.addorganization_id != nil {
  494. *m.addorganization_id += u
  495. } else {
  496. m.addorganization_id = &u
  497. }
  498. }
  499. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  500. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  501. v := m.addorganization_id
  502. if v == nil {
  503. return
  504. }
  505. return *v, true
  506. }
  507. // ResetOrganizationID resets all changes to the "organization_id" field.
  508. func (m *AgentMutation) ResetOrganizationID() {
  509. m.organization_id = nil
  510. m.addorganization_id = nil
  511. }
  512. // Where appends a list predicates to the AgentMutation builder.
  513. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  514. m.predicates = append(m.predicates, ps...)
  515. }
  516. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  517. // users can use type-assertion to append predicates that do not depend on any generated package.
  518. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  519. p := make([]predicate.Agent, len(ps))
  520. for i := range ps {
  521. p[i] = ps[i]
  522. }
  523. m.Where(p...)
  524. }
  525. // Op returns the operation name.
  526. func (m *AgentMutation) Op() Op {
  527. return m.op
  528. }
  529. // SetOp allows setting the mutation operation.
  530. func (m *AgentMutation) SetOp(op Op) {
  531. m.op = op
  532. }
  533. // Type returns the node type of this mutation (Agent).
  534. func (m *AgentMutation) Type() string {
  535. return m.typ
  536. }
  537. // Fields returns all fields that were changed during this mutation. Note that in
  538. // order to get all numeric fields that were incremented/decremented, call
  539. // AddedFields().
  540. func (m *AgentMutation) Fields() []string {
  541. fields := make([]string, 0, 9)
  542. if m.created_at != nil {
  543. fields = append(fields, agent.FieldCreatedAt)
  544. }
  545. if m.updated_at != nil {
  546. fields = append(fields, agent.FieldUpdatedAt)
  547. }
  548. if m.deleted_at != nil {
  549. fields = append(fields, agent.FieldDeletedAt)
  550. }
  551. if m.name != nil {
  552. fields = append(fields, agent.FieldName)
  553. }
  554. if m.role != nil {
  555. fields = append(fields, agent.FieldRole)
  556. }
  557. if m.status != nil {
  558. fields = append(fields, agent.FieldStatus)
  559. }
  560. if m.background != nil {
  561. fields = append(fields, agent.FieldBackground)
  562. }
  563. if m.examples != nil {
  564. fields = append(fields, agent.FieldExamples)
  565. }
  566. if m.organization_id != nil {
  567. fields = append(fields, agent.FieldOrganizationID)
  568. }
  569. return fields
  570. }
  571. // Field returns the value of a field with the given name. The second boolean
  572. // return value indicates that this field was not set, or was not defined in the
  573. // schema.
  574. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  575. switch name {
  576. case agent.FieldCreatedAt:
  577. return m.CreatedAt()
  578. case agent.FieldUpdatedAt:
  579. return m.UpdatedAt()
  580. case agent.FieldDeletedAt:
  581. return m.DeletedAt()
  582. case agent.FieldName:
  583. return m.Name()
  584. case agent.FieldRole:
  585. return m.Role()
  586. case agent.FieldStatus:
  587. return m.Status()
  588. case agent.FieldBackground:
  589. return m.Background()
  590. case agent.FieldExamples:
  591. return m.Examples()
  592. case agent.FieldOrganizationID:
  593. return m.OrganizationID()
  594. }
  595. return nil, false
  596. }
  597. // OldField returns the old value of the field from the database. An error is
  598. // returned if the mutation operation is not UpdateOne, or the query to the
  599. // database failed.
  600. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  601. switch name {
  602. case agent.FieldCreatedAt:
  603. return m.OldCreatedAt(ctx)
  604. case agent.FieldUpdatedAt:
  605. return m.OldUpdatedAt(ctx)
  606. case agent.FieldDeletedAt:
  607. return m.OldDeletedAt(ctx)
  608. case agent.FieldName:
  609. return m.OldName(ctx)
  610. case agent.FieldRole:
  611. return m.OldRole(ctx)
  612. case agent.FieldStatus:
  613. return m.OldStatus(ctx)
  614. case agent.FieldBackground:
  615. return m.OldBackground(ctx)
  616. case agent.FieldExamples:
  617. return m.OldExamples(ctx)
  618. case agent.FieldOrganizationID:
  619. return m.OldOrganizationID(ctx)
  620. }
  621. return nil, fmt.Errorf("unknown Agent field %s", name)
  622. }
  623. // SetField sets the value of a field with the given name. It returns an error if
  624. // the field is not defined in the schema, or if the type mismatched the field
  625. // type.
  626. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  627. switch name {
  628. case agent.FieldCreatedAt:
  629. v, ok := value.(time.Time)
  630. if !ok {
  631. return fmt.Errorf("unexpected type %T for field %s", value, name)
  632. }
  633. m.SetCreatedAt(v)
  634. return nil
  635. case agent.FieldUpdatedAt:
  636. v, ok := value.(time.Time)
  637. if !ok {
  638. return fmt.Errorf("unexpected type %T for field %s", value, name)
  639. }
  640. m.SetUpdatedAt(v)
  641. return nil
  642. case agent.FieldDeletedAt:
  643. v, ok := value.(time.Time)
  644. if !ok {
  645. return fmt.Errorf("unexpected type %T for field %s", value, name)
  646. }
  647. m.SetDeletedAt(v)
  648. return nil
  649. case agent.FieldName:
  650. v, ok := value.(string)
  651. if !ok {
  652. return fmt.Errorf("unexpected type %T for field %s", value, name)
  653. }
  654. m.SetName(v)
  655. return nil
  656. case agent.FieldRole:
  657. v, ok := value.(string)
  658. if !ok {
  659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  660. }
  661. m.SetRole(v)
  662. return nil
  663. case agent.FieldStatus:
  664. v, ok := value.(int)
  665. if !ok {
  666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  667. }
  668. m.SetStatus(v)
  669. return nil
  670. case agent.FieldBackground:
  671. v, ok := value.(string)
  672. if !ok {
  673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  674. }
  675. m.SetBackground(v)
  676. return nil
  677. case agent.FieldExamples:
  678. v, ok := value.(string)
  679. if !ok {
  680. return fmt.Errorf("unexpected type %T for field %s", value, name)
  681. }
  682. m.SetExamples(v)
  683. return nil
  684. case agent.FieldOrganizationID:
  685. v, ok := value.(uint64)
  686. if !ok {
  687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  688. }
  689. m.SetOrganizationID(v)
  690. return nil
  691. }
  692. return fmt.Errorf("unknown Agent field %s", name)
  693. }
  694. // AddedFields returns all numeric fields that were incremented/decremented during
  695. // this mutation.
  696. func (m *AgentMutation) AddedFields() []string {
  697. var fields []string
  698. if m.addstatus != nil {
  699. fields = append(fields, agent.FieldStatus)
  700. }
  701. if m.addorganization_id != nil {
  702. fields = append(fields, agent.FieldOrganizationID)
  703. }
  704. return fields
  705. }
  706. // AddedField returns the numeric value that was incremented/decremented on a field
  707. // with the given name. The second boolean return value indicates that this field
  708. // was not set, or was not defined in the schema.
  709. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  710. switch name {
  711. case agent.FieldStatus:
  712. return m.AddedStatus()
  713. case agent.FieldOrganizationID:
  714. return m.AddedOrganizationID()
  715. }
  716. return nil, false
  717. }
  718. // AddField adds the value to the field with the given name. It returns an error if
  719. // the field is not defined in the schema, or if the type mismatched the field
  720. // type.
  721. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  722. switch name {
  723. case agent.FieldStatus:
  724. v, ok := value.(int)
  725. if !ok {
  726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  727. }
  728. m.AddStatus(v)
  729. return nil
  730. case agent.FieldOrganizationID:
  731. v, ok := value.(int64)
  732. if !ok {
  733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  734. }
  735. m.AddOrganizationID(v)
  736. return nil
  737. }
  738. return fmt.Errorf("unknown Agent numeric field %s", name)
  739. }
  740. // ClearedFields returns all nullable fields that were cleared during this
  741. // mutation.
  742. func (m *AgentMutation) ClearedFields() []string {
  743. var fields []string
  744. if m.FieldCleared(agent.FieldDeletedAt) {
  745. fields = append(fields, agent.FieldDeletedAt)
  746. }
  747. if m.FieldCleared(agent.FieldStatus) {
  748. fields = append(fields, agent.FieldStatus)
  749. }
  750. return fields
  751. }
  752. // FieldCleared returns a boolean indicating if a field with the given name was
  753. // cleared in this mutation.
  754. func (m *AgentMutation) FieldCleared(name string) bool {
  755. _, ok := m.clearedFields[name]
  756. return ok
  757. }
  758. // ClearField clears the value of the field with the given name. It returns an
  759. // error if the field is not defined in the schema.
  760. func (m *AgentMutation) ClearField(name string) error {
  761. switch name {
  762. case agent.FieldDeletedAt:
  763. m.ClearDeletedAt()
  764. return nil
  765. case agent.FieldStatus:
  766. m.ClearStatus()
  767. return nil
  768. }
  769. return fmt.Errorf("unknown Agent nullable field %s", name)
  770. }
  771. // ResetField resets all changes in the mutation for the field with the given name.
  772. // It returns an error if the field is not defined in the schema.
  773. func (m *AgentMutation) ResetField(name string) error {
  774. switch name {
  775. case agent.FieldCreatedAt:
  776. m.ResetCreatedAt()
  777. return nil
  778. case agent.FieldUpdatedAt:
  779. m.ResetUpdatedAt()
  780. return nil
  781. case agent.FieldDeletedAt:
  782. m.ResetDeletedAt()
  783. return nil
  784. case agent.FieldName:
  785. m.ResetName()
  786. return nil
  787. case agent.FieldRole:
  788. m.ResetRole()
  789. return nil
  790. case agent.FieldStatus:
  791. m.ResetStatus()
  792. return nil
  793. case agent.FieldBackground:
  794. m.ResetBackground()
  795. return nil
  796. case agent.FieldExamples:
  797. m.ResetExamples()
  798. return nil
  799. case agent.FieldOrganizationID:
  800. m.ResetOrganizationID()
  801. return nil
  802. }
  803. return fmt.Errorf("unknown Agent field %s", name)
  804. }
  805. // AddedEdges returns all edge names that were set/added in this mutation.
  806. func (m *AgentMutation) AddedEdges() []string {
  807. edges := make([]string, 0, 0)
  808. return edges
  809. }
  810. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  811. // name in this mutation.
  812. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  813. return nil
  814. }
  815. // RemovedEdges returns all edge names that were removed in this mutation.
  816. func (m *AgentMutation) RemovedEdges() []string {
  817. edges := make([]string, 0, 0)
  818. return edges
  819. }
  820. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  821. // the given name in this mutation.
  822. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  823. return nil
  824. }
  825. // ClearedEdges returns all edge names that were cleared in this mutation.
  826. func (m *AgentMutation) ClearedEdges() []string {
  827. edges := make([]string, 0, 0)
  828. return edges
  829. }
  830. // EdgeCleared returns a boolean which indicates if the edge with the given name
  831. // was cleared in this mutation.
  832. func (m *AgentMutation) EdgeCleared(name string) bool {
  833. return false
  834. }
  835. // ClearEdge clears the value of the edge with the given name. It returns an error
  836. // if that edge is not defined in the schema.
  837. func (m *AgentMutation) ClearEdge(name string) error {
  838. return fmt.Errorf("unknown Agent unique edge %s", name)
  839. }
  840. // ResetEdge resets all changes to the edge with the given name in this mutation.
  841. // It returns an error if the edge is not defined in the schema.
  842. func (m *AgentMutation) ResetEdge(name string) error {
  843. return fmt.Errorf("unknown Agent edge %s", name)
  844. }
  845. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  846. type BatchMsgMutation struct {
  847. config
  848. op Op
  849. typ string
  850. id *uint64
  851. created_at *time.Time
  852. updated_at *time.Time
  853. deleted_at *time.Time
  854. status *uint8
  855. addstatus *int8
  856. batch_no *string
  857. fromwxid *string
  858. msg *string
  859. tag *string
  860. total *int32
  861. addtotal *int32
  862. success *int32
  863. addsuccess *int32
  864. fail *int32
  865. addfail *int32
  866. start_time *time.Time
  867. stop_time *time.Time
  868. clearedFields map[string]struct{}
  869. done bool
  870. oldValue func(context.Context) (*BatchMsg, error)
  871. predicates []predicate.BatchMsg
  872. }
  873. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  874. // batchmsgOption allows management of the mutation configuration using functional options.
  875. type batchmsgOption func(*BatchMsgMutation)
  876. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  877. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  878. m := &BatchMsgMutation{
  879. config: c,
  880. op: op,
  881. typ: TypeBatchMsg,
  882. clearedFields: make(map[string]struct{}),
  883. }
  884. for _, opt := range opts {
  885. opt(m)
  886. }
  887. return m
  888. }
  889. // withBatchMsgID sets the ID field of the mutation.
  890. func withBatchMsgID(id uint64) batchmsgOption {
  891. return func(m *BatchMsgMutation) {
  892. var (
  893. err error
  894. once sync.Once
  895. value *BatchMsg
  896. )
  897. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  898. once.Do(func() {
  899. if m.done {
  900. err = errors.New("querying old values post mutation is not allowed")
  901. } else {
  902. value, err = m.Client().BatchMsg.Get(ctx, id)
  903. }
  904. })
  905. return value, err
  906. }
  907. m.id = &id
  908. }
  909. }
  910. // withBatchMsg sets the old BatchMsg of the mutation.
  911. func withBatchMsg(node *BatchMsg) batchmsgOption {
  912. return func(m *BatchMsgMutation) {
  913. m.oldValue = func(context.Context) (*BatchMsg, error) {
  914. return node, nil
  915. }
  916. m.id = &node.ID
  917. }
  918. }
  919. // Client returns a new `ent.Client` from the mutation. If the mutation was
  920. // executed in a transaction (ent.Tx), a transactional client is returned.
  921. func (m BatchMsgMutation) Client() *Client {
  922. client := &Client{config: m.config}
  923. client.init()
  924. return client
  925. }
  926. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  927. // it returns an error otherwise.
  928. func (m BatchMsgMutation) Tx() (*Tx, error) {
  929. if _, ok := m.driver.(*txDriver); !ok {
  930. return nil, errors.New("ent: mutation is not running in a transaction")
  931. }
  932. tx := &Tx{config: m.config}
  933. tx.init()
  934. return tx, nil
  935. }
  936. // SetID sets the value of the id field. Note that this
  937. // operation is only accepted on creation of BatchMsg entities.
  938. func (m *BatchMsgMutation) SetID(id uint64) {
  939. m.id = &id
  940. }
  941. // ID returns the ID value in the mutation. Note that the ID is only available
  942. // if it was provided to the builder or after it was returned from the database.
  943. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  944. if m.id == nil {
  945. return
  946. }
  947. return *m.id, true
  948. }
  949. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  950. // That means, if the mutation is applied within a transaction with an isolation level such
  951. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  952. // or updated by the mutation.
  953. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  954. switch {
  955. case m.op.Is(OpUpdateOne | OpDeleteOne):
  956. id, exists := m.ID()
  957. if exists {
  958. return []uint64{id}, nil
  959. }
  960. fallthrough
  961. case m.op.Is(OpUpdate | OpDelete):
  962. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  963. default:
  964. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  965. }
  966. }
  967. // SetCreatedAt sets the "created_at" field.
  968. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  969. m.created_at = &t
  970. }
  971. // CreatedAt returns the value of the "created_at" field in the mutation.
  972. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  973. v := m.created_at
  974. if v == nil {
  975. return
  976. }
  977. return *v, true
  978. }
  979. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  980. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  981. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  982. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  983. if !m.op.Is(OpUpdateOne) {
  984. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  985. }
  986. if m.id == nil || m.oldValue == nil {
  987. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  988. }
  989. oldValue, err := m.oldValue(ctx)
  990. if err != nil {
  991. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  992. }
  993. return oldValue.CreatedAt, nil
  994. }
  995. // ResetCreatedAt resets all changes to the "created_at" field.
  996. func (m *BatchMsgMutation) ResetCreatedAt() {
  997. m.created_at = nil
  998. }
  999. // SetUpdatedAt sets the "updated_at" field.
  1000. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  1001. m.updated_at = &t
  1002. }
  1003. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  1004. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  1005. v := m.updated_at
  1006. if v == nil {
  1007. return
  1008. }
  1009. return *v, true
  1010. }
  1011. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  1012. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1013. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1014. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  1015. if !m.op.Is(OpUpdateOne) {
  1016. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  1017. }
  1018. if m.id == nil || m.oldValue == nil {
  1019. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  1020. }
  1021. oldValue, err := m.oldValue(ctx)
  1022. if err != nil {
  1023. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  1024. }
  1025. return oldValue.UpdatedAt, nil
  1026. }
  1027. // ResetUpdatedAt resets all changes to the "updated_at" field.
  1028. func (m *BatchMsgMutation) ResetUpdatedAt() {
  1029. m.updated_at = nil
  1030. }
  1031. // SetDeletedAt sets the "deleted_at" field.
  1032. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  1033. m.deleted_at = &t
  1034. }
  1035. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  1036. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  1037. v := m.deleted_at
  1038. if v == nil {
  1039. return
  1040. }
  1041. return *v, true
  1042. }
  1043. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  1044. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1045. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1046. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  1047. if !m.op.Is(OpUpdateOne) {
  1048. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  1049. }
  1050. if m.id == nil || m.oldValue == nil {
  1051. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  1052. }
  1053. oldValue, err := m.oldValue(ctx)
  1054. if err != nil {
  1055. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  1056. }
  1057. return oldValue.DeletedAt, nil
  1058. }
  1059. // ClearDeletedAt clears the value of the "deleted_at" field.
  1060. func (m *BatchMsgMutation) ClearDeletedAt() {
  1061. m.deleted_at = nil
  1062. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  1063. }
  1064. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  1065. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  1066. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  1067. return ok
  1068. }
  1069. // ResetDeletedAt resets all changes to the "deleted_at" field.
  1070. func (m *BatchMsgMutation) ResetDeletedAt() {
  1071. m.deleted_at = nil
  1072. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  1073. }
  1074. // SetStatus sets the "status" field.
  1075. func (m *BatchMsgMutation) SetStatus(u uint8) {
  1076. m.status = &u
  1077. m.addstatus = nil
  1078. }
  1079. // Status returns the value of the "status" field in the mutation.
  1080. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  1081. v := m.status
  1082. if v == nil {
  1083. return
  1084. }
  1085. return *v, true
  1086. }
  1087. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  1088. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1089. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1090. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  1091. if !m.op.Is(OpUpdateOne) {
  1092. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  1093. }
  1094. if m.id == nil || m.oldValue == nil {
  1095. return v, errors.New("OldStatus requires an ID field in the mutation")
  1096. }
  1097. oldValue, err := m.oldValue(ctx)
  1098. if err != nil {
  1099. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  1100. }
  1101. return oldValue.Status, nil
  1102. }
  1103. // AddStatus adds u to the "status" field.
  1104. func (m *BatchMsgMutation) AddStatus(u int8) {
  1105. if m.addstatus != nil {
  1106. *m.addstatus += u
  1107. } else {
  1108. m.addstatus = &u
  1109. }
  1110. }
  1111. // AddedStatus returns the value that was added to the "status" field in this mutation.
  1112. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  1113. v := m.addstatus
  1114. if v == nil {
  1115. return
  1116. }
  1117. return *v, true
  1118. }
  1119. // ClearStatus clears the value of the "status" field.
  1120. func (m *BatchMsgMutation) ClearStatus() {
  1121. m.status = nil
  1122. m.addstatus = nil
  1123. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  1124. }
  1125. // StatusCleared returns if the "status" field was cleared in this mutation.
  1126. func (m *BatchMsgMutation) StatusCleared() bool {
  1127. _, ok := m.clearedFields[batchmsg.FieldStatus]
  1128. return ok
  1129. }
  1130. // ResetStatus resets all changes to the "status" field.
  1131. func (m *BatchMsgMutation) ResetStatus() {
  1132. m.status = nil
  1133. m.addstatus = nil
  1134. delete(m.clearedFields, batchmsg.FieldStatus)
  1135. }
  1136. // SetBatchNo sets the "batch_no" field.
  1137. func (m *BatchMsgMutation) SetBatchNo(s string) {
  1138. m.batch_no = &s
  1139. }
  1140. // BatchNo returns the value of the "batch_no" field in the mutation.
  1141. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  1142. v := m.batch_no
  1143. if v == nil {
  1144. return
  1145. }
  1146. return *v, true
  1147. }
  1148. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  1149. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1151. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  1152. if !m.op.Is(OpUpdateOne) {
  1153. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  1154. }
  1155. if m.id == nil || m.oldValue == nil {
  1156. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  1157. }
  1158. oldValue, err := m.oldValue(ctx)
  1159. if err != nil {
  1160. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  1161. }
  1162. return oldValue.BatchNo, nil
  1163. }
  1164. // ClearBatchNo clears the value of the "batch_no" field.
  1165. func (m *BatchMsgMutation) ClearBatchNo() {
  1166. m.batch_no = nil
  1167. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  1168. }
  1169. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  1170. func (m *BatchMsgMutation) BatchNoCleared() bool {
  1171. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  1172. return ok
  1173. }
  1174. // ResetBatchNo resets all changes to the "batch_no" field.
  1175. func (m *BatchMsgMutation) ResetBatchNo() {
  1176. m.batch_no = nil
  1177. delete(m.clearedFields, batchmsg.FieldBatchNo)
  1178. }
  1179. // SetFromwxid sets the "fromwxid" field.
  1180. func (m *BatchMsgMutation) SetFromwxid(s string) {
  1181. m.fromwxid = &s
  1182. }
  1183. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  1184. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  1185. v := m.fromwxid
  1186. if v == nil {
  1187. return
  1188. }
  1189. return *v, true
  1190. }
  1191. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  1192. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1193. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1194. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  1195. if !m.op.Is(OpUpdateOne) {
  1196. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  1197. }
  1198. if m.id == nil || m.oldValue == nil {
  1199. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  1200. }
  1201. oldValue, err := m.oldValue(ctx)
  1202. if err != nil {
  1203. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  1204. }
  1205. return oldValue.Fromwxid, nil
  1206. }
  1207. // ClearFromwxid clears the value of the "fromwxid" field.
  1208. func (m *BatchMsgMutation) ClearFromwxid() {
  1209. m.fromwxid = nil
  1210. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  1211. }
  1212. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  1213. func (m *BatchMsgMutation) FromwxidCleared() bool {
  1214. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  1215. return ok
  1216. }
  1217. // ResetFromwxid resets all changes to the "fromwxid" field.
  1218. func (m *BatchMsgMutation) ResetFromwxid() {
  1219. m.fromwxid = nil
  1220. delete(m.clearedFields, batchmsg.FieldFromwxid)
  1221. }
  1222. // SetMsg sets the "msg" field.
  1223. func (m *BatchMsgMutation) SetMsg(s string) {
  1224. m.msg = &s
  1225. }
  1226. // Msg returns the value of the "msg" field in the mutation.
  1227. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  1228. v := m.msg
  1229. if v == nil {
  1230. return
  1231. }
  1232. return *v, true
  1233. }
  1234. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  1235. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1236. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1237. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  1238. if !m.op.Is(OpUpdateOne) {
  1239. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  1240. }
  1241. if m.id == nil || m.oldValue == nil {
  1242. return v, errors.New("OldMsg requires an ID field in the mutation")
  1243. }
  1244. oldValue, err := m.oldValue(ctx)
  1245. if err != nil {
  1246. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  1247. }
  1248. return oldValue.Msg, nil
  1249. }
  1250. // ClearMsg clears the value of the "msg" field.
  1251. func (m *BatchMsgMutation) ClearMsg() {
  1252. m.msg = nil
  1253. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  1254. }
  1255. // MsgCleared returns if the "msg" field was cleared in this mutation.
  1256. func (m *BatchMsgMutation) MsgCleared() bool {
  1257. _, ok := m.clearedFields[batchmsg.FieldMsg]
  1258. return ok
  1259. }
  1260. // ResetMsg resets all changes to the "msg" field.
  1261. func (m *BatchMsgMutation) ResetMsg() {
  1262. m.msg = nil
  1263. delete(m.clearedFields, batchmsg.FieldMsg)
  1264. }
  1265. // SetTag sets the "tag" field.
  1266. func (m *BatchMsgMutation) SetTag(s string) {
  1267. m.tag = &s
  1268. }
  1269. // Tag returns the value of the "tag" field in the mutation.
  1270. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  1271. v := m.tag
  1272. if v == nil {
  1273. return
  1274. }
  1275. return *v, true
  1276. }
  1277. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  1278. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1279. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1280. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  1281. if !m.op.Is(OpUpdateOne) {
  1282. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  1283. }
  1284. if m.id == nil || m.oldValue == nil {
  1285. return v, errors.New("OldTag requires an ID field in the mutation")
  1286. }
  1287. oldValue, err := m.oldValue(ctx)
  1288. if err != nil {
  1289. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  1290. }
  1291. return oldValue.Tag, nil
  1292. }
  1293. // ClearTag clears the value of the "tag" field.
  1294. func (m *BatchMsgMutation) ClearTag() {
  1295. m.tag = nil
  1296. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  1297. }
  1298. // TagCleared returns if the "tag" field was cleared in this mutation.
  1299. func (m *BatchMsgMutation) TagCleared() bool {
  1300. _, ok := m.clearedFields[batchmsg.FieldTag]
  1301. return ok
  1302. }
  1303. // ResetTag resets all changes to the "tag" field.
  1304. func (m *BatchMsgMutation) ResetTag() {
  1305. m.tag = nil
  1306. delete(m.clearedFields, batchmsg.FieldTag)
  1307. }
  1308. // SetTotal sets the "total" field.
  1309. func (m *BatchMsgMutation) SetTotal(i int32) {
  1310. m.total = &i
  1311. m.addtotal = nil
  1312. }
  1313. // Total returns the value of the "total" field in the mutation.
  1314. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  1315. v := m.total
  1316. if v == nil {
  1317. return
  1318. }
  1319. return *v, true
  1320. }
  1321. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  1322. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1323. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1324. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  1325. if !m.op.Is(OpUpdateOne) {
  1326. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  1327. }
  1328. if m.id == nil || m.oldValue == nil {
  1329. return v, errors.New("OldTotal requires an ID field in the mutation")
  1330. }
  1331. oldValue, err := m.oldValue(ctx)
  1332. if err != nil {
  1333. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  1334. }
  1335. return oldValue.Total, nil
  1336. }
  1337. // AddTotal adds i to the "total" field.
  1338. func (m *BatchMsgMutation) AddTotal(i int32) {
  1339. if m.addtotal != nil {
  1340. *m.addtotal += i
  1341. } else {
  1342. m.addtotal = &i
  1343. }
  1344. }
  1345. // AddedTotal returns the value that was added to the "total" field in this mutation.
  1346. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  1347. v := m.addtotal
  1348. if v == nil {
  1349. return
  1350. }
  1351. return *v, true
  1352. }
  1353. // ClearTotal clears the value of the "total" field.
  1354. func (m *BatchMsgMutation) ClearTotal() {
  1355. m.total = nil
  1356. m.addtotal = nil
  1357. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  1358. }
  1359. // TotalCleared returns if the "total" field was cleared in this mutation.
  1360. func (m *BatchMsgMutation) TotalCleared() bool {
  1361. _, ok := m.clearedFields[batchmsg.FieldTotal]
  1362. return ok
  1363. }
  1364. // ResetTotal resets all changes to the "total" field.
  1365. func (m *BatchMsgMutation) ResetTotal() {
  1366. m.total = nil
  1367. m.addtotal = nil
  1368. delete(m.clearedFields, batchmsg.FieldTotal)
  1369. }
  1370. // SetSuccess sets the "success" field.
  1371. func (m *BatchMsgMutation) SetSuccess(i int32) {
  1372. m.success = &i
  1373. m.addsuccess = nil
  1374. }
  1375. // Success returns the value of the "success" field in the mutation.
  1376. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  1377. v := m.success
  1378. if v == nil {
  1379. return
  1380. }
  1381. return *v, true
  1382. }
  1383. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  1384. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1386. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  1387. if !m.op.Is(OpUpdateOne) {
  1388. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  1389. }
  1390. if m.id == nil || m.oldValue == nil {
  1391. return v, errors.New("OldSuccess requires an ID field in the mutation")
  1392. }
  1393. oldValue, err := m.oldValue(ctx)
  1394. if err != nil {
  1395. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  1396. }
  1397. return oldValue.Success, nil
  1398. }
  1399. // AddSuccess adds i to the "success" field.
  1400. func (m *BatchMsgMutation) AddSuccess(i int32) {
  1401. if m.addsuccess != nil {
  1402. *m.addsuccess += i
  1403. } else {
  1404. m.addsuccess = &i
  1405. }
  1406. }
  1407. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  1408. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  1409. v := m.addsuccess
  1410. if v == nil {
  1411. return
  1412. }
  1413. return *v, true
  1414. }
  1415. // ClearSuccess clears the value of the "success" field.
  1416. func (m *BatchMsgMutation) ClearSuccess() {
  1417. m.success = nil
  1418. m.addsuccess = nil
  1419. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  1420. }
  1421. // SuccessCleared returns if the "success" field was cleared in this mutation.
  1422. func (m *BatchMsgMutation) SuccessCleared() bool {
  1423. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  1424. return ok
  1425. }
  1426. // ResetSuccess resets all changes to the "success" field.
  1427. func (m *BatchMsgMutation) ResetSuccess() {
  1428. m.success = nil
  1429. m.addsuccess = nil
  1430. delete(m.clearedFields, batchmsg.FieldSuccess)
  1431. }
  1432. // SetFail sets the "fail" field.
  1433. func (m *BatchMsgMutation) SetFail(i int32) {
  1434. m.fail = &i
  1435. m.addfail = nil
  1436. }
  1437. // Fail returns the value of the "fail" field in the mutation.
  1438. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  1439. v := m.fail
  1440. if v == nil {
  1441. return
  1442. }
  1443. return *v, true
  1444. }
  1445. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  1446. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1447. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1448. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  1449. if !m.op.Is(OpUpdateOne) {
  1450. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  1451. }
  1452. if m.id == nil || m.oldValue == nil {
  1453. return v, errors.New("OldFail requires an ID field in the mutation")
  1454. }
  1455. oldValue, err := m.oldValue(ctx)
  1456. if err != nil {
  1457. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  1458. }
  1459. return oldValue.Fail, nil
  1460. }
  1461. // AddFail adds i to the "fail" field.
  1462. func (m *BatchMsgMutation) AddFail(i int32) {
  1463. if m.addfail != nil {
  1464. *m.addfail += i
  1465. } else {
  1466. m.addfail = &i
  1467. }
  1468. }
  1469. // AddedFail returns the value that was added to the "fail" field in this mutation.
  1470. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  1471. v := m.addfail
  1472. if v == nil {
  1473. return
  1474. }
  1475. return *v, true
  1476. }
  1477. // ClearFail clears the value of the "fail" field.
  1478. func (m *BatchMsgMutation) ClearFail() {
  1479. m.fail = nil
  1480. m.addfail = nil
  1481. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  1482. }
  1483. // FailCleared returns if the "fail" field was cleared in this mutation.
  1484. func (m *BatchMsgMutation) FailCleared() bool {
  1485. _, ok := m.clearedFields[batchmsg.FieldFail]
  1486. return ok
  1487. }
  1488. // ResetFail resets all changes to the "fail" field.
  1489. func (m *BatchMsgMutation) ResetFail() {
  1490. m.fail = nil
  1491. m.addfail = nil
  1492. delete(m.clearedFields, batchmsg.FieldFail)
  1493. }
  1494. // SetStartTime sets the "start_time" field.
  1495. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  1496. m.start_time = &t
  1497. }
  1498. // StartTime returns the value of the "start_time" field in the mutation.
  1499. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  1500. v := m.start_time
  1501. if v == nil {
  1502. return
  1503. }
  1504. return *v, true
  1505. }
  1506. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  1507. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1508. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1509. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  1510. if !m.op.Is(OpUpdateOne) {
  1511. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  1512. }
  1513. if m.id == nil || m.oldValue == nil {
  1514. return v, errors.New("OldStartTime requires an ID field in the mutation")
  1515. }
  1516. oldValue, err := m.oldValue(ctx)
  1517. if err != nil {
  1518. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  1519. }
  1520. return oldValue.StartTime, nil
  1521. }
  1522. // ClearStartTime clears the value of the "start_time" field.
  1523. func (m *BatchMsgMutation) ClearStartTime() {
  1524. m.start_time = nil
  1525. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  1526. }
  1527. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  1528. func (m *BatchMsgMutation) StartTimeCleared() bool {
  1529. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  1530. return ok
  1531. }
  1532. // ResetStartTime resets all changes to the "start_time" field.
  1533. func (m *BatchMsgMutation) ResetStartTime() {
  1534. m.start_time = nil
  1535. delete(m.clearedFields, batchmsg.FieldStartTime)
  1536. }
  1537. // SetStopTime sets the "stop_time" field.
  1538. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  1539. m.stop_time = &t
  1540. }
  1541. // StopTime returns the value of the "stop_time" field in the mutation.
  1542. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  1543. v := m.stop_time
  1544. if v == nil {
  1545. return
  1546. }
  1547. return *v, true
  1548. }
  1549. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  1550. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  1551. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1552. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  1553. if !m.op.Is(OpUpdateOne) {
  1554. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  1555. }
  1556. if m.id == nil || m.oldValue == nil {
  1557. return v, errors.New("OldStopTime requires an ID field in the mutation")
  1558. }
  1559. oldValue, err := m.oldValue(ctx)
  1560. if err != nil {
  1561. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  1562. }
  1563. return oldValue.StopTime, nil
  1564. }
  1565. // ClearStopTime clears the value of the "stop_time" field.
  1566. func (m *BatchMsgMutation) ClearStopTime() {
  1567. m.stop_time = nil
  1568. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  1569. }
  1570. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  1571. func (m *BatchMsgMutation) StopTimeCleared() bool {
  1572. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  1573. return ok
  1574. }
  1575. // ResetStopTime resets all changes to the "stop_time" field.
  1576. func (m *BatchMsgMutation) ResetStopTime() {
  1577. m.stop_time = nil
  1578. delete(m.clearedFields, batchmsg.FieldStopTime)
  1579. }
  1580. // Where appends a list predicates to the BatchMsgMutation builder.
  1581. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  1582. m.predicates = append(m.predicates, ps...)
  1583. }
  1584. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  1585. // users can use type-assertion to append predicates that do not depend on any generated package.
  1586. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  1587. p := make([]predicate.BatchMsg, len(ps))
  1588. for i := range ps {
  1589. p[i] = ps[i]
  1590. }
  1591. m.Where(p...)
  1592. }
  1593. // Op returns the operation name.
  1594. func (m *BatchMsgMutation) Op() Op {
  1595. return m.op
  1596. }
  1597. // SetOp allows setting the mutation operation.
  1598. func (m *BatchMsgMutation) SetOp(op Op) {
  1599. m.op = op
  1600. }
  1601. // Type returns the node type of this mutation (BatchMsg).
  1602. func (m *BatchMsgMutation) Type() string {
  1603. return m.typ
  1604. }
  1605. // Fields returns all fields that were changed during this mutation. Note that in
  1606. // order to get all numeric fields that were incremented/decremented, call
  1607. // AddedFields().
  1608. func (m *BatchMsgMutation) Fields() []string {
  1609. fields := make([]string, 0, 13)
  1610. if m.created_at != nil {
  1611. fields = append(fields, batchmsg.FieldCreatedAt)
  1612. }
  1613. if m.updated_at != nil {
  1614. fields = append(fields, batchmsg.FieldUpdatedAt)
  1615. }
  1616. if m.deleted_at != nil {
  1617. fields = append(fields, batchmsg.FieldDeletedAt)
  1618. }
  1619. if m.status != nil {
  1620. fields = append(fields, batchmsg.FieldStatus)
  1621. }
  1622. if m.batch_no != nil {
  1623. fields = append(fields, batchmsg.FieldBatchNo)
  1624. }
  1625. if m.fromwxid != nil {
  1626. fields = append(fields, batchmsg.FieldFromwxid)
  1627. }
  1628. if m.msg != nil {
  1629. fields = append(fields, batchmsg.FieldMsg)
  1630. }
  1631. if m.tag != nil {
  1632. fields = append(fields, batchmsg.FieldTag)
  1633. }
  1634. if m.total != nil {
  1635. fields = append(fields, batchmsg.FieldTotal)
  1636. }
  1637. if m.success != nil {
  1638. fields = append(fields, batchmsg.FieldSuccess)
  1639. }
  1640. if m.fail != nil {
  1641. fields = append(fields, batchmsg.FieldFail)
  1642. }
  1643. if m.start_time != nil {
  1644. fields = append(fields, batchmsg.FieldStartTime)
  1645. }
  1646. if m.stop_time != nil {
  1647. fields = append(fields, batchmsg.FieldStopTime)
  1648. }
  1649. return fields
  1650. }
  1651. // Field returns the value of a field with the given name. The second boolean
  1652. // return value indicates that this field was not set, or was not defined in the
  1653. // schema.
  1654. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  1655. switch name {
  1656. case batchmsg.FieldCreatedAt:
  1657. return m.CreatedAt()
  1658. case batchmsg.FieldUpdatedAt:
  1659. return m.UpdatedAt()
  1660. case batchmsg.FieldDeletedAt:
  1661. return m.DeletedAt()
  1662. case batchmsg.FieldStatus:
  1663. return m.Status()
  1664. case batchmsg.FieldBatchNo:
  1665. return m.BatchNo()
  1666. case batchmsg.FieldFromwxid:
  1667. return m.Fromwxid()
  1668. case batchmsg.FieldMsg:
  1669. return m.Msg()
  1670. case batchmsg.FieldTag:
  1671. return m.Tag()
  1672. case batchmsg.FieldTotal:
  1673. return m.Total()
  1674. case batchmsg.FieldSuccess:
  1675. return m.Success()
  1676. case batchmsg.FieldFail:
  1677. return m.Fail()
  1678. case batchmsg.FieldStartTime:
  1679. return m.StartTime()
  1680. case batchmsg.FieldStopTime:
  1681. return m.StopTime()
  1682. }
  1683. return nil, false
  1684. }
  1685. // OldField returns the old value of the field from the database. An error is
  1686. // returned if the mutation operation is not UpdateOne, or the query to the
  1687. // database failed.
  1688. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1689. switch name {
  1690. case batchmsg.FieldCreatedAt:
  1691. return m.OldCreatedAt(ctx)
  1692. case batchmsg.FieldUpdatedAt:
  1693. return m.OldUpdatedAt(ctx)
  1694. case batchmsg.FieldDeletedAt:
  1695. return m.OldDeletedAt(ctx)
  1696. case batchmsg.FieldStatus:
  1697. return m.OldStatus(ctx)
  1698. case batchmsg.FieldBatchNo:
  1699. return m.OldBatchNo(ctx)
  1700. case batchmsg.FieldFromwxid:
  1701. return m.OldFromwxid(ctx)
  1702. case batchmsg.FieldMsg:
  1703. return m.OldMsg(ctx)
  1704. case batchmsg.FieldTag:
  1705. return m.OldTag(ctx)
  1706. case batchmsg.FieldTotal:
  1707. return m.OldTotal(ctx)
  1708. case batchmsg.FieldSuccess:
  1709. return m.OldSuccess(ctx)
  1710. case batchmsg.FieldFail:
  1711. return m.OldFail(ctx)
  1712. case batchmsg.FieldStartTime:
  1713. return m.OldStartTime(ctx)
  1714. case batchmsg.FieldStopTime:
  1715. return m.OldStopTime(ctx)
  1716. }
  1717. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  1718. }
  1719. // SetField sets the value of a field with the given name. It returns an error if
  1720. // the field is not defined in the schema, or if the type mismatched the field
  1721. // type.
  1722. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  1723. switch name {
  1724. case batchmsg.FieldCreatedAt:
  1725. v, ok := value.(time.Time)
  1726. if !ok {
  1727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1728. }
  1729. m.SetCreatedAt(v)
  1730. return nil
  1731. case batchmsg.FieldUpdatedAt:
  1732. v, ok := value.(time.Time)
  1733. if !ok {
  1734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1735. }
  1736. m.SetUpdatedAt(v)
  1737. return nil
  1738. case batchmsg.FieldDeletedAt:
  1739. v, ok := value.(time.Time)
  1740. if !ok {
  1741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1742. }
  1743. m.SetDeletedAt(v)
  1744. return nil
  1745. case batchmsg.FieldStatus:
  1746. v, ok := value.(uint8)
  1747. if !ok {
  1748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1749. }
  1750. m.SetStatus(v)
  1751. return nil
  1752. case batchmsg.FieldBatchNo:
  1753. v, ok := value.(string)
  1754. if !ok {
  1755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1756. }
  1757. m.SetBatchNo(v)
  1758. return nil
  1759. case batchmsg.FieldFromwxid:
  1760. v, ok := value.(string)
  1761. if !ok {
  1762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1763. }
  1764. m.SetFromwxid(v)
  1765. return nil
  1766. case batchmsg.FieldMsg:
  1767. v, ok := value.(string)
  1768. if !ok {
  1769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1770. }
  1771. m.SetMsg(v)
  1772. return nil
  1773. case batchmsg.FieldTag:
  1774. v, ok := value.(string)
  1775. if !ok {
  1776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1777. }
  1778. m.SetTag(v)
  1779. return nil
  1780. case batchmsg.FieldTotal:
  1781. v, ok := value.(int32)
  1782. if !ok {
  1783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1784. }
  1785. m.SetTotal(v)
  1786. return nil
  1787. case batchmsg.FieldSuccess:
  1788. v, ok := value.(int32)
  1789. if !ok {
  1790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1791. }
  1792. m.SetSuccess(v)
  1793. return nil
  1794. case batchmsg.FieldFail:
  1795. v, ok := value.(int32)
  1796. if !ok {
  1797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1798. }
  1799. m.SetFail(v)
  1800. return nil
  1801. case batchmsg.FieldStartTime:
  1802. v, ok := value.(time.Time)
  1803. if !ok {
  1804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1805. }
  1806. m.SetStartTime(v)
  1807. return nil
  1808. case batchmsg.FieldStopTime:
  1809. v, ok := value.(time.Time)
  1810. if !ok {
  1811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1812. }
  1813. m.SetStopTime(v)
  1814. return nil
  1815. }
  1816. return fmt.Errorf("unknown BatchMsg field %s", name)
  1817. }
  1818. // AddedFields returns all numeric fields that were incremented/decremented during
  1819. // this mutation.
  1820. func (m *BatchMsgMutation) AddedFields() []string {
  1821. var fields []string
  1822. if m.addstatus != nil {
  1823. fields = append(fields, batchmsg.FieldStatus)
  1824. }
  1825. if m.addtotal != nil {
  1826. fields = append(fields, batchmsg.FieldTotal)
  1827. }
  1828. if m.addsuccess != nil {
  1829. fields = append(fields, batchmsg.FieldSuccess)
  1830. }
  1831. if m.addfail != nil {
  1832. fields = append(fields, batchmsg.FieldFail)
  1833. }
  1834. return fields
  1835. }
  1836. // AddedField returns the numeric value that was incremented/decremented on a field
  1837. // with the given name. The second boolean return value indicates that this field
  1838. // was not set, or was not defined in the schema.
  1839. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  1840. switch name {
  1841. case batchmsg.FieldStatus:
  1842. return m.AddedStatus()
  1843. case batchmsg.FieldTotal:
  1844. return m.AddedTotal()
  1845. case batchmsg.FieldSuccess:
  1846. return m.AddedSuccess()
  1847. case batchmsg.FieldFail:
  1848. return m.AddedFail()
  1849. }
  1850. return nil, false
  1851. }
  1852. // AddField adds the value to the field with the given name. It returns an error if
  1853. // the field is not defined in the schema, or if the type mismatched the field
  1854. // type.
  1855. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  1856. switch name {
  1857. case batchmsg.FieldStatus:
  1858. v, ok := value.(int8)
  1859. if !ok {
  1860. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1861. }
  1862. m.AddStatus(v)
  1863. return nil
  1864. case batchmsg.FieldTotal:
  1865. v, ok := value.(int32)
  1866. if !ok {
  1867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1868. }
  1869. m.AddTotal(v)
  1870. return nil
  1871. case batchmsg.FieldSuccess:
  1872. v, ok := value.(int32)
  1873. if !ok {
  1874. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1875. }
  1876. m.AddSuccess(v)
  1877. return nil
  1878. case batchmsg.FieldFail:
  1879. v, ok := value.(int32)
  1880. if !ok {
  1881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1882. }
  1883. m.AddFail(v)
  1884. return nil
  1885. }
  1886. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  1887. }
  1888. // ClearedFields returns all nullable fields that were cleared during this
  1889. // mutation.
  1890. func (m *BatchMsgMutation) ClearedFields() []string {
  1891. var fields []string
  1892. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  1893. fields = append(fields, batchmsg.FieldDeletedAt)
  1894. }
  1895. if m.FieldCleared(batchmsg.FieldStatus) {
  1896. fields = append(fields, batchmsg.FieldStatus)
  1897. }
  1898. if m.FieldCleared(batchmsg.FieldBatchNo) {
  1899. fields = append(fields, batchmsg.FieldBatchNo)
  1900. }
  1901. if m.FieldCleared(batchmsg.FieldFromwxid) {
  1902. fields = append(fields, batchmsg.FieldFromwxid)
  1903. }
  1904. if m.FieldCleared(batchmsg.FieldMsg) {
  1905. fields = append(fields, batchmsg.FieldMsg)
  1906. }
  1907. if m.FieldCleared(batchmsg.FieldTag) {
  1908. fields = append(fields, batchmsg.FieldTag)
  1909. }
  1910. if m.FieldCleared(batchmsg.FieldTotal) {
  1911. fields = append(fields, batchmsg.FieldTotal)
  1912. }
  1913. if m.FieldCleared(batchmsg.FieldSuccess) {
  1914. fields = append(fields, batchmsg.FieldSuccess)
  1915. }
  1916. if m.FieldCleared(batchmsg.FieldFail) {
  1917. fields = append(fields, batchmsg.FieldFail)
  1918. }
  1919. if m.FieldCleared(batchmsg.FieldStartTime) {
  1920. fields = append(fields, batchmsg.FieldStartTime)
  1921. }
  1922. if m.FieldCleared(batchmsg.FieldStopTime) {
  1923. fields = append(fields, batchmsg.FieldStopTime)
  1924. }
  1925. return fields
  1926. }
  1927. // FieldCleared returns a boolean indicating if a field with the given name was
  1928. // cleared in this mutation.
  1929. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  1930. _, ok := m.clearedFields[name]
  1931. return ok
  1932. }
  1933. // ClearField clears the value of the field with the given name. It returns an
  1934. // error if the field is not defined in the schema.
  1935. func (m *BatchMsgMutation) ClearField(name string) error {
  1936. switch name {
  1937. case batchmsg.FieldDeletedAt:
  1938. m.ClearDeletedAt()
  1939. return nil
  1940. case batchmsg.FieldStatus:
  1941. m.ClearStatus()
  1942. return nil
  1943. case batchmsg.FieldBatchNo:
  1944. m.ClearBatchNo()
  1945. return nil
  1946. case batchmsg.FieldFromwxid:
  1947. m.ClearFromwxid()
  1948. return nil
  1949. case batchmsg.FieldMsg:
  1950. m.ClearMsg()
  1951. return nil
  1952. case batchmsg.FieldTag:
  1953. m.ClearTag()
  1954. return nil
  1955. case batchmsg.FieldTotal:
  1956. m.ClearTotal()
  1957. return nil
  1958. case batchmsg.FieldSuccess:
  1959. m.ClearSuccess()
  1960. return nil
  1961. case batchmsg.FieldFail:
  1962. m.ClearFail()
  1963. return nil
  1964. case batchmsg.FieldStartTime:
  1965. m.ClearStartTime()
  1966. return nil
  1967. case batchmsg.FieldStopTime:
  1968. m.ClearStopTime()
  1969. return nil
  1970. }
  1971. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  1972. }
  1973. // ResetField resets all changes in the mutation for the field with the given name.
  1974. // It returns an error if the field is not defined in the schema.
  1975. func (m *BatchMsgMutation) ResetField(name string) error {
  1976. switch name {
  1977. case batchmsg.FieldCreatedAt:
  1978. m.ResetCreatedAt()
  1979. return nil
  1980. case batchmsg.FieldUpdatedAt:
  1981. m.ResetUpdatedAt()
  1982. return nil
  1983. case batchmsg.FieldDeletedAt:
  1984. m.ResetDeletedAt()
  1985. return nil
  1986. case batchmsg.FieldStatus:
  1987. m.ResetStatus()
  1988. return nil
  1989. case batchmsg.FieldBatchNo:
  1990. m.ResetBatchNo()
  1991. return nil
  1992. case batchmsg.FieldFromwxid:
  1993. m.ResetFromwxid()
  1994. return nil
  1995. case batchmsg.FieldMsg:
  1996. m.ResetMsg()
  1997. return nil
  1998. case batchmsg.FieldTag:
  1999. m.ResetTag()
  2000. return nil
  2001. case batchmsg.FieldTotal:
  2002. m.ResetTotal()
  2003. return nil
  2004. case batchmsg.FieldSuccess:
  2005. m.ResetSuccess()
  2006. return nil
  2007. case batchmsg.FieldFail:
  2008. m.ResetFail()
  2009. return nil
  2010. case batchmsg.FieldStartTime:
  2011. m.ResetStartTime()
  2012. return nil
  2013. case batchmsg.FieldStopTime:
  2014. m.ResetStopTime()
  2015. return nil
  2016. }
  2017. return fmt.Errorf("unknown BatchMsg field %s", name)
  2018. }
  2019. // AddedEdges returns all edge names that were set/added in this mutation.
  2020. func (m *BatchMsgMutation) AddedEdges() []string {
  2021. edges := make([]string, 0, 0)
  2022. return edges
  2023. }
  2024. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2025. // name in this mutation.
  2026. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  2027. return nil
  2028. }
  2029. // RemovedEdges returns all edge names that were removed in this mutation.
  2030. func (m *BatchMsgMutation) RemovedEdges() []string {
  2031. edges := make([]string, 0, 0)
  2032. return edges
  2033. }
  2034. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2035. // the given name in this mutation.
  2036. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  2037. return nil
  2038. }
  2039. // ClearedEdges returns all edge names that were cleared in this mutation.
  2040. func (m *BatchMsgMutation) ClearedEdges() []string {
  2041. edges := make([]string, 0, 0)
  2042. return edges
  2043. }
  2044. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2045. // was cleared in this mutation.
  2046. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  2047. return false
  2048. }
  2049. // ClearEdge clears the value of the edge with the given name. It returns an error
  2050. // if that edge is not defined in the schema.
  2051. func (m *BatchMsgMutation) ClearEdge(name string) error {
  2052. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  2053. }
  2054. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2055. // It returns an error if the edge is not defined in the schema.
  2056. func (m *BatchMsgMutation) ResetEdge(name string) error {
  2057. return fmt.Errorf("unknown BatchMsg edge %s", name)
  2058. }
  2059. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  2060. type ContactMutation struct {
  2061. config
  2062. op Op
  2063. typ string
  2064. id *uint64
  2065. created_at *time.Time
  2066. updated_at *time.Time
  2067. status *uint8
  2068. addstatus *int8
  2069. deleted_at *time.Time
  2070. wx_wxid *string
  2071. _type *int
  2072. add_type *int
  2073. wxid *string
  2074. account *string
  2075. nickname *string
  2076. markname *string
  2077. headimg *string
  2078. sex *int
  2079. addsex *int
  2080. starrole *string
  2081. dontseeit *int
  2082. adddontseeit *int
  2083. dontseeme *int
  2084. adddontseeme *int
  2085. lag *string
  2086. gid *string
  2087. gname *string
  2088. v3 *string
  2089. organization_id *uint64
  2090. addorganization_id *int64
  2091. clearedFields map[string]struct{}
  2092. contact_relationships map[uint64]struct{}
  2093. removedcontact_relationships map[uint64]struct{}
  2094. clearedcontact_relationships bool
  2095. contact_messages map[uint64]struct{}
  2096. removedcontact_messages map[uint64]struct{}
  2097. clearedcontact_messages bool
  2098. done bool
  2099. oldValue func(context.Context) (*Contact, error)
  2100. predicates []predicate.Contact
  2101. }
  2102. var _ ent.Mutation = (*ContactMutation)(nil)
  2103. // contactOption allows management of the mutation configuration using functional options.
  2104. type contactOption func(*ContactMutation)
  2105. // newContactMutation creates new mutation for the Contact entity.
  2106. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  2107. m := &ContactMutation{
  2108. config: c,
  2109. op: op,
  2110. typ: TypeContact,
  2111. clearedFields: make(map[string]struct{}),
  2112. }
  2113. for _, opt := range opts {
  2114. opt(m)
  2115. }
  2116. return m
  2117. }
  2118. // withContactID sets the ID field of the mutation.
  2119. func withContactID(id uint64) contactOption {
  2120. return func(m *ContactMutation) {
  2121. var (
  2122. err error
  2123. once sync.Once
  2124. value *Contact
  2125. )
  2126. m.oldValue = func(ctx context.Context) (*Contact, error) {
  2127. once.Do(func() {
  2128. if m.done {
  2129. err = errors.New("querying old values post mutation is not allowed")
  2130. } else {
  2131. value, err = m.Client().Contact.Get(ctx, id)
  2132. }
  2133. })
  2134. return value, err
  2135. }
  2136. m.id = &id
  2137. }
  2138. }
  2139. // withContact sets the old Contact of the mutation.
  2140. func withContact(node *Contact) contactOption {
  2141. return func(m *ContactMutation) {
  2142. m.oldValue = func(context.Context) (*Contact, error) {
  2143. return node, nil
  2144. }
  2145. m.id = &node.ID
  2146. }
  2147. }
  2148. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2149. // executed in a transaction (ent.Tx), a transactional client is returned.
  2150. func (m ContactMutation) Client() *Client {
  2151. client := &Client{config: m.config}
  2152. client.init()
  2153. return client
  2154. }
  2155. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2156. // it returns an error otherwise.
  2157. func (m ContactMutation) Tx() (*Tx, error) {
  2158. if _, ok := m.driver.(*txDriver); !ok {
  2159. return nil, errors.New("ent: mutation is not running in a transaction")
  2160. }
  2161. tx := &Tx{config: m.config}
  2162. tx.init()
  2163. return tx, nil
  2164. }
  2165. // SetID sets the value of the id field. Note that this
  2166. // operation is only accepted on creation of Contact entities.
  2167. func (m *ContactMutation) SetID(id uint64) {
  2168. m.id = &id
  2169. }
  2170. // ID returns the ID value in the mutation. Note that the ID is only available
  2171. // if it was provided to the builder or after it was returned from the database.
  2172. func (m *ContactMutation) ID() (id uint64, exists bool) {
  2173. if m.id == nil {
  2174. return
  2175. }
  2176. return *m.id, true
  2177. }
  2178. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2179. // That means, if the mutation is applied within a transaction with an isolation level such
  2180. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2181. // or updated by the mutation.
  2182. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  2183. switch {
  2184. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2185. id, exists := m.ID()
  2186. if exists {
  2187. return []uint64{id}, nil
  2188. }
  2189. fallthrough
  2190. case m.op.Is(OpUpdate | OpDelete):
  2191. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  2192. default:
  2193. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2194. }
  2195. }
  2196. // SetCreatedAt sets the "created_at" field.
  2197. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  2198. m.created_at = &t
  2199. }
  2200. // CreatedAt returns the value of the "created_at" field in the mutation.
  2201. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  2202. v := m.created_at
  2203. if v == nil {
  2204. return
  2205. }
  2206. return *v, true
  2207. }
  2208. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  2209. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2210. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2211. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2212. if !m.op.Is(OpUpdateOne) {
  2213. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2214. }
  2215. if m.id == nil || m.oldValue == nil {
  2216. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2217. }
  2218. oldValue, err := m.oldValue(ctx)
  2219. if err != nil {
  2220. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2221. }
  2222. return oldValue.CreatedAt, nil
  2223. }
  2224. // ResetCreatedAt resets all changes to the "created_at" field.
  2225. func (m *ContactMutation) ResetCreatedAt() {
  2226. m.created_at = nil
  2227. }
  2228. // SetUpdatedAt sets the "updated_at" field.
  2229. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  2230. m.updated_at = &t
  2231. }
  2232. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2233. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  2234. v := m.updated_at
  2235. if v == nil {
  2236. return
  2237. }
  2238. return *v, true
  2239. }
  2240. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  2241. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2242. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2243. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2244. if !m.op.Is(OpUpdateOne) {
  2245. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2246. }
  2247. if m.id == nil || m.oldValue == nil {
  2248. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2249. }
  2250. oldValue, err := m.oldValue(ctx)
  2251. if err != nil {
  2252. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2253. }
  2254. return oldValue.UpdatedAt, nil
  2255. }
  2256. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2257. func (m *ContactMutation) ResetUpdatedAt() {
  2258. m.updated_at = nil
  2259. }
  2260. // SetStatus sets the "status" field.
  2261. func (m *ContactMutation) SetStatus(u uint8) {
  2262. m.status = &u
  2263. m.addstatus = nil
  2264. }
  2265. // Status returns the value of the "status" field in the mutation.
  2266. func (m *ContactMutation) Status() (r uint8, exists bool) {
  2267. v := m.status
  2268. if v == nil {
  2269. return
  2270. }
  2271. return *v, true
  2272. }
  2273. // OldStatus returns the old "status" field's value of the Contact entity.
  2274. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2275. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2276. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  2277. if !m.op.Is(OpUpdateOne) {
  2278. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  2279. }
  2280. if m.id == nil || m.oldValue == nil {
  2281. return v, errors.New("OldStatus requires an ID field in the mutation")
  2282. }
  2283. oldValue, err := m.oldValue(ctx)
  2284. if err != nil {
  2285. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  2286. }
  2287. return oldValue.Status, nil
  2288. }
  2289. // AddStatus adds u to the "status" field.
  2290. func (m *ContactMutation) AddStatus(u int8) {
  2291. if m.addstatus != nil {
  2292. *m.addstatus += u
  2293. } else {
  2294. m.addstatus = &u
  2295. }
  2296. }
  2297. // AddedStatus returns the value that was added to the "status" field in this mutation.
  2298. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  2299. v := m.addstatus
  2300. if v == nil {
  2301. return
  2302. }
  2303. return *v, true
  2304. }
  2305. // ClearStatus clears the value of the "status" field.
  2306. func (m *ContactMutation) ClearStatus() {
  2307. m.status = nil
  2308. m.addstatus = nil
  2309. m.clearedFields[contact.FieldStatus] = struct{}{}
  2310. }
  2311. // StatusCleared returns if the "status" field was cleared in this mutation.
  2312. func (m *ContactMutation) StatusCleared() bool {
  2313. _, ok := m.clearedFields[contact.FieldStatus]
  2314. return ok
  2315. }
  2316. // ResetStatus resets all changes to the "status" field.
  2317. func (m *ContactMutation) ResetStatus() {
  2318. m.status = nil
  2319. m.addstatus = nil
  2320. delete(m.clearedFields, contact.FieldStatus)
  2321. }
  2322. // SetDeletedAt sets the "deleted_at" field.
  2323. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  2324. m.deleted_at = &t
  2325. }
  2326. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2327. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  2328. v := m.deleted_at
  2329. if v == nil {
  2330. return
  2331. }
  2332. return *v, true
  2333. }
  2334. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  2335. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2336. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2337. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2338. if !m.op.Is(OpUpdateOne) {
  2339. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2340. }
  2341. if m.id == nil || m.oldValue == nil {
  2342. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2343. }
  2344. oldValue, err := m.oldValue(ctx)
  2345. if err != nil {
  2346. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2347. }
  2348. return oldValue.DeletedAt, nil
  2349. }
  2350. // ClearDeletedAt clears the value of the "deleted_at" field.
  2351. func (m *ContactMutation) ClearDeletedAt() {
  2352. m.deleted_at = nil
  2353. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  2354. }
  2355. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2356. func (m *ContactMutation) DeletedAtCleared() bool {
  2357. _, ok := m.clearedFields[contact.FieldDeletedAt]
  2358. return ok
  2359. }
  2360. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2361. func (m *ContactMutation) ResetDeletedAt() {
  2362. m.deleted_at = nil
  2363. delete(m.clearedFields, contact.FieldDeletedAt)
  2364. }
  2365. // SetWxWxid sets the "wx_wxid" field.
  2366. func (m *ContactMutation) SetWxWxid(s string) {
  2367. m.wx_wxid = &s
  2368. }
  2369. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  2370. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  2371. v := m.wx_wxid
  2372. if v == nil {
  2373. return
  2374. }
  2375. return *v, true
  2376. }
  2377. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  2378. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2379. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2380. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  2381. if !m.op.Is(OpUpdateOne) {
  2382. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  2383. }
  2384. if m.id == nil || m.oldValue == nil {
  2385. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  2386. }
  2387. oldValue, err := m.oldValue(ctx)
  2388. if err != nil {
  2389. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  2390. }
  2391. return oldValue.WxWxid, nil
  2392. }
  2393. // ClearWxWxid clears the value of the "wx_wxid" field.
  2394. func (m *ContactMutation) ClearWxWxid() {
  2395. m.wx_wxid = nil
  2396. m.clearedFields[contact.FieldWxWxid] = struct{}{}
  2397. }
  2398. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  2399. func (m *ContactMutation) WxWxidCleared() bool {
  2400. _, ok := m.clearedFields[contact.FieldWxWxid]
  2401. return ok
  2402. }
  2403. // ResetWxWxid resets all changes to the "wx_wxid" field.
  2404. func (m *ContactMutation) ResetWxWxid() {
  2405. m.wx_wxid = nil
  2406. delete(m.clearedFields, contact.FieldWxWxid)
  2407. }
  2408. // SetType sets the "type" field.
  2409. func (m *ContactMutation) SetType(i int) {
  2410. m._type = &i
  2411. m.add_type = nil
  2412. }
  2413. // GetType returns the value of the "type" field in the mutation.
  2414. func (m *ContactMutation) GetType() (r int, exists bool) {
  2415. v := m._type
  2416. if v == nil {
  2417. return
  2418. }
  2419. return *v, true
  2420. }
  2421. // OldType returns the old "type" field's value of the Contact entity.
  2422. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2424. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  2425. if !m.op.Is(OpUpdateOne) {
  2426. return v, errors.New("OldType is only allowed on UpdateOne operations")
  2427. }
  2428. if m.id == nil || m.oldValue == nil {
  2429. return v, errors.New("OldType requires an ID field in the mutation")
  2430. }
  2431. oldValue, err := m.oldValue(ctx)
  2432. if err != nil {
  2433. return v, fmt.Errorf("querying old value for OldType: %w", err)
  2434. }
  2435. return oldValue.Type, nil
  2436. }
  2437. // AddType adds i to the "type" field.
  2438. func (m *ContactMutation) AddType(i int) {
  2439. if m.add_type != nil {
  2440. *m.add_type += i
  2441. } else {
  2442. m.add_type = &i
  2443. }
  2444. }
  2445. // AddedType returns the value that was added to the "type" field in this mutation.
  2446. func (m *ContactMutation) AddedType() (r int, exists bool) {
  2447. v := m.add_type
  2448. if v == nil {
  2449. return
  2450. }
  2451. return *v, true
  2452. }
  2453. // ClearType clears the value of the "type" field.
  2454. func (m *ContactMutation) ClearType() {
  2455. m._type = nil
  2456. m.add_type = nil
  2457. m.clearedFields[contact.FieldType] = struct{}{}
  2458. }
  2459. // TypeCleared returns if the "type" field was cleared in this mutation.
  2460. func (m *ContactMutation) TypeCleared() bool {
  2461. _, ok := m.clearedFields[contact.FieldType]
  2462. return ok
  2463. }
  2464. // ResetType resets all changes to the "type" field.
  2465. func (m *ContactMutation) ResetType() {
  2466. m._type = nil
  2467. m.add_type = nil
  2468. delete(m.clearedFields, contact.FieldType)
  2469. }
  2470. // SetWxid sets the "wxid" field.
  2471. func (m *ContactMutation) SetWxid(s string) {
  2472. m.wxid = &s
  2473. }
  2474. // Wxid returns the value of the "wxid" field in the mutation.
  2475. func (m *ContactMutation) Wxid() (r string, exists bool) {
  2476. v := m.wxid
  2477. if v == nil {
  2478. return
  2479. }
  2480. return *v, true
  2481. }
  2482. // OldWxid returns the old "wxid" field's value of the Contact entity.
  2483. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2484. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2485. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  2486. if !m.op.Is(OpUpdateOne) {
  2487. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  2488. }
  2489. if m.id == nil || m.oldValue == nil {
  2490. return v, errors.New("OldWxid requires an ID field in the mutation")
  2491. }
  2492. oldValue, err := m.oldValue(ctx)
  2493. if err != nil {
  2494. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  2495. }
  2496. return oldValue.Wxid, nil
  2497. }
  2498. // ResetWxid resets all changes to the "wxid" field.
  2499. func (m *ContactMutation) ResetWxid() {
  2500. m.wxid = nil
  2501. }
  2502. // SetAccount sets the "account" field.
  2503. func (m *ContactMutation) SetAccount(s string) {
  2504. m.account = &s
  2505. }
  2506. // Account returns the value of the "account" field in the mutation.
  2507. func (m *ContactMutation) Account() (r string, exists bool) {
  2508. v := m.account
  2509. if v == nil {
  2510. return
  2511. }
  2512. return *v, true
  2513. }
  2514. // OldAccount returns the old "account" field's value of the Contact entity.
  2515. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2516. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2517. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  2518. if !m.op.Is(OpUpdateOne) {
  2519. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  2520. }
  2521. if m.id == nil || m.oldValue == nil {
  2522. return v, errors.New("OldAccount requires an ID field in the mutation")
  2523. }
  2524. oldValue, err := m.oldValue(ctx)
  2525. if err != nil {
  2526. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  2527. }
  2528. return oldValue.Account, nil
  2529. }
  2530. // ResetAccount resets all changes to the "account" field.
  2531. func (m *ContactMutation) ResetAccount() {
  2532. m.account = nil
  2533. }
  2534. // SetNickname sets the "nickname" field.
  2535. func (m *ContactMutation) SetNickname(s string) {
  2536. m.nickname = &s
  2537. }
  2538. // Nickname returns the value of the "nickname" field in the mutation.
  2539. func (m *ContactMutation) Nickname() (r string, exists bool) {
  2540. v := m.nickname
  2541. if v == nil {
  2542. return
  2543. }
  2544. return *v, true
  2545. }
  2546. // OldNickname returns the old "nickname" field's value of the Contact entity.
  2547. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2548. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2549. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  2550. if !m.op.Is(OpUpdateOne) {
  2551. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  2552. }
  2553. if m.id == nil || m.oldValue == nil {
  2554. return v, errors.New("OldNickname requires an ID field in the mutation")
  2555. }
  2556. oldValue, err := m.oldValue(ctx)
  2557. if err != nil {
  2558. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  2559. }
  2560. return oldValue.Nickname, nil
  2561. }
  2562. // ResetNickname resets all changes to the "nickname" field.
  2563. func (m *ContactMutation) ResetNickname() {
  2564. m.nickname = nil
  2565. }
  2566. // SetMarkname sets the "markname" field.
  2567. func (m *ContactMutation) SetMarkname(s string) {
  2568. m.markname = &s
  2569. }
  2570. // Markname returns the value of the "markname" field in the mutation.
  2571. func (m *ContactMutation) Markname() (r string, exists bool) {
  2572. v := m.markname
  2573. if v == nil {
  2574. return
  2575. }
  2576. return *v, true
  2577. }
  2578. // OldMarkname returns the old "markname" field's value of the Contact entity.
  2579. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2581. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  2582. if !m.op.Is(OpUpdateOne) {
  2583. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  2584. }
  2585. if m.id == nil || m.oldValue == nil {
  2586. return v, errors.New("OldMarkname requires an ID field in the mutation")
  2587. }
  2588. oldValue, err := m.oldValue(ctx)
  2589. if err != nil {
  2590. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  2591. }
  2592. return oldValue.Markname, nil
  2593. }
  2594. // ResetMarkname resets all changes to the "markname" field.
  2595. func (m *ContactMutation) ResetMarkname() {
  2596. m.markname = nil
  2597. }
  2598. // SetHeadimg sets the "headimg" field.
  2599. func (m *ContactMutation) SetHeadimg(s string) {
  2600. m.headimg = &s
  2601. }
  2602. // Headimg returns the value of the "headimg" field in the mutation.
  2603. func (m *ContactMutation) Headimg() (r string, exists bool) {
  2604. v := m.headimg
  2605. if v == nil {
  2606. return
  2607. }
  2608. return *v, true
  2609. }
  2610. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  2611. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2612. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2613. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  2614. if !m.op.Is(OpUpdateOne) {
  2615. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  2616. }
  2617. if m.id == nil || m.oldValue == nil {
  2618. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  2619. }
  2620. oldValue, err := m.oldValue(ctx)
  2621. if err != nil {
  2622. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  2623. }
  2624. return oldValue.Headimg, nil
  2625. }
  2626. // ResetHeadimg resets all changes to the "headimg" field.
  2627. func (m *ContactMutation) ResetHeadimg() {
  2628. m.headimg = nil
  2629. }
  2630. // SetSex sets the "sex" field.
  2631. func (m *ContactMutation) SetSex(i int) {
  2632. m.sex = &i
  2633. m.addsex = nil
  2634. }
  2635. // Sex returns the value of the "sex" field in the mutation.
  2636. func (m *ContactMutation) Sex() (r int, exists bool) {
  2637. v := m.sex
  2638. if v == nil {
  2639. return
  2640. }
  2641. return *v, true
  2642. }
  2643. // OldSex returns the old "sex" field's value of the Contact entity.
  2644. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2645. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2646. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  2647. if !m.op.Is(OpUpdateOne) {
  2648. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  2649. }
  2650. if m.id == nil || m.oldValue == nil {
  2651. return v, errors.New("OldSex requires an ID field in the mutation")
  2652. }
  2653. oldValue, err := m.oldValue(ctx)
  2654. if err != nil {
  2655. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  2656. }
  2657. return oldValue.Sex, nil
  2658. }
  2659. // AddSex adds i to the "sex" field.
  2660. func (m *ContactMutation) AddSex(i int) {
  2661. if m.addsex != nil {
  2662. *m.addsex += i
  2663. } else {
  2664. m.addsex = &i
  2665. }
  2666. }
  2667. // AddedSex returns the value that was added to the "sex" field in this mutation.
  2668. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  2669. v := m.addsex
  2670. if v == nil {
  2671. return
  2672. }
  2673. return *v, true
  2674. }
  2675. // ResetSex resets all changes to the "sex" field.
  2676. func (m *ContactMutation) ResetSex() {
  2677. m.sex = nil
  2678. m.addsex = nil
  2679. }
  2680. // SetStarrole sets the "starrole" field.
  2681. func (m *ContactMutation) SetStarrole(s string) {
  2682. m.starrole = &s
  2683. }
  2684. // Starrole returns the value of the "starrole" field in the mutation.
  2685. func (m *ContactMutation) Starrole() (r string, exists bool) {
  2686. v := m.starrole
  2687. if v == nil {
  2688. return
  2689. }
  2690. return *v, true
  2691. }
  2692. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  2693. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2694. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2695. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  2696. if !m.op.Is(OpUpdateOne) {
  2697. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  2698. }
  2699. if m.id == nil || m.oldValue == nil {
  2700. return v, errors.New("OldStarrole requires an ID field in the mutation")
  2701. }
  2702. oldValue, err := m.oldValue(ctx)
  2703. if err != nil {
  2704. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  2705. }
  2706. return oldValue.Starrole, nil
  2707. }
  2708. // ResetStarrole resets all changes to the "starrole" field.
  2709. func (m *ContactMutation) ResetStarrole() {
  2710. m.starrole = nil
  2711. }
  2712. // SetDontseeit sets the "dontseeit" field.
  2713. func (m *ContactMutation) SetDontseeit(i int) {
  2714. m.dontseeit = &i
  2715. m.adddontseeit = nil
  2716. }
  2717. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  2718. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  2719. v := m.dontseeit
  2720. if v == nil {
  2721. return
  2722. }
  2723. return *v, true
  2724. }
  2725. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  2726. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2727. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2728. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  2729. if !m.op.Is(OpUpdateOne) {
  2730. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  2731. }
  2732. if m.id == nil || m.oldValue == nil {
  2733. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  2734. }
  2735. oldValue, err := m.oldValue(ctx)
  2736. if err != nil {
  2737. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  2738. }
  2739. return oldValue.Dontseeit, nil
  2740. }
  2741. // AddDontseeit adds i to the "dontseeit" field.
  2742. func (m *ContactMutation) AddDontseeit(i int) {
  2743. if m.adddontseeit != nil {
  2744. *m.adddontseeit += i
  2745. } else {
  2746. m.adddontseeit = &i
  2747. }
  2748. }
  2749. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  2750. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  2751. v := m.adddontseeit
  2752. if v == nil {
  2753. return
  2754. }
  2755. return *v, true
  2756. }
  2757. // ResetDontseeit resets all changes to the "dontseeit" field.
  2758. func (m *ContactMutation) ResetDontseeit() {
  2759. m.dontseeit = nil
  2760. m.adddontseeit = nil
  2761. }
  2762. // SetDontseeme sets the "dontseeme" field.
  2763. func (m *ContactMutation) SetDontseeme(i int) {
  2764. m.dontseeme = &i
  2765. m.adddontseeme = nil
  2766. }
  2767. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  2768. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  2769. v := m.dontseeme
  2770. if v == nil {
  2771. return
  2772. }
  2773. return *v, true
  2774. }
  2775. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  2776. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2777. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2778. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  2779. if !m.op.Is(OpUpdateOne) {
  2780. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  2781. }
  2782. if m.id == nil || m.oldValue == nil {
  2783. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  2784. }
  2785. oldValue, err := m.oldValue(ctx)
  2786. if err != nil {
  2787. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  2788. }
  2789. return oldValue.Dontseeme, nil
  2790. }
  2791. // AddDontseeme adds i to the "dontseeme" field.
  2792. func (m *ContactMutation) AddDontseeme(i int) {
  2793. if m.adddontseeme != nil {
  2794. *m.adddontseeme += i
  2795. } else {
  2796. m.adddontseeme = &i
  2797. }
  2798. }
  2799. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  2800. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  2801. v := m.adddontseeme
  2802. if v == nil {
  2803. return
  2804. }
  2805. return *v, true
  2806. }
  2807. // ResetDontseeme resets all changes to the "dontseeme" field.
  2808. func (m *ContactMutation) ResetDontseeme() {
  2809. m.dontseeme = nil
  2810. m.adddontseeme = nil
  2811. }
  2812. // SetLag sets the "lag" field.
  2813. func (m *ContactMutation) SetLag(s string) {
  2814. m.lag = &s
  2815. }
  2816. // Lag returns the value of the "lag" field in the mutation.
  2817. func (m *ContactMutation) Lag() (r string, exists bool) {
  2818. v := m.lag
  2819. if v == nil {
  2820. return
  2821. }
  2822. return *v, true
  2823. }
  2824. // OldLag returns the old "lag" field's value of the Contact entity.
  2825. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2826. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2827. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  2828. if !m.op.Is(OpUpdateOne) {
  2829. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  2830. }
  2831. if m.id == nil || m.oldValue == nil {
  2832. return v, errors.New("OldLag requires an ID field in the mutation")
  2833. }
  2834. oldValue, err := m.oldValue(ctx)
  2835. if err != nil {
  2836. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  2837. }
  2838. return oldValue.Lag, nil
  2839. }
  2840. // ResetLag resets all changes to the "lag" field.
  2841. func (m *ContactMutation) ResetLag() {
  2842. m.lag = nil
  2843. }
  2844. // SetGid sets the "gid" field.
  2845. func (m *ContactMutation) SetGid(s string) {
  2846. m.gid = &s
  2847. }
  2848. // Gid returns the value of the "gid" field in the mutation.
  2849. func (m *ContactMutation) Gid() (r string, exists bool) {
  2850. v := m.gid
  2851. if v == nil {
  2852. return
  2853. }
  2854. return *v, true
  2855. }
  2856. // OldGid returns the old "gid" field's value of the Contact entity.
  2857. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2858. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2859. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  2860. if !m.op.Is(OpUpdateOne) {
  2861. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  2862. }
  2863. if m.id == nil || m.oldValue == nil {
  2864. return v, errors.New("OldGid requires an ID field in the mutation")
  2865. }
  2866. oldValue, err := m.oldValue(ctx)
  2867. if err != nil {
  2868. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  2869. }
  2870. return oldValue.Gid, nil
  2871. }
  2872. // ResetGid resets all changes to the "gid" field.
  2873. func (m *ContactMutation) ResetGid() {
  2874. m.gid = nil
  2875. }
  2876. // SetGname sets the "gname" field.
  2877. func (m *ContactMutation) SetGname(s string) {
  2878. m.gname = &s
  2879. }
  2880. // Gname returns the value of the "gname" field in the mutation.
  2881. func (m *ContactMutation) Gname() (r string, exists bool) {
  2882. v := m.gname
  2883. if v == nil {
  2884. return
  2885. }
  2886. return *v, true
  2887. }
  2888. // OldGname returns the old "gname" field's value of the Contact entity.
  2889. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2890. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2891. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  2892. if !m.op.Is(OpUpdateOne) {
  2893. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  2894. }
  2895. if m.id == nil || m.oldValue == nil {
  2896. return v, errors.New("OldGname requires an ID field in the mutation")
  2897. }
  2898. oldValue, err := m.oldValue(ctx)
  2899. if err != nil {
  2900. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  2901. }
  2902. return oldValue.Gname, nil
  2903. }
  2904. // ResetGname resets all changes to the "gname" field.
  2905. func (m *ContactMutation) ResetGname() {
  2906. m.gname = nil
  2907. }
  2908. // SetV3 sets the "v3" field.
  2909. func (m *ContactMutation) SetV3(s string) {
  2910. m.v3 = &s
  2911. }
  2912. // V3 returns the value of the "v3" field in the mutation.
  2913. func (m *ContactMutation) V3() (r string, exists bool) {
  2914. v := m.v3
  2915. if v == nil {
  2916. return
  2917. }
  2918. return *v, true
  2919. }
  2920. // OldV3 returns the old "v3" field's value of the Contact entity.
  2921. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2922. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2923. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  2924. if !m.op.Is(OpUpdateOne) {
  2925. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  2926. }
  2927. if m.id == nil || m.oldValue == nil {
  2928. return v, errors.New("OldV3 requires an ID field in the mutation")
  2929. }
  2930. oldValue, err := m.oldValue(ctx)
  2931. if err != nil {
  2932. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  2933. }
  2934. return oldValue.V3, nil
  2935. }
  2936. // ResetV3 resets all changes to the "v3" field.
  2937. func (m *ContactMutation) ResetV3() {
  2938. m.v3 = nil
  2939. }
  2940. // SetOrganizationID sets the "organization_id" field.
  2941. func (m *ContactMutation) SetOrganizationID(u uint64) {
  2942. m.organization_id = &u
  2943. m.addorganization_id = nil
  2944. }
  2945. // OrganizationID returns the value of the "organization_id" field in the mutation.
  2946. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  2947. v := m.organization_id
  2948. if v == nil {
  2949. return
  2950. }
  2951. return *v, true
  2952. }
  2953. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  2954. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  2955. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2956. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  2957. if !m.op.Is(OpUpdateOne) {
  2958. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  2959. }
  2960. if m.id == nil || m.oldValue == nil {
  2961. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  2962. }
  2963. oldValue, err := m.oldValue(ctx)
  2964. if err != nil {
  2965. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  2966. }
  2967. return oldValue.OrganizationID, nil
  2968. }
  2969. // AddOrganizationID adds u to the "organization_id" field.
  2970. func (m *ContactMutation) AddOrganizationID(u int64) {
  2971. if m.addorganization_id != nil {
  2972. *m.addorganization_id += u
  2973. } else {
  2974. m.addorganization_id = &u
  2975. }
  2976. }
  2977. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  2978. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  2979. v := m.addorganization_id
  2980. if v == nil {
  2981. return
  2982. }
  2983. return *v, true
  2984. }
  2985. // ClearOrganizationID clears the value of the "organization_id" field.
  2986. func (m *ContactMutation) ClearOrganizationID() {
  2987. m.organization_id = nil
  2988. m.addorganization_id = nil
  2989. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  2990. }
  2991. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  2992. func (m *ContactMutation) OrganizationIDCleared() bool {
  2993. _, ok := m.clearedFields[contact.FieldOrganizationID]
  2994. return ok
  2995. }
  2996. // ResetOrganizationID resets all changes to the "organization_id" field.
  2997. func (m *ContactMutation) ResetOrganizationID() {
  2998. m.organization_id = nil
  2999. m.addorganization_id = nil
  3000. delete(m.clearedFields, contact.FieldOrganizationID)
  3001. }
  3002. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  3003. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  3004. if m.contact_relationships == nil {
  3005. m.contact_relationships = make(map[uint64]struct{})
  3006. }
  3007. for i := range ids {
  3008. m.contact_relationships[ids[i]] = struct{}{}
  3009. }
  3010. }
  3011. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  3012. func (m *ContactMutation) ClearContactRelationships() {
  3013. m.clearedcontact_relationships = true
  3014. }
  3015. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  3016. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  3017. return m.clearedcontact_relationships
  3018. }
  3019. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  3020. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  3021. if m.removedcontact_relationships == nil {
  3022. m.removedcontact_relationships = make(map[uint64]struct{})
  3023. }
  3024. for i := range ids {
  3025. delete(m.contact_relationships, ids[i])
  3026. m.removedcontact_relationships[ids[i]] = struct{}{}
  3027. }
  3028. }
  3029. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  3030. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  3031. for id := range m.removedcontact_relationships {
  3032. ids = append(ids, id)
  3033. }
  3034. return
  3035. }
  3036. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  3037. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  3038. for id := range m.contact_relationships {
  3039. ids = append(ids, id)
  3040. }
  3041. return
  3042. }
  3043. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  3044. func (m *ContactMutation) ResetContactRelationships() {
  3045. m.contact_relationships = nil
  3046. m.clearedcontact_relationships = false
  3047. m.removedcontact_relationships = nil
  3048. }
  3049. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  3050. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  3051. if m.contact_messages == nil {
  3052. m.contact_messages = make(map[uint64]struct{})
  3053. }
  3054. for i := range ids {
  3055. m.contact_messages[ids[i]] = struct{}{}
  3056. }
  3057. }
  3058. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  3059. func (m *ContactMutation) ClearContactMessages() {
  3060. m.clearedcontact_messages = true
  3061. }
  3062. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  3063. func (m *ContactMutation) ContactMessagesCleared() bool {
  3064. return m.clearedcontact_messages
  3065. }
  3066. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  3067. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  3068. if m.removedcontact_messages == nil {
  3069. m.removedcontact_messages = make(map[uint64]struct{})
  3070. }
  3071. for i := range ids {
  3072. delete(m.contact_messages, ids[i])
  3073. m.removedcontact_messages[ids[i]] = struct{}{}
  3074. }
  3075. }
  3076. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  3077. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  3078. for id := range m.removedcontact_messages {
  3079. ids = append(ids, id)
  3080. }
  3081. return
  3082. }
  3083. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  3084. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  3085. for id := range m.contact_messages {
  3086. ids = append(ids, id)
  3087. }
  3088. return
  3089. }
  3090. // ResetContactMessages resets all changes to the "contact_messages" edge.
  3091. func (m *ContactMutation) ResetContactMessages() {
  3092. m.contact_messages = nil
  3093. m.clearedcontact_messages = false
  3094. m.removedcontact_messages = nil
  3095. }
  3096. // Where appends a list predicates to the ContactMutation builder.
  3097. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  3098. m.predicates = append(m.predicates, ps...)
  3099. }
  3100. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  3101. // users can use type-assertion to append predicates that do not depend on any generated package.
  3102. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  3103. p := make([]predicate.Contact, len(ps))
  3104. for i := range ps {
  3105. p[i] = ps[i]
  3106. }
  3107. m.Where(p...)
  3108. }
  3109. // Op returns the operation name.
  3110. func (m *ContactMutation) Op() Op {
  3111. return m.op
  3112. }
  3113. // SetOp allows setting the mutation operation.
  3114. func (m *ContactMutation) SetOp(op Op) {
  3115. m.op = op
  3116. }
  3117. // Type returns the node type of this mutation (Contact).
  3118. func (m *ContactMutation) Type() string {
  3119. return m.typ
  3120. }
  3121. // Fields returns all fields that were changed during this mutation. Note that in
  3122. // order to get all numeric fields that were incremented/decremented, call
  3123. // AddedFields().
  3124. func (m *ContactMutation) Fields() []string {
  3125. fields := make([]string, 0, 20)
  3126. if m.created_at != nil {
  3127. fields = append(fields, contact.FieldCreatedAt)
  3128. }
  3129. if m.updated_at != nil {
  3130. fields = append(fields, contact.FieldUpdatedAt)
  3131. }
  3132. if m.status != nil {
  3133. fields = append(fields, contact.FieldStatus)
  3134. }
  3135. if m.deleted_at != nil {
  3136. fields = append(fields, contact.FieldDeletedAt)
  3137. }
  3138. if m.wx_wxid != nil {
  3139. fields = append(fields, contact.FieldWxWxid)
  3140. }
  3141. if m._type != nil {
  3142. fields = append(fields, contact.FieldType)
  3143. }
  3144. if m.wxid != nil {
  3145. fields = append(fields, contact.FieldWxid)
  3146. }
  3147. if m.account != nil {
  3148. fields = append(fields, contact.FieldAccount)
  3149. }
  3150. if m.nickname != nil {
  3151. fields = append(fields, contact.FieldNickname)
  3152. }
  3153. if m.markname != nil {
  3154. fields = append(fields, contact.FieldMarkname)
  3155. }
  3156. if m.headimg != nil {
  3157. fields = append(fields, contact.FieldHeadimg)
  3158. }
  3159. if m.sex != nil {
  3160. fields = append(fields, contact.FieldSex)
  3161. }
  3162. if m.starrole != nil {
  3163. fields = append(fields, contact.FieldStarrole)
  3164. }
  3165. if m.dontseeit != nil {
  3166. fields = append(fields, contact.FieldDontseeit)
  3167. }
  3168. if m.dontseeme != nil {
  3169. fields = append(fields, contact.FieldDontseeme)
  3170. }
  3171. if m.lag != nil {
  3172. fields = append(fields, contact.FieldLag)
  3173. }
  3174. if m.gid != nil {
  3175. fields = append(fields, contact.FieldGid)
  3176. }
  3177. if m.gname != nil {
  3178. fields = append(fields, contact.FieldGname)
  3179. }
  3180. if m.v3 != nil {
  3181. fields = append(fields, contact.FieldV3)
  3182. }
  3183. if m.organization_id != nil {
  3184. fields = append(fields, contact.FieldOrganizationID)
  3185. }
  3186. return fields
  3187. }
  3188. // Field returns the value of a field with the given name. The second boolean
  3189. // return value indicates that this field was not set, or was not defined in the
  3190. // schema.
  3191. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  3192. switch name {
  3193. case contact.FieldCreatedAt:
  3194. return m.CreatedAt()
  3195. case contact.FieldUpdatedAt:
  3196. return m.UpdatedAt()
  3197. case contact.FieldStatus:
  3198. return m.Status()
  3199. case contact.FieldDeletedAt:
  3200. return m.DeletedAt()
  3201. case contact.FieldWxWxid:
  3202. return m.WxWxid()
  3203. case contact.FieldType:
  3204. return m.GetType()
  3205. case contact.FieldWxid:
  3206. return m.Wxid()
  3207. case contact.FieldAccount:
  3208. return m.Account()
  3209. case contact.FieldNickname:
  3210. return m.Nickname()
  3211. case contact.FieldMarkname:
  3212. return m.Markname()
  3213. case contact.FieldHeadimg:
  3214. return m.Headimg()
  3215. case contact.FieldSex:
  3216. return m.Sex()
  3217. case contact.FieldStarrole:
  3218. return m.Starrole()
  3219. case contact.FieldDontseeit:
  3220. return m.Dontseeit()
  3221. case contact.FieldDontseeme:
  3222. return m.Dontseeme()
  3223. case contact.FieldLag:
  3224. return m.Lag()
  3225. case contact.FieldGid:
  3226. return m.Gid()
  3227. case contact.FieldGname:
  3228. return m.Gname()
  3229. case contact.FieldV3:
  3230. return m.V3()
  3231. case contact.FieldOrganizationID:
  3232. return m.OrganizationID()
  3233. }
  3234. return nil, false
  3235. }
  3236. // OldField returns the old value of the field from the database. An error is
  3237. // returned if the mutation operation is not UpdateOne, or the query to the
  3238. // database failed.
  3239. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3240. switch name {
  3241. case contact.FieldCreatedAt:
  3242. return m.OldCreatedAt(ctx)
  3243. case contact.FieldUpdatedAt:
  3244. return m.OldUpdatedAt(ctx)
  3245. case contact.FieldStatus:
  3246. return m.OldStatus(ctx)
  3247. case contact.FieldDeletedAt:
  3248. return m.OldDeletedAt(ctx)
  3249. case contact.FieldWxWxid:
  3250. return m.OldWxWxid(ctx)
  3251. case contact.FieldType:
  3252. return m.OldType(ctx)
  3253. case contact.FieldWxid:
  3254. return m.OldWxid(ctx)
  3255. case contact.FieldAccount:
  3256. return m.OldAccount(ctx)
  3257. case contact.FieldNickname:
  3258. return m.OldNickname(ctx)
  3259. case contact.FieldMarkname:
  3260. return m.OldMarkname(ctx)
  3261. case contact.FieldHeadimg:
  3262. return m.OldHeadimg(ctx)
  3263. case contact.FieldSex:
  3264. return m.OldSex(ctx)
  3265. case contact.FieldStarrole:
  3266. return m.OldStarrole(ctx)
  3267. case contact.FieldDontseeit:
  3268. return m.OldDontseeit(ctx)
  3269. case contact.FieldDontseeme:
  3270. return m.OldDontseeme(ctx)
  3271. case contact.FieldLag:
  3272. return m.OldLag(ctx)
  3273. case contact.FieldGid:
  3274. return m.OldGid(ctx)
  3275. case contact.FieldGname:
  3276. return m.OldGname(ctx)
  3277. case contact.FieldV3:
  3278. return m.OldV3(ctx)
  3279. case contact.FieldOrganizationID:
  3280. return m.OldOrganizationID(ctx)
  3281. }
  3282. return nil, fmt.Errorf("unknown Contact field %s", name)
  3283. }
  3284. // SetField sets the value of a field with the given name. It returns an error if
  3285. // the field is not defined in the schema, or if the type mismatched the field
  3286. // type.
  3287. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  3288. switch name {
  3289. case contact.FieldCreatedAt:
  3290. v, ok := value.(time.Time)
  3291. if !ok {
  3292. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3293. }
  3294. m.SetCreatedAt(v)
  3295. return nil
  3296. case contact.FieldUpdatedAt:
  3297. v, ok := value.(time.Time)
  3298. if !ok {
  3299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3300. }
  3301. m.SetUpdatedAt(v)
  3302. return nil
  3303. case contact.FieldStatus:
  3304. v, ok := value.(uint8)
  3305. if !ok {
  3306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3307. }
  3308. m.SetStatus(v)
  3309. return nil
  3310. case contact.FieldDeletedAt:
  3311. v, ok := value.(time.Time)
  3312. if !ok {
  3313. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3314. }
  3315. m.SetDeletedAt(v)
  3316. return nil
  3317. case contact.FieldWxWxid:
  3318. v, ok := value.(string)
  3319. if !ok {
  3320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3321. }
  3322. m.SetWxWxid(v)
  3323. return nil
  3324. case contact.FieldType:
  3325. v, ok := value.(int)
  3326. if !ok {
  3327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3328. }
  3329. m.SetType(v)
  3330. return nil
  3331. case contact.FieldWxid:
  3332. v, ok := value.(string)
  3333. if !ok {
  3334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3335. }
  3336. m.SetWxid(v)
  3337. return nil
  3338. case contact.FieldAccount:
  3339. v, ok := value.(string)
  3340. if !ok {
  3341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3342. }
  3343. m.SetAccount(v)
  3344. return nil
  3345. case contact.FieldNickname:
  3346. v, ok := value.(string)
  3347. if !ok {
  3348. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3349. }
  3350. m.SetNickname(v)
  3351. return nil
  3352. case contact.FieldMarkname:
  3353. v, ok := value.(string)
  3354. if !ok {
  3355. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3356. }
  3357. m.SetMarkname(v)
  3358. return nil
  3359. case contact.FieldHeadimg:
  3360. v, ok := value.(string)
  3361. if !ok {
  3362. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3363. }
  3364. m.SetHeadimg(v)
  3365. return nil
  3366. case contact.FieldSex:
  3367. v, ok := value.(int)
  3368. if !ok {
  3369. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3370. }
  3371. m.SetSex(v)
  3372. return nil
  3373. case contact.FieldStarrole:
  3374. v, ok := value.(string)
  3375. if !ok {
  3376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3377. }
  3378. m.SetStarrole(v)
  3379. return nil
  3380. case contact.FieldDontseeit:
  3381. v, ok := value.(int)
  3382. if !ok {
  3383. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3384. }
  3385. m.SetDontseeit(v)
  3386. return nil
  3387. case contact.FieldDontseeme:
  3388. v, ok := value.(int)
  3389. if !ok {
  3390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3391. }
  3392. m.SetDontseeme(v)
  3393. return nil
  3394. case contact.FieldLag:
  3395. v, ok := value.(string)
  3396. if !ok {
  3397. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3398. }
  3399. m.SetLag(v)
  3400. return nil
  3401. case contact.FieldGid:
  3402. v, ok := value.(string)
  3403. if !ok {
  3404. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3405. }
  3406. m.SetGid(v)
  3407. return nil
  3408. case contact.FieldGname:
  3409. v, ok := value.(string)
  3410. if !ok {
  3411. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3412. }
  3413. m.SetGname(v)
  3414. return nil
  3415. case contact.FieldV3:
  3416. v, ok := value.(string)
  3417. if !ok {
  3418. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3419. }
  3420. m.SetV3(v)
  3421. return nil
  3422. case contact.FieldOrganizationID:
  3423. v, ok := value.(uint64)
  3424. if !ok {
  3425. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3426. }
  3427. m.SetOrganizationID(v)
  3428. return nil
  3429. }
  3430. return fmt.Errorf("unknown Contact field %s", name)
  3431. }
  3432. // AddedFields returns all numeric fields that were incremented/decremented during
  3433. // this mutation.
  3434. func (m *ContactMutation) AddedFields() []string {
  3435. var fields []string
  3436. if m.addstatus != nil {
  3437. fields = append(fields, contact.FieldStatus)
  3438. }
  3439. if m.add_type != nil {
  3440. fields = append(fields, contact.FieldType)
  3441. }
  3442. if m.addsex != nil {
  3443. fields = append(fields, contact.FieldSex)
  3444. }
  3445. if m.adddontseeit != nil {
  3446. fields = append(fields, contact.FieldDontseeit)
  3447. }
  3448. if m.adddontseeme != nil {
  3449. fields = append(fields, contact.FieldDontseeme)
  3450. }
  3451. if m.addorganization_id != nil {
  3452. fields = append(fields, contact.FieldOrganizationID)
  3453. }
  3454. return fields
  3455. }
  3456. // AddedField returns the numeric value that was incremented/decremented on a field
  3457. // with the given name. The second boolean return value indicates that this field
  3458. // was not set, or was not defined in the schema.
  3459. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  3460. switch name {
  3461. case contact.FieldStatus:
  3462. return m.AddedStatus()
  3463. case contact.FieldType:
  3464. return m.AddedType()
  3465. case contact.FieldSex:
  3466. return m.AddedSex()
  3467. case contact.FieldDontseeit:
  3468. return m.AddedDontseeit()
  3469. case contact.FieldDontseeme:
  3470. return m.AddedDontseeme()
  3471. case contact.FieldOrganizationID:
  3472. return m.AddedOrganizationID()
  3473. }
  3474. return nil, false
  3475. }
  3476. // AddField adds the value to the field with the given name. It returns an error if
  3477. // the field is not defined in the schema, or if the type mismatched the field
  3478. // type.
  3479. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  3480. switch name {
  3481. case contact.FieldStatus:
  3482. v, ok := value.(int8)
  3483. if !ok {
  3484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3485. }
  3486. m.AddStatus(v)
  3487. return nil
  3488. case contact.FieldType:
  3489. v, ok := value.(int)
  3490. if !ok {
  3491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3492. }
  3493. m.AddType(v)
  3494. return nil
  3495. case contact.FieldSex:
  3496. v, ok := value.(int)
  3497. if !ok {
  3498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3499. }
  3500. m.AddSex(v)
  3501. return nil
  3502. case contact.FieldDontseeit:
  3503. v, ok := value.(int)
  3504. if !ok {
  3505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3506. }
  3507. m.AddDontseeit(v)
  3508. return nil
  3509. case contact.FieldDontseeme:
  3510. v, ok := value.(int)
  3511. if !ok {
  3512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3513. }
  3514. m.AddDontseeme(v)
  3515. return nil
  3516. case contact.FieldOrganizationID:
  3517. v, ok := value.(int64)
  3518. if !ok {
  3519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3520. }
  3521. m.AddOrganizationID(v)
  3522. return nil
  3523. }
  3524. return fmt.Errorf("unknown Contact numeric field %s", name)
  3525. }
  3526. // ClearedFields returns all nullable fields that were cleared during this
  3527. // mutation.
  3528. func (m *ContactMutation) ClearedFields() []string {
  3529. var fields []string
  3530. if m.FieldCleared(contact.FieldStatus) {
  3531. fields = append(fields, contact.FieldStatus)
  3532. }
  3533. if m.FieldCleared(contact.FieldDeletedAt) {
  3534. fields = append(fields, contact.FieldDeletedAt)
  3535. }
  3536. if m.FieldCleared(contact.FieldWxWxid) {
  3537. fields = append(fields, contact.FieldWxWxid)
  3538. }
  3539. if m.FieldCleared(contact.FieldType) {
  3540. fields = append(fields, contact.FieldType)
  3541. }
  3542. if m.FieldCleared(contact.FieldOrganizationID) {
  3543. fields = append(fields, contact.FieldOrganizationID)
  3544. }
  3545. return fields
  3546. }
  3547. // FieldCleared returns a boolean indicating if a field with the given name was
  3548. // cleared in this mutation.
  3549. func (m *ContactMutation) FieldCleared(name string) bool {
  3550. _, ok := m.clearedFields[name]
  3551. return ok
  3552. }
  3553. // ClearField clears the value of the field with the given name. It returns an
  3554. // error if the field is not defined in the schema.
  3555. func (m *ContactMutation) ClearField(name string) error {
  3556. switch name {
  3557. case contact.FieldStatus:
  3558. m.ClearStatus()
  3559. return nil
  3560. case contact.FieldDeletedAt:
  3561. m.ClearDeletedAt()
  3562. return nil
  3563. case contact.FieldWxWxid:
  3564. m.ClearWxWxid()
  3565. return nil
  3566. case contact.FieldType:
  3567. m.ClearType()
  3568. return nil
  3569. case contact.FieldOrganizationID:
  3570. m.ClearOrganizationID()
  3571. return nil
  3572. }
  3573. return fmt.Errorf("unknown Contact nullable field %s", name)
  3574. }
  3575. // ResetField resets all changes in the mutation for the field with the given name.
  3576. // It returns an error if the field is not defined in the schema.
  3577. func (m *ContactMutation) ResetField(name string) error {
  3578. switch name {
  3579. case contact.FieldCreatedAt:
  3580. m.ResetCreatedAt()
  3581. return nil
  3582. case contact.FieldUpdatedAt:
  3583. m.ResetUpdatedAt()
  3584. return nil
  3585. case contact.FieldStatus:
  3586. m.ResetStatus()
  3587. return nil
  3588. case contact.FieldDeletedAt:
  3589. m.ResetDeletedAt()
  3590. return nil
  3591. case contact.FieldWxWxid:
  3592. m.ResetWxWxid()
  3593. return nil
  3594. case contact.FieldType:
  3595. m.ResetType()
  3596. return nil
  3597. case contact.FieldWxid:
  3598. m.ResetWxid()
  3599. return nil
  3600. case contact.FieldAccount:
  3601. m.ResetAccount()
  3602. return nil
  3603. case contact.FieldNickname:
  3604. m.ResetNickname()
  3605. return nil
  3606. case contact.FieldMarkname:
  3607. m.ResetMarkname()
  3608. return nil
  3609. case contact.FieldHeadimg:
  3610. m.ResetHeadimg()
  3611. return nil
  3612. case contact.FieldSex:
  3613. m.ResetSex()
  3614. return nil
  3615. case contact.FieldStarrole:
  3616. m.ResetStarrole()
  3617. return nil
  3618. case contact.FieldDontseeit:
  3619. m.ResetDontseeit()
  3620. return nil
  3621. case contact.FieldDontseeme:
  3622. m.ResetDontseeme()
  3623. return nil
  3624. case contact.FieldLag:
  3625. m.ResetLag()
  3626. return nil
  3627. case contact.FieldGid:
  3628. m.ResetGid()
  3629. return nil
  3630. case contact.FieldGname:
  3631. m.ResetGname()
  3632. return nil
  3633. case contact.FieldV3:
  3634. m.ResetV3()
  3635. return nil
  3636. case contact.FieldOrganizationID:
  3637. m.ResetOrganizationID()
  3638. return nil
  3639. }
  3640. return fmt.Errorf("unknown Contact field %s", name)
  3641. }
  3642. // AddedEdges returns all edge names that were set/added in this mutation.
  3643. func (m *ContactMutation) AddedEdges() []string {
  3644. edges := make([]string, 0, 2)
  3645. if m.contact_relationships != nil {
  3646. edges = append(edges, contact.EdgeContactRelationships)
  3647. }
  3648. if m.contact_messages != nil {
  3649. edges = append(edges, contact.EdgeContactMessages)
  3650. }
  3651. return edges
  3652. }
  3653. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3654. // name in this mutation.
  3655. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  3656. switch name {
  3657. case contact.EdgeContactRelationships:
  3658. ids := make([]ent.Value, 0, len(m.contact_relationships))
  3659. for id := range m.contact_relationships {
  3660. ids = append(ids, id)
  3661. }
  3662. return ids
  3663. case contact.EdgeContactMessages:
  3664. ids := make([]ent.Value, 0, len(m.contact_messages))
  3665. for id := range m.contact_messages {
  3666. ids = append(ids, id)
  3667. }
  3668. return ids
  3669. }
  3670. return nil
  3671. }
  3672. // RemovedEdges returns all edge names that were removed in this mutation.
  3673. func (m *ContactMutation) RemovedEdges() []string {
  3674. edges := make([]string, 0, 2)
  3675. if m.removedcontact_relationships != nil {
  3676. edges = append(edges, contact.EdgeContactRelationships)
  3677. }
  3678. if m.removedcontact_messages != nil {
  3679. edges = append(edges, contact.EdgeContactMessages)
  3680. }
  3681. return edges
  3682. }
  3683. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3684. // the given name in this mutation.
  3685. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  3686. switch name {
  3687. case contact.EdgeContactRelationships:
  3688. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  3689. for id := range m.removedcontact_relationships {
  3690. ids = append(ids, id)
  3691. }
  3692. return ids
  3693. case contact.EdgeContactMessages:
  3694. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  3695. for id := range m.removedcontact_messages {
  3696. ids = append(ids, id)
  3697. }
  3698. return ids
  3699. }
  3700. return nil
  3701. }
  3702. // ClearedEdges returns all edge names that were cleared in this mutation.
  3703. func (m *ContactMutation) ClearedEdges() []string {
  3704. edges := make([]string, 0, 2)
  3705. if m.clearedcontact_relationships {
  3706. edges = append(edges, contact.EdgeContactRelationships)
  3707. }
  3708. if m.clearedcontact_messages {
  3709. edges = append(edges, contact.EdgeContactMessages)
  3710. }
  3711. return edges
  3712. }
  3713. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3714. // was cleared in this mutation.
  3715. func (m *ContactMutation) EdgeCleared(name string) bool {
  3716. switch name {
  3717. case contact.EdgeContactRelationships:
  3718. return m.clearedcontact_relationships
  3719. case contact.EdgeContactMessages:
  3720. return m.clearedcontact_messages
  3721. }
  3722. return false
  3723. }
  3724. // ClearEdge clears the value of the edge with the given name. It returns an error
  3725. // if that edge is not defined in the schema.
  3726. func (m *ContactMutation) ClearEdge(name string) error {
  3727. switch name {
  3728. }
  3729. return fmt.Errorf("unknown Contact unique edge %s", name)
  3730. }
  3731. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3732. // It returns an error if the edge is not defined in the schema.
  3733. func (m *ContactMutation) ResetEdge(name string) error {
  3734. switch name {
  3735. case contact.EdgeContactRelationships:
  3736. m.ResetContactRelationships()
  3737. return nil
  3738. case contact.EdgeContactMessages:
  3739. m.ResetContactMessages()
  3740. return nil
  3741. }
  3742. return fmt.Errorf("unknown Contact edge %s", name)
  3743. }
  3744. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  3745. type LabelMutation struct {
  3746. config
  3747. op Op
  3748. typ string
  3749. id *uint64
  3750. created_at *time.Time
  3751. updated_at *time.Time
  3752. status *uint8
  3753. addstatus *int8
  3754. _type *int
  3755. add_type *int
  3756. name *string
  3757. from *int
  3758. addfrom *int
  3759. mode *int
  3760. addmode *int
  3761. conditions *string
  3762. organization_id *uint64
  3763. addorganization_id *int64
  3764. clearedFields map[string]struct{}
  3765. label_relationships map[uint64]struct{}
  3766. removedlabel_relationships map[uint64]struct{}
  3767. clearedlabel_relationships bool
  3768. done bool
  3769. oldValue func(context.Context) (*Label, error)
  3770. predicates []predicate.Label
  3771. }
  3772. var _ ent.Mutation = (*LabelMutation)(nil)
  3773. // labelOption allows management of the mutation configuration using functional options.
  3774. type labelOption func(*LabelMutation)
  3775. // newLabelMutation creates new mutation for the Label entity.
  3776. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  3777. m := &LabelMutation{
  3778. config: c,
  3779. op: op,
  3780. typ: TypeLabel,
  3781. clearedFields: make(map[string]struct{}),
  3782. }
  3783. for _, opt := range opts {
  3784. opt(m)
  3785. }
  3786. return m
  3787. }
  3788. // withLabelID sets the ID field of the mutation.
  3789. func withLabelID(id uint64) labelOption {
  3790. return func(m *LabelMutation) {
  3791. var (
  3792. err error
  3793. once sync.Once
  3794. value *Label
  3795. )
  3796. m.oldValue = func(ctx context.Context) (*Label, error) {
  3797. once.Do(func() {
  3798. if m.done {
  3799. err = errors.New("querying old values post mutation is not allowed")
  3800. } else {
  3801. value, err = m.Client().Label.Get(ctx, id)
  3802. }
  3803. })
  3804. return value, err
  3805. }
  3806. m.id = &id
  3807. }
  3808. }
  3809. // withLabel sets the old Label of the mutation.
  3810. func withLabel(node *Label) labelOption {
  3811. return func(m *LabelMutation) {
  3812. m.oldValue = func(context.Context) (*Label, error) {
  3813. return node, nil
  3814. }
  3815. m.id = &node.ID
  3816. }
  3817. }
  3818. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3819. // executed in a transaction (ent.Tx), a transactional client is returned.
  3820. func (m LabelMutation) Client() *Client {
  3821. client := &Client{config: m.config}
  3822. client.init()
  3823. return client
  3824. }
  3825. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3826. // it returns an error otherwise.
  3827. func (m LabelMutation) Tx() (*Tx, error) {
  3828. if _, ok := m.driver.(*txDriver); !ok {
  3829. return nil, errors.New("ent: mutation is not running in a transaction")
  3830. }
  3831. tx := &Tx{config: m.config}
  3832. tx.init()
  3833. return tx, nil
  3834. }
  3835. // SetID sets the value of the id field. Note that this
  3836. // operation is only accepted on creation of Label entities.
  3837. func (m *LabelMutation) SetID(id uint64) {
  3838. m.id = &id
  3839. }
  3840. // ID returns the ID value in the mutation. Note that the ID is only available
  3841. // if it was provided to the builder or after it was returned from the database.
  3842. func (m *LabelMutation) ID() (id uint64, exists bool) {
  3843. if m.id == nil {
  3844. return
  3845. }
  3846. return *m.id, true
  3847. }
  3848. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3849. // That means, if the mutation is applied within a transaction with an isolation level such
  3850. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3851. // or updated by the mutation.
  3852. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  3853. switch {
  3854. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3855. id, exists := m.ID()
  3856. if exists {
  3857. return []uint64{id}, nil
  3858. }
  3859. fallthrough
  3860. case m.op.Is(OpUpdate | OpDelete):
  3861. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  3862. default:
  3863. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3864. }
  3865. }
  3866. // SetCreatedAt sets the "created_at" field.
  3867. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  3868. m.created_at = &t
  3869. }
  3870. // CreatedAt returns the value of the "created_at" field in the mutation.
  3871. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  3872. v := m.created_at
  3873. if v == nil {
  3874. return
  3875. }
  3876. return *v, true
  3877. }
  3878. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  3879. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  3880. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3881. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3882. if !m.op.Is(OpUpdateOne) {
  3883. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3884. }
  3885. if m.id == nil || m.oldValue == nil {
  3886. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3887. }
  3888. oldValue, err := m.oldValue(ctx)
  3889. if err != nil {
  3890. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3891. }
  3892. return oldValue.CreatedAt, nil
  3893. }
  3894. // ResetCreatedAt resets all changes to the "created_at" field.
  3895. func (m *LabelMutation) ResetCreatedAt() {
  3896. m.created_at = nil
  3897. }
  3898. // SetUpdatedAt sets the "updated_at" field.
  3899. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  3900. m.updated_at = &t
  3901. }
  3902. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3903. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  3904. v := m.updated_at
  3905. if v == nil {
  3906. return
  3907. }
  3908. return *v, true
  3909. }
  3910. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  3911. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  3912. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3913. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3914. if !m.op.Is(OpUpdateOne) {
  3915. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3916. }
  3917. if m.id == nil || m.oldValue == nil {
  3918. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3919. }
  3920. oldValue, err := m.oldValue(ctx)
  3921. if err != nil {
  3922. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3923. }
  3924. return oldValue.UpdatedAt, nil
  3925. }
  3926. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3927. func (m *LabelMutation) ResetUpdatedAt() {
  3928. m.updated_at = nil
  3929. }
  3930. // SetStatus sets the "status" field.
  3931. func (m *LabelMutation) SetStatus(u uint8) {
  3932. m.status = &u
  3933. m.addstatus = nil
  3934. }
  3935. // Status returns the value of the "status" field in the mutation.
  3936. func (m *LabelMutation) Status() (r uint8, exists bool) {
  3937. v := m.status
  3938. if v == nil {
  3939. return
  3940. }
  3941. return *v, true
  3942. }
  3943. // OldStatus returns the old "status" field's value of the Label entity.
  3944. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  3945. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3946. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  3947. if !m.op.Is(OpUpdateOne) {
  3948. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3949. }
  3950. if m.id == nil || m.oldValue == nil {
  3951. return v, errors.New("OldStatus requires an ID field in the mutation")
  3952. }
  3953. oldValue, err := m.oldValue(ctx)
  3954. if err != nil {
  3955. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3956. }
  3957. return oldValue.Status, nil
  3958. }
  3959. // AddStatus adds u to the "status" field.
  3960. func (m *LabelMutation) AddStatus(u int8) {
  3961. if m.addstatus != nil {
  3962. *m.addstatus += u
  3963. } else {
  3964. m.addstatus = &u
  3965. }
  3966. }
  3967. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3968. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  3969. v := m.addstatus
  3970. if v == nil {
  3971. return
  3972. }
  3973. return *v, true
  3974. }
  3975. // ClearStatus clears the value of the "status" field.
  3976. func (m *LabelMutation) ClearStatus() {
  3977. m.status = nil
  3978. m.addstatus = nil
  3979. m.clearedFields[label.FieldStatus] = struct{}{}
  3980. }
  3981. // StatusCleared returns if the "status" field was cleared in this mutation.
  3982. func (m *LabelMutation) StatusCleared() bool {
  3983. _, ok := m.clearedFields[label.FieldStatus]
  3984. return ok
  3985. }
  3986. // ResetStatus resets all changes to the "status" field.
  3987. func (m *LabelMutation) ResetStatus() {
  3988. m.status = nil
  3989. m.addstatus = nil
  3990. delete(m.clearedFields, label.FieldStatus)
  3991. }
  3992. // SetType sets the "type" field.
  3993. func (m *LabelMutation) SetType(i int) {
  3994. m._type = &i
  3995. m.add_type = nil
  3996. }
  3997. // GetType returns the value of the "type" field in the mutation.
  3998. func (m *LabelMutation) GetType() (r int, exists bool) {
  3999. v := m._type
  4000. if v == nil {
  4001. return
  4002. }
  4003. return *v, true
  4004. }
  4005. // OldType returns the old "type" field's value of the Label entity.
  4006. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  4007. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4008. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  4009. if !m.op.Is(OpUpdateOne) {
  4010. return v, errors.New("OldType is only allowed on UpdateOne operations")
  4011. }
  4012. if m.id == nil || m.oldValue == nil {
  4013. return v, errors.New("OldType requires an ID field in the mutation")
  4014. }
  4015. oldValue, err := m.oldValue(ctx)
  4016. if err != nil {
  4017. return v, fmt.Errorf("querying old value for OldType: %w", err)
  4018. }
  4019. return oldValue.Type, nil
  4020. }
  4021. // AddType adds i to the "type" field.
  4022. func (m *LabelMutation) AddType(i int) {
  4023. if m.add_type != nil {
  4024. *m.add_type += i
  4025. } else {
  4026. m.add_type = &i
  4027. }
  4028. }
  4029. // AddedType returns the value that was added to the "type" field in this mutation.
  4030. func (m *LabelMutation) AddedType() (r int, exists bool) {
  4031. v := m.add_type
  4032. if v == nil {
  4033. return
  4034. }
  4035. return *v, true
  4036. }
  4037. // ResetType resets all changes to the "type" field.
  4038. func (m *LabelMutation) ResetType() {
  4039. m._type = nil
  4040. m.add_type = nil
  4041. }
  4042. // SetName sets the "name" field.
  4043. func (m *LabelMutation) SetName(s string) {
  4044. m.name = &s
  4045. }
  4046. // Name returns the value of the "name" field in the mutation.
  4047. func (m *LabelMutation) Name() (r string, exists bool) {
  4048. v := m.name
  4049. if v == nil {
  4050. return
  4051. }
  4052. return *v, true
  4053. }
  4054. // OldName returns the old "name" field's value of the Label entity.
  4055. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  4056. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4057. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  4058. if !m.op.Is(OpUpdateOne) {
  4059. return v, errors.New("OldName is only allowed on UpdateOne operations")
  4060. }
  4061. if m.id == nil || m.oldValue == nil {
  4062. return v, errors.New("OldName requires an ID field in the mutation")
  4063. }
  4064. oldValue, err := m.oldValue(ctx)
  4065. if err != nil {
  4066. return v, fmt.Errorf("querying old value for OldName: %w", err)
  4067. }
  4068. return oldValue.Name, nil
  4069. }
  4070. // ResetName resets all changes to the "name" field.
  4071. func (m *LabelMutation) ResetName() {
  4072. m.name = nil
  4073. }
  4074. // SetFrom sets the "from" field.
  4075. func (m *LabelMutation) SetFrom(i int) {
  4076. m.from = &i
  4077. m.addfrom = nil
  4078. }
  4079. // From returns the value of the "from" field in the mutation.
  4080. func (m *LabelMutation) From() (r int, exists bool) {
  4081. v := m.from
  4082. if v == nil {
  4083. return
  4084. }
  4085. return *v, true
  4086. }
  4087. // OldFrom returns the old "from" field's value of the Label entity.
  4088. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  4089. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4090. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  4091. if !m.op.Is(OpUpdateOne) {
  4092. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  4093. }
  4094. if m.id == nil || m.oldValue == nil {
  4095. return v, errors.New("OldFrom requires an ID field in the mutation")
  4096. }
  4097. oldValue, err := m.oldValue(ctx)
  4098. if err != nil {
  4099. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  4100. }
  4101. return oldValue.From, nil
  4102. }
  4103. // AddFrom adds i to the "from" field.
  4104. func (m *LabelMutation) AddFrom(i int) {
  4105. if m.addfrom != nil {
  4106. *m.addfrom += i
  4107. } else {
  4108. m.addfrom = &i
  4109. }
  4110. }
  4111. // AddedFrom returns the value that was added to the "from" field in this mutation.
  4112. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  4113. v := m.addfrom
  4114. if v == nil {
  4115. return
  4116. }
  4117. return *v, true
  4118. }
  4119. // ResetFrom resets all changes to the "from" field.
  4120. func (m *LabelMutation) ResetFrom() {
  4121. m.from = nil
  4122. m.addfrom = nil
  4123. }
  4124. // SetMode sets the "mode" field.
  4125. func (m *LabelMutation) SetMode(i int) {
  4126. m.mode = &i
  4127. m.addmode = nil
  4128. }
  4129. // Mode returns the value of the "mode" field in the mutation.
  4130. func (m *LabelMutation) Mode() (r int, exists bool) {
  4131. v := m.mode
  4132. if v == nil {
  4133. return
  4134. }
  4135. return *v, true
  4136. }
  4137. // OldMode returns the old "mode" field's value of the Label entity.
  4138. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  4139. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4140. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  4141. if !m.op.Is(OpUpdateOne) {
  4142. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  4143. }
  4144. if m.id == nil || m.oldValue == nil {
  4145. return v, errors.New("OldMode requires an ID field in the mutation")
  4146. }
  4147. oldValue, err := m.oldValue(ctx)
  4148. if err != nil {
  4149. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  4150. }
  4151. return oldValue.Mode, nil
  4152. }
  4153. // AddMode adds i to the "mode" field.
  4154. func (m *LabelMutation) AddMode(i int) {
  4155. if m.addmode != nil {
  4156. *m.addmode += i
  4157. } else {
  4158. m.addmode = &i
  4159. }
  4160. }
  4161. // AddedMode returns the value that was added to the "mode" field in this mutation.
  4162. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  4163. v := m.addmode
  4164. if v == nil {
  4165. return
  4166. }
  4167. return *v, true
  4168. }
  4169. // ResetMode resets all changes to the "mode" field.
  4170. func (m *LabelMutation) ResetMode() {
  4171. m.mode = nil
  4172. m.addmode = nil
  4173. }
  4174. // SetConditions sets the "conditions" field.
  4175. func (m *LabelMutation) SetConditions(s string) {
  4176. m.conditions = &s
  4177. }
  4178. // Conditions returns the value of the "conditions" field in the mutation.
  4179. func (m *LabelMutation) Conditions() (r string, exists bool) {
  4180. v := m.conditions
  4181. if v == nil {
  4182. return
  4183. }
  4184. return *v, true
  4185. }
  4186. // OldConditions returns the old "conditions" field's value of the Label entity.
  4187. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  4188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4189. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  4190. if !m.op.Is(OpUpdateOne) {
  4191. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  4192. }
  4193. if m.id == nil || m.oldValue == nil {
  4194. return v, errors.New("OldConditions requires an ID field in the mutation")
  4195. }
  4196. oldValue, err := m.oldValue(ctx)
  4197. if err != nil {
  4198. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  4199. }
  4200. return oldValue.Conditions, nil
  4201. }
  4202. // ClearConditions clears the value of the "conditions" field.
  4203. func (m *LabelMutation) ClearConditions() {
  4204. m.conditions = nil
  4205. m.clearedFields[label.FieldConditions] = struct{}{}
  4206. }
  4207. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  4208. func (m *LabelMutation) ConditionsCleared() bool {
  4209. _, ok := m.clearedFields[label.FieldConditions]
  4210. return ok
  4211. }
  4212. // ResetConditions resets all changes to the "conditions" field.
  4213. func (m *LabelMutation) ResetConditions() {
  4214. m.conditions = nil
  4215. delete(m.clearedFields, label.FieldConditions)
  4216. }
  4217. // SetOrganizationID sets the "organization_id" field.
  4218. func (m *LabelMutation) SetOrganizationID(u uint64) {
  4219. m.organization_id = &u
  4220. m.addorganization_id = nil
  4221. }
  4222. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4223. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  4224. v := m.organization_id
  4225. if v == nil {
  4226. return
  4227. }
  4228. return *v, true
  4229. }
  4230. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  4231. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  4232. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4233. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4234. if !m.op.Is(OpUpdateOne) {
  4235. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4236. }
  4237. if m.id == nil || m.oldValue == nil {
  4238. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4239. }
  4240. oldValue, err := m.oldValue(ctx)
  4241. if err != nil {
  4242. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4243. }
  4244. return oldValue.OrganizationID, nil
  4245. }
  4246. // AddOrganizationID adds u to the "organization_id" field.
  4247. func (m *LabelMutation) AddOrganizationID(u int64) {
  4248. if m.addorganization_id != nil {
  4249. *m.addorganization_id += u
  4250. } else {
  4251. m.addorganization_id = &u
  4252. }
  4253. }
  4254. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4255. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  4256. v := m.addorganization_id
  4257. if v == nil {
  4258. return
  4259. }
  4260. return *v, true
  4261. }
  4262. // ClearOrganizationID clears the value of the "organization_id" field.
  4263. func (m *LabelMutation) ClearOrganizationID() {
  4264. m.organization_id = nil
  4265. m.addorganization_id = nil
  4266. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  4267. }
  4268. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  4269. func (m *LabelMutation) OrganizationIDCleared() bool {
  4270. _, ok := m.clearedFields[label.FieldOrganizationID]
  4271. return ok
  4272. }
  4273. // ResetOrganizationID resets all changes to the "organization_id" field.
  4274. func (m *LabelMutation) ResetOrganizationID() {
  4275. m.organization_id = nil
  4276. m.addorganization_id = nil
  4277. delete(m.clearedFields, label.FieldOrganizationID)
  4278. }
  4279. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  4280. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  4281. if m.label_relationships == nil {
  4282. m.label_relationships = make(map[uint64]struct{})
  4283. }
  4284. for i := range ids {
  4285. m.label_relationships[ids[i]] = struct{}{}
  4286. }
  4287. }
  4288. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  4289. func (m *LabelMutation) ClearLabelRelationships() {
  4290. m.clearedlabel_relationships = true
  4291. }
  4292. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  4293. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  4294. return m.clearedlabel_relationships
  4295. }
  4296. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  4297. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  4298. if m.removedlabel_relationships == nil {
  4299. m.removedlabel_relationships = make(map[uint64]struct{})
  4300. }
  4301. for i := range ids {
  4302. delete(m.label_relationships, ids[i])
  4303. m.removedlabel_relationships[ids[i]] = struct{}{}
  4304. }
  4305. }
  4306. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  4307. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  4308. for id := range m.removedlabel_relationships {
  4309. ids = append(ids, id)
  4310. }
  4311. return
  4312. }
  4313. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  4314. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  4315. for id := range m.label_relationships {
  4316. ids = append(ids, id)
  4317. }
  4318. return
  4319. }
  4320. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  4321. func (m *LabelMutation) ResetLabelRelationships() {
  4322. m.label_relationships = nil
  4323. m.clearedlabel_relationships = false
  4324. m.removedlabel_relationships = nil
  4325. }
  4326. // Where appends a list predicates to the LabelMutation builder.
  4327. func (m *LabelMutation) Where(ps ...predicate.Label) {
  4328. m.predicates = append(m.predicates, ps...)
  4329. }
  4330. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  4331. // users can use type-assertion to append predicates that do not depend on any generated package.
  4332. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  4333. p := make([]predicate.Label, len(ps))
  4334. for i := range ps {
  4335. p[i] = ps[i]
  4336. }
  4337. m.Where(p...)
  4338. }
  4339. // Op returns the operation name.
  4340. func (m *LabelMutation) Op() Op {
  4341. return m.op
  4342. }
  4343. // SetOp allows setting the mutation operation.
  4344. func (m *LabelMutation) SetOp(op Op) {
  4345. m.op = op
  4346. }
  4347. // Type returns the node type of this mutation (Label).
  4348. func (m *LabelMutation) Type() string {
  4349. return m.typ
  4350. }
  4351. // Fields returns all fields that were changed during this mutation. Note that in
  4352. // order to get all numeric fields that were incremented/decremented, call
  4353. // AddedFields().
  4354. func (m *LabelMutation) Fields() []string {
  4355. fields := make([]string, 0, 9)
  4356. if m.created_at != nil {
  4357. fields = append(fields, label.FieldCreatedAt)
  4358. }
  4359. if m.updated_at != nil {
  4360. fields = append(fields, label.FieldUpdatedAt)
  4361. }
  4362. if m.status != nil {
  4363. fields = append(fields, label.FieldStatus)
  4364. }
  4365. if m._type != nil {
  4366. fields = append(fields, label.FieldType)
  4367. }
  4368. if m.name != nil {
  4369. fields = append(fields, label.FieldName)
  4370. }
  4371. if m.from != nil {
  4372. fields = append(fields, label.FieldFrom)
  4373. }
  4374. if m.mode != nil {
  4375. fields = append(fields, label.FieldMode)
  4376. }
  4377. if m.conditions != nil {
  4378. fields = append(fields, label.FieldConditions)
  4379. }
  4380. if m.organization_id != nil {
  4381. fields = append(fields, label.FieldOrganizationID)
  4382. }
  4383. return fields
  4384. }
  4385. // Field returns the value of a field with the given name. The second boolean
  4386. // return value indicates that this field was not set, or was not defined in the
  4387. // schema.
  4388. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  4389. switch name {
  4390. case label.FieldCreatedAt:
  4391. return m.CreatedAt()
  4392. case label.FieldUpdatedAt:
  4393. return m.UpdatedAt()
  4394. case label.FieldStatus:
  4395. return m.Status()
  4396. case label.FieldType:
  4397. return m.GetType()
  4398. case label.FieldName:
  4399. return m.Name()
  4400. case label.FieldFrom:
  4401. return m.From()
  4402. case label.FieldMode:
  4403. return m.Mode()
  4404. case label.FieldConditions:
  4405. return m.Conditions()
  4406. case label.FieldOrganizationID:
  4407. return m.OrganizationID()
  4408. }
  4409. return nil, false
  4410. }
  4411. // OldField returns the old value of the field from the database. An error is
  4412. // returned if the mutation operation is not UpdateOne, or the query to the
  4413. // database failed.
  4414. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4415. switch name {
  4416. case label.FieldCreatedAt:
  4417. return m.OldCreatedAt(ctx)
  4418. case label.FieldUpdatedAt:
  4419. return m.OldUpdatedAt(ctx)
  4420. case label.FieldStatus:
  4421. return m.OldStatus(ctx)
  4422. case label.FieldType:
  4423. return m.OldType(ctx)
  4424. case label.FieldName:
  4425. return m.OldName(ctx)
  4426. case label.FieldFrom:
  4427. return m.OldFrom(ctx)
  4428. case label.FieldMode:
  4429. return m.OldMode(ctx)
  4430. case label.FieldConditions:
  4431. return m.OldConditions(ctx)
  4432. case label.FieldOrganizationID:
  4433. return m.OldOrganizationID(ctx)
  4434. }
  4435. return nil, fmt.Errorf("unknown Label field %s", name)
  4436. }
  4437. // SetField sets the value of a field with the given name. It returns an error if
  4438. // the field is not defined in the schema, or if the type mismatched the field
  4439. // type.
  4440. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  4441. switch name {
  4442. case label.FieldCreatedAt:
  4443. v, ok := value.(time.Time)
  4444. if !ok {
  4445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4446. }
  4447. m.SetCreatedAt(v)
  4448. return nil
  4449. case label.FieldUpdatedAt:
  4450. v, ok := value.(time.Time)
  4451. if !ok {
  4452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4453. }
  4454. m.SetUpdatedAt(v)
  4455. return nil
  4456. case label.FieldStatus:
  4457. v, ok := value.(uint8)
  4458. if !ok {
  4459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4460. }
  4461. m.SetStatus(v)
  4462. return nil
  4463. case label.FieldType:
  4464. v, ok := value.(int)
  4465. if !ok {
  4466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4467. }
  4468. m.SetType(v)
  4469. return nil
  4470. case label.FieldName:
  4471. v, ok := value.(string)
  4472. if !ok {
  4473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4474. }
  4475. m.SetName(v)
  4476. return nil
  4477. case label.FieldFrom:
  4478. v, ok := value.(int)
  4479. if !ok {
  4480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4481. }
  4482. m.SetFrom(v)
  4483. return nil
  4484. case label.FieldMode:
  4485. v, ok := value.(int)
  4486. if !ok {
  4487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4488. }
  4489. m.SetMode(v)
  4490. return nil
  4491. case label.FieldConditions:
  4492. v, ok := value.(string)
  4493. if !ok {
  4494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4495. }
  4496. m.SetConditions(v)
  4497. return nil
  4498. case label.FieldOrganizationID:
  4499. v, ok := value.(uint64)
  4500. if !ok {
  4501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4502. }
  4503. m.SetOrganizationID(v)
  4504. return nil
  4505. }
  4506. return fmt.Errorf("unknown Label field %s", name)
  4507. }
  4508. // AddedFields returns all numeric fields that were incremented/decremented during
  4509. // this mutation.
  4510. func (m *LabelMutation) AddedFields() []string {
  4511. var fields []string
  4512. if m.addstatus != nil {
  4513. fields = append(fields, label.FieldStatus)
  4514. }
  4515. if m.add_type != nil {
  4516. fields = append(fields, label.FieldType)
  4517. }
  4518. if m.addfrom != nil {
  4519. fields = append(fields, label.FieldFrom)
  4520. }
  4521. if m.addmode != nil {
  4522. fields = append(fields, label.FieldMode)
  4523. }
  4524. if m.addorganization_id != nil {
  4525. fields = append(fields, label.FieldOrganizationID)
  4526. }
  4527. return fields
  4528. }
  4529. // AddedField returns the numeric value that was incremented/decremented on a field
  4530. // with the given name. The second boolean return value indicates that this field
  4531. // was not set, or was not defined in the schema.
  4532. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  4533. switch name {
  4534. case label.FieldStatus:
  4535. return m.AddedStatus()
  4536. case label.FieldType:
  4537. return m.AddedType()
  4538. case label.FieldFrom:
  4539. return m.AddedFrom()
  4540. case label.FieldMode:
  4541. return m.AddedMode()
  4542. case label.FieldOrganizationID:
  4543. return m.AddedOrganizationID()
  4544. }
  4545. return nil, false
  4546. }
  4547. // AddField adds the value to the field with the given name. It returns an error if
  4548. // the field is not defined in the schema, or if the type mismatched the field
  4549. // type.
  4550. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  4551. switch name {
  4552. case label.FieldStatus:
  4553. v, ok := value.(int8)
  4554. if !ok {
  4555. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4556. }
  4557. m.AddStatus(v)
  4558. return nil
  4559. case label.FieldType:
  4560. v, ok := value.(int)
  4561. if !ok {
  4562. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4563. }
  4564. m.AddType(v)
  4565. return nil
  4566. case label.FieldFrom:
  4567. v, ok := value.(int)
  4568. if !ok {
  4569. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4570. }
  4571. m.AddFrom(v)
  4572. return nil
  4573. case label.FieldMode:
  4574. v, ok := value.(int)
  4575. if !ok {
  4576. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4577. }
  4578. m.AddMode(v)
  4579. return nil
  4580. case label.FieldOrganizationID:
  4581. v, ok := value.(int64)
  4582. if !ok {
  4583. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4584. }
  4585. m.AddOrganizationID(v)
  4586. return nil
  4587. }
  4588. return fmt.Errorf("unknown Label numeric field %s", name)
  4589. }
  4590. // ClearedFields returns all nullable fields that were cleared during this
  4591. // mutation.
  4592. func (m *LabelMutation) ClearedFields() []string {
  4593. var fields []string
  4594. if m.FieldCleared(label.FieldStatus) {
  4595. fields = append(fields, label.FieldStatus)
  4596. }
  4597. if m.FieldCleared(label.FieldConditions) {
  4598. fields = append(fields, label.FieldConditions)
  4599. }
  4600. if m.FieldCleared(label.FieldOrganizationID) {
  4601. fields = append(fields, label.FieldOrganizationID)
  4602. }
  4603. return fields
  4604. }
  4605. // FieldCleared returns a boolean indicating if a field with the given name was
  4606. // cleared in this mutation.
  4607. func (m *LabelMutation) FieldCleared(name string) bool {
  4608. _, ok := m.clearedFields[name]
  4609. return ok
  4610. }
  4611. // ClearField clears the value of the field with the given name. It returns an
  4612. // error if the field is not defined in the schema.
  4613. func (m *LabelMutation) ClearField(name string) error {
  4614. switch name {
  4615. case label.FieldStatus:
  4616. m.ClearStatus()
  4617. return nil
  4618. case label.FieldConditions:
  4619. m.ClearConditions()
  4620. return nil
  4621. case label.FieldOrganizationID:
  4622. m.ClearOrganizationID()
  4623. return nil
  4624. }
  4625. return fmt.Errorf("unknown Label nullable field %s", name)
  4626. }
  4627. // ResetField resets all changes in the mutation for the field with the given name.
  4628. // It returns an error if the field is not defined in the schema.
  4629. func (m *LabelMutation) ResetField(name string) error {
  4630. switch name {
  4631. case label.FieldCreatedAt:
  4632. m.ResetCreatedAt()
  4633. return nil
  4634. case label.FieldUpdatedAt:
  4635. m.ResetUpdatedAt()
  4636. return nil
  4637. case label.FieldStatus:
  4638. m.ResetStatus()
  4639. return nil
  4640. case label.FieldType:
  4641. m.ResetType()
  4642. return nil
  4643. case label.FieldName:
  4644. m.ResetName()
  4645. return nil
  4646. case label.FieldFrom:
  4647. m.ResetFrom()
  4648. return nil
  4649. case label.FieldMode:
  4650. m.ResetMode()
  4651. return nil
  4652. case label.FieldConditions:
  4653. m.ResetConditions()
  4654. return nil
  4655. case label.FieldOrganizationID:
  4656. m.ResetOrganizationID()
  4657. return nil
  4658. }
  4659. return fmt.Errorf("unknown Label field %s", name)
  4660. }
  4661. // AddedEdges returns all edge names that were set/added in this mutation.
  4662. func (m *LabelMutation) AddedEdges() []string {
  4663. edges := make([]string, 0, 1)
  4664. if m.label_relationships != nil {
  4665. edges = append(edges, label.EdgeLabelRelationships)
  4666. }
  4667. return edges
  4668. }
  4669. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4670. // name in this mutation.
  4671. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  4672. switch name {
  4673. case label.EdgeLabelRelationships:
  4674. ids := make([]ent.Value, 0, len(m.label_relationships))
  4675. for id := range m.label_relationships {
  4676. ids = append(ids, id)
  4677. }
  4678. return ids
  4679. }
  4680. return nil
  4681. }
  4682. // RemovedEdges returns all edge names that were removed in this mutation.
  4683. func (m *LabelMutation) RemovedEdges() []string {
  4684. edges := make([]string, 0, 1)
  4685. if m.removedlabel_relationships != nil {
  4686. edges = append(edges, label.EdgeLabelRelationships)
  4687. }
  4688. return edges
  4689. }
  4690. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4691. // the given name in this mutation.
  4692. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  4693. switch name {
  4694. case label.EdgeLabelRelationships:
  4695. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  4696. for id := range m.removedlabel_relationships {
  4697. ids = append(ids, id)
  4698. }
  4699. return ids
  4700. }
  4701. return nil
  4702. }
  4703. // ClearedEdges returns all edge names that were cleared in this mutation.
  4704. func (m *LabelMutation) ClearedEdges() []string {
  4705. edges := make([]string, 0, 1)
  4706. if m.clearedlabel_relationships {
  4707. edges = append(edges, label.EdgeLabelRelationships)
  4708. }
  4709. return edges
  4710. }
  4711. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4712. // was cleared in this mutation.
  4713. func (m *LabelMutation) EdgeCleared(name string) bool {
  4714. switch name {
  4715. case label.EdgeLabelRelationships:
  4716. return m.clearedlabel_relationships
  4717. }
  4718. return false
  4719. }
  4720. // ClearEdge clears the value of the edge with the given name. It returns an error
  4721. // if that edge is not defined in the schema.
  4722. func (m *LabelMutation) ClearEdge(name string) error {
  4723. switch name {
  4724. }
  4725. return fmt.Errorf("unknown Label unique edge %s", name)
  4726. }
  4727. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4728. // It returns an error if the edge is not defined in the schema.
  4729. func (m *LabelMutation) ResetEdge(name string) error {
  4730. switch name {
  4731. case label.EdgeLabelRelationships:
  4732. m.ResetLabelRelationships()
  4733. return nil
  4734. }
  4735. return fmt.Errorf("unknown Label edge %s", name)
  4736. }
  4737. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  4738. type LabelRelationshipMutation struct {
  4739. config
  4740. op Op
  4741. typ string
  4742. id *uint64
  4743. created_at *time.Time
  4744. updated_at *time.Time
  4745. status *uint8
  4746. addstatus *int8
  4747. deleted_at *time.Time
  4748. organization_id *uint64
  4749. addorganization_id *int64
  4750. clearedFields map[string]struct{}
  4751. contacts *uint64
  4752. clearedcontacts bool
  4753. labels *uint64
  4754. clearedlabels bool
  4755. done bool
  4756. oldValue func(context.Context) (*LabelRelationship, error)
  4757. predicates []predicate.LabelRelationship
  4758. }
  4759. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  4760. // labelrelationshipOption allows management of the mutation configuration using functional options.
  4761. type labelrelationshipOption func(*LabelRelationshipMutation)
  4762. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  4763. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  4764. m := &LabelRelationshipMutation{
  4765. config: c,
  4766. op: op,
  4767. typ: TypeLabelRelationship,
  4768. clearedFields: make(map[string]struct{}),
  4769. }
  4770. for _, opt := range opts {
  4771. opt(m)
  4772. }
  4773. return m
  4774. }
  4775. // withLabelRelationshipID sets the ID field of the mutation.
  4776. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  4777. return func(m *LabelRelationshipMutation) {
  4778. var (
  4779. err error
  4780. once sync.Once
  4781. value *LabelRelationship
  4782. )
  4783. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  4784. once.Do(func() {
  4785. if m.done {
  4786. err = errors.New("querying old values post mutation is not allowed")
  4787. } else {
  4788. value, err = m.Client().LabelRelationship.Get(ctx, id)
  4789. }
  4790. })
  4791. return value, err
  4792. }
  4793. m.id = &id
  4794. }
  4795. }
  4796. // withLabelRelationship sets the old LabelRelationship of the mutation.
  4797. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  4798. return func(m *LabelRelationshipMutation) {
  4799. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  4800. return node, nil
  4801. }
  4802. m.id = &node.ID
  4803. }
  4804. }
  4805. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4806. // executed in a transaction (ent.Tx), a transactional client is returned.
  4807. func (m LabelRelationshipMutation) Client() *Client {
  4808. client := &Client{config: m.config}
  4809. client.init()
  4810. return client
  4811. }
  4812. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4813. // it returns an error otherwise.
  4814. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  4815. if _, ok := m.driver.(*txDriver); !ok {
  4816. return nil, errors.New("ent: mutation is not running in a transaction")
  4817. }
  4818. tx := &Tx{config: m.config}
  4819. tx.init()
  4820. return tx, nil
  4821. }
  4822. // SetID sets the value of the id field. Note that this
  4823. // operation is only accepted on creation of LabelRelationship entities.
  4824. func (m *LabelRelationshipMutation) SetID(id uint64) {
  4825. m.id = &id
  4826. }
  4827. // ID returns the ID value in the mutation. Note that the ID is only available
  4828. // if it was provided to the builder or after it was returned from the database.
  4829. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  4830. if m.id == nil {
  4831. return
  4832. }
  4833. return *m.id, true
  4834. }
  4835. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4836. // That means, if the mutation is applied within a transaction with an isolation level such
  4837. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4838. // or updated by the mutation.
  4839. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  4840. switch {
  4841. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4842. id, exists := m.ID()
  4843. if exists {
  4844. return []uint64{id}, nil
  4845. }
  4846. fallthrough
  4847. case m.op.Is(OpUpdate | OpDelete):
  4848. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  4849. default:
  4850. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4851. }
  4852. }
  4853. // SetCreatedAt sets the "created_at" field.
  4854. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  4855. m.created_at = &t
  4856. }
  4857. // CreatedAt returns the value of the "created_at" field in the mutation.
  4858. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  4859. v := m.created_at
  4860. if v == nil {
  4861. return
  4862. }
  4863. return *v, true
  4864. }
  4865. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  4866. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  4867. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4868. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4869. if !m.op.Is(OpUpdateOne) {
  4870. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4871. }
  4872. if m.id == nil || m.oldValue == nil {
  4873. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4874. }
  4875. oldValue, err := m.oldValue(ctx)
  4876. if err != nil {
  4877. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4878. }
  4879. return oldValue.CreatedAt, nil
  4880. }
  4881. // ResetCreatedAt resets all changes to the "created_at" field.
  4882. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  4883. m.created_at = nil
  4884. }
  4885. // SetUpdatedAt sets the "updated_at" field.
  4886. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  4887. m.updated_at = &t
  4888. }
  4889. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4890. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  4891. v := m.updated_at
  4892. if v == nil {
  4893. return
  4894. }
  4895. return *v, true
  4896. }
  4897. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  4898. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  4899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4900. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4901. if !m.op.Is(OpUpdateOne) {
  4902. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4903. }
  4904. if m.id == nil || m.oldValue == nil {
  4905. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4906. }
  4907. oldValue, err := m.oldValue(ctx)
  4908. if err != nil {
  4909. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4910. }
  4911. return oldValue.UpdatedAt, nil
  4912. }
  4913. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4914. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  4915. m.updated_at = nil
  4916. }
  4917. // SetStatus sets the "status" field.
  4918. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  4919. m.status = &u
  4920. m.addstatus = nil
  4921. }
  4922. // Status returns the value of the "status" field in the mutation.
  4923. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  4924. v := m.status
  4925. if v == nil {
  4926. return
  4927. }
  4928. return *v, true
  4929. }
  4930. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  4931. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  4932. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4933. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  4934. if !m.op.Is(OpUpdateOne) {
  4935. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  4936. }
  4937. if m.id == nil || m.oldValue == nil {
  4938. return v, errors.New("OldStatus requires an ID field in the mutation")
  4939. }
  4940. oldValue, err := m.oldValue(ctx)
  4941. if err != nil {
  4942. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  4943. }
  4944. return oldValue.Status, nil
  4945. }
  4946. // AddStatus adds u to the "status" field.
  4947. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  4948. if m.addstatus != nil {
  4949. *m.addstatus += u
  4950. } else {
  4951. m.addstatus = &u
  4952. }
  4953. }
  4954. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4955. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  4956. v := m.addstatus
  4957. if v == nil {
  4958. return
  4959. }
  4960. return *v, true
  4961. }
  4962. // ClearStatus clears the value of the "status" field.
  4963. func (m *LabelRelationshipMutation) ClearStatus() {
  4964. m.status = nil
  4965. m.addstatus = nil
  4966. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  4967. }
  4968. // StatusCleared returns if the "status" field was cleared in this mutation.
  4969. func (m *LabelRelationshipMutation) StatusCleared() bool {
  4970. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  4971. return ok
  4972. }
  4973. // ResetStatus resets all changes to the "status" field.
  4974. func (m *LabelRelationshipMutation) ResetStatus() {
  4975. m.status = nil
  4976. m.addstatus = nil
  4977. delete(m.clearedFields, labelrelationship.FieldStatus)
  4978. }
  4979. // SetDeletedAt sets the "deleted_at" field.
  4980. func (m *LabelRelationshipMutation) SetDeletedAt(t time.Time) {
  4981. m.deleted_at = &t
  4982. }
  4983. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4984. func (m *LabelRelationshipMutation) DeletedAt() (r time.Time, exists bool) {
  4985. v := m.deleted_at
  4986. if v == nil {
  4987. return
  4988. }
  4989. return *v, true
  4990. }
  4991. // OldDeletedAt returns the old "deleted_at" field's value of the LabelRelationship entity.
  4992. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  4993. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4994. func (m *LabelRelationshipMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4995. if !m.op.Is(OpUpdateOne) {
  4996. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4997. }
  4998. if m.id == nil || m.oldValue == nil {
  4999. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5000. }
  5001. oldValue, err := m.oldValue(ctx)
  5002. if err != nil {
  5003. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5004. }
  5005. return oldValue.DeletedAt, nil
  5006. }
  5007. // ClearDeletedAt clears the value of the "deleted_at" field.
  5008. func (m *LabelRelationshipMutation) ClearDeletedAt() {
  5009. m.deleted_at = nil
  5010. m.clearedFields[labelrelationship.FieldDeletedAt] = struct{}{}
  5011. }
  5012. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5013. func (m *LabelRelationshipMutation) DeletedAtCleared() bool {
  5014. _, ok := m.clearedFields[labelrelationship.FieldDeletedAt]
  5015. return ok
  5016. }
  5017. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5018. func (m *LabelRelationshipMutation) ResetDeletedAt() {
  5019. m.deleted_at = nil
  5020. delete(m.clearedFields, labelrelationship.FieldDeletedAt)
  5021. }
  5022. // SetLabelID sets the "label_id" field.
  5023. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  5024. m.labels = &u
  5025. }
  5026. // LabelID returns the value of the "label_id" field in the mutation.
  5027. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  5028. v := m.labels
  5029. if v == nil {
  5030. return
  5031. }
  5032. return *v, true
  5033. }
  5034. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  5035. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  5036. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5037. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  5038. if !m.op.Is(OpUpdateOne) {
  5039. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  5040. }
  5041. if m.id == nil || m.oldValue == nil {
  5042. return v, errors.New("OldLabelID requires an ID field in the mutation")
  5043. }
  5044. oldValue, err := m.oldValue(ctx)
  5045. if err != nil {
  5046. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  5047. }
  5048. return oldValue.LabelID, nil
  5049. }
  5050. // ResetLabelID resets all changes to the "label_id" field.
  5051. func (m *LabelRelationshipMutation) ResetLabelID() {
  5052. m.labels = nil
  5053. }
  5054. // SetContactID sets the "contact_id" field.
  5055. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  5056. m.contacts = &u
  5057. }
  5058. // ContactID returns the value of the "contact_id" field in the mutation.
  5059. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  5060. v := m.contacts
  5061. if v == nil {
  5062. return
  5063. }
  5064. return *v, true
  5065. }
  5066. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  5067. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  5068. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5069. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  5070. if !m.op.Is(OpUpdateOne) {
  5071. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  5072. }
  5073. if m.id == nil || m.oldValue == nil {
  5074. return v, errors.New("OldContactID requires an ID field in the mutation")
  5075. }
  5076. oldValue, err := m.oldValue(ctx)
  5077. if err != nil {
  5078. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  5079. }
  5080. return oldValue.ContactID, nil
  5081. }
  5082. // ResetContactID resets all changes to the "contact_id" field.
  5083. func (m *LabelRelationshipMutation) ResetContactID() {
  5084. m.contacts = nil
  5085. }
  5086. // SetOrganizationID sets the "organization_id" field.
  5087. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  5088. m.organization_id = &u
  5089. m.addorganization_id = nil
  5090. }
  5091. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5092. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  5093. v := m.organization_id
  5094. if v == nil {
  5095. return
  5096. }
  5097. return *v, true
  5098. }
  5099. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  5100. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  5101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5102. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5103. if !m.op.Is(OpUpdateOne) {
  5104. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5105. }
  5106. if m.id == nil || m.oldValue == nil {
  5107. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5108. }
  5109. oldValue, err := m.oldValue(ctx)
  5110. if err != nil {
  5111. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  5112. }
  5113. return oldValue.OrganizationID, nil
  5114. }
  5115. // AddOrganizationID adds u to the "organization_id" field.
  5116. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  5117. if m.addorganization_id != nil {
  5118. *m.addorganization_id += u
  5119. } else {
  5120. m.addorganization_id = &u
  5121. }
  5122. }
  5123. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5124. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  5125. v := m.addorganization_id
  5126. if v == nil {
  5127. return
  5128. }
  5129. return *v, true
  5130. }
  5131. // ClearOrganizationID clears the value of the "organization_id" field.
  5132. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  5133. m.organization_id = nil
  5134. m.addorganization_id = nil
  5135. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  5136. }
  5137. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  5138. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  5139. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  5140. return ok
  5141. }
  5142. // ResetOrganizationID resets all changes to the "organization_id" field.
  5143. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  5144. m.organization_id = nil
  5145. m.addorganization_id = nil
  5146. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  5147. }
  5148. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  5149. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  5150. m.contacts = &id
  5151. }
  5152. // ClearContacts clears the "contacts" edge to the Contact entity.
  5153. func (m *LabelRelationshipMutation) ClearContacts() {
  5154. m.clearedcontacts = true
  5155. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  5156. }
  5157. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  5158. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  5159. return m.clearedcontacts
  5160. }
  5161. // ContactsID returns the "contacts" edge ID in the mutation.
  5162. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  5163. if m.contacts != nil {
  5164. return *m.contacts, true
  5165. }
  5166. return
  5167. }
  5168. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  5169. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  5170. // ContactsID instead. It exists only for internal usage by the builders.
  5171. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  5172. if id := m.contacts; id != nil {
  5173. ids = append(ids, *id)
  5174. }
  5175. return
  5176. }
  5177. // ResetContacts resets all changes to the "contacts" edge.
  5178. func (m *LabelRelationshipMutation) ResetContacts() {
  5179. m.contacts = nil
  5180. m.clearedcontacts = false
  5181. }
  5182. // SetLabelsID sets the "labels" edge to the Label entity by id.
  5183. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  5184. m.labels = &id
  5185. }
  5186. // ClearLabels clears the "labels" edge to the Label entity.
  5187. func (m *LabelRelationshipMutation) ClearLabels() {
  5188. m.clearedlabels = true
  5189. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  5190. }
  5191. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  5192. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  5193. return m.clearedlabels
  5194. }
  5195. // LabelsID returns the "labels" edge ID in the mutation.
  5196. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  5197. if m.labels != nil {
  5198. return *m.labels, true
  5199. }
  5200. return
  5201. }
  5202. // LabelsIDs returns the "labels" edge IDs in the mutation.
  5203. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  5204. // LabelsID instead. It exists only for internal usage by the builders.
  5205. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  5206. if id := m.labels; id != nil {
  5207. ids = append(ids, *id)
  5208. }
  5209. return
  5210. }
  5211. // ResetLabels resets all changes to the "labels" edge.
  5212. func (m *LabelRelationshipMutation) ResetLabels() {
  5213. m.labels = nil
  5214. m.clearedlabels = false
  5215. }
  5216. // Where appends a list predicates to the LabelRelationshipMutation builder.
  5217. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  5218. m.predicates = append(m.predicates, ps...)
  5219. }
  5220. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  5221. // users can use type-assertion to append predicates that do not depend on any generated package.
  5222. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  5223. p := make([]predicate.LabelRelationship, len(ps))
  5224. for i := range ps {
  5225. p[i] = ps[i]
  5226. }
  5227. m.Where(p...)
  5228. }
  5229. // Op returns the operation name.
  5230. func (m *LabelRelationshipMutation) Op() Op {
  5231. return m.op
  5232. }
  5233. // SetOp allows setting the mutation operation.
  5234. func (m *LabelRelationshipMutation) SetOp(op Op) {
  5235. m.op = op
  5236. }
  5237. // Type returns the node type of this mutation (LabelRelationship).
  5238. func (m *LabelRelationshipMutation) Type() string {
  5239. return m.typ
  5240. }
  5241. // Fields returns all fields that were changed during this mutation. Note that in
  5242. // order to get all numeric fields that were incremented/decremented, call
  5243. // AddedFields().
  5244. func (m *LabelRelationshipMutation) Fields() []string {
  5245. fields := make([]string, 0, 7)
  5246. if m.created_at != nil {
  5247. fields = append(fields, labelrelationship.FieldCreatedAt)
  5248. }
  5249. if m.updated_at != nil {
  5250. fields = append(fields, labelrelationship.FieldUpdatedAt)
  5251. }
  5252. if m.status != nil {
  5253. fields = append(fields, labelrelationship.FieldStatus)
  5254. }
  5255. if m.deleted_at != nil {
  5256. fields = append(fields, labelrelationship.FieldDeletedAt)
  5257. }
  5258. if m.labels != nil {
  5259. fields = append(fields, labelrelationship.FieldLabelID)
  5260. }
  5261. if m.contacts != nil {
  5262. fields = append(fields, labelrelationship.FieldContactID)
  5263. }
  5264. if m.organization_id != nil {
  5265. fields = append(fields, labelrelationship.FieldOrganizationID)
  5266. }
  5267. return fields
  5268. }
  5269. // Field returns the value of a field with the given name. The second boolean
  5270. // return value indicates that this field was not set, or was not defined in the
  5271. // schema.
  5272. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  5273. switch name {
  5274. case labelrelationship.FieldCreatedAt:
  5275. return m.CreatedAt()
  5276. case labelrelationship.FieldUpdatedAt:
  5277. return m.UpdatedAt()
  5278. case labelrelationship.FieldStatus:
  5279. return m.Status()
  5280. case labelrelationship.FieldDeletedAt:
  5281. return m.DeletedAt()
  5282. case labelrelationship.FieldLabelID:
  5283. return m.LabelID()
  5284. case labelrelationship.FieldContactID:
  5285. return m.ContactID()
  5286. case labelrelationship.FieldOrganizationID:
  5287. return m.OrganizationID()
  5288. }
  5289. return nil, false
  5290. }
  5291. // OldField returns the old value of the field from the database. An error is
  5292. // returned if the mutation operation is not UpdateOne, or the query to the
  5293. // database failed.
  5294. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5295. switch name {
  5296. case labelrelationship.FieldCreatedAt:
  5297. return m.OldCreatedAt(ctx)
  5298. case labelrelationship.FieldUpdatedAt:
  5299. return m.OldUpdatedAt(ctx)
  5300. case labelrelationship.FieldStatus:
  5301. return m.OldStatus(ctx)
  5302. case labelrelationship.FieldDeletedAt:
  5303. return m.OldDeletedAt(ctx)
  5304. case labelrelationship.FieldLabelID:
  5305. return m.OldLabelID(ctx)
  5306. case labelrelationship.FieldContactID:
  5307. return m.OldContactID(ctx)
  5308. case labelrelationship.FieldOrganizationID:
  5309. return m.OldOrganizationID(ctx)
  5310. }
  5311. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  5312. }
  5313. // SetField sets the value of a field with the given name. It returns an error if
  5314. // the field is not defined in the schema, or if the type mismatched the field
  5315. // type.
  5316. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  5317. switch name {
  5318. case labelrelationship.FieldCreatedAt:
  5319. v, ok := value.(time.Time)
  5320. if !ok {
  5321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5322. }
  5323. m.SetCreatedAt(v)
  5324. return nil
  5325. case labelrelationship.FieldUpdatedAt:
  5326. v, ok := value.(time.Time)
  5327. if !ok {
  5328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5329. }
  5330. m.SetUpdatedAt(v)
  5331. return nil
  5332. case labelrelationship.FieldStatus:
  5333. v, ok := value.(uint8)
  5334. if !ok {
  5335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5336. }
  5337. m.SetStatus(v)
  5338. return nil
  5339. case labelrelationship.FieldDeletedAt:
  5340. v, ok := value.(time.Time)
  5341. if !ok {
  5342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5343. }
  5344. m.SetDeletedAt(v)
  5345. return nil
  5346. case labelrelationship.FieldLabelID:
  5347. v, ok := value.(uint64)
  5348. if !ok {
  5349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5350. }
  5351. m.SetLabelID(v)
  5352. return nil
  5353. case labelrelationship.FieldContactID:
  5354. v, ok := value.(uint64)
  5355. if !ok {
  5356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5357. }
  5358. m.SetContactID(v)
  5359. return nil
  5360. case labelrelationship.FieldOrganizationID:
  5361. v, ok := value.(uint64)
  5362. if !ok {
  5363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5364. }
  5365. m.SetOrganizationID(v)
  5366. return nil
  5367. }
  5368. return fmt.Errorf("unknown LabelRelationship field %s", name)
  5369. }
  5370. // AddedFields returns all numeric fields that were incremented/decremented during
  5371. // this mutation.
  5372. func (m *LabelRelationshipMutation) AddedFields() []string {
  5373. var fields []string
  5374. if m.addstatus != nil {
  5375. fields = append(fields, labelrelationship.FieldStatus)
  5376. }
  5377. if m.addorganization_id != nil {
  5378. fields = append(fields, labelrelationship.FieldOrganizationID)
  5379. }
  5380. return fields
  5381. }
  5382. // AddedField returns the numeric value that was incremented/decremented on a field
  5383. // with the given name. The second boolean return value indicates that this field
  5384. // was not set, or was not defined in the schema.
  5385. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  5386. switch name {
  5387. case labelrelationship.FieldStatus:
  5388. return m.AddedStatus()
  5389. case labelrelationship.FieldOrganizationID:
  5390. return m.AddedOrganizationID()
  5391. }
  5392. return nil, false
  5393. }
  5394. // AddField adds the value to the field with the given name. It returns an error if
  5395. // the field is not defined in the schema, or if the type mismatched the field
  5396. // type.
  5397. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  5398. switch name {
  5399. case labelrelationship.FieldStatus:
  5400. v, ok := value.(int8)
  5401. if !ok {
  5402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5403. }
  5404. m.AddStatus(v)
  5405. return nil
  5406. case labelrelationship.FieldOrganizationID:
  5407. v, ok := value.(int64)
  5408. if !ok {
  5409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5410. }
  5411. m.AddOrganizationID(v)
  5412. return nil
  5413. }
  5414. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  5415. }
  5416. // ClearedFields returns all nullable fields that were cleared during this
  5417. // mutation.
  5418. func (m *LabelRelationshipMutation) ClearedFields() []string {
  5419. var fields []string
  5420. if m.FieldCleared(labelrelationship.FieldStatus) {
  5421. fields = append(fields, labelrelationship.FieldStatus)
  5422. }
  5423. if m.FieldCleared(labelrelationship.FieldDeletedAt) {
  5424. fields = append(fields, labelrelationship.FieldDeletedAt)
  5425. }
  5426. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  5427. fields = append(fields, labelrelationship.FieldOrganizationID)
  5428. }
  5429. return fields
  5430. }
  5431. // FieldCleared returns a boolean indicating if a field with the given name was
  5432. // cleared in this mutation.
  5433. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  5434. _, ok := m.clearedFields[name]
  5435. return ok
  5436. }
  5437. // ClearField clears the value of the field with the given name. It returns an
  5438. // error if the field is not defined in the schema.
  5439. func (m *LabelRelationshipMutation) ClearField(name string) error {
  5440. switch name {
  5441. case labelrelationship.FieldStatus:
  5442. m.ClearStatus()
  5443. return nil
  5444. case labelrelationship.FieldDeletedAt:
  5445. m.ClearDeletedAt()
  5446. return nil
  5447. case labelrelationship.FieldOrganizationID:
  5448. m.ClearOrganizationID()
  5449. return nil
  5450. }
  5451. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  5452. }
  5453. // ResetField resets all changes in the mutation for the field with the given name.
  5454. // It returns an error if the field is not defined in the schema.
  5455. func (m *LabelRelationshipMutation) ResetField(name string) error {
  5456. switch name {
  5457. case labelrelationship.FieldCreatedAt:
  5458. m.ResetCreatedAt()
  5459. return nil
  5460. case labelrelationship.FieldUpdatedAt:
  5461. m.ResetUpdatedAt()
  5462. return nil
  5463. case labelrelationship.FieldStatus:
  5464. m.ResetStatus()
  5465. return nil
  5466. case labelrelationship.FieldDeletedAt:
  5467. m.ResetDeletedAt()
  5468. return nil
  5469. case labelrelationship.FieldLabelID:
  5470. m.ResetLabelID()
  5471. return nil
  5472. case labelrelationship.FieldContactID:
  5473. m.ResetContactID()
  5474. return nil
  5475. case labelrelationship.FieldOrganizationID:
  5476. m.ResetOrganizationID()
  5477. return nil
  5478. }
  5479. return fmt.Errorf("unknown LabelRelationship field %s", name)
  5480. }
  5481. // AddedEdges returns all edge names that were set/added in this mutation.
  5482. func (m *LabelRelationshipMutation) AddedEdges() []string {
  5483. edges := make([]string, 0, 2)
  5484. if m.contacts != nil {
  5485. edges = append(edges, labelrelationship.EdgeContacts)
  5486. }
  5487. if m.labels != nil {
  5488. edges = append(edges, labelrelationship.EdgeLabels)
  5489. }
  5490. return edges
  5491. }
  5492. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5493. // name in this mutation.
  5494. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  5495. switch name {
  5496. case labelrelationship.EdgeContacts:
  5497. if id := m.contacts; id != nil {
  5498. return []ent.Value{*id}
  5499. }
  5500. case labelrelationship.EdgeLabels:
  5501. if id := m.labels; id != nil {
  5502. return []ent.Value{*id}
  5503. }
  5504. }
  5505. return nil
  5506. }
  5507. // RemovedEdges returns all edge names that were removed in this mutation.
  5508. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  5509. edges := make([]string, 0, 2)
  5510. return edges
  5511. }
  5512. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5513. // the given name in this mutation.
  5514. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  5515. return nil
  5516. }
  5517. // ClearedEdges returns all edge names that were cleared in this mutation.
  5518. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  5519. edges := make([]string, 0, 2)
  5520. if m.clearedcontacts {
  5521. edges = append(edges, labelrelationship.EdgeContacts)
  5522. }
  5523. if m.clearedlabels {
  5524. edges = append(edges, labelrelationship.EdgeLabels)
  5525. }
  5526. return edges
  5527. }
  5528. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5529. // was cleared in this mutation.
  5530. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  5531. switch name {
  5532. case labelrelationship.EdgeContacts:
  5533. return m.clearedcontacts
  5534. case labelrelationship.EdgeLabels:
  5535. return m.clearedlabels
  5536. }
  5537. return false
  5538. }
  5539. // ClearEdge clears the value of the edge with the given name. It returns an error
  5540. // if that edge is not defined in the schema.
  5541. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  5542. switch name {
  5543. case labelrelationship.EdgeContacts:
  5544. m.ClearContacts()
  5545. return nil
  5546. case labelrelationship.EdgeLabels:
  5547. m.ClearLabels()
  5548. return nil
  5549. }
  5550. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  5551. }
  5552. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5553. // It returns an error if the edge is not defined in the schema.
  5554. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  5555. switch name {
  5556. case labelrelationship.EdgeContacts:
  5557. m.ResetContacts()
  5558. return nil
  5559. case labelrelationship.EdgeLabels:
  5560. m.ResetLabels()
  5561. return nil
  5562. }
  5563. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  5564. }
  5565. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  5566. type MessageMutation struct {
  5567. config
  5568. op Op
  5569. typ string
  5570. id *int
  5571. wx_wxid *string
  5572. wxid *string
  5573. content *string
  5574. clearedFields map[string]struct{}
  5575. done bool
  5576. oldValue func(context.Context) (*Message, error)
  5577. predicates []predicate.Message
  5578. }
  5579. var _ ent.Mutation = (*MessageMutation)(nil)
  5580. // messageOption allows management of the mutation configuration using functional options.
  5581. type messageOption func(*MessageMutation)
  5582. // newMessageMutation creates new mutation for the Message entity.
  5583. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  5584. m := &MessageMutation{
  5585. config: c,
  5586. op: op,
  5587. typ: TypeMessage,
  5588. clearedFields: make(map[string]struct{}),
  5589. }
  5590. for _, opt := range opts {
  5591. opt(m)
  5592. }
  5593. return m
  5594. }
  5595. // withMessageID sets the ID field of the mutation.
  5596. func withMessageID(id int) messageOption {
  5597. return func(m *MessageMutation) {
  5598. var (
  5599. err error
  5600. once sync.Once
  5601. value *Message
  5602. )
  5603. m.oldValue = func(ctx context.Context) (*Message, error) {
  5604. once.Do(func() {
  5605. if m.done {
  5606. err = errors.New("querying old values post mutation is not allowed")
  5607. } else {
  5608. value, err = m.Client().Message.Get(ctx, id)
  5609. }
  5610. })
  5611. return value, err
  5612. }
  5613. m.id = &id
  5614. }
  5615. }
  5616. // withMessage sets the old Message of the mutation.
  5617. func withMessage(node *Message) messageOption {
  5618. return func(m *MessageMutation) {
  5619. m.oldValue = func(context.Context) (*Message, error) {
  5620. return node, nil
  5621. }
  5622. m.id = &node.ID
  5623. }
  5624. }
  5625. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5626. // executed in a transaction (ent.Tx), a transactional client is returned.
  5627. func (m MessageMutation) Client() *Client {
  5628. client := &Client{config: m.config}
  5629. client.init()
  5630. return client
  5631. }
  5632. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5633. // it returns an error otherwise.
  5634. func (m MessageMutation) Tx() (*Tx, error) {
  5635. if _, ok := m.driver.(*txDriver); !ok {
  5636. return nil, errors.New("ent: mutation is not running in a transaction")
  5637. }
  5638. tx := &Tx{config: m.config}
  5639. tx.init()
  5640. return tx, nil
  5641. }
  5642. // ID returns the ID value in the mutation. Note that the ID is only available
  5643. // if it was provided to the builder or after it was returned from the database.
  5644. func (m *MessageMutation) ID() (id int, exists bool) {
  5645. if m.id == nil {
  5646. return
  5647. }
  5648. return *m.id, true
  5649. }
  5650. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5651. // That means, if the mutation is applied within a transaction with an isolation level such
  5652. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5653. // or updated by the mutation.
  5654. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  5655. switch {
  5656. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5657. id, exists := m.ID()
  5658. if exists {
  5659. return []int{id}, nil
  5660. }
  5661. fallthrough
  5662. case m.op.Is(OpUpdate | OpDelete):
  5663. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  5664. default:
  5665. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5666. }
  5667. }
  5668. // SetWxWxid sets the "wx_wxid" field.
  5669. func (m *MessageMutation) SetWxWxid(s string) {
  5670. m.wx_wxid = &s
  5671. }
  5672. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  5673. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  5674. v := m.wx_wxid
  5675. if v == nil {
  5676. return
  5677. }
  5678. return *v, true
  5679. }
  5680. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  5681. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  5682. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5683. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  5684. if !m.op.Is(OpUpdateOne) {
  5685. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  5686. }
  5687. if m.id == nil || m.oldValue == nil {
  5688. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  5689. }
  5690. oldValue, err := m.oldValue(ctx)
  5691. if err != nil {
  5692. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  5693. }
  5694. return oldValue.WxWxid, nil
  5695. }
  5696. // ClearWxWxid clears the value of the "wx_wxid" field.
  5697. func (m *MessageMutation) ClearWxWxid() {
  5698. m.wx_wxid = nil
  5699. m.clearedFields[message.FieldWxWxid] = struct{}{}
  5700. }
  5701. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  5702. func (m *MessageMutation) WxWxidCleared() bool {
  5703. _, ok := m.clearedFields[message.FieldWxWxid]
  5704. return ok
  5705. }
  5706. // ResetWxWxid resets all changes to the "wx_wxid" field.
  5707. func (m *MessageMutation) ResetWxWxid() {
  5708. m.wx_wxid = nil
  5709. delete(m.clearedFields, message.FieldWxWxid)
  5710. }
  5711. // SetWxid sets the "wxid" field.
  5712. func (m *MessageMutation) SetWxid(s string) {
  5713. m.wxid = &s
  5714. }
  5715. // Wxid returns the value of the "wxid" field in the mutation.
  5716. func (m *MessageMutation) Wxid() (r string, exists bool) {
  5717. v := m.wxid
  5718. if v == nil {
  5719. return
  5720. }
  5721. return *v, true
  5722. }
  5723. // OldWxid returns the old "wxid" field's value of the Message entity.
  5724. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  5725. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5726. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  5727. if !m.op.Is(OpUpdateOne) {
  5728. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  5729. }
  5730. if m.id == nil || m.oldValue == nil {
  5731. return v, errors.New("OldWxid requires an ID field in the mutation")
  5732. }
  5733. oldValue, err := m.oldValue(ctx)
  5734. if err != nil {
  5735. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  5736. }
  5737. return oldValue.Wxid, nil
  5738. }
  5739. // ResetWxid resets all changes to the "wxid" field.
  5740. func (m *MessageMutation) ResetWxid() {
  5741. m.wxid = nil
  5742. }
  5743. // SetContent sets the "content" field.
  5744. func (m *MessageMutation) SetContent(s string) {
  5745. m.content = &s
  5746. }
  5747. // Content returns the value of the "content" field in the mutation.
  5748. func (m *MessageMutation) Content() (r string, exists bool) {
  5749. v := m.content
  5750. if v == nil {
  5751. return
  5752. }
  5753. return *v, true
  5754. }
  5755. // OldContent returns the old "content" field's value of the Message entity.
  5756. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  5757. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5758. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  5759. if !m.op.Is(OpUpdateOne) {
  5760. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  5761. }
  5762. if m.id == nil || m.oldValue == nil {
  5763. return v, errors.New("OldContent requires an ID field in the mutation")
  5764. }
  5765. oldValue, err := m.oldValue(ctx)
  5766. if err != nil {
  5767. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  5768. }
  5769. return oldValue.Content, nil
  5770. }
  5771. // ResetContent resets all changes to the "content" field.
  5772. func (m *MessageMutation) ResetContent() {
  5773. m.content = nil
  5774. }
  5775. // Where appends a list predicates to the MessageMutation builder.
  5776. func (m *MessageMutation) Where(ps ...predicate.Message) {
  5777. m.predicates = append(m.predicates, ps...)
  5778. }
  5779. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  5780. // users can use type-assertion to append predicates that do not depend on any generated package.
  5781. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  5782. p := make([]predicate.Message, len(ps))
  5783. for i := range ps {
  5784. p[i] = ps[i]
  5785. }
  5786. m.Where(p...)
  5787. }
  5788. // Op returns the operation name.
  5789. func (m *MessageMutation) Op() Op {
  5790. return m.op
  5791. }
  5792. // SetOp allows setting the mutation operation.
  5793. func (m *MessageMutation) SetOp(op Op) {
  5794. m.op = op
  5795. }
  5796. // Type returns the node type of this mutation (Message).
  5797. func (m *MessageMutation) Type() string {
  5798. return m.typ
  5799. }
  5800. // Fields returns all fields that were changed during this mutation. Note that in
  5801. // order to get all numeric fields that were incremented/decremented, call
  5802. // AddedFields().
  5803. func (m *MessageMutation) Fields() []string {
  5804. fields := make([]string, 0, 3)
  5805. if m.wx_wxid != nil {
  5806. fields = append(fields, message.FieldWxWxid)
  5807. }
  5808. if m.wxid != nil {
  5809. fields = append(fields, message.FieldWxid)
  5810. }
  5811. if m.content != nil {
  5812. fields = append(fields, message.FieldContent)
  5813. }
  5814. return fields
  5815. }
  5816. // Field returns the value of a field with the given name. The second boolean
  5817. // return value indicates that this field was not set, or was not defined in the
  5818. // schema.
  5819. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  5820. switch name {
  5821. case message.FieldWxWxid:
  5822. return m.WxWxid()
  5823. case message.FieldWxid:
  5824. return m.Wxid()
  5825. case message.FieldContent:
  5826. return m.Content()
  5827. }
  5828. return nil, false
  5829. }
  5830. // OldField returns the old value of the field from the database. An error is
  5831. // returned if the mutation operation is not UpdateOne, or the query to the
  5832. // database failed.
  5833. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5834. switch name {
  5835. case message.FieldWxWxid:
  5836. return m.OldWxWxid(ctx)
  5837. case message.FieldWxid:
  5838. return m.OldWxid(ctx)
  5839. case message.FieldContent:
  5840. return m.OldContent(ctx)
  5841. }
  5842. return nil, fmt.Errorf("unknown Message field %s", name)
  5843. }
  5844. // SetField sets the value of a field with the given name. It returns an error if
  5845. // the field is not defined in the schema, or if the type mismatched the field
  5846. // type.
  5847. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  5848. switch name {
  5849. case message.FieldWxWxid:
  5850. v, ok := value.(string)
  5851. if !ok {
  5852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5853. }
  5854. m.SetWxWxid(v)
  5855. return nil
  5856. case message.FieldWxid:
  5857. v, ok := value.(string)
  5858. if !ok {
  5859. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5860. }
  5861. m.SetWxid(v)
  5862. return nil
  5863. case message.FieldContent:
  5864. v, ok := value.(string)
  5865. if !ok {
  5866. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5867. }
  5868. m.SetContent(v)
  5869. return nil
  5870. }
  5871. return fmt.Errorf("unknown Message field %s", name)
  5872. }
  5873. // AddedFields returns all numeric fields that were incremented/decremented during
  5874. // this mutation.
  5875. func (m *MessageMutation) AddedFields() []string {
  5876. return nil
  5877. }
  5878. // AddedField returns the numeric value that was incremented/decremented on a field
  5879. // with the given name. The second boolean return value indicates that this field
  5880. // was not set, or was not defined in the schema.
  5881. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  5882. return nil, false
  5883. }
  5884. // AddField adds the value to the field with the given name. It returns an error if
  5885. // the field is not defined in the schema, or if the type mismatched the field
  5886. // type.
  5887. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  5888. switch name {
  5889. }
  5890. return fmt.Errorf("unknown Message numeric field %s", name)
  5891. }
  5892. // ClearedFields returns all nullable fields that were cleared during this
  5893. // mutation.
  5894. func (m *MessageMutation) ClearedFields() []string {
  5895. var fields []string
  5896. if m.FieldCleared(message.FieldWxWxid) {
  5897. fields = append(fields, message.FieldWxWxid)
  5898. }
  5899. return fields
  5900. }
  5901. // FieldCleared returns a boolean indicating if a field with the given name was
  5902. // cleared in this mutation.
  5903. func (m *MessageMutation) FieldCleared(name string) bool {
  5904. _, ok := m.clearedFields[name]
  5905. return ok
  5906. }
  5907. // ClearField clears the value of the field with the given name. It returns an
  5908. // error if the field is not defined in the schema.
  5909. func (m *MessageMutation) ClearField(name string) error {
  5910. switch name {
  5911. case message.FieldWxWxid:
  5912. m.ClearWxWxid()
  5913. return nil
  5914. }
  5915. return fmt.Errorf("unknown Message nullable field %s", name)
  5916. }
  5917. // ResetField resets all changes in the mutation for the field with the given name.
  5918. // It returns an error if the field is not defined in the schema.
  5919. func (m *MessageMutation) ResetField(name string) error {
  5920. switch name {
  5921. case message.FieldWxWxid:
  5922. m.ResetWxWxid()
  5923. return nil
  5924. case message.FieldWxid:
  5925. m.ResetWxid()
  5926. return nil
  5927. case message.FieldContent:
  5928. m.ResetContent()
  5929. return nil
  5930. }
  5931. return fmt.Errorf("unknown Message field %s", name)
  5932. }
  5933. // AddedEdges returns all edge names that were set/added in this mutation.
  5934. func (m *MessageMutation) AddedEdges() []string {
  5935. edges := make([]string, 0, 0)
  5936. return edges
  5937. }
  5938. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5939. // name in this mutation.
  5940. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  5941. return nil
  5942. }
  5943. // RemovedEdges returns all edge names that were removed in this mutation.
  5944. func (m *MessageMutation) RemovedEdges() []string {
  5945. edges := make([]string, 0, 0)
  5946. return edges
  5947. }
  5948. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5949. // the given name in this mutation.
  5950. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  5951. return nil
  5952. }
  5953. // ClearedEdges returns all edge names that were cleared in this mutation.
  5954. func (m *MessageMutation) ClearedEdges() []string {
  5955. edges := make([]string, 0, 0)
  5956. return edges
  5957. }
  5958. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5959. // was cleared in this mutation.
  5960. func (m *MessageMutation) EdgeCleared(name string) bool {
  5961. return false
  5962. }
  5963. // ClearEdge clears the value of the edge with the given name. It returns an error
  5964. // if that edge is not defined in the schema.
  5965. func (m *MessageMutation) ClearEdge(name string) error {
  5966. return fmt.Errorf("unknown Message unique edge %s", name)
  5967. }
  5968. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5969. // It returns an error if the edge is not defined in the schema.
  5970. func (m *MessageMutation) ResetEdge(name string) error {
  5971. return fmt.Errorf("unknown Message edge %s", name)
  5972. }
  5973. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  5974. type MessageRecordsMutation struct {
  5975. config
  5976. op Op
  5977. typ string
  5978. id *uint64
  5979. created_at *time.Time
  5980. updated_at *time.Time
  5981. status *uint8
  5982. addstatus *int8
  5983. deleted_at *time.Time
  5984. bot_wxid *string
  5985. contact_type *int
  5986. addcontact_type *int
  5987. contact_wxid *string
  5988. content_type *int
  5989. addcontent_type *int
  5990. content *string
  5991. meta *custom_types.Meta
  5992. error_detail *string
  5993. send_time *time.Time
  5994. source_type *int
  5995. addsource_type *int
  5996. organization_id *uint64
  5997. addorganization_id *int64
  5998. clearedFields map[string]struct{}
  5999. sop_stage *uint64
  6000. clearedsop_stage bool
  6001. sop_node *uint64
  6002. clearedsop_node bool
  6003. message_contact *uint64
  6004. clearedmessage_contact bool
  6005. done bool
  6006. oldValue func(context.Context) (*MessageRecords, error)
  6007. predicates []predicate.MessageRecords
  6008. }
  6009. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  6010. // messagerecordsOption allows management of the mutation configuration using functional options.
  6011. type messagerecordsOption func(*MessageRecordsMutation)
  6012. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  6013. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  6014. m := &MessageRecordsMutation{
  6015. config: c,
  6016. op: op,
  6017. typ: TypeMessageRecords,
  6018. clearedFields: make(map[string]struct{}),
  6019. }
  6020. for _, opt := range opts {
  6021. opt(m)
  6022. }
  6023. return m
  6024. }
  6025. // withMessageRecordsID sets the ID field of the mutation.
  6026. func withMessageRecordsID(id uint64) messagerecordsOption {
  6027. return func(m *MessageRecordsMutation) {
  6028. var (
  6029. err error
  6030. once sync.Once
  6031. value *MessageRecords
  6032. )
  6033. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  6034. once.Do(func() {
  6035. if m.done {
  6036. err = errors.New("querying old values post mutation is not allowed")
  6037. } else {
  6038. value, err = m.Client().MessageRecords.Get(ctx, id)
  6039. }
  6040. })
  6041. return value, err
  6042. }
  6043. m.id = &id
  6044. }
  6045. }
  6046. // withMessageRecords sets the old MessageRecords of the mutation.
  6047. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  6048. return func(m *MessageRecordsMutation) {
  6049. m.oldValue = func(context.Context) (*MessageRecords, error) {
  6050. return node, nil
  6051. }
  6052. m.id = &node.ID
  6053. }
  6054. }
  6055. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6056. // executed in a transaction (ent.Tx), a transactional client is returned.
  6057. func (m MessageRecordsMutation) Client() *Client {
  6058. client := &Client{config: m.config}
  6059. client.init()
  6060. return client
  6061. }
  6062. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6063. // it returns an error otherwise.
  6064. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  6065. if _, ok := m.driver.(*txDriver); !ok {
  6066. return nil, errors.New("ent: mutation is not running in a transaction")
  6067. }
  6068. tx := &Tx{config: m.config}
  6069. tx.init()
  6070. return tx, nil
  6071. }
  6072. // SetID sets the value of the id field. Note that this
  6073. // operation is only accepted on creation of MessageRecords entities.
  6074. func (m *MessageRecordsMutation) SetID(id uint64) {
  6075. m.id = &id
  6076. }
  6077. // ID returns the ID value in the mutation. Note that the ID is only available
  6078. // if it was provided to the builder or after it was returned from the database.
  6079. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  6080. if m.id == nil {
  6081. return
  6082. }
  6083. return *m.id, true
  6084. }
  6085. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6086. // That means, if the mutation is applied within a transaction with an isolation level such
  6087. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6088. // or updated by the mutation.
  6089. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  6090. switch {
  6091. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6092. id, exists := m.ID()
  6093. if exists {
  6094. return []uint64{id}, nil
  6095. }
  6096. fallthrough
  6097. case m.op.Is(OpUpdate | OpDelete):
  6098. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  6099. default:
  6100. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6101. }
  6102. }
  6103. // SetCreatedAt sets the "created_at" field.
  6104. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  6105. m.created_at = &t
  6106. }
  6107. // CreatedAt returns the value of the "created_at" field in the mutation.
  6108. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  6109. v := m.created_at
  6110. if v == nil {
  6111. return
  6112. }
  6113. return *v, true
  6114. }
  6115. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  6116. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6117. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6118. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6119. if !m.op.Is(OpUpdateOne) {
  6120. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6121. }
  6122. if m.id == nil || m.oldValue == nil {
  6123. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6124. }
  6125. oldValue, err := m.oldValue(ctx)
  6126. if err != nil {
  6127. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6128. }
  6129. return oldValue.CreatedAt, nil
  6130. }
  6131. // ResetCreatedAt resets all changes to the "created_at" field.
  6132. func (m *MessageRecordsMutation) ResetCreatedAt() {
  6133. m.created_at = nil
  6134. }
  6135. // SetUpdatedAt sets the "updated_at" field.
  6136. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  6137. m.updated_at = &t
  6138. }
  6139. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6140. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  6141. v := m.updated_at
  6142. if v == nil {
  6143. return
  6144. }
  6145. return *v, true
  6146. }
  6147. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  6148. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6149. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6150. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6151. if !m.op.Is(OpUpdateOne) {
  6152. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6153. }
  6154. if m.id == nil || m.oldValue == nil {
  6155. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6156. }
  6157. oldValue, err := m.oldValue(ctx)
  6158. if err != nil {
  6159. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6160. }
  6161. return oldValue.UpdatedAt, nil
  6162. }
  6163. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6164. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  6165. m.updated_at = nil
  6166. }
  6167. // SetStatus sets the "status" field.
  6168. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  6169. m.status = &u
  6170. m.addstatus = nil
  6171. }
  6172. // Status returns the value of the "status" field in the mutation.
  6173. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  6174. v := m.status
  6175. if v == nil {
  6176. return
  6177. }
  6178. return *v, true
  6179. }
  6180. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  6181. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6182. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6183. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  6184. if !m.op.Is(OpUpdateOne) {
  6185. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  6186. }
  6187. if m.id == nil || m.oldValue == nil {
  6188. return v, errors.New("OldStatus requires an ID field in the mutation")
  6189. }
  6190. oldValue, err := m.oldValue(ctx)
  6191. if err != nil {
  6192. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  6193. }
  6194. return oldValue.Status, nil
  6195. }
  6196. // AddStatus adds u to the "status" field.
  6197. func (m *MessageRecordsMutation) AddStatus(u int8) {
  6198. if m.addstatus != nil {
  6199. *m.addstatus += u
  6200. } else {
  6201. m.addstatus = &u
  6202. }
  6203. }
  6204. // AddedStatus returns the value that was added to the "status" field in this mutation.
  6205. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  6206. v := m.addstatus
  6207. if v == nil {
  6208. return
  6209. }
  6210. return *v, true
  6211. }
  6212. // ClearStatus clears the value of the "status" field.
  6213. func (m *MessageRecordsMutation) ClearStatus() {
  6214. m.status = nil
  6215. m.addstatus = nil
  6216. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  6217. }
  6218. // StatusCleared returns if the "status" field was cleared in this mutation.
  6219. func (m *MessageRecordsMutation) StatusCleared() bool {
  6220. _, ok := m.clearedFields[messagerecords.FieldStatus]
  6221. return ok
  6222. }
  6223. // ResetStatus resets all changes to the "status" field.
  6224. func (m *MessageRecordsMutation) ResetStatus() {
  6225. m.status = nil
  6226. m.addstatus = nil
  6227. delete(m.clearedFields, messagerecords.FieldStatus)
  6228. }
  6229. // SetDeletedAt sets the "deleted_at" field.
  6230. func (m *MessageRecordsMutation) SetDeletedAt(t time.Time) {
  6231. m.deleted_at = &t
  6232. }
  6233. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6234. func (m *MessageRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  6235. v := m.deleted_at
  6236. if v == nil {
  6237. return
  6238. }
  6239. return *v, true
  6240. }
  6241. // OldDeletedAt returns the old "deleted_at" field's value of the MessageRecords entity.
  6242. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6243. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6244. func (m *MessageRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6245. if !m.op.Is(OpUpdateOne) {
  6246. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6247. }
  6248. if m.id == nil || m.oldValue == nil {
  6249. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6250. }
  6251. oldValue, err := m.oldValue(ctx)
  6252. if err != nil {
  6253. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6254. }
  6255. return oldValue.DeletedAt, nil
  6256. }
  6257. // ClearDeletedAt clears the value of the "deleted_at" field.
  6258. func (m *MessageRecordsMutation) ClearDeletedAt() {
  6259. m.deleted_at = nil
  6260. m.clearedFields[messagerecords.FieldDeletedAt] = struct{}{}
  6261. }
  6262. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6263. func (m *MessageRecordsMutation) DeletedAtCleared() bool {
  6264. _, ok := m.clearedFields[messagerecords.FieldDeletedAt]
  6265. return ok
  6266. }
  6267. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6268. func (m *MessageRecordsMutation) ResetDeletedAt() {
  6269. m.deleted_at = nil
  6270. delete(m.clearedFields, messagerecords.FieldDeletedAt)
  6271. }
  6272. // SetBotWxid sets the "bot_wxid" field.
  6273. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  6274. m.bot_wxid = &s
  6275. }
  6276. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  6277. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  6278. v := m.bot_wxid
  6279. if v == nil {
  6280. return
  6281. }
  6282. return *v, true
  6283. }
  6284. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  6285. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6286. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6287. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  6288. if !m.op.Is(OpUpdateOne) {
  6289. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  6290. }
  6291. if m.id == nil || m.oldValue == nil {
  6292. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  6293. }
  6294. oldValue, err := m.oldValue(ctx)
  6295. if err != nil {
  6296. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  6297. }
  6298. return oldValue.BotWxid, nil
  6299. }
  6300. // ResetBotWxid resets all changes to the "bot_wxid" field.
  6301. func (m *MessageRecordsMutation) ResetBotWxid() {
  6302. m.bot_wxid = nil
  6303. }
  6304. // SetContactID sets the "contact_id" field.
  6305. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  6306. m.message_contact = &u
  6307. }
  6308. // ContactID returns the value of the "contact_id" field in the mutation.
  6309. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  6310. v := m.message_contact
  6311. if v == nil {
  6312. return
  6313. }
  6314. return *v, true
  6315. }
  6316. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  6317. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6319. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  6320. if !m.op.Is(OpUpdateOne) {
  6321. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  6322. }
  6323. if m.id == nil || m.oldValue == nil {
  6324. return v, errors.New("OldContactID requires an ID field in the mutation")
  6325. }
  6326. oldValue, err := m.oldValue(ctx)
  6327. if err != nil {
  6328. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  6329. }
  6330. return oldValue.ContactID, nil
  6331. }
  6332. // ClearContactID clears the value of the "contact_id" field.
  6333. func (m *MessageRecordsMutation) ClearContactID() {
  6334. m.message_contact = nil
  6335. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  6336. }
  6337. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  6338. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  6339. _, ok := m.clearedFields[messagerecords.FieldContactID]
  6340. return ok
  6341. }
  6342. // ResetContactID resets all changes to the "contact_id" field.
  6343. func (m *MessageRecordsMutation) ResetContactID() {
  6344. m.message_contact = nil
  6345. delete(m.clearedFields, messagerecords.FieldContactID)
  6346. }
  6347. // SetContactType sets the "contact_type" field.
  6348. func (m *MessageRecordsMutation) SetContactType(i int) {
  6349. m.contact_type = &i
  6350. m.addcontact_type = nil
  6351. }
  6352. // ContactType returns the value of the "contact_type" field in the mutation.
  6353. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  6354. v := m.contact_type
  6355. if v == nil {
  6356. return
  6357. }
  6358. return *v, true
  6359. }
  6360. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  6361. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6363. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  6364. if !m.op.Is(OpUpdateOne) {
  6365. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  6366. }
  6367. if m.id == nil || m.oldValue == nil {
  6368. return v, errors.New("OldContactType requires an ID field in the mutation")
  6369. }
  6370. oldValue, err := m.oldValue(ctx)
  6371. if err != nil {
  6372. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  6373. }
  6374. return oldValue.ContactType, nil
  6375. }
  6376. // AddContactType adds i to the "contact_type" field.
  6377. func (m *MessageRecordsMutation) AddContactType(i int) {
  6378. if m.addcontact_type != nil {
  6379. *m.addcontact_type += i
  6380. } else {
  6381. m.addcontact_type = &i
  6382. }
  6383. }
  6384. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  6385. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  6386. v := m.addcontact_type
  6387. if v == nil {
  6388. return
  6389. }
  6390. return *v, true
  6391. }
  6392. // ResetContactType resets all changes to the "contact_type" field.
  6393. func (m *MessageRecordsMutation) ResetContactType() {
  6394. m.contact_type = nil
  6395. m.addcontact_type = nil
  6396. }
  6397. // SetContactWxid sets the "contact_wxid" field.
  6398. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  6399. m.contact_wxid = &s
  6400. }
  6401. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  6402. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  6403. v := m.contact_wxid
  6404. if v == nil {
  6405. return
  6406. }
  6407. return *v, true
  6408. }
  6409. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  6410. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6411. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6412. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  6413. if !m.op.Is(OpUpdateOne) {
  6414. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  6415. }
  6416. if m.id == nil || m.oldValue == nil {
  6417. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  6418. }
  6419. oldValue, err := m.oldValue(ctx)
  6420. if err != nil {
  6421. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  6422. }
  6423. return oldValue.ContactWxid, nil
  6424. }
  6425. // ResetContactWxid resets all changes to the "contact_wxid" field.
  6426. func (m *MessageRecordsMutation) ResetContactWxid() {
  6427. m.contact_wxid = nil
  6428. }
  6429. // SetContentType sets the "content_type" field.
  6430. func (m *MessageRecordsMutation) SetContentType(i int) {
  6431. m.content_type = &i
  6432. m.addcontent_type = nil
  6433. }
  6434. // ContentType returns the value of the "content_type" field in the mutation.
  6435. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  6436. v := m.content_type
  6437. if v == nil {
  6438. return
  6439. }
  6440. return *v, true
  6441. }
  6442. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  6443. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6445. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  6446. if !m.op.Is(OpUpdateOne) {
  6447. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  6448. }
  6449. if m.id == nil || m.oldValue == nil {
  6450. return v, errors.New("OldContentType requires an ID field in the mutation")
  6451. }
  6452. oldValue, err := m.oldValue(ctx)
  6453. if err != nil {
  6454. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  6455. }
  6456. return oldValue.ContentType, nil
  6457. }
  6458. // AddContentType adds i to the "content_type" field.
  6459. func (m *MessageRecordsMutation) AddContentType(i int) {
  6460. if m.addcontent_type != nil {
  6461. *m.addcontent_type += i
  6462. } else {
  6463. m.addcontent_type = &i
  6464. }
  6465. }
  6466. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  6467. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  6468. v := m.addcontent_type
  6469. if v == nil {
  6470. return
  6471. }
  6472. return *v, true
  6473. }
  6474. // ResetContentType resets all changes to the "content_type" field.
  6475. func (m *MessageRecordsMutation) ResetContentType() {
  6476. m.content_type = nil
  6477. m.addcontent_type = nil
  6478. }
  6479. // SetContent sets the "content" field.
  6480. func (m *MessageRecordsMutation) SetContent(s string) {
  6481. m.content = &s
  6482. }
  6483. // Content returns the value of the "content" field in the mutation.
  6484. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  6485. v := m.content
  6486. if v == nil {
  6487. return
  6488. }
  6489. return *v, true
  6490. }
  6491. // OldContent returns the old "content" field's value of the MessageRecords entity.
  6492. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6494. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  6495. if !m.op.Is(OpUpdateOne) {
  6496. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  6497. }
  6498. if m.id == nil || m.oldValue == nil {
  6499. return v, errors.New("OldContent requires an ID field in the mutation")
  6500. }
  6501. oldValue, err := m.oldValue(ctx)
  6502. if err != nil {
  6503. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  6504. }
  6505. return oldValue.Content, nil
  6506. }
  6507. // ResetContent resets all changes to the "content" field.
  6508. func (m *MessageRecordsMutation) ResetContent() {
  6509. m.content = nil
  6510. }
  6511. // SetMeta sets the "meta" field.
  6512. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  6513. m.meta = &ct
  6514. }
  6515. // Meta returns the value of the "meta" field in the mutation.
  6516. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  6517. v := m.meta
  6518. if v == nil {
  6519. return
  6520. }
  6521. return *v, true
  6522. }
  6523. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  6524. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6526. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  6527. if !m.op.Is(OpUpdateOne) {
  6528. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  6529. }
  6530. if m.id == nil || m.oldValue == nil {
  6531. return v, errors.New("OldMeta requires an ID field in the mutation")
  6532. }
  6533. oldValue, err := m.oldValue(ctx)
  6534. if err != nil {
  6535. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  6536. }
  6537. return oldValue.Meta, nil
  6538. }
  6539. // ClearMeta clears the value of the "meta" field.
  6540. func (m *MessageRecordsMutation) ClearMeta() {
  6541. m.meta = nil
  6542. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  6543. }
  6544. // MetaCleared returns if the "meta" field was cleared in this mutation.
  6545. func (m *MessageRecordsMutation) MetaCleared() bool {
  6546. _, ok := m.clearedFields[messagerecords.FieldMeta]
  6547. return ok
  6548. }
  6549. // ResetMeta resets all changes to the "meta" field.
  6550. func (m *MessageRecordsMutation) ResetMeta() {
  6551. m.meta = nil
  6552. delete(m.clearedFields, messagerecords.FieldMeta)
  6553. }
  6554. // SetErrorDetail sets the "error_detail" field.
  6555. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  6556. m.error_detail = &s
  6557. }
  6558. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  6559. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  6560. v := m.error_detail
  6561. if v == nil {
  6562. return
  6563. }
  6564. return *v, true
  6565. }
  6566. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  6567. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6568. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6569. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  6570. if !m.op.Is(OpUpdateOne) {
  6571. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  6572. }
  6573. if m.id == nil || m.oldValue == nil {
  6574. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  6575. }
  6576. oldValue, err := m.oldValue(ctx)
  6577. if err != nil {
  6578. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  6579. }
  6580. return oldValue.ErrorDetail, nil
  6581. }
  6582. // ResetErrorDetail resets all changes to the "error_detail" field.
  6583. func (m *MessageRecordsMutation) ResetErrorDetail() {
  6584. m.error_detail = nil
  6585. }
  6586. // SetSendTime sets the "send_time" field.
  6587. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  6588. m.send_time = &t
  6589. }
  6590. // SendTime returns the value of the "send_time" field in the mutation.
  6591. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  6592. v := m.send_time
  6593. if v == nil {
  6594. return
  6595. }
  6596. return *v, true
  6597. }
  6598. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  6599. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6601. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  6602. if !m.op.Is(OpUpdateOne) {
  6603. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  6604. }
  6605. if m.id == nil || m.oldValue == nil {
  6606. return v, errors.New("OldSendTime requires an ID field in the mutation")
  6607. }
  6608. oldValue, err := m.oldValue(ctx)
  6609. if err != nil {
  6610. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  6611. }
  6612. return oldValue.SendTime, nil
  6613. }
  6614. // ClearSendTime clears the value of the "send_time" field.
  6615. func (m *MessageRecordsMutation) ClearSendTime() {
  6616. m.send_time = nil
  6617. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  6618. }
  6619. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  6620. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  6621. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  6622. return ok
  6623. }
  6624. // ResetSendTime resets all changes to the "send_time" field.
  6625. func (m *MessageRecordsMutation) ResetSendTime() {
  6626. m.send_time = nil
  6627. delete(m.clearedFields, messagerecords.FieldSendTime)
  6628. }
  6629. // SetSourceType sets the "source_type" field.
  6630. func (m *MessageRecordsMutation) SetSourceType(i int) {
  6631. m.source_type = &i
  6632. m.addsource_type = nil
  6633. }
  6634. // SourceType returns the value of the "source_type" field in the mutation.
  6635. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  6636. v := m.source_type
  6637. if v == nil {
  6638. return
  6639. }
  6640. return *v, true
  6641. }
  6642. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  6643. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6644. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6645. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  6646. if !m.op.Is(OpUpdateOne) {
  6647. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  6648. }
  6649. if m.id == nil || m.oldValue == nil {
  6650. return v, errors.New("OldSourceType requires an ID field in the mutation")
  6651. }
  6652. oldValue, err := m.oldValue(ctx)
  6653. if err != nil {
  6654. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  6655. }
  6656. return oldValue.SourceType, nil
  6657. }
  6658. // AddSourceType adds i to the "source_type" field.
  6659. func (m *MessageRecordsMutation) AddSourceType(i int) {
  6660. if m.addsource_type != nil {
  6661. *m.addsource_type += i
  6662. } else {
  6663. m.addsource_type = &i
  6664. }
  6665. }
  6666. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  6667. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  6668. v := m.addsource_type
  6669. if v == nil {
  6670. return
  6671. }
  6672. return *v, true
  6673. }
  6674. // ResetSourceType resets all changes to the "source_type" field.
  6675. func (m *MessageRecordsMutation) ResetSourceType() {
  6676. m.source_type = nil
  6677. m.addsource_type = nil
  6678. }
  6679. // SetSourceID sets the "source_id" field.
  6680. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  6681. m.sop_stage = &u
  6682. }
  6683. // SourceID returns the value of the "source_id" field in the mutation.
  6684. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  6685. v := m.sop_stage
  6686. if v == nil {
  6687. return
  6688. }
  6689. return *v, true
  6690. }
  6691. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  6692. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6693. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6694. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  6695. if !m.op.Is(OpUpdateOne) {
  6696. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  6697. }
  6698. if m.id == nil || m.oldValue == nil {
  6699. return v, errors.New("OldSourceID requires an ID field in the mutation")
  6700. }
  6701. oldValue, err := m.oldValue(ctx)
  6702. if err != nil {
  6703. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  6704. }
  6705. return oldValue.SourceID, nil
  6706. }
  6707. // ClearSourceID clears the value of the "source_id" field.
  6708. func (m *MessageRecordsMutation) ClearSourceID() {
  6709. m.sop_stage = nil
  6710. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  6711. }
  6712. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  6713. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  6714. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  6715. return ok
  6716. }
  6717. // ResetSourceID resets all changes to the "source_id" field.
  6718. func (m *MessageRecordsMutation) ResetSourceID() {
  6719. m.sop_stage = nil
  6720. delete(m.clearedFields, messagerecords.FieldSourceID)
  6721. }
  6722. // SetSubSourceID sets the "sub_source_id" field.
  6723. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  6724. m.sop_node = &u
  6725. }
  6726. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  6727. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  6728. v := m.sop_node
  6729. if v == nil {
  6730. return
  6731. }
  6732. return *v, true
  6733. }
  6734. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  6735. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6736. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6737. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  6738. if !m.op.Is(OpUpdateOne) {
  6739. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  6740. }
  6741. if m.id == nil || m.oldValue == nil {
  6742. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  6743. }
  6744. oldValue, err := m.oldValue(ctx)
  6745. if err != nil {
  6746. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  6747. }
  6748. return oldValue.SubSourceID, nil
  6749. }
  6750. // ClearSubSourceID clears the value of the "sub_source_id" field.
  6751. func (m *MessageRecordsMutation) ClearSubSourceID() {
  6752. m.sop_node = nil
  6753. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  6754. }
  6755. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  6756. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  6757. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  6758. return ok
  6759. }
  6760. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  6761. func (m *MessageRecordsMutation) ResetSubSourceID() {
  6762. m.sop_node = nil
  6763. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  6764. }
  6765. // SetOrganizationID sets the "organization_id" field.
  6766. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  6767. m.organization_id = &u
  6768. m.addorganization_id = nil
  6769. }
  6770. // OrganizationID returns the value of the "organization_id" field in the mutation.
  6771. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  6772. v := m.organization_id
  6773. if v == nil {
  6774. return
  6775. }
  6776. return *v, true
  6777. }
  6778. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  6779. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  6780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6781. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  6782. if !m.op.Is(OpUpdateOne) {
  6783. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  6784. }
  6785. if m.id == nil || m.oldValue == nil {
  6786. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6787. }
  6788. oldValue, err := m.oldValue(ctx)
  6789. if err != nil {
  6790. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6791. }
  6792. return oldValue.OrganizationID, nil
  6793. }
  6794. // AddOrganizationID adds u to the "organization_id" field.
  6795. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  6796. if m.addorganization_id != nil {
  6797. *m.addorganization_id += u
  6798. } else {
  6799. m.addorganization_id = &u
  6800. }
  6801. }
  6802. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6803. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  6804. v := m.addorganization_id
  6805. if v == nil {
  6806. return
  6807. }
  6808. return *v, true
  6809. }
  6810. // ClearOrganizationID clears the value of the "organization_id" field.
  6811. func (m *MessageRecordsMutation) ClearOrganizationID() {
  6812. m.organization_id = nil
  6813. m.addorganization_id = nil
  6814. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  6815. }
  6816. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  6817. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  6818. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  6819. return ok
  6820. }
  6821. // ResetOrganizationID resets all changes to the "organization_id" field.
  6822. func (m *MessageRecordsMutation) ResetOrganizationID() {
  6823. m.organization_id = nil
  6824. m.addorganization_id = nil
  6825. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  6826. }
  6827. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  6828. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  6829. m.sop_stage = &id
  6830. }
  6831. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  6832. func (m *MessageRecordsMutation) ClearSopStage() {
  6833. m.clearedsop_stage = true
  6834. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  6835. }
  6836. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  6837. func (m *MessageRecordsMutation) SopStageCleared() bool {
  6838. return m.SourceIDCleared() || m.clearedsop_stage
  6839. }
  6840. // SopStageID returns the "sop_stage" edge ID in the mutation.
  6841. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  6842. if m.sop_stage != nil {
  6843. return *m.sop_stage, true
  6844. }
  6845. return
  6846. }
  6847. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  6848. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  6849. // SopStageID instead. It exists only for internal usage by the builders.
  6850. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  6851. if id := m.sop_stage; id != nil {
  6852. ids = append(ids, *id)
  6853. }
  6854. return
  6855. }
  6856. // ResetSopStage resets all changes to the "sop_stage" edge.
  6857. func (m *MessageRecordsMutation) ResetSopStage() {
  6858. m.sop_stage = nil
  6859. m.clearedsop_stage = false
  6860. }
  6861. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  6862. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  6863. m.sop_node = &id
  6864. }
  6865. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  6866. func (m *MessageRecordsMutation) ClearSopNode() {
  6867. m.clearedsop_node = true
  6868. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  6869. }
  6870. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  6871. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  6872. return m.SubSourceIDCleared() || m.clearedsop_node
  6873. }
  6874. // SopNodeID returns the "sop_node" edge ID in the mutation.
  6875. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  6876. if m.sop_node != nil {
  6877. return *m.sop_node, true
  6878. }
  6879. return
  6880. }
  6881. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  6882. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  6883. // SopNodeID instead. It exists only for internal usage by the builders.
  6884. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  6885. if id := m.sop_node; id != nil {
  6886. ids = append(ids, *id)
  6887. }
  6888. return
  6889. }
  6890. // ResetSopNode resets all changes to the "sop_node" edge.
  6891. func (m *MessageRecordsMutation) ResetSopNode() {
  6892. m.sop_node = nil
  6893. m.clearedsop_node = false
  6894. }
  6895. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  6896. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  6897. m.message_contact = &id
  6898. }
  6899. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  6900. func (m *MessageRecordsMutation) ClearMessageContact() {
  6901. m.clearedmessage_contact = true
  6902. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  6903. }
  6904. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  6905. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  6906. return m.ContactIDCleared() || m.clearedmessage_contact
  6907. }
  6908. // MessageContactID returns the "message_contact" edge ID in the mutation.
  6909. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  6910. if m.message_contact != nil {
  6911. return *m.message_contact, true
  6912. }
  6913. return
  6914. }
  6915. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  6916. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  6917. // MessageContactID instead. It exists only for internal usage by the builders.
  6918. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  6919. if id := m.message_contact; id != nil {
  6920. ids = append(ids, *id)
  6921. }
  6922. return
  6923. }
  6924. // ResetMessageContact resets all changes to the "message_contact" edge.
  6925. func (m *MessageRecordsMutation) ResetMessageContact() {
  6926. m.message_contact = nil
  6927. m.clearedmessage_contact = false
  6928. }
  6929. // Where appends a list predicates to the MessageRecordsMutation builder.
  6930. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  6931. m.predicates = append(m.predicates, ps...)
  6932. }
  6933. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  6934. // users can use type-assertion to append predicates that do not depend on any generated package.
  6935. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  6936. p := make([]predicate.MessageRecords, len(ps))
  6937. for i := range ps {
  6938. p[i] = ps[i]
  6939. }
  6940. m.Where(p...)
  6941. }
  6942. // Op returns the operation name.
  6943. func (m *MessageRecordsMutation) Op() Op {
  6944. return m.op
  6945. }
  6946. // SetOp allows setting the mutation operation.
  6947. func (m *MessageRecordsMutation) SetOp(op Op) {
  6948. m.op = op
  6949. }
  6950. // Type returns the node type of this mutation (MessageRecords).
  6951. func (m *MessageRecordsMutation) Type() string {
  6952. return m.typ
  6953. }
  6954. // Fields returns all fields that were changed during this mutation. Note that in
  6955. // order to get all numeric fields that were incremented/decremented, call
  6956. // AddedFields().
  6957. func (m *MessageRecordsMutation) Fields() []string {
  6958. fields := make([]string, 0, 17)
  6959. if m.created_at != nil {
  6960. fields = append(fields, messagerecords.FieldCreatedAt)
  6961. }
  6962. if m.updated_at != nil {
  6963. fields = append(fields, messagerecords.FieldUpdatedAt)
  6964. }
  6965. if m.status != nil {
  6966. fields = append(fields, messagerecords.FieldStatus)
  6967. }
  6968. if m.deleted_at != nil {
  6969. fields = append(fields, messagerecords.FieldDeletedAt)
  6970. }
  6971. if m.bot_wxid != nil {
  6972. fields = append(fields, messagerecords.FieldBotWxid)
  6973. }
  6974. if m.message_contact != nil {
  6975. fields = append(fields, messagerecords.FieldContactID)
  6976. }
  6977. if m.contact_type != nil {
  6978. fields = append(fields, messagerecords.FieldContactType)
  6979. }
  6980. if m.contact_wxid != nil {
  6981. fields = append(fields, messagerecords.FieldContactWxid)
  6982. }
  6983. if m.content_type != nil {
  6984. fields = append(fields, messagerecords.FieldContentType)
  6985. }
  6986. if m.content != nil {
  6987. fields = append(fields, messagerecords.FieldContent)
  6988. }
  6989. if m.meta != nil {
  6990. fields = append(fields, messagerecords.FieldMeta)
  6991. }
  6992. if m.error_detail != nil {
  6993. fields = append(fields, messagerecords.FieldErrorDetail)
  6994. }
  6995. if m.send_time != nil {
  6996. fields = append(fields, messagerecords.FieldSendTime)
  6997. }
  6998. if m.source_type != nil {
  6999. fields = append(fields, messagerecords.FieldSourceType)
  7000. }
  7001. if m.sop_stage != nil {
  7002. fields = append(fields, messagerecords.FieldSourceID)
  7003. }
  7004. if m.sop_node != nil {
  7005. fields = append(fields, messagerecords.FieldSubSourceID)
  7006. }
  7007. if m.organization_id != nil {
  7008. fields = append(fields, messagerecords.FieldOrganizationID)
  7009. }
  7010. return fields
  7011. }
  7012. // Field returns the value of a field with the given name. The second boolean
  7013. // return value indicates that this field was not set, or was not defined in the
  7014. // schema.
  7015. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  7016. switch name {
  7017. case messagerecords.FieldCreatedAt:
  7018. return m.CreatedAt()
  7019. case messagerecords.FieldUpdatedAt:
  7020. return m.UpdatedAt()
  7021. case messagerecords.FieldStatus:
  7022. return m.Status()
  7023. case messagerecords.FieldDeletedAt:
  7024. return m.DeletedAt()
  7025. case messagerecords.FieldBotWxid:
  7026. return m.BotWxid()
  7027. case messagerecords.FieldContactID:
  7028. return m.ContactID()
  7029. case messagerecords.FieldContactType:
  7030. return m.ContactType()
  7031. case messagerecords.FieldContactWxid:
  7032. return m.ContactWxid()
  7033. case messagerecords.FieldContentType:
  7034. return m.ContentType()
  7035. case messagerecords.FieldContent:
  7036. return m.Content()
  7037. case messagerecords.FieldMeta:
  7038. return m.Meta()
  7039. case messagerecords.FieldErrorDetail:
  7040. return m.ErrorDetail()
  7041. case messagerecords.FieldSendTime:
  7042. return m.SendTime()
  7043. case messagerecords.FieldSourceType:
  7044. return m.SourceType()
  7045. case messagerecords.FieldSourceID:
  7046. return m.SourceID()
  7047. case messagerecords.FieldSubSourceID:
  7048. return m.SubSourceID()
  7049. case messagerecords.FieldOrganizationID:
  7050. return m.OrganizationID()
  7051. }
  7052. return nil, false
  7053. }
  7054. // OldField returns the old value of the field from the database. An error is
  7055. // returned if the mutation operation is not UpdateOne, or the query to the
  7056. // database failed.
  7057. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7058. switch name {
  7059. case messagerecords.FieldCreatedAt:
  7060. return m.OldCreatedAt(ctx)
  7061. case messagerecords.FieldUpdatedAt:
  7062. return m.OldUpdatedAt(ctx)
  7063. case messagerecords.FieldStatus:
  7064. return m.OldStatus(ctx)
  7065. case messagerecords.FieldDeletedAt:
  7066. return m.OldDeletedAt(ctx)
  7067. case messagerecords.FieldBotWxid:
  7068. return m.OldBotWxid(ctx)
  7069. case messagerecords.FieldContactID:
  7070. return m.OldContactID(ctx)
  7071. case messagerecords.FieldContactType:
  7072. return m.OldContactType(ctx)
  7073. case messagerecords.FieldContactWxid:
  7074. return m.OldContactWxid(ctx)
  7075. case messagerecords.FieldContentType:
  7076. return m.OldContentType(ctx)
  7077. case messagerecords.FieldContent:
  7078. return m.OldContent(ctx)
  7079. case messagerecords.FieldMeta:
  7080. return m.OldMeta(ctx)
  7081. case messagerecords.FieldErrorDetail:
  7082. return m.OldErrorDetail(ctx)
  7083. case messagerecords.FieldSendTime:
  7084. return m.OldSendTime(ctx)
  7085. case messagerecords.FieldSourceType:
  7086. return m.OldSourceType(ctx)
  7087. case messagerecords.FieldSourceID:
  7088. return m.OldSourceID(ctx)
  7089. case messagerecords.FieldSubSourceID:
  7090. return m.OldSubSourceID(ctx)
  7091. case messagerecords.FieldOrganizationID:
  7092. return m.OldOrganizationID(ctx)
  7093. }
  7094. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  7095. }
  7096. // SetField sets the value of a field with the given name. It returns an error if
  7097. // the field is not defined in the schema, or if the type mismatched the field
  7098. // type.
  7099. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  7100. switch name {
  7101. case messagerecords.FieldCreatedAt:
  7102. v, ok := value.(time.Time)
  7103. if !ok {
  7104. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7105. }
  7106. m.SetCreatedAt(v)
  7107. return nil
  7108. case messagerecords.FieldUpdatedAt:
  7109. v, ok := value.(time.Time)
  7110. if !ok {
  7111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7112. }
  7113. m.SetUpdatedAt(v)
  7114. return nil
  7115. case messagerecords.FieldStatus:
  7116. v, ok := value.(uint8)
  7117. if !ok {
  7118. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7119. }
  7120. m.SetStatus(v)
  7121. return nil
  7122. case messagerecords.FieldDeletedAt:
  7123. v, ok := value.(time.Time)
  7124. if !ok {
  7125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7126. }
  7127. m.SetDeletedAt(v)
  7128. return nil
  7129. case messagerecords.FieldBotWxid:
  7130. v, ok := value.(string)
  7131. if !ok {
  7132. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7133. }
  7134. m.SetBotWxid(v)
  7135. return nil
  7136. case messagerecords.FieldContactID:
  7137. v, ok := value.(uint64)
  7138. if !ok {
  7139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7140. }
  7141. m.SetContactID(v)
  7142. return nil
  7143. case messagerecords.FieldContactType:
  7144. v, ok := value.(int)
  7145. if !ok {
  7146. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7147. }
  7148. m.SetContactType(v)
  7149. return nil
  7150. case messagerecords.FieldContactWxid:
  7151. v, ok := value.(string)
  7152. if !ok {
  7153. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7154. }
  7155. m.SetContactWxid(v)
  7156. return nil
  7157. case messagerecords.FieldContentType:
  7158. v, ok := value.(int)
  7159. if !ok {
  7160. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7161. }
  7162. m.SetContentType(v)
  7163. return nil
  7164. case messagerecords.FieldContent:
  7165. v, ok := value.(string)
  7166. if !ok {
  7167. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7168. }
  7169. m.SetContent(v)
  7170. return nil
  7171. case messagerecords.FieldMeta:
  7172. v, ok := value.(custom_types.Meta)
  7173. if !ok {
  7174. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7175. }
  7176. m.SetMeta(v)
  7177. return nil
  7178. case messagerecords.FieldErrorDetail:
  7179. v, ok := value.(string)
  7180. if !ok {
  7181. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7182. }
  7183. m.SetErrorDetail(v)
  7184. return nil
  7185. case messagerecords.FieldSendTime:
  7186. v, ok := value.(time.Time)
  7187. if !ok {
  7188. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7189. }
  7190. m.SetSendTime(v)
  7191. return nil
  7192. case messagerecords.FieldSourceType:
  7193. v, ok := value.(int)
  7194. if !ok {
  7195. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7196. }
  7197. m.SetSourceType(v)
  7198. return nil
  7199. case messagerecords.FieldSourceID:
  7200. v, ok := value.(uint64)
  7201. if !ok {
  7202. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7203. }
  7204. m.SetSourceID(v)
  7205. return nil
  7206. case messagerecords.FieldSubSourceID:
  7207. v, ok := value.(uint64)
  7208. if !ok {
  7209. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7210. }
  7211. m.SetSubSourceID(v)
  7212. return nil
  7213. case messagerecords.FieldOrganizationID:
  7214. v, ok := value.(uint64)
  7215. if !ok {
  7216. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7217. }
  7218. m.SetOrganizationID(v)
  7219. return nil
  7220. }
  7221. return fmt.Errorf("unknown MessageRecords field %s", name)
  7222. }
  7223. // AddedFields returns all numeric fields that were incremented/decremented during
  7224. // this mutation.
  7225. func (m *MessageRecordsMutation) AddedFields() []string {
  7226. var fields []string
  7227. if m.addstatus != nil {
  7228. fields = append(fields, messagerecords.FieldStatus)
  7229. }
  7230. if m.addcontact_type != nil {
  7231. fields = append(fields, messagerecords.FieldContactType)
  7232. }
  7233. if m.addcontent_type != nil {
  7234. fields = append(fields, messagerecords.FieldContentType)
  7235. }
  7236. if m.addsource_type != nil {
  7237. fields = append(fields, messagerecords.FieldSourceType)
  7238. }
  7239. if m.addorganization_id != nil {
  7240. fields = append(fields, messagerecords.FieldOrganizationID)
  7241. }
  7242. return fields
  7243. }
  7244. // AddedField returns the numeric value that was incremented/decremented on a field
  7245. // with the given name. The second boolean return value indicates that this field
  7246. // was not set, or was not defined in the schema.
  7247. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  7248. switch name {
  7249. case messagerecords.FieldStatus:
  7250. return m.AddedStatus()
  7251. case messagerecords.FieldContactType:
  7252. return m.AddedContactType()
  7253. case messagerecords.FieldContentType:
  7254. return m.AddedContentType()
  7255. case messagerecords.FieldSourceType:
  7256. return m.AddedSourceType()
  7257. case messagerecords.FieldOrganizationID:
  7258. return m.AddedOrganizationID()
  7259. }
  7260. return nil, false
  7261. }
  7262. // AddField adds the value to the field with the given name. It returns an error if
  7263. // the field is not defined in the schema, or if the type mismatched the field
  7264. // type.
  7265. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  7266. switch name {
  7267. case messagerecords.FieldStatus:
  7268. v, ok := value.(int8)
  7269. if !ok {
  7270. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7271. }
  7272. m.AddStatus(v)
  7273. return nil
  7274. case messagerecords.FieldContactType:
  7275. v, ok := value.(int)
  7276. if !ok {
  7277. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7278. }
  7279. m.AddContactType(v)
  7280. return nil
  7281. case messagerecords.FieldContentType:
  7282. v, ok := value.(int)
  7283. if !ok {
  7284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7285. }
  7286. m.AddContentType(v)
  7287. return nil
  7288. case messagerecords.FieldSourceType:
  7289. v, ok := value.(int)
  7290. if !ok {
  7291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7292. }
  7293. m.AddSourceType(v)
  7294. return nil
  7295. case messagerecords.FieldOrganizationID:
  7296. v, ok := value.(int64)
  7297. if !ok {
  7298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7299. }
  7300. m.AddOrganizationID(v)
  7301. return nil
  7302. }
  7303. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  7304. }
  7305. // ClearedFields returns all nullable fields that were cleared during this
  7306. // mutation.
  7307. func (m *MessageRecordsMutation) ClearedFields() []string {
  7308. var fields []string
  7309. if m.FieldCleared(messagerecords.FieldStatus) {
  7310. fields = append(fields, messagerecords.FieldStatus)
  7311. }
  7312. if m.FieldCleared(messagerecords.FieldDeletedAt) {
  7313. fields = append(fields, messagerecords.FieldDeletedAt)
  7314. }
  7315. if m.FieldCleared(messagerecords.FieldContactID) {
  7316. fields = append(fields, messagerecords.FieldContactID)
  7317. }
  7318. if m.FieldCleared(messagerecords.FieldMeta) {
  7319. fields = append(fields, messagerecords.FieldMeta)
  7320. }
  7321. if m.FieldCleared(messagerecords.FieldSendTime) {
  7322. fields = append(fields, messagerecords.FieldSendTime)
  7323. }
  7324. if m.FieldCleared(messagerecords.FieldSourceID) {
  7325. fields = append(fields, messagerecords.FieldSourceID)
  7326. }
  7327. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  7328. fields = append(fields, messagerecords.FieldSubSourceID)
  7329. }
  7330. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  7331. fields = append(fields, messagerecords.FieldOrganizationID)
  7332. }
  7333. return fields
  7334. }
  7335. // FieldCleared returns a boolean indicating if a field with the given name was
  7336. // cleared in this mutation.
  7337. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  7338. _, ok := m.clearedFields[name]
  7339. return ok
  7340. }
  7341. // ClearField clears the value of the field with the given name. It returns an
  7342. // error if the field is not defined in the schema.
  7343. func (m *MessageRecordsMutation) ClearField(name string) error {
  7344. switch name {
  7345. case messagerecords.FieldStatus:
  7346. m.ClearStatus()
  7347. return nil
  7348. case messagerecords.FieldDeletedAt:
  7349. m.ClearDeletedAt()
  7350. return nil
  7351. case messagerecords.FieldContactID:
  7352. m.ClearContactID()
  7353. return nil
  7354. case messagerecords.FieldMeta:
  7355. m.ClearMeta()
  7356. return nil
  7357. case messagerecords.FieldSendTime:
  7358. m.ClearSendTime()
  7359. return nil
  7360. case messagerecords.FieldSourceID:
  7361. m.ClearSourceID()
  7362. return nil
  7363. case messagerecords.FieldSubSourceID:
  7364. m.ClearSubSourceID()
  7365. return nil
  7366. case messagerecords.FieldOrganizationID:
  7367. m.ClearOrganizationID()
  7368. return nil
  7369. }
  7370. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  7371. }
  7372. // ResetField resets all changes in the mutation for the field with the given name.
  7373. // It returns an error if the field is not defined in the schema.
  7374. func (m *MessageRecordsMutation) ResetField(name string) error {
  7375. switch name {
  7376. case messagerecords.FieldCreatedAt:
  7377. m.ResetCreatedAt()
  7378. return nil
  7379. case messagerecords.FieldUpdatedAt:
  7380. m.ResetUpdatedAt()
  7381. return nil
  7382. case messagerecords.FieldStatus:
  7383. m.ResetStatus()
  7384. return nil
  7385. case messagerecords.FieldDeletedAt:
  7386. m.ResetDeletedAt()
  7387. return nil
  7388. case messagerecords.FieldBotWxid:
  7389. m.ResetBotWxid()
  7390. return nil
  7391. case messagerecords.FieldContactID:
  7392. m.ResetContactID()
  7393. return nil
  7394. case messagerecords.FieldContactType:
  7395. m.ResetContactType()
  7396. return nil
  7397. case messagerecords.FieldContactWxid:
  7398. m.ResetContactWxid()
  7399. return nil
  7400. case messagerecords.FieldContentType:
  7401. m.ResetContentType()
  7402. return nil
  7403. case messagerecords.FieldContent:
  7404. m.ResetContent()
  7405. return nil
  7406. case messagerecords.FieldMeta:
  7407. m.ResetMeta()
  7408. return nil
  7409. case messagerecords.FieldErrorDetail:
  7410. m.ResetErrorDetail()
  7411. return nil
  7412. case messagerecords.FieldSendTime:
  7413. m.ResetSendTime()
  7414. return nil
  7415. case messagerecords.FieldSourceType:
  7416. m.ResetSourceType()
  7417. return nil
  7418. case messagerecords.FieldSourceID:
  7419. m.ResetSourceID()
  7420. return nil
  7421. case messagerecords.FieldSubSourceID:
  7422. m.ResetSubSourceID()
  7423. return nil
  7424. case messagerecords.FieldOrganizationID:
  7425. m.ResetOrganizationID()
  7426. return nil
  7427. }
  7428. return fmt.Errorf("unknown MessageRecords field %s", name)
  7429. }
  7430. // AddedEdges returns all edge names that were set/added in this mutation.
  7431. func (m *MessageRecordsMutation) AddedEdges() []string {
  7432. edges := make([]string, 0, 3)
  7433. if m.sop_stage != nil {
  7434. edges = append(edges, messagerecords.EdgeSopStage)
  7435. }
  7436. if m.sop_node != nil {
  7437. edges = append(edges, messagerecords.EdgeSopNode)
  7438. }
  7439. if m.message_contact != nil {
  7440. edges = append(edges, messagerecords.EdgeMessageContact)
  7441. }
  7442. return edges
  7443. }
  7444. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7445. // name in this mutation.
  7446. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  7447. switch name {
  7448. case messagerecords.EdgeSopStage:
  7449. if id := m.sop_stage; id != nil {
  7450. return []ent.Value{*id}
  7451. }
  7452. case messagerecords.EdgeSopNode:
  7453. if id := m.sop_node; id != nil {
  7454. return []ent.Value{*id}
  7455. }
  7456. case messagerecords.EdgeMessageContact:
  7457. if id := m.message_contact; id != nil {
  7458. return []ent.Value{*id}
  7459. }
  7460. }
  7461. return nil
  7462. }
  7463. // RemovedEdges returns all edge names that were removed in this mutation.
  7464. func (m *MessageRecordsMutation) RemovedEdges() []string {
  7465. edges := make([]string, 0, 3)
  7466. return edges
  7467. }
  7468. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7469. // the given name in this mutation.
  7470. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  7471. return nil
  7472. }
  7473. // ClearedEdges returns all edge names that were cleared in this mutation.
  7474. func (m *MessageRecordsMutation) ClearedEdges() []string {
  7475. edges := make([]string, 0, 3)
  7476. if m.clearedsop_stage {
  7477. edges = append(edges, messagerecords.EdgeSopStage)
  7478. }
  7479. if m.clearedsop_node {
  7480. edges = append(edges, messagerecords.EdgeSopNode)
  7481. }
  7482. if m.clearedmessage_contact {
  7483. edges = append(edges, messagerecords.EdgeMessageContact)
  7484. }
  7485. return edges
  7486. }
  7487. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7488. // was cleared in this mutation.
  7489. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  7490. switch name {
  7491. case messagerecords.EdgeSopStage:
  7492. return m.clearedsop_stage
  7493. case messagerecords.EdgeSopNode:
  7494. return m.clearedsop_node
  7495. case messagerecords.EdgeMessageContact:
  7496. return m.clearedmessage_contact
  7497. }
  7498. return false
  7499. }
  7500. // ClearEdge clears the value of the edge with the given name. It returns an error
  7501. // if that edge is not defined in the schema.
  7502. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  7503. switch name {
  7504. case messagerecords.EdgeSopStage:
  7505. m.ClearSopStage()
  7506. return nil
  7507. case messagerecords.EdgeSopNode:
  7508. m.ClearSopNode()
  7509. return nil
  7510. case messagerecords.EdgeMessageContact:
  7511. m.ClearMessageContact()
  7512. return nil
  7513. }
  7514. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  7515. }
  7516. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7517. // It returns an error if the edge is not defined in the schema.
  7518. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  7519. switch name {
  7520. case messagerecords.EdgeSopStage:
  7521. m.ResetSopStage()
  7522. return nil
  7523. case messagerecords.EdgeSopNode:
  7524. m.ResetSopNode()
  7525. return nil
  7526. case messagerecords.EdgeMessageContact:
  7527. m.ResetMessageContact()
  7528. return nil
  7529. }
  7530. return fmt.Errorf("unknown MessageRecords edge %s", name)
  7531. }
  7532. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  7533. type MsgMutation struct {
  7534. config
  7535. op Op
  7536. typ string
  7537. id *uint64
  7538. created_at *time.Time
  7539. updated_at *time.Time
  7540. deleted_at *time.Time
  7541. status *uint8
  7542. addstatus *int8
  7543. fromwxid *string
  7544. toid *string
  7545. msgtype *int32
  7546. addmsgtype *int32
  7547. msg *string
  7548. batch_no *string
  7549. clearedFields map[string]struct{}
  7550. done bool
  7551. oldValue func(context.Context) (*Msg, error)
  7552. predicates []predicate.Msg
  7553. }
  7554. var _ ent.Mutation = (*MsgMutation)(nil)
  7555. // msgOption allows management of the mutation configuration using functional options.
  7556. type msgOption func(*MsgMutation)
  7557. // newMsgMutation creates new mutation for the Msg entity.
  7558. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  7559. m := &MsgMutation{
  7560. config: c,
  7561. op: op,
  7562. typ: TypeMsg,
  7563. clearedFields: make(map[string]struct{}),
  7564. }
  7565. for _, opt := range opts {
  7566. opt(m)
  7567. }
  7568. return m
  7569. }
  7570. // withMsgID sets the ID field of the mutation.
  7571. func withMsgID(id uint64) msgOption {
  7572. return func(m *MsgMutation) {
  7573. var (
  7574. err error
  7575. once sync.Once
  7576. value *Msg
  7577. )
  7578. m.oldValue = func(ctx context.Context) (*Msg, error) {
  7579. once.Do(func() {
  7580. if m.done {
  7581. err = errors.New("querying old values post mutation is not allowed")
  7582. } else {
  7583. value, err = m.Client().Msg.Get(ctx, id)
  7584. }
  7585. })
  7586. return value, err
  7587. }
  7588. m.id = &id
  7589. }
  7590. }
  7591. // withMsg sets the old Msg of the mutation.
  7592. func withMsg(node *Msg) msgOption {
  7593. return func(m *MsgMutation) {
  7594. m.oldValue = func(context.Context) (*Msg, error) {
  7595. return node, nil
  7596. }
  7597. m.id = &node.ID
  7598. }
  7599. }
  7600. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7601. // executed in a transaction (ent.Tx), a transactional client is returned.
  7602. func (m MsgMutation) Client() *Client {
  7603. client := &Client{config: m.config}
  7604. client.init()
  7605. return client
  7606. }
  7607. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7608. // it returns an error otherwise.
  7609. func (m MsgMutation) Tx() (*Tx, error) {
  7610. if _, ok := m.driver.(*txDriver); !ok {
  7611. return nil, errors.New("ent: mutation is not running in a transaction")
  7612. }
  7613. tx := &Tx{config: m.config}
  7614. tx.init()
  7615. return tx, nil
  7616. }
  7617. // SetID sets the value of the id field. Note that this
  7618. // operation is only accepted on creation of Msg entities.
  7619. func (m *MsgMutation) SetID(id uint64) {
  7620. m.id = &id
  7621. }
  7622. // ID returns the ID value in the mutation. Note that the ID is only available
  7623. // if it was provided to the builder or after it was returned from the database.
  7624. func (m *MsgMutation) ID() (id uint64, exists bool) {
  7625. if m.id == nil {
  7626. return
  7627. }
  7628. return *m.id, true
  7629. }
  7630. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7631. // That means, if the mutation is applied within a transaction with an isolation level such
  7632. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7633. // or updated by the mutation.
  7634. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  7635. switch {
  7636. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7637. id, exists := m.ID()
  7638. if exists {
  7639. return []uint64{id}, nil
  7640. }
  7641. fallthrough
  7642. case m.op.Is(OpUpdate | OpDelete):
  7643. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  7644. default:
  7645. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7646. }
  7647. }
  7648. // SetCreatedAt sets the "created_at" field.
  7649. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  7650. m.created_at = &t
  7651. }
  7652. // CreatedAt returns the value of the "created_at" field in the mutation.
  7653. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  7654. v := m.created_at
  7655. if v == nil {
  7656. return
  7657. }
  7658. return *v, true
  7659. }
  7660. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  7661. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  7662. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7663. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7664. if !m.op.Is(OpUpdateOne) {
  7665. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7666. }
  7667. if m.id == nil || m.oldValue == nil {
  7668. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7669. }
  7670. oldValue, err := m.oldValue(ctx)
  7671. if err != nil {
  7672. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7673. }
  7674. return oldValue.CreatedAt, nil
  7675. }
  7676. // ResetCreatedAt resets all changes to the "created_at" field.
  7677. func (m *MsgMutation) ResetCreatedAt() {
  7678. m.created_at = nil
  7679. }
  7680. // SetUpdatedAt sets the "updated_at" field.
  7681. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  7682. m.updated_at = &t
  7683. }
  7684. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7685. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  7686. v := m.updated_at
  7687. if v == nil {
  7688. return
  7689. }
  7690. return *v, true
  7691. }
  7692. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  7693. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  7694. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7695. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7696. if !m.op.Is(OpUpdateOne) {
  7697. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7698. }
  7699. if m.id == nil || m.oldValue == nil {
  7700. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7701. }
  7702. oldValue, err := m.oldValue(ctx)
  7703. if err != nil {
  7704. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7705. }
  7706. return oldValue.UpdatedAt, nil
  7707. }
  7708. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7709. func (m *MsgMutation) ResetUpdatedAt() {
  7710. m.updated_at = nil
  7711. }
  7712. // SetDeletedAt sets the "deleted_at" field.
  7713. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  7714. m.deleted_at = &t
  7715. }
  7716. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7717. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  7718. v := m.deleted_at
  7719. if v == nil {
  7720. return
  7721. }
  7722. return *v, true
  7723. }
  7724. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  7725. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  7726. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7727. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7728. if !m.op.Is(OpUpdateOne) {
  7729. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7730. }
  7731. if m.id == nil || m.oldValue == nil {
  7732. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7733. }
  7734. oldValue, err := m.oldValue(ctx)
  7735. if err != nil {
  7736. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7737. }
  7738. return oldValue.DeletedAt, nil
  7739. }
  7740. // ClearDeletedAt clears the value of the "deleted_at" field.
  7741. func (m *MsgMutation) ClearDeletedAt() {
  7742. m.deleted_at = nil
  7743. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  7744. }
  7745. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7746. func (m *MsgMutation) DeletedAtCleared() bool {
  7747. _, ok := m.clearedFields[msg.FieldDeletedAt]
  7748. return ok
  7749. }
  7750. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7751. func (m *MsgMutation) ResetDeletedAt() {
  7752. m.deleted_at = nil
  7753. delete(m.clearedFields, msg.FieldDeletedAt)
  7754. }
  7755. // SetStatus sets the "status" field.
  7756. func (m *MsgMutation) SetStatus(u uint8) {
  7757. m.status = &u
  7758. m.addstatus = nil
  7759. }
  7760. // Status returns the value of the "status" field in the mutation.
  7761. func (m *MsgMutation) Status() (r uint8, exists bool) {
  7762. v := m.status
  7763. if v == nil {
  7764. return
  7765. }
  7766. return *v, true
  7767. }
  7768. // OldStatus returns the old "status" field's value of the Msg entity.
  7769. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  7770. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7771. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7772. if !m.op.Is(OpUpdateOne) {
  7773. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7774. }
  7775. if m.id == nil || m.oldValue == nil {
  7776. return v, errors.New("OldStatus requires an ID field in the mutation")
  7777. }
  7778. oldValue, err := m.oldValue(ctx)
  7779. if err != nil {
  7780. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7781. }
  7782. return oldValue.Status, nil
  7783. }
  7784. // AddStatus adds u to the "status" field.
  7785. func (m *MsgMutation) AddStatus(u int8) {
  7786. if m.addstatus != nil {
  7787. *m.addstatus += u
  7788. } else {
  7789. m.addstatus = &u
  7790. }
  7791. }
  7792. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7793. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  7794. v := m.addstatus
  7795. if v == nil {
  7796. return
  7797. }
  7798. return *v, true
  7799. }
  7800. // ClearStatus clears the value of the "status" field.
  7801. func (m *MsgMutation) ClearStatus() {
  7802. m.status = nil
  7803. m.addstatus = nil
  7804. m.clearedFields[msg.FieldStatus] = struct{}{}
  7805. }
  7806. // StatusCleared returns if the "status" field was cleared in this mutation.
  7807. func (m *MsgMutation) StatusCleared() bool {
  7808. _, ok := m.clearedFields[msg.FieldStatus]
  7809. return ok
  7810. }
  7811. // ResetStatus resets all changes to the "status" field.
  7812. func (m *MsgMutation) ResetStatus() {
  7813. m.status = nil
  7814. m.addstatus = nil
  7815. delete(m.clearedFields, msg.FieldStatus)
  7816. }
  7817. // SetFromwxid sets the "fromwxid" field.
  7818. func (m *MsgMutation) SetFromwxid(s string) {
  7819. m.fromwxid = &s
  7820. }
  7821. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  7822. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  7823. v := m.fromwxid
  7824. if v == nil {
  7825. return
  7826. }
  7827. return *v, true
  7828. }
  7829. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  7830. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  7831. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7832. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  7833. if !m.op.Is(OpUpdateOne) {
  7834. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  7835. }
  7836. if m.id == nil || m.oldValue == nil {
  7837. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  7838. }
  7839. oldValue, err := m.oldValue(ctx)
  7840. if err != nil {
  7841. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  7842. }
  7843. return oldValue.Fromwxid, nil
  7844. }
  7845. // ClearFromwxid clears the value of the "fromwxid" field.
  7846. func (m *MsgMutation) ClearFromwxid() {
  7847. m.fromwxid = nil
  7848. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  7849. }
  7850. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  7851. func (m *MsgMutation) FromwxidCleared() bool {
  7852. _, ok := m.clearedFields[msg.FieldFromwxid]
  7853. return ok
  7854. }
  7855. // ResetFromwxid resets all changes to the "fromwxid" field.
  7856. func (m *MsgMutation) ResetFromwxid() {
  7857. m.fromwxid = nil
  7858. delete(m.clearedFields, msg.FieldFromwxid)
  7859. }
  7860. // SetToid sets the "toid" field.
  7861. func (m *MsgMutation) SetToid(s string) {
  7862. m.toid = &s
  7863. }
  7864. // Toid returns the value of the "toid" field in the mutation.
  7865. func (m *MsgMutation) Toid() (r string, exists bool) {
  7866. v := m.toid
  7867. if v == nil {
  7868. return
  7869. }
  7870. return *v, true
  7871. }
  7872. // OldToid returns the old "toid" field's value of the Msg entity.
  7873. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  7874. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7875. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  7876. if !m.op.Is(OpUpdateOne) {
  7877. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  7878. }
  7879. if m.id == nil || m.oldValue == nil {
  7880. return v, errors.New("OldToid requires an ID field in the mutation")
  7881. }
  7882. oldValue, err := m.oldValue(ctx)
  7883. if err != nil {
  7884. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  7885. }
  7886. return oldValue.Toid, nil
  7887. }
  7888. // ClearToid clears the value of the "toid" field.
  7889. func (m *MsgMutation) ClearToid() {
  7890. m.toid = nil
  7891. m.clearedFields[msg.FieldToid] = struct{}{}
  7892. }
  7893. // ToidCleared returns if the "toid" field was cleared in this mutation.
  7894. func (m *MsgMutation) ToidCleared() bool {
  7895. _, ok := m.clearedFields[msg.FieldToid]
  7896. return ok
  7897. }
  7898. // ResetToid resets all changes to the "toid" field.
  7899. func (m *MsgMutation) ResetToid() {
  7900. m.toid = nil
  7901. delete(m.clearedFields, msg.FieldToid)
  7902. }
  7903. // SetMsgtype sets the "msgtype" field.
  7904. func (m *MsgMutation) SetMsgtype(i int32) {
  7905. m.msgtype = &i
  7906. m.addmsgtype = nil
  7907. }
  7908. // Msgtype returns the value of the "msgtype" field in the mutation.
  7909. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  7910. v := m.msgtype
  7911. if v == nil {
  7912. return
  7913. }
  7914. return *v, true
  7915. }
  7916. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  7917. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  7918. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7919. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  7920. if !m.op.Is(OpUpdateOne) {
  7921. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  7922. }
  7923. if m.id == nil || m.oldValue == nil {
  7924. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  7925. }
  7926. oldValue, err := m.oldValue(ctx)
  7927. if err != nil {
  7928. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  7929. }
  7930. return oldValue.Msgtype, nil
  7931. }
  7932. // AddMsgtype adds i to the "msgtype" field.
  7933. func (m *MsgMutation) AddMsgtype(i int32) {
  7934. if m.addmsgtype != nil {
  7935. *m.addmsgtype += i
  7936. } else {
  7937. m.addmsgtype = &i
  7938. }
  7939. }
  7940. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  7941. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  7942. v := m.addmsgtype
  7943. if v == nil {
  7944. return
  7945. }
  7946. return *v, true
  7947. }
  7948. // ClearMsgtype clears the value of the "msgtype" field.
  7949. func (m *MsgMutation) ClearMsgtype() {
  7950. m.msgtype = nil
  7951. m.addmsgtype = nil
  7952. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  7953. }
  7954. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  7955. func (m *MsgMutation) MsgtypeCleared() bool {
  7956. _, ok := m.clearedFields[msg.FieldMsgtype]
  7957. return ok
  7958. }
  7959. // ResetMsgtype resets all changes to the "msgtype" field.
  7960. func (m *MsgMutation) ResetMsgtype() {
  7961. m.msgtype = nil
  7962. m.addmsgtype = nil
  7963. delete(m.clearedFields, msg.FieldMsgtype)
  7964. }
  7965. // SetMsg sets the "msg" field.
  7966. func (m *MsgMutation) SetMsg(s string) {
  7967. m.msg = &s
  7968. }
  7969. // Msg returns the value of the "msg" field in the mutation.
  7970. func (m *MsgMutation) Msg() (r string, exists bool) {
  7971. v := m.msg
  7972. if v == nil {
  7973. return
  7974. }
  7975. return *v, true
  7976. }
  7977. // OldMsg returns the old "msg" field's value of the Msg entity.
  7978. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  7979. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7980. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  7981. if !m.op.Is(OpUpdateOne) {
  7982. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  7983. }
  7984. if m.id == nil || m.oldValue == nil {
  7985. return v, errors.New("OldMsg requires an ID field in the mutation")
  7986. }
  7987. oldValue, err := m.oldValue(ctx)
  7988. if err != nil {
  7989. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  7990. }
  7991. return oldValue.Msg, nil
  7992. }
  7993. // ClearMsg clears the value of the "msg" field.
  7994. func (m *MsgMutation) ClearMsg() {
  7995. m.msg = nil
  7996. m.clearedFields[msg.FieldMsg] = struct{}{}
  7997. }
  7998. // MsgCleared returns if the "msg" field was cleared in this mutation.
  7999. func (m *MsgMutation) MsgCleared() bool {
  8000. _, ok := m.clearedFields[msg.FieldMsg]
  8001. return ok
  8002. }
  8003. // ResetMsg resets all changes to the "msg" field.
  8004. func (m *MsgMutation) ResetMsg() {
  8005. m.msg = nil
  8006. delete(m.clearedFields, msg.FieldMsg)
  8007. }
  8008. // SetBatchNo sets the "batch_no" field.
  8009. func (m *MsgMutation) SetBatchNo(s string) {
  8010. m.batch_no = &s
  8011. }
  8012. // BatchNo returns the value of the "batch_no" field in the mutation.
  8013. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  8014. v := m.batch_no
  8015. if v == nil {
  8016. return
  8017. }
  8018. return *v, true
  8019. }
  8020. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  8021. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  8022. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8023. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  8024. if !m.op.Is(OpUpdateOne) {
  8025. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  8026. }
  8027. if m.id == nil || m.oldValue == nil {
  8028. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  8029. }
  8030. oldValue, err := m.oldValue(ctx)
  8031. if err != nil {
  8032. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  8033. }
  8034. return oldValue.BatchNo, nil
  8035. }
  8036. // ClearBatchNo clears the value of the "batch_no" field.
  8037. func (m *MsgMutation) ClearBatchNo() {
  8038. m.batch_no = nil
  8039. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  8040. }
  8041. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  8042. func (m *MsgMutation) BatchNoCleared() bool {
  8043. _, ok := m.clearedFields[msg.FieldBatchNo]
  8044. return ok
  8045. }
  8046. // ResetBatchNo resets all changes to the "batch_no" field.
  8047. func (m *MsgMutation) ResetBatchNo() {
  8048. m.batch_no = nil
  8049. delete(m.clearedFields, msg.FieldBatchNo)
  8050. }
  8051. // Where appends a list predicates to the MsgMutation builder.
  8052. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  8053. m.predicates = append(m.predicates, ps...)
  8054. }
  8055. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  8056. // users can use type-assertion to append predicates that do not depend on any generated package.
  8057. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  8058. p := make([]predicate.Msg, len(ps))
  8059. for i := range ps {
  8060. p[i] = ps[i]
  8061. }
  8062. m.Where(p...)
  8063. }
  8064. // Op returns the operation name.
  8065. func (m *MsgMutation) Op() Op {
  8066. return m.op
  8067. }
  8068. // SetOp allows setting the mutation operation.
  8069. func (m *MsgMutation) SetOp(op Op) {
  8070. m.op = op
  8071. }
  8072. // Type returns the node type of this mutation (Msg).
  8073. func (m *MsgMutation) Type() string {
  8074. return m.typ
  8075. }
  8076. // Fields returns all fields that were changed during this mutation. Note that in
  8077. // order to get all numeric fields that were incremented/decremented, call
  8078. // AddedFields().
  8079. func (m *MsgMutation) Fields() []string {
  8080. fields := make([]string, 0, 9)
  8081. if m.created_at != nil {
  8082. fields = append(fields, msg.FieldCreatedAt)
  8083. }
  8084. if m.updated_at != nil {
  8085. fields = append(fields, msg.FieldUpdatedAt)
  8086. }
  8087. if m.deleted_at != nil {
  8088. fields = append(fields, msg.FieldDeletedAt)
  8089. }
  8090. if m.status != nil {
  8091. fields = append(fields, msg.FieldStatus)
  8092. }
  8093. if m.fromwxid != nil {
  8094. fields = append(fields, msg.FieldFromwxid)
  8095. }
  8096. if m.toid != nil {
  8097. fields = append(fields, msg.FieldToid)
  8098. }
  8099. if m.msgtype != nil {
  8100. fields = append(fields, msg.FieldMsgtype)
  8101. }
  8102. if m.msg != nil {
  8103. fields = append(fields, msg.FieldMsg)
  8104. }
  8105. if m.batch_no != nil {
  8106. fields = append(fields, msg.FieldBatchNo)
  8107. }
  8108. return fields
  8109. }
  8110. // Field returns the value of a field with the given name. The second boolean
  8111. // return value indicates that this field was not set, or was not defined in the
  8112. // schema.
  8113. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  8114. switch name {
  8115. case msg.FieldCreatedAt:
  8116. return m.CreatedAt()
  8117. case msg.FieldUpdatedAt:
  8118. return m.UpdatedAt()
  8119. case msg.FieldDeletedAt:
  8120. return m.DeletedAt()
  8121. case msg.FieldStatus:
  8122. return m.Status()
  8123. case msg.FieldFromwxid:
  8124. return m.Fromwxid()
  8125. case msg.FieldToid:
  8126. return m.Toid()
  8127. case msg.FieldMsgtype:
  8128. return m.Msgtype()
  8129. case msg.FieldMsg:
  8130. return m.Msg()
  8131. case msg.FieldBatchNo:
  8132. return m.BatchNo()
  8133. }
  8134. return nil, false
  8135. }
  8136. // OldField returns the old value of the field from the database. An error is
  8137. // returned if the mutation operation is not UpdateOne, or the query to the
  8138. // database failed.
  8139. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8140. switch name {
  8141. case msg.FieldCreatedAt:
  8142. return m.OldCreatedAt(ctx)
  8143. case msg.FieldUpdatedAt:
  8144. return m.OldUpdatedAt(ctx)
  8145. case msg.FieldDeletedAt:
  8146. return m.OldDeletedAt(ctx)
  8147. case msg.FieldStatus:
  8148. return m.OldStatus(ctx)
  8149. case msg.FieldFromwxid:
  8150. return m.OldFromwxid(ctx)
  8151. case msg.FieldToid:
  8152. return m.OldToid(ctx)
  8153. case msg.FieldMsgtype:
  8154. return m.OldMsgtype(ctx)
  8155. case msg.FieldMsg:
  8156. return m.OldMsg(ctx)
  8157. case msg.FieldBatchNo:
  8158. return m.OldBatchNo(ctx)
  8159. }
  8160. return nil, fmt.Errorf("unknown Msg field %s", name)
  8161. }
  8162. // SetField sets the value of a field with the given name. It returns an error if
  8163. // the field is not defined in the schema, or if the type mismatched the field
  8164. // type.
  8165. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  8166. switch name {
  8167. case msg.FieldCreatedAt:
  8168. v, ok := value.(time.Time)
  8169. if !ok {
  8170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8171. }
  8172. m.SetCreatedAt(v)
  8173. return nil
  8174. case msg.FieldUpdatedAt:
  8175. v, ok := value.(time.Time)
  8176. if !ok {
  8177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8178. }
  8179. m.SetUpdatedAt(v)
  8180. return nil
  8181. case msg.FieldDeletedAt:
  8182. v, ok := value.(time.Time)
  8183. if !ok {
  8184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8185. }
  8186. m.SetDeletedAt(v)
  8187. return nil
  8188. case msg.FieldStatus:
  8189. v, ok := value.(uint8)
  8190. if !ok {
  8191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8192. }
  8193. m.SetStatus(v)
  8194. return nil
  8195. case msg.FieldFromwxid:
  8196. v, ok := value.(string)
  8197. if !ok {
  8198. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8199. }
  8200. m.SetFromwxid(v)
  8201. return nil
  8202. case msg.FieldToid:
  8203. v, ok := value.(string)
  8204. if !ok {
  8205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8206. }
  8207. m.SetToid(v)
  8208. return nil
  8209. case msg.FieldMsgtype:
  8210. v, ok := value.(int32)
  8211. if !ok {
  8212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8213. }
  8214. m.SetMsgtype(v)
  8215. return nil
  8216. case msg.FieldMsg:
  8217. v, ok := value.(string)
  8218. if !ok {
  8219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8220. }
  8221. m.SetMsg(v)
  8222. return nil
  8223. case msg.FieldBatchNo:
  8224. v, ok := value.(string)
  8225. if !ok {
  8226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8227. }
  8228. m.SetBatchNo(v)
  8229. return nil
  8230. }
  8231. return fmt.Errorf("unknown Msg field %s", name)
  8232. }
  8233. // AddedFields returns all numeric fields that were incremented/decremented during
  8234. // this mutation.
  8235. func (m *MsgMutation) AddedFields() []string {
  8236. var fields []string
  8237. if m.addstatus != nil {
  8238. fields = append(fields, msg.FieldStatus)
  8239. }
  8240. if m.addmsgtype != nil {
  8241. fields = append(fields, msg.FieldMsgtype)
  8242. }
  8243. return fields
  8244. }
  8245. // AddedField returns the numeric value that was incremented/decremented on a field
  8246. // with the given name. The second boolean return value indicates that this field
  8247. // was not set, or was not defined in the schema.
  8248. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  8249. switch name {
  8250. case msg.FieldStatus:
  8251. return m.AddedStatus()
  8252. case msg.FieldMsgtype:
  8253. return m.AddedMsgtype()
  8254. }
  8255. return nil, false
  8256. }
  8257. // AddField adds the value to the field with the given name. It returns an error if
  8258. // the field is not defined in the schema, or if the type mismatched the field
  8259. // type.
  8260. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  8261. switch name {
  8262. case msg.FieldStatus:
  8263. v, ok := value.(int8)
  8264. if !ok {
  8265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8266. }
  8267. m.AddStatus(v)
  8268. return nil
  8269. case msg.FieldMsgtype:
  8270. v, ok := value.(int32)
  8271. if !ok {
  8272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8273. }
  8274. m.AddMsgtype(v)
  8275. return nil
  8276. }
  8277. return fmt.Errorf("unknown Msg numeric field %s", name)
  8278. }
  8279. // ClearedFields returns all nullable fields that were cleared during this
  8280. // mutation.
  8281. func (m *MsgMutation) ClearedFields() []string {
  8282. var fields []string
  8283. if m.FieldCleared(msg.FieldDeletedAt) {
  8284. fields = append(fields, msg.FieldDeletedAt)
  8285. }
  8286. if m.FieldCleared(msg.FieldStatus) {
  8287. fields = append(fields, msg.FieldStatus)
  8288. }
  8289. if m.FieldCleared(msg.FieldFromwxid) {
  8290. fields = append(fields, msg.FieldFromwxid)
  8291. }
  8292. if m.FieldCleared(msg.FieldToid) {
  8293. fields = append(fields, msg.FieldToid)
  8294. }
  8295. if m.FieldCleared(msg.FieldMsgtype) {
  8296. fields = append(fields, msg.FieldMsgtype)
  8297. }
  8298. if m.FieldCleared(msg.FieldMsg) {
  8299. fields = append(fields, msg.FieldMsg)
  8300. }
  8301. if m.FieldCleared(msg.FieldBatchNo) {
  8302. fields = append(fields, msg.FieldBatchNo)
  8303. }
  8304. return fields
  8305. }
  8306. // FieldCleared returns a boolean indicating if a field with the given name was
  8307. // cleared in this mutation.
  8308. func (m *MsgMutation) FieldCleared(name string) bool {
  8309. _, ok := m.clearedFields[name]
  8310. return ok
  8311. }
  8312. // ClearField clears the value of the field with the given name. It returns an
  8313. // error if the field is not defined in the schema.
  8314. func (m *MsgMutation) ClearField(name string) error {
  8315. switch name {
  8316. case msg.FieldDeletedAt:
  8317. m.ClearDeletedAt()
  8318. return nil
  8319. case msg.FieldStatus:
  8320. m.ClearStatus()
  8321. return nil
  8322. case msg.FieldFromwxid:
  8323. m.ClearFromwxid()
  8324. return nil
  8325. case msg.FieldToid:
  8326. m.ClearToid()
  8327. return nil
  8328. case msg.FieldMsgtype:
  8329. m.ClearMsgtype()
  8330. return nil
  8331. case msg.FieldMsg:
  8332. m.ClearMsg()
  8333. return nil
  8334. case msg.FieldBatchNo:
  8335. m.ClearBatchNo()
  8336. return nil
  8337. }
  8338. return fmt.Errorf("unknown Msg nullable field %s", name)
  8339. }
  8340. // ResetField resets all changes in the mutation for the field with the given name.
  8341. // It returns an error if the field is not defined in the schema.
  8342. func (m *MsgMutation) ResetField(name string) error {
  8343. switch name {
  8344. case msg.FieldCreatedAt:
  8345. m.ResetCreatedAt()
  8346. return nil
  8347. case msg.FieldUpdatedAt:
  8348. m.ResetUpdatedAt()
  8349. return nil
  8350. case msg.FieldDeletedAt:
  8351. m.ResetDeletedAt()
  8352. return nil
  8353. case msg.FieldStatus:
  8354. m.ResetStatus()
  8355. return nil
  8356. case msg.FieldFromwxid:
  8357. m.ResetFromwxid()
  8358. return nil
  8359. case msg.FieldToid:
  8360. m.ResetToid()
  8361. return nil
  8362. case msg.FieldMsgtype:
  8363. m.ResetMsgtype()
  8364. return nil
  8365. case msg.FieldMsg:
  8366. m.ResetMsg()
  8367. return nil
  8368. case msg.FieldBatchNo:
  8369. m.ResetBatchNo()
  8370. return nil
  8371. }
  8372. return fmt.Errorf("unknown Msg field %s", name)
  8373. }
  8374. // AddedEdges returns all edge names that were set/added in this mutation.
  8375. func (m *MsgMutation) AddedEdges() []string {
  8376. edges := make([]string, 0, 0)
  8377. return edges
  8378. }
  8379. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8380. // name in this mutation.
  8381. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  8382. return nil
  8383. }
  8384. // RemovedEdges returns all edge names that were removed in this mutation.
  8385. func (m *MsgMutation) RemovedEdges() []string {
  8386. edges := make([]string, 0, 0)
  8387. return edges
  8388. }
  8389. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8390. // the given name in this mutation.
  8391. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  8392. return nil
  8393. }
  8394. // ClearedEdges returns all edge names that were cleared in this mutation.
  8395. func (m *MsgMutation) ClearedEdges() []string {
  8396. edges := make([]string, 0, 0)
  8397. return edges
  8398. }
  8399. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8400. // was cleared in this mutation.
  8401. func (m *MsgMutation) EdgeCleared(name string) bool {
  8402. return false
  8403. }
  8404. // ClearEdge clears the value of the edge with the given name. It returns an error
  8405. // if that edge is not defined in the schema.
  8406. func (m *MsgMutation) ClearEdge(name string) error {
  8407. return fmt.Errorf("unknown Msg unique edge %s", name)
  8408. }
  8409. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8410. // It returns an error if the edge is not defined in the schema.
  8411. func (m *MsgMutation) ResetEdge(name string) error {
  8412. return fmt.Errorf("unknown Msg edge %s", name)
  8413. }
  8414. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  8415. type ServerMutation struct {
  8416. config
  8417. op Op
  8418. typ string
  8419. id *uint64
  8420. created_at *time.Time
  8421. updated_at *time.Time
  8422. status *uint8
  8423. addstatus *int8
  8424. deleted_at *time.Time
  8425. name *string
  8426. public_ip *string
  8427. private_ip *string
  8428. admin_port *string
  8429. clearedFields map[string]struct{}
  8430. wxs map[uint64]struct{}
  8431. removedwxs map[uint64]struct{}
  8432. clearedwxs bool
  8433. done bool
  8434. oldValue func(context.Context) (*Server, error)
  8435. predicates []predicate.Server
  8436. }
  8437. var _ ent.Mutation = (*ServerMutation)(nil)
  8438. // serverOption allows management of the mutation configuration using functional options.
  8439. type serverOption func(*ServerMutation)
  8440. // newServerMutation creates new mutation for the Server entity.
  8441. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  8442. m := &ServerMutation{
  8443. config: c,
  8444. op: op,
  8445. typ: TypeServer,
  8446. clearedFields: make(map[string]struct{}),
  8447. }
  8448. for _, opt := range opts {
  8449. opt(m)
  8450. }
  8451. return m
  8452. }
  8453. // withServerID sets the ID field of the mutation.
  8454. func withServerID(id uint64) serverOption {
  8455. return func(m *ServerMutation) {
  8456. var (
  8457. err error
  8458. once sync.Once
  8459. value *Server
  8460. )
  8461. m.oldValue = func(ctx context.Context) (*Server, error) {
  8462. once.Do(func() {
  8463. if m.done {
  8464. err = errors.New("querying old values post mutation is not allowed")
  8465. } else {
  8466. value, err = m.Client().Server.Get(ctx, id)
  8467. }
  8468. })
  8469. return value, err
  8470. }
  8471. m.id = &id
  8472. }
  8473. }
  8474. // withServer sets the old Server of the mutation.
  8475. func withServer(node *Server) serverOption {
  8476. return func(m *ServerMutation) {
  8477. m.oldValue = func(context.Context) (*Server, error) {
  8478. return node, nil
  8479. }
  8480. m.id = &node.ID
  8481. }
  8482. }
  8483. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8484. // executed in a transaction (ent.Tx), a transactional client is returned.
  8485. func (m ServerMutation) Client() *Client {
  8486. client := &Client{config: m.config}
  8487. client.init()
  8488. return client
  8489. }
  8490. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8491. // it returns an error otherwise.
  8492. func (m ServerMutation) Tx() (*Tx, error) {
  8493. if _, ok := m.driver.(*txDriver); !ok {
  8494. return nil, errors.New("ent: mutation is not running in a transaction")
  8495. }
  8496. tx := &Tx{config: m.config}
  8497. tx.init()
  8498. return tx, nil
  8499. }
  8500. // SetID sets the value of the id field. Note that this
  8501. // operation is only accepted on creation of Server entities.
  8502. func (m *ServerMutation) SetID(id uint64) {
  8503. m.id = &id
  8504. }
  8505. // ID returns the ID value in the mutation. Note that the ID is only available
  8506. // if it was provided to the builder or after it was returned from the database.
  8507. func (m *ServerMutation) ID() (id uint64, exists bool) {
  8508. if m.id == nil {
  8509. return
  8510. }
  8511. return *m.id, true
  8512. }
  8513. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8514. // That means, if the mutation is applied within a transaction with an isolation level such
  8515. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8516. // or updated by the mutation.
  8517. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  8518. switch {
  8519. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8520. id, exists := m.ID()
  8521. if exists {
  8522. return []uint64{id}, nil
  8523. }
  8524. fallthrough
  8525. case m.op.Is(OpUpdate | OpDelete):
  8526. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  8527. default:
  8528. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8529. }
  8530. }
  8531. // SetCreatedAt sets the "created_at" field.
  8532. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  8533. m.created_at = &t
  8534. }
  8535. // CreatedAt returns the value of the "created_at" field in the mutation.
  8536. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  8537. v := m.created_at
  8538. if v == nil {
  8539. return
  8540. }
  8541. return *v, true
  8542. }
  8543. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  8544. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  8545. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8546. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8547. if !m.op.Is(OpUpdateOne) {
  8548. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8549. }
  8550. if m.id == nil || m.oldValue == nil {
  8551. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8552. }
  8553. oldValue, err := m.oldValue(ctx)
  8554. if err != nil {
  8555. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8556. }
  8557. return oldValue.CreatedAt, nil
  8558. }
  8559. // ResetCreatedAt resets all changes to the "created_at" field.
  8560. func (m *ServerMutation) ResetCreatedAt() {
  8561. m.created_at = nil
  8562. }
  8563. // SetUpdatedAt sets the "updated_at" field.
  8564. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  8565. m.updated_at = &t
  8566. }
  8567. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8568. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  8569. v := m.updated_at
  8570. if v == nil {
  8571. return
  8572. }
  8573. return *v, true
  8574. }
  8575. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  8576. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  8577. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8578. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8579. if !m.op.Is(OpUpdateOne) {
  8580. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8581. }
  8582. if m.id == nil || m.oldValue == nil {
  8583. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8584. }
  8585. oldValue, err := m.oldValue(ctx)
  8586. if err != nil {
  8587. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8588. }
  8589. return oldValue.UpdatedAt, nil
  8590. }
  8591. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8592. func (m *ServerMutation) ResetUpdatedAt() {
  8593. m.updated_at = nil
  8594. }
  8595. // SetStatus sets the "status" field.
  8596. func (m *ServerMutation) SetStatus(u uint8) {
  8597. m.status = &u
  8598. m.addstatus = nil
  8599. }
  8600. // Status returns the value of the "status" field in the mutation.
  8601. func (m *ServerMutation) Status() (r uint8, exists bool) {
  8602. v := m.status
  8603. if v == nil {
  8604. return
  8605. }
  8606. return *v, true
  8607. }
  8608. // OldStatus returns the old "status" field's value of the Server entity.
  8609. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  8610. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8611. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  8612. if !m.op.Is(OpUpdateOne) {
  8613. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  8614. }
  8615. if m.id == nil || m.oldValue == nil {
  8616. return v, errors.New("OldStatus requires an ID field in the mutation")
  8617. }
  8618. oldValue, err := m.oldValue(ctx)
  8619. if err != nil {
  8620. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  8621. }
  8622. return oldValue.Status, nil
  8623. }
  8624. // AddStatus adds u to the "status" field.
  8625. func (m *ServerMutation) AddStatus(u int8) {
  8626. if m.addstatus != nil {
  8627. *m.addstatus += u
  8628. } else {
  8629. m.addstatus = &u
  8630. }
  8631. }
  8632. // AddedStatus returns the value that was added to the "status" field in this mutation.
  8633. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  8634. v := m.addstatus
  8635. if v == nil {
  8636. return
  8637. }
  8638. return *v, true
  8639. }
  8640. // ClearStatus clears the value of the "status" field.
  8641. func (m *ServerMutation) ClearStatus() {
  8642. m.status = nil
  8643. m.addstatus = nil
  8644. m.clearedFields[server.FieldStatus] = struct{}{}
  8645. }
  8646. // StatusCleared returns if the "status" field was cleared in this mutation.
  8647. func (m *ServerMutation) StatusCleared() bool {
  8648. _, ok := m.clearedFields[server.FieldStatus]
  8649. return ok
  8650. }
  8651. // ResetStatus resets all changes to the "status" field.
  8652. func (m *ServerMutation) ResetStatus() {
  8653. m.status = nil
  8654. m.addstatus = nil
  8655. delete(m.clearedFields, server.FieldStatus)
  8656. }
  8657. // SetDeletedAt sets the "deleted_at" field.
  8658. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  8659. m.deleted_at = &t
  8660. }
  8661. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8662. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  8663. v := m.deleted_at
  8664. if v == nil {
  8665. return
  8666. }
  8667. return *v, true
  8668. }
  8669. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  8670. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  8671. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8672. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8673. if !m.op.Is(OpUpdateOne) {
  8674. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8675. }
  8676. if m.id == nil || m.oldValue == nil {
  8677. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8678. }
  8679. oldValue, err := m.oldValue(ctx)
  8680. if err != nil {
  8681. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8682. }
  8683. return oldValue.DeletedAt, nil
  8684. }
  8685. // ClearDeletedAt clears the value of the "deleted_at" field.
  8686. func (m *ServerMutation) ClearDeletedAt() {
  8687. m.deleted_at = nil
  8688. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  8689. }
  8690. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8691. func (m *ServerMutation) DeletedAtCleared() bool {
  8692. _, ok := m.clearedFields[server.FieldDeletedAt]
  8693. return ok
  8694. }
  8695. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8696. func (m *ServerMutation) ResetDeletedAt() {
  8697. m.deleted_at = nil
  8698. delete(m.clearedFields, server.FieldDeletedAt)
  8699. }
  8700. // SetName sets the "name" field.
  8701. func (m *ServerMutation) SetName(s string) {
  8702. m.name = &s
  8703. }
  8704. // Name returns the value of the "name" field in the mutation.
  8705. func (m *ServerMutation) Name() (r string, exists bool) {
  8706. v := m.name
  8707. if v == nil {
  8708. return
  8709. }
  8710. return *v, true
  8711. }
  8712. // OldName returns the old "name" field's value of the Server entity.
  8713. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  8714. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8715. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  8716. if !m.op.Is(OpUpdateOne) {
  8717. return v, errors.New("OldName is only allowed on UpdateOne operations")
  8718. }
  8719. if m.id == nil || m.oldValue == nil {
  8720. return v, errors.New("OldName requires an ID field in the mutation")
  8721. }
  8722. oldValue, err := m.oldValue(ctx)
  8723. if err != nil {
  8724. return v, fmt.Errorf("querying old value for OldName: %w", err)
  8725. }
  8726. return oldValue.Name, nil
  8727. }
  8728. // ResetName resets all changes to the "name" field.
  8729. func (m *ServerMutation) ResetName() {
  8730. m.name = nil
  8731. }
  8732. // SetPublicIP sets the "public_ip" field.
  8733. func (m *ServerMutation) SetPublicIP(s string) {
  8734. m.public_ip = &s
  8735. }
  8736. // PublicIP returns the value of the "public_ip" field in the mutation.
  8737. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  8738. v := m.public_ip
  8739. if v == nil {
  8740. return
  8741. }
  8742. return *v, true
  8743. }
  8744. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  8745. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  8746. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8747. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  8748. if !m.op.Is(OpUpdateOne) {
  8749. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  8750. }
  8751. if m.id == nil || m.oldValue == nil {
  8752. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  8753. }
  8754. oldValue, err := m.oldValue(ctx)
  8755. if err != nil {
  8756. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  8757. }
  8758. return oldValue.PublicIP, nil
  8759. }
  8760. // ResetPublicIP resets all changes to the "public_ip" field.
  8761. func (m *ServerMutation) ResetPublicIP() {
  8762. m.public_ip = nil
  8763. }
  8764. // SetPrivateIP sets the "private_ip" field.
  8765. func (m *ServerMutation) SetPrivateIP(s string) {
  8766. m.private_ip = &s
  8767. }
  8768. // PrivateIP returns the value of the "private_ip" field in the mutation.
  8769. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  8770. v := m.private_ip
  8771. if v == nil {
  8772. return
  8773. }
  8774. return *v, true
  8775. }
  8776. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  8777. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  8778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8779. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  8780. if !m.op.Is(OpUpdateOne) {
  8781. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  8782. }
  8783. if m.id == nil || m.oldValue == nil {
  8784. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  8785. }
  8786. oldValue, err := m.oldValue(ctx)
  8787. if err != nil {
  8788. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  8789. }
  8790. return oldValue.PrivateIP, nil
  8791. }
  8792. // ResetPrivateIP resets all changes to the "private_ip" field.
  8793. func (m *ServerMutation) ResetPrivateIP() {
  8794. m.private_ip = nil
  8795. }
  8796. // SetAdminPort sets the "admin_port" field.
  8797. func (m *ServerMutation) SetAdminPort(s string) {
  8798. m.admin_port = &s
  8799. }
  8800. // AdminPort returns the value of the "admin_port" field in the mutation.
  8801. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  8802. v := m.admin_port
  8803. if v == nil {
  8804. return
  8805. }
  8806. return *v, true
  8807. }
  8808. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  8809. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  8810. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8811. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  8812. if !m.op.Is(OpUpdateOne) {
  8813. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  8814. }
  8815. if m.id == nil || m.oldValue == nil {
  8816. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  8817. }
  8818. oldValue, err := m.oldValue(ctx)
  8819. if err != nil {
  8820. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  8821. }
  8822. return oldValue.AdminPort, nil
  8823. }
  8824. // ResetAdminPort resets all changes to the "admin_port" field.
  8825. func (m *ServerMutation) ResetAdminPort() {
  8826. m.admin_port = nil
  8827. }
  8828. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  8829. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  8830. if m.wxs == nil {
  8831. m.wxs = make(map[uint64]struct{})
  8832. }
  8833. for i := range ids {
  8834. m.wxs[ids[i]] = struct{}{}
  8835. }
  8836. }
  8837. // ClearWxs clears the "wxs" edge to the Wx entity.
  8838. func (m *ServerMutation) ClearWxs() {
  8839. m.clearedwxs = true
  8840. }
  8841. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  8842. func (m *ServerMutation) WxsCleared() bool {
  8843. return m.clearedwxs
  8844. }
  8845. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  8846. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  8847. if m.removedwxs == nil {
  8848. m.removedwxs = make(map[uint64]struct{})
  8849. }
  8850. for i := range ids {
  8851. delete(m.wxs, ids[i])
  8852. m.removedwxs[ids[i]] = struct{}{}
  8853. }
  8854. }
  8855. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  8856. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  8857. for id := range m.removedwxs {
  8858. ids = append(ids, id)
  8859. }
  8860. return
  8861. }
  8862. // WxsIDs returns the "wxs" edge IDs in the mutation.
  8863. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  8864. for id := range m.wxs {
  8865. ids = append(ids, id)
  8866. }
  8867. return
  8868. }
  8869. // ResetWxs resets all changes to the "wxs" edge.
  8870. func (m *ServerMutation) ResetWxs() {
  8871. m.wxs = nil
  8872. m.clearedwxs = false
  8873. m.removedwxs = nil
  8874. }
  8875. // Where appends a list predicates to the ServerMutation builder.
  8876. func (m *ServerMutation) Where(ps ...predicate.Server) {
  8877. m.predicates = append(m.predicates, ps...)
  8878. }
  8879. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  8880. // users can use type-assertion to append predicates that do not depend on any generated package.
  8881. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  8882. p := make([]predicate.Server, len(ps))
  8883. for i := range ps {
  8884. p[i] = ps[i]
  8885. }
  8886. m.Where(p...)
  8887. }
  8888. // Op returns the operation name.
  8889. func (m *ServerMutation) Op() Op {
  8890. return m.op
  8891. }
  8892. // SetOp allows setting the mutation operation.
  8893. func (m *ServerMutation) SetOp(op Op) {
  8894. m.op = op
  8895. }
  8896. // Type returns the node type of this mutation (Server).
  8897. func (m *ServerMutation) Type() string {
  8898. return m.typ
  8899. }
  8900. // Fields returns all fields that were changed during this mutation. Note that in
  8901. // order to get all numeric fields that were incremented/decremented, call
  8902. // AddedFields().
  8903. func (m *ServerMutation) Fields() []string {
  8904. fields := make([]string, 0, 8)
  8905. if m.created_at != nil {
  8906. fields = append(fields, server.FieldCreatedAt)
  8907. }
  8908. if m.updated_at != nil {
  8909. fields = append(fields, server.FieldUpdatedAt)
  8910. }
  8911. if m.status != nil {
  8912. fields = append(fields, server.FieldStatus)
  8913. }
  8914. if m.deleted_at != nil {
  8915. fields = append(fields, server.FieldDeletedAt)
  8916. }
  8917. if m.name != nil {
  8918. fields = append(fields, server.FieldName)
  8919. }
  8920. if m.public_ip != nil {
  8921. fields = append(fields, server.FieldPublicIP)
  8922. }
  8923. if m.private_ip != nil {
  8924. fields = append(fields, server.FieldPrivateIP)
  8925. }
  8926. if m.admin_port != nil {
  8927. fields = append(fields, server.FieldAdminPort)
  8928. }
  8929. return fields
  8930. }
  8931. // Field returns the value of a field with the given name. The second boolean
  8932. // return value indicates that this field was not set, or was not defined in the
  8933. // schema.
  8934. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  8935. switch name {
  8936. case server.FieldCreatedAt:
  8937. return m.CreatedAt()
  8938. case server.FieldUpdatedAt:
  8939. return m.UpdatedAt()
  8940. case server.FieldStatus:
  8941. return m.Status()
  8942. case server.FieldDeletedAt:
  8943. return m.DeletedAt()
  8944. case server.FieldName:
  8945. return m.Name()
  8946. case server.FieldPublicIP:
  8947. return m.PublicIP()
  8948. case server.FieldPrivateIP:
  8949. return m.PrivateIP()
  8950. case server.FieldAdminPort:
  8951. return m.AdminPort()
  8952. }
  8953. return nil, false
  8954. }
  8955. // OldField returns the old value of the field from the database. An error is
  8956. // returned if the mutation operation is not UpdateOne, or the query to the
  8957. // database failed.
  8958. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8959. switch name {
  8960. case server.FieldCreatedAt:
  8961. return m.OldCreatedAt(ctx)
  8962. case server.FieldUpdatedAt:
  8963. return m.OldUpdatedAt(ctx)
  8964. case server.FieldStatus:
  8965. return m.OldStatus(ctx)
  8966. case server.FieldDeletedAt:
  8967. return m.OldDeletedAt(ctx)
  8968. case server.FieldName:
  8969. return m.OldName(ctx)
  8970. case server.FieldPublicIP:
  8971. return m.OldPublicIP(ctx)
  8972. case server.FieldPrivateIP:
  8973. return m.OldPrivateIP(ctx)
  8974. case server.FieldAdminPort:
  8975. return m.OldAdminPort(ctx)
  8976. }
  8977. return nil, fmt.Errorf("unknown Server field %s", name)
  8978. }
  8979. // SetField sets the value of a field with the given name. It returns an error if
  8980. // the field is not defined in the schema, or if the type mismatched the field
  8981. // type.
  8982. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  8983. switch name {
  8984. case server.FieldCreatedAt:
  8985. v, ok := value.(time.Time)
  8986. if !ok {
  8987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8988. }
  8989. m.SetCreatedAt(v)
  8990. return nil
  8991. case server.FieldUpdatedAt:
  8992. v, ok := value.(time.Time)
  8993. if !ok {
  8994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8995. }
  8996. m.SetUpdatedAt(v)
  8997. return nil
  8998. case server.FieldStatus:
  8999. v, ok := value.(uint8)
  9000. if !ok {
  9001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9002. }
  9003. m.SetStatus(v)
  9004. return nil
  9005. case server.FieldDeletedAt:
  9006. v, ok := value.(time.Time)
  9007. if !ok {
  9008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9009. }
  9010. m.SetDeletedAt(v)
  9011. return nil
  9012. case server.FieldName:
  9013. v, ok := value.(string)
  9014. if !ok {
  9015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9016. }
  9017. m.SetName(v)
  9018. return nil
  9019. case server.FieldPublicIP:
  9020. v, ok := value.(string)
  9021. if !ok {
  9022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9023. }
  9024. m.SetPublicIP(v)
  9025. return nil
  9026. case server.FieldPrivateIP:
  9027. v, ok := value.(string)
  9028. if !ok {
  9029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9030. }
  9031. m.SetPrivateIP(v)
  9032. return nil
  9033. case server.FieldAdminPort:
  9034. v, ok := value.(string)
  9035. if !ok {
  9036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9037. }
  9038. m.SetAdminPort(v)
  9039. return nil
  9040. }
  9041. return fmt.Errorf("unknown Server field %s", name)
  9042. }
  9043. // AddedFields returns all numeric fields that were incremented/decremented during
  9044. // this mutation.
  9045. func (m *ServerMutation) AddedFields() []string {
  9046. var fields []string
  9047. if m.addstatus != nil {
  9048. fields = append(fields, server.FieldStatus)
  9049. }
  9050. return fields
  9051. }
  9052. // AddedField returns the numeric value that was incremented/decremented on a field
  9053. // with the given name. The second boolean return value indicates that this field
  9054. // was not set, or was not defined in the schema.
  9055. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  9056. switch name {
  9057. case server.FieldStatus:
  9058. return m.AddedStatus()
  9059. }
  9060. return nil, false
  9061. }
  9062. // AddField adds the value to the field with the given name. It returns an error if
  9063. // the field is not defined in the schema, or if the type mismatched the field
  9064. // type.
  9065. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  9066. switch name {
  9067. case server.FieldStatus:
  9068. v, ok := value.(int8)
  9069. if !ok {
  9070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9071. }
  9072. m.AddStatus(v)
  9073. return nil
  9074. }
  9075. return fmt.Errorf("unknown Server numeric field %s", name)
  9076. }
  9077. // ClearedFields returns all nullable fields that were cleared during this
  9078. // mutation.
  9079. func (m *ServerMutation) ClearedFields() []string {
  9080. var fields []string
  9081. if m.FieldCleared(server.FieldStatus) {
  9082. fields = append(fields, server.FieldStatus)
  9083. }
  9084. if m.FieldCleared(server.FieldDeletedAt) {
  9085. fields = append(fields, server.FieldDeletedAt)
  9086. }
  9087. return fields
  9088. }
  9089. // FieldCleared returns a boolean indicating if a field with the given name was
  9090. // cleared in this mutation.
  9091. func (m *ServerMutation) FieldCleared(name string) bool {
  9092. _, ok := m.clearedFields[name]
  9093. return ok
  9094. }
  9095. // ClearField clears the value of the field with the given name. It returns an
  9096. // error if the field is not defined in the schema.
  9097. func (m *ServerMutation) ClearField(name string) error {
  9098. switch name {
  9099. case server.FieldStatus:
  9100. m.ClearStatus()
  9101. return nil
  9102. case server.FieldDeletedAt:
  9103. m.ClearDeletedAt()
  9104. return nil
  9105. }
  9106. return fmt.Errorf("unknown Server nullable field %s", name)
  9107. }
  9108. // ResetField resets all changes in the mutation for the field with the given name.
  9109. // It returns an error if the field is not defined in the schema.
  9110. func (m *ServerMutation) ResetField(name string) error {
  9111. switch name {
  9112. case server.FieldCreatedAt:
  9113. m.ResetCreatedAt()
  9114. return nil
  9115. case server.FieldUpdatedAt:
  9116. m.ResetUpdatedAt()
  9117. return nil
  9118. case server.FieldStatus:
  9119. m.ResetStatus()
  9120. return nil
  9121. case server.FieldDeletedAt:
  9122. m.ResetDeletedAt()
  9123. return nil
  9124. case server.FieldName:
  9125. m.ResetName()
  9126. return nil
  9127. case server.FieldPublicIP:
  9128. m.ResetPublicIP()
  9129. return nil
  9130. case server.FieldPrivateIP:
  9131. m.ResetPrivateIP()
  9132. return nil
  9133. case server.FieldAdminPort:
  9134. m.ResetAdminPort()
  9135. return nil
  9136. }
  9137. return fmt.Errorf("unknown Server field %s", name)
  9138. }
  9139. // AddedEdges returns all edge names that were set/added in this mutation.
  9140. func (m *ServerMutation) AddedEdges() []string {
  9141. edges := make([]string, 0, 1)
  9142. if m.wxs != nil {
  9143. edges = append(edges, server.EdgeWxs)
  9144. }
  9145. return edges
  9146. }
  9147. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9148. // name in this mutation.
  9149. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  9150. switch name {
  9151. case server.EdgeWxs:
  9152. ids := make([]ent.Value, 0, len(m.wxs))
  9153. for id := range m.wxs {
  9154. ids = append(ids, id)
  9155. }
  9156. return ids
  9157. }
  9158. return nil
  9159. }
  9160. // RemovedEdges returns all edge names that were removed in this mutation.
  9161. func (m *ServerMutation) RemovedEdges() []string {
  9162. edges := make([]string, 0, 1)
  9163. if m.removedwxs != nil {
  9164. edges = append(edges, server.EdgeWxs)
  9165. }
  9166. return edges
  9167. }
  9168. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9169. // the given name in this mutation.
  9170. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  9171. switch name {
  9172. case server.EdgeWxs:
  9173. ids := make([]ent.Value, 0, len(m.removedwxs))
  9174. for id := range m.removedwxs {
  9175. ids = append(ids, id)
  9176. }
  9177. return ids
  9178. }
  9179. return nil
  9180. }
  9181. // ClearedEdges returns all edge names that were cleared in this mutation.
  9182. func (m *ServerMutation) ClearedEdges() []string {
  9183. edges := make([]string, 0, 1)
  9184. if m.clearedwxs {
  9185. edges = append(edges, server.EdgeWxs)
  9186. }
  9187. return edges
  9188. }
  9189. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9190. // was cleared in this mutation.
  9191. func (m *ServerMutation) EdgeCleared(name string) bool {
  9192. switch name {
  9193. case server.EdgeWxs:
  9194. return m.clearedwxs
  9195. }
  9196. return false
  9197. }
  9198. // ClearEdge clears the value of the edge with the given name. It returns an error
  9199. // if that edge is not defined in the schema.
  9200. func (m *ServerMutation) ClearEdge(name string) error {
  9201. switch name {
  9202. }
  9203. return fmt.Errorf("unknown Server unique edge %s", name)
  9204. }
  9205. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9206. // It returns an error if the edge is not defined in the schema.
  9207. func (m *ServerMutation) ResetEdge(name string) error {
  9208. switch name {
  9209. case server.EdgeWxs:
  9210. m.ResetWxs()
  9211. return nil
  9212. }
  9213. return fmt.Errorf("unknown Server edge %s", name)
  9214. }
  9215. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  9216. type SopNodeMutation struct {
  9217. config
  9218. op Op
  9219. typ string
  9220. id *uint64
  9221. created_at *time.Time
  9222. updated_at *time.Time
  9223. status *uint8
  9224. addstatus *int8
  9225. deleted_at *time.Time
  9226. parent_id *uint64
  9227. addparent_id *int64
  9228. name *string
  9229. condition_type *int
  9230. addcondition_type *int
  9231. condition_list *[]string
  9232. appendcondition_list []string
  9233. no_reply_condition *uint64
  9234. addno_reply_condition *int64
  9235. action_message *[]custom_types.Action
  9236. appendaction_message []custom_types.Action
  9237. action_label *[]uint64
  9238. appendaction_label []uint64
  9239. clearedFields map[string]struct{}
  9240. sop_stage *uint64
  9241. clearedsop_stage bool
  9242. node_messages map[uint64]struct{}
  9243. removednode_messages map[uint64]struct{}
  9244. clearednode_messages bool
  9245. done bool
  9246. oldValue func(context.Context) (*SopNode, error)
  9247. predicates []predicate.SopNode
  9248. }
  9249. var _ ent.Mutation = (*SopNodeMutation)(nil)
  9250. // sopnodeOption allows management of the mutation configuration using functional options.
  9251. type sopnodeOption func(*SopNodeMutation)
  9252. // newSopNodeMutation creates new mutation for the SopNode entity.
  9253. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  9254. m := &SopNodeMutation{
  9255. config: c,
  9256. op: op,
  9257. typ: TypeSopNode,
  9258. clearedFields: make(map[string]struct{}),
  9259. }
  9260. for _, opt := range opts {
  9261. opt(m)
  9262. }
  9263. return m
  9264. }
  9265. // withSopNodeID sets the ID field of the mutation.
  9266. func withSopNodeID(id uint64) sopnodeOption {
  9267. return func(m *SopNodeMutation) {
  9268. var (
  9269. err error
  9270. once sync.Once
  9271. value *SopNode
  9272. )
  9273. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  9274. once.Do(func() {
  9275. if m.done {
  9276. err = errors.New("querying old values post mutation is not allowed")
  9277. } else {
  9278. value, err = m.Client().SopNode.Get(ctx, id)
  9279. }
  9280. })
  9281. return value, err
  9282. }
  9283. m.id = &id
  9284. }
  9285. }
  9286. // withSopNode sets the old SopNode of the mutation.
  9287. func withSopNode(node *SopNode) sopnodeOption {
  9288. return func(m *SopNodeMutation) {
  9289. m.oldValue = func(context.Context) (*SopNode, error) {
  9290. return node, nil
  9291. }
  9292. m.id = &node.ID
  9293. }
  9294. }
  9295. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9296. // executed in a transaction (ent.Tx), a transactional client is returned.
  9297. func (m SopNodeMutation) Client() *Client {
  9298. client := &Client{config: m.config}
  9299. client.init()
  9300. return client
  9301. }
  9302. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9303. // it returns an error otherwise.
  9304. func (m SopNodeMutation) Tx() (*Tx, error) {
  9305. if _, ok := m.driver.(*txDriver); !ok {
  9306. return nil, errors.New("ent: mutation is not running in a transaction")
  9307. }
  9308. tx := &Tx{config: m.config}
  9309. tx.init()
  9310. return tx, nil
  9311. }
  9312. // SetID sets the value of the id field. Note that this
  9313. // operation is only accepted on creation of SopNode entities.
  9314. func (m *SopNodeMutation) SetID(id uint64) {
  9315. m.id = &id
  9316. }
  9317. // ID returns the ID value in the mutation. Note that the ID is only available
  9318. // if it was provided to the builder or after it was returned from the database.
  9319. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  9320. if m.id == nil {
  9321. return
  9322. }
  9323. return *m.id, true
  9324. }
  9325. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9326. // That means, if the mutation is applied within a transaction with an isolation level such
  9327. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9328. // or updated by the mutation.
  9329. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  9330. switch {
  9331. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9332. id, exists := m.ID()
  9333. if exists {
  9334. return []uint64{id}, nil
  9335. }
  9336. fallthrough
  9337. case m.op.Is(OpUpdate | OpDelete):
  9338. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  9339. default:
  9340. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9341. }
  9342. }
  9343. // SetCreatedAt sets the "created_at" field.
  9344. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  9345. m.created_at = &t
  9346. }
  9347. // CreatedAt returns the value of the "created_at" field in the mutation.
  9348. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  9349. v := m.created_at
  9350. if v == nil {
  9351. return
  9352. }
  9353. return *v, true
  9354. }
  9355. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  9356. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9357. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9358. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9359. if !m.op.Is(OpUpdateOne) {
  9360. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9361. }
  9362. if m.id == nil || m.oldValue == nil {
  9363. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9364. }
  9365. oldValue, err := m.oldValue(ctx)
  9366. if err != nil {
  9367. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9368. }
  9369. return oldValue.CreatedAt, nil
  9370. }
  9371. // ResetCreatedAt resets all changes to the "created_at" field.
  9372. func (m *SopNodeMutation) ResetCreatedAt() {
  9373. m.created_at = nil
  9374. }
  9375. // SetUpdatedAt sets the "updated_at" field.
  9376. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  9377. m.updated_at = &t
  9378. }
  9379. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9380. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  9381. v := m.updated_at
  9382. if v == nil {
  9383. return
  9384. }
  9385. return *v, true
  9386. }
  9387. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  9388. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9389. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9390. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9391. if !m.op.Is(OpUpdateOne) {
  9392. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9393. }
  9394. if m.id == nil || m.oldValue == nil {
  9395. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9396. }
  9397. oldValue, err := m.oldValue(ctx)
  9398. if err != nil {
  9399. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9400. }
  9401. return oldValue.UpdatedAt, nil
  9402. }
  9403. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9404. func (m *SopNodeMutation) ResetUpdatedAt() {
  9405. m.updated_at = nil
  9406. }
  9407. // SetStatus sets the "status" field.
  9408. func (m *SopNodeMutation) SetStatus(u uint8) {
  9409. m.status = &u
  9410. m.addstatus = nil
  9411. }
  9412. // Status returns the value of the "status" field in the mutation.
  9413. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  9414. v := m.status
  9415. if v == nil {
  9416. return
  9417. }
  9418. return *v, true
  9419. }
  9420. // OldStatus returns the old "status" field's value of the SopNode entity.
  9421. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9422. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9423. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  9424. if !m.op.Is(OpUpdateOne) {
  9425. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9426. }
  9427. if m.id == nil || m.oldValue == nil {
  9428. return v, errors.New("OldStatus requires an ID field in the mutation")
  9429. }
  9430. oldValue, err := m.oldValue(ctx)
  9431. if err != nil {
  9432. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9433. }
  9434. return oldValue.Status, nil
  9435. }
  9436. // AddStatus adds u to the "status" field.
  9437. func (m *SopNodeMutation) AddStatus(u int8) {
  9438. if m.addstatus != nil {
  9439. *m.addstatus += u
  9440. } else {
  9441. m.addstatus = &u
  9442. }
  9443. }
  9444. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9445. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  9446. v := m.addstatus
  9447. if v == nil {
  9448. return
  9449. }
  9450. return *v, true
  9451. }
  9452. // ClearStatus clears the value of the "status" field.
  9453. func (m *SopNodeMutation) ClearStatus() {
  9454. m.status = nil
  9455. m.addstatus = nil
  9456. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  9457. }
  9458. // StatusCleared returns if the "status" field was cleared in this mutation.
  9459. func (m *SopNodeMutation) StatusCleared() bool {
  9460. _, ok := m.clearedFields[sopnode.FieldStatus]
  9461. return ok
  9462. }
  9463. // ResetStatus resets all changes to the "status" field.
  9464. func (m *SopNodeMutation) ResetStatus() {
  9465. m.status = nil
  9466. m.addstatus = nil
  9467. delete(m.clearedFields, sopnode.FieldStatus)
  9468. }
  9469. // SetDeletedAt sets the "deleted_at" field.
  9470. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  9471. m.deleted_at = &t
  9472. }
  9473. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9474. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  9475. v := m.deleted_at
  9476. if v == nil {
  9477. return
  9478. }
  9479. return *v, true
  9480. }
  9481. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  9482. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9483. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9484. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9485. if !m.op.Is(OpUpdateOne) {
  9486. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9487. }
  9488. if m.id == nil || m.oldValue == nil {
  9489. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9490. }
  9491. oldValue, err := m.oldValue(ctx)
  9492. if err != nil {
  9493. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9494. }
  9495. return oldValue.DeletedAt, nil
  9496. }
  9497. // ClearDeletedAt clears the value of the "deleted_at" field.
  9498. func (m *SopNodeMutation) ClearDeletedAt() {
  9499. m.deleted_at = nil
  9500. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  9501. }
  9502. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9503. func (m *SopNodeMutation) DeletedAtCleared() bool {
  9504. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  9505. return ok
  9506. }
  9507. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9508. func (m *SopNodeMutation) ResetDeletedAt() {
  9509. m.deleted_at = nil
  9510. delete(m.clearedFields, sopnode.FieldDeletedAt)
  9511. }
  9512. // SetStageID sets the "stage_id" field.
  9513. func (m *SopNodeMutation) SetStageID(u uint64) {
  9514. m.sop_stage = &u
  9515. }
  9516. // StageID returns the value of the "stage_id" field in the mutation.
  9517. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  9518. v := m.sop_stage
  9519. if v == nil {
  9520. return
  9521. }
  9522. return *v, true
  9523. }
  9524. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  9525. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9526. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9527. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  9528. if !m.op.Is(OpUpdateOne) {
  9529. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  9530. }
  9531. if m.id == nil || m.oldValue == nil {
  9532. return v, errors.New("OldStageID requires an ID field in the mutation")
  9533. }
  9534. oldValue, err := m.oldValue(ctx)
  9535. if err != nil {
  9536. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  9537. }
  9538. return oldValue.StageID, nil
  9539. }
  9540. // ResetStageID resets all changes to the "stage_id" field.
  9541. func (m *SopNodeMutation) ResetStageID() {
  9542. m.sop_stage = nil
  9543. }
  9544. // SetParentID sets the "parent_id" field.
  9545. func (m *SopNodeMutation) SetParentID(u uint64) {
  9546. m.parent_id = &u
  9547. m.addparent_id = nil
  9548. }
  9549. // ParentID returns the value of the "parent_id" field in the mutation.
  9550. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  9551. v := m.parent_id
  9552. if v == nil {
  9553. return
  9554. }
  9555. return *v, true
  9556. }
  9557. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  9558. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9559. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9560. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  9561. if !m.op.Is(OpUpdateOne) {
  9562. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  9563. }
  9564. if m.id == nil || m.oldValue == nil {
  9565. return v, errors.New("OldParentID requires an ID field in the mutation")
  9566. }
  9567. oldValue, err := m.oldValue(ctx)
  9568. if err != nil {
  9569. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  9570. }
  9571. return oldValue.ParentID, nil
  9572. }
  9573. // AddParentID adds u to the "parent_id" field.
  9574. func (m *SopNodeMutation) AddParentID(u int64) {
  9575. if m.addparent_id != nil {
  9576. *m.addparent_id += u
  9577. } else {
  9578. m.addparent_id = &u
  9579. }
  9580. }
  9581. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  9582. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  9583. v := m.addparent_id
  9584. if v == nil {
  9585. return
  9586. }
  9587. return *v, true
  9588. }
  9589. // ResetParentID resets all changes to the "parent_id" field.
  9590. func (m *SopNodeMutation) ResetParentID() {
  9591. m.parent_id = nil
  9592. m.addparent_id = nil
  9593. }
  9594. // SetName sets the "name" field.
  9595. func (m *SopNodeMutation) SetName(s string) {
  9596. m.name = &s
  9597. }
  9598. // Name returns the value of the "name" field in the mutation.
  9599. func (m *SopNodeMutation) Name() (r string, exists bool) {
  9600. v := m.name
  9601. if v == nil {
  9602. return
  9603. }
  9604. return *v, true
  9605. }
  9606. // OldName returns the old "name" field's value of the SopNode entity.
  9607. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9608. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9609. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  9610. if !m.op.Is(OpUpdateOne) {
  9611. return v, errors.New("OldName is only allowed on UpdateOne operations")
  9612. }
  9613. if m.id == nil || m.oldValue == nil {
  9614. return v, errors.New("OldName requires an ID field in the mutation")
  9615. }
  9616. oldValue, err := m.oldValue(ctx)
  9617. if err != nil {
  9618. return v, fmt.Errorf("querying old value for OldName: %w", err)
  9619. }
  9620. return oldValue.Name, nil
  9621. }
  9622. // ResetName resets all changes to the "name" field.
  9623. func (m *SopNodeMutation) ResetName() {
  9624. m.name = nil
  9625. }
  9626. // SetConditionType sets the "condition_type" field.
  9627. func (m *SopNodeMutation) SetConditionType(i int) {
  9628. m.condition_type = &i
  9629. m.addcondition_type = nil
  9630. }
  9631. // ConditionType returns the value of the "condition_type" field in the mutation.
  9632. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  9633. v := m.condition_type
  9634. if v == nil {
  9635. return
  9636. }
  9637. return *v, true
  9638. }
  9639. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  9640. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9641. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9642. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  9643. if !m.op.Is(OpUpdateOne) {
  9644. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  9645. }
  9646. if m.id == nil || m.oldValue == nil {
  9647. return v, errors.New("OldConditionType requires an ID field in the mutation")
  9648. }
  9649. oldValue, err := m.oldValue(ctx)
  9650. if err != nil {
  9651. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  9652. }
  9653. return oldValue.ConditionType, nil
  9654. }
  9655. // AddConditionType adds i to the "condition_type" field.
  9656. func (m *SopNodeMutation) AddConditionType(i int) {
  9657. if m.addcondition_type != nil {
  9658. *m.addcondition_type += i
  9659. } else {
  9660. m.addcondition_type = &i
  9661. }
  9662. }
  9663. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  9664. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  9665. v := m.addcondition_type
  9666. if v == nil {
  9667. return
  9668. }
  9669. return *v, true
  9670. }
  9671. // ResetConditionType resets all changes to the "condition_type" field.
  9672. func (m *SopNodeMutation) ResetConditionType() {
  9673. m.condition_type = nil
  9674. m.addcondition_type = nil
  9675. }
  9676. // SetConditionList sets the "condition_list" field.
  9677. func (m *SopNodeMutation) SetConditionList(s []string) {
  9678. m.condition_list = &s
  9679. m.appendcondition_list = nil
  9680. }
  9681. // ConditionList returns the value of the "condition_list" field in the mutation.
  9682. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  9683. v := m.condition_list
  9684. if v == nil {
  9685. return
  9686. }
  9687. return *v, true
  9688. }
  9689. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  9690. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9691. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9692. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  9693. if !m.op.Is(OpUpdateOne) {
  9694. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  9695. }
  9696. if m.id == nil || m.oldValue == nil {
  9697. return v, errors.New("OldConditionList requires an ID field in the mutation")
  9698. }
  9699. oldValue, err := m.oldValue(ctx)
  9700. if err != nil {
  9701. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  9702. }
  9703. return oldValue.ConditionList, nil
  9704. }
  9705. // AppendConditionList adds s to the "condition_list" field.
  9706. func (m *SopNodeMutation) AppendConditionList(s []string) {
  9707. m.appendcondition_list = append(m.appendcondition_list, s...)
  9708. }
  9709. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  9710. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  9711. if len(m.appendcondition_list) == 0 {
  9712. return nil, false
  9713. }
  9714. return m.appendcondition_list, true
  9715. }
  9716. // ClearConditionList clears the value of the "condition_list" field.
  9717. func (m *SopNodeMutation) ClearConditionList() {
  9718. m.condition_list = nil
  9719. m.appendcondition_list = nil
  9720. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  9721. }
  9722. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  9723. func (m *SopNodeMutation) ConditionListCleared() bool {
  9724. _, ok := m.clearedFields[sopnode.FieldConditionList]
  9725. return ok
  9726. }
  9727. // ResetConditionList resets all changes to the "condition_list" field.
  9728. func (m *SopNodeMutation) ResetConditionList() {
  9729. m.condition_list = nil
  9730. m.appendcondition_list = nil
  9731. delete(m.clearedFields, sopnode.FieldConditionList)
  9732. }
  9733. // SetNoReplyCondition sets the "no_reply_condition" field.
  9734. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  9735. m.no_reply_condition = &u
  9736. m.addno_reply_condition = nil
  9737. }
  9738. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  9739. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  9740. v := m.no_reply_condition
  9741. if v == nil {
  9742. return
  9743. }
  9744. return *v, true
  9745. }
  9746. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  9747. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9748. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9749. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  9750. if !m.op.Is(OpUpdateOne) {
  9751. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  9752. }
  9753. if m.id == nil || m.oldValue == nil {
  9754. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  9755. }
  9756. oldValue, err := m.oldValue(ctx)
  9757. if err != nil {
  9758. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  9759. }
  9760. return oldValue.NoReplyCondition, nil
  9761. }
  9762. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  9763. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  9764. if m.addno_reply_condition != nil {
  9765. *m.addno_reply_condition += u
  9766. } else {
  9767. m.addno_reply_condition = &u
  9768. }
  9769. }
  9770. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  9771. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  9772. v := m.addno_reply_condition
  9773. if v == nil {
  9774. return
  9775. }
  9776. return *v, true
  9777. }
  9778. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  9779. func (m *SopNodeMutation) ResetNoReplyCondition() {
  9780. m.no_reply_condition = nil
  9781. m.addno_reply_condition = nil
  9782. }
  9783. // SetActionMessage sets the "action_message" field.
  9784. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  9785. m.action_message = &ct
  9786. m.appendaction_message = nil
  9787. }
  9788. // ActionMessage returns the value of the "action_message" field in the mutation.
  9789. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  9790. v := m.action_message
  9791. if v == nil {
  9792. return
  9793. }
  9794. return *v, true
  9795. }
  9796. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  9797. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9798. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9799. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  9800. if !m.op.Is(OpUpdateOne) {
  9801. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  9802. }
  9803. if m.id == nil || m.oldValue == nil {
  9804. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  9805. }
  9806. oldValue, err := m.oldValue(ctx)
  9807. if err != nil {
  9808. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  9809. }
  9810. return oldValue.ActionMessage, nil
  9811. }
  9812. // AppendActionMessage adds ct to the "action_message" field.
  9813. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  9814. m.appendaction_message = append(m.appendaction_message, ct...)
  9815. }
  9816. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  9817. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  9818. if len(m.appendaction_message) == 0 {
  9819. return nil, false
  9820. }
  9821. return m.appendaction_message, true
  9822. }
  9823. // ClearActionMessage clears the value of the "action_message" field.
  9824. func (m *SopNodeMutation) ClearActionMessage() {
  9825. m.action_message = nil
  9826. m.appendaction_message = nil
  9827. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  9828. }
  9829. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  9830. func (m *SopNodeMutation) ActionMessageCleared() bool {
  9831. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  9832. return ok
  9833. }
  9834. // ResetActionMessage resets all changes to the "action_message" field.
  9835. func (m *SopNodeMutation) ResetActionMessage() {
  9836. m.action_message = nil
  9837. m.appendaction_message = nil
  9838. delete(m.clearedFields, sopnode.FieldActionMessage)
  9839. }
  9840. // SetActionLabel sets the "action_label" field.
  9841. func (m *SopNodeMutation) SetActionLabel(u []uint64) {
  9842. m.action_label = &u
  9843. m.appendaction_label = nil
  9844. }
  9845. // ActionLabel returns the value of the "action_label" field in the mutation.
  9846. func (m *SopNodeMutation) ActionLabel() (r []uint64, exists bool) {
  9847. v := m.action_label
  9848. if v == nil {
  9849. return
  9850. }
  9851. return *v, true
  9852. }
  9853. // OldActionLabel returns the old "action_label" field's value of the SopNode entity.
  9854. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  9855. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9856. func (m *SopNodeMutation) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  9857. if !m.op.Is(OpUpdateOne) {
  9858. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  9859. }
  9860. if m.id == nil || m.oldValue == nil {
  9861. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  9862. }
  9863. oldValue, err := m.oldValue(ctx)
  9864. if err != nil {
  9865. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  9866. }
  9867. return oldValue.ActionLabel, nil
  9868. }
  9869. // AppendActionLabel adds u to the "action_label" field.
  9870. func (m *SopNodeMutation) AppendActionLabel(u []uint64) {
  9871. m.appendaction_label = append(m.appendaction_label, u...)
  9872. }
  9873. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  9874. func (m *SopNodeMutation) AppendedActionLabel() ([]uint64, bool) {
  9875. if len(m.appendaction_label) == 0 {
  9876. return nil, false
  9877. }
  9878. return m.appendaction_label, true
  9879. }
  9880. // ClearActionLabel clears the value of the "action_label" field.
  9881. func (m *SopNodeMutation) ClearActionLabel() {
  9882. m.action_label = nil
  9883. m.appendaction_label = nil
  9884. m.clearedFields[sopnode.FieldActionLabel] = struct{}{}
  9885. }
  9886. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  9887. func (m *SopNodeMutation) ActionLabelCleared() bool {
  9888. _, ok := m.clearedFields[sopnode.FieldActionLabel]
  9889. return ok
  9890. }
  9891. // ResetActionLabel resets all changes to the "action_label" field.
  9892. func (m *SopNodeMutation) ResetActionLabel() {
  9893. m.action_label = nil
  9894. m.appendaction_label = nil
  9895. delete(m.clearedFields, sopnode.FieldActionLabel)
  9896. }
  9897. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  9898. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  9899. m.sop_stage = &id
  9900. }
  9901. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  9902. func (m *SopNodeMutation) ClearSopStage() {
  9903. m.clearedsop_stage = true
  9904. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  9905. }
  9906. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  9907. func (m *SopNodeMutation) SopStageCleared() bool {
  9908. return m.clearedsop_stage
  9909. }
  9910. // SopStageID returns the "sop_stage" edge ID in the mutation.
  9911. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  9912. if m.sop_stage != nil {
  9913. return *m.sop_stage, true
  9914. }
  9915. return
  9916. }
  9917. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  9918. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  9919. // SopStageID instead. It exists only for internal usage by the builders.
  9920. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  9921. if id := m.sop_stage; id != nil {
  9922. ids = append(ids, *id)
  9923. }
  9924. return
  9925. }
  9926. // ResetSopStage resets all changes to the "sop_stage" edge.
  9927. func (m *SopNodeMutation) ResetSopStage() {
  9928. m.sop_stage = nil
  9929. m.clearedsop_stage = false
  9930. }
  9931. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  9932. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  9933. if m.node_messages == nil {
  9934. m.node_messages = make(map[uint64]struct{})
  9935. }
  9936. for i := range ids {
  9937. m.node_messages[ids[i]] = struct{}{}
  9938. }
  9939. }
  9940. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  9941. func (m *SopNodeMutation) ClearNodeMessages() {
  9942. m.clearednode_messages = true
  9943. }
  9944. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  9945. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  9946. return m.clearednode_messages
  9947. }
  9948. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  9949. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  9950. if m.removednode_messages == nil {
  9951. m.removednode_messages = make(map[uint64]struct{})
  9952. }
  9953. for i := range ids {
  9954. delete(m.node_messages, ids[i])
  9955. m.removednode_messages[ids[i]] = struct{}{}
  9956. }
  9957. }
  9958. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  9959. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  9960. for id := range m.removednode_messages {
  9961. ids = append(ids, id)
  9962. }
  9963. return
  9964. }
  9965. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  9966. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  9967. for id := range m.node_messages {
  9968. ids = append(ids, id)
  9969. }
  9970. return
  9971. }
  9972. // ResetNodeMessages resets all changes to the "node_messages" edge.
  9973. func (m *SopNodeMutation) ResetNodeMessages() {
  9974. m.node_messages = nil
  9975. m.clearednode_messages = false
  9976. m.removednode_messages = nil
  9977. }
  9978. // Where appends a list predicates to the SopNodeMutation builder.
  9979. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  9980. m.predicates = append(m.predicates, ps...)
  9981. }
  9982. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  9983. // users can use type-assertion to append predicates that do not depend on any generated package.
  9984. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  9985. p := make([]predicate.SopNode, len(ps))
  9986. for i := range ps {
  9987. p[i] = ps[i]
  9988. }
  9989. m.Where(p...)
  9990. }
  9991. // Op returns the operation name.
  9992. func (m *SopNodeMutation) Op() Op {
  9993. return m.op
  9994. }
  9995. // SetOp allows setting the mutation operation.
  9996. func (m *SopNodeMutation) SetOp(op Op) {
  9997. m.op = op
  9998. }
  9999. // Type returns the node type of this mutation (SopNode).
  10000. func (m *SopNodeMutation) Type() string {
  10001. return m.typ
  10002. }
  10003. // Fields returns all fields that were changed during this mutation. Note that in
  10004. // order to get all numeric fields that were incremented/decremented, call
  10005. // AddedFields().
  10006. func (m *SopNodeMutation) Fields() []string {
  10007. fields := make([]string, 0, 12)
  10008. if m.created_at != nil {
  10009. fields = append(fields, sopnode.FieldCreatedAt)
  10010. }
  10011. if m.updated_at != nil {
  10012. fields = append(fields, sopnode.FieldUpdatedAt)
  10013. }
  10014. if m.status != nil {
  10015. fields = append(fields, sopnode.FieldStatus)
  10016. }
  10017. if m.deleted_at != nil {
  10018. fields = append(fields, sopnode.FieldDeletedAt)
  10019. }
  10020. if m.sop_stage != nil {
  10021. fields = append(fields, sopnode.FieldStageID)
  10022. }
  10023. if m.parent_id != nil {
  10024. fields = append(fields, sopnode.FieldParentID)
  10025. }
  10026. if m.name != nil {
  10027. fields = append(fields, sopnode.FieldName)
  10028. }
  10029. if m.condition_type != nil {
  10030. fields = append(fields, sopnode.FieldConditionType)
  10031. }
  10032. if m.condition_list != nil {
  10033. fields = append(fields, sopnode.FieldConditionList)
  10034. }
  10035. if m.no_reply_condition != nil {
  10036. fields = append(fields, sopnode.FieldNoReplyCondition)
  10037. }
  10038. if m.action_message != nil {
  10039. fields = append(fields, sopnode.FieldActionMessage)
  10040. }
  10041. if m.action_label != nil {
  10042. fields = append(fields, sopnode.FieldActionLabel)
  10043. }
  10044. return fields
  10045. }
  10046. // Field returns the value of a field with the given name. The second boolean
  10047. // return value indicates that this field was not set, or was not defined in the
  10048. // schema.
  10049. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  10050. switch name {
  10051. case sopnode.FieldCreatedAt:
  10052. return m.CreatedAt()
  10053. case sopnode.FieldUpdatedAt:
  10054. return m.UpdatedAt()
  10055. case sopnode.FieldStatus:
  10056. return m.Status()
  10057. case sopnode.FieldDeletedAt:
  10058. return m.DeletedAt()
  10059. case sopnode.FieldStageID:
  10060. return m.StageID()
  10061. case sopnode.FieldParentID:
  10062. return m.ParentID()
  10063. case sopnode.FieldName:
  10064. return m.Name()
  10065. case sopnode.FieldConditionType:
  10066. return m.ConditionType()
  10067. case sopnode.FieldConditionList:
  10068. return m.ConditionList()
  10069. case sopnode.FieldNoReplyCondition:
  10070. return m.NoReplyCondition()
  10071. case sopnode.FieldActionMessage:
  10072. return m.ActionMessage()
  10073. case sopnode.FieldActionLabel:
  10074. return m.ActionLabel()
  10075. }
  10076. return nil, false
  10077. }
  10078. // OldField returns the old value of the field from the database. An error is
  10079. // returned if the mutation operation is not UpdateOne, or the query to the
  10080. // database failed.
  10081. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10082. switch name {
  10083. case sopnode.FieldCreatedAt:
  10084. return m.OldCreatedAt(ctx)
  10085. case sopnode.FieldUpdatedAt:
  10086. return m.OldUpdatedAt(ctx)
  10087. case sopnode.FieldStatus:
  10088. return m.OldStatus(ctx)
  10089. case sopnode.FieldDeletedAt:
  10090. return m.OldDeletedAt(ctx)
  10091. case sopnode.FieldStageID:
  10092. return m.OldStageID(ctx)
  10093. case sopnode.FieldParentID:
  10094. return m.OldParentID(ctx)
  10095. case sopnode.FieldName:
  10096. return m.OldName(ctx)
  10097. case sopnode.FieldConditionType:
  10098. return m.OldConditionType(ctx)
  10099. case sopnode.FieldConditionList:
  10100. return m.OldConditionList(ctx)
  10101. case sopnode.FieldNoReplyCondition:
  10102. return m.OldNoReplyCondition(ctx)
  10103. case sopnode.FieldActionMessage:
  10104. return m.OldActionMessage(ctx)
  10105. case sopnode.FieldActionLabel:
  10106. return m.OldActionLabel(ctx)
  10107. }
  10108. return nil, fmt.Errorf("unknown SopNode field %s", name)
  10109. }
  10110. // SetField sets the value of a field with the given name. It returns an error if
  10111. // the field is not defined in the schema, or if the type mismatched the field
  10112. // type.
  10113. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  10114. switch name {
  10115. case sopnode.FieldCreatedAt:
  10116. v, ok := value.(time.Time)
  10117. if !ok {
  10118. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10119. }
  10120. m.SetCreatedAt(v)
  10121. return nil
  10122. case sopnode.FieldUpdatedAt:
  10123. v, ok := value.(time.Time)
  10124. if !ok {
  10125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10126. }
  10127. m.SetUpdatedAt(v)
  10128. return nil
  10129. case sopnode.FieldStatus:
  10130. v, ok := value.(uint8)
  10131. if !ok {
  10132. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10133. }
  10134. m.SetStatus(v)
  10135. return nil
  10136. case sopnode.FieldDeletedAt:
  10137. v, ok := value.(time.Time)
  10138. if !ok {
  10139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10140. }
  10141. m.SetDeletedAt(v)
  10142. return nil
  10143. case sopnode.FieldStageID:
  10144. v, ok := value.(uint64)
  10145. if !ok {
  10146. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10147. }
  10148. m.SetStageID(v)
  10149. return nil
  10150. case sopnode.FieldParentID:
  10151. v, ok := value.(uint64)
  10152. if !ok {
  10153. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10154. }
  10155. m.SetParentID(v)
  10156. return nil
  10157. case sopnode.FieldName:
  10158. v, ok := value.(string)
  10159. if !ok {
  10160. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10161. }
  10162. m.SetName(v)
  10163. return nil
  10164. case sopnode.FieldConditionType:
  10165. v, ok := value.(int)
  10166. if !ok {
  10167. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10168. }
  10169. m.SetConditionType(v)
  10170. return nil
  10171. case sopnode.FieldConditionList:
  10172. v, ok := value.([]string)
  10173. if !ok {
  10174. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10175. }
  10176. m.SetConditionList(v)
  10177. return nil
  10178. case sopnode.FieldNoReplyCondition:
  10179. v, ok := value.(uint64)
  10180. if !ok {
  10181. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10182. }
  10183. m.SetNoReplyCondition(v)
  10184. return nil
  10185. case sopnode.FieldActionMessage:
  10186. v, ok := value.([]custom_types.Action)
  10187. if !ok {
  10188. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10189. }
  10190. m.SetActionMessage(v)
  10191. return nil
  10192. case sopnode.FieldActionLabel:
  10193. v, ok := value.([]uint64)
  10194. if !ok {
  10195. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10196. }
  10197. m.SetActionLabel(v)
  10198. return nil
  10199. }
  10200. return fmt.Errorf("unknown SopNode field %s", name)
  10201. }
  10202. // AddedFields returns all numeric fields that were incremented/decremented during
  10203. // this mutation.
  10204. func (m *SopNodeMutation) AddedFields() []string {
  10205. var fields []string
  10206. if m.addstatus != nil {
  10207. fields = append(fields, sopnode.FieldStatus)
  10208. }
  10209. if m.addparent_id != nil {
  10210. fields = append(fields, sopnode.FieldParentID)
  10211. }
  10212. if m.addcondition_type != nil {
  10213. fields = append(fields, sopnode.FieldConditionType)
  10214. }
  10215. if m.addno_reply_condition != nil {
  10216. fields = append(fields, sopnode.FieldNoReplyCondition)
  10217. }
  10218. return fields
  10219. }
  10220. // AddedField returns the numeric value that was incremented/decremented on a field
  10221. // with the given name. The second boolean return value indicates that this field
  10222. // was not set, or was not defined in the schema.
  10223. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  10224. switch name {
  10225. case sopnode.FieldStatus:
  10226. return m.AddedStatus()
  10227. case sopnode.FieldParentID:
  10228. return m.AddedParentID()
  10229. case sopnode.FieldConditionType:
  10230. return m.AddedConditionType()
  10231. case sopnode.FieldNoReplyCondition:
  10232. return m.AddedNoReplyCondition()
  10233. }
  10234. return nil, false
  10235. }
  10236. // AddField adds the value to the field with the given name. It returns an error if
  10237. // the field is not defined in the schema, or if the type mismatched the field
  10238. // type.
  10239. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  10240. switch name {
  10241. case sopnode.FieldStatus:
  10242. v, ok := value.(int8)
  10243. if !ok {
  10244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10245. }
  10246. m.AddStatus(v)
  10247. return nil
  10248. case sopnode.FieldParentID:
  10249. v, ok := value.(int64)
  10250. if !ok {
  10251. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10252. }
  10253. m.AddParentID(v)
  10254. return nil
  10255. case sopnode.FieldConditionType:
  10256. v, ok := value.(int)
  10257. if !ok {
  10258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10259. }
  10260. m.AddConditionType(v)
  10261. return nil
  10262. case sopnode.FieldNoReplyCondition:
  10263. v, ok := value.(int64)
  10264. if !ok {
  10265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10266. }
  10267. m.AddNoReplyCondition(v)
  10268. return nil
  10269. }
  10270. return fmt.Errorf("unknown SopNode numeric field %s", name)
  10271. }
  10272. // ClearedFields returns all nullable fields that were cleared during this
  10273. // mutation.
  10274. func (m *SopNodeMutation) ClearedFields() []string {
  10275. var fields []string
  10276. if m.FieldCleared(sopnode.FieldStatus) {
  10277. fields = append(fields, sopnode.FieldStatus)
  10278. }
  10279. if m.FieldCleared(sopnode.FieldDeletedAt) {
  10280. fields = append(fields, sopnode.FieldDeletedAt)
  10281. }
  10282. if m.FieldCleared(sopnode.FieldConditionList) {
  10283. fields = append(fields, sopnode.FieldConditionList)
  10284. }
  10285. if m.FieldCleared(sopnode.FieldActionMessage) {
  10286. fields = append(fields, sopnode.FieldActionMessage)
  10287. }
  10288. if m.FieldCleared(sopnode.FieldActionLabel) {
  10289. fields = append(fields, sopnode.FieldActionLabel)
  10290. }
  10291. return fields
  10292. }
  10293. // FieldCleared returns a boolean indicating if a field with the given name was
  10294. // cleared in this mutation.
  10295. func (m *SopNodeMutation) FieldCleared(name string) bool {
  10296. _, ok := m.clearedFields[name]
  10297. return ok
  10298. }
  10299. // ClearField clears the value of the field with the given name. It returns an
  10300. // error if the field is not defined in the schema.
  10301. func (m *SopNodeMutation) ClearField(name string) error {
  10302. switch name {
  10303. case sopnode.FieldStatus:
  10304. m.ClearStatus()
  10305. return nil
  10306. case sopnode.FieldDeletedAt:
  10307. m.ClearDeletedAt()
  10308. return nil
  10309. case sopnode.FieldConditionList:
  10310. m.ClearConditionList()
  10311. return nil
  10312. case sopnode.FieldActionMessage:
  10313. m.ClearActionMessage()
  10314. return nil
  10315. case sopnode.FieldActionLabel:
  10316. m.ClearActionLabel()
  10317. return nil
  10318. }
  10319. return fmt.Errorf("unknown SopNode nullable field %s", name)
  10320. }
  10321. // ResetField resets all changes in the mutation for the field with the given name.
  10322. // It returns an error if the field is not defined in the schema.
  10323. func (m *SopNodeMutation) ResetField(name string) error {
  10324. switch name {
  10325. case sopnode.FieldCreatedAt:
  10326. m.ResetCreatedAt()
  10327. return nil
  10328. case sopnode.FieldUpdatedAt:
  10329. m.ResetUpdatedAt()
  10330. return nil
  10331. case sopnode.FieldStatus:
  10332. m.ResetStatus()
  10333. return nil
  10334. case sopnode.FieldDeletedAt:
  10335. m.ResetDeletedAt()
  10336. return nil
  10337. case sopnode.FieldStageID:
  10338. m.ResetStageID()
  10339. return nil
  10340. case sopnode.FieldParentID:
  10341. m.ResetParentID()
  10342. return nil
  10343. case sopnode.FieldName:
  10344. m.ResetName()
  10345. return nil
  10346. case sopnode.FieldConditionType:
  10347. m.ResetConditionType()
  10348. return nil
  10349. case sopnode.FieldConditionList:
  10350. m.ResetConditionList()
  10351. return nil
  10352. case sopnode.FieldNoReplyCondition:
  10353. m.ResetNoReplyCondition()
  10354. return nil
  10355. case sopnode.FieldActionMessage:
  10356. m.ResetActionMessage()
  10357. return nil
  10358. case sopnode.FieldActionLabel:
  10359. m.ResetActionLabel()
  10360. return nil
  10361. }
  10362. return fmt.Errorf("unknown SopNode field %s", name)
  10363. }
  10364. // AddedEdges returns all edge names that were set/added in this mutation.
  10365. func (m *SopNodeMutation) AddedEdges() []string {
  10366. edges := make([]string, 0, 2)
  10367. if m.sop_stage != nil {
  10368. edges = append(edges, sopnode.EdgeSopStage)
  10369. }
  10370. if m.node_messages != nil {
  10371. edges = append(edges, sopnode.EdgeNodeMessages)
  10372. }
  10373. return edges
  10374. }
  10375. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10376. // name in this mutation.
  10377. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  10378. switch name {
  10379. case sopnode.EdgeSopStage:
  10380. if id := m.sop_stage; id != nil {
  10381. return []ent.Value{*id}
  10382. }
  10383. case sopnode.EdgeNodeMessages:
  10384. ids := make([]ent.Value, 0, len(m.node_messages))
  10385. for id := range m.node_messages {
  10386. ids = append(ids, id)
  10387. }
  10388. return ids
  10389. }
  10390. return nil
  10391. }
  10392. // RemovedEdges returns all edge names that were removed in this mutation.
  10393. func (m *SopNodeMutation) RemovedEdges() []string {
  10394. edges := make([]string, 0, 2)
  10395. if m.removednode_messages != nil {
  10396. edges = append(edges, sopnode.EdgeNodeMessages)
  10397. }
  10398. return edges
  10399. }
  10400. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10401. // the given name in this mutation.
  10402. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  10403. switch name {
  10404. case sopnode.EdgeNodeMessages:
  10405. ids := make([]ent.Value, 0, len(m.removednode_messages))
  10406. for id := range m.removednode_messages {
  10407. ids = append(ids, id)
  10408. }
  10409. return ids
  10410. }
  10411. return nil
  10412. }
  10413. // ClearedEdges returns all edge names that were cleared in this mutation.
  10414. func (m *SopNodeMutation) ClearedEdges() []string {
  10415. edges := make([]string, 0, 2)
  10416. if m.clearedsop_stage {
  10417. edges = append(edges, sopnode.EdgeSopStage)
  10418. }
  10419. if m.clearednode_messages {
  10420. edges = append(edges, sopnode.EdgeNodeMessages)
  10421. }
  10422. return edges
  10423. }
  10424. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10425. // was cleared in this mutation.
  10426. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  10427. switch name {
  10428. case sopnode.EdgeSopStage:
  10429. return m.clearedsop_stage
  10430. case sopnode.EdgeNodeMessages:
  10431. return m.clearednode_messages
  10432. }
  10433. return false
  10434. }
  10435. // ClearEdge clears the value of the edge with the given name. It returns an error
  10436. // if that edge is not defined in the schema.
  10437. func (m *SopNodeMutation) ClearEdge(name string) error {
  10438. switch name {
  10439. case sopnode.EdgeSopStage:
  10440. m.ClearSopStage()
  10441. return nil
  10442. }
  10443. return fmt.Errorf("unknown SopNode unique edge %s", name)
  10444. }
  10445. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10446. // It returns an error if the edge is not defined in the schema.
  10447. func (m *SopNodeMutation) ResetEdge(name string) error {
  10448. switch name {
  10449. case sopnode.EdgeSopStage:
  10450. m.ResetSopStage()
  10451. return nil
  10452. case sopnode.EdgeNodeMessages:
  10453. m.ResetNodeMessages()
  10454. return nil
  10455. }
  10456. return fmt.Errorf("unknown SopNode edge %s", name)
  10457. }
  10458. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  10459. type SopStageMutation struct {
  10460. config
  10461. op Op
  10462. typ string
  10463. id *uint64
  10464. created_at *time.Time
  10465. updated_at *time.Time
  10466. status *uint8
  10467. addstatus *int8
  10468. deleted_at *time.Time
  10469. name *string
  10470. condition_type *int
  10471. addcondition_type *int
  10472. condition_operator *int
  10473. addcondition_operator *int
  10474. condition_list *[]custom_types.Condition
  10475. appendcondition_list []custom_types.Condition
  10476. action_message *[]custom_types.Action
  10477. appendaction_message []custom_types.Action
  10478. action_label *[]uint64
  10479. appendaction_label []uint64
  10480. index_sort *int
  10481. addindex_sort *int
  10482. clearedFields map[string]struct{}
  10483. sop_task *uint64
  10484. clearedsop_task bool
  10485. stage_nodes map[uint64]struct{}
  10486. removedstage_nodes map[uint64]struct{}
  10487. clearedstage_nodes bool
  10488. stage_messages map[uint64]struct{}
  10489. removedstage_messages map[uint64]struct{}
  10490. clearedstage_messages bool
  10491. done bool
  10492. oldValue func(context.Context) (*SopStage, error)
  10493. predicates []predicate.SopStage
  10494. }
  10495. var _ ent.Mutation = (*SopStageMutation)(nil)
  10496. // sopstageOption allows management of the mutation configuration using functional options.
  10497. type sopstageOption func(*SopStageMutation)
  10498. // newSopStageMutation creates new mutation for the SopStage entity.
  10499. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  10500. m := &SopStageMutation{
  10501. config: c,
  10502. op: op,
  10503. typ: TypeSopStage,
  10504. clearedFields: make(map[string]struct{}),
  10505. }
  10506. for _, opt := range opts {
  10507. opt(m)
  10508. }
  10509. return m
  10510. }
  10511. // withSopStageID sets the ID field of the mutation.
  10512. func withSopStageID(id uint64) sopstageOption {
  10513. return func(m *SopStageMutation) {
  10514. var (
  10515. err error
  10516. once sync.Once
  10517. value *SopStage
  10518. )
  10519. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  10520. once.Do(func() {
  10521. if m.done {
  10522. err = errors.New("querying old values post mutation is not allowed")
  10523. } else {
  10524. value, err = m.Client().SopStage.Get(ctx, id)
  10525. }
  10526. })
  10527. return value, err
  10528. }
  10529. m.id = &id
  10530. }
  10531. }
  10532. // withSopStage sets the old SopStage of the mutation.
  10533. func withSopStage(node *SopStage) sopstageOption {
  10534. return func(m *SopStageMutation) {
  10535. m.oldValue = func(context.Context) (*SopStage, error) {
  10536. return node, nil
  10537. }
  10538. m.id = &node.ID
  10539. }
  10540. }
  10541. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10542. // executed in a transaction (ent.Tx), a transactional client is returned.
  10543. func (m SopStageMutation) Client() *Client {
  10544. client := &Client{config: m.config}
  10545. client.init()
  10546. return client
  10547. }
  10548. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10549. // it returns an error otherwise.
  10550. func (m SopStageMutation) Tx() (*Tx, error) {
  10551. if _, ok := m.driver.(*txDriver); !ok {
  10552. return nil, errors.New("ent: mutation is not running in a transaction")
  10553. }
  10554. tx := &Tx{config: m.config}
  10555. tx.init()
  10556. return tx, nil
  10557. }
  10558. // SetID sets the value of the id field. Note that this
  10559. // operation is only accepted on creation of SopStage entities.
  10560. func (m *SopStageMutation) SetID(id uint64) {
  10561. m.id = &id
  10562. }
  10563. // ID returns the ID value in the mutation. Note that the ID is only available
  10564. // if it was provided to the builder or after it was returned from the database.
  10565. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  10566. if m.id == nil {
  10567. return
  10568. }
  10569. return *m.id, true
  10570. }
  10571. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10572. // That means, if the mutation is applied within a transaction with an isolation level such
  10573. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10574. // or updated by the mutation.
  10575. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  10576. switch {
  10577. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10578. id, exists := m.ID()
  10579. if exists {
  10580. return []uint64{id}, nil
  10581. }
  10582. fallthrough
  10583. case m.op.Is(OpUpdate | OpDelete):
  10584. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  10585. default:
  10586. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10587. }
  10588. }
  10589. // SetCreatedAt sets the "created_at" field.
  10590. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  10591. m.created_at = &t
  10592. }
  10593. // CreatedAt returns the value of the "created_at" field in the mutation.
  10594. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  10595. v := m.created_at
  10596. if v == nil {
  10597. return
  10598. }
  10599. return *v, true
  10600. }
  10601. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  10602. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  10603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10604. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10605. if !m.op.Is(OpUpdateOne) {
  10606. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10607. }
  10608. if m.id == nil || m.oldValue == nil {
  10609. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10610. }
  10611. oldValue, err := m.oldValue(ctx)
  10612. if err != nil {
  10613. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10614. }
  10615. return oldValue.CreatedAt, nil
  10616. }
  10617. // ResetCreatedAt resets all changes to the "created_at" field.
  10618. func (m *SopStageMutation) ResetCreatedAt() {
  10619. m.created_at = nil
  10620. }
  10621. // SetUpdatedAt sets the "updated_at" field.
  10622. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  10623. m.updated_at = &t
  10624. }
  10625. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10626. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  10627. v := m.updated_at
  10628. if v == nil {
  10629. return
  10630. }
  10631. return *v, true
  10632. }
  10633. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  10634. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  10635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10636. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10637. if !m.op.Is(OpUpdateOne) {
  10638. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10639. }
  10640. if m.id == nil || m.oldValue == nil {
  10641. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10642. }
  10643. oldValue, err := m.oldValue(ctx)
  10644. if err != nil {
  10645. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10646. }
  10647. return oldValue.UpdatedAt, nil
  10648. }
  10649. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10650. func (m *SopStageMutation) ResetUpdatedAt() {
  10651. m.updated_at = nil
  10652. }
  10653. // SetStatus sets the "status" field.
  10654. func (m *SopStageMutation) SetStatus(u uint8) {
  10655. m.status = &u
  10656. m.addstatus = nil
  10657. }
  10658. // Status returns the value of the "status" field in the mutation.
  10659. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  10660. v := m.status
  10661. if v == nil {
  10662. return
  10663. }
  10664. return *v, true
  10665. }
  10666. // OldStatus returns the old "status" field's value of the SopStage entity.
  10667. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  10668. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10669. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  10670. if !m.op.Is(OpUpdateOne) {
  10671. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  10672. }
  10673. if m.id == nil || m.oldValue == nil {
  10674. return v, errors.New("OldStatus requires an ID field in the mutation")
  10675. }
  10676. oldValue, err := m.oldValue(ctx)
  10677. if err != nil {
  10678. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  10679. }
  10680. return oldValue.Status, nil
  10681. }
  10682. // AddStatus adds u to the "status" field.
  10683. func (m *SopStageMutation) AddStatus(u int8) {
  10684. if m.addstatus != nil {
  10685. *m.addstatus += u
  10686. } else {
  10687. m.addstatus = &u
  10688. }
  10689. }
  10690. // AddedStatus returns the value that was added to the "status" field in this mutation.
  10691. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  10692. v := m.addstatus
  10693. if v == nil {
  10694. return
  10695. }
  10696. return *v, true
  10697. }
  10698. // ClearStatus clears the value of the "status" field.
  10699. func (m *SopStageMutation) ClearStatus() {
  10700. m.status = nil
  10701. m.addstatus = nil
  10702. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  10703. }
  10704. // StatusCleared returns if the "status" field was cleared in this mutation.
  10705. func (m *SopStageMutation) StatusCleared() bool {
  10706. _, ok := m.clearedFields[sopstage.FieldStatus]
  10707. return ok
  10708. }
  10709. // ResetStatus resets all changes to the "status" field.
  10710. func (m *SopStageMutation) ResetStatus() {
  10711. m.status = nil
  10712. m.addstatus = nil
  10713. delete(m.clearedFields, sopstage.FieldStatus)
  10714. }
  10715. // SetDeletedAt sets the "deleted_at" field.
  10716. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  10717. m.deleted_at = &t
  10718. }
  10719. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10720. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  10721. v := m.deleted_at
  10722. if v == nil {
  10723. return
  10724. }
  10725. return *v, true
  10726. }
  10727. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  10728. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  10729. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10730. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10731. if !m.op.Is(OpUpdateOne) {
  10732. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10733. }
  10734. if m.id == nil || m.oldValue == nil {
  10735. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10736. }
  10737. oldValue, err := m.oldValue(ctx)
  10738. if err != nil {
  10739. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10740. }
  10741. return oldValue.DeletedAt, nil
  10742. }
  10743. // ClearDeletedAt clears the value of the "deleted_at" field.
  10744. func (m *SopStageMutation) ClearDeletedAt() {
  10745. m.deleted_at = nil
  10746. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  10747. }
  10748. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10749. func (m *SopStageMutation) DeletedAtCleared() bool {
  10750. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  10751. return ok
  10752. }
  10753. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10754. func (m *SopStageMutation) ResetDeletedAt() {
  10755. m.deleted_at = nil
  10756. delete(m.clearedFields, sopstage.FieldDeletedAt)
  10757. }
  10758. // SetTaskID sets the "task_id" field.
  10759. func (m *SopStageMutation) SetTaskID(u uint64) {
  10760. m.sop_task = &u
  10761. }
  10762. // TaskID returns the value of the "task_id" field in the mutation.
  10763. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  10764. v := m.sop_task
  10765. if v == nil {
  10766. return
  10767. }
  10768. return *v, true
  10769. }
  10770. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  10771. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  10772. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10773. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  10774. if !m.op.Is(OpUpdateOne) {
  10775. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  10776. }
  10777. if m.id == nil || m.oldValue == nil {
  10778. return v, errors.New("OldTaskID requires an ID field in the mutation")
  10779. }
  10780. oldValue, err := m.oldValue(ctx)
  10781. if err != nil {
  10782. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  10783. }
  10784. return oldValue.TaskID, nil
  10785. }
  10786. // ResetTaskID resets all changes to the "task_id" field.
  10787. func (m *SopStageMutation) ResetTaskID() {
  10788. m.sop_task = nil
  10789. }
  10790. // SetName sets the "name" field.
  10791. func (m *SopStageMutation) SetName(s string) {
  10792. m.name = &s
  10793. }
  10794. // Name returns the value of the "name" field in the mutation.
  10795. func (m *SopStageMutation) Name() (r string, exists bool) {
  10796. v := m.name
  10797. if v == nil {
  10798. return
  10799. }
  10800. return *v, true
  10801. }
  10802. // OldName returns the old "name" field's value of the SopStage entity.
  10803. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  10804. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10805. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  10806. if !m.op.Is(OpUpdateOne) {
  10807. return v, errors.New("OldName is only allowed on UpdateOne operations")
  10808. }
  10809. if m.id == nil || m.oldValue == nil {
  10810. return v, errors.New("OldName requires an ID field in the mutation")
  10811. }
  10812. oldValue, err := m.oldValue(ctx)
  10813. if err != nil {
  10814. return v, fmt.Errorf("querying old value for OldName: %w", err)
  10815. }
  10816. return oldValue.Name, nil
  10817. }
  10818. // ResetName resets all changes to the "name" field.
  10819. func (m *SopStageMutation) ResetName() {
  10820. m.name = nil
  10821. }
  10822. // SetConditionType sets the "condition_type" field.
  10823. func (m *SopStageMutation) SetConditionType(i int) {
  10824. m.condition_type = &i
  10825. m.addcondition_type = nil
  10826. }
  10827. // ConditionType returns the value of the "condition_type" field in the mutation.
  10828. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  10829. v := m.condition_type
  10830. if v == nil {
  10831. return
  10832. }
  10833. return *v, true
  10834. }
  10835. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  10836. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  10837. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10838. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  10839. if !m.op.Is(OpUpdateOne) {
  10840. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  10841. }
  10842. if m.id == nil || m.oldValue == nil {
  10843. return v, errors.New("OldConditionType requires an ID field in the mutation")
  10844. }
  10845. oldValue, err := m.oldValue(ctx)
  10846. if err != nil {
  10847. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  10848. }
  10849. return oldValue.ConditionType, nil
  10850. }
  10851. // AddConditionType adds i to the "condition_type" field.
  10852. func (m *SopStageMutation) AddConditionType(i int) {
  10853. if m.addcondition_type != nil {
  10854. *m.addcondition_type += i
  10855. } else {
  10856. m.addcondition_type = &i
  10857. }
  10858. }
  10859. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  10860. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  10861. v := m.addcondition_type
  10862. if v == nil {
  10863. return
  10864. }
  10865. return *v, true
  10866. }
  10867. // ResetConditionType resets all changes to the "condition_type" field.
  10868. func (m *SopStageMutation) ResetConditionType() {
  10869. m.condition_type = nil
  10870. m.addcondition_type = nil
  10871. }
  10872. // SetConditionOperator sets the "condition_operator" field.
  10873. func (m *SopStageMutation) SetConditionOperator(i int) {
  10874. m.condition_operator = &i
  10875. m.addcondition_operator = nil
  10876. }
  10877. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  10878. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  10879. v := m.condition_operator
  10880. if v == nil {
  10881. return
  10882. }
  10883. return *v, true
  10884. }
  10885. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  10886. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  10887. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10888. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  10889. if !m.op.Is(OpUpdateOne) {
  10890. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  10891. }
  10892. if m.id == nil || m.oldValue == nil {
  10893. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  10894. }
  10895. oldValue, err := m.oldValue(ctx)
  10896. if err != nil {
  10897. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  10898. }
  10899. return oldValue.ConditionOperator, nil
  10900. }
  10901. // AddConditionOperator adds i to the "condition_operator" field.
  10902. func (m *SopStageMutation) AddConditionOperator(i int) {
  10903. if m.addcondition_operator != nil {
  10904. *m.addcondition_operator += i
  10905. } else {
  10906. m.addcondition_operator = &i
  10907. }
  10908. }
  10909. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  10910. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  10911. v := m.addcondition_operator
  10912. if v == nil {
  10913. return
  10914. }
  10915. return *v, true
  10916. }
  10917. // ResetConditionOperator resets all changes to the "condition_operator" field.
  10918. func (m *SopStageMutation) ResetConditionOperator() {
  10919. m.condition_operator = nil
  10920. m.addcondition_operator = nil
  10921. }
  10922. // SetConditionList sets the "condition_list" field.
  10923. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  10924. m.condition_list = &ct
  10925. m.appendcondition_list = nil
  10926. }
  10927. // ConditionList returns the value of the "condition_list" field in the mutation.
  10928. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  10929. v := m.condition_list
  10930. if v == nil {
  10931. return
  10932. }
  10933. return *v, true
  10934. }
  10935. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  10936. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  10937. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10938. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  10939. if !m.op.Is(OpUpdateOne) {
  10940. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  10941. }
  10942. if m.id == nil || m.oldValue == nil {
  10943. return v, errors.New("OldConditionList requires an ID field in the mutation")
  10944. }
  10945. oldValue, err := m.oldValue(ctx)
  10946. if err != nil {
  10947. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  10948. }
  10949. return oldValue.ConditionList, nil
  10950. }
  10951. // AppendConditionList adds ct to the "condition_list" field.
  10952. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  10953. m.appendcondition_list = append(m.appendcondition_list, ct...)
  10954. }
  10955. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  10956. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  10957. if len(m.appendcondition_list) == 0 {
  10958. return nil, false
  10959. }
  10960. return m.appendcondition_list, true
  10961. }
  10962. // ResetConditionList resets all changes to the "condition_list" field.
  10963. func (m *SopStageMutation) ResetConditionList() {
  10964. m.condition_list = nil
  10965. m.appendcondition_list = nil
  10966. }
  10967. // SetActionMessage sets the "action_message" field.
  10968. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  10969. m.action_message = &ct
  10970. m.appendaction_message = nil
  10971. }
  10972. // ActionMessage returns the value of the "action_message" field in the mutation.
  10973. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  10974. v := m.action_message
  10975. if v == nil {
  10976. return
  10977. }
  10978. return *v, true
  10979. }
  10980. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  10981. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  10982. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10983. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  10984. if !m.op.Is(OpUpdateOne) {
  10985. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  10986. }
  10987. if m.id == nil || m.oldValue == nil {
  10988. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  10989. }
  10990. oldValue, err := m.oldValue(ctx)
  10991. if err != nil {
  10992. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  10993. }
  10994. return oldValue.ActionMessage, nil
  10995. }
  10996. // AppendActionMessage adds ct to the "action_message" field.
  10997. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  10998. m.appendaction_message = append(m.appendaction_message, ct...)
  10999. }
  11000. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  11001. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  11002. if len(m.appendaction_message) == 0 {
  11003. return nil, false
  11004. }
  11005. return m.appendaction_message, true
  11006. }
  11007. // ClearActionMessage clears the value of the "action_message" field.
  11008. func (m *SopStageMutation) ClearActionMessage() {
  11009. m.action_message = nil
  11010. m.appendaction_message = nil
  11011. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  11012. }
  11013. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  11014. func (m *SopStageMutation) ActionMessageCleared() bool {
  11015. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  11016. return ok
  11017. }
  11018. // ResetActionMessage resets all changes to the "action_message" field.
  11019. func (m *SopStageMutation) ResetActionMessage() {
  11020. m.action_message = nil
  11021. m.appendaction_message = nil
  11022. delete(m.clearedFields, sopstage.FieldActionMessage)
  11023. }
  11024. // SetActionLabel sets the "action_label" field.
  11025. func (m *SopStageMutation) SetActionLabel(u []uint64) {
  11026. m.action_label = &u
  11027. m.appendaction_label = nil
  11028. }
  11029. // ActionLabel returns the value of the "action_label" field in the mutation.
  11030. func (m *SopStageMutation) ActionLabel() (r []uint64, exists bool) {
  11031. v := m.action_label
  11032. if v == nil {
  11033. return
  11034. }
  11035. return *v, true
  11036. }
  11037. // OldActionLabel returns the old "action_label" field's value of the SopStage entity.
  11038. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  11039. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11040. func (m *SopStageMutation) OldActionLabel(ctx context.Context) (v []uint64, err error) {
  11041. if !m.op.Is(OpUpdateOne) {
  11042. return v, errors.New("OldActionLabel is only allowed on UpdateOne operations")
  11043. }
  11044. if m.id == nil || m.oldValue == nil {
  11045. return v, errors.New("OldActionLabel requires an ID field in the mutation")
  11046. }
  11047. oldValue, err := m.oldValue(ctx)
  11048. if err != nil {
  11049. return v, fmt.Errorf("querying old value for OldActionLabel: %w", err)
  11050. }
  11051. return oldValue.ActionLabel, nil
  11052. }
  11053. // AppendActionLabel adds u to the "action_label" field.
  11054. func (m *SopStageMutation) AppendActionLabel(u []uint64) {
  11055. m.appendaction_label = append(m.appendaction_label, u...)
  11056. }
  11057. // AppendedActionLabel returns the list of values that were appended to the "action_label" field in this mutation.
  11058. func (m *SopStageMutation) AppendedActionLabel() ([]uint64, bool) {
  11059. if len(m.appendaction_label) == 0 {
  11060. return nil, false
  11061. }
  11062. return m.appendaction_label, true
  11063. }
  11064. // ClearActionLabel clears the value of the "action_label" field.
  11065. func (m *SopStageMutation) ClearActionLabel() {
  11066. m.action_label = nil
  11067. m.appendaction_label = nil
  11068. m.clearedFields[sopstage.FieldActionLabel] = struct{}{}
  11069. }
  11070. // ActionLabelCleared returns if the "action_label" field was cleared in this mutation.
  11071. func (m *SopStageMutation) ActionLabelCleared() bool {
  11072. _, ok := m.clearedFields[sopstage.FieldActionLabel]
  11073. return ok
  11074. }
  11075. // ResetActionLabel resets all changes to the "action_label" field.
  11076. func (m *SopStageMutation) ResetActionLabel() {
  11077. m.action_label = nil
  11078. m.appendaction_label = nil
  11079. delete(m.clearedFields, sopstage.FieldActionLabel)
  11080. }
  11081. // SetIndexSort sets the "index_sort" field.
  11082. func (m *SopStageMutation) SetIndexSort(i int) {
  11083. m.index_sort = &i
  11084. m.addindex_sort = nil
  11085. }
  11086. // IndexSort returns the value of the "index_sort" field in the mutation.
  11087. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  11088. v := m.index_sort
  11089. if v == nil {
  11090. return
  11091. }
  11092. return *v, true
  11093. }
  11094. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  11095. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  11096. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11097. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  11098. if !m.op.Is(OpUpdateOne) {
  11099. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  11100. }
  11101. if m.id == nil || m.oldValue == nil {
  11102. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  11103. }
  11104. oldValue, err := m.oldValue(ctx)
  11105. if err != nil {
  11106. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  11107. }
  11108. return oldValue.IndexSort, nil
  11109. }
  11110. // AddIndexSort adds i to the "index_sort" field.
  11111. func (m *SopStageMutation) AddIndexSort(i int) {
  11112. if m.addindex_sort != nil {
  11113. *m.addindex_sort += i
  11114. } else {
  11115. m.addindex_sort = &i
  11116. }
  11117. }
  11118. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  11119. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  11120. v := m.addindex_sort
  11121. if v == nil {
  11122. return
  11123. }
  11124. return *v, true
  11125. }
  11126. // ClearIndexSort clears the value of the "index_sort" field.
  11127. func (m *SopStageMutation) ClearIndexSort() {
  11128. m.index_sort = nil
  11129. m.addindex_sort = nil
  11130. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  11131. }
  11132. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  11133. func (m *SopStageMutation) IndexSortCleared() bool {
  11134. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  11135. return ok
  11136. }
  11137. // ResetIndexSort resets all changes to the "index_sort" field.
  11138. func (m *SopStageMutation) ResetIndexSort() {
  11139. m.index_sort = nil
  11140. m.addindex_sort = nil
  11141. delete(m.clearedFields, sopstage.FieldIndexSort)
  11142. }
  11143. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  11144. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  11145. m.sop_task = &id
  11146. }
  11147. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  11148. func (m *SopStageMutation) ClearSopTask() {
  11149. m.clearedsop_task = true
  11150. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  11151. }
  11152. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  11153. func (m *SopStageMutation) SopTaskCleared() bool {
  11154. return m.clearedsop_task
  11155. }
  11156. // SopTaskID returns the "sop_task" edge ID in the mutation.
  11157. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  11158. if m.sop_task != nil {
  11159. return *m.sop_task, true
  11160. }
  11161. return
  11162. }
  11163. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  11164. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  11165. // SopTaskID instead. It exists only for internal usage by the builders.
  11166. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  11167. if id := m.sop_task; id != nil {
  11168. ids = append(ids, *id)
  11169. }
  11170. return
  11171. }
  11172. // ResetSopTask resets all changes to the "sop_task" edge.
  11173. func (m *SopStageMutation) ResetSopTask() {
  11174. m.sop_task = nil
  11175. m.clearedsop_task = false
  11176. }
  11177. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  11178. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  11179. if m.stage_nodes == nil {
  11180. m.stage_nodes = make(map[uint64]struct{})
  11181. }
  11182. for i := range ids {
  11183. m.stage_nodes[ids[i]] = struct{}{}
  11184. }
  11185. }
  11186. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  11187. func (m *SopStageMutation) ClearStageNodes() {
  11188. m.clearedstage_nodes = true
  11189. }
  11190. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  11191. func (m *SopStageMutation) StageNodesCleared() bool {
  11192. return m.clearedstage_nodes
  11193. }
  11194. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  11195. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  11196. if m.removedstage_nodes == nil {
  11197. m.removedstage_nodes = make(map[uint64]struct{})
  11198. }
  11199. for i := range ids {
  11200. delete(m.stage_nodes, ids[i])
  11201. m.removedstage_nodes[ids[i]] = struct{}{}
  11202. }
  11203. }
  11204. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  11205. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  11206. for id := range m.removedstage_nodes {
  11207. ids = append(ids, id)
  11208. }
  11209. return
  11210. }
  11211. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  11212. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  11213. for id := range m.stage_nodes {
  11214. ids = append(ids, id)
  11215. }
  11216. return
  11217. }
  11218. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  11219. func (m *SopStageMutation) ResetStageNodes() {
  11220. m.stage_nodes = nil
  11221. m.clearedstage_nodes = false
  11222. m.removedstage_nodes = nil
  11223. }
  11224. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  11225. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  11226. if m.stage_messages == nil {
  11227. m.stage_messages = make(map[uint64]struct{})
  11228. }
  11229. for i := range ids {
  11230. m.stage_messages[ids[i]] = struct{}{}
  11231. }
  11232. }
  11233. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  11234. func (m *SopStageMutation) ClearStageMessages() {
  11235. m.clearedstage_messages = true
  11236. }
  11237. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  11238. func (m *SopStageMutation) StageMessagesCleared() bool {
  11239. return m.clearedstage_messages
  11240. }
  11241. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  11242. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  11243. if m.removedstage_messages == nil {
  11244. m.removedstage_messages = make(map[uint64]struct{})
  11245. }
  11246. for i := range ids {
  11247. delete(m.stage_messages, ids[i])
  11248. m.removedstage_messages[ids[i]] = struct{}{}
  11249. }
  11250. }
  11251. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  11252. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  11253. for id := range m.removedstage_messages {
  11254. ids = append(ids, id)
  11255. }
  11256. return
  11257. }
  11258. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  11259. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  11260. for id := range m.stage_messages {
  11261. ids = append(ids, id)
  11262. }
  11263. return
  11264. }
  11265. // ResetStageMessages resets all changes to the "stage_messages" edge.
  11266. func (m *SopStageMutation) ResetStageMessages() {
  11267. m.stage_messages = nil
  11268. m.clearedstage_messages = false
  11269. m.removedstage_messages = nil
  11270. }
  11271. // Where appends a list predicates to the SopStageMutation builder.
  11272. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  11273. m.predicates = append(m.predicates, ps...)
  11274. }
  11275. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  11276. // users can use type-assertion to append predicates that do not depend on any generated package.
  11277. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  11278. p := make([]predicate.SopStage, len(ps))
  11279. for i := range ps {
  11280. p[i] = ps[i]
  11281. }
  11282. m.Where(p...)
  11283. }
  11284. // Op returns the operation name.
  11285. func (m *SopStageMutation) Op() Op {
  11286. return m.op
  11287. }
  11288. // SetOp allows setting the mutation operation.
  11289. func (m *SopStageMutation) SetOp(op Op) {
  11290. m.op = op
  11291. }
  11292. // Type returns the node type of this mutation (SopStage).
  11293. func (m *SopStageMutation) Type() string {
  11294. return m.typ
  11295. }
  11296. // Fields returns all fields that were changed during this mutation. Note that in
  11297. // order to get all numeric fields that were incremented/decremented, call
  11298. // AddedFields().
  11299. func (m *SopStageMutation) Fields() []string {
  11300. fields := make([]string, 0, 12)
  11301. if m.created_at != nil {
  11302. fields = append(fields, sopstage.FieldCreatedAt)
  11303. }
  11304. if m.updated_at != nil {
  11305. fields = append(fields, sopstage.FieldUpdatedAt)
  11306. }
  11307. if m.status != nil {
  11308. fields = append(fields, sopstage.FieldStatus)
  11309. }
  11310. if m.deleted_at != nil {
  11311. fields = append(fields, sopstage.FieldDeletedAt)
  11312. }
  11313. if m.sop_task != nil {
  11314. fields = append(fields, sopstage.FieldTaskID)
  11315. }
  11316. if m.name != nil {
  11317. fields = append(fields, sopstage.FieldName)
  11318. }
  11319. if m.condition_type != nil {
  11320. fields = append(fields, sopstage.FieldConditionType)
  11321. }
  11322. if m.condition_operator != nil {
  11323. fields = append(fields, sopstage.FieldConditionOperator)
  11324. }
  11325. if m.condition_list != nil {
  11326. fields = append(fields, sopstage.FieldConditionList)
  11327. }
  11328. if m.action_message != nil {
  11329. fields = append(fields, sopstage.FieldActionMessage)
  11330. }
  11331. if m.action_label != nil {
  11332. fields = append(fields, sopstage.FieldActionLabel)
  11333. }
  11334. if m.index_sort != nil {
  11335. fields = append(fields, sopstage.FieldIndexSort)
  11336. }
  11337. return fields
  11338. }
  11339. // Field returns the value of a field with the given name. The second boolean
  11340. // return value indicates that this field was not set, or was not defined in the
  11341. // schema.
  11342. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  11343. switch name {
  11344. case sopstage.FieldCreatedAt:
  11345. return m.CreatedAt()
  11346. case sopstage.FieldUpdatedAt:
  11347. return m.UpdatedAt()
  11348. case sopstage.FieldStatus:
  11349. return m.Status()
  11350. case sopstage.FieldDeletedAt:
  11351. return m.DeletedAt()
  11352. case sopstage.FieldTaskID:
  11353. return m.TaskID()
  11354. case sopstage.FieldName:
  11355. return m.Name()
  11356. case sopstage.FieldConditionType:
  11357. return m.ConditionType()
  11358. case sopstage.FieldConditionOperator:
  11359. return m.ConditionOperator()
  11360. case sopstage.FieldConditionList:
  11361. return m.ConditionList()
  11362. case sopstage.FieldActionMessage:
  11363. return m.ActionMessage()
  11364. case sopstage.FieldActionLabel:
  11365. return m.ActionLabel()
  11366. case sopstage.FieldIndexSort:
  11367. return m.IndexSort()
  11368. }
  11369. return nil, false
  11370. }
  11371. // OldField returns the old value of the field from the database. An error is
  11372. // returned if the mutation operation is not UpdateOne, or the query to the
  11373. // database failed.
  11374. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11375. switch name {
  11376. case sopstage.FieldCreatedAt:
  11377. return m.OldCreatedAt(ctx)
  11378. case sopstage.FieldUpdatedAt:
  11379. return m.OldUpdatedAt(ctx)
  11380. case sopstage.FieldStatus:
  11381. return m.OldStatus(ctx)
  11382. case sopstage.FieldDeletedAt:
  11383. return m.OldDeletedAt(ctx)
  11384. case sopstage.FieldTaskID:
  11385. return m.OldTaskID(ctx)
  11386. case sopstage.FieldName:
  11387. return m.OldName(ctx)
  11388. case sopstage.FieldConditionType:
  11389. return m.OldConditionType(ctx)
  11390. case sopstage.FieldConditionOperator:
  11391. return m.OldConditionOperator(ctx)
  11392. case sopstage.FieldConditionList:
  11393. return m.OldConditionList(ctx)
  11394. case sopstage.FieldActionMessage:
  11395. return m.OldActionMessage(ctx)
  11396. case sopstage.FieldActionLabel:
  11397. return m.OldActionLabel(ctx)
  11398. case sopstage.FieldIndexSort:
  11399. return m.OldIndexSort(ctx)
  11400. }
  11401. return nil, fmt.Errorf("unknown SopStage field %s", name)
  11402. }
  11403. // SetField sets the value of a field with the given name. It returns an error if
  11404. // the field is not defined in the schema, or if the type mismatched the field
  11405. // type.
  11406. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  11407. switch name {
  11408. case sopstage.FieldCreatedAt:
  11409. v, ok := value.(time.Time)
  11410. if !ok {
  11411. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11412. }
  11413. m.SetCreatedAt(v)
  11414. return nil
  11415. case sopstage.FieldUpdatedAt:
  11416. v, ok := value.(time.Time)
  11417. if !ok {
  11418. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11419. }
  11420. m.SetUpdatedAt(v)
  11421. return nil
  11422. case sopstage.FieldStatus:
  11423. v, ok := value.(uint8)
  11424. if !ok {
  11425. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11426. }
  11427. m.SetStatus(v)
  11428. return nil
  11429. case sopstage.FieldDeletedAt:
  11430. v, ok := value.(time.Time)
  11431. if !ok {
  11432. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11433. }
  11434. m.SetDeletedAt(v)
  11435. return nil
  11436. case sopstage.FieldTaskID:
  11437. v, ok := value.(uint64)
  11438. if !ok {
  11439. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11440. }
  11441. m.SetTaskID(v)
  11442. return nil
  11443. case sopstage.FieldName:
  11444. v, ok := value.(string)
  11445. if !ok {
  11446. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11447. }
  11448. m.SetName(v)
  11449. return nil
  11450. case sopstage.FieldConditionType:
  11451. v, ok := value.(int)
  11452. if !ok {
  11453. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11454. }
  11455. m.SetConditionType(v)
  11456. return nil
  11457. case sopstage.FieldConditionOperator:
  11458. v, ok := value.(int)
  11459. if !ok {
  11460. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11461. }
  11462. m.SetConditionOperator(v)
  11463. return nil
  11464. case sopstage.FieldConditionList:
  11465. v, ok := value.([]custom_types.Condition)
  11466. if !ok {
  11467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11468. }
  11469. m.SetConditionList(v)
  11470. return nil
  11471. case sopstage.FieldActionMessage:
  11472. v, ok := value.([]custom_types.Action)
  11473. if !ok {
  11474. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11475. }
  11476. m.SetActionMessage(v)
  11477. return nil
  11478. case sopstage.FieldActionLabel:
  11479. v, ok := value.([]uint64)
  11480. if !ok {
  11481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11482. }
  11483. m.SetActionLabel(v)
  11484. return nil
  11485. case sopstage.FieldIndexSort:
  11486. v, ok := value.(int)
  11487. if !ok {
  11488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11489. }
  11490. m.SetIndexSort(v)
  11491. return nil
  11492. }
  11493. return fmt.Errorf("unknown SopStage field %s", name)
  11494. }
  11495. // AddedFields returns all numeric fields that were incremented/decremented during
  11496. // this mutation.
  11497. func (m *SopStageMutation) AddedFields() []string {
  11498. var fields []string
  11499. if m.addstatus != nil {
  11500. fields = append(fields, sopstage.FieldStatus)
  11501. }
  11502. if m.addcondition_type != nil {
  11503. fields = append(fields, sopstage.FieldConditionType)
  11504. }
  11505. if m.addcondition_operator != nil {
  11506. fields = append(fields, sopstage.FieldConditionOperator)
  11507. }
  11508. if m.addindex_sort != nil {
  11509. fields = append(fields, sopstage.FieldIndexSort)
  11510. }
  11511. return fields
  11512. }
  11513. // AddedField returns the numeric value that was incremented/decremented on a field
  11514. // with the given name. The second boolean return value indicates that this field
  11515. // was not set, or was not defined in the schema.
  11516. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  11517. switch name {
  11518. case sopstage.FieldStatus:
  11519. return m.AddedStatus()
  11520. case sopstage.FieldConditionType:
  11521. return m.AddedConditionType()
  11522. case sopstage.FieldConditionOperator:
  11523. return m.AddedConditionOperator()
  11524. case sopstage.FieldIndexSort:
  11525. return m.AddedIndexSort()
  11526. }
  11527. return nil, false
  11528. }
  11529. // AddField adds the value to the field with the given name. It returns an error if
  11530. // the field is not defined in the schema, or if the type mismatched the field
  11531. // type.
  11532. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  11533. switch name {
  11534. case sopstage.FieldStatus:
  11535. v, ok := value.(int8)
  11536. if !ok {
  11537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11538. }
  11539. m.AddStatus(v)
  11540. return nil
  11541. case sopstage.FieldConditionType:
  11542. v, ok := value.(int)
  11543. if !ok {
  11544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11545. }
  11546. m.AddConditionType(v)
  11547. return nil
  11548. case sopstage.FieldConditionOperator:
  11549. v, ok := value.(int)
  11550. if !ok {
  11551. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11552. }
  11553. m.AddConditionOperator(v)
  11554. return nil
  11555. case sopstage.FieldIndexSort:
  11556. v, ok := value.(int)
  11557. if !ok {
  11558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11559. }
  11560. m.AddIndexSort(v)
  11561. return nil
  11562. }
  11563. return fmt.Errorf("unknown SopStage numeric field %s", name)
  11564. }
  11565. // ClearedFields returns all nullable fields that were cleared during this
  11566. // mutation.
  11567. func (m *SopStageMutation) ClearedFields() []string {
  11568. var fields []string
  11569. if m.FieldCleared(sopstage.FieldStatus) {
  11570. fields = append(fields, sopstage.FieldStatus)
  11571. }
  11572. if m.FieldCleared(sopstage.FieldDeletedAt) {
  11573. fields = append(fields, sopstage.FieldDeletedAt)
  11574. }
  11575. if m.FieldCleared(sopstage.FieldActionMessage) {
  11576. fields = append(fields, sopstage.FieldActionMessage)
  11577. }
  11578. if m.FieldCleared(sopstage.FieldActionLabel) {
  11579. fields = append(fields, sopstage.FieldActionLabel)
  11580. }
  11581. if m.FieldCleared(sopstage.FieldIndexSort) {
  11582. fields = append(fields, sopstage.FieldIndexSort)
  11583. }
  11584. return fields
  11585. }
  11586. // FieldCleared returns a boolean indicating if a field with the given name was
  11587. // cleared in this mutation.
  11588. func (m *SopStageMutation) FieldCleared(name string) bool {
  11589. _, ok := m.clearedFields[name]
  11590. return ok
  11591. }
  11592. // ClearField clears the value of the field with the given name. It returns an
  11593. // error if the field is not defined in the schema.
  11594. func (m *SopStageMutation) ClearField(name string) error {
  11595. switch name {
  11596. case sopstage.FieldStatus:
  11597. m.ClearStatus()
  11598. return nil
  11599. case sopstage.FieldDeletedAt:
  11600. m.ClearDeletedAt()
  11601. return nil
  11602. case sopstage.FieldActionMessage:
  11603. m.ClearActionMessage()
  11604. return nil
  11605. case sopstage.FieldActionLabel:
  11606. m.ClearActionLabel()
  11607. return nil
  11608. case sopstage.FieldIndexSort:
  11609. m.ClearIndexSort()
  11610. return nil
  11611. }
  11612. return fmt.Errorf("unknown SopStage nullable field %s", name)
  11613. }
  11614. // ResetField resets all changes in the mutation for the field with the given name.
  11615. // It returns an error if the field is not defined in the schema.
  11616. func (m *SopStageMutation) ResetField(name string) error {
  11617. switch name {
  11618. case sopstage.FieldCreatedAt:
  11619. m.ResetCreatedAt()
  11620. return nil
  11621. case sopstage.FieldUpdatedAt:
  11622. m.ResetUpdatedAt()
  11623. return nil
  11624. case sopstage.FieldStatus:
  11625. m.ResetStatus()
  11626. return nil
  11627. case sopstage.FieldDeletedAt:
  11628. m.ResetDeletedAt()
  11629. return nil
  11630. case sopstage.FieldTaskID:
  11631. m.ResetTaskID()
  11632. return nil
  11633. case sopstage.FieldName:
  11634. m.ResetName()
  11635. return nil
  11636. case sopstage.FieldConditionType:
  11637. m.ResetConditionType()
  11638. return nil
  11639. case sopstage.FieldConditionOperator:
  11640. m.ResetConditionOperator()
  11641. return nil
  11642. case sopstage.FieldConditionList:
  11643. m.ResetConditionList()
  11644. return nil
  11645. case sopstage.FieldActionMessage:
  11646. m.ResetActionMessage()
  11647. return nil
  11648. case sopstage.FieldActionLabel:
  11649. m.ResetActionLabel()
  11650. return nil
  11651. case sopstage.FieldIndexSort:
  11652. m.ResetIndexSort()
  11653. return nil
  11654. }
  11655. return fmt.Errorf("unknown SopStage field %s", name)
  11656. }
  11657. // AddedEdges returns all edge names that were set/added in this mutation.
  11658. func (m *SopStageMutation) AddedEdges() []string {
  11659. edges := make([]string, 0, 3)
  11660. if m.sop_task != nil {
  11661. edges = append(edges, sopstage.EdgeSopTask)
  11662. }
  11663. if m.stage_nodes != nil {
  11664. edges = append(edges, sopstage.EdgeStageNodes)
  11665. }
  11666. if m.stage_messages != nil {
  11667. edges = append(edges, sopstage.EdgeStageMessages)
  11668. }
  11669. return edges
  11670. }
  11671. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11672. // name in this mutation.
  11673. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  11674. switch name {
  11675. case sopstage.EdgeSopTask:
  11676. if id := m.sop_task; id != nil {
  11677. return []ent.Value{*id}
  11678. }
  11679. case sopstage.EdgeStageNodes:
  11680. ids := make([]ent.Value, 0, len(m.stage_nodes))
  11681. for id := range m.stage_nodes {
  11682. ids = append(ids, id)
  11683. }
  11684. return ids
  11685. case sopstage.EdgeStageMessages:
  11686. ids := make([]ent.Value, 0, len(m.stage_messages))
  11687. for id := range m.stage_messages {
  11688. ids = append(ids, id)
  11689. }
  11690. return ids
  11691. }
  11692. return nil
  11693. }
  11694. // RemovedEdges returns all edge names that were removed in this mutation.
  11695. func (m *SopStageMutation) RemovedEdges() []string {
  11696. edges := make([]string, 0, 3)
  11697. if m.removedstage_nodes != nil {
  11698. edges = append(edges, sopstage.EdgeStageNodes)
  11699. }
  11700. if m.removedstage_messages != nil {
  11701. edges = append(edges, sopstage.EdgeStageMessages)
  11702. }
  11703. return edges
  11704. }
  11705. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11706. // the given name in this mutation.
  11707. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  11708. switch name {
  11709. case sopstage.EdgeStageNodes:
  11710. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  11711. for id := range m.removedstage_nodes {
  11712. ids = append(ids, id)
  11713. }
  11714. return ids
  11715. case sopstage.EdgeStageMessages:
  11716. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  11717. for id := range m.removedstage_messages {
  11718. ids = append(ids, id)
  11719. }
  11720. return ids
  11721. }
  11722. return nil
  11723. }
  11724. // ClearedEdges returns all edge names that were cleared in this mutation.
  11725. func (m *SopStageMutation) ClearedEdges() []string {
  11726. edges := make([]string, 0, 3)
  11727. if m.clearedsop_task {
  11728. edges = append(edges, sopstage.EdgeSopTask)
  11729. }
  11730. if m.clearedstage_nodes {
  11731. edges = append(edges, sopstage.EdgeStageNodes)
  11732. }
  11733. if m.clearedstage_messages {
  11734. edges = append(edges, sopstage.EdgeStageMessages)
  11735. }
  11736. return edges
  11737. }
  11738. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11739. // was cleared in this mutation.
  11740. func (m *SopStageMutation) EdgeCleared(name string) bool {
  11741. switch name {
  11742. case sopstage.EdgeSopTask:
  11743. return m.clearedsop_task
  11744. case sopstage.EdgeStageNodes:
  11745. return m.clearedstage_nodes
  11746. case sopstage.EdgeStageMessages:
  11747. return m.clearedstage_messages
  11748. }
  11749. return false
  11750. }
  11751. // ClearEdge clears the value of the edge with the given name. It returns an error
  11752. // if that edge is not defined in the schema.
  11753. func (m *SopStageMutation) ClearEdge(name string) error {
  11754. switch name {
  11755. case sopstage.EdgeSopTask:
  11756. m.ClearSopTask()
  11757. return nil
  11758. }
  11759. return fmt.Errorf("unknown SopStage unique edge %s", name)
  11760. }
  11761. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11762. // It returns an error if the edge is not defined in the schema.
  11763. func (m *SopStageMutation) ResetEdge(name string) error {
  11764. switch name {
  11765. case sopstage.EdgeSopTask:
  11766. m.ResetSopTask()
  11767. return nil
  11768. case sopstage.EdgeStageNodes:
  11769. m.ResetStageNodes()
  11770. return nil
  11771. case sopstage.EdgeStageMessages:
  11772. m.ResetStageMessages()
  11773. return nil
  11774. }
  11775. return fmt.Errorf("unknown SopStage edge %s", name)
  11776. }
  11777. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  11778. type SopTaskMutation struct {
  11779. config
  11780. op Op
  11781. typ string
  11782. id *uint64
  11783. created_at *time.Time
  11784. updated_at *time.Time
  11785. status *uint8
  11786. addstatus *int8
  11787. deleted_at *time.Time
  11788. name *string
  11789. bot_wxid_list *[]string
  11790. appendbot_wxid_list []string
  11791. _type *int
  11792. add_type *int
  11793. plan_start_time *time.Time
  11794. plan_end_time *time.Time
  11795. creator_id *string
  11796. organization_id *uint64
  11797. addorganization_id *int64
  11798. clearedFields map[string]struct{}
  11799. task_stages map[uint64]struct{}
  11800. removedtask_stages map[uint64]struct{}
  11801. clearedtask_stages bool
  11802. done bool
  11803. oldValue func(context.Context) (*SopTask, error)
  11804. predicates []predicate.SopTask
  11805. }
  11806. var _ ent.Mutation = (*SopTaskMutation)(nil)
  11807. // soptaskOption allows management of the mutation configuration using functional options.
  11808. type soptaskOption func(*SopTaskMutation)
  11809. // newSopTaskMutation creates new mutation for the SopTask entity.
  11810. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  11811. m := &SopTaskMutation{
  11812. config: c,
  11813. op: op,
  11814. typ: TypeSopTask,
  11815. clearedFields: make(map[string]struct{}),
  11816. }
  11817. for _, opt := range opts {
  11818. opt(m)
  11819. }
  11820. return m
  11821. }
  11822. // withSopTaskID sets the ID field of the mutation.
  11823. func withSopTaskID(id uint64) soptaskOption {
  11824. return func(m *SopTaskMutation) {
  11825. var (
  11826. err error
  11827. once sync.Once
  11828. value *SopTask
  11829. )
  11830. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  11831. once.Do(func() {
  11832. if m.done {
  11833. err = errors.New("querying old values post mutation is not allowed")
  11834. } else {
  11835. value, err = m.Client().SopTask.Get(ctx, id)
  11836. }
  11837. })
  11838. return value, err
  11839. }
  11840. m.id = &id
  11841. }
  11842. }
  11843. // withSopTask sets the old SopTask of the mutation.
  11844. func withSopTask(node *SopTask) soptaskOption {
  11845. return func(m *SopTaskMutation) {
  11846. m.oldValue = func(context.Context) (*SopTask, error) {
  11847. return node, nil
  11848. }
  11849. m.id = &node.ID
  11850. }
  11851. }
  11852. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11853. // executed in a transaction (ent.Tx), a transactional client is returned.
  11854. func (m SopTaskMutation) Client() *Client {
  11855. client := &Client{config: m.config}
  11856. client.init()
  11857. return client
  11858. }
  11859. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11860. // it returns an error otherwise.
  11861. func (m SopTaskMutation) Tx() (*Tx, error) {
  11862. if _, ok := m.driver.(*txDriver); !ok {
  11863. return nil, errors.New("ent: mutation is not running in a transaction")
  11864. }
  11865. tx := &Tx{config: m.config}
  11866. tx.init()
  11867. return tx, nil
  11868. }
  11869. // SetID sets the value of the id field. Note that this
  11870. // operation is only accepted on creation of SopTask entities.
  11871. func (m *SopTaskMutation) SetID(id uint64) {
  11872. m.id = &id
  11873. }
  11874. // ID returns the ID value in the mutation. Note that the ID is only available
  11875. // if it was provided to the builder or after it was returned from the database.
  11876. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  11877. if m.id == nil {
  11878. return
  11879. }
  11880. return *m.id, true
  11881. }
  11882. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11883. // That means, if the mutation is applied within a transaction with an isolation level such
  11884. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11885. // or updated by the mutation.
  11886. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  11887. switch {
  11888. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11889. id, exists := m.ID()
  11890. if exists {
  11891. return []uint64{id}, nil
  11892. }
  11893. fallthrough
  11894. case m.op.Is(OpUpdate | OpDelete):
  11895. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  11896. default:
  11897. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11898. }
  11899. }
  11900. // SetCreatedAt sets the "created_at" field.
  11901. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  11902. m.created_at = &t
  11903. }
  11904. // CreatedAt returns the value of the "created_at" field in the mutation.
  11905. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  11906. v := m.created_at
  11907. if v == nil {
  11908. return
  11909. }
  11910. return *v, true
  11911. }
  11912. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  11913. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  11914. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11915. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11916. if !m.op.Is(OpUpdateOne) {
  11917. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11918. }
  11919. if m.id == nil || m.oldValue == nil {
  11920. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11921. }
  11922. oldValue, err := m.oldValue(ctx)
  11923. if err != nil {
  11924. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11925. }
  11926. return oldValue.CreatedAt, nil
  11927. }
  11928. // ResetCreatedAt resets all changes to the "created_at" field.
  11929. func (m *SopTaskMutation) ResetCreatedAt() {
  11930. m.created_at = nil
  11931. }
  11932. // SetUpdatedAt sets the "updated_at" field.
  11933. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  11934. m.updated_at = &t
  11935. }
  11936. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11937. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  11938. v := m.updated_at
  11939. if v == nil {
  11940. return
  11941. }
  11942. return *v, true
  11943. }
  11944. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  11945. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  11946. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11947. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11948. if !m.op.Is(OpUpdateOne) {
  11949. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11950. }
  11951. if m.id == nil || m.oldValue == nil {
  11952. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11953. }
  11954. oldValue, err := m.oldValue(ctx)
  11955. if err != nil {
  11956. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11957. }
  11958. return oldValue.UpdatedAt, nil
  11959. }
  11960. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11961. func (m *SopTaskMutation) ResetUpdatedAt() {
  11962. m.updated_at = nil
  11963. }
  11964. // SetStatus sets the "status" field.
  11965. func (m *SopTaskMutation) SetStatus(u uint8) {
  11966. m.status = &u
  11967. m.addstatus = nil
  11968. }
  11969. // Status returns the value of the "status" field in the mutation.
  11970. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  11971. v := m.status
  11972. if v == nil {
  11973. return
  11974. }
  11975. return *v, true
  11976. }
  11977. // OldStatus returns the old "status" field's value of the SopTask entity.
  11978. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  11979. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11980. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11981. if !m.op.Is(OpUpdateOne) {
  11982. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11983. }
  11984. if m.id == nil || m.oldValue == nil {
  11985. return v, errors.New("OldStatus requires an ID field in the mutation")
  11986. }
  11987. oldValue, err := m.oldValue(ctx)
  11988. if err != nil {
  11989. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11990. }
  11991. return oldValue.Status, nil
  11992. }
  11993. // AddStatus adds u to the "status" field.
  11994. func (m *SopTaskMutation) AddStatus(u int8) {
  11995. if m.addstatus != nil {
  11996. *m.addstatus += u
  11997. } else {
  11998. m.addstatus = &u
  11999. }
  12000. }
  12001. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12002. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  12003. v := m.addstatus
  12004. if v == nil {
  12005. return
  12006. }
  12007. return *v, true
  12008. }
  12009. // ClearStatus clears the value of the "status" field.
  12010. func (m *SopTaskMutation) ClearStatus() {
  12011. m.status = nil
  12012. m.addstatus = nil
  12013. m.clearedFields[soptask.FieldStatus] = struct{}{}
  12014. }
  12015. // StatusCleared returns if the "status" field was cleared in this mutation.
  12016. func (m *SopTaskMutation) StatusCleared() bool {
  12017. _, ok := m.clearedFields[soptask.FieldStatus]
  12018. return ok
  12019. }
  12020. // ResetStatus resets all changes to the "status" field.
  12021. func (m *SopTaskMutation) ResetStatus() {
  12022. m.status = nil
  12023. m.addstatus = nil
  12024. delete(m.clearedFields, soptask.FieldStatus)
  12025. }
  12026. // SetDeletedAt sets the "deleted_at" field.
  12027. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  12028. m.deleted_at = &t
  12029. }
  12030. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12031. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  12032. v := m.deleted_at
  12033. if v == nil {
  12034. return
  12035. }
  12036. return *v, true
  12037. }
  12038. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  12039. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12040. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12041. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12042. if !m.op.Is(OpUpdateOne) {
  12043. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12044. }
  12045. if m.id == nil || m.oldValue == nil {
  12046. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12047. }
  12048. oldValue, err := m.oldValue(ctx)
  12049. if err != nil {
  12050. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12051. }
  12052. return oldValue.DeletedAt, nil
  12053. }
  12054. // ClearDeletedAt clears the value of the "deleted_at" field.
  12055. func (m *SopTaskMutation) ClearDeletedAt() {
  12056. m.deleted_at = nil
  12057. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  12058. }
  12059. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12060. func (m *SopTaskMutation) DeletedAtCleared() bool {
  12061. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  12062. return ok
  12063. }
  12064. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12065. func (m *SopTaskMutation) ResetDeletedAt() {
  12066. m.deleted_at = nil
  12067. delete(m.clearedFields, soptask.FieldDeletedAt)
  12068. }
  12069. // SetName sets the "name" field.
  12070. func (m *SopTaskMutation) SetName(s string) {
  12071. m.name = &s
  12072. }
  12073. // Name returns the value of the "name" field in the mutation.
  12074. func (m *SopTaskMutation) Name() (r string, exists bool) {
  12075. v := m.name
  12076. if v == nil {
  12077. return
  12078. }
  12079. return *v, true
  12080. }
  12081. // OldName returns the old "name" field's value of the SopTask entity.
  12082. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12083. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12084. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  12085. if !m.op.Is(OpUpdateOne) {
  12086. return v, errors.New("OldName is only allowed on UpdateOne operations")
  12087. }
  12088. if m.id == nil || m.oldValue == nil {
  12089. return v, errors.New("OldName requires an ID field in the mutation")
  12090. }
  12091. oldValue, err := m.oldValue(ctx)
  12092. if err != nil {
  12093. return v, fmt.Errorf("querying old value for OldName: %w", err)
  12094. }
  12095. return oldValue.Name, nil
  12096. }
  12097. // ResetName resets all changes to the "name" field.
  12098. func (m *SopTaskMutation) ResetName() {
  12099. m.name = nil
  12100. }
  12101. // SetBotWxidList sets the "bot_wxid_list" field.
  12102. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  12103. m.bot_wxid_list = &s
  12104. m.appendbot_wxid_list = nil
  12105. }
  12106. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  12107. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  12108. v := m.bot_wxid_list
  12109. if v == nil {
  12110. return
  12111. }
  12112. return *v, true
  12113. }
  12114. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  12115. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12116. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12117. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  12118. if !m.op.Is(OpUpdateOne) {
  12119. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  12120. }
  12121. if m.id == nil || m.oldValue == nil {
  12122. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  12123. }
  12124. oldValue, err := m.oldValue(ctx)
  12125. if err != nil {
  12126. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  12127. }
  12128. return oldValue.BotWxidList, nil
  12129. }
  12130. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  12131. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  12132. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  12133. }
  12134. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  12135. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  12136. if len(m.appendbot_wxid_list) == 0 {
  12137. return nil, false
  12138. }
  12139. return m.appendbot_wxid_list, true
  12140. }
  12141. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  12142. func (m *SopTaskMutation) ClearBotWxidList() {
  12143. m.bot_wxid_list = nil
  12144. m.appendbot_wxid_list = nil
  12145. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  12146. }
  12147. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  12148. func (m *SopTaskMutation) BotWxidListCleared() bool {
  12149. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  12150. return ok
  12151. }
  12152. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  12153. func (m *SopTaskMutation) ResetBotWxidList() {
  12154. m.bot_wxid_list = nil
  12155. m.appendbot_wxid_list = nil
  12156. delete(m.clearedFields, soptask.FieldBotWxidList)
  12157. }
  12158. // SetType sets the "type" field.
  12159. func (m *SopTaskMutation) SetType(i int) {
  12160. m._type = &i
  12161. m.add_type = nil
  12162. }
  12163. // GetType returns the value of the "type" field in the mutation.
  12164. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  12165. v := m._type
  12166. if v == nil {
  12167. return
  12168. }
  12169. return *v, true
  12170. }
  12171. // OldType returns the old "type" field's value of the SopTask entity.
  12172. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12173. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12174. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  12175. if !m.op.Is(OpUpdateOne) {
  12176. return v, errors.New("OldType is only allowed on UpdateOne operations")
  12177. }
  12178. if m.id == nil || m.oldValue == nil {
  12179. return v, errors.New("OldType requires an ID field in the mutation")
  12180. }
  12181. oldValue, err := m.oldValue(ctx)
  12182. if err != nil {
  12183. return v, fmt.Errorf("querying old value for OldType: %w", err)
  12184. }
  12185. return oldValue.Type, nil
  12186. }
  12187. // AddType adds i to the "type" field.
  12188. func (m *SopTaskMutation) AddType(i int) {
  12189. if m.add_type != nil {
  12190. *m.add_type += i
  12191. } else {
  12192. m.add_type = &i
  12193. }
  12194. }
  12195. // AddedType returns the value that was added to the "type" field in this mutation.
  12196. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  12197. v := m.add_type
  12198. if v == nil {
  12199. return
  12200. }
  12201. return *v, true
  12202. }
  12203. // ResetType resets all changes to the "type" field.
  12204. func (m *SopTaskMutation) ResetType() {
  12205. m._type = nil
  12206. m.add_type = nil
  12207. }
  12208. // SetPlanStartTime sets the "plan_start_time" field.
  12209. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  12210. m.plan_start_time = &t
  12211. }
  12212. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  12213. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  12214. v := m.plan_start_time
  12215. if v == nil {
  12216. return
  12217. }
  12218. return *v, true
  12219. }
  12220. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  12221. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12223. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  12224. if !m.op.Is(OpUpdateOne) {
  12225. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  12226. }
  12227. if m.id == nil || m.oldValue == nil {
  12228. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  12229. }
  12230. oldValue, err := m.oldValue(ctx)
  12231. if err != nil {
  12232. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  12233. }
  12234. return oldValue.PlanStartTime, nil
  12235. }
  12236. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  12237. func (m *SopTaskMutation) ClearPlanStartTime() {
  12238. m.plan_start_time = nil
  12239. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  12240. }
  12241. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  12242. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  12243. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  12244. return ok
  12245. }
  12246. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  12247. func (m *SopTaskMutation) ResetPlanStartTime() {
  12248. m.plan_start_time = nil
  12249. delete(m.clearedFields, soptask.FieldPlanStartTime)
  12250. }
  12251. // SetPlanEndTime sets the "plan_end_time" field.
  12252. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  12253. m.plan_end_time = &t
  12254. }
  12255. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  12256. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  12257. v := m.plan_end_time
  12258. if v == nil {
  12259. return
  12260. }
  12261. return *v, true
  12262. }
  12263. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  12264. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12266. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  12267. if !m.op.Is(OpUpdateOne) {
  12268. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  12269. }
  12270. if m.id == nil || m.oldValue == nil {
  12271. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  12272. }
  12273. oldValue, err := m.oldValue(ctx)
  12274. if err != nil {
  12275. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  12276. }
  12277. return oldValue.PlanEndTime, nil
  12278. }
  12279. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  12280. func (m *SopTaskMutation) ClearPlanEndTime() {
  12281. m.plan_end_time = nil
  12282. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  12283. }
  12284. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  12285. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  12286. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  12287. return ok
  12288. }
  12289. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  12290. func (m *SopTaskMutation) ResetPlanEndTime() {
  12291. m.plan_end_time = nil
  12292. delete(m.clearedFields, soptask.FieldPlanEndTime)
  12293. }
  12294. // SetCreatorID sets the "creator_id" field.
  12295. func (m *SopTaskMutation) SetCreatorID(s string) {
  12296. m.creator_id = &s
  12297. }
  12298. // CreatorID returns the value of the "creator_id" field in the mutation.
  12299. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  12300. v := m.creator_id
  12301. if v == nil {
  12302. return
  12303. }
  12304. return *v, true
  12305. }
  12306. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  12307. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12308. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12309. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  12310. if !m.op.Is(OpUpdateOne) {
  12311. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  12312. }
  12313. if m.id == nil || m.oldValue == nil {
  12314. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  12315. }
  12316. oldValue, err := m.oldValue(ctx)
  12317. if err != nil {
  12318. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  12319. }
  12320. return oldValue.CreatorID, nil
  12321. }
  12322. // ClearCreatorID clears the value of the "creator_id" field.
  12323. func (m *SopTaskMutation) ClearCreatorID() {
  12324. m.creator_id = nil
  12325. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  12326. }
  12327. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  12328. func (m *SopTaskMutation) CreatorIDCleared() bool {
  12329. _, ok := m.clearedFields[soptask.FieldCreatorID]
  12330. return ok
  12331. }
  12332. // ResetCreatorID resets all changes to the "creator_id" field.
  12333. func (m *SopTaskMutation) ResetCreatorID() {
  12334. m.creator_id = nil
  12335. delete(m.clearedFields, soptask.FieldCreatorID)
  12336. }
  12337. // SetOrganizationID sets the "organization_id" field.
  12338. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  12339. m.organization_id = &u
  12340. m.addorganization_id = nil
  12341. }
  12342. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12343. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  12344. v := m.organization_id
  12345. if v == nil {
  12346. return
  12347. }
  12348. return *v, true
  12349. }
  12350. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  12351. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  12352. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12353. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12354. if !m.op.Is(OpUpdateOne) {
  12355. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12356. }
  12357. if m.id == nil || m.oldValue == nil {
  12358. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12359. }
  12360. oldValue, err := m.oldValue(ctx)
  12361. if err != nil {
  12362. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12363. }
  12364. return oldValue.OrganizationID, nil
  12365. }
  12366. // AddOrganizationID adds u to the "organization_id" field.
  12367. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  12368. if m.addorganization_id != nil {
  12369. *m.addorganization_id += u
  12370. } else {
  12371. m.addorganization_id = &u
  12372. }
  12373. }
  12374. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12375. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  12376. v := m.addorganization_id
  12377. if v == nil {
  12378. return
  12379. }
  12380. return *v, true
  12381. }
  12382. // ClearOrganizationID clears the value of the "organization_id" field.
  12383. func (m *SopTaskMutation) ClearOrganizationID() {
  12384. m.organization_id = nil
  12385. m.addorganization_id = nil
  12386. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  12387. }
  12388. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  12389. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  12390. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  12391. return ok
  12392. }
  12393. // ResetOrganizationID resets all changes to the "organization_id" field.
  12394. func (m *SopTaskMutation) ResetOrganizationID() {
  12395. m.organization_id = nil
  12396. m.addorganization_id = nil
  12397. delete(m.clearedFields, soptask.FieldOrganizationID)
  12398. }
  12399. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  12400. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  12401. if m.task_stages == nil {
  12402. m.task_stages = make(map[uint64]struct{})
  12403. }
  12404. for i := range ids {
  12405. m.task_stages[ids[i]] = struct{}{}
  12406. }
  12407. }
  12408. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  12409. func (m *SopTaskMutation) ClearTaskStages() {
  12410. m.clearedtask_stages = true
  12411. }
  12412. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  12413. func (m *SopTaskMutation) TaskStagesCleared() bool {
  12414. return m.clearedtask_stages
  12415. }
  12416. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  12417. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  12418. if m.removedtask_stages == nil {
  12419. m.removedtask_stages = make(map[uint64]struct{})
  12420. }
  12421. for i := range ids {
  12422. delete(m.task_stages, ids[i])
  12423. m.removedtask_stages[ids[i]] = struct{}{}
  12424. }
  12425. }
  12426. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  12427. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  12428. for id := range m.removedtask_stages {
  12429. ids = append(ids, id)
  12430. }
  12431. return
  12432. }
  12433. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  12434. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  12435. for id := range m.task_stages {
  12436. ids = append(ids, id)
  12437. }
  12438. return
  12439. }
  12440. // ResetTaskStages resets all changes to the "task_stages" edge.
  12441. func (m *SopTaskMutation) ResetTaskStages() {
  12442. m.task_stages = nil
  12443. m.clearedtask_stages = false
  12444. m.removedtask_stages = nil
  12445. }
  12446. // Where appends a list predicates to the SopTaskMutation builder.
  12447. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  12448. m.predicates = append(m.predicates, ps...)
  12449. }
  12450. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  12451. // users can use type-assertion to append predicates that do not depend on any generated package.
  12452. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  12453. p := make([]predicate.SopTask, len(ps))
  12454. for i := range ps {
  12455. p[i] = ps[i]
  12456. }
  12457. m.Where(p...)
  12458. }
  12459. // Op returns the operation name.
  12460. func (m *SopTaskMutation) Op() Op {
  12461. return m.op
  12462. }
  12463. // SetOp allows setting the mutation operation.
  12464. func (m *SopTaskMutation) SetOp(op Op) {
  12465. m.op = op
  12466. }
  12467. // Type returns the node type of this mutation (SopTask).
  12468. func (m *SopTaskMutation) Type() string {
  12469. return m.typ
  12470. }
  12471. // Fields returns all fields that were changed during this mutation. Note that in
  12472. // order to get all numeric fields that were incremented/decremented, call
  12473. // AddedFields().
  12474. func (m *SopTaskMutation) Fields() []string {
  12475. fields := make([]string, 0, 11)
  12476. if m.created_at != nil {
  12477. fields = append(fields, soptask.FieldCreatedAt)
  12478. }
  12479. if m.updated_at != nil {
  12480. fields = append(fields, soptask.FieldUpdatedAt)
  12481. }
  12482. if m.status != nil {
  12483. fields = append(fields, soptask.FieldStatus)
  12484. }
  12485. if m.deleted_at != nil {
  12486. fields = append(fields, soptask.FieldDeletedAt)
  12487. }
  12488. if m.name != nil {
  12489. fields = append(fields, soptask.FieldName)
  12490. }
  12491. if m.bot_wxid_list != nil {
  12492. fields = append(fields, soptask.FieldBotWxidList)
  12493. }
  12494. if m._type != nil {
  12495. fields = append(fields, soptask.FieldType)
  12496. }
  12497. if m.plan_start_time != nil {
  12498. fields = append(fields, soptask.FieldPlanStartTime)
  12499. }
  12500. if m.plan_end_time != nil {
  12501. fields = append(fields, soptask.FieldPlanEndTime)
  12502. }
  12503. if m.creator_id != nil {
  12504. fields = append(fields, soptask.FieldCreatorID)
  12505. }
  12506. if m.organization_id != nil {
  12507. fields = append(fields, soptask.FieldOrganizationID)
  12508. }
  12509. return fields
  12510. }
  12511. // Field returns the value of a field with the given name. The second boolean
  12512. // return value indicates that this field was not set, or was not defined in the
  12513. // schema.
  12514. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  12515. switch name {
  12516. case soptask.FieldCreatedAt:
  12517. return m.CreatedAt()
  12518. case soptask.FieldUpdatedAt:
  12519. return m.UpdatedAt()
  12520. case soptask.FieldStatus:
  12521. return m.Status()
  12522. case soptask.FieldDeletedAt:
  12523. return m.DeletedAt()
  12524. case soptask.FieldName:
  12525. return m.Name()
  12526. case soptask.FieldBotWxidList:
  12527. return m.BotWxidList()
  12528. case soptask.FieldType:
  12529. return m.GetType()
  12530. case soptask.FieldPlanStartTime:
  12531. return m.PlanStartTime()
  12532. case soptask.FieldPlanEndTime:
  12533. return m.PlanEndTime()
  12534. case soptask.FieldCreatorID:
  12535. return m.CreatorID()
  12536. case soptask.FieldOrganizationID:
  12537. return m.OrganizationID()
  12538. }
  12539. return nil, false
  12540. }
  12541. // OldField returns the old value of the field from the database. An error is
  12542. // returned if the mutation operation is not UpdateOne, or the query to the
  12543. // database failed.
  12544. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12545. switch name {
  12546. case soptask.FieldCreatedAt:
  12547. return m.OldCreatedAt(ctx)
  12548. case soptask.FieldUpdatedAt:
  12549. return m.OldUpdatedAt(ctx)
  12550. case soptask.FieldStatus:
  12551. return m.OldStatus(ctx)
  12552. case soptask.FieldDeletedAt:
  12553. return m.OldDeletedAt(ctx)
  12554. case soptask.FieldName:
  12555. return m.OldName(ctx)
  12556. case soptask.FieldBotWxidList:
  12557. return m.OldBotWxidList(ctx)
  12558. case soptask.FieldType:
  12559. return m.OldType(ctx)
  12560. case soptask.FieldPlanStartTime:
  12561. return m.OldPlanStartTime(ctx)
  12562. case soptask.FieldPlanEndTime:
  12563. return m.OldPlanEndTime(ctx)
  12564. case soptask.FieldCreatorID:
  12565. return m.OldCreatorID(ctx)
  12566. case soptask.FieldOrganizationID:
  12567. return m.OldOrganizationID(ctx)
  12568. }
  12569. return nil, fmt.Errorf("unknown SopTask field %s", name)
  12570. }
  12571. // SetField sets the value of a field with the given name. It returns an error if
  12572. // the field is not defined in the schema, or if the type mismatched the field
  12573. // type.
  12574. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  12575. switch name {
  12576. case soptask.FieldCreatedAt:
  12577. v, ok := value.(time.Time)
  12578. if !ok {
  12579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12580. }
  12581. m.SetCreatedAt(v)
  12582. return nil
  12583. case soptask.FieldUpdatedAt:
  12584. v, ok := value.(time.Time)
  12585. if !ok {
  12586. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12587. }
  12588. m.SetUpdatedAt(v)
  12589. return nil
  12590. case soptask.FieldStatus:
  12591. v, ok := value.(uint8)
  12592. if !ok {
  12593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12594. }
  12595. m.SetStatus(v)
  12596. return nil
  12597. case soptask.FieldDeletedAt:
  12598. v, ok := value.(time.Time)
  12599. if !ok {
  12600. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12601. }
  12602. m.SetDeletedAt(v)
  12603. return nil
  12604. case soptask.FieldName:
  12605. v, ok := value.(string)
  12606. if !ok {
  12607. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12608. }
  12609. m.SetName(v)
  12610. return nil
  12611. case soptask.FieldBotWxidList:
  12612. v, ok := value.([]string)
  12613. if !ok {
  12614. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12615. }
  12616. m.SetBotWxidList(v)
  12617. return nil
  12618. case soptask.FieldType:
  12619. v, ok := value.(int)
  12620. if !ok {
  12621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12622. }
  12623. m.SetType(v)
  12624. return nil
  12625. case soptask.FieldPlanStartTime:
  12626. v, ok := value.(time.Time)
  12627. if !ok {
  12628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12629. }
  12630. m.SetPlanStartTime(v)
  12631. return nil
  12632. case soptask.FieldPlanEndTime:
  12633. v, ok := value.(time.Time)
  12634. if !ok {
  12635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12636. }
  12637. m.SetPlanEndTime(v)
  12638. return nil
  12639. case soptask.FieldCreatorID:
  12640. v, ok := value.(string)
  12641. if !ok {
  12642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12643. }
  12644. m.SetCreatorID(v)
  12645. return nil
  12646. case soptask.FieldOrganizationID:
  12647. v, ok := value.(uint64)
  12648. if !ok {
  12649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12650. }
  12651. m.SetOrganizationID(v)
  12652. return nil
  12653. }
  12654. return fmt.Errorf("unknown SopTask field %s", name)
  12655. }
  12656. // AddedFields returns all numeric fields that were incremented/decremented during
  12657. // this mutation.
  12658. func (m *SopTaskMutation) AddedFields() []string {
  12659. var fields []string
  12660. if m.addstatus != nil {
  12661. fields = append(fields, soptask.FieldStatus)
  12662. }
  12663. if m.add_type != nil {
  12664. fields = append(fields, soptask.FieldType)
  12665. }
  12666. if m.addorganization_id != nil {
  12667. fields = append(fields, soptask.FieldOrganizationID)
  12668. }
  12669. return fields
  12670. }
  12671. // AddedField returns the numeric value that was incremented/decremented on a field
  12672. // with the given name. The second boolean return value indicates that this field
  12673. // was not set, or was not defined in the schema.
  12674. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  12675. switch name {
  12676. case soptask.FieldStatus:
  12677. return m.AddedStatus()
  12678. case soptask.FieldType:
  12679. return m.AddedType()
  12680. case soptask.FieldOrganizationID:
  12681. return m.AddedOrganizationID()
  12682. }
  12683. return nil, false
  12684. }
  12685. // AddField adds the value to the field with the given name. It returns an error if
  12686. // the field is not defined in the schema, or if the type mismatched the field
  12687. // type.
  12688. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  12689. switch name {
  12690. case soptask.FieldStatus:
  12691. v, ok := value.(int8)
  12692. if !ok {
  12693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12694. }
  12695. m.AddStatus(v)
  12696. return nil
  12697. case soptask.FieldType:
  12698. v, ok := value.(int)
  12699. if !ok {
  12700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12701. }
  12702. m.AddType(v)
  12703. return nil
  12704. case soptask.FieldOrganizationID:
  12705. v, ok := value.(int64)
  12706. if !ok {
  12707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12708. }
  12709. m.AddOrganizationID(v)
  12710. return nil
  12711. }
  12712. return fmt.Errorf("unknown SopTask numeric field %s", name)
  12713. }
  12714. // ClearedFields returns all nullable fields that were cleared during this
  12715. // mutation.
  12716. func (m *SopTaskMutation) ClearedFields() []string {
  12717. var fields []string
  12718. if m.FieldCleared(soptask.FieldStatus) {
  12719. fields = append(fields, soptask.FieldStatus)
  12720. }
  12721. if m.FieldCleared(soptask.FieldDeletedAt) {
  12722. fields = append(fields, soptask.FieldDeletedAt)
  12723. }
  12724. if m.FieldCleared(soptask.FieldBotWxidList) {
  12725. fields = append(fields, soptask.FieldBotWxidList)
  12726. }
  12727. if m.FieldCleared(soptask.FieldPlanStartTime) {
  12728. fields = append(fields, soptask.FieldPlanStartTime)
  12729. }
  12730. if m.FieldCleared(soptask.FieldPlanEndTime) {
  12731. fields = append(fields, soptask.FieldPlanEndTime)
  12732. }
  12733. if m.FieldCleared(soptask.FieldCreatorID) {
  12734. fields = append(fields, soptask.FieldCreatorID)
  12735. }
  12736. if m.FieldCleared(soptask.FieldOrganizationID) {
  12737. fields = append(fields, soptask.FieldOrganizationID)
  12738. }
  12739. return fields
  12740. }
  12741. // FieldCleared returns a boolean indicating if a field with the given name was
  12742. // cleared in this mutation.
  12743. func (m *SopTaskMutation) FieldCleared(name string) bool {
  12744. _, ok := m.clearedFields[name]
  12745. return ok
  12746. }
  12747. // ClearField clears the value of the field with the given name. It returns an
  12748. // error if the field is not defined in the schema.
  12749. func (m *SopTaskMutation) ClearField(name string) error {
  12750. switch name {
  12751. case soptask.FieldStatus:
  12752. m.ClearStatus()
  12753. return nil
  12754. case soptask.FieldDeletedAt:
  12755. m.ClearDeletedAt()
  12756. return nil
  12757. case soptask.FieldBotWxidList:
  12758. m.ClearBotWxidList()
  12759. return nil
  12760. case soptask.FieldPlanStartTime:
  12761. m.ClearPlanStartTime()
  12762. return nil
  12763. case soptask.FieldPlanEndTime:
  12764. m.ClearPlanEndTime()
  12765. return nil
  12766. case soptask.FieldCreatorID:
  12767. m.ClearCreatorID()
  12768. return nil
  12769. case soptask.FieldOrganizationID:
  12770. m.ClearOrganizationID()
  12771. return nil
  12772. }
  12773. return fmt.Errorf("unknown SopTask nullable field %s", name)
  12774. }
  12775. // ResetField resets all changes in the mutation for the field with the given name.
  12776. // It returns an error if the field is not defined in the schema.
  12777. func (m *SopTaskMutation) ResetField(name string) error {
  12778. switch name {
  12779. case soptask.FieldCreatedAt:
  12780. m.ResetCreatedAt()
  12781. return nil
  12782. case soptask.FieldUpdatedAt:
  12783. m.ResetUpdatedAt()
  12784. return nil
  12785. case soptask.FieldStatus:
  12786. m.ResetStatus()
  12787. return nil
  12788. case soptask.FieldDeletedAt:
  12789. m.ResetDeletedAt()
  12790. return nil
  12791. case soptask.FieldName:
  12792. m.ResetName()
  12793. return nil
  12794. case soptask.FieldBotWxidList:
  12795. m.ResetBotWxidList()
  12796. return nil
  12797. case soptask.FieldType:
  12798. m.ResetType()
  12799. return nil
  12800. case soptask.FieldPlanStartTime:
  12801. m.ResetPlanStartTime()
  12802. return nil
  12803. case soptask.FieldPlanEndTime:
  12804. m.ResetPlanEndTime()
  12805. return nil
  12806. case soptask.FieldCreatorID:
  12807. m.ResetCreatorID()
  12808. return nil
  12809. case soptask.FieldOrganizationID:
  12810. m.ResetOrganizationID()
  12811. return nil
  12812. }
  12813. return fmt.Errorf("unknown SopTask field %s", name)
  12814. }
  12815. // AddedEdges returns all edge names that were set/added in this mutation.
  12816. func (m *SopTaskMutation) AddedEdges() []string {
  12817. edges := make([]string, 0, 1)
  12818. if m.task_stages != nil {
  12819. edges = append(edges, soptask.EdgeTaskStages)
  12820. }
  12821. return edges
  12822. }
  12823. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12824. // name in this mutation.
  12825. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  12826. switch name {
  12827. case soptask.EdgeTaskStages:
  12828. ids := make([]ent.Value, 0, len(m.task_stages))
  12829. for id := range m.task_stages {
  12830. ids = append(ids, id)
  12831. }
  12832. return ids
  12833. }
  12834. return nil
  12835. }
  12836. // RemovedEdges returns all edge names that were removed in this mutation.
  12837. func (m *SopTaskMutation) RemovedEdges() []string {
  12838. edges := make([]string, 0, 1)
  12839. if m.removedtask_stages != nil {
  12840. edges = append(edges, soptask.EdgeTaskStages)
  12841. }
  12842. return edges
  12843. }
  12844. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12845. // the given name in this mutation.
  12846. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  12847. switch name {
  12848. case soptask.EdgeTaskStages:
  12849. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  12850. for id := range m.removedtask_stages {
  12851. ids = append(ids, id)
  12852. }
  12853. return ids
  12854. }
  12855. return nil
  12856. }
  12857. // ClearedEdges returns all edge names that were cleared in this mutation.
  12858. func (m *SopTaskMutation) ClearedEdges() []string {
  12859. edges := make([]string, 0, 1)
  12860. if m.clearedtask_stages {
  12861. edges = append(edges, soptask.EdgeTaskStages)
  12862. }
  12863. return edges
  12864. }
  12865. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12866. // was cleared in this mutation.
  12867. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  12868. switch name {
  12869. case soptask.EdgeTaskStages:
  12870. return m.clearedtask_stages
  12871. }
  12872. return false
  12873. }
  12874. // ClearEdge clears the value of the edge with the given name. It returns an error
  12875. // if that edge is not defined in the schema.
  12876. func (m *SopTaskMutation) ClearEdge(name string) error {
  12877. switch name {
  12878. }
  12879. return fmt.Errorf("unknown SopTask unique edge %s", name)
  12880. }
  12881. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12882. // It returns an error if the edge is not defined in the schema.
  12883. func (m *SopTaskMutation) ResetEdge(name string) error {
  12884. switch name {
  12885. case soptask.EdgeTaskStages:
  12886. m.ResetTaskStages()
  12887. return nil
  12888. }
  12889. return fmt.Errorf("unknown SopTask edge %s", name)
  12890. }
  12891. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  12892. type WxMutation struct {
  12893. config
  12894. op Op
  12895. typ string
  12896. id *uint64
  12897. created_at *time.Time
  12898. updated_at *time.Time
  12899. status *uint8
  12900. addstatus *int8
  12901. deleted_at *time.Time
  12902. port *string
  12903. process_id *string
  12904. callback *string
  12905. wxid *string
  12906. account *string
  12907. nickname *string
  12908. tel *string
  12909. head_big *string
  12910. organization_id *uint64
  12911. addorganization_id *int64
  12912. clearedFields map[string]struct{}
  12913. server *uint64
  12914. clearedserver bool
  12915. done bool
  12916. oldValue func(context.Context) (*Wx, error)
  12917. predicates []predicate.Wx
  12918. }
  12919. var _ ent.Mutation = (*WxMutation)(nil)
  12920. // wxOption allows management of the mutation configuration using functional options.
  12921. type wxOption func(*WxMutation)
  12922. // newWxMutation creates new mutation for the Wx entity.
  12923. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  12924. m := &WxMutation{
  12925. config: c,
  12926. op: op,
  12927. typ: TypeWx,
  12928. clearedFields: make(map[string]struct{}),
  12929. }
  12930. for _, opt := range opts {
  12931. opt(m)
  12932. }
  12933. return m
  12934. }
  12935. // withWxID sets the ID field of the mutation.
  12936. func withWxID(id uint64) wxOption {
  12937. return func(m *WxMutation) {
  12938. var (
  12939. err error
  12940. once sync.Once
  12941. value *Wx
  12942. )
  12943. m.oldValue = func(ctx context.Context) (*Wx, error) {
  12944. once.Do(func() {
  12945. if m.done {
  12946. err = errors.New("querying old values post mutation is not allowed")
  12947. } else {
  12948. value, err = m.Client().Wx.Get(ctx, id)
  12949. }
  12950. })
  12951. return value, err
  12952. }
  12953. m.id = &id
  12954. }
  12955. }
  12956. // withWx sets the old Wx of the mutation.
  12957. func withWx(node *Wx) wxOption {
  12958. return func(m *WxMutation) {
  12959. m.oldValue = func(context.Context) (*Wx, error) {
  12960. return node, nil
  12961. }
  12962. m.id = &node.ID
  12963. }
  12964. }
  12965. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12966. // executed in a transaction (ent.Tx), a transactional client is returned.
  12967. func (m WxMutation) Client() *Client {
  12968. client := &Client{config: m.config}
  12969. client.init()
  12970. return client
  12971. }
  12972. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12973. // it returns an error otherwise.
  12974. func (m WxMutation) Tx() (*Tx, error) {
  12975. if _, ok := m.driver.(*txDriver); !ok {
  12976. return nil, errors.New("ent: mutation is not running in a transaction")
  12977. }
  12978. tx := &Tx{config: m.config}
  12979. tx.init()
  12980. return tx, nil
  12981. }
  12982. // SetID sets the value of the id field. Note that this
  12983. // operation is only accepted on creation of Wx entities.
  12984. func (m *WxMutation) SetID(id uint64) {
  12985. m.id = &id
  12986. }
  12987. // ID returns the ID value in the mutation. Note that the ID is only available
  12988. // if it was provided to the builder or after it was returned from the database.
  12989. func (m *WxMutation) ID() (id uint64, exists bool) {
  12990. if m.id == nil {
  12991. return
  12992. }
  12993. return *m.id, true
  12994. }
  12995. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12996. // That means, if the mutation is applied within a transaction with an isolation level such
  12997. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12998. // or updated by the mutation.
  12999. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  13000. switch {
  13001. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13002. id, exists := m.ID()
  13003. if exists {
  13004. return []uint64{id}, nil
  13005. }
  13006. fallthrough
  13007. case m.op.Is(OpUpdate | OpDelete):
  13008. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  13009. default:
  13010. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13011. }
  13012. }
  13013. // SetCreatedAt sets the "created_at" field.
  13014. func (m *WxMutation) SetCreatedAt(t time.Time) {
  13015. m.created_at = &t
  13016. }
  13017. // CreatedAt returns the value of the "created_at" field in the mutation.
  13018. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  13019. v := m.created_at
  13020. if v == nil {
  13021. return
  13022. }
  13023. return *v, true
  13024. }
  13025. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  13026. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13027. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13028. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13029. if !m.op.Is(OpUpdateOne) {
  13030. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13031. }
  13032. if m.id == nil || m.oldValue == nil {
  13033. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13034. }
  13035. oldValue, err := m.oldValue(ctx)
  13036. if err != nil {
  13037. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13038. }
  13039. return oldValue.CreatedAt, nil
  13040. }
  13041. // ResetCreatedAt resets all changes to the "created_at" field.
  13042. func (m *WxMutation) ResetCreatedAt() {
  13043. m.created_at = nil
  13044. }
  13045. // SetUpdatedAt sets the "updated_at" field.
  13046. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  13047. m.updated_at = &t
  13048. }
  13049. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13050. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  13051. v := m.updated_at
  13052. if v == nil {
  13053. return
  13054. }
  13055. return *v, true
  13056. }
  13057. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  13058. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13059. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13060. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13061. if !m.op.Is(OpUpdateOne) {
  13062. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13063. }
  13064. if m.id == nil || m.oldValue == nil {
  13065. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13066. }
  13067. oldValue, err := m.oldValue(ctx)
  13068. if err != nil {
  13069. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13070. }
  13071. return oldValue.UpdatedAt, nil
  13072. }
  13073. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13074. func (m *WxMutation) ResetUpdatedAt() {
  13075. m.updated_at = nil
  13076. }
  13077. // SetStatus sets the "status" field.
  13078. func (m *WxMutation) SetStatus(u uint8) {
  13079. m.status = &u
  13080. m.addstatus = nil
  13081. }
  13082. // Status returns the value of the "status" field in the mutation.
  13083. func (m *WxMutation) Status() (r uint8, exists bool) {
  13084. v := m.status
  13085. if v == nil {
  13086. return
  13087. }
  13088. return *v, true
  13089. }
  13090. // OldStatus returns the old "status" field's value of the Wx entity.
  13091. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13092. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13093. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13094. if !m.op.Is(OpUpdateOne) {
  13095. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13096. }
  13097. if m.id == nil || m.oldValue == nil {
  13098. return v, errors.New("OldStatus requires an ID field in the mutation")
  13099. }
  13100. oldValue, err := m.oldValue(ctx)
  13101. if err != nil {
  13102. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13103. }
  13104. return oldValue.Status, nil
  13105. }
  13106. // AddStatus adds u to the "status" field.
  13107. func (m *WxMutation) AddStatus(u int8) {
  13108. if m.addstatus != nil {
  13109. *m.addstatus += u
  13110. } else {
  13111. m.addstatus = &u
  13112. }
  13113. }
  13114. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13115. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  13116. v := m.addstatus
  13117. if v == nil {
  13118. return
  13119. }
  13120. return *v, true
  13121. }
  13122. // ClearStatus clears the value of the "status" field.
  13123. func (m *WxMutation) ClearStatus() {
  13124. m.status = nil
  13125. m.addstatus = nil
  13126. m.clearedFields[wx.FieldStatus] = struct{}{}
  13127. }
  13128. // StatusCleared returns if the "status" field was cleared in this mutation.
  13129. func (m *WxMutation) StatusCleared() bool {
  13130. _, ok := m.clearedFields[wx.FieldStatus]
  13131. return ok
  13132. }
  13133. // ResetStatus resets all changes to the "status" field.
  13134. func (m *WxMutation) ResetStatus() {
  13135. m.status = nil
  13136. m.addstatus = nil
  13137. delete(m.clearedFields, wx.FieldStatus)
  13138. }
  13139. // SetDeletedAt sets the "deleted_at" field.
  13140. func (m *WxMutation) SetDeletedAt(t time.Time) {
  13141. m.deleted_at = &t
  13142. }
  13143. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13144. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  13145. v := m.deleted_at
  13146. if v == nil {
  13147. return
  13148. }
  13149. return *v, true
  13150. }
  13151. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  13152. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13153. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13154. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13155. if !m.op.Is(OpUpdateOne) {
  13156. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13157. }
  13158. if m.id == nil || m.oldValue == nil {
  13159. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13160. }
  13161. oldValue, err := m.oldValue(ctx)
  13162. if err != nil {
  13163. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13164. }
  13165. return oldValue.DeletedAt, nil
  13166. }
  13167. // ClearDeletedAt clears the value of the "deleted_at" field.
  13168. func (m *WxMutation) ClearDeletedAt() {
  13169. m.deleted_at = nil
  13170. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  13171. }
  13172. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13173. func (m *WxMutation) DeletedAtCleared() bool {
  13174. _, ok := m.clearedFields[wx.FieldDeletedAt]
  13175. return ok
  13176. }
  13177. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13178. func (m *WxMutation) ResetDeletedAt() {
  13179. m.deleted_at = nil
  13180. delete(m.clearedFields, wx.FieldDeletedAt)
  13181. }
  13182. // SetServerID sets the "server_id" field.
  13183. func (m *WxMutation) SetServerID(u uint64) {
  13184. m.server = &u
  13185. }
  13186. // ServerID returns the value of the "server_id" field in the mutation.
  13187. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  13188. v := m.server
  13189. if v == nil {
  13190. return
  13191. }
  13192. return *v, true
  13193. }
  13194. // OldServerID returns the old "server_id" field's value of the Wx entity.
  13195. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13196. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13197. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  13198. if !m.op.Is(OpUpdateOne) {
  13199. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  13200. }
  13201. if m.id == nil || m.oldValue == nil {
  13202. return v, errors.New("OldServerID requires an ID field in the mutation")
  13203. }
  13204. oldValue, err := m.oldValue(ctx)
  13205. if err != nil {
  13206. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  13207. }
  13208. return oldValue.ServerID, nil
  13209. }
  13210. // ClearServerID clears the value of the "server_id" field.
  13211. func (m *WxMutation) ClearServerID() {
  13212. m.server = nil
  13213. m.clearedFields[wx.FieldServerID] = struct{}{}
  13214. }
  13215. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  13216. func (m *WxMutation) ServerIDCleared() bool {
  13217. _, ok := m.clearedFields[wx.FieldServerID]
  13218. return ok
  13219. }
  13220. // ResetServerID resets all changes to the "server_id" field.
  13221. func (m *WxMutation) ResetServerID() {
  13222. m.server = nil
  13223. delete(m.clearedFields, wx.FieldServerID)
  13224. }
  13225. // SetPort sets the "port" field.
  13226. func (m *WxMutation) SetPort(s string) {
  13227. m.port = &s
  13228. }
  13229. // Port returns the value of the "port" field in the mutation.
  13230. func (m *WxMutation) Port() (r string, exists bool) {
  13231. v := m.port
  13232. if v == nil {
  13233. return
  13234. }
  13235. return *v, true
  13236. }
  13237. // OldPort returns the old "port" field's value of the Wx entity.
  13238. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13239. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13240. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  13241. if !m.op.Is(OpUpdateOne) {
  13242. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  13243. }
  13244. if m.id == nil || m.oldValue == nil {
  13245. return v, errors.New("OldPort requires an ID field in the mutation")
  13246. }
  13247. oldValue, err := m.oldValue(ctx)
  13248. if err != nil {
  13249. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  13250. }
  13251. return oldValue.Port, nil
  13252. }
  13253. // ResetPort resets all changes to the "port" field.
  13254. func (m *WxMutation) ResetPort() {
  13255. m.port = nil
  13256. }
  13257. // SetProcessID sets the "process_id" field.
  13258. func (m *WxMutation) SetProcessID(s string) {
  13259. m.process_id = &s
  13260. }
  13261. // ProcessID returns the value of the "process_id" field in the mutation.
  13262. func (m *WxMutation) ProcessID() (r string, exists bool) {
  13263. v := m.process_id
  13264. if v == nil {
  13265. return
  13266. }
  13267. return *v, true
  13268. }
  13269. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  13270. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13272. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  13273. if !m.op.Is(OpUpdateOne) {
  13274. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  13275. }
  13276. if m.id == nil || m.oldValue == nil {
  13277. return v, errors.New("OldProcessID requires an ID field in the mutation")
  13278. }
  13279. oldValue, err := m.oldValue(ctx)
  13280. if err != nil {
  13281. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  13282. }
  13283. return oldValue.ProcessID, nil
  13284. }
  13285. // ResetProcessID resets all changes to the "process_id" field.
  13286. func (m *WxMutation) ResetProcessID() {
  13287. m.process_id = nil
  13288. }
  13289. // SetCallback sets the "callback" field.
  13290. func (m *WxMutation) SetCallback(s string) {
  13291. m.callback = &s
  13292. }
  13293. // Callback returns the value of the "callback" field in the mutation.
  13294. func (m *WxMutation) Callback() (r string, exists bool) {
  13295. v := m.callback
  13296. if v == nil {
  13297. return
  13298. }
  13299. return *v, true
  13300. }
  13301. // OldCallback returns the old "callback" field's value of the Wx entity.
  13302. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13303. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13304. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  13305. if !m.op.Is(OpUpdateOne) {
  13306. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  13307. }
  13308. if m.id == nil || m.oldValue == nil {
  13309. return v, errors.New("OldCallback requires an ID field in the mutation")
  13310. }
  13311. oldValue, err := m.oldValue(ctx)
  13312. if err != nil {
  13313. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  13314. }
  13315. return oldValue.Callback, nil
  13316. }
  13317. // ResetCallback resets all changes to the "callback" field.
  13318. func (m *WxMutation) ResetCallback() {
  13319. m.callback = nil
  13320. }
  13321. // SetWxid sets the "wxid" field.
  13322. func (m *WxMutation) SetWxid(s string) {
  13323. m.wxid = &s
  13324. }
  13325. // Wxid returns the value of the "wxid" field in the mutation.
  13326. func (m *WxMutation) Wxid() (r string, exists bool) {
  13327. v := m.wxid
  13328. if v == nil {
  13329. return
  13330. }
  13331. return *v, true
  13332. }
  13333. // OldWxid returns the old "wxid" field's value of the Wx entity.
  13334. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13336. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  13337. if !m.op.Is(OpUpdateOne) {
  13338. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  13339. }
  13340. if m.id == nil || m.oldValue == nil {
  13341. return v, errors.New("OldWxid requires an ID field in the mutation")
  13342. }
  13343. oldValue, err := m.oldValue(ctx)
  13344. if err != nil {
  13345. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  13346. }
  13347. return oldValue.Wxid, nil
  13348. }
  13349. // ResetWxid resets all changes to the "wxid" field.
  13350. func (m *WxMutation) ResetWxid() {
  13351. m.wxid = nil
  13352. }
  13353. // SetAccount sets the "account" field.
  13354. func (m *WxMutation) SetAccount(s string) {
  13355. m.account = &s
  13356. }
  13357. // Account returns the value of the "account" field in the mutation.
  13358. func (m *WxMutation) Account() (r string, exists bool) {
  13359. v := m.account
  13360. if v == nil {
  13361. return
  13362. }
  13363. return *v, true
  13364. }
  13365. // OldAccount returns the old "account" field's value of the Wx entity.
  13366. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13367. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13368. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  13369. if !m.op.Is(OpUpdateOne) {
  13370. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  13371. }
  13372. if m.id == nil || m.oldValue == nil {
  13373. return v, errors.New("OldAccount requires an ID field in the mutation")
  13374. }
  13375. oldValue, err := m.oldValue(ctx)
  13376. if err != nil {
  13377. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  13378. }
  13379. return oldValue.Account, nil
  13380. }
  13381. // ResetAccount resets all changes to the "account" field.
  13382. func (m *WxMutation) ResetAccount() {
  13383. m.account = nil
  13384. }
  13385. // SetNickname sets the "nickname" field.
  13386. func (m *WxMutation) SetNickname(s string) {
  13387. m.nickname = &s
  13388. }
  13389. // Nickname returns the value of the "nickname" field in the mutation.
  13390. func (m *WxMutation) Nickname() (r string, exists bool) {
  13391. v := m.nickname
  13392. if v == nil {
  13393. return
  13394. }
  13395. return *v, true
  13396. }
  13397. // OldNickname returns the old "nickname" field's value of the Wx entity.
  13398. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13400. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  13401. if !m.op.Is(OpUpdateOne) {
  13402. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  13403. }
  13404. if m.id == nil || m.oldValue == nil {
  13405. return v, errors.New("OldNickname requires an ID field in the mutation")
  13406. }
  13407. oldValue, err := m.oldValue(ctx)
  13408. if err != nil {
  13409. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  13410. }
  13411. return oldValue.Nickname, nil
  13412. }
  13413. // ResetNickname resets all changes to the "nickname" field.
  13414. func (m *WxMutation) ResetNickname() {
  13415. m.nickname = nil
  13416. }
  13417. // SetTel sets the "tel" field.
  13418. func (m *WxMutation) SetTel(s string) {
  13419. m.tel = &s
  13420. }
  13421. // Tel returns the value of the "tel" field in the mutation.
  13422. func (m *WxMutation) Tel() (r string, exists bool) {
  13423. v := m.tel
  13424. if v == nil {
  13425. return
  13426. }
  13427. return *v, true
  13428. }
  13429. // OldTel returns the old "tel" field's value of the Wx entity.
  13430. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13432. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  13433. if !m.op.Is(OpUpdateOne) {
  13434. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  13435. }
  13436. if m.id == nil || m.oldValue == nil {
  13437. return v, errors.New("OldTel requires an ID field in the mutation")
  13438. }
  13439. oldValue, err := m.oldValue(ctx)
  13440. if err != nil {
  13441. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  13442. }
  13443. return oldValue.Tel, nil
  13444. }
  13445. // ResetTel resets all changes to the "tel" field.
  13446. func (m *WxMutation) ResetTel() {
  13447. m.tel = nil
  13448. }
  13449. // SetHeadBig sets the "head_big" field.
  13450. func (m *WxMutation) SetHeadBig(s string) {
  13451. m.head_big = &s
  13452. }
  13453. // HeadBig returns the value of the "head_big" field in the mutation.
  13454. func (m *WxMutation) HeadBig() (r string, exists bool) {
  13455. v := m.head_big
  13456. if v == nil {
  13457. return
  13458. }
  13459. return *v, true
  13460. }
  13461. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  13462. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13463. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13464. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  13465. if !m.op.Is(OpUpdateOne) {
  13466. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  13467. }
  13468. if m.id == nil || m.oldValue == nil {
  13469. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  13470. }
  13471. oldValue, err := m.oldValue(ctx)
  13472. if err != nil {
  13473. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  13474. }
  13475. return oldValue.HeadBig, nil
  13476. }
  13477. // ResetHeadBig resets all changes to the "head_big" field.
  13478. func (m *WxMutation) ResetHeadBig() {
  13479. m.head_big = nil
  13480. }
  13481. // SetOrganizationID sets the "organization_id" field.
  13482. func (m *WxMutation) SetOrganizationID(u uint64) {
  13483. m.organization_id = &u
  13484. m.addorganization_id = nil
  13485. }
  13486. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13487. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  13488. v := m.organization_id
  13489. if v == nil {
  13490. return
  13491. }
  13492. return *v, true
  13493. }
  13494. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  13495. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  13496. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13497. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13498. if !m.op.Is(OpUpdateOne) {
  13499. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13500. }
  13501. if m.id == nil || m.oldValue == nil {
  13502. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13503. }
  13504. oldValue, err := m.oldValue(ctx)
  13505. if err != nil {
  13506. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13507. }
  13508. return oldValue.OrganizationID, nil
  13509. }
  13510. // AddOrganizationID adds u to the "organization_id" field.
  13511. func (m *WxMutation) AddOrganizationID(u int64) {
  13512. if m.addorganization_id != nil {
  13513. *m.addorganization_id += u
  13514. } else {
  13515. m.addorganization_id = &u
  13516. }
  13517. }
  13518. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13519. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  13520. v := m.addorganization_id
  13521. if v == nil {
  13522. return
  13523. }
  13524. return *v, true
  13525. }
  13526. // ClearOrganizationID clears the value of the "organization_id" field.
  13527. func (m *WxMutation) ClearOrganizationID() {
  13528. m.organization_id = nil
  13529. m.addorganization_id = nil
  13530. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  13531. }
  13532. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13533. func (m *WxMutation) OrganizationIDCleared() bool {
  13534. _, ok := m.clearedFields[wx.FieldOrganizationID]
  13535. return ok
  13536. }
  13537. // ResetOrganizationID resets all changes to the "organization_id" field.
  13538. func (m *WxMutation) ResetOrganizationID() {
  13539. m.organization_id = nil
  13540. m.addorganization_id = nil
  13541. delete(m.clearedFields, wx.FieldOrganizationID)
  13542. }
  13543. // ClearServer clears the "server" edge to the Server entity.
  13544. func (m *WxMutation) ClearServer() {
  13545. m.clearedserver = true
  13546. m.clearedFields[wx.FieldServerID] = struct{}{}
  13547. }
  13548. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  13549. func (m *WxMutation) ServerCleared() bool {
  13550. return m.ServerIDCleared() || m.clearedserver
  13551. }
  13552. // ServerIDs returns the "server" edge IDs in the mutation.
  13553. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  13554. // ServerID instead. It exists only for internal usage by the builders.
  13555. func (m *WxMutation) ServerIDs() (ids []uint64) {
  13556. if id := m.server; id != nil {
  13557. ids = append(ids, *id)
  13558. }
  13559. return
  13560. }
  13561. // ResetServer resets all changes to the "server" edge.
  13562. func (m *WxMutation) ResetServer() {
  13563. m.server = nil
  13564. m.clearedserver = false
  13565. }
  13566. // Where appends a list predicates to the WxMutation builder.
  13567. func (m *WxMutation) Where(ps ...predicate.Wx) {
  13568. m.predicates = append(m.predicates, ps...)
  13569. }
  13570. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  13571. // users can use type-assertion to append predicates that do not depend on any generated package.
  13572. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  13573. p := make([]predicate.Wx, len(ps))
  13574. for i := range ps {
  13575. p[i] = ps[i]
  13576. }
  13577. m.Where(p...)
  13578. }
  13579. // Op returns the operation name.
  13580. func (m *WxMutation) Op() Op {
  13581. return m.op
  13582. }
  13583. // SetOp allows setting the mutation operation.
  13584. func (m *WxMutation) SetOp(op Op) {
  13585. m.op = op
  13586. }
  13587. // Type returns the node type of this mutation (Wx).
  13588. func (m *WxMutation) Type() string {
  13589. return m.typ
  13590. }
  13591. // Fields returns all fields that were changed during this mutation. Note that in
  13592. // order to get all numeric fields that were incremented/decremented, call
  13593. // AddedFields().
  13594. func (m *WxMutation) Fields() []string {
  13595. fields := make([]string, 0, 14)
  13596. if m.created_at != nil {
  13597. fields = append(fields, wx.FieldCreatedAt)
  13598. }
  13599. if m.updated_at != nil {
  13600. fields = append(fields, wx.FieldUpdatedAt)
  13601. }
  13602. if m.status != nil {
  13603. fields = append(fields, wx.FieldStatus)
  13604. }
  13605. if m.deleted_at != nil {
  13606. fields = append(fields, wx.FieldDeletedAt)
  13607. }
  13608. if m.server != nil {
  13609. fields = append(fields, wx.FieldServerID)
  13610. }
  13611. if m.port != nil {
  13612. fields = append(fields, wx.FieldPort)
  13613. }
  13614. if m.process_id != nil {
  13615. fields = append(fields, wx.FieldProcessID)
  13616. }
  13617. if m.callback != nil {
  13618. fields = append(fields, wx.FieldCallback)
  13619. }
  13620. if m.wxid != nil {
  13621. fields = append(fields, wx.FieldWxid)
  13622. }
  13623. if m.account != nil {
  13624. fields = append(fields, wx.FieldAccount)
  13625. }
  13626. if m.nickname != nil {
  13627. fields = append(fields, wx.FieldNickname)
  13628. }
  13629. if m.tel != nil {
  13630. fields = append(fields, wx.FieldTel)
  13631. }
  13632. if m.head_big != nil {
  13633. fields = append(fields, wx.FieldHeadBig)
  13634. }
  13635. if m.organization_id != nil {
  13636. fields = append(fields, wx.FieldOrganizationID)
  13637. }
  13638. return fields
  13639. }
  13640. // Field returns the value of a field with the given name. The second boolean
  13641. // return value indicates that this field was not set, or was not defined in the
  13642. // schema.
  13643. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  13644. switch name {
  13645. case wx.FieldCreatedAt:
  13646. return m.CreatedAt()
  13647. case wx.FieldUpdatedAt:
  13648. return m.UpdatedAt()
  13649. case wx.FieldStatus:
  13650. return m.Status()
  13651. case wx.FieldDeletedAt:
  13652. return m.DeletedAt()
  13653. case wx.FieldServerID:
  13654. return m.ServerID()
  13655. case wx.FieldPort:
  13656. return m.Port()
  13657. case wx.FieldProcessID:
  13658. return m.ProcessID()
  13659. case wx.FieldCallback:
  13660. return m.Callback()
  13661. case wx.FieldWxid:
  13662. return m.Wxid()
  13663. case wx.FieldAccount:
  13664. return m.Account()
  13665. case wx.FieldNickname:
  13666. return m.Nickname()
  13667. case wx.FieldTel:
  13668. return m.Tel()
  13669. case wx.FieldHeadBig:
  13670. return m.HeadBig()
  13671. case wx.FieldOrganizationID:
  13672. return m.OrganizationID()
  13673. }
  13674. return nil, false
  13675. }
  13676. // OldField returns the old value of the field from the database. An error is
  13677. // returned if the mutation operation is not UpdateOne, or the query to the
  13678. // database failed.
  13679. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13680. switch name {
  13681. case wx.FieldCreatedAt:
  13682. return m.OldCreatedAt(ctx)
  13683. case wx.FieldUpdatedAt:
  13684. return m.OldUpdatedAt(ctx)
  13685. case wx.FieldStatus:
  13686. return m.OldStatus(ctx)
  13687. case wx.FieldDeletedAt:
  13688. return m.OldDeletedAt(ctx)
  13689. case wx.FieldServerID:
  13690. return m.OldServerID(ctx)
  13691. case wx.FieldPort:
  13692. return m.OldPort(ctx)
  13693. case wx.FieldProcessID:
  13694. return m.OldProcessID(ctx)
  13695. case wx.FieldCallback:
  13696. return m.OldCallback(ctx)
  13697. case wx.FieldWxid:
  13698. return m.OldWxid(ctx)
  13699. case wx.FieldAccount:
  13700. return m.OldAccount(ctx)
  13701. case wx.FieldNickname:
  13702. return m.OldNickname(ctx)
  13703. case wx.FieldTel:
  13704. return m.OldTel(ctx)
  13705. case wx.FieldHeadBig:
  13706. return m.OldHeadBig(ctx)
  13707. case wx.FieldOrganizationID:
  13708. return m.OldOrganizationID(ctx)
  13709. }
  13710. return nil, fmt.Errorf("unknown Wx field %s", name)
  13711. }
  13712. // SetField sets the value of a field with the given name. It returns an error if
  13713. // the field is not defined in the schema, or if the type mismatched the field
  13714. // type.
  13715. func (m *WxMutation) SetField(name string, value ent.Value) error {
  13716. switch name {
  13717. case wx.FieldCreatedAt:
  13718. v, ok := value.(time.Time)
  13719. if !ok {
  13720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13721. }
  13722. m.SetCreatedAt(v)
  13723. return nil
  13724. case wx.FieldUpdatedAt:
  13725. v, ok := value.(time.Time)
  13726. if !ok {
  13727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13728. }
  13729. m.SetUpdatedAt(v)
  13730. return nil
  13731. case wx.FieldStatus:
  13732. v, ok := value.(uint8)
  13733. if !ok {
  13734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13735. }
  13736. m.SetStatus(v)
  13737. return nil
  13738. case wx.FieldDeletedAt:
  13739. v, ok := value.(time.Time)
  13740. if !ok {
  13741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13742. }
  13743. m.SetDeletedAt(v)
  13744. return nil
  13745. case wx.FieldServerID:
  13746. v, ok := value.(uint64)
  13747. if !ok {
  13748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13749. }
  13750. m.SetServerID(v)
  13751. return nil
  13752. case wx.FieldPort:
  13753. v, ok := value.(string)
  13754. if !ok {
  13755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13756. }
  13757. m.SetPort(v)
  13758. return nil
  13759. case wx.FieldProcessID:
  13760. v, ok := value.(string)
  13761. if !ok {
  13762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13763. }
  13764. m.SetProcessID(v)
  13765. return nil
  13766. case wx.FieldCallback:
  13767. v, ok := value.(string)
  13768. if !ok {
  13769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13770. }
  13771. m.SetCallback(v)
  13772. return nil
  13773. case wx.FieldWxid:
  13774. v, ok := value.(string)
  13775. if !ok {
  13776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13777. }
  13778. m.SetWxid(v)
  13779. return nil
  13780. case wx.FieldAccount:
  13781. v, ok := value.(string)
  13782. if !ok {
  13783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13784. }
  13785. m.SetAccount(v)
  13786. return nil
  13787. case wx.FieldNickname:
  13788. v, ok := value.(string)
  13789. if !ok {
  13790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13791. }
  13792. m.SetNickname(v)
  13793. return nil
  13794. case wx.FieldTel:
  13795. v, ok := value.(string)
  13796. if !ok {
  13797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13798. }
  13799. m.SetTel(v)
  13800. return nil
  13801. case wx.FieldHeadBig:
  13802. v, ok := value.(string)
  13803. if !ok {
  13804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13805. }
  13806. m.SetHeadBig(v)
  13807. return nil
  13808. case wx.FieldOrganizationID:
  13809. v, ok := value.(uint64)
  13810. if !ok {
  13811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13812. }
  13813. m.SetOrganizationID(v)
  13814. return nil
  13815. }
  13816. return fmt.Errorf("unknown Wx field %s", name)
  13817. }
  13818. // AddedFields returns all numeric fields that were incremented/decremented during
  13819. // this mutation.
  13820. func (m *WxMutation) AddedFields() []string {
  13821. var fields []string
  13822. if m.addstatus != nil {
  13823. fields = append(fields, wx.FieldStatus)
  13824. }
  13825. if m.addorganization_id != nil {
  13826. fields = append(fields, wx.FieldOrganizationID)
  13827. }
  13828. return fields
  13829. }
  13830. // AddedField returns the numeric value that was incremented/decremented on a field
  13831. // with the given name. The second boolean return value indicates that this field
  13832. // was not set, or was not defined in the schema.
  13833. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  13834. switch name {
  13835. case wx.FieldStatus:
  13836. return m.AddedStatus()
  13837. case wx.FieldOrganizationID:
  13838. return m.AddedOrganizationID()
  13839. }
  13840. return nil, false
  13841. }
  13842. // AddField adds the value to the field with the given name. It returns an error if
  13843. // the field is not defined in the schema, or if the type mismatched the field
  13844. // type.
  13845. func (m *WxMutation) AddField(name string, value ent.Value) error {
  13846. switch name {
  13847. case wx.FieldStatus:
  13848. v, ok := value.(int8)
  13849. if !ok {
  13850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13851. }
  13852. m.AddStatus(v)
  13853. return nil
  13854. case wx.FieldOrganizationID:
  13855. v, ok := value.(int64)
  13856. if !ok {
  13857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13858. }
  13859. m.AddOrganizationID(v)
  13860. return nil
  13861. }
  13862. return fmt.Errorf("unknown Wx numeric field %s", name)
  13863. }
  13864. // ClearedFields returns all nullable fields that were cleared during this
  13865. // mutation.
  13866. func (m *WxMutation) ClearedFields() []string {
  13867. var fields []string
  13868. if m.FieldCleared(wx.FieldStatus) {
  13869. fields = append(fields, wx.FieldStatus)
  13870. }
  13871. if m.FieldCleared(wx.FieldDeletedAt) {
  13872. fields = append(fields, wx.FieldDeletedAt)
  13873. }
  13874. if m.FieldCleared(wx.FieldServerID) {
  13875. fields = append(fields, wx.FieldServerID)
  13876. }
  13877. if m.FieldCleared(wx.FieldOrganizationID) {
  13878. fields = append(fields, wx.FieldOrganizationID)
  13879. }
  13880. return fields
  13881. }
  13882. // FieldCleared returns a boolean indicating if a field with the given name was
  13883. // cleared in this mutation.
  13884. func (m *WxMutation) FieldCleared(name string) bool {
  13885. _, ok := m.clearedFields[name]
  13886. return ok
  13887. }
  13888. // ClearField clears the value of the field with the given name. It returns an
  13889. // error if the field is not defined in the schema.
  13890. func (m *WxMutation) ClearField(name string) error {
  13891. switch name {
  13892. case wx.FieldStatus:
  13893. m.ClearStatus()
  13894. return nil
  13895. case wx.FieldDeletedAt:
  13896. m.ClearDeletedAt()
  13897. return nil
  13898. case wx.FieldServerID:
  13899. m.ClearServerID()
  13900. return nil
  13901. case wx.FieldOrganizationID:
  13902. m.ClearOrganizationID()
  13903. return nil
  13904. }
  13905. return fmt.Errorf("unknown Wx nullable field %s", name)
  13906. }
  13907. // ResetField resets all changes in the mutation for the field with the given name.
  13908. // It returns an error if the field is not defined in the schema.
  13909. func (m *WxMutation) ResetField(name string) error {
  13910. switch name {
  13911. case wx.FieldCreatedAt:
  13912. m.ResetCreatedAt()
  13913. return nil
  13914. case wx.FieldUpdatedAt:
  13915. m.ResetUpdatedAt()
  13916. return nil
  13917. case wx.FieldStatus:
  13918. m.ResetStatus()
  13919. return nil
  13920. case wx.FieldDeletedAt:
  13921. m.ResetDeletedAt()
  13922. return nil
  13923. case wx.FieldServerID:
  13924. m.ResetServerID()
  13925. return nil
  13926. case wx.FieldPort:
  13927. m.ResetPort()
  13928. return nil
  13929. case wx.FieldProcessID:
  13930. m.ResetProcessID()
  13931. return nil
  13932. case wx.FieldCallback:
  13933. m.ResetCallback()
  13934. return nil
  13935. case wx.FieldWxid:
  13936. m.ResetWxid()
  13937. return nil
  13938. case wx.FieldAccount:
  13939. m.ResetAccount()
  13940. return nil
  13941. case wx.FieldNickname:
  13942. m.ResetNickname()
  13943. return nil
  13944. case wx.FieldTel:
  13945. m.ResetTel()
  13946. return nil
  13947. case wx.FieldHeadBig:
  13948. m.ResetHeadBig()
  13949. return nil
  13950. case wx.FieldOrganizationID:
  13951. m.ResetOrganizationID()
  13952. return nil
  13953. }
  13954. return fmt.Errorf("unknown Wx field %s", name)
  13955. }
  13956. // AddedEdges returns all edge names that were set/added in this mutation.
  13957. func (m *WxMutation) AddedEdges() []string {
  13958. edges := make([]string, 0, 1)
  13959. if m.server != nil {
  13960. edges = append(edges, wx.EdgeServer)
  13961. }
  13962. return edges
  13963. }
  13964. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13965. // name in this mutation.
  13966. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  13967. switch name {
  13968. case wx.EdgeServer:
  13969. if id := m.server; id != nil {
  13970. return []ent.Value{*id}
  13971. }
  13972. }
  13973. return nil
  13974. }
  13975. // RemovedEdges returns all edge names that were removed in this mutation.
  13976. func (m *WxMutation) RemovedEdges() []string {
  13977. edges := make([]string, 0, 1)
  13978. return edges
  13979. }
  13980. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13981. // the given name in this mutation.
  13982. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  13983. return nil
  13984. }
  13985. // ClearedEdges returns all edge names that were cleared in this mutation.
  13986. func (m *WxMutation) ClearedEdges() []string {
  13987. edges := make([]string, 0, 1)
  13988. if m.clearedserver {
  13989. edges = append(edges, wx.EdgeServer)
  13990. }
  13991. return edges
  13992. }
  13993. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13994. // was cleared in this mutation.
  13995. func (m *WxMutation) EdgeCleared(name string) bool {
  13996. switch name {
  13997. case wx.EdgeServer:
  13998. return m.clearedserver
  13999. }
  14000. return false
  14001. }
  14002. // ClearEdge clears the value of the edge with the given name. It returns an error
  14003. // if that edge is not defined in the schema.
  14004. func (m *WxMutation) ClearEdge(name string) error {
  14005. switch name {
  14006. case wx.EdgeServer:
  14007. m.ClearServer()
  14008. return nil
  14009. }
  14010. return fmt.Errorf("unknown Wx unique edge %s", name)
  14011. }
  14012. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14013. // It returns an error if the edge is not defined in the schema.
  14014. func (m *WxMutation) ResetEdge(name string) error {
  14015. switch name {
  14016. case wx.EdgeServer:
  14017. m.ResetServer()
  14018. return nil
  14019. }
  14020. return fmt.Errorf("unknown Wx edge %s", name)
  14021. }